archimate 2.0.2 → 2.0.3
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 +5 -5
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/README.md +10 -55
- data/Rakefile +19 -1
- data/archimate.gemspec +16 -14
- data/bin/archimate +12 -0
- data/lib/archimate/cli/archi.rb +38 -19
- data/lib/archimate/cli/cleanup.rb +41 -25
- data/lib/archimate/cli/duper.rb +0 -1
- data/lib/archimate/cli/mapper.rb +53 -40
- data/lib/archimate/cli/svger.rb +33 -4
- data/lib/archimate/core_refinements.rb +41 -0
- data/lib/archimate/data_model/bounds.rb +14 -4
- data/lib/archimate/data_model/comparison.rb +3 -27
- data/lib/archimate/data_model/connection.rb +26 -11
- data/lib/archimate/data_model/diagram.rb +17 -10
- data/lib/archimate/data_model/element.rb +21 -9
- data/lib/archimate/data_model/elements.rb +24 -18
- data/lib/archimate/data_model/lang_string.rb +34 -10
- data/lib/archimate/data_model/layer.rb +6 -0
- data/lib/archimate/data_model/location.rb +10 -13
- data/lib/archimate/data_model/model.rb +55 -43
- data/lib/archimate/data_model/organization.rb +21 -5
- data/lib/archimate/data_model/property.rb +0 -6
- data/lib/archimate/data_model/referenceable.rb +29 -3
- data/lib/archimate/data_model/referenceable_list.rb +34 -14
- data/lib/archimate/data_model/relationship.rb +29 -8
- data/lib/archimate/data_model/relationship_references.rb +115 -6
- data/lib/archimate/data_model/relationships.rb +15 -0
- data/lib/archimate/data_model/view_node.rb +20 -13
- data/lib/archimate/data_model/viewpoint.rb +13 -1
- data/lib/archimate/data_model/viewpoints.rb +416 -0
- data/lib/archimate/data_model.rb +7 -1
- data/lib/archimate/derived_relations.rb +2 -11
- data/lib/archimate/export/cypher.rb +6 -5
- data/lib/archimate/file_format.rb +1 -0
- data/lib/archimate/file_formats/archi_file_reader.rb +11 -1
- data/lib/archimate/file_formats/archi_file_writer.rb +15 -46
- data/lib/archimate/file_formats/archi_file_writer_4.rb +14 -0
- data/lib/archimate/file_formats/model_exchange_file_reader.rb +2 -1
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +1 -0
- data/lib/archimate/file_formats/sax/archi/diagram.rb +53 -13
- data/lib/archimate/file_formats/sax/archi/location.rb +1 -3
- data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +13 -2
- data/lib/archimate/file_formats/sax.rb +1 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer.rb +63 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer_3.rb +18 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer_4.rb +18 -0
- data/lib/archimate/file_formats/serializer/archi/bounds.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/connection.rb +24 -13
- data/lib/archimate/file_formats/serializer/archi/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/archi/element.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/organization.rb +1 -1
- data/lib/archimate/file_formats/serializer/archi/property.rb +1 -1
- data/lib/archimate/file_formats/serializer/archi/relationship.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/view_node.rb +20 -22
- data/lib/archimate/file_formats/serializer/archi/viewpoint3.rb +43 -0
- data/lib/archimate/file_formats/serializer/archi/viewpoint4.rb +41 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +3 -7
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +9 -2
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +1 -1
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/viewpoint.rb +23 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +5 -7
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +3 -3
- data/lib/archimate/file_formats/serializer/writer.rb +0 -5
- data/lib/archimate/file_formats/serializer.rb +6 -2
- data/lib/archimate/lint/duplicate_entities.rb +5 -5
- data/lib/archimate/lint/linter.rb +4 -4
- data/lib/archimate/maybe_io.rb +3 -2
- data/lib/archimate/svg/archimate.css +19 -21
- data/lib/archimate/svg/connection.rb +1 -1
- data/lib/archimate/svg/diagram.rb +1 -6
- data/lib/archimate/svg/entity/application_component.rb +9 -3
- data/lib/archimate/svg/entity/constraint.rb +0 -1
- data/lib/archimate/svg/entity/contract.rb +9 -0
- data/lib/archimate/svg/entity/data_entity.rb +1 -1
- data/lib/archimate/svg/entity/device.rb +1 -1
- data/lib/archimate/svg/entity/event_entity.rb +24 -7
- data/lib/archimate/svg/entity/group.rb +23 -4
- data/lib/archimate/svg/entity/grouping.rb +37 -0
- data/lib/archimate/svg/entity/interface_entity.rb +1 -1
- data/lib/archimate/svg/entity/node.rb +1 -1
- data/lib/archimate/svg/entity/outcome.rb +0 -1
- data/lib/archimate/svg/entity/principle.rb +0 -1
- data/lib/archimate/svg/entity/process_entity.rb +1 -1
- data/lib/archimate/svg/entity/requirement.rb +0 -1
- data/lib/archimate/svg/entity/service_entity.rb +6 -13
- data/lib/archimate/svg/entity.rb +1 -0
- data/lib/archimate/svg/entity_factory.rb +9 -5
- data/lib/archimate/svg/path.rb +57 -46
- data/lib/archimate/svg/point.rb +4 -0
- data/lib/archimate/svg/segment.rb +30 -0
- data/lib/archimate/svg/svg_template.svg.erb +11 -3
- data/lib/archimate/svg/view_node.rb +22 -0
- data/lib/archimate/version.rb +1 -1
- data/lib/archimate.rb +3 -2
- metadata +54 -54
- data/exe/archidiff +0 -7
- data/exe/archidiff-summary +0 -7
- data/exe/archimerge +0 -7
- data/exe/fmtxml +0 -7
- data/lib/archimate/data_model/viewpoint_type.rb +0 -389
- data/lib/archimate/file_formats/serializer/archi/location.rb +0 -26
- data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +0 -45
- data/lib/archimate/svg/child.rb +0 -29
|
@@ -16,9 +16,35 @@ module Archimate
|
|
|
16
16
|
@referenceable_set ||= []
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
def model
|
|
20
|
+
references.find { |ref| ref.is_a?(Model) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def destroy
|
|
24
|
+
references.each { |ref| ref.remove_reference(self) }
|
|
25
|
+
to_h.values.select { |v| v.is_a?(Referenceable) }.each { |ref| ref.remove_reference(self) }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def replace_with(other)
|
|
29
|
+
references.dup.each do |ref|
|
|
30
|
+
ref.replace_item_with(self, other)
|
|
31
|
+
remove_reference(ref)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def replace_item_with(item, replacement)
|
|
36
|
+
# default not doing anything
|
|
37
|
+
# puts Archimate::Color.uncolor(" Referenceable(#{cls_name(self)}).replace_item_with item: #{item} replacement: #{replacement}")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def cls_name(o)
|
|
43
|
+
o.class.name.split("::").last
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_cls_name
|
|
47
|
+
->(o) { o.class.name.split("::").last }
|
|
22
48
|
end
|
|
23
49
|
end
|
|
24
50
|
end
|
|
@@ -7,24 +7,36 @@ module Archimate
|
|
|
7
7
|
# A list of things that can be referenced by another entity.
|
|
8
8
|
class ReferenceableList
|
|
9
9
|
extend Forwardable
|
|
10
|
+
include Referenceable
|
|
10
11
|
|
|
11
12
|
def_delegators :@list,
|
|
13
|
+
:+,
|
|
14
|
+
:==,
|
|
12
15
|
:[],
|
|
13
16
|
:all?,
|
|
17
|
+
:any?,
|
|
18
|
+
:chunk,
|
|
14
19
|
:dig,
|
|
20
|
+
:each,
|
|
15
21
|
:each_with_object,
|
|
22
|
+
:empty?,
|
|
16
23
|
:find,
|
|
24
|
+
:first,
|
|
25
|
+
:flat_map,
|
|
26
|
+
:group_by,
|
|
17
27
|
:hash,
|
|
18
28
|
:include?,
|
|
29
|
+
:inject,
|
|
30
|
+
:inspect,
|
|
31
|
+
:last,
|
|
19
32
|
:map,
|
|
20
33
|
:none?,
|
|
21
|
-
:select,
|
|
22
|
-
:==,
|
|
23
|
-
:each,
|
|
24
|
-
:empty?,
|
|
25
|
-
:first,
|
|
26
34
|
:reduce,
|
|
27
|
-
:
|
|
35
|
+
:reject,
|
|
36
|
+
:select,
|
|
37
|
+
:sort,
|
|
38
|
+
:size,
|
|
39
|
+
:to_a
|
|
28
40
|
|
|
29
41
|
attr_reader :parent
|
|
30
42
|
|
|
@@ -46,14 +58,20 @@ module Archimate
|
|
|
46
58
|
end
|
|
47
59
|
|
|
48
60
|
def push(item)
|
|
61
|
+
return if @list.include?(item)
|
|
62
|
+
add_item_references(item)
|
|
63
|
+
@list.push(item)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def <<(item)
|
|
49
67
|
return if @list.include?(item)
|
|
50
68
|
add_item_references(item)
|
|
51
69
|
@list << item
|
|
52
70
|
end
|
|
53
71
|
|
|
54
|
-
def
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
def delete(item)
|
|
73
|
+
@list.delete(item)
|
|
74
|
+
remove_item_references(item)
|
|
57
75
|
end
|
|
58
76
|
|
|
59
77
|
private
|
|
@@ -70,11 +88,13 @@ module Archimate
|
|
|
70
88
|
end
|
|
71
89
|
|
|
72
90
|
def remove_references
|
|
73
|
-
@list.each
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
@list.each { |item| remove_item_references(item) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def remove_item_references(item)
|
|
95
|
+
item.remove_reference(parent)
|
|
96
|
+
@parent_attr_references.each do |attr|
|
|
97
|
+
item.remove_reference(parent.send(attr)) if parent.send(attr)
|
|
78
98
|
end
|
|
79
99
|
end
|
|
80
100
|
end
|
|
@@ -23,7 +23,7 @@ module Archimate
|
|
|
23
23
|
model_attr :name, default: nil
|
|
24
24
|
# @!attribute [r] documentation
|
|
25
25
|
# @return [PreservedLangString, NilClass]
|
|
26
|
-
model_attr :documentation, default: nil
|
|
26
|
+
model_attr :documentation, writable: true, default: nil
|
|
27
27
|
# @return [Array<AnyElement>]
|
|
28
28
|
# model_attr :other_elements
|
|
29
29
|
# @return [Array<AnyAttribute>]
|
|
@@ -81,12 +81,6 @@ module Archimate
|
|
|
81
81
|
].compact.join(" ")
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
# @todo remove when it doesn't break diff merge conflicts
|
|
85
|
-
# @deprecated
|
|
86
|
-
def referenced_identified_nodes
|
|
87
|
-
[@source, @target].compact
|
|
88
|
-
end
|
|
89
|
-
|
|
90
84
|
# Copy any attributes/docs, etc. from each of the others into the original.
|
|
91
85
|
# 1. Child `label`s with different `xml:lang` attribute values
|
|
92
86
|
# 2. Child `documentation` (and different `xml:lang` attribute values)
|
|
@@ -94,9 +88,36 @@ module Archimate
|
|
|
94
88
|
# 4. Any other elements
|
|
95
89
|
# source and target don't change on a merge
|
|
96
90
|
def merge(relationship)
|
|
97
|
-
|
|
91
|
+
if !documentation
|
|
92
|
+
self.documentation = relationship.documentation
|
|
93
|
+
elsif documentation != relationship.documentation
|
|
94
|
+
documentation.merge(relationship.documentation)
|
|
95
|
+
end
|
|
96
|
+
relationship.properties.each do |property|
|
|
97
|
+
unless properties.find { |my_prop| my_prop.property_definition.name == property.property_definition.name && my_prop.value == property.value}
|
|
98
|
+
properties << property
|
|
99
|
+
end
|
|
100
|
+
end
|
|
98
101
|
@access_type ||= relationship.access_type
|
|
99
102
|
end
|
|
103
|
+
|
|
104
|
+
# Diagrams that this entity is referenced in.
|
|
105
|
+
def diagrams
|
|
106
|
+
references.select { |ref| ref.is_a?(Diagram) }
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def replace_item_with(item, replacement)
|
|
110
|
+
super
|
|
111
|
+
item.remove_reference(self)
|
|
112
|
+
case item
|
|
113
|
+
when source
|
|
114
|
+
@source = replacement
|
|
115
|
+
when target
|
|
116
|
+
@target = replacement
|
|
117
|
+
else
|
|
118
|
+
raise "Trying to replace #{item} that I don't reference"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
100
121
|
end
|
|
101
122
|
end
|
|
102
123
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
using Archimate::CoreRefinements
|
|
4
|
+
|
|
3
5
|
module Archimate
|
|
4
6
|
module DataModel
|
|
5
7
|
# RelationshipReferences provides a means to allow a class that is referenced
|
|
@@ -13,15 +15,122 @@ module Archimate
|
|
|
13
15
|
references.select { |ref| ref.is_a?(DataModel::Relationship) }
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
# List of relationships where this object is the source
|
|
19
|
+
def source_relationships
|
|
20
|
+
relationships.select { |rel| rel.source.id == id }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# List of relationships where this object is the target
|
|
24
|
+
def target_relationships
|
|
25
|
+
relationships.select { |rel| rel.target.id == id }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Creates a method on this instance that returns the relationships of the
|
|
29
|
+
# relationship type `rel_cls` where this object is the source.
|
|
30
|
+
#
|
|
31
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
32
|
+
def self.define_typed_relationships_method(rel_cls)
|
|
33
|
+
define_method(rel_cls::VERB.to_method_name("relationships")) do
|
|
34
|
+
references.select { |ref| ref.is_a?(rel_cls) && ref.source == self }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Creates a method on this instance that returns the elements related by the
|
|
39
|
+
# relationship type `rel_cls` where this object is the source.
|
|
40
|
+
#
|
|
41
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
42
|
+
def self.define_typed_elements_method(rel_cls)
|
|
43
|
+
define_method(rel_cls::VERB.to_method_name("elements")) do
|
|
44
|
+
references
|
|
45
|
+
.select { |ref| ref.is_a?(rel_cls) && ref.source == self }
|
|
46
|
+
.map(&:target)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Creates a method on this instance that returns the relationships of the
|
|
51
|
+
# relationship type `rel_cls` where this object is the target.
|
|
52
|
+
#
|
|
53
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
54
|
+
def self.define_typed_targeted_relationships_method(rel_cls)
|
|
55
|
+
define_method(rel_cls::OBJECT_VERB.to_method_name("relationships")) do
|
|
56
|
+
references.select { |ref| ref.is_a?(rel_cls) && ref.target == self }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Creates a method on this instance that returns the elements related by the
|
|
61
|
+
# relationship type `rel_cls` where this object is the source.
|
|
62
|
+
#
|
|
63
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
64
|
+
def self.define_typed_targeted_elements_method(rel_cls)
|
|
65
|
+
define_method(rel_cls::OBJECT_VERB.to_method_name("elements")) do
|
|
66
|
+
references
|
|
67
|
+
.select { |ref| ref.is_a?(rel_cls) && ref.target == self }
|
|
68
|
+
.map(&:source)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Creates a method on this instance to create relationships to one or more
|
|
73
|
+
# elements of a the rel_cls relationship type where this object is source.
|
|
74
|
+
#
|
|
75
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
76
|
+
def self.define_source_relationship_creation_method(rel_cls)
|
|
77
|
+
define_method(rel_cls::VERB.to_method_name) do |targets = nil, args = {}|
|
|
78
|
+
rels = Array(args.fetch(:target, targets)).compact.map do |target|
|
|
79
|
+
relationship = model&.relationships&.find do |r|
|
|
80
|
+
r.is_a?(rel_cls) &&
|
|
81
|
+
r.name == args.fetch(:name, nil) &&
|
|
82
|
+
r.source == self &&
|
|
83
|
+
r.target == target
|
|
84
|
+
end
|
|
85
|
+
unless relationship
|
|
86
|
+
rargs = args.dup
|
|
87
|
+
rargs[:target] = target
|
|
88
|
+
rargs[:source] = self
|
|
89
|
+
rargs[:id] = model.make_unique_id if !rargs.key?(:id) && model
|
|
90
|
+
relationship = rel_cls.new(rargs)
|
|
91
|
+
(model.relationships << relationship) if model
|
|
92
|
+
end
|
|
93
|
+
relationship
|
|
20
94
|
end
|
|
95
|
+
rels.size < 2 ? rels.first : rels
|
|
96
|
+
end
|
|
97
|
+
end
|
|
21
98
|
|
|
22
|
-
|
|
23
|
-
|
|
99
|
+
# Creates a method on this instance to create relationships to one or more
|
|
100
|
+
# elements of a the rel_cls relationship type where this object is target.
|
|
101
|
+
#
|
|
102
|
+
# @param rel_cls [Archimate::DataModel::Relationship] Relationships class to define references method
|
|
103
|
+
def self.define_target_relationship_creation_method(rel_cls)
|
|
104
|
+
define_method(rel_cls::OBJECT_VERB.to_method_name) do |sources = nil, args = {}|
|
|
105
|
+
rels = Array(args.fetch(:source, sources)).compact.map do |source|
|
|
106
|
+
relationship = model&.relationships&.find do |r|
|
|
107
|
+
r.is_a?(rel_cls) &&
|
|
108
|
+
r.name == args.fetch(:name, nil) &&
|
|
109
|
+
r.source == source &&
|
|
110
|
+
r.target == self
|
|
111
|
+
end
|
|
112
|
+
unless relationship
|
|
113
|
+
rargs = args.dup
|
|
114
|
+
rargs[:source] = source
|
|
115
|
+
rargs[:target] = self
|
|
116
|
+
rargs[:id] = model.make_unique_id if !rargs.key?(:id) && model
|
|
117
|
+
relationship = rel_cls.new(rargs)
|
|
118
|
+
(model.relationships << relationship) if model
|
|
119
|
+
end
|
|
120
|
+
relationship
|
|
24
121
|
end
|
|
122
|
+
rels.size < 2 ? rels.first : rels
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.included(_base)
|
|
127
|
+
Relationships.classes.each do |rel_cls|
|
|
128
|
+
define_typed_relationships_method(rel_cls)
|
|
129
|
+
define_typed_elements_method(rel_cls)
|
|
130
|
+
define_typed_targeted_relationships_method(rel_cls)
|
|
131
|
+
define_typed_targeted_elements_method(rel_cls)
|
|
132
|
+
define_source_relationship_creation_method(rel_cls)
|
|
133
|
+
define_target_relationship_creation_method(rel_cls)
|
|
25
134
|
end
|
|
26
135
|
end
|
|
27
136
|
end
|
|
@@ -209,6 +209,21 @@ module Archimate
|
|
|
209
209
|
def self.classes
|
|
210
210
|
constants.map { |cls_name| const_get(cls_name) }
|
|
211
211
|
end
|
|
212
|
+
|
|
213
|
+
def self.default
|
|
214
|
+
[
|
|
215
|
+
Relationships::Access,
|
|
216
|
+
Relationships::Aggregation,
|
|
217
|
+
Relationships::Assignment,
|
|
218
|
+
Relationships::Association,
|
|
219
|
+
Relationships::Composition,
|
|
220
|
+
Relationships::Flow,
|
|
221
|
+
Relationships::Realization,
|
|
222
|
+
Relationships::Specialization,
|
|
223
|
+
Relationships::Triggering,
|
|
224
|
+
Relationships::Serving
|
|
225
|
+
].freeze
|
|
226
|
+
end
|
|
212
227
|
end
|
|
213
228
|
end
|
|
214
229
|
end
|
|
@@ -92,8 +92,9 @@ module Archimate
|
|
|
92
92
|
# @return [Element, NilClass]
|
|
93
93
|
model_attr :element, writable: true, comparison_attr: :id, default: nil, also_reference: [:diagram]
|
|
94
94
|
# Archi format, selects the shape of element (for elements that can have two or more shapes)
|
|
95
|
+
# A nil value indicates the standard representation, a value of "1" indicates the alternate
|
|
95
96
|
# @!attribute [r] child_type
|
|
96
|
-
# @return [
|
|
97
|
+
# @return [String, NilClass]
|
|
97
98
|
model_attr :child_type, default: nil
|
|
98
99
|
|
|
99
100
|
# @!attribute [r] diagram
|
|
@@ -122,9 +123,9 @@ module Archimate
|
|
|
122
123
|
|
|
123
124
|
def description
|
|
124
125
|
[
|
|
125
|
-
name
|
|
126
|
-
element
|
|
127
|
-
element
|
|
126
|
+
name&.to_s,
|
|
127
|
+
element&.name,
|
|
128
|
+
element ? "(#{element.type})" : nil
|
|
128
129
|
].compact.join(" ")
|
|
129
130
|
end
|
|
130
131
|
|
|
@@ -136,15 +137,6 @@ module Archimate
|
|
|
136
137
|
nodes.each_with_object(id => self) { |i, a| a.merge!(i.child_id_hash) }
|
|
137
138
|
end
|
|
138
139
|
|
|
139
|
-
def referenced_identified_nodes
|
|
140
|
-
(nodes.to_ary + connections).reduce(
|
|
141
|
-
[element]
|
|
142
|
-
.compact
|
|
143
|
-
) do |a, e|
|
|
144
|
-
a.concat(e.referenced_identified_nodes)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
140
|
def in_diagram
|
|
149
141
|
diagram # ||= ->(node) { node = node.parent until node.nil? || node.is_a?(Diagram) }.call(self)
|
|
150
142
|
end
|
|
@@ -167,6 +159,21 @@ module Archimate
|
|
|
167
159
|
.select { |conn| conn.target&.id == id }
|
|
168
160
|
.map(&:id)
|
|
169
161
|
end
|
|
162
|
+
|
|
163
|
+
def center
|
|
164
|
+
@bounds&.center
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def replace_item_with(item, replacement)
|
|
168
|
+
super
|
|
169
|
+
item.remove_reference(self)
|
|
170
|
+
case item
|
|
171
|
+
when element
|
|
172
|
+
@element = replacement
|
|
173
|
+
else
|
|
174
|
+
raise "Trying to replace #{item} that I don't reference"
|
|
175
|
+
end
|
|
176
|
+
end
|
|
170
177
|
end
|
|
171
178
|
end
|
|
172
179
|
end
|
|
@@ -35,7 +35,7 @@ module Archimate
|
|
|
35
35
|
# @return [Array<ViewpointContentEnum>]
|
|
36
36
|
model_attr :viewpoint_contents, default: []
|
|
37
37
|
# @!attribute [r] allowed_element_types
|
|
38
|
-
# @return [Array<
|
|
38
|
+
# @return [Array<Elements::*>]
|
|
39
39
|
model_attr :allowed_element_types, default: []
|
|
40
40
|
# @!attribute [r] allowed_relationship_types
|
|
41
41
|
# @return [Array<Relationships::*>]
|
|
@@ -43,6 +43,18 @@ module Archimate
|
|
|
43
43
|
# @!attribute [r] modeling_notes
|
|
44
44
|
# @return [Array<ModelingNote>]
|
|
45
45
|
model_attr :modeling_notes, default: []
|
|
46
|
+
|
|
47
|
+
def to_s
|
|
48
|
+
name.to_s
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def select_elements(from_elements)
|
|
52
|
+
from_elements.select { |el| allowed_element_types.include?(el.class) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def select_relationships(from_relationships)
|
|
56
|
+
from_relationships.select { |rel| allowed_relationship_types.include?(rel.class) }
|
|
57
|
+
end
|
|
46
58
|
end
|
|
47
59
|
end
|
|
48
60
|
end
|