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

Returns a new instance of ActivityGraph.


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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/xmimodel/activity_graph.rb', line 25

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
		@initial_state = pseudo_state if pseudo_state.is_initial_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

	@states = @pseudo_states.concat(@action_states).concat(@final_states)

	@states.each do |state|

		state.transitions = transitions_by_source_id(state.id)

		state.transitions.each do |transition|
			transition.source = state			
			
			target = state_by_id(transition.target_id)

			target.from_transitions << transition
			transition.target = target

			state.targets << target
		end
	end
end

Instance Attribute Details

#action_statesObject (readonly)

Returns the value of attribute action_states


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

def action_states
  @action_states
end

#final_statesObject (readonly)

Returns the value of attribute final_states


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

def final_states
  @final_states
end

#initial_stateObject (readonly)

Returns the value of attribute initial_state


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

def initial_state
  @initial_state
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


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

def pseudo_states
  @pseudo_states
end

#statesObject (readonly)

Returns the value of attribute states


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

def states
  @states
end

#transitionsObject (readonly)

Returns the value of attribute transitions


23
24
25
# File 'lib/xmimodel/activity_graph.rb', line 23

def transitions
  @transitions
end

Instance Method Details

#full_nameObject


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

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

#state_by_id(state_id) ⇒ Object


104
105
106
107
# File 'lib/xmimodel/activity_graph.rb', line 104

def state_by_id(state_id)
	objs = @states.select{|obj| obj.id == state_id}
	(!objs.nil? && objs.size > 0) ? objs[0] : nil
end

#state_by_name(state_name, name_state = nil) ⇒ Object


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/xmimodel/activity_graph.rb', line 85

def state_by_name(state_name, name_state=nil)

	if name_state.nil?
		return @states.select{|obj| obj.name == state_name}
	else
		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
	end
	nil
end

#to_sObject


81
82
83
# File 'lib/xmimodel/activity_graph.rb', line 81

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

#transition_by_source_target_ids(source_id, target_id) ⇒ Object


113
114
115
116
# File 'lib/xmimodel/activity_graph.rb', line 113

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

#transitions_by_source_id(source) ⇒ Object


109
110
111
# File 'lib/xmimodel/activity_graph.rb', line 109

def transitions_by_source_id(source)
	objs = @transitions.select{|obj| obj.source_id == source}
end