lutaml 0.9.36 → 0.9.38
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/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +11 -0
- data/lib/lutaml/xmi/liquid_drops/connector_drop.rb +2 -2
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +7 -4
- data/lib/lutaml/xmi/liquid_drops/dependency_drop.rb +37 -0
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +11 -0
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +46 -9
- data/lib/lutaml/xmi/liquid_drops/source_target_drop.rb +8 -0
- data/lib/lutaml/xmi/parsers/xmi_base.rb +46 -5
- data/lib/lutaml/xmi/parsers/xml.rb +44 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12410a33e4b17ab05b04f225dfc29f02c166593e11f60eb18855377c34f0045
|
4
|
+
data.tar.gz: 3eea93807b6903d9ac1542a9d6dcac3f02e1ebb5cb6a53dcc8e0323343167782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93f8ef8383797613ba709e08a4d7b17b9f89a13a2fea1232987116add58d7fdad7c0eca0665d749a02a8a2052d32164a2c24bf6b281e3ba6493f779ced3cdc70
|
7
|
+
data.tar.gz: 2db73837b21c95b8a7d53820ce43dd32577ca2ea825a964adf8422138eb0fe9afb2445678937a8370d03ad4278cdb8ebd8f00fd7123a939151d2ef855c5f2719
|
data/lib/lutaml/version.rb
CHANGED
@@ -55,11 +55,22 @@ module Lutaml
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def association_connector
|
59
|
+
connector = fetch_connector(@model.association)
|
60
|
+
if connector
|
61
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
58
65
|
def type_ns
|
59
66
|
if @options[:with_assoc] && @model.association
|
60
67
|
get_ns_by_xmi_id(xmi_id)
|
61
68
|
end
|
62
69
|
end
|
70
|
+
|
71
|
+
def stereotype
|
72
|
+
doc_node_attribute_value(@uml_type_idref, "stereotype")
|
73
|
+
end
|
63
74
|
end
|
64
75
|
end
|
65
76
|
end
|
@@ -37,11 +37,11 @@ module Lutaml
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def source
|
40
|
-
::Lutaml::XMI::SourceTargetDrop.new(@model.source)
|
40
|
+
::Lutaml::XMI::SourceTargetDrop.new(@model.source, @options)
|
41
41
|
end
|
42
42
|
|
43
43
|
def target
|
44
|
-
::Lutaml::XMI::SourceTargetDrop.new(@model.target)
|
44
|
+
::Lutaml::XMI::SourceTargetDrop.new(@model.target, @options)
|
45
45
|
end
|
46
46
|
|
47
47
|
def recognized?
|
@@ -47,11 +47,14 @@ module Lutaml
|
|
47
47
|
end
|
48
48
|
|
49
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?
|
50
|
+
return if !@matched_element || !@matched_element.links
|
53
51
|
|
54
|
-
|
52
|
+
links = []
|
53
|
+
@matched_element.links.each do |link|
|
54
|
+
links << link.association if link.association.any?
|
55
|
+
end
|
56
|
+
|
57
|
+
links.flatten.compact.map do |assoc|
|
55
58
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
56
59
|
link_owner_name = link_member == "start" ? "end" : "start"
|
57
60
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lutaml
|
4
|
+
module XMI
|
5
|
+
class DependencyDrop < Liquid::Drop
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
9
|
+
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@id_name_mapping = options[:id_name_mapping]
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
@model.id
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
@model.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def ea_type
|
24
|
+
@model&.properties&.ea_type
|
25
|
+
end
|
26
|
+
|
27
|
+
def documentation
|
28
|
+
@model&.documentation&.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def connector
|
32
|
+
connector = fetch_connector(@model.id)
|
33
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -37,6 +37,17 @@ module Lutaml
|
|
37
37
|
def stereotype
|
38
38
|
doc_node_attribute_value(@model.id, "stereotype")
|
39
39
|
end
|
40
|
+
|
41
|
+
# @return name of the upper packaged element
|
42
|
+
def upper_packaged_element
|
43
|
+
if @options[:with_gen]
|
44
|
+
find_upper_level_packaged_element(@model.id)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def subtype_of
|
49
|
+
find_subtype_of(@model.id)
|
50
|
+
end
|
40
51
|
end
|
41
52
|
end
|
42
53
|
end
|
@@ -24,6 +24,14 @@ module Lutaml
|
|
24
24
|
@matched_element = @xmi_root_model&.extension&.elements&.element&.find do |e| # rubocop:disable Layout/LineLength,Style/SafeNavigationChainLength
|
25
25
|
e.idref == @model.id
|
26
26
|
end
|
27
|
+
|
28
|
+
@dependencies = select_dependencies_by_supplier(@model.id)
|
29
|
+
|
30
|
+
@inheritance_ids = @matched_element&.links&.map do |link|
|
31
|
+
link.generalization.select do |gen|
|
32
|
+
gen.end == @model.id
|
33
|
+
end.map(&:id)
|
34
|
+
end&.flatten&.compact || []
|
27
35
|
end
|
28
36
|
|
29
37
|
if guidance
|
@@ -69,17 +77,36 @@ module Lutaml
|
|
69
77
|
end.compact
|
70
78
|
end
|
71
79
|
|
80
|
+
def owned_attributes
|
81
|
+
@owned_attributes.map do |owned_attr|
|
82
|
+
::Lutaml::XMI::AttributeDrop.new(owned_attr, @options)
|
83
|
+
end.compact
|
84
|
+
end
|
85
|
+
|
86
|
+
def dependencies
|
87
|
+
@dependencies.map do |dependency|
|
88
|
+
::Lutaml::XMI::DependencyDrop.new(dependency, @options)
|
89
|
+
end.compact
|
90
|
+
end
|
91
|
+
|
92
|
+
def inheritances
|
93
|
+
@inheritance_ids.map do |inheritance_id|
|
94
|
+
# ::Lutaml::XMI::InheritanceDrop.new(dependency, @options)
|
95
|
+
connector = fetch_connector(inheritance_id)
|
96
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
97
|
+
end.compact
|
98
|
+
end
|
99
|
+
|
72
100
|
def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
73
|
-
return if !@matched_element ||
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
101
|
+
return if !@matched_element || !@matched_element.links
|
102
|
+
|
103
|
+
links = []
|
104
|
+
@matched_element.links.each do |link|
|
105
|
+
links << link.association if link.association.any?
|
106
|
+
links << link.generalization if link.generalization.any?
|
107
|
+
end
|
79
108
|
|
80
|
-
links
|
81
|
-
@matched_element.links.generalization
|
82
|
-
links.map do |assoc|
|
109
|
+
links.flatten.compact.map do |assoc|
|
83
110
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
84
111
|
link_owner_name = link_member == "start" ? "end" : "start"
|
85
112
|
|
@@ -145,6 +172,16 @@ module Lutaml
|
|
145
172
|
end
|
146
173
|
end
|
147
174
|
|
175
|
+
def upper_packaged_element
|
176
|
+
if @options[:with_gen]
|
177
|
+
find_upper_level_packaged_element(@model.id)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def subtype_of
|
182
|
+
find_subtype_of(@model.id)
|
183
|
+
end
|
184
|
+
|
148
185
|
def has_guidance?
|
149
186
|
!!@klass_guidance
|
150
187
|
end
|
@@ -297,6 +297,23 @@ module Lutaml
|
|
297
297
|
@upper_level_cache[klass_id]
|
298
298
|
end
|
299
299
|
|
300
|
+
def find_subtype_of(id) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
301
|
+
@pkg_elements_owned_attributes ||= all_packaged_elements.map do |e|
|
302
|
+
{
|
303
|
+
name: e.name,
|
304
|
+
idrefs: e&.owned_attribute&.map do |oa|
|
305
|
+
oa&.uml_type&.idref
|
306
|
+
end || [],
|
307
|
+
}
|
308
|
+
end
|
309
|
+
|
310
|
+
result = @pkg_elements_owned_attributes.find do |e|
|
311
|
+
e[:idrefs].include?(id)
|
312
|
+
end
|
313
|
+
|
314
|
+
result[:name] if result
|
315
|
+
end
|
316
|
+
|
300
317
|
# Build cache once for all packaged elements
|
301
318
|
def build_upper_level_cache
|
302
319
|
@upper_level_cache = {}
|
@@ -371,7 +388,28 @@ module Lutaml
|
|
371
388
|
# @return [Lutaml::Model::Serializable]
|
372
389
|
def find_klass_packaged_element_by_name(name)
|
373
390
|
all_packaged_elements.find do |e|
|
374
|
-
e.
|
391
|
+
e.name == name &&
|
392
|
+
(
|
393
|
+
e.type?("uml:Class") ||
|
394
|
+
e.type?("uml:AssociationClass")
|
395
|
+
)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
# @param name [String]
|
400
|
+
# @return [Lutaml::Model::Serializable]
|
401
|
+
def find_enum_packaged_element_by_name(name)
|
402
|
+
all_packaged_elements.find do |e|
|
403
|
+
e.name == name && e.type?("uml:Enumeration")
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
# @param supplier_id [String]
|
408
|
+
# @return [Lutaml::Model::Serializable]
|
409
|
+
def select_dependencies_by_supplier(supplier_id)
|
410
|
+
all_packaged_elements.select do |e|
|
411
|
+
e.supplier == supplier_id &&
|
412
|
+
e.type?("uml:Dependency")
|
375
413
|
end
|
376
414
|
end
|
377
415
|
|
@@ -473,11 +511,14 @@ module Lutaml
|
|
473
511
|
matched_element = @xmi_root_model.extension.elements.element
|
474
512
|
.find { |e| e.idref == xmi_id }
|
475
513
|
|
476
|
-
return if !matched_element ||
|
477
|
-
|
478
|
-
|
514
|
+
return if !matched_element || !matched_element.links
|
515
|
+
|
516
|
+
links = []
|
517
|
+
matched_element.links.each do |link|
|
518
|
+
links << link.association if link.association.any?
|
519
|
+
end
|
479
520
|
|
480
|
-
|
521
|
+
links.flatten.compact.map do |assoc|
|
481
522
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
482
523
|
linke_owner_name = link_member == "start" ? "end" : "start"
|
483
524
|
|
@@ -67,6 +67,30 @@ module Lutaml
|
|
67
67
|
|
68
68
|
ret_val
|
69
69
|
end
|
70
|
+
|
71
|
+
# @param xmi_path [String] path to xml
|
72
|
+
# @param name [String]
|
73
|
+
# @return [Hash]
|
74
|
+
def serialize_enumeration_by_name( # rubocop:disable Metrics/MethodLength
|
75
|
+
xmi_path, name
|
76
|
+
)
|
77
|
+
# Load from cache or file
|
78
|
+
xml_cache_key = (Digest::SHA256.file xmi_path).hexdigest
|
79
|
+
xmi_model = @xmi_root_model_cache_static[xml_cache_key] ||
|
80
|
+
get_xmi_model(xmi_path)
|
81
|
+
id_name_mapping = @id_name_mapping_static[xml_cache_key]
|
82
|
+
|
83
|
+
instance = new
|
84
|
+
enum = instance.serialize_enumeration_by_name(
|
85
|
+
xmi_model, name, id_name_mapping
|
86
|
+
)
|
87
|
+
|
88
|
+
# Put xmi_model and id_name_mapping to cache
|
89
|
+
@id_name_mapping_static[xml_cache_key] ||= instance.id_name_mapping
|
90
|
+
@xmi_root_model_cache_static[xml_cache_key] ||= xmi_model
|
91
|
+
|
92
|
+
enum
|
93
|
+
end
|
70
94
|
end
|
71
95
|
|
72
96
|
# @param xmi_model [Lutaml::Model::Serializable]
|
@@ -122,12 +146,32 @@ module Lutaml
|
|
122
146
|
with_gen: true,
|
123
147
|
with_absolute_path: true,
|
124
148
|
}
|
149
|
+
puts "Error: Class not found for name: #{name}!" if klass.nil?
|
125
150
|
::Lutaml::XMI::KlassDrop.new(
|
126
151
|
klass,
|
127
152
|
guidance,
|
128
153
|
options,
|
129
154
|
)
|
130
155
|
end
|
156
|
+
|
157
|
+
# @param xmi_model [Lutaml::Model::Serializable]
|
158
|
+
# @param name [String]
|
159
|
+
# @param id_name_mapping [Hash]
|
160
|
+
# @return [Hash]
|
161
|
+
def serialize_enumeration_by_name( # rubocop:disable Metrics/MethodLength
|
162
|
+
xmi_model, name, id_name_mapping = nil
|
163
|
+
)
|
164
|
+
set_xmi_model(xmi_model, id_name_mapping)
|
165
|
+
enum = find_enum_packaged_element_by_name(name)
|
166
|
+
options = {
|
167
|
+
xmi_root_model: @xmi_root_model,
|
168
|
+
id_name_mapping: @id_name_mapping,
|
169
|
+
with_gen: true,
|
170
|
+
with_absolute_path: true,
|
171
|
+
}
|
172
|
+
puts "Error: Enumeration not found for name: #{name}!" if enum.nil?
|
173
|
+
::Lutaml::XMI::EnumDrop.new(enum, options)
|
174
|
+
end
|
131
175
|
end
|
132
176
|
end
|
133
177
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- lib/lutaml/xmi/liquid_drops/connector_drop.rb
|
315
315
|
- lib/lutaml/xmi/liquid_drops/constraint_drop.rb
|
316
316
|
- lib/lutaml/xmi/liquid_drops/data_type_drop.rb
|
317
|
+
- lib/lutaml/xmi/liquid_drops/dependency_drop.rb
|
317
318
|
- lib/lutaml/xmi/liquid_drops/diagram_drop.rb
|
318
319
|
- lib/lutaml/xmi/liquid_drops/enum_drop.rb
|
319
320
|
- lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb
|