archimate 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.projectile +18 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +4 -0
- data/.yardocs +15 -0
- data/Gemfile +5 -0
- data/Guardfile +27 -0
- data/LICENSE +201 -0
- data/README.md +94 -0
- data/Rakefile +29 -0
- data/TODOs.org +286 -0
- data/archimate.gemspec +51 -0
- data/bin/archimate +17 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/exe/archidiff +7 -0
- data/exe/archidiff-summary +7 -0
- data/exe/archimate +7 -0
- data/exe/archimerge +7 -0
- data/exe/fmtxml +7 -0
- data/lib/archimate/cli/archi.rb +189 -0
- data/lib/archimate/cli/cleanup.rb +54 -0
- data/lib/archimate/cli/conflict_resolver.rb +39 -0
- data/lib/archimate/cli/convert.rb +39 -0
- data/lib/archimate/cli/diff.rb +31 -0
- data/lib/archimate/cli/diff_summary.rb +101 -0
- data/lib/archimate/cli/duper.rb +85 -0
- data/lib/archimate/cli/lint.rb +16 -0
- data/lib/archimate/cli/mapper.rb +82 -0
- data/lib/archimate/cli/merge.rb +49 -0
- data/lib/archimate/cli/merger.rb +109 -0
- data/lib/archimate/cli/stats.rb +42 -0
- data/lib/archimate/cli/svger.rb +40 -0
- data/lib/archimate/color.rb +53 -0
- data/lib/archimate/config.rb +35 -0
- data/lib/archimate/data_model/any_attribute.rb +13 -0
- data/lib/archimate/data_model/any_element.rb +15 -0
- data/lib/archimate/data_model/archimate_node.rb +181 -0
- data/lib/archimate/data_model/bounds.rb +72 -0
- data/lib/archimate/data_model/color.rb +47 -0
- data/lib/archimate/data_model/concept.rb +14 -0
- data/lib/archimate/data_model/concern.rb +17 -0
- data/lib/archimate/data_model/connection.rb +107 -0
- data/lib/archimate/data_model/constants.rb +82 -0
- data/lib/archimate/data_model/container.rb +17 -0
- data/lib/archimate/data_model/diagram.rb +40 -0
- data/lib/archimate/data_model/diffable_array.rb +213 -0
- data/lib/archimate/data_model/diffable_primitive.rb +83 -0
- data/lib/archimate/data_model/documentation.rb +14 -0
- data/lib/archimate/data_model/element.rb +87 -0
- data/lib/archimate/data_model/font.rb +54 -0
- data/lib/archimate/data_model/label.rb +19 -0
- data/lib/archimate/data_model/lang_string.rb +41 -0
- data/lib/archimate/data_model/location.rb +31 -0
- data/lib/archimate/data_model/metadata.rb +14 -0
- data/lib/archimate/data_model/model.rb +217 -0
- data/lib/archimate/data_model/modeling_note.rb +13 -0
- data/lib/archimate/data_model/named_referenceable.rb +14 -0
- data/lib/archimate/data_model/organization.rb +40 -0
- data/lib/archimate/data_model/property.rb +25 -0
- data/lib/archimate/data_model/property_definition.rb +16 -0
- data/lib/archimate/data_model/referenceable.rb +29 -0
- data/lib/archimate/data_model/relationship.rb +85 -0
- data/lib/archimate/data_model/schema_info.rb +18 -0
- data/lib/archimate/data_model/style.rb +32 -0
- data/lib/archimate/data_model/view.rb +12 -0
- data/lib/archimate/data_model/view_concept.rb +18 -0
- data/lib/archimate/data_model/view_node.rb +114 -0
- data/lib/archimate/data_model/viewpoint.rb +87 -0
- data/lib/archimate/data_model.rb +54 -0
- data/lib/archimate/diff/archimate_array_reference.rb +113 -0
- data/lib/archimate/diff/archimate_identified_node_reference.rb +41 -0
- data/lib/archimate/diff/archimate_node_attribute_reference.rb +70 -0
- data/lib/archimate/diff/archimate_node_reference.rb +80 -0
- data/lib/archimate/diff/change.rb +49 -0
- data/lib/archimate/diff/conflict.rb +31 -0
- data/lib/archimate/diff/conflicts/base_conflict.rb +53 -0
- data/lib/archimate/diff/conflicts/deleted_items_child_updated_conflict.rb +30 -0
- data/lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb +63 -0
- data/lib/archimate/diff/conflicts/path_conflict.rb +51 -0
- data/lib/archimate/diff/conflicts.rb +89 -0
- data/lib/archimate/diff/delete.rb +41 -0
- data/lib/archimate/diff/difference.rb +113 -0
- data/lib/archimate/diff/insert.rb +43 -0
- data/lib/archimate/diff/merge.rb +70 -0
- data/lib/archimate/diff/move.rb +51 -0
- data/lib/archimate/diff.rb +17 -0
- data/lib/archimate/export/csv_export.rb +32 -0
- data/lib/archimate/export/cypher.rb +171 -0
- data/lib/archimate/export/graph_ml.rb +131 -0
- data/lib/archimate/export/n_quads.rb +142 -0
- data/lib/archimate/file_format.rb +30 -0
- data/lib/archimate/file_formats/archi_file_format.rb +151 -0
- data/lib/archimate/file_formats/archi_file_reader.rb +252 -0
- data/lib/archimate/file_formats/archi_file_writer.rb +230 -0
- data/lib/archimate/file_formats/archimate_v2.rb +461 -0
- data/lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb +35 -0
- data/lib/archimate/file_formats/model_exchange_file/xml_metadata.rb +115 -0
- data/lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb +28 -0
- data/lib/archimate/file_formats/model_exchange_file/xml_property_defs.rb +27 -0
- data/lib/archimate/file_formats/model_exchange_file_reader.rb +237 -0
- data/lib/archimate/file_formats/model_exchange_file_reader_21.rb +73 -0
- data/lib/archimate/file_formats/model_exchange_file_reader_30.rb +134 -0
- data/lib/archimate/file_formats/model_exchange_file_writer.rb +157 -0
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +143 -0
- data/lib/archimate/file_formats/model_exchange_file_writer_30.rb +153 -0
- data/lib/archimate/file_formats/writer.rb +56 -0
- data/lib/archimate/lint/duplicate_entities.rb +121 -0
- data/lib/archimate/lint/linter.rb +146 -0
- data/lib/archimate/logging.rb +55 -0
- data/lib/archimate/maybe_io.rb +34 -0
- data/lib/archimate/progress_indicator.rb +29 -0
- data/lib/archimate/svg/archimate.css +232 -0
- data/lib/archimate/svg/child.rb +29 -0
- data/lib/archimate/svg/connection.rb +184 -0
- data/lib/archimate/svg/css_style.rb +31 -0
- data/lib/archimate/svg/diagram.rb +87 -0
- data/lib/archimate/svg/entity/and_junction.rb +14 -0
- data/lib/archimate/svg/entity/application_collaboration.rb +14 -0
- data/lib/archimate/svg/entity/application_component.rb +41 -0
- data/lib/archimate/svg/entity/application_event.rb +13 -0
- data/lib/archimate/svg/entity/application_function.rb +13 -0
- data/lib/archimate/svg/entity/application_interaction.rb +13 -0
- data/lib/archimate/svg/entity/application_interface.rb +13 -0
- data/lib/archimate/svg/entity/application_process.rb +13 -0
- data/lib/archimate/svg/entity/application_service.rb +13 -0
- data/lib/archimate/svg/entity/artifact.rb +39 -0
- data/lib/archimate/svg/entity/assessment.rb +14 -0
- data/lib/archimate/svg/entity/base_entity.rb +128 -0
- data/lib/archimate/svg/entity/business_actor.rb +14 -0
- data/lib/archimate/svg/entity/business_collaboration.rb +14 -0
- data/lib/archimate/svg/entity/business_event.rb +10 -0
- data/lib/archimate/svg/entity/business_function.rb +13 -0
- data/lib/archimate/svg/entity/business_interaction.rb +13 -0
- data/lib/archimate/svg/entity/business_interface.rb +13 -0
- data/lib/archimate/svg/entity/business_object.rb +13 -0
- data/lib/archimate/svg/entity/business_process.rb +13 -0
- data/lib/archimate/svg/entity/business_role.rb +14 -0
- data/lib/archimate/svg/entity/business_service.rb +13 -0
- data/lib/archimate/svg/entity/capability.rb +14 -0
- data/lib/archimate/svg/entity/communication_network.rb +14 -0
- data/lib/archimate/svg/entity/communication_path.rb +14 -0
- data/lib/archimate/svg/entity/constraint.rb +15 -0
- data/lib/archimate/svg/entity/contract.rb +13 -0
- data/lib/archimate/svg/entity/course_of_action.rb +14 -0
- data/lib/archimate/svg/entity/data_entity.rb +29 -0
- data/lib/archimate/svg/entity/data_object.rb +13 -0
- data/lib/archimate/svg/entity/deliverable.rb +13 -0
- data/lib/archimate/svg/entity/device.rb +48 -0
- data/lib/archimate/svg/entity/diagram_model_reference.rb +22 -0
- data/lib/archimate/svg/entity/diagram_object.rb +30 -0
- data/lib/archimate/svg/entity/distribution_network.rb +14 -0
- data/lib/archimate/svg/entity/driver.rb +14 -0
- data/lib/archimate/svg/entity/equipment.rb +16 -0
- data/lib/archimate/svg/entity/event_entity.rb +36 -0
- data/lib/archimate/svg/entity/facility.rb +16 -0
- data/lib/archimate/svg/entity/function_entity.rb +14 -0
- data/lib/archimate/svg/entity/gap.rb +21 -0
- data/lib/archimate/svg/entity/goal.rb +14 -0
- data/lib/archimate/svg/entity/group.rb +24 -0
- data/lib/archimate/svg/entity/implementation_event.rb +13 -0
- data/lib/archimate/svg/entity/infrastructure_function.rb +13 -0
- data/lib/archimate/svg/entity/infrastructure_interface.rb +13 -0
- data/lib/archimate/svg/entity/infrastructure_service.rb +13 -0
- data/lib/archimate/svg/entity/interaction_entity.rb +14 -0
- data/lib/archimate/svg/entity/interface_entity.rb +35 -0
- data/lib/archimate/svg/entity/junction.rb +19 -0
- data/lib/archimate/svg/entity/location.rb +14 -0
- data/lib/archimate/svg/entity/material.rb +14 -0
- data/lib/archimate/svg/entity/meaning.rb +40 -0
- data/lib/archimate/svg/entity/motivation_entity.rb +40 -0
- data/lib/archimate/svg/entity/network.rb +14 -0
- data/lib/archimate/svg/entity/node.rb +33 -0
- data/lib/archimate/svg/entity/node_shape.rb +64 -0
- data/lib/archimate/svg/entity/note.rb +30 -0
- data/lib/archimate/svg/entity/or_junction.rb +14 -0
- data/lib/archimate/svg/entity/outcome.rb +15 -0
- data/lib/archimate/svg/entity/path.rb +14 -0
- data/lib/archimate/svg/entity/plateau.rb +15 -0
- data/lib/archimate/svg/entity/principle.rb +15 -0
- data/lib/archimate/svg/entity/process_entity.rb +63 -0
- data/lib/archimate/svg/entity/product.rb +20 -0
- data/lib/archimate/svg/entity/rect.rb +13 -0
- data/lib/archimate/svg/entity/rect_entity.rb +25 -0
- data/lib/archimate/svg/entity/representation.rb +31 -0
- data/lib/archimate/svg/entity/requirement.rb +15 -0
- data/lib/archimate/svg/entity/resource.rb +14 -0
- data/lib/archimate/svg/entity/rounded_rect_entity.rb +23 -0
- data/lib/archimate/svg/entity/service_entity.rb +51 -0
- data/lib/archimate/svg/entity/sketch_model_sticky.rb +14 -0
- data/lib/archimate/svg/entity/stakeholder.rb +15 -0
- data/lib/archimate/svg/entity/system_software.rb +14 -0
- data/lib/archimate/svg/entity/technology_collaboration.rb +14 -0
- data/lib/archimate/svg/entity/technology_event.rb +13 -0
- data/lib/archimate/svg/entity/technology_function.rb +13 -0
- data/lib/archimate/svg/entity/technology_interaction.rb +13 -0
- data/lib/archimate/svg/entity/technology_interface.rb +13 -0
- data/lib/archimate/svg/entity/technology_process.rb +13 -0
- data/lib/archimate/svg/entity/technology_service.rb +13 -0
- data/lib/archimate/svg/entity/value.rb +27 -0
- data/lib/archimate/svg/entity/work_package.rb +14 -0
- data/lib/archimate/svg/entity.rb +93 -0
- data/lib/archimate/svg/entity_factory.rb +17 -0
- data/lib/archimate/svg/extents.rb +27 -0
- data/lib/archimate/svg/point.rb +7 -0
- data/lib/archimate/svg/svg_template.rb +27 -0
- data/lib/archimate/svg/svg_template.svg.erb +169 -0
- data/lib/archimate/version.rb +4 -0
- data/lib/archimate.rb +114 -0
- metadata +623 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# This module takes an ArchiMate model and builds GraphML representation of it.
|
3
|
+
require "set"
|
4
|
+
|
5
|
+
module Archimate
|
6
|
+
module Export
|
7
|
+
class GraphML
|
8
|
+
attr_reader :model
|
9
|
+
|
10
|
+
def initialize(model)
|
11
|
+
@model = model
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_graphml
|
15
|
+
@prop_id = 1
|
16
|
+
@edge_id = 1
|
17
|
+
@layers = Hash.new do |hash, key|
|
18
|
+
hash[key] = [] unless hash.key?(key)
|
19
|
+
hash[key]
|
20
|
+
end
|
21
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
22
|
+
xml.graphml(
|
23
|
+
"xmlns" => "http://graphml.graphdrawing.org/xmlns",
|
24
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
25
|
+
"xsi:schemaLocation" => "http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"
|
26
|
+
) do
|
27
|
+
xml.key(id: "element-type", for: "node", "attr.name" => "type", "attr.type" => "string")
|
28
|
+
xml.key(id: "relationship-type", for: "edge", "attr.name" => "type", "attr.type" => "string")
|
29
|
+
xml.key(id: "name", for: "all", "attr.name" => "name", "attr.type" => "string")
|
30
|
+
xml.key(id: "documentation", for: "all", "attr.name" => "documentation", "attr.type" => "string")
|
31
|
+
xml.key(id: "property-value", for: "all", "attr.name" => "value", "attr.type" => "string")
|
32
|
+
xml.graph(
|
33
|
+
id: model.id,
|
34
|
+
edgedefault: "directed"
|
35
|
+
) do
|
36
|
+
graph_attrs(xml, model)
|
37
|
+
nodes(xml, model.elements)
|
38
|
+
layers(xml, @layers)
|
39
|
+
relationships(xml, model.relationships)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
builder.to_xml
|
44
|
+
end
|
45
|
+
|
46
|
+
def next_prop_id
|
47
|
+
@prop_id += 1
|
48
|
+
"property-#{@prop_id}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def next_edge_id
|
52
|
+
@edge_id += 1
|
53
|
+
"edge-#{@edge_id}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def graph_attrs(xml, model)
|
57
|
+
name(xml, model.name)
|
58
|
+
docs(xml, model.documentation)
|
59
|
+
properties(xml, model.id, model.properties)
|
60
|
+
end
|
61
|
+
|
62
|
+
def name(xml, name_str)
|
63
|
+
data(xml, "name", name_str) unless name_str.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
def data_type(xml, key, type)
|
67
|
+
data(xml, key, type.nil? ? nil : type.sub("archimate:", ""))
|
68
|
+
end
|
69
|
+
|
70
|
+
def data(xml, key, value)
|
71
|
+
xml.data(key: key) { xml.text(value) unless value.nil? }
|
72
|
+
end
|
73
|
+
|
74
|
+
def properties(xml, source_id, properties)
|
75
|
+
properties.each do |property|
|
76
|
+
# TODO: if we want to be slick here, keep a set of property values and point to that instead
|
77
|
+
prop_id = next_prop_id
|
78
|
+
node(xml, prop_id, property.key, "Property", "property-value" => property.value)
|
79
|
+
edge(xml, next_edge_id, source_id, prop_id, "HasProperty", property.key)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def docs(xml, docs)
|
84
|
+
docs.each do |doc|
|
85
|
+
data(xml, "documentation", doc)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def nodes(xml, elements)
|
90
|
+
elements.each do |element|
|
91
|
+
node(xml, element.id, element.name, element.type, element.documentation, element.properties)
|
92
|
+
|
93
|
+
@layers[element.layer] << element.id
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def layers(xml, layers)
|
98
|
+
layers.each_with_index do |layer, i|
|
99
|
+
node(xml, "layer-#{i}", layer, "Layer")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def relationships(xml, relationships)
|
104
|
+
relationships.each do |r|
|
105
|
+
edge(xml, r.id, r.source, r.target, r.type, r.name, r.documentation, r.properties)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def node(xml, id, name, type, docs = [], properties = [], other_data = {})
|
110
|
+
xml.node(id: id, label: name, labels: "#{type}:#{name}") do
|
111
|
+
data_type(xml, "element-type", type)
|
112
|
+
name(xml, name)
|
113
|
+
docs(xml, docs)
|
114
|
+
other_data.each do |k, v|
|
115
|
+
xml.data(key: k) { xml.text(v) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
properties(xml, id, properties)
|
119
|
+
end
|
120
|
+
|
121
|
+
def edge(xml, id, source, target, type, name = nil, docs = [], properties = [])
|
122
|
+
xml.edge(id: id, source: source, target: target, label: type) do
|
123
|
+
data_type(xml, "relationship-type", type)
|
124
|
+
name(xml, name)
|
125
|
+
docs(xml, docs)
|
126
|
+
end
|
127
|
+
properties(xml, id, properties)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module takes an ArchiMate model and builds a set of relationship quads
|
4
|
+
# for use in RDF or graph databases.
|
5
|
+
#
|
6
|
+
# The approach is to as follows:
|
7
|
+
#
|
8
|
+
# For each element in the model (not under the "Views" organization)
|
9
|
+
# (Which looks like this:
|
10
|
+
# <element xsi:type="archimate:BusinessProcess" id="0f6c2750"
|
11
|
+
# name="Start Provisioning"/>)
|
12
|
+
#
|
13
|
+
# <0f6c2750> <named> <Start Provisioning>
|
14
|
+
# <0f6c2750> <typed> <archimate:BusinessProcess>
|
15
|
+
# <0f6c2750> <in_layer> <business>
|
16
|
+
#
|
17
|
+
# and for relationship
|
18
|
+
# <element xsi:type="archimate:AssignmentRelationship" id="a7cc2df6"
|
19
|
+
# source="1c524402" target="0f6c2750"/>
|
20
|
+
#
|
21
|
+
# a couple of options:
|
22
|
+
#
|
23
|
+
# option 1:
|
24
|
+
#
|
25
|
+
# <0f6c2750> <targeted_by> <a7cc2df6>
|
26
|
+
# <1c524402> <sourced_by> <a7cc2df6>
|
27
|
+
# <a7cc2df6> <typed> <archimate:AssignmentRelationship>
|
28
|
+
# <a7cc2df6> <sources> <1c524402>
|
29
|
+
# <a7cc2df6> <targets> <0f6c2750>
|
30
|
+
#
|
31
|
+
# option 2:
|
32
|
+
#
|
33
|
+
# <1c524402> <assigned_to> <0f6c2750>
|
34
|
+
#
|
35
|
+
# option 3: combine both so you get easier queries but retain the ability to
|
36
|
+
# look at properties on the relationship itsef.
|
37
|
+
#
|
38
|
+
# Future ideas:
|
39
|
+
#
|
40
|
+
# Take views and add to the graph so that we can do
|
41
|
+
# queries based on things that should possibly be added to a diagram or make
|
42
|
+
# suggestions on things that should be graphed.
|
43
|
+
#
|
44
|
+
# Add in quads for properties
|
45
|
+
module Archimate
|
46
|
+
module Export
|
47
|
+
Quad = Struct.new(:subject, :predicate, :object) do
|
48
|
+
def fmt_obj
|
49
|
+
if object =~ /\s/
|
50
|
+
"\"#{object.gsub('"', '\\"').gsub(/[\n\r]/, '\\n')}\""
|
51
|
+
else
|
52
|
+
"<#{object}>"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def fmt_subject
|
57
|
+
subject.gsub(/\s/, '_').to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
"<#{fmt_subject}> <#{predicate}> #{fmt_obj} ."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class NQuads
|
66
|
+
def initialize(model)
|
67
|
+
@model = model
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_nq
|
71
|
+
quads = @model.elements.map do |el|
|
72
|
+
[named(el),
|
73
|
+
typed(el),
|
74
|
+
in_layer(el),
|
75
|
+
documentation(el)]
|
76
|
+
end
|
77
|
+
quads << @model.relationships.map { |rel| relationships(rel) }
|
78
|
+
quads.flatten.compact.uniq.join("\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
def named(el)
|
82
|
+
el.name.nil? ? nil : make_quad(el.id, "named", el.name)
|
83
|
+
end
|
84
|
+
|
85
|
+
def typed(el)
|
86
|
+
make_quad(el.id, "typed", el.type)
|
87
|
+
end
|
88
|
+
|
89
|
+
def in_layer(el)
|
90
|
+
layer = el.layer
|
91
|
+
return nil if layer.nil?
|
92
|
+
make_quad(el.id, "in_layer", layer)
|
93
|
+
end
|
94
|
+
|
95
|
+
def documentation(el)
|
96
|
+
docs = []
|
97
|
+
el.documentation.each do |doc|
|
98
|
+
docs << make_quad(el.id, "documentation", doc.text)
|
99
|
+
end
|
100
|
+
docs
|
101
|
+
end
|
102
|
+
|
103
|
+
def relationships(el)
|
104
|
+
[
|
105
|
+
make_quad(el.source, predicate(el.type), el.target),
|
106
|
+
make_quad(el.id, "sources", el.source),
|
107
|
+
make_quad(el.id, "target", el.target)
|
108
|
+
]
|
109
|
+
end
|
110
|
+
|
111
|
+
PREDICATES = {
|
112
|
+
"AssociationRelationship" => %w(associated_with associated_with),
|
113
|
+
"AccessRelationship" => %w(accesses accessed_by),
|
114
|
+
"UsedByRelationship" => %w(used_by uses),
|
115
|
+
"RealisationRelationship" => %w(realizes realized_by),
|
116
|
+
"AssignmentRelationship" => %w(assigned_to assigned_from),
|
117
|
+
"AggregationRelationship" => %w(aggregates aggregated_by),
|
118
|
+
"CompositionRelationship" => %w(composes composed_by),
|
119
|
+
"FlowRelationship" => %w(flows_to flows_from),
|
120
|
+
"TriggeringRelationship" => %w(triggers triggered_by),
|
121
|
+
"GroupingRelationship" => %w(groups grouped_by),
|
122
|
+
"SpecialisationRelationship" => %w(specializes specialized_by),
|
123
|
+
"InfluenceRelationship" => %w(influences influenced)
|
124
|
+
}.freeze
|
125
|
+
|
126
|
+
def predicate(t)
|
127
|
+
raise "Unexpected relationship name: '#{t}'" unless PREDICATES.include?(t)
|
128
|
+
PREDICATES[t][0]
|
129
|
+
end
|
130
|
+
|
131
|
+
def make_quad(subject, predicate, object)
|
132
|
+
if subject.nil? || predicate.nil? || object.nil?
|
133
|
+
raise(
|
134
|
+
ArgumentError,
|
135
|
+
"Invalid: subject, predicate, or object [#{[subject, predicate, object].map(&:inspect).join(', ')}]"
|
136
|
+
)
|
137
|
+
end
|
138
|
+
Quad.new(subject, predicate, object)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "nokogiri"
|
3
|
+
|
4
|
+
module Archimate
|
5
|
+
# This File Format class supports reading and parsing from a number of ArchiMate formats
|
6
|
+
class FileFormat
|
7
|
+
def self.read(filename)
|
8
|
+
case File.extname(filename)
|
9
|
+
when ".marshal"
|
10
|
+
File.open(filename, "rb") do |marshal_file|
|
11
|
+
Marshal.load(marshal_file)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
parse(File.read(filename))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.parse(str)
|
19
|
+
doc = Nokogiri::XML(str)
|
20
|
+
case doc.namespaces["xmlns"]
|
21
|
+
when "http://www.opengroup.org/xsd/archimate/3.0/"
|
22
|
+
FileFormats::ModelExchangeFileReader30.new.parse(doc)
|
23
|
+
when "http://www.opengroup.org/xsd/archimate"
|
24
|
+
FileFormats::ModelExchangeFileReader21.new.parse(doc)
|
25
|
+
else
|
26
|
+
FileFormats::ArchiFileReader.new.parse(doc)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Archimate
|
3
|
+
module FileFormats
|
4
|
+
module ArchiFileFormat
|
5
|
+
# strategy_folder_xpath = "/archimate:model/folder[@type='strategy']"
|
6
|
+
application_folder_xpath = "/archimate:model/folder[@type='application']"
|
7
|
+
business_folder_xpath = "/archimate:model/folder[@type='business']"
|
8
|
+
technology_folder_xpath = "/archimate:model/folder[@type='technology']"
|
9
|
+
# physical_folder_xpath = "/archimate:model/folder[@type='physical']"
|
10
|
+
motivation_folder_xpath = "/archimate:model/folder[@type='motivation']"
|
11
|
+
implementation_migration_folder_xpath = "/archimate:model/folder[@type='implementation_migration']"
|
12
|
+
connectors_folder_xpath = "/archimate:model/folder[@type='connectors']"
|
13
|
+
relations_folder_xpath = "/archimate:model/folder[@type='relations']"
|
14
|
+
diagrams_folder_xpath = "/archimate:model/folder[@type='diagrams']"
|
15
|
+
|
16
|
+
ELEMENT_TYPE_TO_PARENT_XPATH = {
|
17
|
+
"archimate:BusinessActor" => business_folder_xpath,
|
18
|
+
"archimate:BusinessCollaboration" => business_folder_xpath,
|
19
|
+
"archimate:BusinessEvent" => business_folder_xpath,
|
20
|
+
"archimate:BusinessFunction" => business_folder_xpath,
|
21
|
+
"archimate:BusinessInteraction" => business_folder_xpath,
|
22
|
+
"archimate:BusinessInterface" => business_folder_xpath,
|
23
|
+
"archimate:BusinessObject" => business_folder_xpath,
|
24
|
+
"archimate:BusinessProcess" => business_folder_xpath,
|
25
|
+
"archimate:BusinessRole" => business_folder_xpath,
|
26
|
+
"archimate:BusinessService" => business_folder_xpath,
|
27
|
+
"archimate:Contract" => business_folder_xpath,
|
28
|
+
"archimate:Location" => business_folder_xpath,
|
29
|
+
"archimate:Meaning" => business_folder_xpath,
|
30
|
+
"archimate:Value" => business_folder_xpath,
|
31
|
+
"archimate:Product" => business_folder_xpath,
|
32
|
+
"archimate:Representation" => business_folder_xpath,
|
33
|
+
|
34
|
+
"archimate:ApplicationCollaboration" => application_folder_xpath,
|
35
|
+
"archimate:ApplicationComponent" => application_folder_xpath,
|
36
|
+
"archimate:ApplicationFunction" => application_folder_xpath,
|
37
|
+
"archimate:ApplicationInteraction" => application_folder_xpath,
|
38
|
+
"archimate:ApplicationInterface" => application_folder_xpath,
|
39
|
+
"archimate:ApplicationService" => application_folder_xpath,
|
40
|
+
"archimate:DataObject" => application_folder_xpath,
|
41
|
+
|
42
|
+
"archimate:Artifact" => technology_folder_xpath,
|
43
|
+
"archimate:CommunicationPath" => technology_folder_xpath,
|
44
|
+
"archimate:Device" => technology_folder_xpath,
|
45
|
+
"archimate:InfrastructureFunction" => technology_folder_xpath,
|
46
|
+
"archimate:InfrastructureInterface" => technology_folder_xpath,
|
47
|
+
"archimate:InfrastructureService" => technology_folder_xpath,
|
48
|
+
"archimate:Network" => technology_folder_xpath,
|
49
|
+
"archimate:Node" => technology_folder_xpath,
|
50
|
+
"archimate:SystemSoftware" => technology_folder_xpath,
|
51
|
+
|
52
|
+
"archimate:Assessment" => motivation_folder_xpath,
|
53
|
+
"archimate:Constraint" => motivation_folder_xpath,
|
54
|
+
"archimate:Driver" => motivation_folder_xpath,
|
55
|
+
"archimate:Goal" => motivation_folder_xpath,
|
56
|
+
"archimate:Principle" => motivation_folder_xpath,
|
57
|
+
"archimate:Requirement" => motivation_folder_xpath,
|
58
|
+
"archimate:Stakeholder" => motivation_folder_xpath,
|
59
|
+
|
60
|
+
"archimate:Deliverable" => implementation_migration_folder_xpath,
|
61
|
+
"archimate:Gap" => implementation_migration_folder_xpath,
|
62
|
+
"archimate:Plateau" => implementation_migration_folder_xpath,
|
63
|
+
"archimate:WorkPackage" => implementation_migration_folder_xpath,
|
64
|
+
|
65
|
+
"archimate:AndJunction" => connectors_folder_xpath,
|
66
|
+
"archimate:Junction" => connectors_folder_xpath,
|
67
|
+
"archimate:OrJunction" => connectors_folder_xpath,
|
68
|
+
|
69
|
+
"archimate:AccessRelationship" => relations_folder_xpath,
|
70
|
+
"archimate:AggregationRelationship" => relations_folder_xpath,
|
71
|
+
"archimate:AssignmentRelationship" => relations_folder_xpath,
|
72
|
+
"archimate:AssociationRelationship" => relations_folder_xpath,
|
73
|
+
"archimate:CompositionRelationship" => relations_folder_xpath,
|
74
|
+
"archimate:FlowRelationship" => relations_folder_xpath,
|
75
|
+
"archimate:InfluenceRelationship" => relations_folder_xpath,
|
76
|
+
"archimate:RealisationRelationship" => relations_folder_xpath,
|
77
|
+
"archimate:SpecialisationRelationship" => relations_folder_xpath,
|
78
|
+
"archimate:TriggeringRelationship" => relations_folder_xpath,
|
79
|
+
"archimate:UsedByRelationship" => relations_folder_xpath,
|
80
|
+
|
81
|
+
"archimate:SketchModel" => diagrams_folder_xpath,
|
82
|
+
"archimate:ArchimateDiagramModel" => diagrams_folder_xpath
|
83
|
+
}.freeze
|
84
|
+
|
85
|
+
FOLDER_XPATHS = [
|
86
|
+
"folder[type=\"strategy\"]",
|
87
|
+
"folder[type=\"business\"]",
|
88
|
+
"folder[type=\"application\"]",
|
89
|
+
"folder[type=\"technology\"]",
|
90
|
+
"folder[type=\"physical\"]",
|
91
|
+
"folder[type=\"motivation\"]",
|
92
|
+
"folder[type=\"implementation_migration\"]",
|
93
|
+
"folder[type=\"other\"]",
|
94
|
+
"folder[type=\"connectors\"]"
|
95
|
+
].freeze
|
96
|
+
|
97
|
+
ELEMENT_FOLDER_TYPES = %w(
|
98
|
+
strategy
|
99
|
+
business
|
100
|
+
application
|
101
|
+
technology
|
102
|
+
physical
|
103
|
+
motivation
|
104
|
+
implementation_migration
|
105
|
+
connectors
|
106
|
+
).freeze
|
107
|
+
|
108
|
+
RELATION_XPATHS = [
|
109
|
+
"folder[type=\"relations\"]",
|
110
|
+
"folder[type=\"derived\"]"
|
111
|
+
].freeze
|
112
|
+
|
113
|
+
RELATION_FOLDER_TYPES = %w(relations derived).freeze
|
114
|
+
|
115
|
+
DIAGRAM_XPATHS = [
|
116
|
+
"folder[type=\"diagrams\"]"
|
117
|
+
].freeze
|
118
|
+
|
119
|
+
DIAGRAM_FOLDER_TYPES = %w(diagrams).freeze
|
120
|
+
|
121
|
+
VIEWPOINTS = [
|
122
|
+
"",
|
123
|
+
"Actor Co-operation",
|
124
|
+
"Application Behavior",
|
125
|
+
"Application Co-operation",
|
126
|
+
"Application Structure",
|
127
|
+
"Application Usage",
|
128
|
+
"Business Function",
|
129
|
+
"Business Process Co-operation",
|
130
|
+
"Business Process",
|
131
|
+
"Product",
|
132
|
+
"Implementation and Deployment",
|
133
|
+
"Information Structure",
|
134
|
+
"Infrastructure Usage",
|
135
|
+
"Infrastructure",
|
136
|
+
"Layered",
|
137
|
+
"Organization",
|
138
|
+
"Service Realization",
|
139
|
+
"Stakeholder",
|
140
|
+
"Goal Realization",
|
141
|
+
"Goal Contribution",
|
142
|
+
"Principles",
|
143
|
+
"Requirements Realization",
|
144
|
+
"Motivation",
|
145
|
+
"Project",
|
146
|
+
"Migration",
|
147
|
+
"Implementation and Migration"
|
148
|
+
].freeze
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|