class Camunda::BpmnXML

Used to parse bpmn file during bpmn_classes generator to create Camunda job class based on process id

Public Class Methods

new(io_or_string) click to toggle source

@param io_or_string [IO,String] valid xml string for bpmn file

# File lib/camunda/bpmn_xml.rb, line 4
def initialize(io_or_string)
  @doc = Nokogiri::XML(io_or_string)
end

Public Instance Methods

class_names_with_same_bpmn_id_as_topic() click to toggle source

We may have tasks with different topics. Returns classes with topics which are the same as the BPMN process id @return [Array<String>] class names which should be implemented @example

["DoSomething"]
# 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() click to toggle source

creates a new instance of Camunda::BpmnXML::Task

# 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() click to toggle source

@return [Array<String>] array of modularized class names @example

["CamundaWorkflow::DoSomething"]
# 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() click to toggle source

@return [String] Id (process definition key) of the BPMN process @example

"CamundaWorkflow"
# File lib/camunda/bpmn_xml.rb, line 17
def module_name
  @doc.xpath('/bpmn:definitions/bpmn:process').first['id']
end
to_s() click to toggle source

Friendly name of this BPMN file is the module name @return [String] module name

# File lib/camunda/bpmn_xml.rb, line 10
def to_s
  module_name
end
topics() click to toggle source

@return [Array<String>] topics in this BPMN file

# File lib/camunda/bpmn_xml.rb, line 49
def topics
  @doc.xpath('//*[@camunda:topic]').map { |node| node.attribute('topic').value }.uniq
end

Private Instance Methods

tasks_with_same_bpmn_id_as_topic() click to toggle source

We may have tasks with different topics. @return [Array<Camunda::BpmnXML::Task>] tasks with topics which are the same as the BPMN process id

# File lib/camunda/bpmn_xml.rb, line 57
def tasks_with_same_bpmn_id_as_topic
  external_tasks.select { |task| task.topic == module_name }
end