archimate 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "scanf"
|
3
4
|
|
4
5
|
module Archimate
|
@@ -6,6 +7,57 @@ module Archimate
|
|
6
7
|
module Sax
|
7
8
|
module Archi
|
8
9
|
class Diagram < FileFormats::Sax::Handler
|
10
|
+
VIEWPOINT_INDEX = {
|
11
|
+
"1" => nil, # DataModel::Viewpoints::Actor_cooperation,
|
12
|
+
"2" => DataModel::Viewpoints::Application_behavior,
|
13
|
+
"application_cooperation" => DataModel::Viewpoints::Application_cooperation,
|
14
|
+
"3" => DataModel::Viewpoints::Application_cooperation,
|
15
|
+
"4" => DataModel::Viewpoints::Application_structure,
|
16
|
+
"application_usage" => DataModel::Viewpoints::Application_usage,
|
17
|
+
"5" => DataModel::Viewpoints::Application_usage,
|
18
|
+
"6" => DataModel::Viewpoints::Business_function,
|
19
|
+
"business_process_cooperation" => DataModel::Viewpoints::Business_process_cooperation,
|
20
|
+
"7" => nil, # DataModel::Viewpoints::Business_cooperation,
|
21
|
+
"8" => DataModel::Viewpoints::Business_process,
|
22
|
+
"product" => DataModel::Viewpoints::Product,
|
23
|
+
"9" => DataModel::Viewpoints::Product,
|
24
|
+
"implementation_deployment" => DataModel::Viewpoints::Implementation_and_deployment,
|
25
|
+
"10" => DataModel::Viewpoints::Implementation_and_deployment,
|
26
|
+
"information_structure" => DataModel::Viewpoints::Information_structure,
|
27
|
+
"11" => DataModel::Viewpoints::Information_structure,
|
28
|
+
"12" => DataModel::Viewpoints::Infrastructure_usage,
|
29
|
+
"13" => DataModel::Viewpoints::Infrastructure,
|
30
|
+
"layered" => DataModel::Viewpoints::Layered,
|
31
|
+
"14" => DataModel::Viewpoints::Layered,
|
32
|
+
"organization" => DataModel::Viewpoints::Organization,
|
33
|
+
"15" => DataModel::Viewpoints::Organization,
|
34
|
+
"service_realization" => DataModel::Viewpoints::Service_realization,
|
35
|
+
"16" => DataModel::Viewpoints::Service_realization,
|
36
|
+
"stakeholder" => DataModel::Viewpoints::Stakeholder,
|
37
|
+
"17" => DataModel::Viewpoints::Stakeholder,
|
38
|
+
"goal_realization" => DataModel::Viewpoints::Goal_realization,
|
39
|
+
"18" => DataModel::Viewpoints::Goal_realization,
|
40
|
+
"19" => DataModel::Viewpoints::Goal_contribution,
|
41
|
+
"20" => DataModel::Viewpoints::Principles,
|
42
|
+
"requirements_realization" => DataModel::Viewpoints::Requirements_realization,
|
43
|
+
"21" => DataModel::Viewpoints::Requirements_realization,
|
44
|
+
"motivation" => DataModel::Viewpoints::Motivation,
|
45
|
+
"22" => DataModel::Viewpoints::Motivation,
|
46
|
+
"project" => DataModel::Viewpoints::Project,
|
47
|
+
"23" => DataModel::Viewpoints::Project,
|
48
|
+
"migration" => DataModel::Viewpoints::Migration,
|
49
|
+
"24" => DataModel::Viewpoints::Migration,
|
50
|
+
"implementation_migration" => DataModel::Viewpoints::Implementation_and_migration,
|
51
|
+
"25" => DataModel::Viewpoints::Implementation_and_migration,
|
52
|
+
"capability" => nil, # DataModel::Viewpoints::Capability,
|
53
|
+
"outcome_realization" => DataModel::Viewpoints::Outcome_realization,
|
54
|
+
"physical" => DataModel::Viewpoints::Physical,
|
55
|
+
"resource" => nil, # DataModel::Viewpoints::Resource,
|
56
|
+
"strategy" => DataModel::Viewpoints::Strategy,
|
57
|
+
"technology" => DataModel::Viewpoints::Technology,
|
58
|
+
"technology_usage" => DataModel::Viewpoints::Technology_usage
|
59
|
+
}.freeze
|
60
|
+
|
9
61
|
include Sax::CaptureDocumentation
|
10
62
|
include Sax::CaptureProperties
|
11
63
|
|
@@ -31,8 +83,7 @@ module Archimate
|
|
31
83
|
@diagram ||= DataModel::Diagram.new(
|
32
84
|
id: @attrs["id"],
|
33
85
|
name: DataModel::LangString.string(process_text(@attrs["name"])),
|
34
|
-
|
35
|
-
viewpoint: nil,
|
86
|
+
viewpoint: VIEWPOINT_INDEX.fetch(@attrs["viewpoint"], nil),
|
36
87
|
connection_router_type: @attrs["connectionRouterType"],
|
37
88
|
type: @attrs["xsi:type"],
|
38
89
|
background: @attrs["background"]
|
@@ -48,17 +99,6 @@ module Archimate
|
|
48
99
|
@connections << connection
|
49
100
|
false
|
50
101
|
end
|
51
|
-
|
52
|
-
def parse_viewpoint_type(viewpoint_idx)
|
53
|
-
case viewpoint_idx
|
54
|
-
when String
|
55
|
-
idx = viewpoint_idx.scanf("%d").first
|
56
|
-
return nil unless idx
|
57
|
-
Serializer::Archi::ViewpointType.values[idx]
|
58
|
-
else
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
end
|
62
102
|
end
|
63
103
|
end
|
64
104
|
end
|
@@ -31,8 +31,7 @@ module Archimate
|
|
31
31
|
def diagram
|
32
32
|
@diagram ||= DataModel::Diagram.new(
|
33
33
|
id: @attrs["identifier"],
|
34
|
-
|
35
|
-
viewpoint: nil,
|
34
|
+
viewpoint: viewpoint,
|
36
35
|
connection_router_type: @attrs["connectionRouterType"],
|
37
36
|
type: @attrs["xsi:type"],
|
38
37
|
background: @attrs["background"]
|
@@ -53,6 +52,18 @@ module Archimate
|
|
53
52
|
@connections << connection
|
54
53
|
false
|
55
54
|
end
|
55
|
+
|
56
|
+
VIEWPOINT_MAP = {
|
57
|
+
"Business Process Co-operation" => DataModel::Viewpoints::Business_process_cooperation,
|
58
|
+
"Application Co-operation" => DataModel::Viewpoints::Application_cooperation
|
59
|
+
}.freeze
|
60
|
+
|
61
|
+
def viewpoint
|
62
|
+
viewpoint_attr = @attrs["viewpoint"]&.strip || ""
|
63
|
+
return nil if viewpoint_attr.empty?
|
64
|
+
return VIEWPOINT_MAP[viewpoint_attr] if VIEWPOINT_MAP.include?(viewpoint_attr)
|
65
|
+
DataModel::Viewpoints.with_name(viewpoint_attr)
|
66
|
+
end
|
56
67
|
end
|
57
68
|
end
|
58
69
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "nokogiri"
|
4
|
+
|
5
|
+
module Archimate
|
6
|
+
module FileFormats
|
7
|
+
module Serializer
|
8
|
+
module Archi
|
9
|
+
class ArchiFileWriter < Serializer::Writer
|
10
|
+
include Serializer::Archi::Bounds
|
11
|
+
include Serializer::Archi::Connection
|
12
|
+
include Serializer::Archi::Diagram
|
13
|
+
include Serializer::Archi::Documentation
|
14
|
+
include Serializer::Archi::Element
|
15
|
+
include Serializer::Archi::Model
|
16
|
+
include Serializer::Archi::Organization
|
17
|
+
include Serializer::Archi::Property
|
18
|
+
include Serializer::Archi::Relationship
|
19
|
+
include Serializer::Archi::ViewNode
|
20
|
+
include Serializer::Archi::Viewpoint3
|
21
|
+
|
22
|
+
TEXT_SUBSTITUTIONS = [
|
23
|
+
[' ', '
'],
|
24
|
+
['"', '"'],
|
25
|
+
['>', '>'],
|
26
|
+
['&', '&']
|
27
|
+
].freeze
|
28
|
+
|
29
|
+
def initialize(model)
|
30
|
+
super
|
31
|
+
@version = "3.1.1"
|
32
|
+
end
|
33
|
+
|
34
|
+
def process_text(doc_str)
|
35
|
+
%w(documentation content name).each do |tag|
|
36
|
+
TEXT_SUBSTITUTIONS.each do |from, to|
|
37
|
+
doc_str.gsub!(%r{<#{tag}>([^<]*#{from}[^<]*)</#{tag}>}) do |str|
|
38
|
+
str.gsub(from, to)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
doc_str.gsub(
|
43
|
+
%r{<(/)?archimate:}, "<\\1"
|
44
|
+
).gsub(
|
45
|
+
%r{<(/)?model}, "<\\1archimate:model"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write(archifile_io)
|
50
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
51
|
+
serialize_model(xml, model)
|
52
|
+
end
|
53
|
+
archifile_io.write(
|
54
|
+
process_text(
|
55
|
+
builder.to_xml
|
56
|
+
)
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Serializer
|
6
|
+
module Archi
|
7
|
+
class ArchiFileWriter3 < Serializer::Archi::ArchiFileWriter
|
8
|
+
include Serializer::Archi::Viewpoint3
|
9
|
+
|
10
|
+
def initialize(model)
|
11
|
+
super
|
12
|
+
@version = model.version || "3.1.1"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Serializer
|
6
|
+
module Archi
|
7
|
+
class ArchiFileWriter4 < Serializer::Archi::ArchiFileWriter
|
8
|
+
include Serializer::Archi::Viewpoint4
|
9
|
+
|
10
|
+
def initialize(model)
|
11
|
+
super
|
12
|
+
@version = model.version || "4.0.0"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,12 +8,12 @@ module Archimate
|
|
8
8
|
def serialize_bounds(xml, bounds)
|
9
9
|
return unless bounds
|
10
10
|
xml.bounds(
|
11
|
-
|
11
|
+
{
|
12
12
|
x: bounds.x&.to_i,
|
13
13
|
y: bounds.y&.to_i,
|
14
14
|
width: bounds.width&.to_i,
|
15
15
|
height: bounds.height&.to_i
|
16
|
-
|
16
|
+
}.compact
|
17
17
|
)
|
18
18
|
end
|
19
19
|
end
|
@@ -7,25 +7,36 @@ module Archimate
|
|
7
7
|
module Connection
|
8
8
|
def serialize_connection(xml, connection)
|
9
9
|
xml.sourceConnection(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
"relationship" => connection.relationship&.id
|
20
|
-
)
|
10
|
+
{
|
11
|
+
"xsi:type" => connection.type,
|
12
|
+
"id" => connection.id,
|
13
|
+
"name" => connection.name
|
14
|
+
}.merge(
|
15
|
+
archi_style_hash(connection.style).merge(
|
16
|
+
"source" => connection.source&.id,
|
17
|
+
"target" => connection.target&.id,
|
18
|
+
"archimateRelationship" => connection.relationship&.id
|
21
19
|
)
|
22
|
-
)
|
20
|
+
).compact
|
23
21
|
) do
|
24
|
-
|
22
|
+
connection.bendpoints.each do |bendpoint|
|
23
|
+
serialize_bendpoint(xml, bendpoint, connection)
|
24
|
+
end
|
25
25
|
serialize_documentation(xml, connection.documentation)
|
26
26
|
serialize(xml, connection.properties)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
def serialize_bendpoint(xml, bendpoint, connection)
|
31
|
+
xml.bendpoint(
|
32
|
+
{
|
33
|
+
startX: (bendpoint.x - connection.start_location.x).to_i,
|
34
|
+
startY: (bendpoint.y - connection.start_location.y).to_i,
|
35
|
+
endX: (bendpoint.x - connection.end_location.x).to_i,
|
36
|
+
endY: (bendpoint.y - connection.end_location.y).to_i
|
37
|
+
}.delete_if { |_k, v| v.zero? }
|
38
|
+
)
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
@@ -7,14 +7,14 @@ module Archimate
|
|
7
7
|
module Diagram
|
8
8
|
def serialize_diagram(xml, diagram)
|
9
9
|
xml.element(
|
10
|
-
|
10
|
+
{
|
11
11
|
"xsi:type" => diagram.type || "archimate:ArchimateDiagramModel",
|
12
12
|
"id" => diagram.id,
|
13
13
|
"name" => diagram.name,
|
14
14
|
"connectionRouterType" => diagram.connection_router_type,
|
15
|
-
"viewpoint" =>
|
15
|
+
"viewpoint" => serialize_viewpoint(diagram.viewpoint),
|
16
16
|
"background" => diagram.background
|
17
|
-
|
17
|
+
}.compact
|
18
18
|
) do
|
19
19
|
serialize(xml, diagram.nodes)
|
20
20
|
serialize_documentation(xml, diagram.documentation)
|
@@ -7,11 +7,11 @@ module Archimate
|
|
7
7
|
module Element
|
8
8
|
def serialize_element(xml, element)
|
9
9
|
xml.element(
|
10
|
-
|
10
|
+
{
|
11
11
|
"xsi:type" => "archimate:#{element.type}",
|
12
12
|
"id" => element.id,
|
13
13
|
"name" => element.name
|
14
|
-
|
14
|
+
}.compact
|
15
15
|
) do
|
16
16
|
serialize_documentation(xml, element.documentation)
|
17
17
|
serialize(xml, element.properties)
|
@@ -7,7 +7,7 @@ module Archimate
|
|
7
7
|
module Organization
|
8
8
|
def serialize_organization(xml, organization)
|
9
9
|
xml.folder(
|
10
|
-
|
10
|
+
{ name: organization.name, id: organization.id, type: organization.type }.compact
|
11
11
|
) do
|
12
12
|
serialize(xml, organization.organizations)
|
13
13
|
serialize_documentation(xml, organization.documentation)
|
@@ -7,14 +7,14 @@ module Archimate
|
|
7
7
|
module Relationship
|
8
8
|
def serialize_relationship(xml, rel)
|
9
9
|
xml.element(
|
10
|
-
|
10
|
+
{
|
11
11
|
"xsi:type" => "archimate:#{rel.type}Relationship",
|
12
12
|
"id" => rel.id,
|
13
13
|
"name" => rel.name,
|
14
14
|
"source" => rel.source.id,
|
15
15
|
"target" => rel.target.id,
|
16
16
|
"accessType" => serialize_access_type(rel.access_type)
|
17
|
-
|
17
|
+
}.compact
|
18
18
|
) do
|
19
19
|
serialize_documentation(xml, rel.documentation)
|
20
20
|
serialize(xml, rel.properties)
|
@@ -5,32 +5,30 @@ module Archimate
|
|
5
5
|
module Serializer
|
6
6
|
module Archi
|
7
7
|
module ViewNode
|
8
|
-
def serialize_view_node(xml,
|
9
|
-
style_hash = archi_style_hash(
|
8
|
+
def serialize_view_node(xml, view_node)
|
9
|
+
style_hash = archi_style_hash(view_node.style)
|
10
10
|
fill_color = style_hash.delete("fillColor")
|
11
11
|
xml.child(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"type" => child.child_type
|
24
|
-
)
|
12
|
+
{
|
13
|
+
"xsi:type" => view_node.type,
|
14
|
+
"id" => view_node.id,
|
15
|
+
"name" => view_node.name
|
16
|
+
}.merge(
|
17
|
+
style_hash.merge(
|
18
|
+
"targetConnections" => view_node.target_connections.empty? ? nil : view_node.target_connections.join(" "),
|
19
|
+
"fillColor" => fill_color,
|
20
|
+
"model" => view_node.view_refs&.id,
|
21
|
+
"archimateElement" => view_node.element&.id,
|
22
|
+
"type" => view_node.child_type
|
25
23
|
)
|
26
|
-
)
|
24
|
+
).compact
|
27
25
|
) do
|
28
|
-
serialize_bounds(xml,
|
29
|
-
serialize(xml,
|
30
|
-
xml.content { xml.text
|
31
|
-
serialize(xml,
|
32
|
-
serialize_documentation(xml,
|
33
|
-
serialize(xml,
|
26
|
+
serialize_bounds(xml, view_node.bounds)
|
27
|
+
serialize(xml, (view_node.connections + view_node.diagram.connections.select { |conn| conn.source.id == view_node.id }).uniq)
|
28
|
+
xml.content { xml.text view_node.content } if view_node.content
|
29
|
+
serialize(xml, view_node.nodes)
|
30
|
+
serialize_documentation(xml, view_node.documentation)
|
31
|
+
serialize(xml, view_node.properties)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Serializer
|
6
|
+
module Archi
|
7
|
+
module Viewpoint3
|
8
|
+
VIEWPOINT_INDEX = {
|
9
|
+
# nil => "1", # DataModel::Viewpoints::Actor_cooperation,
|
10
|
+
DataModel::Viewpoints::Application_behavior => "2",
|
11
|
+
DataModel::Viewpoints::Application_cooperation => "3",
|
12
|
+
DataModel::Viewpoints::Application_structure => "4",
|
13
|
+
DataModel::Viewpoints::Application_usage => "5",
|
14
|
+
DataModel::Viewpoints::Business_function => "6",
|
15
|
+
# nil => "7", # DataModel::Viewpoints::Business_cooperation,
|
16
|
+
DataModel::Viewpoints::Business_process => "8",
|
17
|
+
DataModel::Viewpoints::Product => "9",
|
18
|
+
DataModel::Viewpoints::Implementation_and_deployment => "10",
|
19
|
+
DataModel::Viewpoints::Information_structure => "11",
|
20
|
+
DataModel::Viewpoints::Infrastructure_usage => "12",
|
21
|
+
DataModel::Viewpoints::Infrastructure => "13",
|
22
|
+
DataModel::Viewpoints::Layered => "14",
|
23
|
+
DataModel::Viewpoints::Organization => "15",
|
24
|
+
DataModel::Viewpoints::Service_realization => "16",
|
25
|
+
DataModel::Viewpoints::Stakeholder => "17",
|
26
|
+
DataModel::Viewpoints::Goal_realization => "18",
|
27
|
+
DataModel::Viewpoints::Goal_contribution => "19",
|
28
|
+
DataModel::Viewpoints::Principles => "20",
|
29
|
+
DataModel::Viewpoints::Requirements_realization => "21",
|
30
|
+
DataModel::Viewpoints::Motivation => "22",
|
31
|
+
DataModel::Viewpoints::Project => "23",
|
32
|
+
DataModel::Viewpoints::Migration => "24",
|
33
|
+
DataModel::Viewpoints::Implementation_and_migration => "25"
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
def serialize_viewpoint(viewpoint)
|
37
|
+
VIEWPOINT_INDEX.fetch(viewpoint, nil)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Serializer
|
6
|
+
module Archi
|
7
|
+
module Viewpoint4
|
8
|
+
VIEWPOINT_INDEX = {
|
9
|
+
DataModel::Viewpoints::Application_cooperation => "application_cooperation",
|
10
|
+
DataModel::Viewpoints::Application_usage => "application_usage",
|
11
|
+
DataModel::Viewpoints::Business_process_cooperation => "business_process_cooperation",
|
12
|
+
DataModel::Viewpoints::Product => "product",
|
13
|
+
DataModel::Viewpoints::Implementation_and_deployment => "implementation_deployment",
|
14
|
+
DataModel::Viewpoints::Information_structure => "information_structure",
|
15
|
+
DataModel::Viewpoints::Layered => "layered",
|
16
|
+
DataModel::Viewpoints::Organization => "organization",
|
17
|
+
DataModel::Viewpoints::Service_realization => "service_realization",
|
18
|
+
DataModel::Viewpoints::Stakeholder => "stakeholder",
|
19
|
+
DataModel::Viewpoints::Goal_realization => "goal_realization",
|
20
|
+
DataModel::Viewpoints::Requirements_realization => "requirements_realization",
|
21
|
+
DataModel::Viewpoints::Motivation => "motivation",
|
22
|
+
DataModel::Viewpoints::Project => "project",
|
23
|
+
DataModel::Viewpoints::Migration => "migration",
|
24
|
+
DataModel::Viewpoints::Implementation_and_migration => "implementation_migration",
|
25
|
+
# DataModel::Viewpoints::Capability => "capability",
|
26
|
+
DataModel::Viewpoints::Outcome_realization => "outcome_realization",
|
27
|
+
DataModel::Viewpoints::Physical => "physical",
|
28
|
+
# DataModel::Viewpoints::Resource => "resource",
|
29
|
+
DataModel::Viewpoints::Strategy => "strategy",
|
30
|
+
DataModel::Viewpoints::Technology => "technology",
|
31
|
+
DataModel::Viewpoints::Technology_usage => "technology_usage"
|
32
|
+
}.freeze
|
33
|
+
|
34
|
+
def serialize_viewpoint(viewpoint)
|
35
|
+
VIEWPOINT_INDEX.fetch(viewpoint, nil)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -7,11 +7,7 @@ module Archimate
|
|
7
7
|
module Style
|
8
8
|
def serialize_style(xml, style)
|
9
9
|
return unless style
|
10
|
-
xml.style(
|
11
|
-
remove_nil_values(
|
12
|
-
lineWidth: style.line_width
|
13
|
-
)
|
14
|
-
) do
|
10
|
+
xml.style({ lineWidth: style.line_width }.compact) do
|
15
11
|
serialize_color(xml, style.fill_color, :fillColor)
|
16
12
|
serialize_color(xml, style.line_color, :lineColor)
|
17
13
|
serialize_font(xml, style)
|
@@ -22,11 +18,11 @@ module Archimate
|
|
22
18
|
def serialize_font(xml, style)
|
23
19
|
return unless style && (style.font || style.font_color)
|
24
20
|
xml.font(
|
25
|
-
|
21
|
+
{
|
26
22
|
name: style.font&.name,
|
27
23
|
size: style.font&.size&.round,
|
28
24
|
style: font_style_string(style.font)
|
29
|
-
|
25
|
+
}.compact
|
30
26
|
) { serialize_color(xml, style&.font_color, :color) }
|
31
27
|
end
|
32
28
|
|
@@ -8,11 +8,11 @@ module Archimate
|
|
8
8
|
module Diagram
|
9
9
|
def serialize_diagram(xml, diagram)
|
10
10
|
xml.view(
|
11
|
-
|
11
|
+
{
|
12
12
|
identifier: identifier(diagram.id),
|
13
|
-
viewpoint: diagram.
|
13
|
+
viewpoint: viewpoint_attribute(diagram.viewpoint),
|
14
14
|
"xsi:type": diagram.type
|
15
|
-
|
15
|
+
}.compact
|
16
16
|
) do
|
17
17
|
elementbase(xml, diagram)
|
18
18
|
serialize(xml, diagram.nodes)
|
@@ -14,7 +14,7 @@ module Archimate
|
|
14
14
|
serialize_properties(xml, model)
|
15
15
|
Serializer::NamedCollection.new("elements", model.elements).serialize(xml) { |xml_e, elements| serialize(xml_e, elements) }
|
16
16
|
Serializer::NamedCollection.new("relationships", model.relationships).serialize(xml) { |xml_r, relationships| serialize(xml_r, relationships) }
|
17
|
-
NamedCollection.new("organization", model.organizations).serialize(xml) { |xml_o, orgs|
|
17
|
+
NamedCollection.new("organization", model.organizations).serialize(xml) { |xml_o, orgs| serialize(xml_o, orgs) }
|
18
18
|
Serializer::XmlPropertyDefs.new(model.property_definitions).serialize(xml)
|
19
19
|
NamedCollection.new("views", model.diagrams).serialize(xml) do |xml_v, diagrams|
|
20
20
|
serialize(xml_v, diagrams)
|
@@ -24,7 +24,14 @@ module Archimate
|
|
24
24
|
|
25
25
|
def model_attrs
|
26
26
|
model.namespaces.merge(
|
27
|
-
"
|
27
|
+
"xmlns" => "http://www.opengroup.org/xsd/archimate",
|
28
|
+
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
|
29
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
30
|
+
"xsi:schemaLocation" => %w[http://www.opengroup.org/xsd/archimate
|
31
|
+
http://www.opengroup.org/xsd/archimate/archimate_v2p1.xsd
|
32
|
+
http://purl.org/dc/elements/1.1/
|
33
|
+
http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd].join(" "),
|
34
|
+
# "xsi:schemaLocation" => model.schema_locations.join(" "),
|
28
35
|
"identifier" => identifier(model.id)
|
29
36
|
)
|
30
37
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module FileFormats
|
5
|
+
module Serializer
|
6
|
+
module ModelExchangeFile
|
7
|
+
module V21
|
8
|
+
module Viewpoint
|
9
|
+
VIEWPOINT_MAP = {
|
10
|
+
"Business Process Co-operation" => DataModel::Viewpoints::Business_process_cooperation,
|
11
|
+
"Application Co-operation" => DataModel::Viewpoints::Application_cooperation
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
def viewpoint_attribute(viewpoint)
|
15
|
+
return nil unless viewpoint
|
16
|
+
VIEWPOINT_MAP.key(viewpoint) || viewpoint.name.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -8,11 +8,11 @@ module Archimate
|
|
8
8
|
module Diagram
|
9
9
|
def serialize_diagram(xml, diagram)
|
10
10
|
xml.view(
|
11
|
-
|
11
|
+
{
|
12
12
|
identifier: identifier(diagram.id),
|
13
13
|
"xsi:type": diagram.type,
|
14
|
-
viewpoint: diagram.
|
15
|
-
|
14
|
+
viewpoint: diagram.viewpoint&.name
|
15
|
+
}.compact
|
16
16
|
) do
|
17
17
|
elementbase(xml, diagram)
|
18
18
|
serialize(xml, diagram.nodes)
|