Class: ActivityGraph

Inherits:
Object
  • 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

Instance Method Summary collapse

Constructor Details

#initialize(xml, parent) ⇒ ActivityGraph

Returns a new instance of 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
# File 'lib/xmimodel/activity_graph.rb', line 23

def initialize(xml, parent)
	@xml = xml
	@use_case = parent.parent
	
	@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

#idObject (readonly)

Returns the value of attribute id.



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

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

#xmlObject (readonly)

Returns the value of attribute xml.



13
14
15
# File 'lib/xmimodel/activity_graph.rb', line 13

def xml
  @xml
end

Instance Method Details

#full_nameObject



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

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

#state_by_name(name_state, state_name) ⇒ Object



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

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



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

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

#transition_by_source_target_ids(source, target) ⇒ Object



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

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