lutaml 0.9.31 → 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 +11 -14
- data/lib/lutaml/xmi/parsers/xml.rb +25 -32
- 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,18 +25,15 @@ module Lutaml
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# @param xmi_model [Lutaml::Model::Serializable]
|
28
|
-
|
29
|
-
@xmi_cache = xmi_cache ? xmi_cache : {}
|
30
|
-
@xmi_root_model = xmi_model
|
31
|
-
map_id_name(@xmi_cache, @xmi_root_model) if @xmi_cache.empty?
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param yaml [String]
|
28
|
+
# @param id_name_mapping [Hash]
|
35
29
|
# @return [Hash]
|
36
|
-
def
|
37
|
-
|
30
|
+
def set_xmi_model(xmi_model, id_name_mapping = nil)
|
31
|
+
@id_name_mapping ||= id_name_mapping || {}
|
32
|
+
@xmi_root_model ||= xmi_model
|
38
33
|
|
39
|
-
|
34
|
+
if @id_name_mapping.empty?
|
35
|
+
map_id_name(@id_name_mapping, @xmi_root_model)
|
36
|
+
end
|
40
37
|
end
|
41
38
|
|
42
39
|
private
|
@@ -915,8 +912,8 @@ module Lutaml
|
|
915
912
|
# @param xmi_id [String]
|
916
913
|
# @return [String]
|
917
914
|
def lookup_entity_name(xmi_id)
|
918
|
-
model_node_name_by_xmi_id(xmi_id) if @
|
919
|
-
@
|
915
|
+
model_node_name_by_xmi_id(xmi_id) if @id_name_mapping.empty?
|
916
|
+
@id_name_mapping[xmi_id]
|
920
917
|
end
|
921
918
|
|
922
919
|
# @param xmi_id [String]
|
@@ -970,8 +967,8 @@ module Lutaml
|
|
970
967
|
def model_node_name_by_xmi_id(xmi_id)
|
971
968
|
id_name_mapping = Hash.new
|
972
969
|
map_id_name(id_name_mapping, @xmi_root_model)
|
973
|
-
@
|
974
|
-
@
|
970
|
+
@id_name_mapping = id_name_mapping
|
971
|
+
@id_name_mapping[xmi_id]
|
975
972
|
end
|
976
973
|
|
977
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]
|
@@ -101,31 +94,31 @@ module Lutaml
|
|
101
94
|
# @param xmi_model [Lutaml::Model::Serializable]
|
102
95
|
# @param guidance_yaml [String]
|
103
96
|
# return [Liquid::Drop]
|
104
|
-
def serialize_xmi_to_liquid(xmi_model,
|
97
|
+
def serialize_xmi_to_liquid(xmi_model, guidance = nil)
|
105
98
|
set_xmi_model(xmi_model)
|
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
|
}
|
113
|
-
guidance = get_guidance(guidance_yaml)
|
114
106
|
::Lutaml::XMI::RootDrop.new(model, guidance, options)
|
115
107
|
end
|
116
108
|
|
117
109
|
# @param xmi_model [Lutaml::Model::Serializable]
|
118
110
|
# @param name [String]
|
119
111
|
# @param guidance_yaml [String]
|
112
|
+
# @param id_name_mapping [Hash]
|
120
113
|
# @return [Hash]
|
121
|
-
def serialize_generalization_by_name(
|
122
|
-
|
123
|
-
|
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)
|
124
118
|
klass = find_klass_packaged_element(name)
|
125
|
-
guidance = get_guidance(guidance_yaml)
|
126
119
|
options = {
|
127
120
|
xmi_root_model: @xmi_root_model,
|
128
|
-
|
121
|
+
id_name_mapping: @id_name_mapping,
|
129
122
|
with_gen: true,
|
130
123
|
with_absolute_path: true,
|
131
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
|