Class: Archimate::DataModel::Relationship
- Inherits:
-
Object
- Object
- Archimate::DataModel::Relationship
show all
- Includes:
- Comparison, Referenceable
- Defined in:
- lib/archimate/data_model/relationship.rb
Overview
A base relationship type that can be extended by concrete ArchiMate types.
Note that RelationshipType is abstract, so one must have derived types of this type. this is indicated in xml by having a tag name of “relationship” and an attribute of xsi:type=“AccessRelationship” where AccessRelationship is a derived type from RelationshipType.
Direct Known Subclasses
Archimate::DataModel::Relationships::Access, Archimate::DataModel::Relationships::Aggregation, Archimate::DataModel::Relationships::AndJunction, Archimate::DataModel::Relationships::Assignment, Archimate::DataModel::Relationships::Association, Archimate::DataModel::Relationships::Composition, Archimate::DataModel::Relationships::Flow, Archimate::DataModel::Relationships::Influence, Archimate::DataModel::Relationships::OrJunction, Archimate::DataModel::Relationships::Realization, Archimate::DataModel::Relationships::Serving, Archimate::DataModel::Relationships::Specialization, Archimate::DataModel::Relationships::Triggering
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_reference, #destroy, #model, #references, #remove_reference, #replace_with
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #initialize, #inspect, #pretty_print, #to_h
Instance Attribute Details
44
|
# File 'lib/archimate/data_model/relationship.rb', line 44
model_attr :access_type, default: nil
|
#derived ⇒ Boolean
Returns this is a derived relation if true.
47
|
# File 'lib/archimate/data_model/relationship.rb', line 47
model_attr :derived, default: false
|
26
|
# File 'lib/archimate/data_model/relationship.rb', line 26
model_attr :documentation, writable: true, default: nil
|
#id ⇒ String
20
|
# File 'lib/archimate/data_model/relationship.rb', line 20
model_attr :id
|
23
|
# File 'lib/archimate/data_model/relationship.rb', line 23
model_attr :name, default: nil
|
#properties ⇒ Array<AnyElement>, ...
model_attr :other_elements model_attr :other_attributes
33
|
# File 'lib/archimate/data_model/relationship.rb', line 33
model_attr :properties, default: []
|
37
|
# File 'lib/archimate/data_model/relationship.rb', line 37
model_attr :source, comparison_attr: :id, writable: true, default: nil
|
41
|
# File 'lib/archimate/data_model/relationship.rb', line 41
model_attr :target, comparison_attr: :id, writable: true, default: nil
|
Instance Method Details
#classification ⇒ Object
62
63
64
|
# File 'lib/archimate/data_model/relationship.rb', line 62
def classification
self.class::CLASSIFICATION
end
|
#description ⇒ Object
77
78
79
80
81
82
|
# File 'lib/archimate/data_model/relationship.rb', line 77
def description
[
name.nil? ? nil : "#{name}:",
verb
].compact.join(" ")
end
|
#diagrams ⇒ Object
Diagrams that this entity is referenced in.
105
106
107
|
# File 'lib/archimate/data_model/relationship.rb', line 105
def diagrams
references.select { |ref| ref.is_a?(Diagram) }
end
|
#merge(relationship) ⇒ Object
Copy any attributes/docs, etc. from each of the others into the original.
1. Child `label`s with different `xml:lang` attribute values
2. Child `documentation` (and different `xml:lang` attribute values)
3. Child `properties`
4. Any other elements
source and target don’t change on a merge
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/archimate/data_model/relationship.rb', line 90
def merge(relationship)
if !documentation
self.documentation = relationship.documentation
elsif documentation != relationship.documentation
documentation.merge(relationship.documentation)
end
relationship.properties.each do |property|
unless properties.find { |my_prop| my_prop.property_definition.name == property.property_definition.name && my_prop.value == property.value}
properties << property
end
end
@access_type ||= relationship.access_type
end
|
#replace(entity, with_entity) ⇒ Object
49
50
51
52
|
# File 'lib/archimate/data_model/relationship.rb', line 49
def replace(entity, with_entity)
@source = with_entity.id if source == entity.id
@target = with_entity.id if target == entity.id
end
|
#replace_item_with(item, replacement) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/archimate/data_model/relationship.rb', line 109
def replace_item_with(item, replacement)
super
item.remove_reference(self)
case item
when source
@source = replacement
when target
@target = replacement
else
raise "Trying to replace #{item} that I don't reference"
end
end
|
#type ⇒ Object
54
55
56
|
# File 'lib/archimate/data_model/relationship.rb', line 54
def type
self.class.name.split("::").last
end
|
#verb ⇒ Object
66
67
68
|
# File 'lib/archimate/data_model/relationship.rb', line 66
def verb
self.class::VERB
end
|
#weight ⇒ Object
58
59
60
|
# File 'lib/archimate/data_model/relationship.rb', line 58
def weight
self.class::WEIGHT
end
|