Class: AssociationEnd

Inherits:
Tag
  • Object
show all
Defined in:
lib/xmimodel/association_end.rb

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(xmls, index, parent_tag) ⇒ AssociationEnd

Returns a new instance of AssociationEnd.



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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/xmimodel/association_end.rb', line 40

def initialize(xmls, index, parent_tag)		
	super(xmls[index], parent_tag)

	@xml_a = xmls[0]
	@xml_b = xmls[1]

	@xmi_model = parent_tag.parent_tag

	@participant_id = @xml.attribute("participant").to_s

	# argoUML
	if @participant_id.nil? or @participant_id.empty?
		c = @xml.at_xpath("./UML:AssociationEnd.participant/UML:Class")			
		@participant_id = c.attribute("xmi.idref").to_s unless c.nil?
	end

	@name = @xml.attribute("name").to_s

	if @name.empty?
		@name = index == 0 ? "EndA" : "EndB"
	end

	@visibility = @xml.attribute("visibility").to_s
	@is_navigable = @xml.attribute("isNavigable").to_s
	@is_specification = @xml.attribute("isSpecification").to_s
	@ordering = @xml.attribute("ordering").to_s
	@aggregation = @xml.attribute("aggregation").to_s
	@target_scope = @xml.attribute("targetScope").to_s
	@changeability = @xml.attribute("changeability").to_s

	@multiplicity_range = XmiHelper.multiplicity_range(@xml)

	@stereotypes = Array.new
	stereotype_id = @xml.attribute("stereotype").to_s
	if !stereotype_id.empty?
		stereotype = XmiHelper.stereotype_by_id(@xml, stereotype_id)
		stereotype = Stereotype.new(stereotype, self)
		@stereotypes << stereotype			
	end
	XmiHelper.stereotypes(@xml).each do |uml_stereotype|
		stereotype = Stereotype.new(uml_stereotype, self)
		@stereotypes << stereotype
	end	

	@tagged_values = Array.new
	XmiHelper.tagged_values(@xml).each do |uml_tagged_value|
		tagged_value = TaggedValue.new(uml_tagged_value, self)
		@tagged_values << tagged_value
	end		
end

Instance Attribute Details

#aggregationString (readonly)

Returns:

  • (String)


26
27
28
# File 'lib/xmimodel/association_end.rb', line 26

def aggregation
  @aggregation
end

#changeabilityString (readonly)

Returns:

  • (String)


32
33
34
# File 'lib/xmimodel/association_end.rb', line 32

def changeability
  @changeability
end

#is_navigableString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/xmimodel/association_end.rb', line 14

def is_navigable
  @is_navigable
end

#is_specificationString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/xmimodel/association_end.rb', line 17

def is_specification
  @is_specification
end

#multiplicity_rangeString (readonly)

Returns:

  • (String)


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

def multiplicity_range
  @multiplicity_range
end

#nameString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/xmimodel/association_end.rb', line 8

def name
  @name
end

#orderingString (readonly)

Returns:

  • (String)


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

def ordering
  @ordering
end

#stereotypesArray<Stereotype> (readonly)

Returns Association end stereotypes.

Returns:

  • (Array<Stereotype>)

    Association end stereotypes.



35
36
37
# File 'lib/xmimodel/association_end.rb', line 35

def stereotypes
  @stereotypes
end

#tagged_valuesArray<TaggedValue> (readonly)

Returns Association end tagged values.

Returns:

  • (Array<TaggedValue>)

    Association end tagged values.



38
39
40
# File 'lib/xmimodel/association_end.rb', line 38

def tagged_values
  @tagged_values
end

#target_scopeString (readonly)

Returns:

  • (String)


29
30
31
# File 'lib/xmimodel/association_end.rb', line 29

def target_scope
  @target_scope
end

#visibilityString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/xmimodel/association_end.rb', line 11

def visibility
  @visibility
end

Instance Method Details

#==(obj) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/xmimodel/association_end.rb', line 97

def ==(obj)
	return false if obj.nil?
	if String == obj.class
		@name == obj
	elsif AssociationEnd == obj.class
   		@name == obj.name && participant.full_name == obj.participant.full_name
   	else
   		return false
   	end
end

#full_nameString

Returns:

  • (String)


123
124
125
# File 'lib/xmimodel/association_end.rb', line 123

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

#participantClazz

Returns:



92
93
94
95
# File 'lib/xmimodel/association_end.rb', line 92

def participant
	return nil if @participant_id.nil? or @participant_id.empty?
	participant = @xmi_model.class_by_id(@participant_id)
end

#stereotype_by_name(name) ⇒ Stereotype

Returns:



109
110
111
112
113
# File 'lib/xmimodel/association_end.rb', line 109

def stereotype_by_name(name)
	stereotype = @stereotypes.select{|obj| obj == name}
	return stereotype[0] if !stereotype.nil? && stereotype.size > 0
	nil		
end

#tagged_value_by_name(tagged_value_name) ⇒ TaggedValue

Returns:



116
117
118
119
120
# File 'lib/xmimodel/association_end.rb', line 116

def tagged_value_by_name(tagged_value_name)
	tagged_value = @tagged_values.select{|obj| obj.name == tagged_value_name}
	return tagged_value[0] if !tagged_value.nil? && tagged_value.size > 0
	nil
end

#to_sString

Returns:

  • (String)


128
129
130
# File 'lib/xmimodel/association_end.rb', line 128

def to_s
	"AssociationEnd[#{name} (#{participant.full_name}])"
end