archimate 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -0
- data/TODOs.org +219 -0
- data/archimate.gemspec +2 -1
- data/exe/archidiff +7 -0
- data/exe/archidiff-summary +7 -0
- data/exe/archimerge +7 -0
- data/exe/fmtxml +7 -0
- data/lib/archimate.rb +10 -21
- data/lib/archimate/cli/archi.rb +2 -1
- data/lib/archimate/cli/cleanup.rb +8 -9
- data/lib/archimate/cli/convert.rb +3 -1
- data/lib/archimate/cli/mapper.rb +1 -1
- data/lib/archimate/cli/stats.rb +1 -1
- data/lib/archimate/config.rb +4 -1
- data/lib/archimate/data_model.rb +11 -24
- data/lib/archimate/data_model/any_attribute.rb +18 -5
- data/lib/archimate/data_model/any_element.rb +30 -7
- data/lib/archimate/data_model/bounds.rb +34 -7
- data/lib/archimate/data_model/color.rb +32 -7
- data/lib/archimate/data_model/comparison.rb +87 -0
- data/lib/archimate/data_model/concern.rb +20 -7
- data/lib/archimate/data_model/connection.rb +71 -51
- data/lib/archimate/data_model/connector_type.rb +23 -0
- data/lib/archimate/data_model/diagram.rb +72 -10
- data/lib/archimate/data_model/diagram_type.rb +17 -0
- data/lib/archimate/data_model/differentiable.rb +142 -0
- data/lib/archimate/data_model/element.rb +39 -45
- data/lib/archimate/data_model/element_type.rb +89 -0
- data/lib/archimate/data_model/font.rb +30 -12
- data/lib/archimate/data_model/lang_string.rb +89 -16
- data/lib/archimate/data_model/layer.rb +55 -0
- data/lib/archimate/data_model/layers.rb +62 -0
- data/lib/archimate/data_model/location.rb +27 -11
- data/lib/archimate/data_model/metadata.rb +10 -3
- data/lib/archimate/data_model/model.rb +188 -121
- data/lib/archimate/data_model/modeling_note.rb +14 -3
- data/lib/archimate/data_model/organization.rb +44 -13
- data/lib/archimate/data_model/{documentation.rb → preserved_lang_string.rb} +1 -5
- data/lib/archimate/data_model/property.rb +17 -11
- data/lib/archimate/data_model/property_definition.rb +34 -4
- data/lib/archimate/data_model/referenceable.rb +0 -9
- data/lib/archimate/data_model/referenceable_collection.rb +201 -0
- data/lib/archimate/data_model/relationship.rb +52 -33
- data/lib/archimate/data_model/relationship_type.rb +43 -0
- data/lib/archimate/data_model/schema_info.rb +17 -6
- data/lib/archimate/data_model/style.rb +41 -11
- data/lib/archimate/data_model/view_node.rb +153 -59
- data/lib/archimate/data_model/viewpoint.rb +56 -80
- data/lib/archimate/data_model/viewpoint_type.rb +429 -0
- data/lib/archimate/export/csv_export.rb +2 -2
- data/lib/archimate/export/cypher.rb +2 -2
- data/lib/archimate/export/graph_ml.rb +7 -5
- data/lib/archimate/export/jsonl.rb +166 -0
- data/lib/archimate/export/n_quads.rb +8 -5
- data/lib/archimate/file_format.rb +4 -5
- data/lib/archimate/file_formats/archi_file_reader.rb +7 -240
- data/lib/archimate/file_formats/archi_file_writer.rb +16 -188
- data/lib/archimate/file_formats/model_exchange_file_reader.rb +7 -225
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +22 -114
- data/lib/archimate/file_formats/model_exchange_file_writer_30.rb +22 -122
- data/lib/archimate/file_formats/sax.rb +55 -0
- data/lib/archimate/file_formats/sax/any_element.rb +64 -0
- data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +48 -0
- data/lib/archimate/file_formats/sax/archi/bounds.rb +25 -0
- data/lib/archimate/file_formats/sax/archi/connection.rb +47 -0
- data/lib/archimate/file_formats/sax/archi/content.rb +28 -0
- data/lib/archimate/file_formats/sax/archi/diagram.rb +66 -0
- data/lib/archimate/file_formats/sax/archi/element.rb +36 -0
- data/lib/archimate/file_formats/sax/archi/location.rb +25 -0
- data/lib/archimate/file_formats/sax/archi/model.rb +109 -0
- data/lib/archimate/file_formats/sax/archi/organization.rb +60 -0
- data/lib/archimate/file_formats/sax/archi/property.rb +54 -0
- data/lib/archimate/file_formats/sax/archi/relationship.rb +50 -0
- data/lib/archimate/file_formats/sax/archi/style.rb +35 -0
- data/lib/archimate/file_formats/sax/archi/view_node.rb +76 -0
- data/lib/archimate/file_formats/sax/capture_content.rb +20 -0
- data/lib/archimate/file_formats/sax/capture_documentation.rb +19 -0
- data/lib/archimate/file_formats/sax/capture_properties.rb +20 -0
- data/lib/archimate/file_formats/sax/content_element.rb +19 -0
- data/lib/archimate/file_formats/sax/document.rb +80 -0
- data/lib/archimate/file_formats/sax/handler.rb +54 -0
- data/lib/archimate/file_formats/sax/lang_string.rb +28 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/color.rb +36 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +67 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +60 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +43 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/font.rb +44 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/item.rb +64 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/location.rb +23 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/metadata.rb +66 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/model.rb +124 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory.rb +53 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/property.rb +32 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/property_definition.rb +36 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +49 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/schema_info.rb +47 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/style.rb +66 -0
- data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +86 -0
- data/lib/archimate/file_formats/sax/no_op.rb +17 -0
- data/lib/archimate/file_formats/sax/preserved_lang_string.rb +28 -0
- data/lib/archimate/file_formats/serializer.rb +57 -0
- data/lib/archimate/file_formats/serializer/archi/bounds.rb +23 -0
- data/lib/archimate/file_formats/serializer/archi/connection.rb +33 -0
- data/lib/archimate/file_formats/serializer/archi/diagram.rb +28 -0
- data/lib/archimate/file_formats/serializer/archi/documentation.rb +16 -0
- data/lib/archimate/file_formats/serializer/archi/element.rb +24 -0
- data/lib/archimate/file_formats/serializer/archi/location.rb +26 -0
- data/lib/archimate/file_formats/serializer/archi/model.rb +25 -0
- data/lib/archimate/file_formats/serializer/archi/organization.rb +21 -0
- data/lib/archimate/file_formats/serializer/archi/property.rb +15 -0
- data/lib/archimate/file_formats/serializer/archi/relationship.rb +36 -0
- data/lib/archimate/file_formats/serializer/archi/view_node.rb +52 -0
- data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +45 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/element.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/location.rb +15 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb +32 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/organization.rb +23 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/properties.rb +15 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/relationship.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +48 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/connection.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +27 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/item.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/label.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +36 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/organization_body.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/property.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +44 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/connection.rb +26 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +27 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/item.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/label.rb +17 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +41 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/organization_body.rb +25 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property.rb +19 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property_definitions.rb +34 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +45 -0
- data/lib/archimate/file_formats/serializer/named_collection.rb +21 -0
- data/lib/archimate/file_formats/serializer/writer.rb +56 -0
- data/lib/archimate/file_formats/serializer/xml_lang_string.rb +30 -0
- data/lib/archimate/file_formats/serializer/xml_metadata.rb +64 -0
- data/lib/archimate/file_formats/{model_exchange_file → serializer}/xml_property_defs.rb +2 -2
- data/lib/archimate/lint/duplicate_entities.rb +3 -3
- data/lib/archimate/lint/linter.rb +24 -29
- data/lib/archimate/svg/connection.rb +13 -103
- data/lib/archimate/svg/diagram.rb +1 -1
- data/lib/archimate/svg/entity/base_entity.rb +12 -8
- data/lib/archimate/svg/entity/data_entity.rb +2 -2
- data/lib/archimate/svg/entity/diagram_model_reference.rb +1 -1
- data/lib/archimate/svg/entity/event_entity.rb +2 -2
- data/lib/archimate/svg/entity/gap.rb +1 -1
- data/lib/archimate/svg/entity/group.rb +1 -1
- data/lib/archimate/svg/entity/motivation_entity.rb +1 -1
- data/lib/archimate/svg/entity/node.rb +1 -1
- data/lib/archimate/svg/entity/rect_entity.rb +1 -1
- data/lib/archimate/svg/entity/rounded_rect_entity.rb +1 -1
- data/lib/archimate/svg/entity/service_entity.rb +2 -2
- data/lib/archimate/svg/entity/value.rb +2 -2
- data/lib/archimate/svg/path.rb +153 -0
- data/lib/archimate/svg/point.rb +8 -1
- data/lib/archimate/version.rb +1 -1
- metadata +118 -36
- data/lib/archimate/data_model/archimate_node.rb +0 -181
- data/lib/archimate/data_model/concept.rb +0 -14
- data/lib/archimate/data_model/constants.rb +0 -82
- data/lib/archimate/data_model/container.rb +0 -17
- data/lib/archimate/data_model/diffable_array.rb +0 -213
- data/lib/archimate/data_model/diffable_primitive.rb +0 -83
- data/lib/archimate/data_model/label.rb +0 -19
- data/lib/archimate/data_model/named_referenceable.rb +0 -14
- data/lib/archimate/data_model/view.rb +0 -12
- data/lib/archimate/data_model/view_concept.rb +0 -18
- data/lib/archimate/file_formats/archi_file_format.rb +0 -151
- data/lib/archimate/file_formats/archimate_v2.rb +0 -461
- data/lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb +0 -35
- data/lib/archimate/file_formats/model_exchange_file/xml_metadata.rb +0 -115
- data/lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb +0 -28
- data/lib/archimate/file_formats/model_exchange_file_reader_21.rb +0 -73
- data/lib/archimate/file_formats/model_exchange_file_reader_30.rb +0 -134
- data/lib/archimate/file_formats/model_exchange_file_writer.rb +0 -157
- data/lib/archimate/file_formats/writer.rb +0 -56
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ruby-enum"
|
3
|
+
|
4
|
+
module Archimate
|
5
|
+
module DataModel
|
6
|
+
# Enumeration class that defines the strings used for all Archimate element
|
7
|
+
# types.
|
8
|
+
class ElementType
|
9
|
+
include Ruby::Enum
|
10
|
+
|
11
|
+
define :BusinessActor, "BusinessActor"
|
12
|
+
define :BusinessCollaboration, "BusinessCollaboration"
|
13
|
+
define :BusinessEvent, "BusinessEvent"
|
14
|
+
define :BusinessFunction, "BusinessFunction"
|
15
|
+
define :BusinessInteraction, "BusinessInteraction"
|
16
|
+
define :BusinessInterface, "BusinessInterface"
|
17
|
+
define :BusinessObject, "BusinessObject"
|
18
|
+
define :BusinessProcess, "BusinessProcess"
|
19
|
+
define :BusinessRole, "BusinessRole"
|
20
|
+
define :BusinessService, "BusinessService"
|
21
|
+
define :Contract, "Contract"
|
22
|
+
define :Location, "Location"
|
23
|
+
define :Meaning, "Meaning"
|
24
|
+
define :Value, "Value"
|
25
|
+
define :Product, "Product"
|
26
|
+
define :Representation, "Representation"
|
27
|
+
define :ApplicationCollaboration, "ApplicationCollaboration"
|
28
|
+
define :ApplicationComponent, "ApplicationComponent"
|
29
|
+
define :ApplicationFunction, "ApplicationFunction"
|
30
|
+
define :ApplicationInteraction, "ApplicationInteraction"
|
31
|
+
define :ApplicationInterface, "ApplicationInterface"
|
32
|
+
define :ApplicationService, "ApplicationService"
|
33
|
+
define :DataObject, "DataObject"
|
34
|
+
define :Artifact, "Artifact"
|
35
|
+
define :CommunicationPath, "CommunicationPath"
|
36
|
+
define :Device, "Device"
|
37
|
+
define :InfrastructureFunction, "InfrastructureFunction"
|
38
|
+
define :InfrastructureInterface, "InfrastructureInterface"
|
39
|
+
define :InfrastructureService, "InfrastructureService"
|
40
|
+
define :Network, "Network"
|
41
|
+
define :Node, "Node"
|
42
|
+
define :SystemSoftware, "SystemSoftware"
|
43
|
+
define :Assessment, "Assessment"
|
44
|
+
define :Constraint, "Constraint"
|
45
|
+
define :Driver, "Driver"
|
46
|
+
define :Goal, "Goal"
|
47
|
+
define :Principle, "Principle"
|
48
|
+
define :Requirement, "Requirement"
|
49
|
+
define :Stakeholder, "Stakeholder"
|
50
|
+
define :Deliverable, "Deliverable"
|
51
|
+
define :Gap, "Gap"
|
52
|
+
define :Plateau, "Plateau"
|
53
|
+
define :WorkPackage, "WorkPackage"
|
54
|
+
define :AndJunction, "AndJunction"
|
55
|
+
define :Junction, "Junction"
|
56
|
+
define :OrJunction, "OrJunction"
|
57
|
+
define :Capability, "Capability"
|
58
|
+
define :CourseOfAction, "CourseOfAction"
|
59
|
+
define :Resource, "Resource"
|
60
|
+
define :ApplicationProcess, "ApplicationProcess"
|
61
|
+
define :ApplicationEvent, "ApplicationEvent"
|
62
|
+
define :TechnologyCollaboration, "TechnologyCollaboration"
|
63
|
+
define :TechnologyInterface, "TechnologyInterface"
|
64
|
+
define :Path, "Path"
|
65
|
+
define :CommunicationNetwork, "CommunicationNetwork"
|
66
|
+
define :TechnologyFunction, "TechnologyFunction"
|
67
|
+
define :TechnologyProcess, "TechnologyProcess"
|
68
|
+
define :TechnologyInteraction, "TechnologyInteraction"
|
69
|
+
define :TechnologyEvent, "TechnologyEvent"
|
70
|
+
define :TechnologyService, "TechnologyService"
|
71
|
+
define :TechnologyObject, "TechnologyObject"
|
72
|
+
define :Equipment, "Equipment"
|
73
|
+
define :Facility, "Facility"
|
74
|
+
define :DistributionNetwork, "DistributionNetwork"
|
75
|
+
define :Material, "Material"
|
76
|
+
define :Outcome, "Outcome"
|
77
|
+
define :ImplementationEvent, "ImplementationEvent"
|
78
|
+
# @todo Is grouping a valid element type?
|
79
|
+
# define :Grouping, "Grouping"
|
80
|
+
|
81
|
+
# Case equality operator. Used to determine if a value is a member of this enum
|
82
|
+
#
|
83
|
+
# @param other [String] string to test for enum membership.
|
84
|
+
def self.===(other)
|
85
|
+
values.include?(other)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -1,28 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Archimate
|
3
4
|
module DataModel
|
4
|
-
class Font
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class Font
|
6
|
+
include Comparison
|
7
|
+
|
8
|
+
# @!attribute [r] name
|
9
|
+
# @return [String, NilClass]
|
10
|
+
model_attr :name
|
11
|
+
# @!attribute [r] size
|
12
|
+
# @return [Float, NilClass]
|
13
|
+
model_attr :size
|
14
|
+
# @todo make this an enum
|
15
|
+
# @!attribute [r] style
|
16
|
+
# @return [Int, NilClass]
|
17
|
+
model_attr :style
|
18
|
+
# @!attribute [r] font_data
|
19
|
+
# @return [String, NilClass]
|
20
|
+
model_attr :font_data
|
9
21
|
|
10
22
|
# Archi font strings look like this:
|
11
23
|
# "1|Arial |14.0|0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial"
|
12
24
|
# "1|Arial |8.0 |0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial"
|
13
25
|
# "1|Segoe UI Semibold|12.0|2|WINDOWS|1|-16|0|0|0|600|-1|0|0|0|3|2|1|34|Segoe UI Semibold"
|
14
26
|
# "1|Times New Roman |12.0|3|WINDOWS|1|-16|0|0|0|700|-1|0|0|0|3|2|1|18|Times New Roman"
|
27
|
+
# @todo move this to the archi file reader
|
15
28
|
def self.archi_font_string(str)
|
16
29
|
return nil if str.nil?
|
17
30
|
font_parts = str.split("|")
|
18
31
|
DataModel::Font.new(
|
19
32
|
name: font_parts[1],
|
20
|
-
size: font_parts[2],
|
21
|
-
style: font_parts[3],
|
33
|
+
size: font_parts[2].to_f,
|
34
|
+
style: font_parts[3].to_i,
|
22
35
|
font_data: str
|
23
36
|
)
|
24
37
|
end
|
25
38
|
|
39
|
+
def initialize(name: nil, size: nil, style: nil, font_data: nil)
|
40
|
+
@name = name
|
41
|
+
@size = size.nil? ? nil : size.to_f
|
42
|
+
@style = style.nil? ? nil : style.to_i
|
43
|
+
@font_data = font_data
|
44
|
+
end
|
45
|
+
|
26
46
|
def to_s
|
27
47
|
"Font(name: #{name}, size: #{size}, style: #{style})"
|
28
48
|
end
|
@@ -30,12 +50,12 @@ module Archimate
|
|
30
50
|
def to_archi_font
|
31
51
|
font_data ||
|
32
52
|
[
|
33
|
-
1,
|
34
|
-
0, 0, 1, 0, 0, 0, 0,
|
53
|
+
1, name, size, style, "WINDOWS", 1, 0, 0, 0, 0, 0, 0,
|
54
|
+
0, 0, 1, 0, 0, 0, 0, name
|
35
55
|
].map(&:to_s).join("|")
|
36
56
|
end
|
37
57
|
|
38
|
-
#
|
58
|
+
# @todo this isn't standard
|
39
59
|
# Move to file format
|
40
60
|
def style_string
|
41
61
|
case style
|
@@ -48,7 +68,5 @@ module Archimate
|
|
48
68
|
end
|
49
69
|
end
|
50
70
|
end
|
51
|
-
|
52
|
-
Dry::Types.register_class(Font)
|
53
71
|
end
|
54
72
|
end
|
@@ -1,41 +1,114 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "forwardable"
|
3
4
|
|
4
5
|
module Archimate
|
5
6
|
module DataModel
|
6
7
|
# A base string type for multi-language strings.
|
7
|
-
class LangString
|
8
|
-
|
8
|
+
class LangString
|
9
|
+
include Comparison
|
9
10
|
extend Forwardable
|
10
|
-
def_delegators :@text, :to_s, :strip, :strip!, :tr, :+, :gsub, :gsub!, :sub!, :downcase!, :empty?, :split
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def_delegators :@default_text, :strip, :tr, :+, :gsub, :sub, :downcase, :empty?, :split, :size, :include?
|
13
|
+
# def_delegators :@lang_hash, :size
|
14
|
+
|
15
|
+
# @!attribute [r] lang_hash
|
16
|
+
# @return [Hash]
|
17
|
+
model_attr :lang_hash
|
18
|
+
# @!attribute [r] default_lang
|
19
|
+
# @return [String, NilClass]
|
20
|
+
model_attr :default_lang
|
21
|
+
# @!attribute [r] default_text
|
22
|
+
# @return [String]
|
23
|
+
model_attr :default_text
|
24
|
+
|
25
|
+
# def self.default_lang
|
26
|
+
# Archimate::Config.instance.default_lang
|
27
|
+
# end
|
28
|
+
|
29
|
+
def self.string(str, lang = nil)
|
30
|
+
return nil if !str || str.strip.empty?
|
31
|
+
str = str.strip
|
32
|
+
lang = nil if !lang || lang.empty?
|
33
|
+
new(
|
34
|
+
lang_hash: { lang => str },
|
35
|
+
default_lang: lang,
|
36
|
+
default_text: str
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create(copy)
|
41
|
+
case copy
|
42
|
+
when String
|
43
|
+
string(copy)
|
44
|
+
when LangString
|
45
|
+
copy
|
46
|
+
when Hash
|
47
|
+
lang_hash = copy.fetch(:lang_hash, {})
|
48
|
+
default_lang = copy.fetch(:default_lang, "")
|
49
|
+
default_text = copy.fetch(:default_text, "")
|
50
|
+
return nil if [lang_hash, default_lang, default_text].any? { |i| i && i.empty? }
|
51
|
+
new(
|
52
|
+
lang_hash: lang_hash,
|
53
|
+
default_lang: default_lang,
|
54
|
+
default_text: default_text
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
14
58
|
|
15
|
-
# @param [Hash{Symbol => Object},
|
59
|
+
# @param [Hash{Symbol => Object},LangString, String] attributes
|
16
60
|
# @raise [Struct::Error] if the given attributes don't conform {#schema}
|
17
|
-
# with given {#constructor_type}
|
18
|
-
def
|
19
|
-
|
20
|
-
|
61
|
+
# with given {# # constructor_type}
|
62
|
+
def initialize(str = nil, lang_hash: {}, default_lang: nil, default_text: nil)
|
63
|
+
@lang_hash = lang_hash
|
64
|
+
@default_lang = default_lang
|
65
|
+
@default_text = default_text
|
66
|
+
case str
|
67
|
+
when String
|
68
|
+
@lang_hash[@default_lang] = @default_text = str.strip
|
69
|
+
when LangString
|
70
|
+
@lang_hash = str.lang_hash
|
71
|
+
@default_lang = str.default_lang
|
72
|
+
@default_text = str.default_text
|
21
73
|
else
|
22
|
-
|
74
|
+
@lang_hash[default_lang] = default_text if default_text
|
23
75
|
end
|
24
76
|
end
|
25
77
|
|
78
|
+
def langs
|
79
|
+
@lang_hash.keys
|
80
|
+
end
|
81
|
+
|
26
82
|
def to_str
|
27
|
-
|
83
|
+
to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
def to_s
|
87
|
+
@default_text ||= @lang_hash.fetch(default_lang) do |key|
|
88
|
+
@lang_hash.fetch(nil, nil) if key
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def by_lang(lang)
|
93
|
+
lang_hash.fetch(lang, nil)
|
94
|
+
end
|
95
|
+
|
96
|
+
def text
|
97
|
+
to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
def lang
|
101
|
+
default_lang
|
28
102
|
end
|
29
103
|
|
30
104
|
def =~(other)
|
105
|
+
str = to_s
|
31
106
|
if other.is_a?(Regexp)
|
32
|
-
other =~
|
107
|
+
other =~ str
|
33
108
|
else
|
34
|
-
Regexp.new(Regexp.escape(
|
109
|
+
Regexp.new(Regexp.escape(str)) =~ other
|
35
110
|
end
|
36
111
|
end
|
37
112
|
end
|
38
|
-
|
39
|
-
Dry::Types.register_class(LangString)
|
40
113
|
end
|
41
114
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ruby-enum"
|
3
|
+
|
4
|
+
module Archimate
|
5
|
+
module DataModel
|
6
|
+
class Layer
|
7
|
+
attr_reader :elements
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
# No user serviceable parts here. don't use me.
|
11
|
+
def initialize(layer = "None", element_names = [])
|
12
|
+
@symbol = Layer.symbolize(layer)
|
13
|
+
@name = layer
|
14
|
+
@elements = element_names
|
15
|
+
end
|
16
|
+
|
17
|
+
def hash
|
18
|
+
self.class.hash ^ @symbol.hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def ===(other)
|
22
|
+
return true if equal?(other)
|
23
|
+
case other
|
24
|
+
when String
|
25
|
+
@symbol == Layer.symbolize(other)
|
26
|
+
when Symbol
|
27
|
+
@symbol == other
|
28
|
+
when Layer
|
29
|
+
self == other
|
30
|
+
else
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def ==(other)
|
36
|
+
@symbol == other&.to_sym
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_sym
|
40
|
+
@symbol
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
@name
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def self.symbolize(str)
|
50
|
+
return str if str.is_a?(Symbol)
|
51
|
+
str.downcase.tr(" ", "_").to_sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ruby-enum"
|
3
|
+
|
4
|
+
module Archimate
|
5
|
+
module DataModel
|
6
|
+
class Layers
|
7
|
+
include Ruby::Enum
|
8
|
+
|
9
|
+
define :Strategy, Layer.new("Strategy", %w[Capability CourseOfAction Resource])
|
10
|
+
|
11
|
+
define :Business, Layer.new("Business", %w[BusinessActor BusinessCollaboration
|
12
|
+
BusinessEvent BusinessFunction
|
13
|
+
BusinessInteraction BusinessInterface
|
14
|
+
BusinessObject BusinessProcess
|
15
|
+
BusinessRole BusinessService
|
16
|
+
Contract Location
|
17
|
+
Meaning Value
|
18
|
+
Product Representation])
|
19
|
+
|
20
|
+
define :Application, Layer.new("Application", %w[ApplicationCollaboration ApplicationComponent
|
21
|
+
ApplicationFunction ApplicationInteraction
|
22
|
+
ApplicationInterface ApplicationService
|
23
|
+
DataObject ApplicationProcess ApplicationEvent])
|
24
|
+
|
25
|
+
define :Technology, Layer.new("Technology", %w[Artifact CommunicationPath
|
26
|
+
Device InfrastructureFunction
|
27
|
+
InfrastructureInterface InfrastructureService
|
28
|
+
Network Node SystemSoftware TechnologyCollaboration
|
29
|
+
TechnologyInterface Path CommunicationNetwork
|
30
|
+
TechnologyFunction TechnologyProcess TechnologyInteraction
|
31
|
+
TechnologyEvent TechnologyService
|
32
|
+
TechnologyObject])
|
33
|
+
|
34
|
+
define :Physical, Layer.new("Physical", %w[Equipment Facility DistributionNetwork Material])
|
35
|
+
|
36
|
+
define :Motivation, Layer.new("Motivation", %w[Assessment Constraint Driver
|
37
|
+
Goal Principle Requirement
|
38
|
+
Stakeholder Outcome])
|
39
|
+
|
40
|
+
define :Implementation_and_migration, Layer.new("Implementation and Migration", %w[Deliverable Gap Plateau
|
41
|
+
WorkPackage ImplementationEvent])
|
42
|
+
|
43
|
+
# @todo Is Connectors used? Should this be none?
|
44
|
+
define :Connectors, Layer.new("Connectors", %w[AndJunction Junction OrJunction])
|
45
|
+
|
46
|
+
define :None, Layer.new("None")
|
47
|
+
|
48
|
+
# def [](name_or_sym)
|
49
|
+
# case name_or_sym
|
50
|
+
# when Integer
|
51
|
+
# @layers[name_or_sym]
|
52
|
+
# else
|
53
|
+
# @layers.find { |layer| layer === name_or_sym }
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
|
57
|
+
def self.for_element(type)
|
58
|
+
values.find { |layer| layer.elements.include?(type) } || Layers::None
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -2,30 +2,46 @@
|
|
2
2
|
|
3
3
|
module Archimate
|
4
4
|
module DataModel
|
5
|
-
#
|
6
|
-
NonNegativeInteger =
|
7
|
-
NonNegativeFloat =
|
5
|
+
# @todo x & y Defined like this in the XSD
|
6
|
+
# NonNegativeInteger = Int.constrained(gteq: 0)
|
7
|
+
# NonNegativeFloat = Float # .constrained(gteq: 0)
|
8
8
|
|
9
9
|
# Graphical node type. It can contain child node types.
|
10
10
|
# This is LocationType/LocationGroup in the XSD.
|
11
|
-
class Location
|
11
|
+
class Location
|
12
|
+
include Comparison
|
13
|
+
|
12
14
|
# The x (towards the right, associated with width) attribute from the Top,Left (i.e. 0,0)
|
13
15
|
# corner of the diagram to the Top, Left corner of the bounding box of the concept.
|
14
|
-
|
16
|
+
# @note the XSD has this as a NonNegativeInteger
|
17
|
+
# @!attribute [r] x
|
18
|
+
# @return [Float]
|
19
|
+
model_attr :x
|
15
20
|
# The y (towards the bottom, associated with height) attribute from the Top,Left (i.e. 0,0)
|
16
21
|
# corner of the diagram to the Top, Left corner of the bounding box of the concept.
|
17
|
-
|
22
|
+
# @note the XSD has this as a NonNegativeInteger
|
23
|
+
# @!attribute [r] y
|
24
|
+
# @return [Float]
|
25
|
+
model_attr :y
|
18
26
|
|
19
27
|
# These are holdovers from the archi file format and are only maintained for compatability
|
20
|
-
attribute
|
21
|
-
|
28
|
+
# @!attribute [r] end_x
|
29
|
+
# @return [Int, NilClass]
|
30
|
+
model_attr :end_x
|
31
|
+
# @!attribute [r] end_y
|
32
|
+
# @return [Int, NilClass]
|
33
|
+
model_attr :end_y
|
34
|
+
|
35
|
+
def initialize(x:, y:, end_x: nil, end_y: nil)
|
36
|
+
@x = x.to_i
|
37
|
+
@y = y.to_i
|
38
|
+
@end_x = end_x.nil? ? nil : end_x.to_i
|
39
|
+
@end_y = end_y.nil? ? nil : end_y.to_i
|
40
|
+
end
|
22
41
|
|
23
42
|
def to_s
|
24
43
|
"Location(x: #{x}, y: #{y})"
|
25
44
|
end
|
26
45
|
end
|
27
|
-
|
28
|
-
Dry::Types.register_class(Location)
|
29
|
-
LocationList = Strict::Array.member(Location).default([])
|
30
46
|
end
|
31
47
|
end
|