ea 0.6.165 → 0.6.166
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/ea/qea/lazy_drops.rb +249 -0
- data/lib/ea/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d3b5c25645d2ed2dc0bcddd625248daccabfb66bb000a0dcce9642ad8379fba
|
|
4
|
+
data.tar.gz: 27e44f5862d326cd6a73626314a4dc03fd3e1929b1242063db9b0d2dd2d9530b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b79815ca68958510bfacbbb0b23e1fa1b96494f6d3b754d47724af0bc3dc674e1c1deae176202fd41681c4ce163b993eec01d6637af83cc19e5d48ec43967b37
|
|
7
|
+
data.tar.gz: 10f1424d27e83baa36ee4d1624075585a5f560085b8cb3a55e5a264c21dd756a3317dec9a43ca8035cc67a62541985bb8375d4a8f227a84c1869d681d8ec3960
|
data/lib/ea/qea/lazy_drops.rb
CHANGED
|
@@ -11,6 +11,12 @@ module Ea
|
|
|
11
11
|
module LazyDrops
|
|
12
12
|
autoload :QeaLookup, "ea/qea/lazy_drops/qea_lookup"
|
|
13
13
|
|
|
14
|
+
# The parsed-source contract the plugin's klass-table cache
|
|
15
|
+
# consumes: parser (model name + index), the lazy id index, and
|
|
16
|
+
# the drop options.
|
|
17
|
+
ParsedResult = Struct.new(:parser, :xmi_id_index, :drop_options,
|
|
18
|
+
keyword_init: true)
|
|
19
|
+
|
|
14
20
|
class << self
|
|
15
21
|
# Build a lazy drop context over a loaded database.
|
|
16
22
|
#
|
|
@@ -22,6 +28,23 @@ module Ea
|
|
|
22
28
|
Context.new(database, guidance)
|
|
23
29
|
end
|
|
24
30
|
|
|
31
|
+
# Load a .qea file and return the parsed-source shape the
|
|
32
|
+
# plugin's klass-table cache consumes — the .qea replacement
|
|
33
|
+
# for the XMI parse pipeline, with no graph materialization.
|
|
34
|
+
#
|
|
35
|
+
# @param qea_path [String] path to the .qea file
|
|
36
|
+
# @param guidance [Object, nil] guidance document
|
|
37
|
+
# @return [ParsedResult]
|
|
38
|
+
def parsed(qea_path, guidance: nil)
|
|
39
|
+
database = Services::DatabaseLoader.new(qea_path).load
|
|
40
|
+
context = Context.new(database, guidance)
|
|
41
|
+
ParsedResult.new(
|
|
42
|
+
parser: context.parser,
|
|
43
|
+
xmi_id_index: context.xmi_id_index,
|
|
44
|
+
drop_options: context.drop_options
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
25
48
|
private
|
|
26
49
|
|
|
27
50
|
def require_uml!
|
|
@@ -97,6 +120,232 @@ module Ea
|
|
|
97
120
|
def respond_to_missing?(name, include_private = false)
|
|
98
121
|
lookup.respond_to?(name, include_private)
|
|
99
122
|
end
|
|
123
|
+
|
|
124
|
+
# The parse-level facade LookupService and the plugin's cache
|
|
125
|
+
# bind to: the root-model stand-in, the packaged-element index,
|
|
126
|
+
# and the whole cross-reference surface (QeaLookup).
|
|
127
|
+
def parser
|
|
128
|
+
@parser ||= ParserFacade.new(self)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# xmi_id -> Lutaml::Uml object, constructed on first access
|
|
132
|
+
# per id (classes, enumerations, data types).
|
|
133
|
+
def xmi_id_index
|
|
134
|
+
@xmi_id_index ||= LazyIdIndex.new(self)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# The packaged-element index shim: name/type lookups and
|
|
138
|
+
# parent walks over the database rows.
|
|
139
|
+
def xmi_index
|
|
140
|
+
@xmi_index ||= IndexShim.new(self)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Enum-placed / datatype-placed object rows.
|
|
144
|
+
def enum_object_ids
|
|
145
|
+
database.objects.all.select(&:enumeration?).map(&:ea_object_id)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def data_type_object_ids
|
|
149
|
+
database.objects.all.select(&:data_type?).map(&:ea_object_id)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def enum_for(ea_object_id)
|
|
153
|
+
object = database.find_object(ea_object_id)
|
|
154
|
+
object && Factory::EnumTransformer.new(database).transform(object)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def data_type_for(ea_object_id)
|
|
158
|
+
object = database.find_object(ea_object_id)
|
|
159
|
+
object && Factory::DataTypeTransformer.new(database).transform(object)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Stand-in for the xmi gem's root model: the klass-table cache
|
|
164
|
+
# reads only its model name (to strip a leading path segment).
|
|
165
|
+
class RootModelFacade
|
|
166
|
+
Model = Struct.new(:name, keyword_init: true)
|
|
167
|
+
|
|
168
|
+
def model
|
|
169
|
+
Model.new(name: "EA Model")
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Parse-level facade: binds LookupService and the plugin's
|
|
174
|
+
# klass-table cache to the QEA lookups and the index shim.
|
|
175
|
+
class ParserFacade
|
|
176
|
+
def initialize(context)
|
|
177
|
+
@context = context
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def xmi_root_model
|
|
181
|
+
RootModelFacade.new
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def xmi_index
|
|
185
|
+
@context.xmi_index
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def doc_node_attribute_value(node_id, attr_name)
|
|
189
|
+
@context.doc_node_attribute_value(node_id, attr_name)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def lookup_entity_name(xmi_id)
|
|
193
|
+
@context.lookup_entity_name(xmi_id)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def lookup_attribute_documentation(xmi_id)
|
|
197
|
+
@context.lookup_attribute_documentation(xmi_id)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def find_upper_level_packaged_element(klass_id)
|
|
201
|
+
@context.find_upper_level_packaged_element(klass_id)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def find_matched_element(xmi_id)
|
|
205
|
+
@context.find_matched_element(xmi_id)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def fetch_connector(link_id)
|
|
209
|
+
@context.fetch_connector(link_id)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def fetch_definition_node_value(link_id, node_name)
|
|
213
|
+
@context.fetch_definition_node_value(link_id, node_name)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def select_dependencies_by_supplier(supplier_id)
|
|
217
|
+
@context.select_dependencies_by_supplier(supplier_id)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def select_dependencies_by_client(client_id)
|
|
221
|
+
@context.select_dependencies_by_client(client_id)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def lookup_assoc_def(association)
|
|
225
|
+
@context.lookup_assoc_def(association)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def lookup_connector_def_by_associationclass(association)
|
|
229
|
+
@context.lookup_connector_def_by_associationclass(association)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Packaged-element index shim: name/type lookups and parent
|
|
234
|
+
# walks over the database rows. Records are lightweight
|
|
235
|
+
# stand-ins carrying id/name — construction happens through
|
|
236
|
+
# the lazy id index.
|
|
237
|
+
class IndexShim
|
|
238
|
+
Record = Struct.new(:id, :name, :type, keyword_init: true)
|
|
239
|
+
|
|
240
|
+
def initialize(context)
|
|
241
|
+
@context = context
|
|
242
|
+
@by_type = nil
|
|
243
|
+
@parents = nil
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def find_packaged_by_name_and_types(name, types)
|
|
247
|
+
types.filter_map { |type| packaged_elements_of_type(type) }
|
|
248
|
+
.flatten
|
|
249
|
+
.find { |record| record.name == name }
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def packaged_elements_of_type(type)
|
|
253
|
+
by_type[type] || []
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def find_parent(id)
|
|
257
|
+
parents[id]
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
private
|
|
261
|
+
|
|
262
|
+
def by_type
|
|
263
|
+
@by_type ||= {
|
|
264
|
+
"uml:Class" => records_for(@context.class_object_ids, "uml:Class"),
|
|
265
|
+
"uml:AssociationClass" => [],
|
|
266
|
+
"uml:Enumeration" => records_for(@context.enum_object_ids,
|
|
267
|
+
"uml:Enumeration"),
|
|
268
|
+
"uml:DataType" => records_for(@context.data_type_object_ids,
|
|
269
|
+
"uml:DataType")
|
|
270
|
+
}.freeze
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def records_for(object_ids, type)
|
|
274
|
+
object_ids.filter_map do |id|
|
|
275
|
+
object = @context.database.find_object(id)
|
|
276
|
+
next unless object&.name
|
|
277
|
+
|
|
278
|
+
Record.new(id: @context.object_xmi_id(object), name: object.name,
|
|
279
|
+
type: type)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def parents
|
|
284
|
+
@parents ||= begin
|
|
285
|
+
map = {}
|
|
286
|
+
@context.database.objects.all.each do |object|
|
|
287
|
+
next unless object.ea_guid
|
|
288
|
+
|
|
289
|
+
id = Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid)
|
|
290
|
+
package = @context.database.find_package(object.package_id)
|
|
291
|
+
next unless package&.ea_guid
|
|
292
|
+
|
|
293
|
+
map[id] = Record.new(
|
|
294
|
+
id: Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid),
|
|
295
|
+
name: package.name, type: "uml:Package"
|
|
296
|
+
)
|
|
297
|
+
end
|
|
298
|
+
@context.database.packages.each do |package|
|
|
299
|
+
next unless package.ea_guid
|
|
300
|
+
|
|
301
|
+
id = Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid)
|
|
302
|
+
parent = @context.database.find_package(package.parent_id)
|
|
303
|
+
next unless parent&.ea_guid
|
|
304
|
+
|
|
305
|
+
map[id] = Record.new(
|
|
306
|
+
id: Ea::GuidFormat.ea_guid_to_xmi_id(parent.ea_guid),
|
|
307
|
+
name: parent.name, type: "uml:Package"
|
|
308
|
+
)
|
|
309
|
+
end
|
|
310
|
+
map
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# xmi_id -> Lutaml::Uml object, constructed on first access.
|
|
316
|
+
# Dispatches on which database entity owns the id.
|
|
317
|
+
class LazyIdIndex
|
|
318
|
+
def initialize(context)
|
|
319
|
+
@context = context
|
|
320
|
+
@built = {}
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def [](xmi_id)
|
|
324
|
+
@built[xmi_id] ||= build(xmi_id)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
private
|
|
328
|
+
|
|
329
|
+
def build(xmi_id)
|
|
330
|
+
context = @context
|
|
331
|
+
database = context.database
|
|
332
|
+
|
|
333
|
+
database.objects.all.each do |object|
|
|
334
|
+
next unless object.ea_guid
|
|
335
|
+
|
|
336
|
+
next unless Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid) == xmi_id
|
|
337
|
+
|
|
338
|
+
return case object
|
|
339
|
+
when ->(o) { o.uml_class? || o.interface? }
|
|
340
|
+
context.klass_for(object.ea_object_id)
|
|
341
|
+
when lambda(&:enumeration?)
|
|
342
|
+
context.enum_for(object.ea_object_id)
|
|
343
|
+
when lambda(&:data_type?)
|
|
344
|
+
context.data_type_for(object.ea_object_id)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
nil
|
|
348
|
+
end
|
|
100
349
|
end
|
|
101
350
|
end
|
|
102
351
|
end
|
data/lib/ea/version.rb
CHANGED