lutaml 0.9.32 → 0.9.33
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 +1 -1
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/package_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/root_drop.rb +1 -1
- data/lib/lutaml/xmi/parsers/xmi_base.rb +13 -8
- data/lib/lutaml/xmi/parsers/xml.rb +24 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a3e7ce554e5b58c9d922d7588087550e9fed056f5492e822b15531d91ddcb14
|
4
|
+
data.tar.gz: 18ee2a6d41c7056f56cbb8f869ca234e3fcff6688024f8aeff55797047069270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8d3699fc5cdda40ae70b388e520095874828d80d5759c32f754df0aff1ec31ae185f17296e26d09e23bb41c8326fb517626389227c277f549f6a107d303c17
|
7
|
+
data.tar.gz: 745883a9eea0ef04d31f6941121d15dc9b0a687ae9c55634bd6790ab5d12fd1e72e6b9ce8b128a992463c405b057de53db76d0d0518a412f673986a4928288b0
|
data/lib/lutaml/version.rb
CHANGED
@@ -9,7 +9,7 @@ module Lutaml
|
|
9
9
|
@model = model
|
10
10
|
@options = options
|
11
11
|
@xmi_root_model = options[:xmi_root_model]
|
12
|
-
@
|
12
|
+
@id_name_mapping = options[:id_name_mapping]
|
13
13
|
|
14
14
|
uml_type = @model.uml_type
|
15
15
|
@uml_type_idref = uml_type.idref if uml_type
|
@@ -9,7 +9,7 @@ module Lutaml
|
|
9
9
|
@model = model
|
10
10
|
@options = options
|
11
11
|
@xmi_root_model = options[:xmi_root_model]
|
12
|
-
@
|
12
|
+
@id_name_mapping = options[:id_name_mapping]
|
13
13
|
|
14
14
|
@owned_attributes = model&.owned_attribute&.select do |attr|
|
15
15
|
attr.type?("uml:Property")
|
@@ -9,7 +9,7 @@ module Lutaml
|
|
9
9
|
@model = model
|
10
10
|
@options = options
|
11
11
|
@xmi_root_model = options[:xmi_root_model]
|
12
|
-
@
|
12
|
+
@id_name_mapping = options[:id_name_mapping]
|
13
13
|
|
14
14
|
@owned_literals = model&.owned_literal&.select do |owned_literal|
|
15
15
|
owned_literal.type? "uml:EnumerationLiteral"
|
@@ -10,7 +10,7 @@ module Lutaml
|
|
10
10
|
@guidance = guidance
|
11
11
|
@options = options
|
12
12
|
@xmi_root_model = options[:xmi_root_model]
|
13
|
-
@
|
13
|
+
@id_name_mapping = options[:id_name_mapping]
|
14
14
|
|
15
15
|
@package = model&.packaged_element&.find do |e|
|
16
16
|
e.type?("uml:Package")
|
@@ -25,10 +25,15 @@ module Lutaml
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# @param xmi_model [Lutaml::Model::Serializable]
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# @param id_name_mapping [Hash]
|
29
|
+
# @return [Hash]
|
30
|
+
def set_xmi_model(xmi_model, id_name_mapping = nil)
|
31
|
+
@id_name_mapping ||= id_name_mapping || {}
|
32
|
+
@xmi_root_model ||= xmi_model
|
33
|
+
|
34
|
+
if @id_name_mapping.empty?
|
35
|
+
map_id_name(@id_name_mapping, @xmi_root_model)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
private
|
@@ -907,8 +912,8 @@ module Lutaml
|
|
907
912
|
# @param xmi_id [String]
|
908
913
|
# @return [String]
|
909
914
|
def lookup_entity_name(xmi_id)
|
910
|
-
model_node_name_by_xmi_id(xmi_id) if @
|
911
|
-
@
|
915
|
+
model_node_name_by_xmi_id(xmi_id) if @id_name_mapping.empty?
|
916
|
+
@id_name_mapping[xmi_id]
|
912
917
|
end
|
913
918
|
|
914
919
|
# @param xmi_id [String]
|
@@ -962,8 +967,8 @@ module Lutaml
|
|
962
967
|
def model_node_name_by_xmi_id(xmi_id)
|
963
968
|
id_name_mapping = Hash.new
|
964
969
|
map_id_name(id_name_mapping, @xmi_root_model)
|
965
|
-
@
|
966
|
-
@
|
970
|
+
@id_name_mapping = id_name_mapping
|
971
|
+
@id_name_mapping[xmi_id]
|
967
972
|
end
|
968
973
|
|
969
974
|
# @return [Array<Xmi::Uml::PackagedElement>]
|
@@ -11,10 +11,11 @@ module Lutaml
|
|
11
11
|
module Parsers
|
12
12
|
# Class for parsing .xmi schema files into ::Lutaml::Uml::Document
|
13
13
|
class XML
|
14
|
-
@
|
14
|
+
@id_name_mapping_static = {}
|
15
15
|
@xmi_root_model_cache_static = {}
|
16
16
|
|
17
|
-
attr_reader :
|
17
|
+
attr_reader :id_name_mapping, :xmi_root_model,
|
18
|
+
:all_packaged_elements_cache
|
18
19
|
|
19
20
|
include XMIBase
|
20
21
|
|
@@ -42,38 +43,30 @@ module Lutaml
|
|
42
43
|
new.serialize_xmi_to_liquid(xmi_model, guidance)
|
43
44
|
end
|
44
45
|
|
45
|
-
# @param
|
46
|
+
# @param xmi_path [String] path to xml
|
46
47
|
# @param name [String]
|
47
48
|
# @param guidance [String]
|
48
49
|
# @return [Hash]
|
49
|
-
def serialize_generalization_by_name(
|
50
|
-
|
51
|
-
|
50
|
+
def serialize_generalization_by_name( # rubocop:disable Metrics/MethodLength
|
51
|
+
xmi_path, name, guidance = nil
|
52
|
+
)
|
52
53
|
# Load from cache or file
|
53
|
-
xml_cache_key = (Digest::SHA256.file
|
54
|
-
xmi_model =
|
55
|
-
|
56
|
-
|
57
|
-
xmi_model = get_xmi_model(xml)
|
58
|
-
xmi_model_to_cache = deep_clone(xmi_model)
|
59
|
-
end
|
60
|
-
xmi_cache = @xmi_cache_static[xml_cache_key]
|
54
|
+
xml_cache_key = (Digest::SHA256.file xmi_path).hexdigest
|
55
|
+
xmi_model = @xmi_root_model_cache_static[xml_cache_key] ||
|
56
|
+
get_xmi_model(xmi_path)
|
57
|
+
id_name_mapping = @id_name_mapping_static[xml_cache_key]
|
61
58
|
|
62
59
|
instance = new
|
63
|
-
ret_val = instance.serialize_generalization_by_name(
|
60
|
+
ret_val = instance.serialize_generalization_by_name(
|
61
|
+
xmi_model, name, guidance, id_name_mapping
|
62
|
+
)
|
64
63
|
|
65
|
-
# Put to cache
|
66
|
-
@
|
67
|
-
@xmi_root_model_cache_static[xml_cache_key]
|
64
|
+
# Put xmi_model and id_name_mapping to cache
|
65
|
+
@id_name_mapping_static[xml_cache_key] ||= instance.id_name_mapping
|
66
|
+
@xmi_root_model_cache_static[xml_cache_key] ||= xmi_model
|
68
67
|
|
69
68
|
ret_val
|
70
69
|
end
|
71
|
-
|
72
|
-
def deep_clone(obj)
|
73
|
-
# TODO: we need this if xmi_model is being modified in serialize_generalization_by_name
|
74
|
-
#Marshal.load(Marshal.dump(obj)) if obj != nil
|
75
|
-
obj
|
76
|
-
end
|
77
70
|
end
|
78
71
|
|
79
72
|
# @param xmi_model [Lutaml::Model::Serializable]
|
@@ -106,7 +99,7 @@ module Lutaml
|
|
106
99
|
model = xmi_model.model
|
107
100
|
options = {
|
108
101
|
xmi_root_model: @xmi_root_model,
|
109
|
-
|
102
|
+
id_name_mapping: @id_name_mapping,
|
110
103
|
with_gen: true,
|
111
104
|
with_absolute_path: true,
|
112
105
|
}
|
@@ -116,14 +109,16 @@ module Lutaml
|
|
116
109
|
# @param xmi_model [Lutaml::Model::Serializable]
|
117
110
|
# @param name [String]
|
118
111
|
# @param guidance_yaml [String]
|
112
|
+
# @param id_name_mapping [Hash]
|
119
113
|
# @return [Hash]
|
120
|
-
def serialize_generalization_by_name(
|
121
|
-
|
122
|
-
|
114
|
+
def serialize_generalization_by_name( # rubocop:disable Metrics/MethodLength
|
115
|
+
xmi_model, name, guidance = nil, id_name_mapping = nil
|
116
|
+
)
|
117
|
+
set_xmi_model(xmi_model, id_name_mapping)
|
123
118
|
klass = find_klass_packaged_element(name)
|
124
119
|
options = {
|
125
120
|
xmi_root_model: @xmi_root_model,
|
126
|
-
|
121
|
+
id_name_mapping: @id_name_mapping,
|
127
122
|
with_gen: true,
|
128
123
|
with_absolute_path: true,
|
129
124
|
}
|
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.33
|
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-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|