archimate 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -0
- data/TODOs.org +219 -0
- data/archimate.gemspec +2 -1
- data/exe/archidiff +7 -0
- data/exe/archidiff-summary +7 -0
- data/exe/archimerge +7 -0
- data/exe/fmtxml +7 -0
- data/lib/archimate.rb +10 -21
- data/lib/archimate/cli/archi.rb +2 -1
- data/lib/archimate/cli/cleanup.rb +8 -9
- data/lib/archimate/cli/convert.rb +3 -1
- data/lib/archimate/cli/mapper.rb +1 -1
- data/lib/archimate/cli/stats.rb +1 -1
- data/lib/archimate/config.rb +4 -1
- data/lib/archimate/data_model.rb +11 -24
- data/lib/archimate/data_model/any_attribute.rb +18 -5
- data/lib/archimate/data_model/any_element.rb +30 -7
- data/lib/archimate/data_model/bounds.rb +34 -7
- data/lib/archimate/data_model/color.rb +32 -7
- data/lib/archimate/data_model/comparison.rb +87 -0
- data/lib/archimate/data_model/concern.rb +20 -7
- data/lib/archimate/data_model/connection.rb +71 -51
- data/lib/archimate/data_model/connector_type.rb +23 -0
- data/lib/archimate/data_model/diagram.rb +72 -10
- data/lib/archimate/data_model/diagram_type.rb +17 -0
- data/lib/archimate/data_model/differentiable.rb +142 -0
- data/lib/archimate/data_model/element.rb +39 -45
- data/lib/archimate/data_model/element_type.rb +89 -0
- data/lib/archimate/data_model/font.rb +30 -12
- data/lib/archimate/data_model/lang_string.rb +89 -16
- data/lib/archimate/data_model/layer.rb +55 -0
- data/lib/archimate/data_model/layers.rb +62 -0
- data/lib/archimate/data_model/location.rb +27 -11
- data/lib/archimate/data_model/metadata.rb +10 -3
- data/lib/archimate/data_model/model.rb +188 -121
- data/lib/archimate/data_model/modeling_note.rb +14 -3
- data/lib/archimate/data_model/organization.rb +44 -13
- data/lib/archimate/data_model/{documentation.rb → preserved_lang_string.rb} +1 -5
- data/lib/archimate/data_model/property.rb +17 -11
- data/lib/archimate/data_model/property_definition.rb +34 -4
- data/lib/archimate/data_model/referenceable.rb +0 -9
- data/lib/archimate/data_model/referenceable_collection.rb +201 -0
- data/lib/archimate/data_model/relationship.rb +52 -33
- data/lib/archimate/data_model/relationship_type.rb +43 -0
- data/lib/archimate/data_model/schema_info.rb +17 -6
- data/lib/archimate/data_model/style.rb +41 -11
- data/lib/archimate/data_model/view_node.rb +153 -59
- data/lib/archimate/data_model/viewpoint.rb +56 -80
- data/lib/archimate/data_model/viewpoint_type.rb +429 -0
- data/lib/archimate/export/csv_export.rb +2 -2
- data/lib/archimate/export/cypher.rb +2 -2
- data/lib/archimate/export/graph_ml.rb +7 -5
- data/lib/archimate/export/jsonl.rb +166 -0
- data/lib/archimate/export/n_quads.rb +8 -5
- data/lib/archimate/file_format.rb +4 -5
- data/lib/archimate/file_formats/archi_file_reader.rb +7 -240
- data/lib/archimate/file_formats/archi_file_writer.rb +16 -188
- data/lib/archimate/file_formats/model_exchange_file_reader.rb +7 -225
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +22 -114
- data/lib/archimate/file_formats/model_exchange_file_writer_30.rb +22 -122
- data/lib/archimate/file_formats/sax.rb +55 -0
- data/lib/archimate/file_formats/sax/any_element.rb +64 -0
- data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +48 -0
- data/lib/archimate/file_formats/sax/archi/bounds.rb +25 -0
- data/lib/archimate/file_formats/sax/archi/connection.rb +47 -0
- data/lib/archimate/file_formats/sax/archi/content.rb +28 -0
- data/lib/archimate/file_formats/sax/archi/diagram.rb +66 -0
- data/lib/archimate/file_formats/sax/archi/element.rb +36 -0
- data/lib/archimate/file_formats/sax/archi/location.rb +25 -0
- data/lib/archimate/file_formats/sax/archi/model.rb +109 -0
- data/lib/archimate/file_formats/sax/archi/organization.rb +60 -0
- data/lib/archimate/file_formats/sax/archi/property.rb +54 -0
- data/lib/archimate/file_formats/sax/archi/relationship.rb +50 -0
- data/lib/archimate/file_formats/sax/archi/style.rb +35 -0
- data/lib/archimate/file_formats/sax/archi/view_node.rb +76 -0
- data/lib/archimate/file_formats/sax/capture_content.rb +20 -0
- data/lib/archimate/file_formats/sax/capture_documentation.rb +19 -0
- data/lib/archimate/file_formats/sax/capture_properties.rb +20 -0
- data/lib/archimate/file_formats/sax/content_element.rb +19 -0
- data/lib/archimate/file_formats/sax/document.rb +80 -0
- data/lib/archimate/file_formats/sax/handler.rb +54 -0
- data/lib/archimate/file_formats/sax/lang_string.rb +28 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/color.rb +36 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +67 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +60 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +43 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/font.rb +44 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/item.rb +64 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/location.rb +23 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/metadata.rb +66 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/model.rb +124 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory.rb +53 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/property.rb +32 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/property_definition.rb +36 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +49 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/schema_info.rb +47 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/style.rb +66 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +86 -0
- data/lib/archimate/file_formats/sax/no_op.rb +17 -0
- data/lib/archimate/file_formats/sax/preserved_lang_string.rb +28 -0
- data/lib/archimate/file_formats/serializer.rb +57 -0
- data/lib/archimate/file_formats/serializer/archi/bounds.rb +23 -0
- data/lib/archimate/file_formats/serializer/archi/connection.rb +33 -0
- data/lib/archimate/file_formats/serializer/archi/diagram.rb +28 -0
- data/lib/archimate/file_formats/serializer/archi/documentation.rb +16 -0
- data/lib/archimate/file_formats/serializer/archi/element.rb +24 -0
- data/lib/archimate/file_formats/serializer/archi/location.rb +26 -0
- data/lib/archimate/file_formats/serializer/archi/model.rb +25 -0
- data/lib/archimate/file_formats/serializer/archi/organization.rb +21 -0
- data/lib/archimate/file_formats/serializer/archi/property.rb +15 -0
- data/lib/archimate/file_formats/serializer/archi/relationship.rb +36 -0
- data/lib/archimate/file_formats/serializer/archi/view_node.rb +52 -0
- data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +45 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/element.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/location.rb +15 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb +32 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/organization.rb +23 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/properties.rb +15 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/relationship.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +48 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/connection.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +27 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/item.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/label.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +36 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/organization_body.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/property.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +44 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/connection.rb +26 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +27 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/item.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/label.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +41 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/organization_body.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property_definitions.rb +34 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +45 -0
- data/lib/archimate/file_formats/serializer/named_collection.rb +21 -0
- data/lib/archimate/file_formats/serializer/writer.rb +56 -0
- data/lib/archimate/file_formats/serializer/xml_lang_string.rb +30 -0
- data/lib/archimate/file_formats/serializer/xml_metadata.rb +64 -0
- data/lib/archimate/file_formats/{model_exchange_file → serializer}/xml_property_defs.rb +2 -2
- data/lib/archimate/lint/duplicate_entities.rb +3 -3
- data/lib/archimate/lint/linter.rb +24 -29
- data/lib/archimate/svg/connection.rb +13 -103
- data/lib/archimate/svg/diagram.rb +1 -1
- data/lib/archimate/svg/entity/base_entity.rb +12 -8
- data/lib/archimate/svg/entity/data_entity.rb +2 -2
- data/lib/archimate/svg/entity/diagram_model_reference.rb +1 -1
- data/lib/archimate/svg/entity/event_entity.rb +2 -2
- data/lib/archimate/svg/entity/gap.rb +1 -1
- data/lib/archimate/svg/entity/group.rb +1 -1
- data/lib/archimate/svg/entity/motivation_entity.rb +1 -1
- data/lib/archimate/svg/entity/node.rb +1 -1
- data/lib/archimate/svg/entity/rect_entity.rb +1 -1
- data/lib/archimate/svg/entity/rounded_rect_entity.rb +1 -1
- data/lib/archimate/svg/entity/service_entity.rb +2 -2
- data/lib/archimate/svg/entity/value.rb +2 -2
- data/lib/archimate/svg/path.rb +153 -0
- data/lib/archimate/svg/point.rb +8 -1
- data/lib/archimate/version.rb +1 -1
- metadata +118 -36
- data/lib/archimate/data_model/archimate_node.rb +0 -181
- data/lib/archimate/data_model/concept.rb +0 -14
- data/lib/archimate/data_model/constants.rb +0 -82
- data/lib/archimate/data_model/container.rb +0 -17
- data/lib/archimate/data_model/diffable_array.rb +0 -213
- data/lib/archimate/data_model/diffable_primitive.rb +0 -83
- data/lib/archimate/data_model/label.rb +0 -19
- data/lib/archimate/data_model/named_referenceable.rb +0 -14
- data/lib/archimate/data_model/view.rb +0 -12
- data/lib/archimate/data_model/view_concept.rb +0 -18
- data/lib/archimate/file_formats/archi_file_format.rb +0 -151
- data/lib/archimate/file_formats/archimate_v2.rb +0 -461
- data/lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb +0 -35
- data/lib/archimate/file_formats/model_exchange_file/xml_metadata.rb +0 -115
- data/lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb +0 -28
- data/lib/archimate/file_formats/model_exchange_file_reader_21.rb +0 -73
- data/lib/archimate/file_formats/model_exchange_file_reader_30.rb +0 -134
- data/lib/archimate/file_formats/model_exchange_file_writer.rb +0 -157
- data/lib/archimate/file_formats/writer.rb +0 -56
@@ -4,131 +4,39 @@ require "nokogiri"
|
|
4
4
|
module Archimate
|
5
5
|
module FileFormats
|
6
6
|
# Archimate version 2.1 Model Exchange Format Writer
|
7
|
-
class ModelExchangeFileWriter21 < ModelExchangeFileWriter
|
7
|
+
class ModelExchangeFileWriter21 < Serializer::ModelExchangeFile::ModelExchangeFileWriter
|
8
|
+
include Serializer::ModelExchangeFile::V21::Connection
|
9
|
+
include Serializer::ModelExchangeFile::V21::Diagram
|
10
|
+
include Serializer::ModelExchangeFile::Element
|
11
|
+
include Serializer::ModelExchangeFile::V21::Item
|
12
|
+
include Serializer::ModelExchangeFile::V21::Label
|
13
|
+
include Serializer::ModelExchangeFile::Location
|
14
|
+
include Serializer::ModelExchangeFile::V21::Model
|
15
|
+
include Serializer::ModelExchangeFile::Organization
|
16
|
+
include Serializer::ModelExchangeFile::V21::OrganizationBody
|
17
|
+
include Serializer::ModelExchangeFile::V21::Property
|
18
|
+
include Serializer::ModelExchangeFile::Properties
|
19
|
+
include Serializer::ModelExchangeFile::Relationship
|
20
|
+
include Serializer::ModelExchangeFile::Style
|
21
|
+
include Serializer::ModelExchangeFile::V21::ViewNode
|
22
|
+
|
8
23
|
def initialize(model)
|
9
24
|
super
|
10
25
|
end
|
11
26
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def serialize_model(xml)
|
20
|
-
xml.model(model_attrs) do
|
21
|
-
ModelExchangeFile::XmlMetadata.new(model.metadata).serialize(xml)
|
22
|
-
ModelExchangeFile::XmlLangString.new(model.name, :name).serialize(xml)
|
23
|
-
ModelExchangeFile::XmlLangString.new(model.documentation, :documentation).serialize(xml)
|
24
|
-
serialize_properties(xml, model)
|
25
|
-
serialize_elements(xml)
|
26
|
-
serialize_relationships(xml)
|
27
|
-
serialize_organization_root(xml, model.organizations)
|
28
|
-
serialize_property_defs(xml)
|
29
|
-
serialize_views(xml)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def serialize_property_defs(xml)
|
34
|
-
return if model.property_definitions.empty?
|
35
|
-
ModelExchangeFile::XmlPropertyDefs.new(model.property_definitions).serialize(xml)
|
36
|
-
end
|
37
|
-
|
38
|
-
def serialize_label(xml, str)
|
39
|
-
return if str.nil? || str.strip.empty?
|
40
|
-
name_attrs = str.lang && !str.lang.empty? ? {"xml:lang" => str.lang} : {}
|
41
|
-
xml.label(name_attrs) { xml.text text_proc(str) }
|
42
|
-
end
|
43
|
-
|
44
|
-
def serialize_organization_root(xml, organizations)
|
45
|
-
return unless organizations && organizations.size > 0
|
46
|
-
xml.organization do
|
47
|
-
serialize(xml, organizations)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def serialize_item(xml, item)
|
52
|
-
xml.item(identifierref: identifier(item))
|
53
|
-
end
|
54
|
-
|
55
|
-
def serialize_property(xml, property)
|
56
|
-
xml.property(identifierref: property.property_definition.id) do
|
57
|
-
ModelExchangeFile::XmlLangString.new(property.value, :value).serialize(xml)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def serialize_views(xml)
|
62
|
-
return if model.diagrams.empty?
|
63
|
-
xml.views do
|
64
|
-
serialize(xml, model.diagrams)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def serialize_diagram(xml, diagram)
|
69
|
-
xml.view(
|
70
|
-
remove_nil_values(
|
71
|
-
identifier: identifier(diagram.id),
|
72
|
-
viewpoint: diagram.viewpoint_type,
|
73
|
-
"xsi:type": diagram.type
|
74
|
-
)
|
75
|
-
) do
|
76
|
-
elementbase(xml, diagram)
|
77
|
-
serialize(xml, diagram.nodes)
|
78
|
-
serialize(xml, diagram.connections)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def view_node_attrs(view_node, x_offset = 0, y_offset = 0)
|
83
|
-
attrs = {
|
84
|
-
identifier: identifier(view_node.id),
|
85
|
-
elementref: nil,
|
86
|
-
x: view_node.bounds ? (view_node.bounds&.x + x_offset).round : nil,
|
87
|
-
y: view_node.bounds ? (view_node.bounds&.y + y_offset).round : nil,
|
88
|
-
w: view_node.bounds&.width&.round,
|
89
|
-
h: view_node.bounds&.height&.round,
|
90
|
-
type: nil
|
27
|
+
def relationship_attributes(relationship)
|
28
|
+
{
|
29
|
+
identifier: identifier(relationship.id),
|
30
|
+
source: identifier(relationship.source.id),
|
31
|
+
target: identifier(relationship.target.id),
|
32
|
+
"xsi:type" => meff_type(relationship.type)
|
91
33
|
}
|
92
|
-
if view_node.archimate_element
|
93
|
-
attrs[:elementref] = identifier(view_node.archimate_element)
|
94
|
-
elsif view_node.model
|
95
|
-
# Since it doesn't seem to be forbidden, we just assume we can use
|
96
|
-
# the elementref for views in views
|
97
|
-
attrs[:elementref] = view_node.model
|
98
|
-
attrs[:type] = "model"
|
99
|
-
else
|
100
|
-
attrs[:type] = "group"
|
101
|
-
end
|
102
|
-
remove_nil_values(attrs)
|
103
|
-
end
|
104
|
-
|
105
|
-
def serialize_view_node(xml, view_node, x_offset = 0, y_offset = 0)
|
106
|
-
attrs = view_node_attrs(view_node, x_offset, y_offset)
|
107
|
-
xml.node(attrs) do
|
108
|
-
serialize_label(xml, view_node.name) if attrs[:type] == "group"
|
109
|
-
serialize(xml, view_node.style) if view_node.style
|
110
|
-
view_node.nodes.each do |c|
|
111
|
-
serialize_view_node(xml, c) # , attrs[:x].to_f, attrs[:y].to_f)
|
112
|
-
end
|
113
|
-
end
|
114
34
|
end
|
115
35
|
|
116
36
|
def font_style_string(font)
|
117
37
|
font&.style_string
|
118
38
|
end
|
119
39
|
|
120
|
-
def serialize_connection(xml, sc)
|
121
|
-
xml.connection(
|
122
|
-
identifier: identifier(sc.id),
|
123
|
-
relationshipref: identifier(sc.relationship),
|
124
|
-
source: identifier(sc.source),
|
125
|
-
target: identifier(sc.target)
|
126
|
-
) do
|
127
|
-
serialize(xml, sc.bendpoints)
|
128
|
-
serialize(xml, sc.style)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
40
|
def meff_type(el_type)
|
133
41
|
el_type = el_type.sub(/^/, "")
|
134
42
|
case el_type
|
@@ -3,122 +3,35 @@ require "nokogiri"
|
|
3
3
|
|
4
4
|
module Archimate
|
5
5
|
module FileFormats
|
6
|
-
class ModelExchangeFileWriter30 < ModelExchangeFileWriter
|
6
|
+
class ModelExchangeFileWriter30 < Serializer::ModelExchangeFile::ModelExchangeFileWriter
|
7
|
+
include Serializer::ModelExchangeFile::V30::Connection
|
8
|
+
include Serializer::ModelExchangeFile::V30::Diagram
|
9
|
+
include Serializer::ModelExchangeFile::Element
|
10
|
+
include Serializer::ModelExchangeFile::V30::Item
|
11
|
+
include Serializer::ModelExchangeFile::V30::Label
|
12
|
+
include Serializer::ModelExchangeFile::Location
|
13
|
+
include Serializer::ModelExchangeFile::V30::Model
|
14
|
+
include Serializer::ModelExchangeFile::Organization
|
15
|
+
include Serializer::ModelExchangeFile::V30::OrganizationBody
|
16
|
+
include Serializer::ModelExchangeFile::V30::Property
|
17
|
+
include Serializer::ModelExchangeFile::Properties
|
18
|
+
include Serializer::ModelExchangeFile::Relationship
|
19
|
+
include Serializer::ModelExchangeFile::Style
|
20
|
+
include Serializer::ModelExchangeFile::V30::ViewNode
|
21
|
+
|
7
22
|
def initialize(model)
|
8
23
|
super
|
9
24
|
end
|
10
25
|
|
11
|
-
def model_attrs
|
12
|
-
remove_nil_values(
|
13
|
-
model_namespaces.merge(
|
14
|
-
"xsi:schemaLocation" => model.schema_locations.join(" "),
|
15
|
-
"identifier" => identifier(model.id),
|
16
|
-
"version" => model.version
|
17
|
-
)
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def serialize_model(xml)
|
22
|
-
xml.model(model_attrs) do
|
23
|
-
ModelExchangeFile::XmlLangString.new(model.name, :name).serialize(xml)
|
24
|
-
ModelExchangeFile::XmlLangString.new(model.documentation, :documentation).serialize(xml)
|
25
|
-
ModelExchangeFile::XmlMetadata.new(model.metadata).serialize(xml)
|
26
|
-
serialize_properties(xml, model)
|
27
|
-
serialize_elements(xml)
|
28
|
-
serialize_relationships(xml)
|
29
|
-
serialize_organization_root(xml, model.organizations)
|
30
|
-
serialize_property_defs(xml)
|
31
|
-
serialize_views(xml)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def serialize_property_defs(xml)
|
36
|
-
return if model.property_definitions.empty?
|
37
|
-
ModelExchangeFile::XmlPropertyDefinitions.new(model.property_definitions).serialize(xml)
|
38
|
-
end
|
39
|
-
|
40
|
-
def serialize_label(xml, str, tag = :name)
|
41
|
-
return if str.nil? || str.strip.empty?
|
42
|
-
name_attrs = str.lang && !str.lang.empty? ? {"xml:lang" => str.lang} : {}
|
43
|
-
xml.send(tag, name_attrs) { xml.text text_proc(str) }
|
44
|
-
end
|
45
|
-
|
46
26
|
def relationship_attributes(relationship)
|
47
|
-
attrs = super
|
48
|
-
attrs["accessType"] = relationship.access_type if relationship.access_type
|
49
|
-
attrs
|
50
|
-
end
|
51
|
-
|
52
|
-
def serialize_organization_root(xml, organizations)
|
53
|
-
return unless organizations && organizations.size > 0
|
54
|
-
xml.organizations do
|
55
|
-
serialize_organization_body(xml, organizations[0])
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def serialize_item(xml, item)
|
60
|
-
xml.item(identifierRef: identifier(item))
|
61
|
-
end
|
62
|
-
|
63
|
-
def serialize_property(xml, property)
|
64
|
-
xml.property("propertyDefinitionRef" => property.property_definition.id) do
|
65
|
-
ModelExchangeFile::XmlLangString.new(property.value, :value).serialize(xml)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def serialize_views(xml)
|
70
|
-
return if model.diagrams.empty?
|
71
|
-
xml.views do
|
72
|
-
xml.diagrams {
|
73
|
-
serialize(xml, model.diagrams)
|
74
|
-
}
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def serialize_diagram(xml, diagram)
|
79
|
-
xml.view(
|
80
|
-
remove_nil_values(
|
81
|
-
identifier: identifier(diagram.id),
|
82
|
-
"xsi:type": diagram.type,
|
83
|
-
viewpoint: diagram.viewpoint_type
|
84
|
-
)
|
85
|
-
) do
|
86
|
-
elementbase(xml, diagram)
|
87
|
-
serialize(xml, diagram.nodes)
|
88
|
-
serialize(xml, diagram.connections)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def view_node_attrs(view_node, x_offset = 0, y_offset = 0)
|
93
27
|
attrs = {
|
94
|
-
identifier: identifier(
|
95
|
-
|
96
|
-
|
97
|
-
"
|
98
|
-
"y" => view_node.bounds ? (view_node.bounds&.y + y_offset).round : nil,
|
99
|
-
"w" => view_node.bounds&.width&.round,
|
100
|
-
"h" => view_node.bounds&.height&.round
|
28
|
+
identifier: identifier(relationship.id),
|
29
|
+
source: identifier(relationship.source.id),
|
30
|
+
target: identifier(relationship.target.id),
|
31
|
+
"xsi:type" => meff_type(relationship.type)
|
101
32
|
}
|
102
|
-
if
|
103
|
-
|
104
|
-
elsif view_node.model
|
105
|
-
# Since it doesn't seem to be forbidden, we just assume we can use
|
106
|
-
# the elementref for views in views
|
107
|
-
attrs[:elementRef] = view_node.model
|
108
|
-
attrs[:type] = "model"
|
109
|
-
end
|
110
|
-
remove_nil_values(attrs)
|
111
|
-
end
|
112
|
-
|
113
|
-
def serialize_view_node(xml, view_node, x_offset = 0, y_offset = 0)
|
114
|
-
attrs = view_node_attrs(view_node, x_offset, y_offset)
|
115
|
-
xml.node(attrs) do
|
116
|
-
serialize_label(xml, view_node.name, :label)
|
117
|
-
serialize(xml, view_node.style) if view_node.style
|
118
|
-
view_node.nodes.each do |c|
|
119
|
-
serialize_view_node(xml, c) # , view_node_attrs[:x].to_f, view_node_attrs[:y].to_f)
|
120
|
-
end
|
121
|
-
end
|
33
|
+
attrs["accessType"] = relationship.access_type if relationship.access_type
|
34
|
+
attrs
|
122
35
|
end
|
123
36
|
|
124
37
|
def font_style_string(font)
|
@@ -132,19 +45,6 @@ module Archimate
|
|
132
45
|
end
|
133
46
|
end
|
134
47
|
|
135
|
-
def serialize_connection(xml, sc)
|
136
|
-
xml.connection(
|
137
|
-
identifier: identifier(sc.id),
|
138
|
-
relationshipRef: identifier(sc.relationship),
|
139
|
-
"xsi:type": sc.type,
|
140
|
-
source: identifier(sc.source),
|
141
|
-
target: identifier(sc.target)
|
142
|
-
) do
|
143
|
-
serialize(xml, sc.style)
|
144
|
-
serialize(xml, sc.bendpoints)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
48
|
def meff_type(el_type)
|
149
49
|
el_type.sub(/^/, "")
|
150
50
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Archimate
|
3
|
+
module FileFormats
|
4
|
+
module Sax
|
5
|
+
SaxEvent = Struct.new(:sym, :args, :source)
|
6
|
+
FutureReference = Struct.new(:obj, :attr, :id)
|
7
|
+
|
8
|
+
autoload :AnyElement, 'archimate/file_formats/sax/any_element'
|
9
|
+
autoload :CaptureContent, 'archimate/file_formats/sax/capture_content'
|
10
|
+
autoload :CaptureDocumentation, 'archimate/file_formats/sax/capture_documentation'
|
11
|
+
autoload :CaptureProperties, 'archimate/file_formats/sax/capture_properties'
|
12
|
+
autoload :ContentElement, 'archimate/file_formats/sax/content_element'
|
13
|
+
autoload :Document, 'archimate/file_formats/sax/document'
|
14
|
+
autoload :Handler, 'archimate/file_formats/sax/handler'
|
15
|
+
autoload :LangString, 'archimate/file_formats/sax/lang_string'
|
16
|
+
autoload :NoOp, 'archimate/file_formats/sax/no_op'
|
17
|
+
autoload :PreservedLangString, 'archimate/file_formats/sax/preserved_lang_string'
|
18
|
+
module Archi
|
19
|
+
autoload :ArchiHandlerFactory, 'archimate/file_formats/sax/archi/archi_handler_factory'
|
20
|
+
autoload :Bounds, 'archimate/file_formats/sax/archi/bounds'
|
21
|
+
autoload :Connection, 'archimate/file_formats/sax/archi/connection'
|
22
|
+
autoload :Content, 'archimate/file_formats/sax/archi/content'
|
23
|
+
autoload :Diagram, 'archimate/file_formats/sax/archi/diagram'
|
24
|
+
autoload :Element, 'archimate/file_formats/sax/archi/element'
|
25
|
+
autoload :Location, 'archimate/file_formats/sax/archi/location'
|
26
|
+
autoload :Model, 'archimate/file_formats/sax/archi/model'
|
27
|
+
autoload :Organization, 'archimate/file_formats/sax/archi/organization'
|
28
|
+
autoload :PreservedLangString, 'archimate/file_formats/sax/archi/preserved_lang_string'
|
29
|
+
autoload :Property, 'archimate/file_formats/sax/archi/property'
|
30
|
+
autoload :Relationship, 'archimate/file_formats/sax/archi/relationship'
|
31
|
+
autoload :Style, 'archimate/file_formats/sax/archi/style'
|
32
|
+
autoload :ViewNode, 'archimate/file_formats/sax/archi/view_node'
|
33
|
+
end
|
34
|
+
module ModelExchangeFile
|
35
|
+
autoload :Color, 'archimate/file_formats/sax/model_exchange_file/color'
|
36
|
+
autoload :Connection, 'archimate/file_formats/sax/model_exchange_file/connection'
|
37
|
+
autoload :Diagram, 'archimate/file_formats/sax/model_exchange_file/diagram'
|
38
|
+
autoload :Element, 'archimate/file_formats/sax/model_exchange_file/element'
|
39
|
+
autoload :Font, 'archimate/file_formats/sax/model_exchange_file/font'
|
40
|
+
autoload :Item, 'archimate/file_formats/sax/model_exchange_file/item'
|
41
|
+
autoload :Location, 'archimate/file_formats/sax/model_exchange_file/location'
|
42
|
+
autoload :Metadata, 'archimate/file_formats/sax/model_exchange_file/metadata'
|
43
|
+
autoload :ModelExchangeHandlerFactory, 'archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory'
|
44
|
+
autoload :Model, 'archimate/file_formats/sax/model_exchange_file/model'
|
45
|
+
autoload :Property, 'archimate/file_formats/sax/model_exchange_file/property'
|
46
|
+
autoload :PropertyDefinition, 'archimate/file_formats/sax/model_exchange_file/property_definition'
|
47
|
+
autoload :Relationship, 'archimate/file_formats/sax/model_exchange_file/relationship'
|
48
|
+
autoload :Schema, 'archimate/file_formats/sax/model_exchange_file/schema'
|
49
|
+
autoload :SchemaInfo, 'archimate/file_formats/sax/model_exchange_file/schema_info'
|
50
|
+
autoload :Style, 'archimate/file_formats/sax/model_exchange_file/style'
|
51
|
+
autoload :ViewNode, 'archimate/file_formats/sax/model_exchange_file/view_node'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Sax
|
6
|
+
class AnyElement < Handler
|
7
|
+
include Sax::CaptureContent
|
8
|
+
|
9
|
+
def initialize(name, attrs, parent_handler)
|
10
|
+
super
|
11
|
+
@children = []
|
12
|
+
@el_name = nil
|
13
|
+
@prefix = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def complete
|
17
|
+
[event(
|
18
|
+
:on_any_element,
|
19
|
+
DataModel::AnyElement.new(
|
20
|
+
element: el_name,
|
21
|
+
prefix: prefix,
|
22
|
+
attributes: any_attributes,
|
23
|
+
content: content,
|
24
|
+
children: @children
|
25
|
+
)
|
26
|
+
)]
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_any_element(any_element, _source)
|
30
|
+
@children << any_element
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def el_name
|
37
|
+
parse_name unless @el_name
|
38
|
+
@el_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def prefix
|
42
|
+
parse_name unless @el_name
|
43
|
+
@prefix
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_name
|
47
|
+
name_parts = name.split(":")
|
48
|
+
@prefix = name_parts.size > 1 ? name_parts.first : nil
|
49
|
+
@el_name = name_parts.last
|
50
|
+
end
|
51
|
+
|
52
|
+
def any_attributes
|
53
|
+
attrs.map do |attr_name, attr_val|
|
54
|
+
DataModel::AnyAttribute.new(
|
55
|
+
attr_name,
|
56
|
+
attr_val,
|
57
|
+
prefix: attr_name.split(":").first
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Sax
|
6
|
+
module Archi
|
7
|
+
class ArchiHandlerFactory
|
8
|
+
def handler_for(name, attrs)
|
9
|
+
case name
|
10
|
+
when "model", "archimate:model"
|
11
|
+
Model
|
12
|
+
when "documentation", "purpose"
|
13
|
+
Sax::PreservedLangString
|
14
|
+
when "element"
|
15
|
+
element_type = Hash[attrs]["xsi:type"].sub(/archimate:/, '')
|
16
|
+
case element_type
|
17
|
+
when DataModel::ElementType, DataModel::ConnectorType
|
18
|
+
Element
|
19
|
+
when DataModel::DiagramType
|
20
|
+
Diagram
|
21
|
+
when DataModel::RelationshipType
|
22
|
+
Relationship
|
23
|
+
else
|
24
|
+
raise "Unexpected element_type #{element_type}"
|
25
|
+
end
|
26
|
+
when "property"
|
27
|
+
Property
|
28
|
+
when "folder"
|
29
|
+
Organization
|
30
|
+
when "child"
|
31
|
+
ViewNode
|
32
|
+
when "bounds"
|
33
|
+
Bounds
|
34
|
+
when "sourceConnection"
|
35
|
+
Connection
|
36
|
+
when "bendpoint"
|
37
|
+
Location
|
38
|
+
when "content"
|
39
|
+
Content
|
40
|
+
else
|
41
|
+
raise "Unhandled element name #{name}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|