Class: MergeActivityGraphs

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

Instance Method Summary collapse

Methods inherited from Merge

#check, #check_change_propertie, #merge

Constructor Details

#initialize(from_use_case, to_use_case) ⇒ MergeActivityGraphs

Returns a new instance of MergeActivityGraphs.



9
10
11
12
13
# File 'lib/xmimerge/merge_activity_graphs.rb', line 9

def initialize(from_use_case, to_use_case)
  super()
  @from_use_case = from_use_case
  @to_use_case = to_use_case
end

Instance Method Details

#check_changes(from_activity_graph) ⇒ Object



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

def check_changes(from_activity_graph)

  @log.info("Checking Activity Graph #{from_activity_graph.full_name}")

  to_activity_graph = @to_use_case.activity_graphs_by_name(from_activity_graph.name)

  if to_activity_graph.nil?
    new_obj to_activity_graph
  else
    check_existing(from_activity_graph, to_activity_graph)
  end  
end

#check_existing(from_activity_graph, to_activity_graph) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/xmimerge/merge_activity_graphs.rb', line 42

def check_existing(from_activity_graph, to_activity_graph)

  @log.debug("Checking Existing Activity Graph: #{from_activity_graph.full_name}")

  # ActionState
  merge = MergeActionStates.new(from_activity_graph, to_activity_graph)
  @only_check ? merge.check : merge.merge

  # FinalState
  merge = MergeFinalStates.new(from_activity_graph, to_activity_graph)
  @only_check ? merge.check : merge.merge

  # PseudoState
  merge = MergePseudoStates.new(from_activity_graph, to_activity_graph)
  @only_check ? merge.check : merge.merge

  # Transition
  merge = MergeTransitions.new(from_activity_graph, to_activity_graph)
  @only_check ? merge.check : merge.merge  
end

#check_removedObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/xmimerge/merge_activity_graphs.rb', line 63

def check_removed

  @log.debug("Checking removed Activity Graph...")

  @to_use_case.activity_graphs.each do |to_activity_graph|
    
    ok = false
    @from_use_case.activity_graphs.each do |from_activity_graph|

      if from_activity_graph.name == to_activity_graph.name
        ok = true
        break
      end
    end
    if !ok
      @log.info("Activity Graph Removed: #{to_activity_graph.full_name}")        
      command = "- ActivityGraph #{to_activity_graph.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_activity_graph) ⇒ Object



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

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

#verifyObject



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

def verify

  @from_use_case.activity_graphs.each do |activity_graphs|
    check_changes activity_graphs
  end    

  check_removed
end