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
|
@@ -6,9 +6,16 @@ module Archimate
|
|
|
6
6
|
# about a meta-data element's parent only.
|
|
7
7
|
#
|
|
8
8
|
# One or more different meta-data models may be declared as child extensions of a meta-data element.
|
|
9
|
-
class Metadata
|
|
10
|
-
|
|
9
|
+
class Metadata
|
|
10
|
+
include Comparison
|
|
11
|
+
|
|
12
|
+
# @!attribute [r] schema_infos
|
|
13
|
+
# @return [Array<SchemaInfo>]
|
|
14
|
+
model_attr :schema_infos
|
|
15
|
+
|
|
16
|
+
def initialize(schema_infos: [])
|
|
17
|
+
@schema_infos = schema_infos
|
|
18
|
+
end
|
|
11
19
|
end
|
|
12
|
-
Dry::Types.register_class(Metadata)
|
|
13
20
|
end
|
|
14
21
|
end
|
|
@@ -3,39 +3,99 @@
|
|
|
3
3
|
module Archimate
|
|
4
4
|
module DataModel
|
|
5
5
|
# This is the root model type.
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
attribute
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
attribute
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
#
|
|
7
|
+
# It is a container for the elements, relationships, diagrams and
|
|
8
|
+
# organizations of the model.
|
|
9
|
+
class Model
|
|
10
|
+
include Comparison
|
|
11
|
+
|
|
12
|
+
# @!attribute [r] id
|
|
13
|
+
# @return [String] unique identifier of this model
|
|
14
|
+
model_attr :id
|
|
15
|
+
# @!attribute [r] name
|
|
16
|
+
# @return [LangString] name of the model
|
|
17
|
+
model_attr :name
|
|
18
|
+
|
|
19
|
+
# @!attribute [r] documentation
|
|
20
|
+
# @return [PreservedLangString, NilClass] model documentation
|
|
21
|
+
model_attr :documentation
|
|
22
|
+
# @!attribute [r] properties
|
|
23
|
+
# @return [Array<Property>] model properties
|
|
24
|
+
model_attr :properties
|
|
25
|
+
# @!attribute [r] metadata
|
|
26
|
+
# @return [Metadata, NilClass] model metadata
|
|
27
|
+
model_attr :metadata
|
|
28
|
+
# @!attribute [r] elements
|
|
29
|
+
# @return [Array<Element>]
|
|
30
|
+
model_attr :elements
|
|
31
|
+
# @!attribute [r] relationships
|
|
32
|
+
# @return [Array<Relationship>]
|
|
33
|
+
model_attr :relationships
|
|
34
|
+
# @!attribute [r] organizations
|
|
35
|
+
# @return [Array<Organization>]
|
|
36
|
+
model_attr :organizations
|
|
37
|
+
# @!attribute [r] property_definitions
|
|
38
|
+
# @return [Array<PropertyDefinition>]
|
|
39
|
+
model_attr :property_definitions
|
|
40
|
+
# @!attribute [r] version
|
|
41
|
+
# @return [String, NilClass]
|
|
42
|
+
model_attr :version
|
|
43
|
+
# @!attribute [r] diagrams
|
|
44
|
+
# @return [Array<Diagram>]
|
|
45
|
+
model_attr :diagrams
|
|
46
|
+
# @!attribute [r] viewpoints
|
|
47
|
+
# @return [Array<Viewpoint>]
|
|
48
|
+
model_attr :viewpoints
|
|
49
|
+
|
|
22
50
|
# Following attributes are to hold info on where the model came from
|
|
23
|
-
attribute
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
# @!attribute [r] filename
|
|
52
|
+
# @return [String]
|
|
53
|
+
model_attr :filename
|
|
54
|
+
# @see Archimate::SUPPORTED_FORMATS
|
|
55
|
+
# @!attribute [r] file_format
|
|
56
|
+
# @return [Symbol, NilClass] supported Archimate format [Archimate::SUPPORTED_FORMATS] or +nil+
|
|
57
|
+
model_attr :file_format
|
|
58
|
+
# @!attribute [r] archimate_version
|
|
59
|
+
# @return [Symbol] one of [Archimate::ARCHIMATE_VERSIONS], default +:archimate_3_0+
|
|
60
|
+
model_attr :archimate_version
|
|
26
61
|
|
|
27
|
-
attribute
|
|
28
|
-
|
|
62
|
+
# @!attribute [r] namespaces
|
|
63
|
+
# @return [Hash]
|
|
64
|
+
model_attr :namespaces
|
|
65
|
+
# @!attribute [r] schema_locations
|
|
66
|
+
# @return [Array<String>]
|
|
67
|
+
model_attr :schema_locations
|
|
29
68
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
rebuild_index
|
|
35
|
-
end
|
|
69
|
+
# # @return [Array<AnyElement>]
|
|
70
|
+
# model_attr :other_elements
|
|
71
|
+
# # @return [Array<AnyAttribute>]
|
|
72
|
+
# model_attr :other_attributes
|
|
36
73
|
|
|
37
|
-
|
|
38
|
-
|
|
74
|
+
# Constructor
|
|
75
|
+
def initialize(id:, name:, documentation: nil, properties: [],
|
|
76
|
+
metadata: nil, elements: [], relationships: [],
|
|
77
|
+
organizations: [], property_definitions: [],
|
|
78
|
+
version: nil, diagrams: [], viewpoints: [],
|
|
79
|
+
filename: nil, file_format: nil, archimate_version: :archimate_3_0,
|
|
80
|
+
namespaces: {}, schema_locations: [])
|
|
81
|
+
@id = id
|
|
82
|
+
@name = name
|
|
83
|
+
@documentation = documentation
|
|
84
|
+
@properties = properties
|
|
85
|
+
@metadata = metadata
|
|
86
|
+
@elements = elements
|
|
87
|
+
@relationships = relationships
|
|
88
|
+
@organizations = organizations
|
|
89
|
+
@property_definitions = property_definitions
|
|
90
|
+
@version = version
|
|
91
|
+
@diagrams = diagrams
|
|
92
|
+
@viewpoints = viewpoints
|
|
93
|
+
@filename = filename
|
|
94
|
+
@file_format = file_format
|
|
95
|
+
@archimate_version = archimate_version
|
|
96
|
+
@namespaces = namespaces
|
|
97
|
+
@schema_locations = schema_locations
|
|
98
|
+
rebuild_index
|
|
39
99
|
end
|
|
40
100
|
|
|
41
101
|
def lookup(id)
|
|
@@ -43,67 +103,27 @@ module Archimate
|
|
|
43
103
|
@index_hash[id]
|
|
44
104
|
end
|
|
45
105
|
|
|
106
|
+
# Called only by [Lint::DuplicateEntities]
|
|
46
107
|
def entities
|
|
47
108
|
@index_hash.values
|
|
48
109
|
end
|
|
49
110
|
|
|
111
|
+
# Called only by [Diff::Merge]
|
|
50
112
|
def rebuild_index(missing_id = :model_creation_event)
|
|
51
113
|
return self unless missing_id
|
|
52
114
|
@index_hash = build_index
|
|
53
115
|
self
|
|
54
116
|
end
|
|
55
117
|
|
|
56
|
-
def register(node, parent)
|
|
57
|
-
node.in_model = self
|
|
58
|
-
node.parent = parent
|
|
59
|
-
@index_hash[node.id] = node
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def deregister(node)
|
|
63
|
-
@index_hash.delete(node.id)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def find_by_class(klass)
|
|
67
|
-
@index_hash.values.select { |item| item.is_a?(klass) }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
118
|
def to_s
|
|
71
|
-
"#{Archimate::Color.data_model('Model')}<#{id}>[#{Archimate::Color.color(name, [
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# TODO: make these DSL like things added dynamically
|
|
75
|
-
def application_components
|
|
76
|
-
elements.select { |element| element.type == "ApplicationComponent" }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def element_type_names
|
|
80
|
-
elements.map(&:type).uniq
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def elements_with_type(el_type)
|
|
84
|
-
elements.select { |element| element.type == el_type }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# TODO: make these DSL like things added dynamically
|
|
88
|
-
def all_properties
|
|
89
|
-
@index_hash.values.each_with_object([]) do |i, a|
|
|
90
|
-
a.concat(i.properties) if i.respond_to?(:properties)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# TODO: refactor to use property def structure instead of separate property objects
|
|
95
|
-
def property_keys
|
|
96
|
-
all_properties.map(&:key).uniq
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# TODO: refactor to use property def structure instead of separate property objects
|
|
100
|
-
def property_def_id(key)
|
|
101
|
-
"propid-#{property_keys.index(key) + 1}"
|
|
119
|
+
"#{Archimate::Color.data_model('Model')}<#{id}>[#{Archimate::Color.color(name, %i[white underline])}]"
|
|
102
120
|
end
|
|
103
121
|
|
|
104
122
|
# Iterate through the model and ensure that elements, relationships, and
|
|
105
123
|
# diagrams are all present in the model's organizations. If an item is missing
|
|
106
124
|
# then move it into the default top-level element for the item type.
|
|
125
|
+
#
|
|
126
|
+
# @note this is only called by [Diff::Merge]
|
|
107
127
|
def organize
|
|
108
128
|
[]
|
|
109
129
|
.concat(elements)
|
|
@@ -117,34 +137,82 @@ module Archimate
|
|
|
117
137
|
self
|
|
118
138
|
end
|
|
119
139
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
# Only used by [Diff::DeletedItemsReferencedConflict]
|
|
141
|
+
def referenced_identified_nodes
|
|
142
|
+
classes = [Diagram, ViewNode, Connection, Organization, Relationship].freeze
|
|
143
|
+
@index_hash
|
|
144
|
+
.values
|
|
145
|
+
.select { |entity| classes.include?(entity.class) }
|
|
146
|
+
.map(&:referenced_identified_nodes)
|
|
147
|
+
.flatten
|
|
148
|
+
.uniq
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# This is used only by the model [Cli::Cleanup] class.
|
|
152
|
+
def unreferenced_nodes
|
|
153
|
+
identified_nodes - referenced_identified_nodes
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# def merge_entities(master_entity, copies)
|
|
157
|
+
# copies.delete(master_entity)
|
|
158
|
+
# copies.each do |copy|
|
|
159
|
+
# entities.each do |entity|
|
|
160
|
+
# case entity
|
|
161
|
+
# when entity == master_entity
|
|
162
|
+
# master_entity.merge(copy)
|
|
163
|
+
# when Organization
|
|
164
|
+
# entity.remove(copy.id)
|
|
165
|
+
# when ViewNode, Relationship, Connection
|
|
166
|
+
# entity.replace(copy, master_entity)
|
|
167
|
+
# end
|
|
168
|
+
# end
|
|
169
|
+
# deregister(copy)
|
|
170
|
+
# end
|
|
171
|
+
# end
|
|
172
|
+
|
|
173
|
+
private
|
|
174
|
+
|
|
175
|
+
# Only used by [#find_default_organization]
|
|
176
|
+
def add_organization(type, name)
|
|
177
|
+
raise "Program Error: #{organizations.inspect}" unless organizations.none? { |f| f.type == type || f.name == name }
|
|
178
|
+
organization = Organization.new(id: make_unique_id, name: LangString.create(name), type: type, items: [], organizations: [], documentation: nil)
|
|
179
|
+
register(organization, organizations)
|
|
180
|
+
organizations.push(organization)
|
|
181
|
+
organization
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def build_index
|
|
185
|
+
@index_hash = { id => self }
|
|
186
|
+
elements.each { |ref| @index_hash[ref.id] = ref }
|
|
187
|
+
relationships.each { |ref| @index_hash[ref.id] = ref }
|
|
188
|
+
diagrams.each { |dia| @index_hash[dia.id] = index_view_nodes(dia) }
|
|
189
|
+
property_definitions.each { |ref| @index_hash[ref.id] = ref }
|
|
190
|
+
index_organizations(self)
|
|
191
|
+
@index_hash
|
|
124
192
|
end
|
|
125
193
|
|
|
126
194
|
def default_organization_for(item)
|
|
127
195
|
case item
|
|
128
196
|
when Element
|
|
129
197
|
case item.layer
|
|
130
|
-
when
|
|
198
|
+
when Layers::Strategy
|
|
131
199
|
find_default_organization("strategy", "Strategy")
|
|
132
|
-
when
|
|
200
|
+
when Layers::Business
|
|
133
201
|
find_default_organization("business", "Business")
|
|
134
|
-
when
|
|
202
|
+
when Layers::Application
|
|
135
203
|
find_default_organization("application", "Application")
|
|
136
|
-
when
|
|
204
|
+
when Layers::Technology
|
|
137
205
|
find_default_organization("technology", "Technology")
|
|
138
|
-
when
|
|
206
|
+
when Layers::Physical
|
|
139
207
|
find_default_organization("physical", "Physical")
|
|
140
|
-
when
|
|
208
|
+
when Layers::Motivation
|
|
141
209
|
find_default_organization("motivation", "Motivation")
|
|
142
|
-
when
|
|
210
|
+
when Layers::Implementation_and_migration
|
|
143
211
|
find_default_organization("implementation_migration", "Implementation & Migration")
|
|
144
|
-
when
|
|
212
|
+
when Layers::Connectors
|
|
145
213
|
find_default_organization("connectors", "Connectors")
|
|
146
214
|
else
|
|
147
|
-
raise StandardError, "Unexpected Element Layer: #{item.layer
|
|
215
|
+
raise StandardError, "Unexpected Element Layer: #{item.layer} for item type #{item.type}"
|
|
148
216
|
end
|
|
149
217
|
when Relationship
|
|
150
218
|
find_default_organization("relations", "Relations")
|
|
@@ -155,6 +223,10 @@ module Archimate
|
|
|
155
223
|
end
|
|
156
224
|
end
|
|
157
225
|
|
|
226
|
+
def find_by_class(klass)
|
|
227
|
+
@index_hash.values.select { |item| item.is_a?(klass) }
|
|
228
|
+
end
|
|
229
|
+
|
|
158
230
|
def find_default_organization(type, name)
|
|
159
231
|
result = organizations.find { |f| f.type == type }
|
|
160
232
|
return result unless result.nil?
|
|
@@ -163,55 +235,50 @@ module Archimate
|
|
|
163
235
|
add_organization(type, name)
|
|
164
236
|
end
|
|
165
237
|
|
|
166
|
-
def
|
|
167
|
-
|
|
168
|
-
organization = Organization.new(id: make_unique_id, name: name, type: type, items: [], organizations: [])
|
|
169
|
-
register(organization, organizations)
|
|
170
|
-
organizations.push(organization)
|
|
171
|
-
organization
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def make_unique_id
|
|
175
|
-
unique_id = random_id
|
|
176
|
-
unique_id = random_id while @index_hash.key?(unique_id)
|
|
177
|
-
unique_id
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def referenced_identified_nodes
|
|
181
|
-
super.uniq
|
|
238
|
+
def find_in_organizations(item, _fs = nil)
|
|
239
|
+
find_by_class(DataModel::Organization).select { |f| f.items.include?(item.id) }.first
|
|
182
240
|
end
|
|
183
241
|
|
|
242
|
+
# Only used by [#unreferenced_nodes]
|
|
184
243
|
def identified_nodes
|
|
185
|
-
@index_hash.values.select { |node| node.
|
|
244
|
+
@index_hash.values.select { |node| node.respond_to? :id }
|
|
186
245
|
end
|
|
187
246
|
|
|
188
|
-
|
|
189
|
-
|
|
247
|
+
# @todo make this private - maybe move to [Organization]
|
|
248
|
+
def index_organizations(ref)
|
|
249
|
+
ref.organizations.each do |org|
|
|
250
|
+
@index_hash[org.id] = index_organizations(org)
|
|
251
|
+
end
|
|
252
|
+
ref
|
|
190
253
|
end
|
|
191
254
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
case entity
|
|
197
|
-
when entity == master_entity
|
|
198
|
-
master_entity.merge(copy)
|
|
199
|
-
when Organization
|
|
200
|
-
entity.remove(copy.id)
|
|
201
|
-
when ViewNode, Relationship, Connection
|
|
202
|
-
entity.replace(copy, master_entity)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
deregister(copy)
|
|
255
|
+
# @todo make this private - maybe move to [ViewNode]
|
|
256
|
+
def index_view_nodes(ref)
|
|
257
|
+
ref.nodes.each do |node|
|
|
258
|
+
@index_hash[node.id] = index_view_nodes(node)
|
|
206
259
|
end
|
|
260
|
+
ref.connections.each { |con| @index_hash[con.id] = con }
|
|
261
|
+
ref
|
|
207
262
|
end
|
|
208
263
|
|
|
209
|
-
|
|
264
|
+
def make_unique_id
|
|
265
|
+
unique_id = random_id
|
|
266
|
+
unique_id = random_id while @index_hash.key?(unique_id)
|
|
267
|
+
unique_id
|
|
268
|
+
end
|
|
210
269
|
|
|
211
270
|
def random_id
|
|
212
271
|
@random ||= Random.new
|
|
213
272
|
format("%08x", @random.rand(0xffffffff))
|
|
214
273
|
end
|
|
274
|
+
|
|
275
|
+
def register(node, _parent)
|
|
276
|
+
@index_hash[node.id] = node
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def deregister(node)
|
|
280
|
+
@index_hash.delete(node.id)
|
|
281
|
+
end
|
|
215
282
|
end
|
|
216
283
|
end
|
|
217
284
|
end
|
|
@@ -4,10 +4,21 @@ module Archimate
|
|
|
4
4
|
module DataModel
|
|
5
5
|
# This is a set of notes to the modeler on how to use and model with this viewpoint. Could contain rules
|
|
6
6
|
# or constraints. The part hold the information for this element.
|
|
7
|
-
class ModelingNote
|
|
8
|
-
|
|
7
|
+
class ModelingNote
|
|
8
|
+
include Comparison
|
|
9
|
+
|
|
10
|
+
# @!attribute [r] documentation
|
|
11
|
+
# @return [PreservedLangString]
|
|
12
|
+
model_attr :documentation
|
|
9
13
|
# `type` attribute expresses a type for the notes, e.g. OCL for OCL rules.
|
|
10
|
-
attribute
|
|
14
|
+
# @!attribute [r] type
|
|
15
|
+
# @return [String, NilClass]
|
|
16
|
+
model_attr :type
|
|
17
|
+
|
|
18
|
+
def initialize(documentation:, type: nil)
|
|
19
|
+
@documentation = documentation
|
|
20
|
+
@type = type
|
|
21
|
+
end
|
|
11
22
|
end
|
|
12
23
|
end
|
|
13
24
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module Archimate
|
|
3
4
|
module DataModel
|
|
4
5
|
# An organization element represents a structural node in a particular organization of the model concepts.
|
|
@@ -10,19 +11,50 @@ module Archimate
|
|
|
10
11
|
#
|
|
11
12
|
# An organization has no meaning unless it has at least child organization element.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
class Organization
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
attribute
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
14
|
+
# @note that Organization must fit into a tree structure (so strictly nested).
|
|
15
|
+
class Organization
|
|
16
|
+
include Comparison
|
|
17
|
+
|
|
18
|
+
# Format should match +/[[[:alpha:]]_][w-.]*/+ to be valid for Archimate
|
|
19
|
+
# Model exchange format
|
|
20
|
+
# @!attribute [r] id
|
|
21
|
+
# @return [String, NilClass]
|
|
22
|
+
model_attr :id
|
|
23
|
+
# LabelGroup in the XSD
|
|
24
|
+
# @!attribute [r] name
|
|
25
|
+
# @return [LangString, NilClass]
|
|
26
|
+
model_attr :name
|
|
27
|
+
# I believe this is used only for Archi formats
|
|
28
|
+
# @!attribute [r] type
|
|
29
|
+
# @return [String, NilClass]
|
|
30
|
+
model_attr :type
|
|
31
|
+
# @!attribute [r] documentation
|
|
32
|
+
# @return [PreservedLangString, NilClass]
|
|
33
|
+
model_attr :documentation
|
|
34
|
+
# @!attribute [rw] items
|
|
35
|
+
# @return [Array<Object>]
|
|
36
|
+
model_attr :items, writable: true
|
|
37
|
+
# item in the XSD
|
|
38
|
+
# @!attribute [rw] organizations
|
|
39
|
+
# @return [Array<Organization>]
|
|
40
|
+
model_attr :organizations, writable: true
|
|
41
|
+
# # @return [Array<AnyElement>]
|
|
42
|
+
# model_attr :other_elements
|
|
43
|
+
# # @return [Array<AnyAttribute>]
|
|
44
|
+
# model_attr :other_attributes
|
|
45
|
+
|
|
46
|
+
def initialize(id: nil, name: nil, type: nil, documentation: nil,
|
|
47
|
+
items: [], organizations: [])
|
|
48
|
+
@id = id
|
|
49
|
+
@name = name
|
|
50
|
+
@type = type
|
|
51
|
+
@documentation = documentation
|
|
52
|
+
@items = items
|
|
53
|
+
@organizations = organizations
|
|
54
|
+
end
|
|
23
55
|
|
|
24
56
|
def to_s
|
|
25
|
-
"#{Archimate::Color.data_model('Organization')}<#{id}>[#{Archimate::Color.color(name, [
|
|
57
|
+
"#{Archimate::Color.data_model('Organization')}<#{id}>[#{Archimate::Color.color(name, %i[white underline])}]"
|
|
26
58
|
end
|
|
27
59
|
|
|
28
60
|
def referenced_identified_nodes
|
|
@@ -32,9 +64,8 @@ module Archimate
|
|
|
32
64
|
end
|
|
33
65
|
|
|
34
66
|
def remove(id)
|
|
35
|
-
items.
|
|
67
|
+
items.delete_if { |item| item.id == id }
|
|
36
68
|
end
|
|
37
69
|
end
|
|
38
|
-
Dry::Types.register_class(Organization)
|
|
39
70
|
end
|
|
40
71
|
end
|