Class: MergeStates

Inherits:
Merge
  • Object
show all
Defined in:
lib/xmimerge/merge_states.rb

Instance Method Summary collapse

Methods inherited from Merge

#check, #check_change_propertie, #merge

Constructor Details

#initialize(name_state, method_name, from_activity_graph, to_activity_graph) ⇒ MergeStates

Returns a new instance of MergeStates.



7
8
9
10
11
12
13
# File 'lib/xmimerge/merge_states.rb', line 7

def initialize(name_state, method_name, from_activity_graph, to_activity_graph)
	super()
	@name_state = name_state
	@from_activity_graph = from_activity_graph
	@to_activity_graph = to_activity_graph
	@method_name = method_name
end

Instance Method Details

#check_changes(from_state) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/xmimerge/merge_states.rb', line 24

def check_changes(from_state)

	to_state = @to_activity_graph.state_by_name(@name_state, from_state.name)

	@log.debug("Checking #{@name_state} #{from_state.full_name}")

	if to_state.nil?
		new_obj from_state
	else
		check_existing(from_state, to_state)
	end		
end

#check_existing(from_action_state, to_action_state) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/xmimerge/merge_states.rb', line 42

def check_existing(from_action_state, to_action_state)

	# Stereotypes		
	merge = MergeStereotypes.new(@name_state, from_action_state, to_action_state)
	@only_check ? merge.check : merge.merge

	# TaggedValues
	merge = MergeTaggedValues.new(@name_state, from_action_state, to_action_state)
	@only_check ? merge.check : merge.merge		
end

#check_removedObject



53
54
55
56
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 'lib/xmimerge/merge_states.rb', line 53

def check_removed

	@log.debug("Checking Removed #{@name_state}...")

	@to_activity_graph.send(@method_name).each do |to_action_state|
		
		ok = false
		@from_activity_graph.send(@method_name).each do |from_action_state|

			if from_action_state.name == to_action_state.name
				ok = true
				break
			end
		end
		if !ok
			@log.debug("#{@name_state} Removed: #{to_action_state.full_name}")				
			command = "- #{@name_state} #{to_action_state.full_name}"
			@commands.add_command_to_buffer(command)
			unless @only_check 
				if @commands.has_command?(command)
					@log.info "[OK] #{command}"
				else
					#@log.info "[NOT] #{command}"
				end
			end
		end
	end			
end

#new_obj(from_action_state) ⇒ Object



37
38
39
40
# File 'lib/xmimerge/merge_states.rb', line 37

def new_obj(from_action_state)
	command = "+ #{@name_state} #{from_action_state.full_name}"
	@commands.add_command_to_buffer(command)
end

#verifyObject



15
16
17
18
19
20
21
22
# File 'lib/xmimerge/merge_states.rb', line 15

def verify

	@from_activity_graph.send(@method_name).each do |state|
		check_changes state
	end		

	check_removed
end