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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +36 -35
  3. data/bin/plantuml2lutaml +11 -7
  4. data/bin/yaml2lutaml +1 -1
  5. data/exe/lutaml-sysml +4 -2
  6. data/exe/lutaml-wsd2uml +11 -7
  7. data/exe/lutaml-yaml2uml +1 -1
  8. data/lib/lutaml/express/parsers/exp.rb +4 -4
  9. data/lib/lutaml/formatter/graphviz.rb +7 -7
  10. data/lib/lutaml/parser.rb +3 -31
  11. data/lib/lutaml/sysml/allocate.rb +6 -7
  12. data/lib/lutaml/sysml/allocated.rb +6 -6
  13. data/lib/lutaml/sysml/binding_connector.rb +6 -6
  14. data/lib/lutaml/sysml/block.rb +28 -25
  15. data/lib/lutaml/sysml/constraint_block.rb +11 -11
  16. data/lib/lutaml/sysml/copy.rb +5 -5
  17. data/lib/lutaml/sysml/derive_requirement.rb +6 -6
  18. data/lib/lutaml/sysml/nested_connector_end.rb +9 -9
  19. data/lib/lutaml/sysml/refine.rb +6 -6
  20. data/lib/lutaml/sysml/requirement_related.rb +6 -6
  21. data/lib/lutaml/sysml/satisfy.rb +6 -6
  22. data/lib/lutaml/sysml/test_case.rb +20 -19
  23. data/lib/lutaml/sysml/trace.rb +6 -6
  24. data/lib/lutaml/sysml/verify.rb +5 -5
  25. data/lib/lutaml/sysml/version.rb +1 -1
  26. data/lib/lutaml/sysml/xmi_file.rb +455 -415
  27. data/lib/lutaml/sysml.rb +1 -1
  28. data/lib/lutaml/uml/association.rb +4 -3
  29. data/lib/lutaml/uml/data_type.rb +1 -0
  30. data/lib/lutaml/uml/document.rb +4 -1
  31. data/lib/lutaml/uml/formatter/graphviz.rb +11 -13
  32. data/lib/lutaml/uml/has_attributes.rb +2 -2
  33. data/lib/lutaml/uml/has_members.rb +4 -3
  34. data/lib/lutaml/uml/node/class_node.rb +5 -7
  35. data/lib/lutaml/uml/node/field.rb +1 -3
  36. data/lib/lutaml/uml/node/method.rb +1 -3
  37. data/lib/lutaml/uml/node/relationship.rb +1 -3
  38. data/lib/lutaml/uml/operation.rb +6 -6
  39. data/lib/lutaml/uml/package.rb +3 -1
  40. data/lib/lutaml/uml/parsers/attribute.rb +1 -3
  41. data/lib/lutaml/uml/parsers/dsl.rb +11 -10
  42. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +7 -6
  43. data/lib/lutaml/uml/parsers/yaml.rb +2 -2
  44. data/lib/lutaml/uml/serializers/class.rb +1 -1
  45. data/lib/lutaml/uml/top_element.rb +9 -9
  46. data/lib/lutaml/uml/top_element_attribute.rb +6 -6
  47. data/lib/lutaml/uml/value.rb +6 -6
  48. data/lib/lutaml/version.rb +1 -1
  49. data/lib/lutaml/xmi/liquid_drops/association_drop.rb +31 -11
  50. data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +29 -11
  51. data/lib/lutaml/xmi/liquid_drops/cardinality_drop.rb +8 -2
  52. data/lib/lutaml/xmi/liquid_drops/constraint_drop.rb +6 -4
  53. data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +76 -18
  54. data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +13 -6
  55. data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +16 -7
  56. data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +10 -4
  57. data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +2 -0
  58. data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +10 -3
  59. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +98 -24
  60. data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +11 -5
  61. data/lib/lutaml/xmi/liquid_drops/package_drop.rb +61 -18
  62. data/lib/lutaml/xmi/liquid_drops/root_drop.rb +14 -4
  63. data/lib/lutaml/xmi/parsers/xmi_base.rb +1031 -0
  64. data/lib/lutaml/xmi/parsers/xml.rb +23 -1018
  65. data/lib/lutaml/xml/parsers/xml.rb +6 -19
  66. data/lib/lutaml/xml.rb +0 -8
  67. data/lutaml.gemspec +2 -1
  68. metadata +32 -23
  69. data/lib/lutaml/express/lutaml_path/document_wrapper.rb +0 -22
  70. data/lib/lutaml/express/lutaml_path/formatter.rb +0 -14
  71. data/lib/lutaml/lutaml_path/document_wrapper.rb +0 -51
  72. data/lib/lutaml/uml/lutaml_path/document_wrapper.rb +0 -15
  73. data/lib/lutaml/xml/lutaml_path/document_wrapper.rb +0 -45
  74. 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[:name]
13
+ HTMLEntities.new.decode(@model.name)
12
14
  end
13
15
 
14
16
  def type
15
- @model[:type]
17
+ @model.type
16
18
  end
17
19
 
18
20
  def weight
19
- @model[:weight]
21
+ @model.weight
20
22
  end
21
23
 
22
24
  def status
23
- @model[:status]
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
- def initialize(model) # rubocop:disable Lint/MissingSuper
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[:xmi_id]
26
+ @model.id
12
27
  end
13
28
 
14
29
  def name
15
- @model[:name]
30
+ @model.name
16
31
  end
17
32
 
18
33
  def attributes
19
- @model[:attributes]&.map do |attribute|
20
- ::Lutaml::XMI::AttributeDrop.new(attribute)
21
- end
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[:operations]&.map do |operation|
26
- ::Lutaml::XMI::OperationDrop.new(operation)
27
- end
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
- @model[:associations]&.map do |association|
32
- ::Lutaml::XMI::AssociationDrop.new(association)
33
- end
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[:constraints]&.map do |constraint|
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[:is_abstract]
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[:definition]
105
+ doc_node_attribute_value(@model.id, "documentation")
48
106
  end
49
107
 
50
108
  def stereotype
51
- @model[:stereotype]
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
- def initialize(model) # rubocop:disable Lint/MissingSuper
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[:xmi_id]
16
+ @model.id
12
17
  end
13
18
 
14
19
  def name
15
- @model[:name]
20
+ @model.properties.name
16
21
  end
17
22
 
18
23
  def definition
19
- @model[:definition]
24
+ @model.properties.documentation
20
25
  end
21
26
 
22
27
  def package_id
23
- @model[:package_id]
28
+ @model.model.package if @options[:with_gen]
24
29
  end
25
30
 
26
31
  def package_name
27
- @model[:package_name]
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
- def initialize(model) # rubocop:disable Lint/MissingSuper
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[:xmi_id]
20
+ @model.id
12
21
  end
13
22
 
14
23
  def name
15
- @model[:name]
24
+ @model.name
16
25
  end
17
26
 
18
27
  def values
19
- @model[:values].map do |value|
20
- ::Lutaml::XMI::EnumOwnedLiteralDrop.new(value)
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[:definition]
34
+ doc_node_attribute_value(@model.id, "documentation")
26
35
  end
27
36
 
28
37
  def stereotype
29
- @model[:stereotype]
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
- def initialize(model) # rubocop:disable Lint/MissingSuper
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[:name]
16
+ @model.name
12
17
  end
13
18
 
14
19
  def type
15
- @model[:type]
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[:definition]
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
- def initialize(gen, guidance = nil) # rubocop:disable Lint/MissingSuper
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
- GeneralizationDrop.new(@gen[:general], @guidance) if @gen[:general]
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
- def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
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[:xmi_id]
37
+ @model.id
19
38
  end
20
39
 
21
40
  def name
22
- @model[:name]
41
+ @model.name
23
42
  end
24
43
 
25
44
  def absolute_path
26
- "#{@model[:absolute_path]}::#{name}"
45
+ "#{@options[:absolute_path]}::#{name}"
27
46
  end
28
47
 
29
48
  def package
30
- ::Lutaml::XMI::PackageDrop.new(@model[:package], @guidance)
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[:type]
61
+ @model.type.split(":").last
35
62
  end
36
63
 
37
64
  def attributes
38
- @model[:attributes]&.map do |attribute|
39
- ::Lutaml::XMI::AttributeDrop.new(attribute)
40
- end
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
- @model[:associations]&.map do |association|
45
- ::Lutaml::XMI::AssociationDrop.new(association)
46
- end
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[:operations]&.map do |operation|
51
- ::Lutaml::XMI::OperationDrop.new(operation)
52
- end
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[:constraints]&.map do |constraint|
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
- return {} if @model[:generalization].nil?
132
+ if @options[:with_gen] && @model.type?("uml:Class")
133
+ generalization = serialize_generalization(@model)
134
+ return {} if generalization.nil?
63
135
 
64
- ::Lutaml::XMI::GeneralizationDrop.new(@model[:generalization],
65
- @klass_guidance)
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[:is_abstract]
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[:definition]
151
+ doc_node_attribute_value(@model.id, "documentation")
78
152
  end
79
153
 
80
154
  def stereotype
81
- @model[:stereotype]
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
- def initialize(model) # rubocop:disable Lint/MissingSuper
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[:id]
16
+ @model.id
12
17
  end
13
18
 
14
19
  def xmi_id
15
- @model[:xmi_id]
20
+ uml_type = @model.uml_type.first
21
+ uml_type&.idref
16
22
  end
17
23
 
18
24
  def name
19
- @model[:name]
25
+ @model.name
20
26
  end
21
27
 
22
28
  def definition
23
- @model[:definition]
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
- def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
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[:xmi_id]
35
+ @model.id
17
36
  end
18
37
 
19
38
  def name
20
- @model[:name]
39
+ get_package_name(@model)
21
40
  end
22
41
 
23
42
  def absolute_path
24
- @model[:absolute_path]
43
+ "#{@options[:absolute_path]}::#{name}"
25
44
  end
26
45
 
27
- def klasses
28
- @model[:classes].map do |klass|
29
- ::Lutaml::XMI::KlassDrop.new(klass, @guidance)
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[:enums].map do |enum|
36
- ::Lutaml::XMI::EnumDrop.new(enum)
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
- @model[:data_types].map do |data_type|
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
- @model[:diagrams].map do |diagram|
48
- ::Lutaml::XMI::DiagramDrop.new(diagram)
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
- @model[:packages].map do |package|
54
- ::Lutaml::XMI::PackageDrop.new(package, @guidance)
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[:definition]
106
+ doc_node_attribute_value(@model.id, "documentation")
64
107
  end
65
108
 
66
109
  def stereotype
67
- @model[:stereotype]
110
+ doc_node_attribute_value(@model.id, "stereotype")
68
111
  end
69
112
  end
70
113
  end