Class: ActivityGraph

Inherits:
Tag
  • Object
show all
Defined in:
lib/xmimodel/activity_graph.rb

Overview

In umbrelo ActivityGraph is not represented by tag ‘UML:ActivityGraph’. It’s represented by tag diagram inside of XMI.extension.

Instance Attribute Summary collapse

Attributes inherited from Tag

#id, #parent_tag, #xml

Instance Method Summary collapse

Methods inherited from Tag

#xml_root

Constructor Details

#initialize(xml, parent_tag) ⇒ ActivityGraph



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/xmimodel/activity_graph.rb', line 23

def initialize(xml, parent_tag)
  super(xml, parent_tag)

  @use_case = parent_tag.parent_tag
  
  @id = xml.attribute("xmi.id").to_s
  @name = xml.attribute("name").to_s

  @pseudo_states = Array.new
  XmiHelper.pseudo_states(xml).each do |uml|
    pseudo_state = PseudoState.new(uml, self)
    @pseudo_states << pseudo_state
  end

  @action_states = Array.new
  XmiHelper.action_states(xml).each do |uml|
    action_state = ActionState.new(uml, self)
    @action_states << action_state
  end  

  @final_states = Array.new
  XmiHelper.final_states(xml).each do |uml|
    final_state = FinalState.new(uml, self)
    @final_states << final_state
  end

  @transitions = Array.new
  XmiHelper.transitions(xml).each do |uml|
    transition = Transition.new(uml, self)
    @transitions << transition
  end      
end

Instance Attribute Details

#action_statesObject (readonly)

Returns the value of attribute action_states.



19
20
21
# File 'lib/xmimodel/activity_graph.rb', line 19

def action_states
  @action_states
end

#final_statesObject (readonly)

Returns the value of attribute final_states.



20
21
22
# File 'lib/xmimodel/activity_graph.rb', line 20

def final_states
  @final_states
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/xmimodel/activity_graph.rb', line 16

def name
  @name
end

#pseudo_statesObject (readonly)

Returns the value of attribute pseudo_states.



18
19
20
# File 'lib/xmimodel/activity_graph.rb', line 18

def pseudo_states
  @pseudo_states
end

#transitionsObject (readonly)

Returns the value of attribute transitions.



21
22
23
# File 'lib/xmimodel/activity_graph.rb', line 21

def transitions
  @transitions
end

Instance Method Details

#full_nameObject



56
57
58
# File 'lib/xmimodel/activity_graph.rb', line 56

def full_name
  "#{@use_case.full_name}::#{@name}"
end

#state_by_name(name_state, state_name) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/xmimodel/activity_graph.rb', line 64

def state_by_name(name_state, state_name)
  case name_state
    when "PseudoState"
      state = @pseudo_states.select{|obj| obj.name == state_name}
    when "ActionState"
      state = @action_states.select{|obj| obj.name == state_name}
    when "FinalState"
      state = @final_states.select{|obj| obj.name == state_name}
  end
  return state[0] if !state.nil? && state.size > 0
  nil
end

#to_sObject



60
61
62
# File 'lib/xmimodel/activity_graph.rb', line 60

def to_s
  "ActivityGraph[#{full_name}]"
end

#transition_by_source_target_ids(source, target) ⇒ Object



77
78
79
80
# File 'lib/xmimodel/activity_graph.rb', line 77

def transition_by_source_target_ids(source, target)
  objs = @transitions.select{|obj| obj.source == source && obj.target == target}
  (!objs.nil? && objs.size > 0) ? objs[0] : nil
end