archimate 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -0
  3. data/TODOs.org +219 -0
  4. data/archimate.gemspec +2 -1
  5. data/exe/archidiff +7 -0
  6. data/exe/archidiff-summary +7 -0
  7. data/exe/archimerge +7 -0
  8. data/exe/fmtxml +7 -0
  9. data/lib/archimate.rb +10 -21
  10. data/lib/archimate/cli/archi.rb +2 -1
  11. data/lib/archimate/cli/cleanup.rb +8 -9
  12. data/lib/archimate/cli/convert.rb +3 -1
  13. data/lib/archimate/cli/mapper.rb +1 -1
  14. data/lib/archimate/cli/stats.rb +1 -1
  15. data/lib/archimate/config.rb +4 -1
  16. data/lib/archimate/data_model.rb +11 -24
  17. data/lib/archimate/data_model/any_attribute.rb +18 -5
  18. data/lib/archimate/data_model/any_element.rb +30 -7
  19. data/lib/archimate/data_model/bounds.rb +34 -7
  20. data/lib/archimate/data_model/color.rb +32 -7
  21. data/lib/archimate/data_model/comparison.rb +87 -0
  22. data/lib/archimate/data_model/concern.rb +20 -7
  23. data/lib/archimate/data_model/connection.rb +71 -51
  24. data/lib/archimate/data_model/connector_type.rb +23 -0
  25. data/lib/archimate/data_model/diagram.rb +72 -10
  26. data/lib/archimate/data_model/diagram_type.rb +17 -0
  27. data/lib/archimate/data_model/differentiable.rb +142 -0
  28. data/lib/archimate/data_model/element.rb +39 -45
  29. data/lib/archimate/data_model/element_type.rb +89 -0
  30. data/lib/archimate/data_model/font.rb +30 -12
  31. data/lib/archimate/data_model/lang_string.rb +89 -16
  32. data/lib/archimate/data_model/layer.rb +55 -0
  33. data/lib/archimate/data_model/layers.rb +62 -0
  34. data/lib/archimate/data_model/location.rb +27 -11
  35. data/lib/archimate/data_model/metadata.rb +10 -3
  36. data/lib/archimate/data_model/model.rb +188 -121
  37. data/lib/archimate/data_model/modeling_note.rb +14 -3
  38. data/lib/archimate/data_model/organization.rb +44 -13
  39. data/lib/archimate/data_model/{documentation.rb → preserved_lang_string.rb} +1 -5
  40. data/lib/archimate/data_model/property.rb +17 -11
  41. data/lib/archimate/data_model/property_definition.rb +34 -4
  42. data/lib/archimate/data_model/referenceable.rb +0 -9
  43. data/lib/archimate/data_model/referenceable_collection.rb +201 -0
  44. data/lib/archimate/data_model/relationship.rb +52 -33
  45. data/lib/archimate/data_model/relationship_type.rb +43 -0
  46. data/lib/archimate/data_model/schema_info.rb +17 -6
  47. data/lib/archimate/data_model/style.rb +41 -11
  48. data/lib/archimate/data_model/view_node.rb +153 -59
  49. data/lib/archimate/data_model/viewpoint.rb +56 -80
  50. data/lib/archimate/data_model/viewpoint_type.rb +429 -0
  51. data/lib/archimate/export/csv_export.rb +2 -2
  52. data/lib/archimate/export/cypher.rb +2 -2
  53. data/lib/archimate/export/graph_ml.rb +7 -5
  54. data/lib/archimate/export/jsonl.rb +166 -0
  55. data/lib/archimate/export/n_quads.rb +8 -5
  56. data/lib/archimate/file_format.rb +4 -5
  57. data/lib/archimate/file_formats/archi_file_reader.rb +7 -240
  58. data/lib/archimate/file_formats/archi_file_writer.rb +16 -188
  59. data/lib/archimate/file_formats/model_exchange_file_reader.rb +7 -225
  60. data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +22 -114
  61. data/lib/archimate/file_formats/model_exchange_file_writer_30.rb +22 -122
  62. data/lib/archimate/file_formats/sax.rb +55 -0
  63. data/lib/archimate/file_formats/sax/any_element.rb +64 -0
  64. data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +48 -0
  65. data/lib/archimate/file_formats/sax/archi/bounds.rb +25 -0
  66. data/lib/archimate/file_formats/sax/archi/connection.rb +47 -0
  67. data/lib/archimate/file_formats/sax/archi/content.rb +28 -0
  68. data/lib/archimate/file_formats/sax/archi/diagram.rb +66 -0
  69. data/lib/archimate/file_formats/sax/archi/element.rb +36 -0
  70. data/lib/archimate/file_formats/sax/archi/location.rb +25 -0
  71. data/lib/archimate/file_formats/sax/archi/model.rb +109 -0
  72. data/lib/archimate/file_formats/sax/archi/organization.rb +60 -0
  73. data/lib/archimate/file_formats/sax/archi/property.rb +54 -0
  74. data/lib/archimate/file_formats/sax/archi/relationship.rb +50 -0
  75. data/lib/archimate/file_formats/sax/archi/style.rb +35 -0
  76. data/lib/archimate/file_formats/sax/archi/view_node.rb +76 -0
  77. data/lib/archimate/file_formats/sax/capture_content.rb +20 -0
  78. data/lib/archimate/file_formats/sax/capture_documentation.rb +19 -0
  79. data/lib/archimate/file_formats/sax/capture_properties.rb +20 -0
  80. data/lib/archimate/file_formats/sax/content_element.rb +19 -0
  81. data/lib/archimate/file_formats/sax/document.rb +80 -0
  82. data/lib/archimate/file_formats/sax/handler.rb +54 -0
  83. data/lib/archimate/file_formats/sax/lang_string.rb +28 -0
  84. data/lib/archimate/file_formats/sax/model_exchange_file/color.rb +36 -0
  85. data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +67 -0
  86. data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +60 -0
  87. data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +43 -0
  88. data/lib/archimate/file_formats/sax/model_exchange_file/font.rb +44 -0
  89. data/lib/archimate/file_formats/sax/model_exchange_file/item.rb +64 -0
  90. data/lib/archimate/file_formats/sax/model_exchange_file/location.rb +23 -0
  91. data/lib/archimate/file_formats/sax/model_exchange_file/metadata.rb +66 -0
  92. data/lib/archimate/file_formats/sax/model_exchange_file/model.rb +124 -0
  93. data/lib/archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory.rb +53 -0
  94. data/lib/archimate/file_formats/sax/model_exchange_file/property.rb +32 -0
  95. data/lib/archimate/file_formats/sax/model_exchange_file/property_definition.rb +36 -0
  96. data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +49 -0
  97. data/lib/archimate/file_formats/sax/model_exchange_file/schema_info.rb +47 -0
  98. data/lib/archimate/file_formats/sax/model_exchange_file/style.rb +66 -0
  99. data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +86 -0
  100. data/lib/archimate/file_formats/sax/no_op.rb +17 -0
  101. data/lib/archimate/file_formats/sax/preserved_lang_string.rb +28 -0
  102. data/lib/archimate/file_formats/serializer.rb +57 -0
  103. data/lib/archimate/file_formats/serializer/archi/bounds.rb +23 -0
  104. data/lib/archimate/file_formats/serializer/archi/connection.rb +33 -0
  105. data/lib/archimate/file_formats/serializer/archi/diagram.rb +28 -0
  106. data/lib/archimate/file_formats/serializer/archi/documentation.rb +16 -0
  107. data/lib/archimate/file_formats/serializer/archi/element.rb +24 -0
  108. data/lib/archimate/file_formats/serializer/archi/location.rb +26 -0
  109. data/lib/archimate/file_formats/serializer/archi/model.rb +25 -0
  110. data/lib/archimate/file_formats/serializer/archi/organization.rb +21 -0
  111. data/lib/archimate/file_formats/serializer/archi/property.rb +15 -0
  112. data/lib/archimate/file_formats/serializer/archi/relationship.rb +36 -0
  113. data/lib/archimate/file_formats/serializer/archi/view_node.rb +52 -0
  114. data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +45 -0
  115. data/lib/archimate/file_formats/serializer/model_exchange_file/element.rb +25 -0
  116. data/lib/archimate/file_formats/serializer/model_exchange_file/location.rb +15 -0
  117. data/lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb +32 -0
  118. data/lib/archimate/file_formats/serializer/model_exchange_file/organization.rb +23 -0
  119. data/lib/archimate/file_formats/serializer/model_exchange_file/properties.rb +15 -0
  120. data/lib/archimate/file_formats/serializer/model_exchange_file/relationship.rb +19 -0
  121. data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +48 -0
  122. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/connection.rb +25 -0
  123. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +27 -0
  124. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/item.rb +17 -0
  125. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/label.rb +17 -0
  126. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +36 -0
  127. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/organization_body.rb +25 -0
  128. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/property.rb +19 -0
  129. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +44 -0
  130. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/connection.rb +26 -0
  131. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +27 -0
  132. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/item.rb +17 -0
  133. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/label.rb +17 -0
  134. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +41 -0
  135. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/organization_body.rb +25 -0
  136. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property.rb +19 -0
  137. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property_definitions.rb +34 -0
  138. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +45 -0
  139. data/lib/archimate/file_formats/serializer/named_collection.rb +21 -0
  140. data/lib/archimate/file_formats/serializer/writer.rb +56 -0
  141. data/lib/archimate/file_formats/serializer/xml_lang_string.rb +30 -0
  142. data/lib/archimate/file_formats/serializer/xml_metadata.rb +64 -0
  143. data/lib/archimate/file_formats/{model_exchange_file → serializer}/xml_property_defs.rb +2 -2
  144. data/lib/archimate/lint/duplicate_entities.rb +3 -3
  145. data/lib/archimate/lint/linter.rb +24 -29
  146. data/lib/archimate/svg/connection.rb +13 -103
  147. data/lib/archimate/svg/diagram.rb +1 -1
  148. data/lib/archimate/svg/entity/base_entity.rb +12 -8
  149. data/lib/archimate/svg/entity/data_entity.rb +2 -2
  150. data/lib/archimate/svg/entity/diagram_model_reference.rb +1 -1
  151. data/lib/archimate/svg/entity/event_entity.rb +2 -2
  152. data/lib/archimate/svg/entity/gap.rb +1 -1
  153. data/lib/archimate/svg/entity/group.rb +1 -1
  154. data/lib/archimate/svg/entity/motivation_entity.rb +1 -1
  155. data/lib/archimate/svg/entity/node.rb +1 -1
  156. data/lib/archimate/svg/entity/rect_entity.rb +1 -1
  157. data/lib/archimate/svg/entity/rounded_rect_entity.rb +1 -1
  158. data/lib/archimate/svg/entity/service_entity.rb +2 -2
  159. data/lib/archimate/svg/entity/value.rb +2 -2
  160. data/lib/archimate/svg/path.rb +153 -0
  161. data/lib/archimate/svg/point.rb +8 -1
  162. data/lib/archimate/version.rb +1 -1
  163. metadata +118 -36
  164. data/lib/archimate/data_model/archimate_node.rb +0 -181
  165. data/lib/archimate/data_model/concept.rb +0 -14
  166. data/lib/archimate/data_model/constants.rb +0 -82
  167. data/lib/archimate/data_model/container.rb +0 -17
  168. data/lib/archimate/data_model/diffable_array.rb +0 -213
  169. data/lib/archimate/data_model/diffable_primitive.rb +0 -83
  170. data/lib/archimate/data_model/label.rb +0 -19
  171. data/lib/archimate/data_model/named_referenceable.rb +0 -14
  172. data/lib/archimate/data_model/view.rb +0 -12
  173. data/lib/archimate/data_model/view_concept.rb +0 -18
  174. data/lib/archimate/file_formats/archi_file_format.rb +0 -151
  175. data/lib/archimate/file_formats/archimate_v2.rb +0 -461
  176. data/lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb +0 -35
  177. data/lib/archimate/file_formats/model_exchange_file/xml_metadata.rb +0 -115
  178. data/lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb +0 -28
  179. data/lib/archimate/file_formats/model_exchange_file_reader_21.rb +0 -73
  180. data/lib/archimate/file_formats/model_exchange_file_reader_30.rb +0 -134
  181. data/lib/archimate/file_formats/model_exchange_file_writer.rb +0 -157
  182. data/lib/archimate/file_formats/writer.rb +0 -56
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ require "ruby-enum"
3
+
4
+ module Archimate
5
+ module DataModel
6
+ RELATION_VERBS = {
7
+ "AccessRelationship" => "accesses",
8
+ "AggregationRelationship" => "aggregates",
9
+ "AssignmentRelationship" => "is assigned to",
10
+ "AssociationRelationship" => "is associated with",
11
+ "CompositionRelationship" => "composes",
12
+ "FlowRelationship" => "flows to",
13
+ "InfluenceRelationship" => "influenecs",
14
+ "RealisationRelationship" => "realizes",
15
+ "SpecialisationRelationship" => "specializes",
16
+ "TriggeringRelationship" => "triggers",
17
+ "UsedByRelationship" => "is used by"
18
+ }.freeze
19
+
20
+ class RelationshipType
21
+ include Ruby::Enum
22
+
23
+ define :AccessRelationship, "AccessRelationship"
24
+ define :AggregationRelationship, "AggregationRelationship"
25
+ define :AssignmentRelationship, "AssignmentRelationship"
26
+ define :AssociationRelationship, "AssociationRelationship"
27
+ define :CompositionRelationship, "CompositionRelationship"
28
+ define :FlowRelationship, "FlowRelationship"
29
+ define :InfluenceRelationship, "InfluenceRelationship"
30
+ define :RealisationRelationship, "RealisationRelationship"
31
+ define :SpecialisationRelationship, "SpecialisationRelationship"
32
+ define :SpecializationRelationship, "SpecializationRelationship"
33
+ define :TriggeringRelationship, "TriggeringRelationship"
34
+ define :UsedByRelationship, "UsedByRelationship" # @todo Support: Serving
35
+ define :ServingRelationship, "ServingRelationship" # @todo Support: Serving
36
+ define :GroupingRelationship, "GroupingRelationship"
37
+
38
+ def self.===(other)
39
+ values.include?(other)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,17 +2,28 @@
2
2
 
3
3
  module Archimate
4
4
  module DataModel
5
- class SchemaInfo < ArchimateNode
6
- using DiffablePrimitive
5
+ class SchemaInfo
6
+ include Comparison
7
7
 
8
- attribute :schema, Strict::String.optional
9
- attribute :schemaversion, Strict::String.optional
10
- attribute :elements, Strict::Array.member(AnyElement).default([])
8
+ # @!attribute [r] schema
9
+ # @return [String, NilClass]
10
+ model_attr :schema
11
+ # @!attribute [r] schemaversion
12
+ # @return [String, NilClass]
13
+ model_attr :schemaversion
14
+ # @!attribute [r] elements
15
+ # @return [Array<AnyElement>]
16
+ model_attr :elements
17
+
18
+ def initialize(schema: nil, schemaversion: nil, elements: [])
19
+ @schema = schema
20
+ @schemaversion = schemaversion
21
+ @elements = elements
22
+ end
11
23
 
12
24
  def to_s
13
25
  "#{type.light_black}[#{schema} #{schemaversion}]"
14
26
  end
15
27
  end
16
- Dry::Types.register_class(SchemaInfo)
17
28
  end
18
29
  end
@@ -1,17 +1,49 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Archimate
3
4
  module DataModel
4
- class Style < ArchimateNode
5
- attribute :text_alignment, Coercible::Int.optional # TODO: make this an enum
6
- attribute :fill_color, Color.optional
7
- attribute :line_color, Color.optional
8
- attribute :font_color, Color.optional # TODO: move this to font
9
- attribute :line_width, Coercible::Int.optional
10
- attribute :font, Font.optional
11
- attribute :text_position, Coercible::Int.optional # TODO: make this an enum
5
+ class Style
6
+ include Comparison
7
+
8
+ # @todo make this an enum
9
+ # @!attribute [r] text_alignment
10
+ # @return [Int, NilClass]
11
+ model_attr :text_alignment
12
+ # @!attribute [r] fill_color
13
+ # @return [Color, NilClass]
14
+ model_attr :fill_color
15
+ # @!attribute [r] line_color
16
+ # @return [Color, NilClass]
17
+ model_attr :line_color
18
+ # @todo move this to font
19
+ # @!attribute [r] font_color
20
+ # @return [Color, NilClass]
21
+ model_attr :font_color
22
+ # @!attribute [r] line_width
23
+ # @return [Int, NilClass]
24
+ model_attr :line_width
25
+ # @!attribute [r] font
26
+ # @return [Font, NilClass]
27
+ model_attr :font
28
+ # @todo make this an enum
29
+ # @!attribute [r] text_position
30
+ # @return [Int, NilClass]
31
+ model_attr :text_position
32
+
33
+ def initialize(text_alignment: nil, fill_color: nil, line_color: nil,
34
+ font_color: nil, line_width: nil, font: nil, text_position: nil)
35
+ @text_alignment = text_alignment
36
+ @fill_color = fill_color
37
+ @line_color = line_color
38
+ @font_color = font_color
39
+ @line_width = line_width
40
+ @font = font
41
+ @text_position = text_position
42
+ end
12
43
 
13
44
  def to_s
14
- attr_name_vals = struct_instance_variables.map { |k| "#{k}: #{self[k]}" }.join(", ")
45
+ attr_name_vals = %i[text_alignment fill_color line_color font_color line_width
46
+ font text_position].map { |k| "#{k}: #{send(k)}" }.join(", ")
15
47
  "Style(#{attr_name_vals})"
16
48
  end
17
49
 
@@ -26,7 +58,5 @@ module Archimate
26
58
  end
27
59
  end
28
60
  end
29
-
30
- Dry::Types.register_class(Style)
31
61
  end
32
62
  end
@@ -1,55 +1,151 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Archimate
3
4
  module DataModel
4
- PositiveInteger = Strict::Int.constrained(gt: 0)
5
+ # PositiveInteger =Int.constrained(gt: 0)
5
6
 
6
7
  # Graphical node type. It can contain child node types.
7
- # TODO: This is ViewNodeType in the v3 XSD
8
- class ViewNode < Referenceable # < ViewConcept
9
- using DiffableArray
10
-
11
- # LocationGroup: TODO: Consider making this a mixin or extract object
12
- # The x (towards the right, associated with width) attribute from the Top,Left (i.e. 0,0)
13
- # corner of the diagram to the Top, Left corner of the bounding box of the concept.
14
- # attribute :x, NonNegativeInteger
15
- # The y (towards the bottom, associated with height) attribute from the Top,Left (i.e. 0,0)
16
- # corner of the diagram to the Top, Left corner of the bounding box of the concept.
17
- # attribute :y, NonNegativeInteger
18
-
19
- # SizeGroup:
20
- # The width (associated with x) attribute from the Left side to the right side of the
21
- # bounding box of a concept.
22
- # attribute :w, PositiveInteger
23
- # The height (associated with y) attribute from the top side to the bottom side of the
24
- # bounding box of a concept.
25
- # attribute :h, PositiveInteger
26
-
27
- attribute :model, Identifier.optional
28
- attribute :content, Strict::String.optional
29
- attribute :target_connections, Strict::Array.member(Identifier).default([])
30
- attribute :archimate_element, Identifier.optional
31
- attribute :bounds, Bounds.optional
32
- attribute :nodes, Strict::Array.member(ViewNode).default([])
33
- attribute :connections, ConnectionList
34
- attribute :style, Style.optional
35
- attribute :type, Strict::String.optional
36
- attribute :child_type, Coercible::Int.optional
37
- attribute :properties, PropertiesList # Note: this is not in the model under element
38
- # it's added under Real Element
8
+ # This can be specialized as Label and Container
9
+ # In the ArchiMate v3 Schema, the tree of these nodes is:
10
+ # ViewConceptType(
11
+ # LabelGroup (name LangString)
12
+ # PreservedLangString
13
+ # style (optional)
14
+ # viewRefs
15
+ # id)
16
+ # - ViewNodeType(
17
+ # LocationGroup (x, y)
18
+ # SizeGroup (width, height))
19
+ # - Label(
20
+ # conceptRef
21
+ # attributeRef
22
+ # xpathPart (optional)
23
+ # )
24
+ # - Container(
25
+ # nodes (ViewNodeType)
26
+ # - Element(
27
+ # elementRef)
28
+ class ViewNode
29
+ include Comparison
30
+
31
+ # ViewConceptType
32
+ # @!attribute [r] id
33
+ # @return [String]
34
+ model_attr :id
35
+ # @!attribute [r] name
36
+ # @return [LangString, NilClass]
37
+ model_attr :name
38
+ # @!attribute [r] documentation
39
+ # @return [PreservedLangString, NilClass]
40
+ model_attr :documentation
41
+ # # @!attribute [r] other_elements
42
+ # @return [Array<AnyElement>]
43
+ model_attr :other_elements
44
+ # # @!attribute [r] other_attributes
45
+ # @return [Array<AnyAttribute>]
46
+ model_attr :other_attributes
47
+ # @note type here was used for the Element/Relationship/Diagram type
48
+ # @!attribute [r] type
49
+ # @return [String, NilClass]
50
+ model_attr :type
51
+ # @!attribute [r] style
52
+ # @return [Style, NilClass]
53
+ model_attr :style
54
+
55
+ # @note viewRefs are pointers to 0-* Diagrams for diagram drill in defined in abstract View Concept
56
+ # @todo Make this an array
57
+ # @!attribute [rw] view_refs
58
+ # @return [Diagram]
59
+ model_attr :view_refs, comparison_attr: :id, writable: true
60
+
61
+ # @todo document where this comes from
62
+ # @!attribute [r] content
63
+ # @return [String, NilClass]
64
+ model_attr :content
65
+
66
+ # This is needed for various calculations
67
+ # @!attribute [r] parent
68
+ # @return [ViewNode]
69
+ model_attr :parent, writable: true, comparison_attr: :no_compare
70
+
71
+ # ViewNodeType
72
+ # @!attribute [r] bounds
73
+ # @return [Bounds, NilClass]
74
+ model_attr :bounds
75
+
76
+ # Container - container doesn't distinguish between nodes and connections
77
+ # @!attribute [r] nodes
78
+ # @return [Array<ViewNode>]
79
+ model_attr :nodes
80
+ # @!attribute [r] connections
81
+ # @return [Array<Connection>]
82
+ model_attr :connections
83
+
84
+ # @note properties is not in the model under element, it's added under Real Element
85
+ # @todo Delete this - I think it's not used
86
+ # @!attribute [r] properties
87
+ # @return [Array<Property>]
88
+ model_attr :properties
89
+
90
+ # Element
91
+ # @!attribute [rw] element
92
+ # @return [Element, NilClass]
93
+ model_attr :element, writable: true, comparison_attr: :id
94
+ # Archi format, selects the shape of element (for elements that can have two or more shapes)
95
+ # @!attribute [r] child_type
96
+ # @return [Int, NilClass]
97
+ model_attr :child_type
98
+
99
+ # @!attribute [r] diagram
100
+ # @return [Diagram, NilClass]
101
+ model_attr :diagram, comparison_attr: :no_compare
102
+
103
+ # Node type to allow a Label in a Artifact. the "label" element holds the info for the @note.
104
+ # Label View Nodes have the following attributes
105
+
106
+ # conceptRef is a reference to an concept for this particular label, along with the attributeRef
107
+ # which references the particular concept's part which this label represents.
108
+ # @!attribute [r] concept_ref
109
+ # @return [String]
110
+ model_attr :concept_ref
111
+ # conceptRef is a reference to an concept for this particular label, along with the partRef
112
+ # which references the particular concept's part which this label represents. If this attribute
113
+ # is set, then there is no need to add a label tag in the Label parent (since it is contained in the model).
114
+ # the XPATH statement is meant to be interpreted in the context of what the conceptRef points to.
115
+ # @!attribute [r] xpath_path
116
+ # @return [String, NilClass]
117
+ model_attr :xpath_path
118
+
119
+ def initialize(id:, name: nil, documentation: nil, type: nil, parent: nil,
120
+ style: nil, view_refs: [], content: nil, bounds: nil,
121
+ nodes: [], connections: [], properties: [], element: nil,
122
+ child_type: nil, diagram:, concept_ref: nil, xpath_path: nil)
123
+ @id = id
124
+ @name = name
125
+ @documentation = documentation
126
+ @type = type
127
+ @parent = parent
128
+ @style = style
129
+ @view_refs = view_refs
130
+ @content = content
131
+ @bounds = bounds
132
+ @nodes = nodes
133
+ @connections = connections
134
+ @properties = properties
135
+ @element = element
136
+ @child_type = child_type
137
+ @diagram = diagram
138
+ @concept_ref = concept_ref
139
+ @xpath_path = xpath_path
140
+ end
39
141
 
40
142
  def replace(entity, with_entity)
41
- if (archimate_element == entity.id)
42
- @archimate_element = with_entity.id
43
- @element = with_entity
44
- end
45
- if (model == entity.id)
46
- @model = with_entity.id
47
- @model_element = with_entity
48
- end
143
+ @element = with_entity if element.id == entity.id
144
+ @view_refs = with_entity if view_refs == entity
49
145
  end
50
146
 
51
147
  def to_s
52
- "ViewNode[#{name || ''}](#{in_model.lookup(archimate_element) if archimate_element && in_model})"
148
+ "ViewNode[#{name || ''}](#{element if element})"
53
149
  end
54
150
 
55
151
  def description
@@ -60,14 +156,6 @@ module Archimate
60
156
  ].compact.join(" ")
61
157
  end
62
158
 
63
- def element
64
- @element ||= in_model.lookup(archimate_element)
65
- end
66
-
67
- def model_element
68
- @model_element ||= in_model.lookup(model)
69
- end
70
-
71
159
  def all_nodes
72
160
  nodes.inject(Array.new(nodes)) { |child_ary, child| child_ary.concat(child.all_nodes) }
73
161
  end
@@ -78,30 +166,36 @@ module Archimate
78
166
 
79
167
  def referenced_identified_nodes
80
168
  (nodes + connections).reduce(
81
- (target_connections + [archimate_element]).compact
169
+ [element]
170
+ .compact
82
171
  ) do |a, e|
83
172
  a.concat(e.referenced_identified_nodes)
84
173
  end
85
174
  end
86
175
 
87
176
  def in_diagram
88
- @diagram ||= ->(node) { node = node.parent until node.nil? || node.is_a?(Diagram) }.call(self)
177
+ diagram # ||= ->(node) { node = node.parent until node.nil? || node.is_a?(Diagram) }.call(self)
89
178
  end
90
179
 
91
- # TODO: Is this true for all or only Archi models?
180
+ # @todo Is this true for all or only Archi models?
92
181
  def absolute_position
93
- offset = bounds || Archimate::DataModel::Bounds.zero
94
- el = parent.parent
182
+ offset = bounds || Bounds.zero
183
+ el = parent
95
184
  while el.respond_to?(:bounds) && el.bounds
96
185
  bounds = el.bounds
97
- offset = offset.with(x: (offset.x || 0) + (bounds.x || 0), y: (offset.y || 0) + (bounds.y || 0))
98
- el = el.parent.parent
186
+ offset = Bounds.new(offset.to_h.merge(x: (offset.x || 0) + (bounds.x || 0), y: (offset.y || 0) + (bounds.y || 0)))
187
+ el = el.parent
99
188
  end
100
189
  offset
101
190
  end
102
- end
103
191
 
104
- Dry::Types.register_class(ViewNode)
192
+ def target_connections
193
+ diagram
194
+ .connections
195
+ .select { |conn| conn.target&.id == id }
196
+ .map(&:id)
197
+ end
198
+ end
105
199
  end
106
200
  end
107
201
 
@@ -2,86 +2,62 @@
2
2
 
3
3
  module Archimate
4
4
  module DataModel
5
- # Basic Viewpoints
6
- # Category:Composition Viewpoints that defines internal compositions and aggregations of elements.
7
- COMPOSITION_VIEWPOINTS = [
8
- "Organization",
9
- "Application Platform",
10
- "Information Structure",
11
- "Technology",
12
- "Layered",
13
- "Physical"
14
- ].freeze
15
-
16
- # Category:Support Viewpoints where you are looking at elements that are supported by other elements. Typically from one layer and upwards to an above layer.
17
- SUPPORT_VIEWPOINTS = [
18
- "Product",
19
- "Application Usage",
20
- "Technology Usage"
21
- ].freeze
22
-
23
- # Category:Cooperation Towards peer elements which cooperate with each other. Typically across aspects.
24
- COOPERATION_VIEWPOINTS = [
25
- "Business Process Cooperation",
26
- "Application Cooperation"
27
- ].freeze
28
-
29
- # Category:Realization Viewpoints where you are looking at elements that realize other elements. Typically from one layer and downwards to a below layer.
30
- REALIZATION_VIEWPOINTS = [
31
- "Service Realization",
32
- "Implementation and Deployment",
33
- "Goal Realization",
34
- "Goal Contribution",
35
- "Principles",
36
- "Requirements Realization",
37
- "Motivation"
38
- ].freeze
39
-
40
- # Strategy Viewpoints
41
- STRATEGY_VIEWPOINTS = [
42
- "Strategy",
43
- "Capability Map",
44
- "Outcome Realization",
45
- "Resource Map"
46
- ].freeze
47
-
48
- # Implementation and Migration Viewpoints
49
- IMPLEMENTATION_AND_MIGRATION_VIEWPOINTS = [
50
- "Project",
51
- "Migration",
52
- "Implementation and Migration"
53
- ].freeze
54
-
55
- # Other Viewpoints
56
- Other_Viewpoints = %w[Stakeholder].freeze
57
-
58
- VIEWPOINTS_ENUM = [].concat(
59
- [COMPOSITION_VIEWPOINTS, SUPPORT_VIEWPOINTS, COOPERATION_VIEWPOINTS,
60
- REALIZATION_VIEWPOINTS, STRATEGY_VIEWPOINTS,
61
- IMPLEMENTATION_AND_MIGRATION_VIEWPOINTS].flatten
62
- )
63
-
64
- ViewpointType = Strict::String.enum(*VIEWPOINTS_ENUM).optional
65
-
66
- ViewpointContentEnum = Strict::String.enum(%w[Details Coherence Overview])
67
- ViewpointContent = Strict::Array.member(ViewpointContentEnum).default([])
68
-
69
- ViewpointPurposeEnum = Strict::String.enum(%w[Designing Deciding Informing])
70
- ViewpointPurpose = Strict::Array.member(ViewpointPurposeEnum).default([])
71
-
72
- class Viewpoint < NamedReferenceable
73
- using DataModel::DiffableArray
74
- using DataModel::DiffablePrimitive
75
-
76
- attribute :concern, ConcernList
77
- attribute :viewpointPurpose, ViewpointPurpose.optional
78
- attribute :viewpointContent, ViewpointContent.optional
79
- attribute :allowedElementTypes, AllowedElementTypes
80
- attribute :allowedRelationshipTypes, AllowedRelationshipTypes
81
- attribute :modelingNotes, Strict::Array.member(ModelingNote).default([])
5
+ class Viewpoint
6
+ include Comparison
7
+
8
+ # @!attribute [r] id
9
+ # @return [String]
10
+ model_attr :id
11
+ # @!attribute [r] name
12
+ # @return [LangString]
13
+ model_attr :name
14
+ # @!attribute [r] documentation
15
+ # @return [PreservedLangString]
16
+ model_attr :documentation
17
+ # # @!attribute [r] other_elements
18
+ # @return [Array<AnyElement>]
19
+ model_attr :other_elements
20
+ # # @!attribute [r] other_attributes
21
+ # @return [Array<AnyAttribute>]
22
+ model_attr :other_attributes
23
+ # type here was used for the Element/Relationship/Diagram type
24
+ # @!attribute [r] type
25
+ # @return [String, NilClass]
26
+ model_attr :type
27
+ # @!attribute [r] concerns
28
+ # @return [Array<Concern>]
29
+ model_attr :concerns
30
+ # @!attribute [r] viewpoint_purposes
31
+ # @return [Array<ViewpointPurposeEnum>]
32
+ model_attr :viewpoint_purposes
33
+ # @!attribute [r] viewpoint_contents
34
+ # @return [Array<ViewpointContentEnum>]
35
+ model_attr :viewpoint_contents
36
+ # @!attribute [r] allowed_element_types
37
+ # @return [Array<ElementType>]
38
+ model_attr :allowed_element_types
39
+ # @!attribute [r] allowed_relationship_types
40
+ # @return [Array<RelationshipType>]
41
+ model_attr :allowed_relationship_types
42
+ # @!attribute [r] modeling_notes
43
+ # @return [Array<ModelingNote>]
44
+ model_attr :modeling_notes
45
+
46
+ def initialize(id:, name:, documentation: nil, type: nil,
47
+ concerns: [], viewpoint_purposes: [],
48
+ viewpoint_contents: [], allowed_element_types: [],
49
+ allowed_relationship_types: [], modeling_notes: [])
50
+ @id = id
51
+ @name = name
52
+ @documentation = documentation
53
+ @type = type
54
+ @concerns = concerns
55
+ @viewpoint_purposes = viewpoint_purposes
56
+ @viewpoint_contents = viewpoint_contents
57
+ @allowed_element_types = allowed_element_types
58
+ @allowed_relationship_types = allowed_relationship_types
59
+ @modeling_notes = modeling_notes
60
+ end
82
61
  end
83
-
84
- Dry::Types.register_class(Viewpoint)
85
- ViewpointList = Strict::Array.member(Viewpoint).default([])
86
62
  end
87
63
  end