ea 0.6.164 → 0.6.165

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee7d2816e74ff31b294607a17ffdf5feb9208c637384f8274e7a6c2f743017ae
4
- data.tar.gz: 84a2d63ae2cd3e40bb9d21f2e9154ea6c2f80e9a7030c004430e376781f164e9
3
+ metadata.gz: 3d6e363d3ce5294bbec1381036c0d58695f74ebef95ac2c5af485ac820d9b4f2
4
+ data.tar.gz: 1a4c1cdbba4cc89cf3a51ab3ed9a745aa1fc689a683b1c1d8cdeb68907d5613c
5
5
  SHA512:
6
- metadata.gz: 789998526d228e9f8ace000f9c949ca4ea4990d6bc0e20d5e4e1ebcf678e7d0724e745f48df21c622b393c465e0bf535b5aabc4c36e8b1f95a52cb1e00eac8d8
7
- data.tar.gz: 1440e9fd64937be62c075d0573117d9d65cb16b8025ae75b56ddb409776999842b6714bfdeb0f55bb8970c63ea4b316037384386d95891e446d7d09354b46ea9
6
+ metadata.gz: d91002f1127005510c1309471d4e24d2bc4f2c20a81cb5cf02f68d756052c3b10465ea5dacb7f8b1ea2878168eeb4113d573165a62563bec8a39876b3e85c8d8
7
+ data.tar.gz: 8335438117d6def1b2421c1c1e9cc1e5f515118e8b8a8af15699a34ff1f425f9641317792f6e1c863007e06bf25cd9bd559099db9336d7d8f1e8f9e4a43cf62a
@@ -0,0 +1,232 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module Qea
5
+ module LazyDrops
6
+ # LookupService-compatible cross-reference facade over the
7
+ # Ea::Qea::Database indexes. Answers the methods the
8
+ # Xmi-model-shaped Liquid drops call on options[:lookup], using
9
+ # the database's own rows instead of a Sparx document graph.
10
+ class QeaLookup
11
+ # Read-only connector reference exposing the idref/name/
12
+ # source/target surface ConnectorDrop and SourceTargetDrop
13
+ # consume.
14
+ ConnectorRef = Struct.new(:idref, :name, :documentation,
15
+ :source, :target, keyword_init: true)
16
+
17
+ Documentation = Struct.new(:value, keyword_init: true)
18
+
19
+ Endpoint = Struct.new(:idref, keyword_init: true) do
20
+ def documentation_value
21
+ documentation&.value
22
+ end
23
+ end
24
+
25
+ Endpoint = Struct.new(:idref, keyword_init: true)
26
+
27
+ # Read-only dependency reference exposing the name/client/
28
+ # supplier surface DependencyDrop consumes.
29
+ DependencyRef = Struct.new(:name, :client, :supplier, keyword_init: true)
30
+
31
+ def initialize(database)
32
+ @database = database
33
+ @names = nil
34
+ end
35
+
36
+ # xmi_id -> element name, the id_name_map equivalent.
37
+ def id_name_mapping
38
+ names
39
+ end
40
+
41
+ def lookup_entity_name(xmi_id)
42
+ names[xmi_id]
43
+ end
44
+
45
+ # The name of the package directly containing the element.
46
+ def find_upper_level_packaged_element(klass_id)
47
+ object = object_by_xmi_id(klass_id)
48
+ return object_package_name(object) if object
49
+
50
+ package = package_by_xmi_id(klass_id)
51
+ parent_name_for(package)
52
+ end
53
+
54
+ def find_packaged_element_by_id(_id)
55
+ nil
56
+ end
57
+
58
+ def get_ns_by_xmi_id(xmi_id)
59
+ object = object_by_xmi_id(xmi_id)
60
+ return object_package_name(object) if object
61
+
62
+ package = package_by_xmi_id(xmi_id)
63
+ parent_name_for(package)
64
+ end
65
+
66
+ def get_package_name(package)
67
+ package&.name
68
+ end
69
+
70
+ # Sparx-shaped connector reference for the drop surface.
71
+ def fetch_connector(link_id)
72
+ conn = database.connectors.find do |c|
73
+ Ea::GuidFormat.ea_guid_to_xmi_id(c.ea_guid) == link_id
74
+ end
75
+ return nil unless conn
76
+
77
+ ConnectorRef.new(
78
+ idref: link_id,
79
+ name: conn.name,
80
+ documentation: documentation(conn.notes),
81
+ source: endpoint(conn.start_object_id),
82
+ target: endpoint(conn.end_object_id)
83
+ )
84
+ end
85
+
86
+ def lookup_assoc_def(association)
87
+ conn = connector_by_xmi_id(association)
88
+ conn ? Ea::Rtf.to_text(conn.notes.to_s) : nil
89
+ end
90
+
91
+ def lookup_connector_def_by_associationclass(_association)
92
+ nil
93
+ end
94
+
95
+ def fetch_definition_node_value(link_id, node_name)
96
+ return unless node_name.to_s == "documentation"
97
+
98
+ conn = connector_by_xmi_id(link_id)
99
+ conn ? Ea::Rtf.to_text(conn.notes.to_s) : nil
100
+ end
101
+
102
+ # Dependency connectors whose supplier (end) or client (start)
103
+ # resolves to the given element xmi id.
104
+ def select_dependencies_by_supplier(supplier_id)
105
+ dependencies.select { |dep| dep.supplier == supplier_id }
106
+ end
107
+
108
+ def select_dependencies_by_client(client_id)
109
+ dependencies.select { |dep| dep.client == client_id }
110
+ end
111
+
112
+ # The parent (general) name behind a generalization link:
113
+ # the generalization connector's end object name.
114
+ def find_subtype_of_from_generalization(id)
115
+ conn = connector_by_xmi_id(id)
116
+ return nil unless conn&.generalization?
117
+
118
+ parent = @database.find_object(conn.end_object_id)
119
+ parent&.name
120
+ end
121
+
122
+ def find_subtype_of_from_owned_attribute_type(_id)
123
+ nil
124
+ end
125
+
126
+ # Stereotype lookups read the object's stored stereotype.
127
+ def doc_node_attribute_value(node_id, attr_name)
128
+ return nil unless attr_name.to_s == "stereotype"
129
+
130
+ object = object_by_xmi_id(node_id)
131
+ object&.stereotype
132
+ end
133
+
134
+ def lookup_attribute_documentation(_xmi_id)
135
+ nil
136
+ end
137
+
138
+ # The XMI-path links graph has no QEA equivalent.
139
+ def find_matched_element(_xmi_id)
140
+ nil
141
+ end
142
+
143
+ def xmi_root_model
144
+ nil
145
+ end
146
+
147
+ def xmi_index
148
+ self
149
+ end
150
+
151
+ private
152
+
153
+ attr_reader :database
154
+
155
+ def names
156
+ @names ||= begin
157
+ map = {}
158
+ database.objects.all.each do |object|
159
+ next unless object.ea_guid
160
+
161
+ map[Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid)] = object.name
162
+ end
163
+ database.packages.each do |package|
164
+ next unless package.ea_guid
165
+
166
+ map[Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid)] = package.name
167
+ end
168
+ map
169
+ end
170
+ end
171
+
172
+ def object_by_xmi_id(xmi_id)
173
+ database.objects.all.find do |object|
174
+ object.ea_guid &&
175
+ Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid) == xmi_id
176
+ end
177
+ end
178
+
179
+ def package_by_xmi_id(xmi_id)
180
+ database.packages.find do |package|
181
+ package.ea_guid &&
182
+ Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid) == xmi_id
183
+ end
184
+ end
185
+
186
+ def connector_by_xmi_id(xmi_id)
187
+ database.connectors.find do |conn|
188
+ conn.ea_guid &&
189
+ Ea::GuidFormat.ea_guid_to_xmi_id(conn.ea_guid) == xmi_id
190
+ end
191
+ end
192
+
193
+ def dependencies
194
+ database.connectors
195
+ .select { |c| c.connector_type == "Dependency" }
196
+ .map do |conn|
197
+ DependencyRef.new(
198
+ name: conn.name,
199
+ client: endpoint(conn.start_object_id)&.idref,
200
+ supplier: endpoint(conn.end_object_id)&.idref
201
+ )
202
+ end
203
+ end
204
+
205
+ def endpoint(object_id)
206
+ object = database.find_object(object_id)
207
+ return nil unless object&.ea_guid
208
+
209
+ Endpoint.new(idref: Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid))
210
+ end
211
+
212
+ def object_package_name(object)
213
+ package = database.find_package(object.package_id)
214
+ package&.name
215
+ end
216
+
217
+ def parent_name_for(package)
218
+ return nil unless package
219
+
220
+ parent = database.find_package(package.parent_id)
221
+ parent&.name
222
+ end
223
+
224
+ def documentation(notes)
225
+ return nil if notes.nil? || notes.empty?
226
+
227
+ Documentation.new(value: Ea::Rtf.to_text(notes.to_s))
228
+ end
229
+ end
230
+ end
231
+ end
232
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module Qea
5
+ # Ea-native lazy rendering (#278): build the Liquid klass-table
6
+ # drops' Lutaml::Uml objects per class, directly from the
7
+ # Ea::Qea::Database rows — no XMI materialization. Presents the
8
+ # LookupService-compatible contract the XMI-model-shaped drops
9
+ # consume, answered from the database indexes instead of a Sparx
10
+ # document graph.
11
+ module LazyDrops
12
+ autoload :QeaLookup, "ea/qea/lazy_drops/qea_lookup"
13
+
14
+ class << self
15
+ # Build a lazy drop context over a loaded database.
16
+ #
17
+ # @param database [Database] loaded QEA database
18
+ # @param guidance [Object, nil] guidance document for the drops
19
+ # @return [Context] the lazy per-class drop context
20
+ def for(database, guidance: nil)
21
+ require_uml!
22
+ Context.new(database, guidance)
23
+ end
24
+
25
+ private
26
+
27
+ def require_uml!
28
+ return if defined?(Lutaml::Uml::Document)
29
+
30
+ require "lutaml/uml"
31
+ rescue LoadError
32
+ raise Ea::Error,
33
+ "lutaml-uml is required for lazy drop construction."
34
+ end
35
+ end
36
+
37
+ # Per-class lazy construction context. Classes are built on
38
+ # first request and cached by their XMI id; packages are
39
+ # wrappers over the database indexes, not materialized trees.
40
+ class Context
41
+ attr_reader :database, :guidance, :lookup
42
+
43
+ def initialize(database, guidance = nil)
44
+ @database = database
45
+ @guidance = guidance
46
+ @klass_cache = {}
47
+ @lookup = QeaLookup.new(database)
48
+ @class_transformer = Factory::ClassTransformer.new(database)
49
+ @base = Factory::BaseTransformer.new(database)
50
+ end
51
+
52
+ # The drop-options contract shared by every drop: the QEA
53
+ # lookup answers the cross-reference surface; there is no
54
+ # xmi_root_model to walk (the drops tolerate its absence).
55
+ def drop_options
56
+ {
57
+ lookup: lookup,
58
+ with_gen: true,
59
+ with_absolute_path: true
60
+ }
61
+ end
62
+
63
+ # Build (or fetch the cached) UmlClass for one object row.
64
+ #
65
+ # @param ea_object_id [Integer] t_object.Object_ID
66
+ # @return [Lutaml::Uml::UmlClass, nil] nil for non-class rows
67
+ def klass_for(ea_object_id)
68
+ object = database.find_object(ea_object_id)
69
+ return nil unless object
70
+
71
+ xmi_id = object_xmi_id(object)
72
+ cache_hit = @klass_cache[xmi_id]
73
+ return cache_hit if cache_hit
74
+
75
+ klass = @class_transformer.transform(object)
76
+ @klass_cache[xmi_id] = klass if klass
77
+ klass
78
+ end
79
+
80
+ # All class-placed object ids on the database.
81
+ #
82
+ # @return [Array<Integer>] t_object ids whose rows are classes
83
+ def class_object_ids
84
+ database.objects.all.select(&:uml_class?).map(&:ea_object_id)
85
+ end
86
+
87
+ def object_xmi_id(object)
88
+ @base.normalize_guid_to_xmi_format(object.ea_guid, "EAID")
89
+ end
90
+
91
+ # The lookup facade the drops consume (LookupService-compatible
92
+ # surface over the database indexes).
93
+ def method_missing(name, ...)
94
+ lookup.respond_to?(name) ? lookup.public_send(name, ...) : super
95
+ end
96
+
97
+ def respond_to_missing?(name, include_private = false)
98
+ lookup.respond_to?(name, include_private)
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
data/lib/ea/qea.rb CHANGED
@@ -12,6 +12,7 @@ module Ea
12
12
  autoload :Database, "ea/qea/database"
13
13
  autoload :Repositories, "ea/qea/repositories"
14
14
  autoload :Benchmark, "ea/qea/benchmark"
15
+ autoload :LazyDrops, "ea/qea/lazy_drops"
15
16
  autoload :FileDetector, "ea/qea/file_detector"
16
17
 
17
18
  class << self
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.164"
7
+ VERSION = "0.6.165"
8
8
  end
data/lib/ea/xmi/slicer.rb CHANGED
@@ -13,19 +13,28 @@ module Ea
13
13
  # Ea graph costs 10+ GB of live objects.
14
14
  #
15
15
  # The closure is generic: every attribute value that looks like an EA
16
- # element id (EAID_/EAPK_/EAEM_) found anywhere inside a kept
16
+ # element id (EAID_/EAPK_/EAEM_/EAJava_) found anywhere inside a kept
17
17
  # element's subtree keeps the referenced element too, transitively -
18
18
  # no XMI semantics are encoded here. Only container tags are
19
- # membership-gated (packagedElement in the model, element and
20
- # connector in the extension); anything nested inside a kept
21
- # container is copied verbatim. The diagrams section is dropped.
19
+ # membership-gated (packagedElement in the model and in the
20
+ # extension's primitivetypes block, element and connector in the
21
+ # extension); anything nested inside a kept container is copied
22
+ # verbatim. The diagrams section is dropped.
23
+ #
24
+ # The extension's primitivetypes block carries EA's built-in
25
+ # primitive types (gml::LengthType, xs::string and friends) under
26
+ # EAJava_-prefixed ids; a model attribute's <type xmi:idref> points
27
+ # at one of them, so a kept attribute keeps its referenced primitive
28
+ # and the primitive's package wrappers. Dropping the block instead
29
+ # makes sliced parses resolve such attributes to the raw idref,
30
+ # diverging from the whole-load render.
22
31
  #
23
32
  # `slices` performs one index pass and one write pass and emits one
24
33
  # standalone slice per requested group, so each consumer (one macro,
25
34
  # one class table) hydrates only its own class's subgraph: the
26
35
  # per-parse peak is the size of one slice, not of the export.
27
36
  class Slicer
28
- EA_ID_RE = /\A(?:EAID|EAPK|EAEM)_[0-9A-Za-z_]+\z/
37
+ EA_ID_RE = /\A(?:EAID|EAPK|EAEM|EAJava)_[0-9A-Za-z_]+\z/
29
38
  private_constant :EA_ID_RE
30
39
 
31
40
  XML_DECL = %(<?xml version="1.0" encoding="UTF-8"?>\n)
@@ -46,11 +55,15 @@ module Ea
46
55
  # document section. umldi:Diagram carries the embedded diagram
47
56
  # shapes (tens of MB with waypoints and bounds in an EA export)
48
57
  # and is never referenced by table content, so it gates on the
49
- # keep set as well.
58
+ # keep set as well. The primitivetypes block carries EA's built-in
59
+ # primitive types, which model attributes reference by id; its
60
+ # entries gate on the keep set too, so only referenced ones are
61
+ # kept.
50
62
  GATED = {
51
63
  model: ["packagedElement", "umldi:Diagram"].freeze,
52
64
  elements: ["element"].freeze,
53
65
  connectors: ["connector"].freeze,
66
+ primitivetypes: ["packagedElement"].freeze,
54
67
  diagrams: ["diagram"].freeze
55
68
  }.freeze
56
69
  private_constant :GATED
@@ -58,8 +71,9 @@ module Ea
58
71
  SECTION_CHILD = {
59
72
  "elements" => :elements,
60
73
  "connectors" => :connectors,
61
- "diagrams" => :drop,
62
- "profiles" => :drop
74
+ "primitivetypes" => :primitivetypes,
75
+ "profiles" => :primitivetypes,
76
+ "diagrams" => :drop
63
77
  }.freeze
64
78
  private_constant :SECTION_CHILD
65
79
 
@@ -132,8 +146,9 @@ module Ea
132
146
  end
133
147
 
134
148
  # Only gated containers become nodes (packagedElement in the
135
- # model, element and connector in the extension, and the
136
- # embedded umldi:Diagram blocks). Other id-bearing elements -
149
+ # model and in the extension's primitivetypes block, element and
150
+ # connector in the extension, and the embedded umldi:Diagram
151
+ # blocks). Other id-bearing elements -
137
152
  # `<type xmi:idref>`, `<model package>` and the like - are pure
138
153
  # references: recording them as nodes would let a reference
139
154
  # define the element's ancestry, so their EA-id values flow into
@@ -263,8 +278,10 @@ module Ea
263
278
  keep[id] = true
264
279
  node.refs.each { |r| frontier << [r, false] }
265
280
  node.links_refs.each { |r| frontier << [r, true] }
266
- # keeping a model element keeps its package ancestry
267
- next unless node.section == :model
281
+ # keeping a model element keeps its package ancestry; a kept
282
+ # primitive keeps its EA_PrimitiveTypes_Package wrappers, so
283
+ # the writer's parent-key chain does not cut it off
284
+ next unless %i[model primitivetypes].include?(node.section)
268
285
 
269
286
  anc = nodes[node.parent_id]
270
287
  while anc && !keep[anc.id]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.164
4
+ version: 0.6.165
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-27 00:00:00.000000000 Z
11
+ date: 2026-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -81,33 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5'
83
83
  - !ruby/object:Gem::Dependency
84
- name: moxml
84
+ name: leptris
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.6'
89
+ version: '1.9'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.6'
96
+ version: '1.9'
97
97
  - !ruby/object:Gem::Dependency
98
- name: leptris
98
+ name: moxml
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.9'
103
+ version: '0.6'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.9'
110
+ version: '0.6'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: thor
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -361,6 +361,8 @@ files:
361
361
  - lib/ea/qea/infrastructure/database_connection.rb
362
362
  - lib/ea/qea/infrastructure/schema_reader.rb
363
363
  - lib/ea/qea/infrastructure/table_reader.rb
364
+ - lib/ea/qea/lazy_drops.rb
365
+ - lib/ea/qea/lazy_drops/qea_lookup.rb
364
366
  - lib/ea/qea/models.rb
365
367
  - lib/ea/qea/models/base_model.rb
366
368
  - lib/ea/qea/models/ea_attribute.rb