Class: MergeStereotypes

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

Instance Method Summary collapse

Methods inherited from Merge

#check, #check_change_propertie, #merge

Constructor Details

#initialize(name, from_tag, to_tag) ⇒ MergeStereotypes

Returns a new instance of MergeStereotypes.



5
6
7
8
9
10
# File 'lib/xmimerge/merge_stereotypes.rb', line 5

def initialize(name, from_tag, to_tag)
  super()
  @name = name
  @from_tag = from_tag
  @to_tag = to_tag
end

Instance Method Details

#check_changes(from_stereotype) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/xmimerge/merge_stereotypes.rb', line 22

def check_changes(from_stereotype)

  @log.debug("Checking Stereotype of #{@name} #{from_stereotype.name}...")

  to_stereotype = @to_tag.stereotype_by_name(from_stereotype.name)

  if to_stereotype.nil?
    new_stereotype from_stereotype
  end  
end

#check_removedObject



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
76
77
78
79
80
# File 'lib/xmimerge/merge_stereotypes.rb', line 49

def check_removed
  @to_tag.stereotypes.each do |to_stereotype|

    #puts "Xml stereotype: #{to_stereotype.xml}"
    #puts "Xml stereotype parent: #{to_stereotype.xml.parent}\n\n"  

    ok = false
    @from_tag.stereotypes.each do |from_stereotype|
      if to_stereotype.name == from_stereotype.name
        ok = true
        break
      end
    end
    if !ok    
      command = "\t- #{@name}Stereotype #{@from_tag.full_name} {'#{to_stereotype.name}'}"
      @commands.add_command_to_buffer(command)
      unless @only_check 
        if @commands.has_command?(command)
                    
          to_stereotype.xml.inner_html = "asdasd"
          @to_tag.stereotypes.delete(to_stereotype)

          #puts "testando: #{to_stereotype.xml}"
          #puts "testando: #{@to_tag.xml}"
          @log.info "[OK] #{command}"
        else
          @log.debug "[NOT] #{command}"
        end
      end
    end
  end    
end

#new_stereotype(from_stereotype) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/xmimerge/merge_stereotypes.rb', line 33

def new_stereotype(from_stereotype)

  @log.debug("New Stereotype of #{@name} #{from_stereotype.name}...")

  command = "\t+ #{@name}Stereotype #{@from_tag.full_name} {'#{from_stereotype.name}'}"
  @commands.add_command_to_buffer(command)
  unless @only_check 
    if @commands.has_command?(command)
      @to_tag.add_xml_stereotype(from_stereotype.xml)
      @log.info "[OK] #{command}"
    else
      @log.debug "[NOT] #{command}"
    end
  end  
end

#verifyObject



12
13
14
15
16
17
18
19
20
# File 'lib/xmimerge/merge_stereotypes.rb', line 12

def verify

  @from_tag.stereotypes.each do |from_stereotype|
    check_changes(from_stereotype)
  end

  check_removed

end