lutaml 0.9.32 → 0.9.34

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -0
  3. data/bin/plantuml2lutaml +1 -1
  4. data/bin/yaml2lutaml +6 -4
  5. data/exe/lutaml-wsd2uml +1 -1
  6. data/exe/lutaml-yaml2uml +6 -4
  7. data/lib/lutaml/command_line.rb +3 -3
  8. data/lib/lutaml/formatter/base.rb +3 -3
  9. data/lib/lutaml/formatter/graphviz.rb +10 -10
  10. data/lib/lutaml/sysml/block.rb +1 -1
  11. data/lib/lutaml/sysml/constraint_block.rb +1 -1
  12. data/lib/lutaml/sysml/nested_connector_end.rb +1 -1
  13. data/lib/lutaml/sysml/requirement.rb +41 -33
  14. data/lib/lutaml/sysml/xmi_file.rb +382 -355
  15. data/lib/lutaml/uml/actor.rb +1 -1
  16. data/lib/lutaml/uml/association.rb +5 -5
  17. data/lib/lutaml/uml/connector.rb +1 -1
  18. data/lib/lutaml/uml/constructor_end.rb +1 -1
  19. data/lib/lutaml/uml/dependency.rb +1 -1
  20. data/lib/lutaml/uml/document.rb +0 -1
  21. data/lib/lutaml/uml/formatter/base.rb +2 -2
  22. data/lib/lutaml/uml/formatter/graphviz.rb +10 -10
  23. data/lib/lutaml/uml/has_members.rb +4 -4
  24. data/lib/lutaml/uml/instance.rb +1 -1
  25. data/lib/lutaml/uml/model.rb +1 -1
  26. data/lib/lutaml/uml/node/class_node.rb +1 -1
  27. data/lib/lutaml/uml/operation.rb +2 -2
  28. data/lib/lutaml/uml/package.rb +2 -2
  29. data/lib/lutaml/uml/parsers/dsl.rb +7 -4
  30. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +6 -3
  31. data/lib/lutaml/uml/property.rb +4 -4
  32. data/lib/lutaml/uml/top_element.rb +2 -2
  33. data/lib/lutaml/uml/top_element_attribute.rb +1 -1
  34. data/lib/lutaml/uml/value.rb +2 -2
  35. data/lib/lutaml/version.rb +1 -1
  36. data/lib/lutaml/xmi/liquid_drops/association_drop.rb +11 -2
  37. data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +2 -2
  38. data/lib/lutaml/xmi/liquid_drops/connector_drop.rb +40 -0
  39. data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +3 -2
  40. data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +1 -1
  41. data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
  42. data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +1 -1
  43. data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +1 -1
  44. data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +1 -1
  45. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +3 -2
  46. data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +1 -1
  47. data/lib/lutaml/xmi/liquid_drops/package_drop.rb +1 -1
  48. data/lib/lutaml/xmi/liquid_drops/root_drop.rb +1 -1
  49. data/lib/lutaml/xmi/liquid_drops/source_target_drop.rb +36 -0
  50. data/lib/lutaml/xmi/parsers/xmi_base.rb +41 -19
  51. data/lib/lutaml/xmi/parsers/xml.rb +24 -29
  52. data/lib/lutaml/xmi.rb +0 -1
  53. data/lutaml.gemspec +2 -10
  54. metadata +6 -103
  55. data/lib/lutaml/xmi/version.rb +0 -5
@@ -1,332 +1,352 @@
1
- module Lutaml::SysMl
2
- class XmiFile
3
- attr_accessor :package_list, :model_list, :class_list, :activity_list, :property_list, :port_list, :datatype_list, :instance_list,
4
- :realization_list, :abstraction_list, :association_list, :connector_list, :connectorend_list, :constraint_list, :block_list, :constraintblock_list,
5
- :requirement_list, :testcase_list, :binding_connector_list, :nested_connectorend_list, :derive_requirement_list,
6
- :refine_requirement_list, :trace_requirement_list, :copy_requirement_list, :verify_requirement_list, :satisfy_requirement_list,
7
- :allocate_requirement_list, :element_hash
8
-
9
- def initialize
10
- @package_list = []
11
- @model_list = []
12
- @class_list = []
13
- @activity_list = []
14
- @property_list = []
15
- @port_list = []
16
- @datatype_list = []
17
- @instance_list = []
18
- @realization_list = []
19
- @abstraction_list = []
20
- @association_list = []
21
- @connector_list = []
22
- @connectorend_list = []
23
- @constraint_list = []
24
-
25
- @block_list = []
26
- @constraintblock_list = []
27
- @requirement_list = []
28
- @testcase_list = []
29
- @binding_connector_list = []
30
- @nested_connectorend_list = []
31
- @derive_requirement_list = []
32
- @refine_requirement_list = []
33
- @trace_requirement_list = []
34
- @copy_requirement_list = []
35
- @verify_requirement_list = []
36
- @satisfy_requirement_list = []
37
- @allocate_requirement_list = []
38
-
39
- @element_hash = Hash.new
40
- end
1
+ module Lutaml
2
+ module SysMl
3
+ class XmiFile
4
+ attr_accessor :package_list, :model_list, :class_list, :activity_list,
5
+ :property_list, :port_list,
6
+ :datatype_list, :instance_list,
7
+ :realization_list, :abstraction_list,
8
+ :association_list, :connector_list,
9
+ :connectorend_list, :constraint_list, :block_list,
10
+ :constraintblock_list, :requirement_list,
11
+ :testcase_list, :binding_connector_list,
12
+ :nested_connectorend_list, :derive_requirement_list,
13
+ :refine_requirement_list, :trace_requirement_list,
14
+ :copy_requirement_list, :verify_requirement_list,
15
+ :satisfy_requirement_list,
16
+ :allocate_requirement_list, :element_hash
17
+
18
+ def initialize # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
19
+ @package_list = []
20
+ @model_list = []
21
+ @class_list = []
22
+ @activity_list = []
23
+ @property_list = []
24
+ @port_list = []
25
+ @datatype_list = []
26
+ @instance_list = []
27
+ @realization_list = []
28
+ @abstraction_list = []
29
+ @association_list = []
30
+ @connector_list = []
31
+ @connectorend_list = []
32
+ @constraint_list = []
33
+ @block_list = []
34
+ @constraintblock_list = []
35
+ @requirement_list = []
36
+ @testcase_list = []
37
+ @binding_connector_list = []
38
+ @nested_connectorend_list = []
39
+ @derive_requirement_list = []
40
+ @refine_requirement_list = []
41
+ @trace_requirement_list = []
42
+ @copy_requirement_list = []
43
+ @verify_requirement_list = []
44
+ @satisfy_requirement_list = []
45
+ @allocate_requirement_list = []
46
+
47
+ @element_hash = Hash.new
48
+ end
41
49
 
42
- def parse(filename)
43
- xmifile = File.new(filename, "r")
44
- inxml = Nokogiri::XML(xmifile)
50
+ def parse(filename) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
51
+ xmifile = File.new(filename, "r")
52
+ inxml = Nokogiri::XML(xmifile)
45
53
 
46
- xmi_elements = inxml.xpath("//xmi:XMI")
47
- if xmi_elements.size == 0
48
- puts "ERROR : File contains no 'xmi:XMI' XML elements : #{filename}, may not be XMI file."
49
- xmifile.close
50
- exit
51
- end
54
+ xmi_elements = inxml.xpath("//xmi:XMI")
55
+ if xmi_elements.empty?
56
+ puts "ERROR : File contains no 'xmi:XMI' XML elements : " \
57
+ "#{filename}, may not be XMI file."
58
+ xmifile.close
59
+ exit
60
+ end
52
61
 
53
- # setup xmi namespace
54
- xmiNS = inxml.root.namespace_definitions.find { |ns| ns.prefix == "xmi" }
62
+ # setup xmi namespace
63
+ xmi_ns = inxml.root.namespace_definitions.find do |ns|
64
+ ns.prefix == "xmi"
65
+ end
55
66
 
56
- ## Step 1: Find UML and SysML Core Objects in XMI file and create as instance of metamodel
67
+ ## Step 1: Find UML and SysML Core Objects in XMI file and create as
68
+ # instance of metamodel
57
69
 
58
- for xml_node in inxml.xpath("//*")
59
- element_new = nil
70
+ inxml.xpath("//*").each do |xml_node| # rubocop:disable Metrics/BlockLength
71
+ element_new = nil
60
72
 
61
- if xml_node.name.to_s == "packagedElement" and xml_node.attribute_with_ns(
62
- "type", xmiNS.href
63
- ).to_s == "uml:Package"
64
- element_new = Lutaml::Uml::Package.new
65
- package_list.push element_new
66
- end
73
+ if xml_node.name.to_s == "packagedElement" &&
74
+ xml_node.attribute_with_ns("type", xmi_ns.href)
75
+ .to_s == "uml:Package"
76
+ element_new = Lutaml::Uml::Package.new
77
+ package_list.push element_new
78
+ end
67
79
 
68
- if xml_node.name.to_s == "Model"
69
- element_new = Lutaml::Uml::Model.new
70
- model_list.push element_new
71
- element_new.viewpoint = xml_node["viewpoint"]
72
- element_new.href = xml_node["href"]
73
- end
80
+ if xml_node.name.to_s == "Model"
81
+ element_new = Lutaml::Uml::Model.new
82
+ model_list.push element_new
83
+ element_new.viewpoint = xml_node["viewpoint"]
84
+ element_new.href = xml_node["href"]
85
+ end
74
86
 
75
- if xml_node.attribute_with_ns("type", xmiNS.href).to_s == "uml:Class"
76
- element_new = Lutaml::Uml::Class.new
77
- if !xml_node["isAbstract"].nil?
78
- element_new.is_abstract = xml_node["isAbstract"] == "true"
87
+ if xml_node.attribute_with_ns("type", xmi_ns.href).to_s == "uml:Class"
88
+ element_new = Lutaml::Uml::Class.new
89
+ if !xml_node["isAbstract"].nil?
90
+ element_new.is_abstract = xml_node["isAbstract"] == "true"
91
+ end
92
+ class_list.push element_new
79
93
  end
80
- class_list.push element_new
81
- end
82
94
 
83
- if xml_node.attribute_with_ns("type",
84
- xmiNS.href).to_s == "uml:Activity"
85
- element_new = Lutaml::Uml::Activity.new
86
- activity_list.push element_new
87
- end
95
+ if xml_node.attribute_with_ns("type",
96
+ xmi_ns.href).to_s == "uml:Activity"
97
+ element_new = Lutaml::Uml::Activity.new
98
+ activity_list.push element_new
99
+ end
88
100
 
89
- if xml_node.attribute_with_ns("type",
90
- xmiNS.href).to_s == "uml:Property"
91
- element_new = Lutaml::Uml::Property.new
92
- property_list.push element_new
93
- end
101
+ if xml_node.attribute_with_ns("type",
102
+ xmi_ns.href).to_s == "uml:Property"
103
+ element_new = Lutaml::Uml::Property.new
104
+ property_list.push element_new
105
+ end
94
106
 
95
- if xml_node.attribute_with_ns("type",
96
- xmiNS.href).to_s == "uml:InstanceSpecification"
97
- element_new = Lutaml::Uml::Instance.new
98
- instance_list.push element_new
99
- end
107
+ if xml_node
108
+ .attribute_with_ns("type", xmi_ns.href)
109
+ .to_s == "uml:InstanceSpecification"
110
+ element_new = Lutaml::Uml::Instance.new
111
+ instance_list.push element_new
112
+ end
100
113
 
101
- if xml_node.attribute_with_ns("type",
102
- xmiNS.href).to_s == "uml:DataType"
103
- element_new = Lutaml::Uml::DataType.new
104
- datatype_list.push element_new
105
- end
114
+ if xml_node.attribute_with_ns("type",
115
+ xmi_ns.href).to_s == "uml:DataType"
116
+ element_new = Lutaml::Uml::DataType.new
117
+ datatype_list.push element_new
118
+ end
106
119
 
107
- if xml_node.attribute_with_ns("type", xmiNS.href).to_s == "uml:Port"
108
- element_new = Lutaml::Uml::Port.new
109
- port_list.push element_new
110
- end
120
+ if xml_node.attribute_with_ns("type", xmi_ns.href).to_s == "uml:Port"
121
+ element_new = Lutaml::Uml::Port.new
122
+ port_list.push element_new
123
+ end
111
124
 
112
- if xml_node.attribute_with_ns("type",
113
- xmiNS.href).to_s == "uml:Connector"
114
- element_new = Lutaml::Uml::Connector.new
115
- connector_list.push element_new
116
- end
125
+ if xml_node.attribute_with_ns("type",
126
+ xmi_ns.href).to_s == "uml:Connector"
127
+ element_new = Lutaml::Uml::Connector.new
128
+ connector_list.push element_new
129
+ end
117
130
 
118
- if xml_node.attribute_with_ns("type",
119
- xmiNS.href).to_s == "uml:ConnectorEnd"
120
- element_new = Lutaml::Uml::ConnectorEnd.new
121
- connectorend_list.push element_new
122
- end
131
+ if xml_node.attribute_with_ns("type",
132
+ xmi_ns.href).to_s == "uml:ConnectorEnd"
133
+ element_new = Lutaml::Uml::ConnectorEnd.new
134
+ connectorend_list.push element_new
135
+ end
123
136
 
124
- if xml_node.attribute_with_ns("type",
125
- xmiNS.href).to_s == "uml:Constraint"
126
- element_new = Lutaml::Uml::Constraint.new
127
- constraint_list.push element_new
128
- end
137
+ if xml_node.attribute_with_ns("type",
138
+ xmi_ns.href).to_s == "uml:Constraint"
139
+ element_new = Lutaml::Uml::Constraint.new
140
+ constraint_list.push element_new
141
+ end
129
142
 
130
- if xml_node.name.to_s == "Block"
131
- element_new = SYSML::Block.new
132
- block_list.push element_new
133
- end
143
+ if xml_node.name.to_s == "Block"
144
+ element_new = SYSML::Block.new
145
+ block_list.push element_new
146
+ end
134
147
 
135
- if xml_node.name.to_s == "Template"
136
- element_new = SYSML::Block.new
137
- block_list.push element_new
138
- end
148
+ if xml_node.name.to_s == "Template"
149
+ element_new = SYSML::Block.new
150
+ block_list.push element_new
151
+ end
139
152
 
140
- if xml_node.name.to_s == "ConstraintBlock"
141
- element_new = SYSML::ConstraintBlock.new
142
- constraintblock_list.push element_new
143
- end
153
+ if xml_node.name.to_s == "ConstraintBlock"
154
+ element_new = SYSML::ConstraintBlock.new
155
+ constraintblock_list.push element_new
156
+ end
144
157
 
145
- if (xml_node.name.to_s.index("Requirement") or xml_node.name.to_s == "designConstraint") && xml_node.name.to_s !=("RequirementRelated")
158
+ if (
159
+ xml_node.name.to_s.index("Requirement") ||
160
+ xml_node.name.to_s == "designConstraint"
161
+ ) && xml_node.name.to_s != "RequirementRelated"
146
162
  element_new = SYSML::Requirement.new
147
163
  requirement_list.push element_new
148
164
  element_new.id = xml_node.attribute_with_ns("id",
149
- xmiNS.href).to_s.strip
165
+ xmi_ns.href).to_s.strip
150
166
  element_new.text = xml_node["Text"]
151
167
  if xml_node.name != "Requirement"
152
168
  element_new.stereotype.push xml_node.name
153
169
  end
154
170
  end
155
171
 
156
- if xml_node.name.to_s == "TestCase"
157
- element_new = SYSML::TestCase.new
158
- testcase_list.push element_new
159
- end
160
-
161
- if xml_node.name.to_s == "BindingConnector"
162
- element_new = SYSML::BindingConnector.new
163
- binding_connector_list.push element_new
164
- end
165
-
166
- if xml_node.name.to_s == "NestedConnectorEnd"
167
- element_new = SYSML::NestedConnectorEnd.new
168
- nested_connectorend_list.push element_new
169
- end
170
-
171
- if xml_node.name.to_s == "DeriveReqt"
172
- element_new = SYSML::DeriveRequirement.new
173
- derive_requirement_list.push element_new
174
- end
175
- if xml_node.name.to_s == "refine"
176
- element_new = SYSML::Refine.new
177
- refine_requirement_list.push element_new
178
- end
179
- if xml_node.name.to_s == "trace"
180
- element_new = SYSML::Trace.new
181
- trace_requirement_list.push element_new
182
- end
183
- if xml_node.name.to_s == "Copy"
184
- element_new = SYSML::Copy.new
185
- copy_requirement_list.push element_new
186
- end
187
- if xml_node.name.to_s == "Verify"
188
- element_new = SYSML::Verify.new
189
- verify_requirement_list.push element_new
190
- end
191
- if xml_node.name.to_s == "Allocate"
192
- element_new = SYSML::Allocate.new
193
- allocate_requirement_list.push element_new
194
- end
195
-
196
- if xml_node.name.to_s == "Satisfy"
197
- element_new = SYSML::Satisfy.new
198
- satisfy_requirement_list.push element_new
199
- end
172
+ if xml_node.name.to_s == "TestCase"
173
+ element_new = SYSML::TestCase.new
174
+ testcase_list.push element_new
175
+ end
200
176
 
201
- if xml_node.attribute_with_ns("type",
202
- xmiNS.href).to_s == "uml:Abstraction"
203
- element_new = Lutaml::Uml::Abstraction.new
204
- abstraction_list.push element_new
205
- end
177
+ if xml_node.name.to_s == "BindingConnector"
178
+ element_new = SYSML::BindingConnector.new
179
+ binding_connector_list.push element_new
180
+ end
206
181
 
207
- if xml_node.attribute_with_ns("type",
208
- xmiNS.href).to_s == "uml:Realization"
209
- element_new = Lutaml::Uml::Realization.new
210
- realization_list.push element_new
211
- end
182
+ if xml_node.name.to_s == "NestedConnectorEnd"
183
+ element_new = SYSML::NestedConnectorEnd.new
184
+ nested_connectorend_list.push element_new
185
+ end
212
186
 
213
- if xml_node.attribute_with_ns("type",
214
- xmiNS.href).to_s == "uml:Association"
215
- element_new = Lutaml::Uml::Association.new
216
- association_list.push element_new
217
- end
187
+ if xml_node.name.to_s == "DeriveReqt"
188
+ element_new = SYSML::DeriveRequirement.new
189
+ derive_requirement_list.push element_new
190
+ end
191
+ if xml_node.name.to_s == "refine"
192
+ element_new = SYSML::Refine.new
193
+ refine_requirement_list.push element_new
194
+ end
195
+ if xml_node.name.to_s == "trace"
196
+ element_new = SYSML::Trace.new
197
+ trace_requirement_list.push element_new
198
+ end
199
+ if xml_node.name.to_s == "Copy"
200
+ element_new = SYSML::Copy.new
201
+ copy_requirement_list.push element_new
202
+ end
203
+ if xml_node.name.to_s == "Verify"
204
+ element_new = SYSML::Verify.new
205
+ verify_requirement_list.push element_new
206
+ end
207
+ if xml_node.name.to_s == "Allocate"
208
+ element_new = SYSML::Allocate.new
209
+ allocate_requirement_list.push element_new
210
+ end
218
211
 
219
- if !element_new.nil?
220
- new_xmi_id_node = xml_node.attribute_with_ns("id", xmiNS.href)
221
- new_xmi_uuid_node = xml_node.attribute_with_ns("uuid", xmiNS.href)
222
- new_name_node = xml_node["name"]
223
- new_href_node = xml_node["href"]
212
+ if xml_node.name.to_s == "Satisfy"
213
+ element_new = SYSML::Satisfy.new
214
+ satisfy_requirement_list.push element_new
215
+ end
224
216
 
225
- if !new_xmi_id_node.nil?
226
- element_new.xmi_id = new_xmi_id_node.to_s
227
- element_hash[element_new.xmi_id] = element_new
217
+ if xml_node.attribute_with_ns("type",
218
+ xmi_ns.href).to_s == "uml:Abstraction"
219
+ element_new = Lutaml::Uml::Abstraction.new
220
+ abstraction_list.push element_new
228
221
  end
229
222
 
230
- if !new_xmi_uuid_node.nil?
231
- element_new.xmi_uuid = new_xmi_uuid_node.to_s
223
+ if xml_node.attribute_with_ns("type",
224
+ xmi_ns.href).to_s == "uml:Realization"
225
+ element_new = Lutaml::Uml::Realization.new
226
+ realization_list.push element_new
232
227
  end
233
228
 
234
- if !new_name_node.nil?
235
- element_new.name = xml_node["name"].strip
229
+ if xml_node.attribute_with_ns("type",
230
+ xmi_ns.href).to_s == "uml:Association"
231
+ element_new = Lutaml::Uml::Association.new
232
+ association_list.push element_new
236
233
  end
237
234
 
238
- if !new_href_node.nil?
239
- element_new.href = new_href_node.to_s
240
- if new_xmi_id_node == nil
241
- element_hash[element_new.href] = element_new
235
+ if !element_new.nil?
236
+ new_xmi_id_node = xml_node.attribute_with_ns("id", xmi_ns.href)
237
+ new_xmi_uuid_node = xml_node.attribute_with_ns("uuid", xmi_ns.href)
238
+ new_name_node = xml_node["name"]
239
+ new_href_node = xml_node["href"]
240
+
241
+ if !new_xmi_id_node.nil?
242
+ element_new.xmi_id = new_xmi_id_node.to_s
243
+ element_hash[element_new.xmi_id] = element_new
242
244
  end
243
- if !xml_node.at("xmi:Extension/referenceExtension").nil?
244
- element_new.name = xml_node.at("xmi:Extension/referenceExtension")["referentPath"]
245
+
246
+ if !new_xmi_uuid_node.nil?
247
+ element_new.xmi_uuid = new_xmi_uuid_node.to_s
245
248
  end
246
- end
247
249
 
248
- if !xml_node.parent.nil? and
249
- xml_node.parent.attribute_with_ns("id", xmiNS.href) != nil and
250
- element_hash[xml_node.parent.attribute_with_ns("id",
251
- xmiNS.href).to_s] != nil
250
+ if !new_name_node.nil?
251
+ element_new.name = xml_node["name"].strip
252
+ end
253
+
254
+ if !new_href_node.nil?
255
+ element_new.href = new_href_node.to_s
256
+ if new_xmi_id_node == nil
257
+ element_hash[element_new.href] = element_new
258
+ end
259
+ if !xml_node.at("xmi:Extension/referenceExtension").nil?
260
+ element_new.name = xml_node
261
+ .at("xmi:Extension/referenceExtension")["referentPath"]
262
+ end
263
+ end
252
264
 
253
- parent = element_hash[xml_node.parent.attribute_with_ns("id",
254
- xmiNS.href).to_s]
255
- element_new.namespace = parent
256
- if parent.is_a? Lutaml::Uml::Package
257
- parent.contents.push element_new
265
+ if !xml_node.parent.nil? &&
266
+ !xml_node.parent.attribute_with_ns("id", xmi_ns.href).nil? &&
267
+ !element_hash[xml_node
268
+ .parent.attribute_with_ns("id", xmi_ns.href).to_s].nil?
269
+
270
+ parent = element_hash[xml_node
271
+ .parent.attribute_with_ns("id", xmi_ns.href).to_s]
272
+ element_new.namespace = parent
273
+ if parent.is_a? Lutaml::Uml::Package
274
+ parent.contents.push element_new
275
+ end
258
276
  end
259
277
  end
260
278
  end
261
- end
262
-
263
- for xml_node in inxml.xpath("//*")
264
279
 
265
- if xml_node.attribute_with_ns("id", xmiNS.href) != nil and
266
- element_hash[xml_node.attribute_with_ns("id",
267
- xmiNS.href).to_s] != nil
280
+ inxml.xpath("//*").each do |xml_node| # rubocop:disable Metrics/BlockLength,Style/CombinableLoops
281
+ if !xml_node.attribute_with_ns("id", xmi_ns.href).nil? &&
282
+ !element_hash[xml_node
283
+ .attribute_with_ns("id", xmi_ns.href).to_s].nil?
268
284
 
269
- this_thing = element_hash[xml_node.attribute_with_ns("id",
270
- xmiNS.href).to_s]
271
- end
285
+ this_thing = element_hash[xml_node
286
+ .attribute_with_ns("id", xmi_ns.href).to_s]
287
+ end
272
288
 
273
- if xml_node.name.to_s == "nestedClassifier" and xml_node.attribute_with_ns(
274
- "type", xmiNS.href
275
- ).to_s == "uml:Class"
276
- owning_class_xmi_id = xml_node.parent.attribute_with_ns("id",
277
- xmiNS.href).to_s
278
- owned_class_xmi_id = xml_node.attribute_with_ns("id",
279
- xmiNS.href).to_s
280
- owning_class = element_hash[owning_class_xmi_id]
281
- owned_class = element_hash[owned_class_xmi_id]
282
- owning_class.nested_classifier.push owned_class
283
- end
289
+ if xml_node.name.to_s == "nestedClassifier" &&
290
+ xml_node.attribute_with_ns(
291
+ "type", xmi_ns.href
292
+ ).to_s == "uml:Class"
293
+ owning_class_xmi_id = xml_node
294
+ .parent.attribute_with_ns("id", xmi_ns.href).to_s
295
+ owned_class_xmi_id = xml_node
296
+ .attribute_with_ns("id", xmi_ns.href).to_s
297
+ owning_class = element_hash[owning_class_xmi_id]
298
+ owned_class = element_hash[owned_class_xmi_id]
299
+ owning_class.nested_classifier.push owned_class
300
+ end
284
301
 
285
- if xml_node.attribute_with_ns("type",
286
- xmiNS.href).to_s == "uml:Realization"
287
- this_thing = element_hash[xml_node.attribute_with_ns("id",
288
- xmiNS.href).to_s]
289
- supplier_xmi_id = xml_node.at("supplier")["idref"]
290
- client_xmi_id = xml_node.at("client")["idref"]
291
- this_thing.supplier.push element_hash[supplier_xmi_id]
292
- this_thing.client.push element_hash[client_xmi_id]
293
- end
302
+ if xml_node.attribute_with_ns("type", xmi_ns.href)
303
+ .to_s == "uml:Realization"
304
+ this_thing = element_hash[xml_node
305
+ .attribute_with_ns("id", xmi_ns.href).to_s]
306
+ supplier_xmi_id = xml_node.at("supplier")["idref"]
307
+ client_xmi_id = xml_node.at("client")["idref"]
308
+ this_thing.supplier.push element_hash[supplier_xmi_id]
309
+ this_thing.client.push element_hash[client_xmi_id]
310
+ end
294
311
 
295
- if xml_node.attribute_with_ns("type",
296
- xmiNS.href).to_s == "uml:Abstraction"
297
- this_thing = element_hash[xml_node.attribute_with_ns("id",
298
- xmiNS.href).to_s]
299
- supplier_xmi_id = xml_node.at("supplier")["idref"]
300
- client_xmi_id = xml_node.at("client")["idref"]
301
- this_thing.supplier.push element_hash[supplier_xmi_id]
302
- this_thing.client.push element_hash[client_xmi_id]
303
- end
312
+ if xml_node.attribute_with_ns("type",
313
+ xmi_ns.href).to_s == "uml:Abstraction"
314
+ this_thing = element_hash[xml_node
315
+ .attribute_with_ns("id", xmi_ns.href).to_s]
316
+ supplier_xmi_id = xml_node.at("supplier")["idref"]
317
+ client_xmi_id = xml_node.at("client")["idref"]
318
+ this_thing.supplier.push element_hash[supplier_xmi_id]
319
+ this_thing.client.push element_hash[client_xmi_id]
320
+ end
304
321
 
305
- if xml_node.name.to_s == "Block"
306
- this_thing = element_hash[xml_node.attribute_with_ns("id",
307
- xmiNS.href).to_s]
308
- base_class_xmi_id = xml_node["base_Class"]
309
- this_thing.base_class = element_hash[base_class_xmi_id]
310
- end
322
+ if xml_node.name.to_s == "Block"
323
+ this_thing = element_hash[xml_node
324
+ .attribute_with_ns("id", xmi_ns.href).to_s]
325
+ base_class_xmi_id = xml_node["base_Class"]
326
+ this_thing.base_class = element_hash[base_class_xmi_id]
327
+ end
311
328
 
312
- if xml_node.name.to_s == "Template"
313
- this_thing = element_hash[xml_node.attribute_with_ns("id",
314
- xmiNS.href).to_s]
315
- base_class_xmi_id = xml_node["base_Class"]
316
- this_thing.base_class = element_hash[base_class_xmi_id]
317
- this_thing.base_class.stereotype.push "Template"
318
- end
329
+ if xml_node.name.to_s == "Template"
330
+ this_thing = element_hash[xml_node
331
+ .attribute_with_ns("id", xmi_ns.href).to_s]
332
+ base_class_xmi_id = xml_node["base_Class"]
333
+ this_thing.base_class = element_hash[base_class_xmi_id]
334
+ this_thing.base_class.stereotype.push "Template"
335
+ end
319
336
 
320
- if xml_node.name.to_s == "ConstraintBlock"
321
- this_thing = element_hash[xml_node.attribute_with_ns("id",
322
- xmiNS.href).to_s]
323
- base_class_xmi_id = xml_node["base_Class"]
324
- this_thing.base_class = element_hash[base_class_xmi_id]
325
- end
337
+ if xml_node.name.to_s == "ConstraintBlock"
338
+ this_thing = element_hash[xml_node
339
+ .attribute_with_ns("id", xmi_ns.href).to_s]
340
+ base_class_xmi_id = xml_node["base_Class"]
341
+ this_thing.base_class = element_hash[base_class_xmi_id]
342
+ end
326
343
 
327
- if (xml_node.name.to_s.index("Requirement") or xml_node.name.to_s == "designConstraint") && xml_node.name.to_s !=("RequirementRelated")
328
- this_thing = element_hash[xml_node.attribute_with_ns("id",
329
- xmiNS.href).to_s]
344
+ if (
345
+ xml_node.name.to_s.index("Requirement") ||
346
+ (xml_node.name.to_s == "designConstraint")
347
+ ) && xml_node.name.to_s != "RequirementRelated"
348
+ this_thing = element_hash[xml_node
349
+ .attribute_with_ns("id", xmi_ns.href).to_s]
330
350
  base_class_xmi_id = xml_node["base_Class"]
331
351
  this_thing.base_class = element_hash[base_class_xmi_id]
332
352
  this_thing.refined_by = element_hash[xml_node["RefinedBy"]]
@@ -334,76 +354,81 @@ module Lutaml::SysMl
334
354
  this_thing.traced_to = element_hash[xml_node["TracedTo"]]
335
355
  end
336
356
 
337
- if xml_node.name.to_s == "TestCase"
338
- this_thing = element_hash[xml_node.attribute_with_ns("id",
339
- xmiNS.href).to_s]
340
- this_thing.base_behavior = element_hash[xml_node["base_Behavior"]]
341
- this_thing.verifies = element_hash[xml_node["Verifies"]]
342
- end
357
+ if xml_node.name.to_s == "TestCase"
358
+ this_thing = element_hash[xml_node
359
+ .attribute_with_ns("id", xmi_ns.href).to_s]
360
+ this_thing.base_behavior = element_hash[xml_node["base_Behavior"]]
361
+ this_thing.verifies = element_hash[xml_node["Verifies"]]
362
+ end
343
363
 
344
- if xml_node.name.to_s == "BindingConnector"
345
- this_thing = element_hash[xml_node.attribute_with_ns("id",
346
- xmiNS.href).to_s]
347
- base_connector_xmi_id = xml_node["base_Connector"]
348
- this_thing.base_connector = element_hash[base_connector_xmi_id]
349
- end
364
+ if xml_node.name.to_s == "BindingConnector"
365
+ this_thing = element_hash[xml_node
366
+ .attribute_with_ns("id", xmi_ns.href).to_s]
367
+ base_connector_xmi_id = xml_node["base_Connector"]
368
+ this_thing.base_connector = element_hash[base_connector_xmi_id]
369
+ end
350
370
 
351
- if xml_node.name.to_s == "NestedConnectorEnd"
352
- this_thing = element_hash[xml_node.attribute_with_ns("id",
353
- xmiNS.href).to_s]
354
- base_connectorend_xmi_id = xml_node["base_ConnectorEnd"]
355
- this_thing.base_connectorend = element_hash[base_connectorend_xmi_id]
356
- if xml_node["propertyPath"] == nil
357
- for prop_path in xml_node.xpath("./propertyPath")
358
- # to deal with href = '#xmi:id' i.e. local references
359
- href_parts = prop_path["href"].split("#")
360
- prop = if href_parts[0].size == 0
361
- element_hash[href_parts[1]]
362
- else
363
- element_hash[prop_path["href"]]
364
- end
365
- this_thing.property_path.push prop
371
+ if xml_node.name.to_s == "NestedConnectorEnd"
372
+ this_thing = element_hash[xml_node
373
+ .attribute_with_ns("id", xmi_ns.href).to_s]
374
+ base_connectorend_xmi_id = xml_node["base_ConnectorEnd"]
375
+ this_thing.base_connectorend =
376
+ element_hash[base_connectorend_xmi_id]
377
+ if xml_node["propertyPath"] == nil
378
+ xml_node.xpath("./propertyPath").each do |prop_path|
379
+ # to deal with href = '#xmi:id' i.e. local references
380
+ href_parts = prop_path["href"].split("#")
381
+ prop = if href_parts[0].empty?
382
+ element_hash[href_parts[1]]
383
+ else
384
+ element_hash[prop_path["href"]]
385
+ end
386
+ this_thing.property_path.push prop
387
+ end
388
+ else
389
+ this_thing.property_path
390
+ .push element_hash[xml_node["propertyPath"]]
366
391
  end
367
- else
368
- this_thing.property_path.push element_hash[xml_node["propertyPath"]]
369
392
  end
370
- end
371
-
372
- if xml_node.name.to_s == "Satisfy"
373
- this_thing = element_hash[xml_node.attribute_with_ns("id",
374
- xmiNS.href).to_s]
375
- base_realization_xmi_id = xml_node["base_Realization"]
376
- this_thing.base_realization = element_hash[base_realization_xmi_id]
377
- end
378
393
 
379
- if ["DeriveReqt", "refine", "trace", "Copy", "Verify", "Allocate",
380
- ""].include? xml_node.name.to_s
381
- this_thing = element_hash[xml_node.attribute_with_ns("id",
382
- xmiNS.href).to_s]
383
- base_abstraction_xmi_id = xml_node["base_Abstraction"]
384
- this_thing.base_abstraction = element_hash[base_abstraction_xmi_id]
385
- end
394
+ if xml_node.name.to_s == "Satisfy"
395
+ this_thing = element_hash[xml_node
396
+ .attribute_with_ns("id", xmi_ns.href).to_s]
397
+ base_realization_xmi_id = xml_node["base_Realization"]
398
+ this_thing.base_realization = element_hash[base_realization_xmi_id]
399
+ end
386
400
 
387
- if xml_node.attribute_with_ns("type",
388
- xmiNS.href).to_s == "uml:Association"
389
- this_thing = element_hash[xml_node.attribute_with_ns("id",
390
- xmiNS.href).to_s]
391
- member_end_list = xml_node.xpath("./memberEnd")
392
- for item in member_end_list
393
- this_thing.member_end.push element_hash[item["idref"]]
401
+ if ["DeriveReqt", "refine", "trace", "Copy", "Verify", "Allocate", # rubocop:disable Performance/CollectionLiteralInLoop
402
+ ""].include? xml_node.name.to_s
403
+ this_thing = element_hash[xml_node
404
+ .attribute_with_ns("id", xmi_ns.href).to_s]
405
+ base_abstraction_xmi_id = xml_node["base_Abstraction"]
406
+ this_thing.base_abstraction = element_hash[base_abstraction_xmi_id]
394
407
  end
395
- owned_end_list = xml_node.xpath("./ownedEnd")
396
- for item in owned_end_list
397
- this_thing.owned_end.push element_hash[item.attribute_with_ns("id",
398
- xmiNS.href).to_s]
408
+
409
+ if xml_node.attribute_with_ns("type",
410
+ xmi_ns.href).to_s == "uml:Association"
411
+ this_thing = element_hash[xml_node
412
+ .attribute_with_ns("id", xmi_ns.href).to_s]
413
+ member_end_list = xml_node.xpath("./memberEnd")
414
+ member_end_list.each do |item|
415
+ this_thing.member_end.push element_hash[item["idref"]]
416
+ end
417
+ owned_end_list = xml_node.xpath("./ownedEnd")
418
+ owned_end_list.each do |item|
419
+ this_thing.owned_end.push element_hash[item.attribute_with_ns(
420
+ "id", xmi_ns.href
421
+ ).to_s]
422
+ end
399
423
  end
400
- end
401
424
 
402
- if (["uml:Property", "uml:Port"].include?(xml_node.attribute_with_ns("type",
403
- xmiNS.href).to_s)) && not ["definingFeature", "partWithPort", "propertyPath",
404
- "role"].include? xml_node.name.to_s
405
- this_thing = element_hash[xml_node.attribute_with_ns("id",
406
- xmiNS.href).to_s]
425
+ if ["uml:Property", "uml:Port"].include?( # rubocop:disable Performance/CollectionLiteralInLoop
426
+ xml_node.attribute_with_ns("type", xmi_ns.href).to_s,
427
+ ) &&
428
+ !["definingFeature", "partWithPort", "propertyPath", "role"] # rubocop:disable Performance/CollectionLiteralInLoop
429
+ .include?(xml_node.name.to_s)
430
+ this_thing = element_hash[xml_node
431
+ .attribute_with_ns("id", xmi_ns.href).to_s]
407
432
  if !xml_node["association"].nil?
408
433
  this_thing.association = element_hash[xml_node["association"]]
409
434
  end
@@ -416,7 +441,7 @@ module Lutaml::SysMl
416
441
 
417
442
  if !xml_node.at("lowerValue").nil?
418
443
 
419
- this_thing.lowerValue = if xml_node.at("lowerValue")["value"] == nil
444
+ this_thing.lowerValue = if xml_node.at("lowerValue")["value"].nil?
420
445
  "0"
421
446
  else
422
447
  xml_node.at("lowerValue")["value"]
@@ -427,29 +452,31 @@ module Lutaml::SysMl
427
452
  end
428
453
  end
429
454
 
430
- if xml_node.attribute_with_ns("type",
431
- xmiNS.href).to_s == "uml:Connector"
432
- this_thing = element_hash[xml_node.attribute_with_ns("id",
433
- xmiNS.href).to_s]
434
- connector_end_list = xml_node.xpath("./end")
435
- for end_xml_node in connector_end_list
436
- this_thing.connector_end.push element_hash[end_xml_node.attribute_with_ns(
437
- "id", xmiNS.href
438
- ).to_s]
455
+ if xml_node.attribute_with_ns("type",
456
+ xmi_ns.href).to_s == "uml:Connector"
457
+ this_thing = element_hash[xml_node
458
+ .attribute_with_ns("id", xmi_ns.href).to_s]
459
+ connector_end_list = xml_node.xpath("./end")
460
+ connector_end_list.each do |end_xml_node|
461
+ this_thing.connector_end
462
+ .push element_hash[end_xml_node.attribute_with_ns(
463
+ "id", xmi_ns.href
464
+ ).to_s]
465
+ end
439
466
  end
440
- end
441
467
 
442
- if xml_node.attribute_with_ns("type",
443
- xmiNS.href).to_s == "uml:ConnectorEnd"
444
- this_thing = element_hash[xml_node.attribute_with_ns("id",
445
- xmiNS.href).to_s]
446
- this_thing.connector = element_hash[xml_node.parent.attribute_with_ns("id",
447
- xmiNS.href).to_s]
448
- this_thing.role = element_hash[xml_node["role"]]
449
- if this_thing.role == nil
450
- this_thing.role = element_hash[xml_node.at("role")["href"]]
451
- end
452
- this_thing.part_with_port = element_hash[xml_node["part_with_port"]]
468
+ if xml_node.attribute_with_ns("type",
469
+ xmi_ns.href).to_s == "uml:ConnectorEnd"
470
+ this_thing = element_hash[xml_node
471
+ .attribute_with_ns("id", xmi_ns.href).to_s]
472
+ this_thing.connector = element_hash[xml_node.parent
473
+ .attribute_with_ns("id", xmi_ns.href).to_s]
474
+ this_thing.role = element_hash[xml_node["role"]]
475
+ if this_thing.role == nil
476
+ this_thing.role = element_hash[xml_node.at("role")["href"]]
477
+ end
478
+ this_thing.part_with_port = element_hash[xml_node["part_with_port"]]
479
+ end
453
480
  end
454
481
  end
455
482
  end