Class: CPEE::Transformation::Source::BPMN2
- Inherits:
-
Object
- Object
- CPEE::Transformation::Source::BPMN2
- Defined in:
- lib/cpee/transformation/bpmn2.rb
Instance Attribute Summary collapse
-
#dataelements ⇒ Object
readonly
Returns the value of attribute dataelements.
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#traces ⇒ Object
readonly
Returns the value of attribute traces.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#extract_dataelements(doc) ⇒ Object
}}}.
-
#extract_endpoints(doc) ⇒ Object
}}}.
-
#extract_nodelink(doc) ⇒ Object
}}}.
-
#initialize(xml) ⇒ BPMN2
constructor
{{{.
Constructor Details
#initialize(xml) ⇒ BPMN2
{{{
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cpee/transformation/bpmn2.rb', line 31 def initialize(xml) #{{{ Node.class_variable_set(:@@niceid, {}) @tree = Tree.new @start = nil doc = XML::Smart.string(xml) doc.register_namespace 'bm', "http://www.omg.org/spec/BPMN/20100524/MODEL" @dataelements = {} @endpoints = {} @graph = Graph.new extract_dataelements(doc) extract_endpoints(doc) extract_nodelink(doc) if @start.nil? @traces = Traces.new [[]] else @traces = Traces.new [[@start]] end end |
Instance Attribute Details
#dataelements ⇒ Object (readonly)
Returns the value of attribute dataelements.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def dataelements @dataelements end |
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def endpoints @endpoints end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def graph @graph end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def start @start end |
#traces ⇒ Object (readonly)
Returns the value of attribute traces.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def traces @traces end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
29 30 31 |
# File 'lib/cpee/transformation/bpmn2.rb', line 29 def tree @tree end |
Instance Method Details
#extract_dataelements(doc) ⇒ Object
}}}
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cpee/transformation/bpmn2.rb', line 55 def extract_dataelements(doc) #{{{ doc.find("/bm:definitions/bm:process/bm:property[bm:dataState/@name='cpee:dataelement']").each do |ref| if ref.attributes['itemSubjectRef'] doc.find("/bm:definitions/bm:itemDefinition[@id=\"" + ref.attributes['itemSubjectRef'] + "\"]").each do |sref| @dataelements[ref.attributes['name']] = sref.attributes['structureRef'].to_s end else @dataelements[ref.attributes['name']] = '' end end end |
#extract_endpoints(doc) ⇒ Object
}}}
67 68 69 70 71 72 73 |
# File 'lib/cpee/transformation/bpmn2.rb', line 67 def extract_endpoints(doc) #{{{ doc.find("/bm:definitions/bm:process/bm:property[bm:dataState/@name='cpee:endpoint']/@itemSubjectRef").each do |ref| doc.find("/bm:definitions/bm:itemDefinition[@id=\"" + ref.value + "\"]/@structureRef").each do |sref| @endpoints[ref.value] = sref.value end end end |
#extract_nodelink(doc) ⇒ Object
}}}
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/cpee/transformation/bpmn2.rb', line 75 def extract_nodelink(doc) #{{{ doc.find("/bm:definitions/bm:process/bm:*[@id and @name and not(@itemSubjectRef) and not(name()='sequenceFlow')]").each do |e| n = Node.new(self.object_id,e.attributes['id'],e.qname.name.to_sym,e.attributes['name'].strip,e.find('count(bm:incoming)'),e.find('count(bm:outgoing)')) if e.attributes['scriptFormat'] != '' n.script_type = e.attributes['scriptFormat'] end e.find("bm:property[@name='cpee:endpoint']/@itemSubjectRef").each do |ep| n.endpoints << ep.value end e.find("bm:property[@name='cpee:method']/@itemSubjectRef").each do |m| n.methods << m.value end e.find("bm:script").each do |s| n.script ||= '' n.script << s.text.strip end e.find("bm:ioSpecification/bm:dataInput").each do |a| name = a.attributes['name'] value = a.attributes['itemSubjectRef'] unless name.nil? if @dataelements.keys.include?(value) n.arguments[name] = 'data.' + value else n.arguments[name] = value end end end e.find("bm:ioSpecification/bm:dataOutput").each do |a| ref = a.attributes['id'] e.find("bm:dataOutputAssociation[bm:sourceRef=\"#{ref}\"]").each do |d| n.script_var = ref n.script_id = d.find("string(bm:targetRef)") end end @graph.add_node n @start = n if n.type == :startEvent && @start == nil end # extract all sequences to a links doc.find("/bm:definitions/bm:process/bm:sequenceFlow").each do |e| source = e.attributes['sourceRef'] target = e.attributes['targetRef'] cond = e.find('bm:conditionExpression') @graph.add_link Link.new(source, target, cond.empty? ? nil : cond.first.text.strip) end @graph.clean_up do |node| if node.type == :scriptTask && (x = @graph.find_script_id(node.id)).any? x.each do |k,n| n.script = node.script n.script_type = node.script_type end true else false end end end |