lutaml 0.9.27 → 0.9.29
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 +4 -4
- data/README.adoc +36 -35
- data/bin/plantuml2lutaml +11 -7
- data/bin/yaml2lutaml +1 -1
- data/exe/lutaml-sysml +4 -2
- data/exe/lutaml-wsd2uml +11 -7
- data/exe/lutaml-yaml2uml +1 -1
- data/lib/lutaml/express/parsers/exp.rb +4 -4
- data/lib/lutaml/formatter/graphviz.rb +7 -7
- data/lib/lutaml/parser.rb +3 -31
- data/lib/lutaml/sysml/allocate.rb +6 -7
- data/lib/lutaml/sysml/allocated.rb +6 -6
- data/lib/lutaml/sysml/binding_connector.rb +6 -6
- data/lib/lutaml/sysml/block.rb +28 -25
- data/lib/lutaml/sysml/constraint_block.rb +11 -11
- data/lib/lutaml/sysml/copy.rb +5 -5
- data/lib/lutaml/sysml/derive_requirement.rb +6 -6
- data/lib/lutaml/sysml/nested_connector_end.rb +9 -9
- data/lib/lutaml/sysml/refine.rb +6 -6
- data/lib/lutaml/sysml/requirement_related.rb +6 -6
- data/lib/lutaml/sysml/satisfy.rb +6 -6
- data/lib/lutaml/sysml/test_case.rb +20 -19
- data/lib/lutaml/sysml/trace.rb +6 -6
- data/lib/lutaml/sysml/verify.rb +5 -5
- data/lib/lutaml/sysml/version.rb +1 -1
- data/lib/lutaml/sysml/xmi_file.rb +455 -415
- data/lib/lutaml/sysml.rb +1 -1
- data/lib/lutaml/uml/association.rb +4 -3
- data/lib/lutaml/uml/data_type.rb +1 -0
- data/lib/lutaml/uml/document.rb +4 -1
- data/lib/lutaml/uml/formatter/graphviz.rb +11 -13
- data/lib/lutaml/uml/has_attributes.rb +2 -2
- data/lib/lutaml/uml/has_members.rb +4 -3
- data/lib/lutaml/uml/node/class_node.rb +5 -7
- data/lib/lutaml/uml/node/field.rb +1 -3
- data/lib/lutaml/uml/node/method.rb +1 -3
- data/lib/lutaml/uml/node/relationship.rb +1 -3
- data/lib/lutaml/uml/operation.rb +6 -6
- data/lib/lutaml/uml/package.rb +3 -1
- data/lib/lutaml/uml/parsers/attribute.rb +1 -3
- data/lib/lutaml/uml/parsers/dsl.rb +11 -10
- data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +7 -6
- data/lib/lutaml/uml/parsers/yaml.rb +2 -2
- data/lib/lutaml/uml/serializers/class.rb +1 -1
- data/lib/lutaml/uml/top_element.rb +9 -9
- data/lib/lutaml/uml/top_element_attribute.rb +6 -6
- data/lib/lutaml/uml/value.rb +6 -6
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/association_drop.rb +31 -11
- data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +29 -11
- data/lib/lutaml/xmi/liquid_drops/cardinality_drop.rb +8 -2
- data/lib/lutaml/xmi/liquid_drops/constraint_drop.rb +6 -4
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +76 -18
- data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +13 -6
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +16 -7
- data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +10 -4
- data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +2 -0
- data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +10 -3
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +98 -24
- data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +11 -5
- data/lib/lutaml/xmi/liquid_drops/package_drop.rb +61 -18
- data/lib/lutaml/xmi/liquid_drops/root_drop.rb +14 -4
- data/lib/lutaml/xmi/parsers/xmi_base.rb +1031 -0
- data/lib/lutaml/xmi/parsers/xml.rb +23 -1018
- data/lib/lutaml/xml/parsers/xml.rb +6 -19
- data/lib/lutaml/xml.rb +0 -8
- data/lutaml.gemspec +2 -1
- metadata +32 -23
- data/lib/lutaml/express/lutaml_path/document_wrapper.rb +0 -22
- data/lib/lutaml/express/lutaml_path/formatter.rb +0 -14
- data/lib/lutaml/lutaml_path/document_wrapper.rb +0 -51
- data/lib/lutaml/uml/lutaml_path/document_wrapper.rb +0 -15
- data/lib/lutaml/xml/lutaml_path/document_wrapper.rb +0 -45
- data/lib/lutaml/xml/mapper.rb +0 -448
@@ -3,24 +3,26 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class ConstraintDrop < Liquid::Drop
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
6
8
|
def initialize(model) # rubocop:disable Lint/MissingSuper
|
7
9
|
@model = model
|
8
10
|
end
|
9
11
|
|
10
12
|
def name
|
11
|
-
@model
|
13
|
+
HTMLEntities.new.decode(@model.name)
|
12
14
|
end
|
13
15
|
|
14
16
|
def type
|
15
|
-
@model
|
17
|
+
@model.type
|
16
18
|
end
|
17
19
|
|
18
20
|
def weight
|
19
|
-
@model
|
21
|
+
@model.weight
|
20
22
|
end
|
21
23
|
|
22
24
|
def status
|
23
|
-
@model
|
25
|
+
@model.status
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -3,52 +3,110 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class DataTypeDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
7
9
|
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@xmi_cache = options[:xmi_cache]
|
13
|
+
|
14
|
+
@owned_attributes = model&.owned_attribute&.select do |attr|
|
15
|
+
attr.type?("uml:Property")
|
16
|
+
end
|
17
|
+
|
18
|
+
if @xmi_root_model
|
19
|
+
@matched_element = @xmi_root_model&.extension&.elements&.element&.find do |e| # rubocop:disable Layout/LineLength,Style/SafeNavigationChainLength
|
20
|
+
e.idref == @model.id
|
21
|
+
end
|
22
|
+
end
|
8
23
|
end
|
9
24
|
|
10
25
|
def xmi_id
|
11
|
-
@model
|
26
|
+
@model.id
|
12
27
|
end
|
13
28
|
|
14
29
|
def name
|
15
|
-
@model
|
30
|
+
@model.name
|
16
31
|
end
|
17
32
|
|
18
33
|
def attributes
|
19
|
-
@
|
20
|
-
|
21
|
-
|
34
|
+
@owned_attributes.map do |owned_attr|
|
35
|
+
if @options[:with_assoc] || owned_attr.association.nil?
|
36
|
+
::Lutaml::XMI::AttributeDrop.new(owned_attr, @options)
|
37
|
+
end
|
38
|
+
end.compact
|
22
39
|
end
|
23
40
|
|
24
41
|
def operations
|
25
|
-
@model
|
26
|
-
|
27
|
-
|
42
|
+
@model.owned_operation.map do |operation|
|
43
|
+
if operation.association.nil?
|
44
|
+
::Lutaml::XMI::OperationDrop.new(operation)
|
45
|
+
end
|
46
|
+
end.compact
|
28
47
|
end
|
29
48
|
|
30
|
-
def associations
|
31
|
-
|
32
|
-
|
33
|
-
|
49
|
+
def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
50
|
+
return if !@matched_element ||
|
51
|
+
!@matched_element.links ||
|
52
|
+
@matched_element.links.association.empty?
|
53
|
+
|
54
|
+
@matched_element.links.association.map do |assoc|
|
55
|
+
link_member = assoc.start == xmi_id ? "end" : "start"
|
56
|
+
link_owner_name = link_member == "start" ? "end" : "start"
|
57
|
+
|
58
|
+
member_end, member_end_type, member_end_cardinality,
|
59
|
+
member_end_attribute_name, member_end_xmi_id =
|
60
|
+
serialize_member_type(xmi_id, assoc, link_member)
|
61
|
+
|
62
|
+
owner_end = serialize_owned_type(xmi_id, assoc, link_owner_name)
|
63
|
+
|
64
|
+
if member_end && ((member_end_type != "aggregation") ||
|
65
|
+
(member_end_type == "aggregation" && member_end_attribute_name))
|
66
|
+
|
67
|
+
doc_node_name = (link_member == "start" ? "source" : "target")
|
68
|
+
definition = fetch_definition_node_value(assoc.id, doc_node_name)
|
69
|
+
|
70
|
+
::Lutaml::XMI::AssociationDrop.new(
|
71
|
+
xmi_id: assoc.id,
|
72
|
+
member_end: member_end,
|
73
|
+
member_end_type: member_end_type,
|
74
|
+
member_end_cardinality: member_end_cardinality,
|
75
|
+
member_end_attribute_name: member_end_attribute_name,
|
76
|
+
member_end_xmi_id: member_end_xmi_id,
|
77
|
+
owner_end: owner_end,
|
78
|
+
owner_end_xmi_id: xmi_id,
|
79
|
+
definition: definition,
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end.compact
|
34
83
|
end
|
35
84
|
|
36
85
|
def constraints
|
37
|
-
@model
|
86
|
+
connector_node = fetch_connector(@model.id)
|
87
|
+
return unless connector_node
|
88
|
+
|
89
|
+
# In ea-xmi-2.5.1, constraints are moved to source/target under
|
90
|
+
# connectors
|
91
|
+
constraints = %i[source target].map do |st|
|
92
|
+
connector_node.send(st).constraints.constraint
|
93
|
+
end.flatten
|
94
|
+
|
95
|
+
constraints.map do |constraint|
|
38
96
|
::Lutaml::XMI::ConstraintDrop.new(constraint)
|
39
97
|
end
|
40
98
|
end
|
41
99
|
|
42
|
-
def is_abstract
|
43
|
-
@model
|
100
|
+
def is_abstract # rubocop:disable Naming/PredicateName
|
101
|
+
doc_node_attribute_value(@model.id, "isAbstract")
|
44
102
|
end
|
45
103
|
|
46
104
|
def definition
|
47
|
-
@model
|
105
|
+
doc_node_attribute_value(@model.id, "documentation")
|
48
106
|
end
|
49
107
|
|
50
108
|
def stereotype
|
51
|
-
@model
|
109
|
+
doc_node_attribute_value(@model.id, "stereotype")
|
52
110
|
end
|
53
111
|
end
|
54
112
|
end
|
@@ -3,28 +3,35 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class DiagramDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
7
9
|
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@xmi_cache = options[:xmi_cache]
|
8
13
|
end
|
9
14
|
|
10
15
|
def xmi_id
|
11
|
-
@model
|
16
|
+
@model.id
|
12
17
|
end
|
13
18
|
|
14
19
|
def name
|
15
|
-
@model
|
20
|
+
@model.properties.name
|
16
21
|
end
|
17
22
|
|
18
23
|
def definition
|
19
|
-
@model
|
24
|
+
@model.properties.documentation
|
20
25
|
end
|
21
26
|
|
22
27
|
def package_id
|
23
|
-
@model[:
|
28
|
+
@model.model.package if @options[:with_gen]
|
24
29
|
end
|
25
30
|
|
26
31
|
def package_name
|
27
|
-
@
|
32
|
+
if @options[:with_gen] && package_id
|
33
|
+
find_packaged_element_by_id(package_id)&.name
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
@@ -3,30 +3,39 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class EnumDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
7
9
|
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@xmi_cache = options[:xmi_cache]
|
13
|
+
|
14
|
+
@owned_literals = model&.owned_literal&.select do |owned_literal|
|
15
|
+
owned_literal.type? "uml:EnumerationLiteral"
|
16
|
+
end
|
8
17
|
end
|
9
18
|
|
10
19
|
def xmi_id
|
11
|
-
@model
|
20
|
+
@model.id
|
12
21
|
end
|
13
22
|
|
14
23
|
def name
|
15
|
-
@model
|
24
|
+
@model.name
|
16
25
|
end
|
17
26
|
|
18
27
|
def values
|
19
|
-
@
|
20
|
-
::Lutaml::XMI::EnumOwnedLiteralDrop.new(
|
28
|
+
@owned_literals.map do |owned_literal|
|
29
|
+
::Lutaml::XMI::EnumOwnedLiteralDrop.new(owned_literal, @options)
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
24
33
|
def definition
|
25
|
-
@model
|
34
|
+
doc_node_attribute_value(@model.id, "documentation")
|
26
35
|
end
|
27
36
|
|
28
37
|
def stereotype
|
29
|
-
@model
|
38
|
+
doc_node_attribute_value(@model.id, "stereotype")
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
@@ -3,20 +3,26 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class EnumOwnedLiteralDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
7
9
|
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@xmi_cache = options[:xmi_cache]
|
8
13
|
end
|
9
14
|
|
10
15
|
def name
|
11
|
-
@model
|
16
|
+
@model.name
|
12
17
|
end
|
13
18
|
|
14
19
|
def type
|
15
|
-
@model
|
20
|
+
uml_type_id = @model&.uml_type&.idref
|
21
|
+
lookup_entity_name(uml_type_id) || uml_type_id
|
16
22
|
end
|
17
23
|
|
18
24
|
def definition
|
19
|
-
@model
|
25
|
+
lookup_attribute_documentation(@model.id)
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationAttributeDrop < Liquid::Drop
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
6
8
|
def initialize(attr, upper_klass, gen_name, guidance = nil) # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists,Layout/LineLength
|
7
9
|
@attr = attr
|
8
10
|
@upper_klass = upper_klass
|
@@ -3,12 +3,17 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(gen, guidance = nil, options = {}) # rubocop:disable Lint/MissingSuper
|
7
9
|
@gen = gen
|
8
10
|
@looped_general_item = false
|
9
11
|
@inherited_props = []
|
10
12
|
@inherited_assoc_props = []
|
11
13
|
@guidance = guidance
|
14
|
+
@options = options
|
15
|
+
@xmi_root_model = options[:xmi_root_model]
|
16
|
+
@xmi_cache = options[:xmi_cache]
|
12
17
|
end
|
13
18
|
|
14
19
|
def id
|
@@ -24,14 +29,16 @@ module Lutaml
|
|
24
29
|
end
|
25
30
|
|
26
31
|
def general
|
27
|
-
|
32
|
+
if @gen[:general]
|
33
|
+
GeneralizationDrop.new(@gen[:general], @guidance, @options)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
def has_general?
|
31
38
|
!!@gen[:general]
|
32
39
|
end
|
33
40
|
|
34
|
-
def attributes
|
41
|
+
def attributes # rubocop:disable Metrics/MethodLength
|
35
42
|
attrs = @gen[:general_attributes]
|
36
43
|
attrs.each do |i|
|
37
44
|
name_ns = case i[:type_ns]
|
@@ -3,9 +3,28 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class KlassDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, guidance = nil, options = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
7
9
|
@model = model
|
8
10
|
@guidance = guidance
|
11
|
+
@options = options
|
12
|
+
@xmi_root_model = options[:xmi_root_model]
|
13
|
+
@xmi_cache = options[:xmi_cache]
|
14
|
+
|
15
|
+
@package = model&.packaged_element&.find do |e|
|
16
|
+
e.type?("uml:Package")
|
17
|
+
end
|
18
|
+
|
19
|
+
@owned_attributes = model&.owned_attribute&.select do |attr|
|
20
|
+
attr.type?("uml:Property")
|
21
|
+
end
|
22
|
+
|
23
|
+
if @xmi_root_model
|
24
|
+
@matched_element = @xmi_root_model&.extension&.elements&.element&.find do |e| # rubocop:disable Layout/LineLength,Style/SafeNavigationChainLength
|
25
|
+
e.idref == @model.id
|
26
|
+
end
|
27
|
+
end
|
9
28
|
|
10
29
|
if guidance
|
11
30
|
@klass_guidance = guidance["classes"].find do |klass|
|
@@ -15,70 +34,125 @@ module Lutaml
|
|
15
34
|
end
|
16
35
|
|
17
36
|
def xmi_id
|
18
|
-
@model
|
37
|
+
@model.id
|
19
38
|
end
|
20
39
|
|
21
40
|
def name
|
22
|
-
@model
|
41
|
+
@model.name
|
23
42
|
end
|
24
43
|
|
25
44
|
def absolute_path
|
26
|
-
"#{@
|
45
|
+
"#{@options[:absolute_path]}::#{name}"
|
27
46
|
end
|
28
47
|
|
29
48
|
def package
|
30
|
-
::Lutaml::XMI::PackageDrop.new(
|
49
|
+
::Lutaml::XMI::PackageDrop.new(
|
50
|
+
@package,
|
51
|
+
@guidance,
|
52
|
+
@options.merge(
|
53
|
+
{
|
54
|
+
absolute_path: "#{@options[:absolute_path]}::#{name}",
|
55
|
+
},
|
56
|
+
),
|
57
|
+
)
|
31
58
|
end
|
32
59
|
|
33
60
|
def type
|
34
|
-
@model
|
61
|
+
@model.type.split(":").last
|
35
62
|
end
|
36
63
|
|
37
64
|
def attributes
|
38
|
-
@
|
39
|
-
|
40
|
-
|
65
|
+
@owned_attributes.map do |owned_attr|
|
66
|
+
if @options[:with_assoc] || owned_attr.association.nil?
|
67
|
+
::Lutaml::XMI::AttributeDrop.new(owned_attr, @options)
|
68
|
+
end
|
69
|
+
end.compact
|
41
70
|
end
|
42
71
|
|
43
|
-
def associations
|
44
|
-
|
45
|
-
|
46
|
-
|
72
|
+
def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
73
|
+
return if !@matched_element ||
|
74
|
+
!@matched_element.links ||
|
75
|
+
@matched_element.links.association.empty?
|
76
|
+
|
77
|
+
@matched_element.links.association.map do |assoc|
|
78
|
+
link_member = assoc.start == xmi_id ? "end" : "start"
|
79
|
+
link_owner_name = link_member == "start" ? "end" : "start"
|
80
|
+
|
81
|
+
member_end, member_end_type, member_end_cardinality,
|
82
|
+
member_end_attribute_name, member_end_xmi_id =
|
83
|
+
serialize_member_type(xmi_id, assoc, link_member)
|
84
|
+
|
85
|
+
owner_end = serialize_owned_type(xmi_id, assoc, link_owner_name)
|
86
|
+
|
87
|
+
if member_end && ((member_end_type != "aggregation") ||
|
88
|
+
(member_end_type == "aggregation" && member_end_attribute_name))
|
89
|
+
|
90
|
+
doc_node_name = (link_member == "start" ? "source" : "target")
|
91
|
+
definition = fetch_definition_node_value(assoc.id, doc_node_name)
|
92
|
+
|
93
|
+
::Lutaml::XMI::AssociationDrop.new(
|
94
|
+
xmi_id: assoc.id,
|
95
|
+
member_end: member_end,
|
96
|
+
member_end_type: member_end_type,
|
97
|
+
member_end_cardinality: member_end_cardinality,
|
98
|
+
member_end_attribute_name: member_end_attribute_name,
|
99
|
+
member_end_xmi_id: member_end_xmi_id,
|
100
|
+
owner_end: owner_end,
|
101
|
+
owner_end_xmi_id: xmi_id,
|
102
|
+
definition: definition,
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end.compact
|
47
106
|
end
|
48
107
|
|
49
108
|
def operations
|
50
|
-
@model
|
51
|
-
|
52
|
-
|
109
|
+
@model.owned_operation.map do |operation|
|
110
|
+
if operation.association.nil?
|
111
|
+
::Lutaml::XMI::OperationDrop.new(operation)
|
112
|
+
end
|
113
|
+
end.compact
|
53
114
|
end
|
54
115
|
|
55
116
|
def constraints
|
56
|
-
@model
|
117
|
+
connector_node = fetch_connector(@model.id)
|
118
|
+
return unless connector_node
|
119
|
+
|
120
|
+
# In ea-xmi-2.5.1, constraints are moved to source/target under
|
121
|
+
# connectors
|
122
|
+
constraints = %i[source target].map do |st|
|
123
|
+
connector_node.send(st).constraints.constraint
|
124
|
+
end.flatten
|
125
|
+
|
126
|
+
constraints.map do |constraint|
|
57
127
|
::Lutaml::XMI::ConstraintDrop.new(constraint)
|
58
128
|
end
|
59
129
|
end
|
60
130
|
|
61
131
|
def generalization
|
62
|
-
|
132
|
+
if @options[:with_gen] && @model.type?("uml:Class")
|
133
|
+
generalization = serialize_generalization(@model)
|
134
|
+
return {} if generalization.nil?
|
63
135
|
|
64
|
-
|
65
|
-
|
136
|
+
::Lutaml::XMI::GeneralizationDrop.new(
|
137
|
+
generalization, @klass_guidance, @options
|
138
|
+
)
|
139
|
+
end
|
66
140
|
end
|
67
141
|
|
68
142
|
def has_guidance?
|
69
143
|
!!@klass_guidance
|
70
144
|
end
|
71
145
|
|
72
|
-
def is_abstract
|
73
|
-
@model
|
146
|
+
def is_abstract # rubocop:disable Naming/PredicateName
|
147
|
+
doc_node_attribute_value(@model.id, "isAbstract")
|
74
148
|
end
|
75
149
|
|
76
150
|
def definition
|
77
|
-
@model
|
151
|
+
doc_node_attribute_value(@model.id, "documentation")
|
78
152
|
end
|
79
153
|
|
80
154
|
def stereotype
|
81
|
-
@model
|
155
|
+
doc_node_attribute_value(@model.id, "stereotype")
|
82
156
|
end
|
83
157
|
end
|
84
158
|
end
|
@@ -3,24 +3,30 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class OperationDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
7
9
|
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@xmi_cache = options[:xmi_cache]
|
8
13
|
end
|
9
14
|
|
10
15
|
def id
|
11
|
-
@model
|
16
|
+
@model.id
|
12
17
|
end
|
13
18
|
|
14
19
|
def xmi_id
|
15
|
-
@model
|
20
|
+
uml_type = @model.uml_type.first
|
21
|
+
uml_type&.idref
|
16
22
|
end
|
17
23
|
|
18
24
|
def name
|
19
|
-
@model
|
25
|
+
@model.name
|
20
26
|
end
|
21
27
|
|
22
28
|
def definition
|
23
|
-
@model
|
29
|
+
lookup_attribute_documentation(@model.id)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -3,55 +3,98 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class PackageDrop < Liquid::Drop
|
6
|
-
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, guidance = nil, options = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
7
9
|
@model = model
|
8
10
|
@guidance = guidance
|
9
11
|
|
12
|
+
@options = options
|
13
|
+
@xmi_root_model = options[:xmi_root_model]
|
14
|
+
@xmi_cache = options[:xmi_cache]
|
15
|
+
|
16
|
+
@packages = model.packaged_element.select do |e|
|
17
|
+
e.type?("uml:Package")
|
18
|
+
end
|
19
|
+
|
20
|
+
@klasses = model.packaged_element.select do |e|
|
21
|
+
e.type?("uml:Class") || e.type?("uml:AssociationClass") ||
|
22
|
+
e.type?("uml:Interface")
|
23
|
+
end
|
24
|
+
|
25
|
+
@all_data_type_elements = []
|
26
|
+
select_all_packaged_elements(@all_data_type_elements, model,
|
27
|
+
"uml:DataType")
|
28
|
+
|
10
29
|
@children_packages ||= packages.map do |pkg|
|
11
30
|
[pkg, pkg.packages, pkg.packages.map(&:children_packages)]
|
12
31
|
end.flatten.uniq
|
13
32
|
end
|
14
33
|
|
15
34
|
def xmi_id
|
16
|
-
@model
|
35
|
+
@model.id
|
17
36
|
end
|
18
37
|
|
19
38
|
def name
|
20
|
-
@model
|
39
|
+
get_package_name(@model)
|
21
40
|
end
|
22
41
|
|
23
42
|
def absolute_path
|
24
|
-
@
|
43
|
+
"#{@options[:absolute_path]}::#{name}"
|
25
44
|
end
|
26
45
|
|
27
|
-
def klasses
|
28
|
-
@
|
29
|
-
::Lutaml::XMI::KlassDrop.new(
|
46
|
+
def klasses # rubocop:disable Metrics/MethodLength
|
47
|
+
@klasses.map do |klass|
|
48
|
+
::Lutaml::XMI::KlassDrop.new(
|
49
|
+
klass,
|
50
|
+
@guidance,
|
51
|
+
@options.merge(
|
52
|
+
{
|
53
|
+
absolute_path: "#{@options[:absolute_path]}::#{name}",
|
54
|
+
},
|
55
|
+
),
|
56
|
+
)
|
30
57
|
end
|
31
58
|
end
|
32
59
|
alias classes klasses
|
33
60
|
|
34
61
|
def enums
|
35
|
-
@model
|
36
|
-
|
62
|
+
enums = @model.packaged_element.select do |e|
|
63
|
+
e.type?("uml:Enumeration")
|
64
|
+
end
|
65
|
+
|
66
|
+
enums.map do |enum|
|
67
|
+
::Lutaml::XMI::EnumDrop.new(enum, @options)
|
37
68
|
end
|
38
69
|
end
|
39
70
|
|
40
71
|
def data_types
|
41
|
-
@
|
42
|
-
::Lutaml::XMI::DataTypeDrop.new(data_type)
|
72
|
+
@all_data_type_elements.map do |data_type|
|
73
|
+
::Lutaml::XMI::DataTypeDrop.new(data_type, @options)
|
43
74
|
end
|
44
75
|
end
|
45
76
|
|
46
77
|
def diagrams
|
47
|
-
@
|
48
|
-
|
78
|
+
diagrams = @xmi_root_model.extension.diagrams.diagram.select do |d|
|
79
|
+
d.model.package == @model.id
|
80
|
+
end
|
81
|
+
|
82
|
+
diagrams.map do |diagram|
|
83
|
+
::Lutaml::XMI::DiagramDrop.new(diagram, @options)
|
49
84
|
end
|
50
85
|
end
|
51
86
|
|
52
|
-
def packages
|
53
|
-
@
|
54
|
-
::Lutaml::XMI::PackageDrop.new(
|
87
|
+
def packages # rubocop:disable Metrics/MethodLength
|
88
|
+
@packages.map do |package|
|
89
|
+
::Lutaml::XMI::PackageDrop.new(
|
90
|
+
package,
|
91
|
+
@guidance,
|
92
|
+
@options.merge(
|
93
|
+
{
|
94
|
+
absolute_path: "#{@options[:absolute_path]}::#{name}",
|
95
|
+
},
|
96
|
+
),
|
97
|
+
)
|
55
98
|
end
|
56
99
|
end
|
57
100
|
|
@@ -60,11 +103,11 @@ module Lutaml
|
|
60
103
|
end
|
61
104
|
|
62
105
|
def definition
|
63
|
-
@model
|
106
|
+
doc_node_attribute_value(@model.id, "documentation")
|
64
107
|
end
|
65
108
|
|
66
109
|
def stereotype
|
67
|
-
@model
|
110
|
+
doc_node_attribute_value(@model.id, "stereotype")
|
68
111
|
end
|
69
112
|
end
|
70
113
|
end
|