Class: Camunda::BpmnXML
- Inherits:
-
Object
- Object
- Camunda::BpmnXML
- Defined in:
- lib/camunda/bpmn_xml.rb
Overview
Used to parse bpmn file during bpmn_classes generator to create Camunda job class based on process id
Defined Under Namespace
Classes: Task
Instance Method Summary collapse
-
#class_names_with_same_bpmn_id_as_topic ⇒ Array<String>
We may have tasks with different topics.
-
#external_tasks ⇒ Object
creates a new instance of Camunda::BpmnXML::Task.
-
#initialize(io_or_string) ⇒ BpmnXML
constructor
A new instance of BpmnXML.
-
#modularized_class_names ⇒ Array<String>
Array of modularized class names.
-
#module_name ⇒ String
Id (process definition key) of the BPMN process.
-
#to_s ⇒ String
Friendly name of this BPMN file is the module name.
-
#topics ⇒ Array<String>
Topics in this BPMN file.
Constructor Details
#initialize(io_or_string) ⇒ BpmnXML
Returns a new instance of BpmnXML.
4 5 6 |
# File 'lib/camunda/bpmn_xml.rb', line 4 def initialize(io_or_string) @doc = Nokogiri::XML(io_or_string) end |
Instance Method Details
#class_names_with_same_bpmn_id_as_topic ⇒ Array<String>
We may have tasks with different topics. Returns classes with topics which are the same as the BPMN process id
37 38 39 |
# File 'lib/camunda/bpmn_xml.rb', line 37 def class_names_with_same_bpmn_id_as_topic tasks_with_same_bpmn_id_as_topic.map(&:class_name) end |
#external_tasks ⇒ Object
creates a new instance of Camunda::BpmnXML::Task
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/camunda/bpmn_xml.rb', line 22 def external_tasks @doc.xpath('(//bpmn:serviceTask[@camunda:type="external"]|//bpmn:sendTask[@camunda:type="external"])').map do |task| Task.new(task) end + @doc.xpath('//bpmn:endEvent/bpmn:messageEventDefinition[@camunda:type="external"]').map do |child_node| task = child_node.parent.dup task["topic"] = child_node["topic"] Task.new(task) end end |
#modularized_class_names ⇒ Array<String>
Returns array of modularized class names.
44 45 46 |
# File 'lib/camunda/bpmn_xml.rb', line 44 def modularized_class_names class_names_with_same_bpmn_id_as_topic.map { |name| "#{module_name}::#{name}" } end |
#module_name ⇒ String
Returns Id (process definition key) of the BPMN process.
17 18 19 |
# File 'lib/camunda/bpmn_xml.rb', line 17 def module_name @doc.xpath('/bpmn:definitions/bpmn:process').first['id'] end |
#to_s ⇒ String
Friendly name of this BPMN file is the module name
10 11 12 |
# File 'lib/camunda/bpmn_xml.rb', line 10 def to_s module_name end |
#topics ⇒ Array<String>
Returns topics in this BPMN file.
49 50 51 |
# File 'lib/camunda/bpmn_xml.rb', line 49 def topics @doc.xpath('//*[@camunda:topic]').map { |node| node.attribute('topic').value }.uniq end |