archimate 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/archimate.gemspec +2 -1
- data/lib/archimate/color.rb +2 -2
- data/lib/archimate/data_model/any_attribute.rb +4 -10
- data/lib/archimate/data_model/any_element.rb +9 -17
- data/lib/archimate/data_model/bounds.rb +6 -6
- data/lib/archimate/data_model/color.rb +6 -6
- data/lib/archimate/data_model/comparison.rb +101 -5
- data/lib/archimate/data_model/concern.rb +5 -13
- data/lib/archimate/data_model/connection.rb +39 -48
- data/lib/archimate/data_model/connector_type.rb +1 -0
- data/lib/archimate/data_model/diagram.rb +27 -42
- data/lib/archimate/data_model/diagram_type.rb +1 -0
- data/lib/archimate/data_model/element.rb +14 -35
- data/lib/archimate/data_model/elements.rb +681 -0
- data/lib/archimate/data_model/font.rb +8 -8
- data/lib/archimate/data_model/lang_string.rb +10 -36
- data/lib/archimate/data_model/layer.rb +4 -5
- data/lib/archimate/data_model/layers.rb +45 -49
- data/lib/archimate/data_model/location.rb +6 -6
- data/lib/archimate/data_model/metadata.rb +2 -6
- data/lib/archimate/data_model/model.rb +50 -62
- data/lib/archimate/data_model/modeling_note.rb +3 -8
- data/lib/archimate/data_model/organization.rb +18 -27
- data/lib/archimate/data_model/property.rb +9 -8
- data/lib/archimate/data_model/property_definition.rb +15 -21
- data/lib/archimate/data_model/referenceable.rb +14 -9
- data/lib/archimate/data_model/referenceable_list.rb +82 -0
- data/lib/archimate/data_model/relationship.rb +41 -152
- data/lib/archimate/data_model/relationship_references.rb +29 -0
- data/lib/archimate/data_model/relationships.rb +214 -0
- data/lib/archimate/data_model/schema_info.rb +6 -12
- data/lib/archimate/data_model/style.rb +14 -25
- data/lib/archimate/data_model/view_node.rb +38 -66
- data/lib/archimate/data_model/viewpoint.rb +23 -38
- data/lib/archimate/data_model/viewpoint_type.rb +347 -387
- data/lib/archimate/data_model.rb +7 -6
- data/lib/archimate/derived_relations.rb +106 -31
- data/lib/archimate/export/cypher.rb +0 -18
- data/lib/archimate/export/jsonl.rb +16 -45
- data/lib/archimate/export/n_quads.rb +1 -24
- data/lib/archimate/file_formats/archi_file_reader.rb +2 -1
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +9 -1
- data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +2 -2
- data/lib/archimate/file_formats/sax/archi/connection.rb +2 -1
- data/lib/archimate/file_formats/sax/archi/element.rb +7 -5
- data/lib/archimate/file_formats/sax/archi/relationship.rb +1 -1
- data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +2 -1
- data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +1 -1
- data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +1 -1
- data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +0 -1
- data/lib/archimate/file_formats/serializer/archi/relationship.rb +1 -1
- data/lib/archimate/lint/duplicate_entities.rb +46 -42
- data/lib/archimate/svg/archimate.css +12 -2
- data/lib/archimate/svg/entity/base_entity.rb +6 -29
- data/lib/archimate/svg/entity/location.rb +1 -0
- data/lib/archimate/svg/entity_factory.rb +3 -3
- data/lib/archimate/svg/point.rb +3 -3
- data/lib/archimate/svg/svg_template.svg.erb +5 -5
- data/lib/archimate/version.rb +2 -1
- metadata +20 -6
- data/TODOs.org +0 -505
- data/lib/archimate/data_model/differentiable.rb +0 -142
- data/lib/archimate/data_model/element_type.rb +0 -89
- data/lib/archimate/data_model/relationship_type.rb +0 -45
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module Archimate
|
6
|
+
module DataModel
|
7
|
+
# A list of things that can be referenced by another entity.
|
8
|
+
class ReferenceableList
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegators :@list,
|
12
|
+
:[],
|
13
|
+
:all?,
|
14
|
+
:dig,
|
15
|
+
:each_with_object,
|
16
|
+
:find,
|
17
|
+
:hash,
|
18
|
+
:include?,
|
19
|
+
:map,
|
20
|
+
:none?,
|
21
|
+
:select,
|
22
|
+
:==,
|
23
|
+
:each,
|
24
|
+
:empty?,
|
25
|
+
:first,
|
26
|
+
:reduce,
|
27
|
+
:size
|
28
|
+
|
29
|
+
attr_reader :parent
|
30
|
+
|
31
|
+
def initialize(parent, contents = [], parent_attr_references = [])
|
32
|
+
@parent = parent
|
33
|
+
@parent_attr_references = parent_attr_references
|
34
|
+
@list = contents || []
|
35
|
+
add_references
|
36
|
+
end
|
37
|
+
|
38
|
+
def replace_with(contents)
|
39
|
+
remove_references
|
40
|
+
@list = contents
|
41
|
+
add_references
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_ary
|
45
|
+
Array.new(@list).freeze
|
46
|
+
end
|
47
|
+
|
48
|
+
def push(item)
|
49
|
+
return if @list.include?(item)
|
50
|
+
add_item_references(item)
|
51
|
+
@list << item
|
52
|
+
end
|
53
|
+
|
54
|
+
def inspect
|
55
|
+
vals = @list.first(3).map(&:brief_inspect)
|
56
|
+
"[#{vals.join(', ')}#{"...#{@list.size}" if @list.size > 3}]"
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def add_references
|
62
|
+
@list.each { |item| add_item_references(item) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_item_references(item)
|
66
|
+
item.add_reference(parent)
|
67
|
+
@parent_attr_references.each do |attr|
|
68
|
+
item.add_reference(parent.send(attr)) if parent.send(attr)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def remove_references
|
73
|
+
@list.each do |item|
|
74
|
+
item.remove_reference(parent)
|
75
|
+
@parent_attr_references.each do |attr|
|
76
|
+
item.remove_reference(parent.send(attr)) if parent.send(attr)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -3,90 +3,70 @@
|
|
3
3
|
module Archimate
|
4
4
|
module DataModel
|
5
5
|
ACCESS_TYPE = %w[Access Read Write ReadWrite].freeze
|
6
|
-
AccessTypeEnum = String #String.enum(*ACCESS_TYPE)
|
6
|
+
AccessTypeEnum = String # String.enum(*ACCESS_TYPE)
|
7
7
|
|
8
8
|
# A base relationship type that can be extended by concrete ArchiMate types.
|
9
9
|
#
|
10
|
-
# Note that RelationshipType is abstract, so one must have derived types of
|
11
|
-
# by having a tag name of "relationship"
|
12
|
-
#
|
10
|
+
# Note that RelationshipType is abstract, so one must have derived types of
|
11
|
+
# this type. this is indicated in xml by having a tag name of "relationship"
|
12
|
+
# and an attribute of xsi:type="AccessRelationship" where AccessRelationship
|
13
|
+
# is a derived type from RelationshipType.
|
13
14
|
class Relationship
|
14
|
-
# @todo: this should be removed once concrete Relationships are used.
|
15
|
-
# @deprecated
|
16
|
-
WEIGHTS = {
|
17
|
-
'GroupingRelationship' => 0,
|
18
|
-
'JunctionRelationship' => 0,
|
19
|
-
'AssociationRelationship' => 0,
|
20
|
-
'SpecialisationRelationship' => 1,
|
21
|
-
'FlowRelationship' => 2,
|
22
|
-
'TriggeringRelationship' => 3,
|
23
|
-
'InfluenceRelationship' => 4,
|
24
|
-
'AccessRelationship' => 5,
|
25
|
-
'ServingRelationship' => 6,
|
26
|
-
'UsedByRelationship' => 6,
|
27
|
-
'RealizationRelationship' => 7,
|
28
|
-
'RealisationRelationship' => 7,
|
29
|
-
'AssignmentRelationship' => 8,
|
30
|
-
'AggregationRelationship' => 9,
|
31
|
-
'CompositionRelationship' => 10
|
32
|
-
}
|
33
|
-
|
34
15
|
include Comparison
|
16
|
+
include Referenceable
|
35
17
|
|
36
18
|
# @!attribute [r] id
|
37
|
-
#
|
19
|
+
# @return [String]
|
38
20
|
model_attr :id
|
39
21
|
# @!attribute [r] name
|
40
|
-
#
|
41
|
-
model_attr :name
|
22
|
+
# @return [LangString, NilClass]
|
23
|
+
model_attr :name, default: nil
|
42
24
|
# @!attribute [r] documentation
|
43
|
-
#
|
44
|
-
model_attr :documentation
|
45
|
-
#
|
25
|
+
# @return [PreservedLangString, NilClass]
|
26
|
+
model_attr :documentation, default: nil
|
27
|
+
# @return [Array<AnyElement>]
|
46
28
|
# model_attr :other_elements
|
47
|
-
#
|
29
|
+
# @return [Array<AnyAttribute>]
|
48
30
|
# model_attr :other_attributes
|
49
|
-
# @note type here was used for the Element/Relationship/Diagram type
|
50
|
-
# @!attribute [r] type
|
51
|
-
# @return [String, NilClass]
|
52
|
-
model_attr :type
|
53
31
|
# @!attribute [r] properties
|
54
|
-
#
|
55
|
-
model_attr :properties
|
32
|
+
# @return [Array<Property>]
|
33
|
+
model_attr :properties, default: []
|
56
34
|
# @todo is this optional?
|
57
35
|
# @!attribute [rw] source
|
58
|
-
#
|
59
|
-
model_attr :source, comparison_attr: :id, writable: true
|
36
|
+
# @return [Element, Relationship]
|
37
|
+
model_attr :source, comparison_attr: :id, writable: true, default: nil
|
60
38
|
# @todo is this optional?
|
61
39
|
# @!attribute [rw] target
|
62
|
-
#
|
63
|
-
model_attr :target, comparison_attr: :id, writable: true
|
40
|
+
# @return [Element, Relationship]
|
41
|
+
model_attr :target, comparison_attr: :id, writable: true, default: nil
|
64
42
|
# @!attribute [r] access_type
|
65
|
-
#
|
66
|
-
model_attr :access_type
|
43
|
+
# @return [AccessTypeEnum, NilClass]
|
44
|
+
model_attr :access_type, default: nil
|
67
45
|
# @!attribute [r] derived
|
68
|
-
#
|
69
|
-
model_attr :derived
|
70
|
-
|
71
|
-
def initialize(id:, name: nil, documentation: nil, type: nil,
|
72
|
-
properties: [], source:, target:, access_type: nil,
|
73
|
-
derived: false)
|
74
|
-
@id = id
|
75
|
-
@name = name
|
76
|
-
@documentation = documentation
|
77
|
-
@type = type
|
78
|
-
@properties = properties
|
79
|
-
@source = source
|
80
|
-
@target = target
|
81
|
-
@access_type = access_type
|
82
|
-
@derived = derived
|
83
|
-
end
|
46
|
+
# @return [Boolean] this is a derived relation if true
|
47
|
+
model_attr :derived, default: false
|
84
48
|
|
85
49
|
def replace(entity, with_entity)
|
86
50
|
@source = with_entity.id if source == entity.id
|
87
51
|
@target = with_entity.id if target == entity.id
|
88
52
|
end
|
89
53
|
|
54
|
+
def type
|
55
|
+
self.class.name.split("::").last
|
56
|
+
end
|
57
|
+
|
58
|
+
def weight
|
59
|
+
self.class::WEIGHT
|
60
|
+
end
|
61
|
+
|
62
|
+
def classification
|
63
|
+
self.class::CLASSIFICATION
|
64
|
+
end
|
65
|
+
|
66
|
+
def verb
|
67
|
+
self.class::VERB
|
68
|
+
end
|
69
|
+
|
90
70
|
def to_s
|
91
71
|
Archimate::Color.color(
|
92
72
|
"#{Archimate::Color.data_model(type)}<#{id}>[#{Archimate::Color.color(name&.strip || '', %i[black underline])}]",
|
@@ -97,7 +77,7 @@ module Archimate
|
|
97
77
|
def description
|
98
78
|
[
|
99
79
|
name.nil? ? nil : "#{name}:",
|
100
|
-
|
80
|
+
verb
|
101
81
|
].compact.join(" ")
|
102
82
|
end
|
103
83
|
|
@@ -107,13 +87,6 @@ module Archimate
|
|
107
87
|
[@source, @target].compact
|
108
88
|
end
|
109
89
|
|
110
|
-
# Diagrams that this element is referenced in.
|
111
|
-
def diagrams
|
112
|
-
@diagrams ||= in_model.diagrams.select do |diagram|
|
113
|
-
diagram.relationship_ids.include?(id)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
90
|
# Copy any attributes/docs, etc. from each of the others into the original.
|
118
91
|
# 1. Child `label`s with different `xml:lang` attribute values
|
119
92
|
# 2. Child `documentation` (and different `xml:lang` attribute values)
|
@@ -122,92 +95,8 @@ module Archimate
|
|
122
95
|
# source and target don't change on a merge
|
123
96
|
def merge(relationship)
|
124
97
|
super
|
125
|
-
access_type ||= relationship.access_type
|
98
|
+
@access_type ||= relationship.access_type
|
126
99
|
end
|
127
|
-
|
128
|
-
def weight
|
129
|
-
WEIGHTS.fetch(type, 0)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Relationship Classifications: Structural, Dynamic, Dependency, Other
|
134
|
-
# • No relationships are allowed between two relationships
|
135
|
-
# • All relationships connected with relationship connectors must be of
|
136
|
-
# the same type
|
137
|
-
# • A chain of relationships of the same type that connects two elements,
|
138
|
-
# and is in turn connected via relationship connectors, is valid only if
|
139
|
-
# a direct relationship of that same type between those two elements is
|
140
|
-
# valid
|
141
|
-
# • A relationship connecting an element with a second relationship can
|
142
|
-
# only be an aggregation, composition, or association; aggregation or
|
143
|
-
# composition are valid only from a composite element to that second
|
144
|
-
# relationship
|
145
|
-
#
|
146
|
-
# Aggregation, composition, and specialization relationships are always
|
147
|
-
# permitted between two elements of the same type, and association is
|
148
|
-
# always allowed between any two elements, and between any element and
|
149
|
-
# relationship.
|
150
|
-
|
151
|
-
class Composition < Relationship
|
152
|
-
CLASSIFICATION = :structural
|
153
|
-
WEIGHT = 10
|
154
|
-
end
|
155
|
-
|
156
|
-
class Aggregation < Relationship
|
157
|
-
CLASSIFICATION = :structural
|
158
|
-
WEIGHT = 9
|
159
|
-
end
|
160
|
-
|
161
|
-
class Assignment < Relationship
|
162
|
-
CLASSIFICATION = :structural
|
163
|
-
WEIGHT = 8
|
164
|
-
end
|
165
|
-
|
166
|
-
class Realization < Relationship
|
167
|
-
CLASSIFICATION = :structural
|
168
|
-
WEIGHT = 7
|
169
|
-
end
|
170
|
-
|
171
|
-
class Serving < Relationship
|
172
|
-
CLASSIFICATION = :dependency
|
173
|
-
WEIGHT = 6
|
174
|
-
end
|
175
|
-
|
176
|
-
class Access < Relationship
|
177
|
-
CLASSIFICATION = :dependency
|
178
|
-
WEIGHT = 5
|
179
|
-
end
|
180
|
-
|
181
|
-
class Influence < Relationship
|
182
|
-
CLASSIFICATION = :dependency
|
183
|
-
WEIGHT = 4
|
184
|
-
end
|
185
|
-
|
186
|
-
class Triggering < Relationship
|
187
|
-
CLASSIFICATION = :dynamic
|
188
|
-
WEIGHT = 3
|
189
|
-
end
|
190
|
-
|
191
|
-
class Flow < Relationship
|
192
|
-
CLASSIFICATION = :dynamic
|
193
|
-
WEIGHT = 2
|
194
|
-
end
|
195
|
-
|
196
|
-
class Specialization < Relationship
|
197
|
-
CLASSIFICATION = :other
|
198
|
-
WEIGHT = 1
|
199
|
-
end
|
200
|
-
|
201
|
-
class Association < Relationship
|
202
|
-
CLASSIFICATION = :other
|
203
|
-
WEIGHT = 0
|
204
|
-
end
|
205
|
-
|
206
|
-
# Junction is a relationship connector
|
207
|
-
# • All relationships connected with relationship connectors must be of the same type
|
208
|
-
class Junction < Relationship
|
209
|
-
CLASSIFICATION = :other
|
210
|
-
WEIGHT = 0
|
211
100
|
end
|
212
101
|
end
|
213
102
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module DataModel
|
5
|
+
# RelationshipReferences provides a means to allow a class that is referenced
|
6
|
+
# by Relationship objects to get the set of:
|
7
|
+
# * All relationships
|
8
|
+
# * All relationships by:
|
9
|
+
# - a particular type
|
10
|
+
# - if this object is the source of target of the relationship
|
11
|
+
module RelationshipReferences
|
12
|
+
def relationships
|
13
|
+
references.select { |ref| ref.is_a?(DataModel::Relationship) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(_base)
|
17
|
+
Relationships.classes.each do |rel_cls|
|
18
|
+
define_method(rel_cls::VERB.tr(' ', '_').to_sym) do
|
19
|
+
references.select { |ref| ref.is_a?(rel_cls) && ref.source == self }
|
20
|
+
end
|
21
|
+
|
22
|
+
define_method(rel_cls::OBJECT_VERB.tr(' ', '_').to_sym) do
|
23
|
+
references.select { |ref| ref.is_a?(rel_cls) && ref.target == self }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module DataModel
|
5
|
+
# Relationship Classifications: Structural, Dynamic, Dependency, Other
|
6
|
+
# * No relationships are allowed between two relationships
|
7
|
+
# * All relationships connected with relationship connectors must be of
|
8
|
+
# the same type
|
9
|
+
# * A chain of relationships of the same type that connects two elements,
|
10
|
+
# and is in turn connected via relationship connectors, is valid only if
|
11
|
+
# a direct relationship of that same type between those two elements is
|
12
|
+
# valid
|
13
|
+
# * A relationship connecting an element with a second relationship can
|
14
|
+
# only be an aggregation, composition, or association; aggregation or
|
15
|
+
# composition are valid only from a composite element to that second
|
16
|
+
# relationship
|
17
|
+
#
|
18
|
+
# Aggregation, composition, and specialization relationships are always
|
19
|
+
# permitted between two elements of the same type, and association is
|
20
|
+
# always allowed between any two elements, and between any element and
|
21
|
+
# relationship.
|
22
|
+
module Relationships
|
23
|
+
class Composition < Relationship
|
24
|
+
WEIGHT = 10
|
25
|
+
CLASSIFICATION = :structural
|
26
|
+
VERB = "composes"
|
27
|
+
OBJECT_VERB = "composed by"
|
28
|
+
|
29
|
+
def initialize(args)
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Aggregation < Relationship
|
35
|
+
WEIGHT = 9
|
36
|
+
CLASSIFICATION = :structural
|
37
|
+
VERB = "aggregates"
|
38
|
+
OBJECT_VERB = "aggregated by"
|
39
|
+
|
40
|
+
def initialize(args)
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Assignment < Relationship
|
46
|
+
WEIGHT = 8
|
47
|
+
CLASSIFICATION = :structural
|
48
|
+
VERB = "assigned to"
|
49
|
+
OBJECT_VERB = "assigned from"
|
50
|
+
|
51
|
+
def initialize(args)
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Realization < Relationship
|
57
|
+
WEIGHT = 7
|
58
|
+
CLASSIFICATION = :structural
|
59
|
+
VERB = "realizes"
|
60
|
+
OBJECT_VERB = "realized by"
|
61
|
+
|
62
|
+
def initialize(args)
|
63
|
+
super
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Serving < Relationship
|
68
|
+
WEIGHT = 6
|
69
|
+
CLASSIFICATION = :dependency
|
70
|
+
VERB = "serves"
|
71
|
+
OBJECT_VERB = "served by"
|
72
|
+
|
73
|
+
def initialize(args)
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Access < Relationship
|
79
|
+
WEIGHT = 5
|
80
|
+
CLASSIFICATION = :dependency
|
81
|
+
VERB = "accesses"
|
82
|
+
OBJECT_VERB = "accessed by"
|
83
|
+
|
84
|
+
def initialize(args)
|
85
|
+
super
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class Influence < Relationship
|
90
|
+
WEIGHT = 4
|
91
|
+
CLASSIFICATION = :dependency
|
92
|
+
VERB = "influences"
|
93
|
+
OBJECT_VERB = "influenced by"
|
94
|
+
|
95
|
+
def initialize(args)
|
96
|
+
super
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Triggering < Relationship
|
101
|
+
WEIGHT = 3
|
102
|
+
CLASSIFICATION = :dynamic
|
103
|
+
VERB = "triggers"
|
104
|
+
OBJECT_VERB = "triggered by"
|
105
|
+
|
106
|
+
def initialize(args)
|
107
|
+
super
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class Flow < Relationship
|
112
|
+
WEIGHT = 2
|
113
|
+
CLASSIFICATION = :dynamic
|
114
|
+
VERB = "flows to"
|
115
|
+
OBJECT_VERB = "flows from"
|
116
|
+
|
117
|
+
def initialize(args)
|
118
|
+
super
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class Specialization < Relationship
|
123
|
+
WEIGHT = 1
|
124
|
+
CLASSIFICATION = :other
|
125
|
+
VERB = "specializes"
|
126
|
+
OBJECT_VERB = "specialized by"
|
127
|
+
|
128
|
+
def initialize(args)
|
129
|
+
super
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class Association < Relationship
|
134
|
+
WEIGHT = 0
|
135
|
+
CLASSIFICATION = :other
|
136
|
+
VERB = "associated with"
|
137
|
+
OBJECT_VERB = "associated from"
|
138
|
+
|
139
|
+
def initialize(args)
|
140
|
+
super
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Junction is a relationship connector
|
145
|
+
# * All relationships connected with relationship connectors must be of the same type
|
146
|
+
class Junction < Relationship
|
147
|
+
WEIGHT = 0
|
148
|
+
CLASSIFICATION = :other
|
149
|
+
VERB = "junction to"
|
150
|
+
OBJECT_VERB = "junction from"
|
151
|
+
|
152
|
+
def initialize(args)
|
153
|
+
super
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Junction is a relationship connector
|
158
|
+
# * All relationships connected with relationship connectors must be of the same type
|
159
|
+
class AndJunction < Relationship
|
160
|
+
WEIGHT = 0
|
161
|
+
CLASSIFICATION = :other
|
162
|
+
VERB = "and junction to"
|
163
|
+
OBJECT_VERB = "and junction from"
|
164
|
+
|
165
|
+
def initialize(args)
|
166
|
+
super
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Junction is a relationship connector
|
171
|
+
# * All relationships connected with relationship connectors must be of the same type
|
172
|
+
class OrJunction < Relationship
|
173
|
+
WEIGHT = 0
|
174
|
+
CLASSIFICATION = :other
|
175
|
+
VERB = "or junction to"
|
176
|
+
OBJECT_VERB = "or junction from"
|
177
|
+
|
178
|
+
def initialize(args)
|
179
|
+
super
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.create(*args)
|
184
|
+
# type = args[0].delete(:type)
|
185
|
+
# cls_name = type.strip.sub(/Relationship$/, '')
|
186
|
+
# cls_name = RELATIONSHIP_SUBSTITUTIONS.fetch(cls_name, cls_name)
|
187
|
+
cls_name = str_filter(args[0].delete(:type))
|
188
|
+
Relationships.const_get(cls_name).new(*args)
|
189
|
+
rescue NameError => err
|
190
|
+
Archimate::Logging.error "An invalid relationship type '#{cls_name}' was used to create a Relationship"
|
191
|
+
raise err
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.===(other)
|
195
|
+
constants.map(&:to_s).include?(str_filter(other))
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.str_filter(str)
|
199
|
+
relationship_substitutions = {
|
200
|
+
"Realisation" => "Realization",
|
201
|
+
"Specialisation" => "Specialization",
|
202
|
+
"UsedBy" => "Serving"
|
203
|
+
}.freeze
|
204
|
+
|
205
|
+
cls_name = str.strip.sub(/Relationship$/, '')
|
206
|
+
relationship_substitutions.fetch(cls_name, cls_name)
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.classes
|
210
|
+
constants.map { |cls_name| const_get(cls_name) }
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -6,20 +6,14 @@ module Archimate
|
|
6
6
|
include Comparison
|
7
7
|
|
8
8
|
# @!attribute [r] schema
|
9
|
-
#
|
10
|
-
model_attr :schema
|
9
|
+
# @return [String, NilClass]
|
10
|
+
model_attr :schema, default: nil
|
11
11
|
# @!attribute [r] schemaversion
|
12
|
-
#
|
13
|
-
model_attr :schemaversion
|
12
|
+
# @return [String, NilClass]
|
13
|
+
model_attr :schemaversion, default: nil
|
14
14
|
# @!attribute [r] elements
|
15
|
-
#
|
16
|
-
model_attr :elements
|
17
|
-
|
18
|
-
def initialize(schema: nil, schemaversion: nil, elements: [])
|
19
|
-
@schema = schema
|
20
|
-
@schemaversion = schemaversion
|
21
|
-
@elements = elements
|
22
|
-
end
|
15
|
+
# @return [Array<AnyElement>]
|
16
|
+
model_attr :elements, default: []
|
23
17
|
|
24
18
|
def to_s
|
25
19
|
"#{type.light_black}[#{schema} #{schemaversion}]"
|
@@ -7,39 +7,28 @@ module Archimate
|
|
7
7
|
|
8
8
|
# @todo make this an enum
|
9
9
|
# @!attribute [r] text_alignment
|
10
|
-
#
|
11
|
-
model_attr :text_alignment
|
10
|
+
# @return [Int, NilClass]
|
11
|
+
model_attr :text_alignment, default: nil
|
12
12
|
# @!attribute [r] fill_color
|
13
|
-
#
|
14
|
-
model_attr :fill_color
|
13
|
+
# @return [Color, NilClass]
|
14
|
+
model_attr :fill_color, default: nil
|
15
15
|
# @!attribute [r] line_color
|
16
|
-
#
|
17
|
-
model_attr :line_color
|
16
|
+
# @return [Color, NilClass]
|
17
|
+
model_attr :line_color, default: nil
|
18
18
|
# @todo move this to font
|
19
19
|
# @!attribute [r] font_color
|
20
|
-
#
|
21
|
-
model_attr :font_color
|
20
|
+
# @return [Color, NilClass]
|
21
|
+
model_attr :font_color, default: nil
|
22
22
|
# @!attribute [r] line_width
|
23
|
-
#
|
24
|
-
model_attr :line_width
|
23
|
+
# @return [Int, NilClass]
|
24
|
+
model_attr :line_width, default: nil
|
25
25
|
# @!attribute [r] font
|
26
|
-
#
|
27
|
-
model_attr :font
|
26
|
+
# @return [Font, NilClass]
|
27
|
+
model_attr :font, default: nil
|
28
28
|
# @todo make this an enum
|
29
29
|
# @!attribute [r] text_position
|
30
|
-
#
|
31
|
-
model_attr :text_position
|
32
|
-
|
33
|
-
def initialize(text_alignment: nil, fill_color: nil, line_color: nil,
|
34
|
-
font_color: nil, line_width: nil, font: nil, text_position: nil)
|
35
|
-
@text_alignment = text_alignment
|
36
|
-
@fill_color = fill_color
|
37
|
-
@line_color = line_color
|
38
|
-
@font_color = font_color
|
39
|
-
@line_width = line_width
|
40
|
-
@font = font
|
41
|
-
@text_position = text_position
|
42
|
-
end
|
30
|
+
# @return [Int, NilClass]
|
31
|
+
model_attr :text_position, default: nil
|
43
32
|
|
44
33
|
def to_s
|
45
34
|
attr_name_vals = %i[text_alignment fill_color line_color font_color line_width
|