Class: ProcessEngine::Parser::XmlNode

Inherits:
Object
  • Object
show all
Defined in:
app/models/process_engine/parser/xml_node.rb

Constant Summary collapse

TYPES_GATEWAY =
%w(exclusiveGateway parallelGateway inclusiveGateway complexGateway)
TYPES_EVENT =
%w(startEvent endEvent)
TYPES_TASK =
%w(scriptTask userTask)
TYPES_FLOW =
%w(sequenceFlow)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ XmlNode

Returns a new instance of XmlNode.



9
10
11
12
13
14
# File 'app/models/process_engine/parser/xml_node.rb', line 9

def initialize(element)
  @id = element["id"]
  @name = element["name"]
  @node_type = element.name
  @element = element
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



7
8
9
# File 'app/models/process_engine/parser/xml_node.rb', line 7

def element
  @element
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'app/models/process_engine/parser/xml_node.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'app/models/process_engine/parser/xml_node.rb', line 7

def name
  @name
end

#node_typeObject (readonly)

Returns the value of attribute node_type.



7
8
9
# File 'app/models/process_engine/parser/xml_node.rb', line 7

def node_type
  @node_type
end

Class Method Details

.factory(element) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/models/process_engine/parser/xml_node.rb', line 57

def factory(element)
  case element.name
  when "startEvent"
    ProcessEngine::Parser::StartEvent.new(element)
  when "endEvent"
    ProcessEngine::Parser::EndEvent.new(element)
  when "userTask"
    ProcessEngine::Parser::UserTask.new(element)
  when "scriptTask"
    ProcessEngine::Parser::ScriptTask.new(element)
  when "parallelGateway"
    ProcessEngine::Parser::ParallelGateway.new(element)
  when "exclusiveGateway"
    ProcessEngine::Parser::ExclusiveGateway.new(element)
  when "complexGateway"
    ProcessEngine::Parser::ComplexGateway.new(element)
  when "inclusiveGateway"
    ProcessEngine::Parser::InclusiveGateway.new(element)
  when "sequenceFlow"
    ProcessEngine::Parser::SequenceFlow.new(element)
  else
    nil
  end
end

Instance Method Details

#documentationObject



28
29
30
# File 'app/models/process_engine/parser/xml_node.rb', line 28

def documentation
  element.at_xpath("bpmn2:documentation").try(:content)
end

#extension_elementsObject



24
25
26
# File 'app/models/process_engine/parser/xml_node.rb', line 24

def extension_elements
  raise "Not imlpmented"
end

#incoming_stringsObject



16
17
18
# File 'app/models/process_engine/parser/xml_node.rb', line 16

def incoming_strings
  element.xpath("bpmn2:incoming").map(&:content)
end

#outgoing_stringsObject



20
21
22
# File 'app/models/process_engine/parser/xml_node.rb', line 20

def outgoing_strings
  element.xpath("bpmn2:outgoing").map(&:content)
end

#to_hObject



48
49
50
51
52
53
54
# File 'app/models/process_engine/parser/xml_node.rb', line 48

def to_h
  {
    node_id: id,
    node_type: node_type,
    name: name
  }
end

#type_event?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/process_engine/parser/xml_node.rb', line 36

def type_event?
  TYPES_EVENT.include?(node_type)
end

#type_flow?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/process_engine/parser/xml_node.rb', line 44

def type_flow?
  TYPES_FLOW.include?(node_type)
end

#type_gateway?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/process_engine/parser/xml_node.rb', line 32

def type_gateway?
  TYPES_GATEWAY.include?(node_type)
end

#type_task?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/models/process_engine/parser/xml_node.rb', line 40

def type_task?
  TYPES_TASK.include?(node_type)
end