ea 0.6.165 → 0.6.167
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 +358 -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: 5adeaa57c0343b644501c9413dfa0a3b1e3f220ab0924ab79dc8c89e0e396047
|
|
4
|
+
data.tar.gz: 3d1e06b23d4c4ea4bcdfa8b5b028183f18524975bcf19f9ed1c728a3407412a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1dae66ae0da9917a1b14bb67bbb492b945cf215d357c4f3b3c0753eeee3476444da8c7b0d31e4806e7d667161f3ecb760afb9e002ddecbab8ed909ef1bf1435
|
|
7
|
+
data.tar.gz: bce07ec117097f324e165203745d54f145835bfe1ae7885398b294186a85640fab402e3e792b24d007c42c001c62250c4e50baea42c52dc1acfc044e9cfacf92
|
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,43 @@ 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
|
+
require_uml!
|
|
40
|
+
database = Services::DatabaseLoader.new(qea_path).load
|
|
41
|
+
context = Context.new(database, guidance)
|
|
42
|
+
ParsedResult.new(
|
|
43
|
+
parser: context.parser,
|
|
44
|
+
xmi_id_index: context.xmi_id_index,
|
|
45
|
+
drop_options: context.drop_options
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Load a .qea file into the Loaded graph shape the table
|
|
50
|
+
# renders consume (parser, uml_document facade, drop options,
|
|
51
|
+
# lazy id index) — the .qea branch of the XMI load_graph.
|
|
52
|
+
#
|
|
53
|
+
# @param qea_path [String] path to the .qea file
|
|
54
|
+
# @param guidance [Object, nil] guidance document
|
|
55
|
+
# @return [LazyGraph]
|
|
56
|
+
def parsed_graph(qea_path, guidance: nil)
|
|
57
|
+
require_uml!
|
|
58
|
+
database = Services::DatabaseLoader.new(qea_path).load
|
|
59
|
+
context = Context.new(database, guidance)
|
|
60
|
+
LazyGraph.new(
|
|
61
|
+
parser: context.parser,
|
|
62
|
+
uml_document: LazyDocument.new(context),
|
|
63
|
+
drop_options: context.drop_options,
|
|
64
|
+
xmi_id_index: context.xmi_id_index
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
25
68
|
private
|
|
26
69
|
|
|
27
70
|
def require_uml!
|
|
@@ -97,6 +140,321 @@ module Ea
|
|
|
97
140
|
def respond_to_missing?(name, include_private = false)
|
|
98
141
|
lookup.respond_to?(name, include_private)
|
|
99
142
|
end
|
|
143
|
+
|
|
144
|
+
# The parse-level facade LookupService and the plugin's cache
|
|
145
|
+
# bind to: the root-model stand-in, the packaged-element index,
|
|
146
|
+
# and the whole cross-reference surface (QeaLookup).
|
|
147
|
+
def parser
|
|
148
|
+
@parser ||= ParserFacade.new(self)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# xmi_id -> Lutaml::Uml object, constructed on first access
|
|
152
|
+
# per id (classes, enumerations, data types).
|
|
153
|
+
def xmi_id_index
|
|
154
|
+
@xmi_id_index ||= LazyIdIndex.new(self)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# The packaged-element index shim: name/type lookups and
|
|
158
|
+
# parent walks over the database rows.
|
|
159
|
+
def xmi_index
|
|
160
|
+
@xmi_index ||= IndexShim.new(self)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Enum-placed / datatype-placed object rows.
|
|
164
|
+
def enum_object_ids
|
|
165
|
+
database.objects.all.select(&:enumeration?).map(&:ea_object_id)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def data_type_object_ids
|
|
169
|
+
database.objects.all.select(&:data_type?).map(&:ea_object_id)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def enum_for(ea_object_id)
|
|
173
|
+
object = database.find_object(ea_object_id)
|
|
174
|
+
object && Factory::EnumTransformer.new(database).transform(object)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def data_type_for(ea_object_id)
|
|
178
|
+
object = database.find_object(ea_object_id)
|
|
179
|
+
object && Factory::DataTypeTransformer.new(database).transform(object)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# The Loaded graph shape the table renders consume. Classes are
|
|
184
|
+
# constructed per package on demand and memoized on the
|
|
185
|
+
# context's caches; the database stays the single source.
|
|
186
|
+
class LazyGraph < Struct.new(:parser, :uml_document, :drop_options,
|
|
187
|
+
:xmi_id_index, keyword_init: true)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Document facade answering RootDrop's reads: name + packages.
|
|
191
|
+
class LazyDocument
|
|
192
|
+
def initialize(context)
|
|
193
|
+
@context = context
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def name
|
|
197
|
+
"EA Model"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def packages
|
|
201
|
+
@context.database.packages
|
|
202
|
+
.reject { |package| parent(package) }
|
|
203
|
+
.map { |package| LazyPackage.new(@context, package) }
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
private
|
|
207
|
+
|
|
208
|
+
def parent(package)
|
|
209
|
+
@context.database.find_package(package.parent_id)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Package facade over one t_package row: classes, enums, data
|
|
214
|
+
# types and child packages construct on demand.
|
|
215
|
+
class LazyPackage
|
|
216
|
+
def initialize(context, package)
|
|
217
|
+
@context = context
|
|
218
|
+
@package = package
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def name
|
|
222
|
+
@package.name
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def xmi_id
|
|
226
|
+
@package.ea_guid ? ea_id(@package.ea_guid) : nil
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def definition
|
|
230
|
+
@package.notes ? Ea::Rtf.to_text(@package.notes.to_s) : nil
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def stereotype
|
|
234
|
+
nil
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def classes
|
|
238
|
+
@context.database.objects_in_package(@package.package_id)
|
|
239
|
+
.select(&:uml_class?)
|
|
240
|
+
.map { |row| @context.klass_for(row.ea_object_id) }
|
|
241
|
+
.compact
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def enums
|
|
245
|
+
@context.database.objects_in_package(@package.package_id)
|
|
246
|
+
.select(&:enumeration?)
|
|
247
|
+
.filter_map { |row| @context.enum_for(row.ea_object_id) }
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def data_types
|
|
251
|
+
@context.database.objects_in_package(@package.package_id)
|
|
252
|
+
.select(&:data_type?)
|
|
253
|
+
.filter_map { |row| @context.data_type_for(row.ea_object_id) }
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def packages
|
|
257
|
+
@context.database.child_packages_for(@package.package_id)
|
|
258
|
+
.map { |row| LazyPackage.new(@context, row) }
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def diagrams
|
|
262
|
+
[]
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
private
|
|
266
|
+
|
|
267
|
+
def ea_id(guid)
|
|
268
|
+
Ea::GuidFormat.ea_guid_to_xmi_id(guid)
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Stand-in for the xmi gem's root model: the klass-table cache
|
|
273
|
+
# reads only its model name (to strip a leading path segment).
|
|
274
|
+
class RootModelFacade
|
|
275
|
+
Model = Struct.new(:name, keyword_init: true)
|
|
276
|
+
|
|
277
|
+
def model
|
|
278
|
+
Model.new(name: "EA Model")
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Parse-level facade: binds LookupService and the plugin's
|
|
283
|
+
# klass-table cache to the QEA lookups and the index shim.
|
|
284
|
+
class ParserFacade
|
|
285
|
+
def initialize(context)
|
|
286
|
+
@context = context
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def xmi_root_model
|
|
290
|
+
RootModelFacade.new
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def xmi_index
|
|
294
|
+
@context.xmi_index
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def doc_node_attribute_value(node_id, attr_name)
|
|
298
|
+
@context.doc_node_attribute_value(node_id, attr_name)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def lookup_entity_name(xmi_id)
|
|
302
|
+
@context.lookup_entity_name(xmi_id)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def lookup_attribute_documentation(xmi_id)
|
|
306
|
+
@context.lookup_attribute_documentation(xmi_id)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def find_upper_level_packaged_element(klass_id)
|
|
310
|
+
@context.find_upper_level_packaged_element(klass_id)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def find_matched_element(xmi_id)
|
|
314
|
+
@context.find_matched_element(xmi_id)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def fetch_connector(link_id)
|
|
318
|
+
@context.fetch_connector(link_id)
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def fetch_definition_node_value(link_id, node_name)
|
|
322
|
+
@context.fetch_definition_node_value(link_id, node_name)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def select_dependencies_by_supplier(supplier_id)
|
|
326
|
+
@context.select_dependencies_by_supplier(supplier_id)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def select_dependencies_by_client(client_id)
|
|
330
|
+
@context.select_dependencies_by_client(client_id)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def lookup_assoc_def(association)
|
|
334
|
+
@context.lookup_assoc_def(association)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def lookup_connector_def_by_associationclass(association)
|
|
338
|
+
@context.lookup_connector_def_by_associationclass(association)
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
# Packaged-element index shim: name/type lookups and parent
|
|
343
|
+
# walks over the database rows. Records are lightweight
|
|
344
|
+
# stand-ins carrying id/name — construction happens through
|
|
345
|
+
# the lazy id index.
|
|
346
|
+
class IndexShim
|
|
347
|
+
Record = Struct.new(:id, :name, :type, keyword_init: true)
|
|
348
|
+
|
|
349
|
+
def initialize(context)
|
|
350
|
+
@context = context
|
|
351
|
+
@by_type = nil
|
|
352
|
+
@parents = nil
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def find_packaged_by_name_and_types(name, types)
|
|
356
|
+
types.filter_map { |type| packaged_elements_of_type(type) }
|
|
357
|
+
.flatten
|
|
358
|
+
.find { |record| record.name == name }
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def packaged_elements_of_type(type)
|
|
362
|
+
by_type[type] || []
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def find_parent(id)
|
|
366
|
+
parents[id]
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
private
|
|
370
|
+
|
|
371
|
+
def by_type
|
|
372
|
+
@by_type ||= {
|
|
373
|
+
"uml:Class" => records_for(@context.class_object_ids, "uml:Class"),
|
|
374
|
+
"uml:AssociationClass" => [],
|
|
375
|
+
"uml:Enumeration" => records_for(@context.enum_object_ids,
|
|
376
|
+
"uml:Enumeration"),
|
|
377
|
+
"uml:DataType" => records_for(@context.data_type_object_ids,
|
|
378
|
+
"uml:DataType")
|
|
379
|
+
}.freeze
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def records_for(object_ids, type)
|
|
383
|
+
object_ids.filter_map do |id|
|
|
384
|
+
object = @context.database.find_object(id)
|
|
385
|
+
next unless object&.name
|
|
386
|
+
|
|
387
|
+
Record.new(id: @context.object_xmi_id(object), name: object.name,
|
|
388
|
+
type: type)
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def parents
|
|
393
|
+
@parents ||= begin
|
|
394
|
+
map = {}
|
|
395
|
+
@context.database.objects.all.each do |object|
|
|
396
|
+
next unless object.ea_guid
|
|
397
|
+
|
|
398
|
+
id = Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid)
|
|
399
|
+
package = @context.database.find_package(object.package_id)
|
|
400
|
+
next unless package&.ea_guid
|
|
401
|
+
|
|
402
|
+
map[id] = Record.new(
|
|
403
|
+
id: Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid),
|
|
404
|
+
name: package.name, type: "uml:Package"
|
|
405
|
+
)
|
|
406
|
+
end
|
|
407
|
+
@context.database.packages.each do |package|
|
|
408
|
+
next unless package.ea_guid
|
|
409
|
+
|
|
410
|
+
id = Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid)
|
|
411
|
+
parent = @context.database.find_package(package.parent_id)
|
|
412
|
+
next unless parent&.ea_guid
|
|
413
|
+
|
|
414
|
+
map[id] = Record.new(
|
|
415
|
+
id: Ea::GuidFormat.ea_guid_to_xmi_id(parent.ea_guid),
|
|
416
|
+
name: parent.name, type: "uml:Package"
|
|
417
|
+
)
|
|
418
|
+
end
|
|
419
|
+
map
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
# xmi_id -> Lutaml::Uml object, constructed on first access.
|
|
425
|
+
# Dispatches on which database entity owns the id.
|
|
426
|
+
class LazyIdIndex
|
|
427
|
+
def initialize(context)
|
|
428
|
+
@context = context
|
|
429
|
+
@built = {}
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def [](xmi_id)
|
|
433
|
+
@built[xmi_id] ||= build(xmi_id)
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
private
|
|
437
|
+
|
|
438
|
+
def build(xmi_id)
|
|
439
|
+
context = @context
|
|
440
|
+
database = context.database
|
|
441
|
+
|
|
442
|
+
database.objects.all.each do |object|
|
|
443
|
+
next unless object.ea_guid
|
|
444
|
+
|
|
445
|
+
next unless Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid) == xmi_id
|
|
446
|
+
|
|
447
|
+
return case object
|
|
448
|
+
when ->(o) { o.uml_class? || o.interface? }
|
|
449
|
+
context.klass_for(object.ea_object_id)
|
|
450
|
+
when lambda(&:enumeration?)
|
|
451
|
+
context.enum_for(object.ea_object_id)
|
|
452
|
+
when lambda(&:data_type?)
|
|
453
|
+
context.data_type_for(object.ea_object_id)
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
nil
|
|
457
|
+
end
|
|
100
458
|
end
|
|
101
459
|
end
|
|
102
460
|
end
|
data/lib/ea/version.rb
CHANGED