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.
- 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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Archimate
|
|
4
|
-
module FileFormats
|
|
5
|
-
module ModelExchangeFile
|
|
6
|
-
class XmlLangString
|
|
7
|
-
def self.parse(node)
|
|
8
|
-
return nil unless node
|
|
9
|
-
DataModel::LangString.new(text: node.content, lang: node["xml:lang"])
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(lang_str, tag_name)
|
|
13
|
-
@tag_name = tag_name
|
|
14
|
-
@lang_strs = Array(lang_str)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def serialize(xml)
|
|
18
|
-
return if @lang_strs.empty?
|
|
19
|
-
|
|
20
|
-
@lang_strs.each do |lang_str|
|
|
21
|
-
attrs = lang_str.lang && !lang_str.lang.empty? ? {"xml:lang" => lang_str.lang} : {}
|
|
22
|
-
xml.send(@tag_name, attrs) { xml.text text_proc(lang_str) }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Processes text for text elements
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def text_proc(str)
|
|
30
|
-
str.strip.tr("\r", "\n")
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Archimate
|
|
4
|
-
module FileFormats
|
|
5
|
-
module ModelExchangeFile
|
|
6
|
-
class XmlMetadata
|
|
7
|
-
def self.parse(metadata)
|
|
8
|
-
return nil unless metadata
|
|
9
|
-
DataModel::Metadata.new(schema_infos: parse_schema_infos(metadata))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(metadata)
|
|
13
|
-
@metadata = metadata
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def serialize(xml)
|
|
17
|
-
return unless @metadata && @metadata.schema_infos.size > 0
|
|
18
|
-
xml.metadata do
|
|
19
|
-
if @metadata.schema_infos.size == 1
|
|
20
|
-
serialize_schema_info_body(xml, @metadata.schema_infos.first)
|
|
21
|
-
else
|
|
22
|
-
@metadata.schema_infos.each do |schema_info|
|
|
23
|
-
serialize_schema_info(xml, schema_info)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
def serialize_schema_info(xml, schema_info)
|
|
32
|
-
xml.schemaInfo do
|
|
33
|
-
serialize_schema_info_body(xml, schema_info)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def serialize_schema_info_body(xml, schema_info)
|
|
38
|
-
xml.schema { xml.text (schema_info.schema) } if schema_info.schema
|
|
39
|
-
xml.schemaversion { xml.text (schema_info.schemaversion) } if schema_info.schemaversion
|
|
40
|
-
schema_info.elements.each do |el|
|
|
41
|
-
serialize_any_element(xml, el)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def serialize_any_element(xml, el)
|
|
46
|
-
if el.prefix && !el.prefix.empty?
|
|
47
|
-
xml_prefix = xml[el.prefix]
|
|
48
|
-
else
|
|
49
|
-
xml_prefix = xml
|
|
50
|
-
end
|
|
51
|
-
xml_prefix.send(el.element.to_sym, serialize_any_attributes(el.attributes)) do
|
|
52
|
-
xml.text(el.content) if el.content&.size > 0
|
|
53
|
-
el.children.each { |child| serialize_any_element(xml, child) }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def serialize_any_attributes(attrs)
|
|
58
|
-
attrs.each_with_object({}) do |attr, hash|
|
|
59
|
-
key = attr.prefix&.size > 0 ? [attr.prefix, attr.attribute].join(":") : attr.attribute
|
|
60
|
-
hash[key] = attr.value
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def self.parse_schema_infos(metadata)
|
|
65
|
-
schema_infos = metadata.css(">schemaInfo")
|
|
66
|
-
if schema_infos.size > 0
|
|
67
|
-
schema_infos.map { |si| parse_schema_info(si) }
|
|
68
|
-
else
|
|
69
|
-
[parse_schema_info(metadata)].compact
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def self.parse_schema_info(node)
|
|
74
|
-
els = node.element_children
|
|
75
|
-
return nil if els.empty?
|
|
76
|
-
schema_info_attrs = {
|
|
77
|
-
schema: nil,
|
|
78
|
-
schemaversion: nil,
|
|
79
|
-
elements: []
|
|
80
|
-
}
|
|
81
|
-
els.each do |el|
|
|
82
|
-
case(el.name)
|
|
83
|
-
when "schema"
|
|
84
|
-
schema_info_attrs[:schema] = el.text
|
|
85
|
-
when "schemaversion"
|
|
86
|
-
schema_info_attrs[:schemaversion] = el.text
|
|
87
|
-
else
|
|
88
|
-
schema_info_attrs[:elements] << parse_any_element(el)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
DataModel::SchemaInfo.new(schema_info_attrs)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def self.parse_any_element(node)
|
|
95
|
-
return nil unless node && node.is_a?(Nokogiri::XML::Element)
|
|
96
|
-
DataModel::AnyElement.new(
|
|
97
|
-
element: node.name,
|
|
98
|
-
prefix: node.namespace&.prefix,
|
|
99
|
-
attributes: node.attributes.map { |attr| parse_any_attribute(attr) },
|
|
100
|
-
content: node.text,
|
|
101
|
-
children: node.element_children.map { |child| parse_any_element(node) }
|
|
102
|
-
)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def self.parse_any_attribute(attr)
|
|
106
|
-
DataModel::AnyAttribute.new(
|
|
107
|
-
attribute: attr.name,
|
|
108
|
-
prefix: attr.namepace&.prefix,
|
|
109
|
-
value: attr.text
|
|
110
|
-
)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Archimate
|
|
4
|
-
module FileFormats
|
|
5
|
-
module ModelExchangeFile
|
|
6
|
-
# Property Definitions as defined in ArchiMate 3.0 Model Exchange XSDs
|
|
7
|
-
class XmlPropertyDefinitions
|
|
8
|
-
def initialize(property_defs)
|
|
9
|
-
@property_definitions = property_defs
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def serialize(xml)
|
|
13
|
-
return if @property_definitions.empty?
|
|
14
|
-
xml.propertyDefinitions do
|
|
15
|
-
@property_definitions.each do |property_def|
|
|
16
|
-
xml.propertyDefinition(
|
|
17
|
-
"identifier" => property_def.id,
|
|
18
|
-
"type" => property_def.value_type
|
|
19
|
-
) do
|
|
20
|
-
ModelExchangeFile::XmlLangString.new(property_def.name, :name).serialize(xml)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "nokogiri"
|
|
3
|
-
|
|
4
|
-
module Archimate
|
|
5
|
-
module FileFormats
|
|
6
|
-
# This class implements a file reader for ArchiMate 2.1 Model Exchange Format
|
|
7
|
-
class ModelExchangeFileReader21 < ModelExchangeFileReader
|
|
8
|
-
def parse_archimate_version(root)
|
|
9
|
-
case root.namespace.href
|
|
10
|
-
when "http://www.opengroup.org/xsd/archimate"
|
|
11
|
-
:archimate_2_1
|
|
12
|
-
else
|
|
13
|
-
raise "Unexpected namespace: #{root.namespace.href}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def organizations_root_selector
|
|
18
|
-
">organization>item"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def property_defs_selector
|
|
22
|
-
">propertydefs>propertydef"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def property_def_attr_name
|
|
26
|
-
"identifierref"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def property_def_name(node)
|
|
30
|
-
node["name"]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def parse_element_name(el)
|
|
34
|
-
ModelExchangeFile::XmlLangString.parse(el.at_css(">label"))
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def identifier_ref_name
|
|
38
|
-
"identifierref"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def diagrams_path
|
|
42
|
-
">views>view"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def view_node_element_ref
|
|
46
|
-
"elementref"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def view_node_type_attr
|
|
50
|
-
"type"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def connection_relationship_ref
|
|
54
|
-
"relationshipref"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def style_to_int(str)
|
|
58
|
-
case str
|
|
59
|
-
when nil
|
|
60
|
-
0
|
|
61
|
-
when "italic"
|
|
62
|
-
1
|
|
63
|
-
when "bold"
|
|
64
|
-
2
|
|
65
|
-
when "bold|italic"
|
|
66
|
-
3
|
|
67
|
-
else
|
|
68
|
-
raise "Broken for value: #{str}"
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "nokogiri"
|
|
3
|
-
|
|
4
|
-
module Archimate
|
|
5
|
-
module FileFormats
|
|
6
|
-
class ModelExchangeFileReader30 < ModelExchangeFileReader
|
|
7
|
-
def parse_archimate_version(root)
|
|
8
|
-
case root.namespace.href
|
|
9
|
-
when "http://www.opengroup.org/xsd/archimate/3.0/"
|
|
10
|
-
:archimate_3_0
|
|
11
|
-
else
|
|
12
|
-
raise "Unexpected namespace version: #{root.namespace.href}"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def organizations_root_selector
|
|
17
|
-
">organizations"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def property_defs_selector
|
|
21
|
-
">propertyDefinitions>propertyDefinition"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def property_def_attr_name
|
|
25
|
-
"propertyDefinitionRef"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def property_def_name(node)
|
|
29
|
-
ModelExchangeFile::XmlLangString.parse(node.at_css("name"))
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def parse_element_name(el)
|
|
33
|
-
ModelExchangeFile::XmlLangString.parse(el.at_css(">name"))
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def identifier_ref_name
|
|
37
|
-
"identifierRef"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def diagrams_path
|
|
41
|
-
">views>diagrams>view"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def view_node_element_ref
|
|
45
|
-
"elementRef"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def view_node_type_attr
|
|
49
|
-
"xsi:type"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def connection_relationship_ref
|
|
53
|
-
"relationshipRef"
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def style_to_int(str)
|
|
57
|
-
case str
|
|
58
|
-
when nil
|
|
59
|
-
0
|
|
60
|
-
when "italic"
|
|
61
|
-
1
|
|
62
|
-
when "bold"
|
|
63
|
-
2
|
|
64
|
-
when "bold italic"
|
|
65
|
-
3
|
|
66
|
-
else
|
|
67
|
-
raise "Broken for value: #{str}"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# <xs:simpleType name="ViewpointPurposeEnum">
|
|
72
|
-
# <xs:restriction base="xs:NMTOKEN">
|
|
73
|
-
# <xs:enumeration value="Designing" />
|
|
74
|
-
# <xs:enumeration value="Deciding" />
|
|
75
|
-
# <xs:enumeration value="Informing" />
|
|
76
|
-
# </xs:restriction>
|
|
77
|
-
# </xs:simpleType>
|
|
78
|
-
|
|
79
|
-
# <xs:simpleType name="ViewpointPurposeType">
|
|
80
|
-
# <xs:list itemType="ViewpointPurposeEnum" />
|
|
81
|
-
# </xs:simpleType>
|
|
82
|
-
|
|
83
|
-
# <xs:simpleType name="ViewpointContentEnum">
|
|
84
|
-
# <xs:restriction base="xs:NMTOKEN">
|
|
85
|
-
# <xs:enumeration value="Details" />
|
|
86
|
-
# <xs:enumeration value="Coherence" />
|
|
87
|
-
# <xs:enumeration value="Overview" />
|
|
88
|
-
# </xs:restriction>
|
|
89
|
-
# </xs:simpleType>
|
|
90
|
-
|
|
91
|
-
# <xs:simpleType name="ViewpointContentType">
|
|
92
|
-
# <xs:list itemType="ViewpointContentEnum" />
|
|
93
|
-
# </xs:simpleType>
|
|
94
|
-
|
|
95
|
-
# <xs:complexType name="ViewpointType">
|
|
96
|
-
# <xs:complexContent>
|
|
97
|
-
# <xs:extension base="NamedReferenceableType">
|
|
98
|
-
# <xs:sequence>
|
|
99
|
-
# <xs:group ref="PropertiesGroup" />
|
|
100
|
-
# <xs:element name="concern" type="ConcernType" minOccurs="0" maxOccurs="unbounded" />
|
|
101
|
-
# <xs:element name="viewpointPurpose" type="ViewpointPurposeType" minOccurs="0" maxOccurs="1" />
|
|
102
|
-
# <xs:element name="viewpointContent" type="ViewpointContentType" minOccurs="0" maxOccurs="1" />
|
|
103
|
-
# <xs:element name="allowedElementType" type="AllowedElementTypeType" minOccurs="0" maxOccurs="unbounded" />
|
|
104
|
-
# <xs:element name="allowedRelationshipType" type="AllowedRelationshipTypeType" minOccurs="0" maxOccurs="unbounded" />
|
|
105
|
-
# <xs:element name="modelingNote" type="ModelingNoteType" minOccurs="0" maxOccurs="unbounded" />
|
|
106
|
-
# </xs:sequence>
|
|
107
|
-
# </xs:extension>
|
|
108
|
-
# </xs:complexContent>
|
|
109
|
-
# </xs:complexType>
|
|
110
|
-
def parse_viewpoints(model)
|
|
111
|
-
[]
|
|
112
|
-
# model.css("views > viewpoints").map do |i|
|
|
113
|
-
# attribute :concern, ConcernList
|
|
114
|
-
# attribute :viewpointPurpose, ViewpointPurpose.optional
|
|
115
|
-
# attribute :viewpointContent, ViewpointContent.optional
|
|
116
|
-
# attribute :allowedElementTypes, AllowedElementTypes
|
|
117
|
-
# attribute :allowedRelationshipTypes, AllowedRelationshipTypes
|
|
118
|
-
# attribute :modelingNotes, Strict::Array.member(ModelingNote).default([])
|
|
119
|
-
# DataModel::Viewpoint.new(
|
|
120
|
-
# id: identifier_to_id(i["identifier"]),
|
|
121
|
-
# name: parse_element_name(i),
|
|
122
|
-
# documentation: parse_documentation(i),
|
|
123
|
-
# properties: parse_properties(i),
|
|
124
|
-
# nodes: nodes,
|
|
125
|
-
# connections: connections,
|
|
126
|
-
# connection_router_type: i["connectionRouterType"],
|
|
127
|
-
# type: i.attr("xsi:type"),
|
|
128
|
-
# background: i.attr("background")
|
|
129
|
-
# )
|
|
130
|
-
# end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "nokogiri"
|
|
3
|
-
|
|
4
|
-
module Archimate
|
|
5
|
-
module FileFormats
|
|
6
|
-
class ModelExchangeFileWriter < Writer
|
|
7
|
-
attr_reader :model
|
|
8
|
-
|
|
9
|
-
def initialize(model)
|
|
10
|
-
super
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def write(output_io)
|
|
14
|
-
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
|
15
|
-
serialize_model(xml)
|
|
16
|
-
end
|
|
17
|
-
output_io.write(builder.to_xml)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def serialize_elements(xml)
|
|
21
|
-
xml.elements { serialize(xml, model.elements) } unless model.elements.empty?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def serialize_element(xml, element)
|
|
25
|
-
return if element.type == "SketchModel" # TODO: print a warning that data is lost
|
|
26
|
-
xml.element(identifier: identifier(element['id']),
|
|
27
|
-
"xsi:type" => meff_type(element.type)) do
|
|
28
|
-
elementbase(xml, element)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def elementbase(xml, element)
|
|
33
|
-
serialize_label(xml, element.name)
|
|
34
|
-
serialize(xml, element.documentation)
|
|
35
|
-
serialize_properties(xml, element)
|
|
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_relationships(xml)
|
|
45
|
-
return if model.relationships.empty?
|
|
46
|
-
xml.relationships { serialize(xml, model.relationships) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def relationship_attributes(relationship)
|
|
50
|
-
{
|
|
51
|
-
identifier: identifier(relationship.id),
|
|
52
|
-
source: identifier(relationship.source),
|
|
53
|
-
target: identifier(relationship.target),
|
|
54
|
-
"xsi:type" => meff_type(relationship.type)
|
|
55
|
-
}
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def serialize_relationship(xml, relationship)
|
|
59
|
-
xml.relationship(
|
|
60
|
-
relationship_attributes(relationship)
|
|
61
|
-
) do
|
|
62
|
-
elementbase(xml, relationship)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def serialize_organization_root(xml, organizations)
|
|
67
|
-
return unless organizations && organizations.size > 0
|
|
68
|
-
xml.organization do
|
|
69
|
-
serialize(xml, organizations)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def serialize_organization(xml, organization)
|
|
74
|
-
return if organization.items.empty? && organization.documentation.empty? && organization.organizations.empty?
|
|
75
|
-
item_attrs = organization.id.nil? || organization.id.empty? ? {} : {identifier: organization.id}
|
|
76
|
-
xml.item(item_attrs) do
|
|
77
|
-
serialize_organization_body(xml, organization)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def serialize_organization_body(xml, organization)
|
|
82
|
-
return if organization.items.empty? && organization.documentation.empty? && organization.organizations.empty?
|
|
83
|
-
str = organization.name
|
|
84
|
-
label_attrs = organization.name&.lang && !organization.name.lang.empty? ? {"xml:lang" => organization.name.lang} : {}
|
|
85
|
-
xml.label(label_attrs) { xml.text text_proc(str) } unless str.nil? || str.strip.empty?
|
|
86
|
-
serialize(xml, organization.documentation)
|
|
87
|
-
serialize(xml, organization.organizations)
|
|
88
|
-
organization.items.each { |i| serialize_item(xml, i) }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def serialize_properties(xml, element)
|
|
92
|
-
return if element.properties.empty?
|
|
93
|
-
xml.properties do
|
|
94
|
-
serialize(xml, element.properties)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def serialize_style(xml, style)
|
|
99
|
-
return unless style
|
|
100
|
-
xml.style(
|
|
101
|
-
remove_nil_values(
|
|
102
|
-
lineWidth: style.line_width
|
|
103
|
-
)
|
|
104
|
-
) do
|
|
105
|
-
serialize_color(xml, style.fill_color, :fillColor)
|
|
106
|
-
serialize_color(xml, style.line_color, :lineColor)
|
|
107
|
-
serialize_font(xml, style)
|
|
108
|
-
# TODO: complete this
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def serialize_font(xml, style)
|
|
113
|
-
return unless style && (style.font || style.font_color)
|
|
114
|
-
xml.font(
|
|
115
|
-
remove_nil_values(
|
|
116
|
-
name: style.font&.name,
|
|
117
|
-
size: style.font&.size&.round,
|
|
118
|
-
style: font_style_string(style.font)
|
|
119
|
-
)
|
|
120
|
-
) { serialize_color(xml, style&.font_color, :color) }
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def serialize_color(xml, color, sym)
|
|
124
|
-
return if color.nil?
|
|
125
|
-
h = {
|
|
126
|
-
r: color.r,
|
|
127
|
-
g: color.g,
|
|
128
|
-
b: color.b,
|
|
129
|
-
a: color.a
|
|
130
|
-
}
|
|
131
|
-
h.delete(:a) if color.a.nil? || color.a == 100
|
|
132
|
-
xml.send(sym, h)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def serialize_location(xml, location)
|
|
136
|
-
xml.bendpoint(x: location.x.round, y: location.y.round)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# # Processes text for text elements
|
|
140
|
-
def text_proc(str)
|
|
141
|
-
str.strip.tr("\r", "\n")
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# TODO: this should replace namespaces as appropriate for the desired export version
|
|
145
|
-
def model_namespaces
|
|
146
|
-
model.namespaces
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
# TODO: Archi uses hex numbers for ids which may not be valid for
|
|
150
|
-
# identifer. If we are converting from Archi, decorate the IDs here.
|
|
151
|
-
def identifier(str)
|
|
152
|
-
return "id-#{str}" if str =~ /^\d/
|
|
153
|
-
str
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|