Class: Archimate::DataModel::Connection
- Inherits:
-
Referenceable
- Object
- Dry::Struct
- ArchimateNode
- Referenceable
- Archimate::DataModel::Connection
- Defined in:
- lib/archimate/data_model/connection.rb
Overview
Graphical connection type.
If the ‘relationshipRef’ attribute is present, the connection should reference an existing ArchiMate relationship.
If the connection is an ArchiMate relationship type, the connection’s label, documentation and properties may be determined (i.e inherited) from those in the referenced ArchiMate relationship. Otherwise the connection’s label, documentation and properties can be provided and will be additional to (or over-ride) those contained in the referenced ArchiMate relationship.
This is ConnectionType in the XSD ViewConceptType > ConnectionType > SourcedConnectionType > Relationship > NestingRelationship
> Line
> ViewNodeType >
Label
Container > Element
Instance Attribute Summary
Attributes inherited from ArchimateNode
#parent_attribute_name, #struct_instance_variables
Instance Method Summary collapse
-
#absolute_position ⇒ Object
TODO: Is this true for all or only Archi models?.
- #description ⇒ Object
- #element ⇒ Object
-
#nodes ⇒ Object
This is used when rendering a connection to connection relationship.
- #referenced_identified_nodes ⇒ Object
- #relationship_element ⇒ Object
- #replace(entity, with_entity) ⇒ Object
- #source_element ⇒ Object
- #target_element ⇒ Object
- #to_s ⇒ Object
- #type_name ⇒ Object
Methods inherited from ArchimateNode
#ancestors, #build_index, #clone, #compact!, #delete, #diff, #dup, #element_by_id, #id, #in_model, #in_model=, #initialize, #parent, #parent=, #path, #primitive?, #set, #with
Constructor Details
This class inherits a constructor from Archimate::DataModel::ArchimateNode
Instance Method Details
#absolute_position ⇒ Object
TODO: Is this true for all or only Archi models?
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/archimate/data_model/connection.rb', line 92 def absolute_position # offset = bounds || Archimate::DataModel::Bounds.zero offset = Archimate::DataModel::Bounds.zero el = parent.parent while el.respond_to?(:bounds) && el.bounds bounds = el.bounds offset = offset.with(x: (offset.x || 0) + (bounds.x || 0), y: (offset.y || 0) + (bounds.y || 0)) el = el.parent.parent end offset end |
#description ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/archimate/data_model/connection.rb', line 73 def description [ name.nil? ? nil : "#{name}: ", source_element&.description, relationship_element&.description, target_element&.description ].compact.join(" ") end |
#element ⇒ Object
50 51 52 |
# File 'lib/archimate/data_model/connection.rb', line 50 def element relationship_element end |
#nodes ⇒ Object
This is used when rendering a connection to connection relationship.
87 88 89 |
# File 'lib/archimate/data_model/connection.rb', line 87 def nodes [] end |
#referenced_identified_nodes ⇒ Object
82 83 84 |
# File 'lib/archimate/data_model/connection.rb', line 82 def referenced_identified_nodes [@source, @target, @relationship].compact end |
#relationship_element ⇒ Object
46 47 48 |
# File 'lib/archimate/data_model/connection.rb', line 46 def relationship_element in_model.lookup(relationship) end |
#replace(entity, with_entity) ⇒ Object
36 37 38 39 40 |
# File 'lib/archimate/data_model/connection.rb', line 36 def replace(entity, with_entity) @relationship = with_entity.id if (relationship == entity.id) @source = with_entity.id if (source == entity.id) @target = with_entity.id if (target == entity.id) end |
#source_element ⇒ Object
54 55 56 |
# File 'lib/archimate/data_model/connection.rb', line 54 def source_element in_model.lookup(source) end |
#target_element ⇒ Object
58 59 60 |
# File 'lib/archimate/data_model/connection.rb', line 58 def target_element in_model.lookup(target) end |
#to_s ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/archimate/data_model/connection.rb', line 62 def to_s if in_model s = in_model.lookup(source) unless source.nil? t = in_model.lookup(target) unless target.nil? else s = source t = target end "#{type_name} #{s.nil? ? 'nothing' : s} -> #{t.nil? ? 'nothing' : t}" end |