archimate 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Bounds
8
+ def serialize_bounds(xml, bounds)
9
+ return unless bounds
10
+ xml.bounds(
11
+ remove_nil_values(
12
+ x: bounds.x&.to_i,
13
+ y: bounds.y&.to_i,
14
+ width: bounds.width&.to_i,
15
+ height: bounds.height&.to_i
16
+ )
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Connection
8
+ def serialize_connection(xml, connection)
9
+ xml.sourceConnection(
10
+ remove_nil_values(
11
+ {
12
+ "xsi:type" => connection.type,
13
+ "id" => connection.id,
14
+ "name" => connection.name
15
+ }.merge(
16
+ archi_style_hash(connection.style).merge(
17
+ "source" => connection.source&.id,
18
+ "target" => connection.target&.id,
19
+ "relationship" => connection.relationship&.id
20
+ )
21
+ )
22
+ )
23
+ ) do
24
+ serialize(xml, connection.bendpoints)
25
+ serialize_documentation(xml, connection.documentation)
26
+ serialize(xml, connection.properties)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Diagram
8
+ def serialize_diagram(xml, diagram)
9
+ xml.element(
10
+ remove_nil_values(
11
+ "xsi:type" => diagram.type || "archimate:ArchimateDiagramModel",
12
+ "id" => diagram.id,
13
+ "name" => diagram.name,
14
+ "connectionRouterType" => diagram.connection_router_type,
15
+ "viewpoint" => ViewpointType.values.index(diagram.viewpoint_type)&.to_s,
16
+ "background" => diagram.background
17
+ )
18
+ ) do
19
+ serialize(xml, diagram.nodes)
20
+ serialize_documentation(xml, diagram.documentation)
21
+ serialize(xml, diagram.properties)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Documentation
8
+ def serialize_documentation(xml, documentation, element_name = "documentation")
9
+ return unless documentation
10
+ xml.send(element_name) { xml.text(documentation.text) }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Element
8
+ def serialize_element(xml, element)
9
+ xml.element(
10
+ remove_nil_values(
11
+ "xsi:type" => "archimate:#{element.type}",
12
+ "id" => element.id,
13
+ "name" => element.name
14
+ )
15
+ ) do
16
+ serialize_documentation(xml, element.documentation)
17
+ serialize(xml, element.properties)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Location
8
+ # startX = location.x - source_attachment.x
9
+ # startY = location.y - source_attachment.y
10
+ # endX = location.x - target_attachment.x
11
+ # endY = location.y - source_attachment.y
12
+ def serialize_location(xml, bendpoint)
13
+ xml.bendpoint(
14
+ remove_nil_values(
15
+ startX: bendpoint.x == 0 ? nil : bendpoint.x&.to_i,
16
+ startY: bendpoint.y == 0 ? nil : bendpoint.y&.to_i,
17
+ endX: bendpoint.end_x&.to_i,
18
+ endY: bendpoint.end_y&.to_i
19
+ )
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Model
8
+ def serialize_model(xml, model)
9
+ xml["archimate"].model(
10
+ "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
11
+ "xmlns:archimate" => "http://www.archimatetool.com/archimate",
12
+ "name" => model.name,
13
+ "id" => model.id,
14
+ "version" => @version
15
+ ) do
16
+ serialize(xml, model.organizations)
17
+ serialize(xml, model.properties)
18
+ serialize_documentation(xml, model.documentation, "purpose")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Organization
8
+ def serialize_organization(xml, organization)
9
+ xml.folder(
10
+ remove_nil_values(name: organization.name, id: organization.id, type: organization.type)
11
+ ) do
12
+ serialize(xml, organization.organizations)
13
+ serialize_documentation(xml, organization.documentation)
14
+ serialize(xml, organization.items)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Property
8
+ def serialize_property(xml, property)
9
+ xml.property(remove_nil_values(key: property.key, value: property.value))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module Relationship
8
+ def serialize_relationship(xml, rel)
9
+ xml.element(
10
+ remove_nil_values(
11
+ "xsi:type" => "archimate:#{rel.type}",
12
+ "id" => rel.id,
13
+ "name" => rel.name,
14
+ "source" => rel.source.id,
15
+ "target" => rel.target.id,
16
+ "accessType" => serialize_access_type(rel.access_type)
17
+ )
18
+ ) do
19
+ serialize_documentation(xml, rel.documentation)
20
+ serialize(xml, rel.properties)
21
+ end
22
+ end
23
+
24
+ def serialize_access_type(val)
25
+ case val
26
+ when nil
27
+ nil
28
+ else
29
+ DataModel::ACCESS_TYPE.index(val)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module Archi
7
+ module ViewNode
8
+ def serialize_view_node(xml, child)
9
+ style_hash = archi_style_hash(child.style)
10
+ fill_color = style_hash.delete("fillColor")
11
+ xml.child(
12
+ remove_nil_values(
13
+ {
14
+ "xsi:type" => child.type,
15
+ "id" => child.id,
16
+ "name" => child.name
17
+ }.merge(
18
+ style_hash.merge(
19
+ "targetConnections" => child.target_connections.empty? ? nil : child.target_connections.join(" "),
20
+ "fillColor" => fill_color,
21
+ "model" => child.view_refs&.id,
22
+ "archimateElement" => child.element&.id,
23
+ "type" => child.child_type
24
+ )
25
+ )
26
+ )
27
+ ) do
28
+ serialize_bounds(xml, child.bounds)
29
+ serialize(xml, child.connections)
30
+ xml.content { xml.text child.content } if child.content
31
+ serialize(xml, child.nodes)
32
+ serialize_documentation(xml, child.documentation)
33
+ serialize(xml, child.properties)
34
+ end
35
+ end
36
+
37
+ def archi_style_hash(style)
38
+ {
39
+ "fillColor" => style&.fill_color&.to_rgba,
40
+ "font" => style&.font&.to_archi_font,
41
+ "fontColor" => style&.font_color&.to_rgba,
42
+ "lineColor" => style&.line_color&.to_rgba,
43
+ "lineWidth" => style&.line_width&.to_s,
44
+ "textAlignment" => style&.text_alignment&.to_s,
45
+ "textPosition" => style&.text_position
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ require "ruby-enum"
3
+
4
+ module Archimate
5
+ module FileFormats
6
+ module Serializer
7
+ module Archi
8
+ class ViewpointType
9
+ include Ruby::Enum
10
+
11
+ define :None, ""
12
+ define :Actor_cooperation, "Actor Co-operation"
13
+ define :Application_behavior, "Application Behavior"
14
+ define :Application_cooperation, "Application Co-operation"
15
+ define :Application_structure, "Application Structure"
16
+ define :Application_usage, "Application Usage"
17
+ define :Business_function, "Business Function"
18
+ define :Business_process_cooperation, "Business Process Co-operation"
19
+ define :Business_process, "Business Process"
20
+ define :Product, "Product"
21
+ define :Implementation_and_deployment, "Implementation and Deployment"
22
+ define :Information_structure, "Information Structure"
23
+ define :Infrastructure_usage, "Infrastructure Usage"
24
+ define :Infrastructure, "Infrastructure"
25
+ define :Layered, "Layered"
26
+ define :Organization, "Organization"
27
+ define :Service_realization, "Service Realization"
28
+ define :Stakeholder, "Stakeholder"
29
+ define :Goal_realization, "Goal Realization"
30
+ define :Goal_contribution, "Goal Contribution"
31
+ define :Principles, "Principles"
32
+ define :Requirements_realization, "Requirements Realization"
33
+ define :Motivation, "Motivation"
34
+ define :Project, "Project"
35
+ define :Migration, "Migration"
36
+ define :Implementation_and_migration, "Implementation and Migration"
37
+
38
+ def self.[](idx)
39
+ values[idx]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module ModelExchangeFile
7
+ module Element
8
+ def serialize_element(xml, element)
9
+ return if element.type == "SketchModel" # TODO: print a warning that data is lost
10
+ xml.element(identifier: identifier(element.id),
11
+ "xsi:type" => meff_type(element.type)) do
12
+ elementbase(xml, element)
13
+ end
14
+ end
15
+
16
+ def elementbase(xml, element)
17
+ serialize_label(xml, element.name)
18
+ serialize(xml, element.documentation)
19
+ serialize_properties(xml, element)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module ModelExchangeFile
7
+ module Location
8
+ def serialize_location(xml, location)
9
+ xml.bendpoint(x: location.x.round, y: location.y.round)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ require "nokogiri"
3
+
4
+ module Archimate
5
+ module FileFormats
6
+ module Serializer
7
+ module ModelExchangeFile
8
+ class ModelExchangeFileWriter < Writer
9
+ attr_reader :model
10
+
11
+ def initialize(model)
12
+ super
13
+ end
14
+
15
+ def write(output_io)
16
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
17
+ serialize_model(xml, model)
18
+ end
19
+ output_io.write(builder.to_xml)
20
+ end
21
+
22
+ # TODO: Archi uses hex numbers for ids which may not be valid for
23
+ # identifer. If we are converting from Archi, decorate the IDs here.
24
+ def identifier(str)
25
+ return "id-#{str}" if str =~ /^\d/
26
+ str
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module FileFormats
5
+ module Serializer
6
+ module ModelExchangeFile
7
+ module Organization
8
+ def serialize_organization(xml, organization)
9
+ if organization.items.empty? &&
10
+ (!organization.documentation || organization.documentation.empty?) &&
11
+ organization.organizations.empty?
12
+ return
13
+ end
14
+ item_attrs = organization.id.nil? || organization.id.empty? ? {} : {identifier: organization.id}
15
+ xml.item(item_attrs) do
16
+ serialize_organization_body(xml, organization)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end