ea 0.6.177 → 0.6.178

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: 2b64a1978bc6e836dc911f991400e4b27bce6c6b172d9e061a6aa23e32bdabf0
4
- data.tar.gz: 315822317e8802a247b4dad639a1ccc7c3647d1efcab28e70b38d87685815fcb
3
+ metadata.gz: 33721c4a6706ca5ed8c43f9f73ecfa0a1fdd83294a259f880c0b95b1c5ffd2fb
4
+ data.tar.gz: b3880c8d7ed52f051476795b417ca9891c5cdf829d17728b7aae7c6a706da06f
5
5
  SHA512:
6
- metadata.gz: f1ad82a19fe4aa8904170f4b43d54f6afa206db43600599c94d0e31ec667290204075a03e460c596dfc68f71b58282a590018afd5bd14ab90a7e5436f395a36c
7
- data.tar.gz: 9f0e6958156d45c3d8d1078c624b9264c74aea29f35b47bd59c37d03289ddbbd84900e47863e30a9eacc27ddee5649466b409cb6c8d5bc25666c3a955ba6db37
6
+ metadata.gz: b1e536f9a683b1370df3c3f1100d1cc54a4f0d96876e3baab517c7f343ec9b32044e7ba8e54cf5e3c93a91b853e018ac735a2084596b12a056d2a48c88d9d7e0
7
+ data.tar.gz: 3a57d6ed29830e351f0f7e2cb097122b4ecbb2a24d90e08585112d37f6517897aa24f43d2c2cfca4d74500301e9d70c36ce3b0b6a2f2f9151766dc6a2343ee07
@@ -22,12 +22,16 @@ module Ea
22
22
  end
23
23
  end
24
24
 
25
- Endpoint = Struct.new(:idref, keyword_init: true)
26
-
27
25
  # Read-only dependency reference exposing the name/client/
28
26
  # supplier surface DependencyDrop consumes.
29
27
  DependencyRef = Struct.new(:name, :client, :supplier, keyword_init: true)
30
28
 
29
+ # Chain-iterable package reference for KlassDrop#absolute_path:
30
+ # each hop exposes the id the next hop resolves plus the name
31
+ # the path accumulates, mirroring the Sparx packaged-element
32
+ # wrapper the XMI-shaped LookupService returns.
33
+ ParentElement = Struct.new(:id, :name, keyword_init: true)
34
+
31
35
  def initialize(database)
32
36
  @database = database
33
37
  @names = nil
@@ -42,13 +46,17 @@ module Ea
42
46
  names[xmi_id]
43
47
  end
44
48
 
45
- # The name of the package directly containing the element.
49
+ # The package directly containing the element, as a
50
+ # chain-iterable reference: KlassDrop#absolute_path feeds the
51
+ # returned id back in to walk the full package ancestry.
46
52
  def find_upper_level_packaged_element(klass_id)
47
- object = object_by_xmi_id(klass_id)
48
- return object_package_name(object) if object
53
+ package = parent_package_of(klass_id)
54
+ return nil unless package&.ea_guid
49
55
 
50
- package = package_by_xmi_id(klass_id)
51
- parent_name_for(package)
56
+ ParentElement.new(
57
+ id: Ea::GuidFormat.ea_guid_to_xmi_id(package.ea_guid),
58
+ name: package.name
59
+ )
52
60
  end
53
61
 
54
62
  def find_packaged_element_by_id(_id)
@@ -67,6 +75,16 @@ module Ea
67
75
  package&.name
68
76
  end
69
77
 
78
+ def parent_package_of(id)
79
+ object = object_by_xmi_id(id)
80
+ if object
81
+ database.find_package(object.package_id)
82
+ else
83
+ package = package_by_xmi_id(id)
84
+ package && database.find_package(package.parent_id)
85
+ end
86
+ end
87
+
70
88
  # Sparx-shaped connector reference for the drop surface.
71
89
  def fetch_connector(link_id)
72
90
  conn = database.connectors.find do |c|
@@ -148,6 +166,10 @@ module Ea
148
166
  self
149
167
  end
150
168
 
169
+ def object_by_xmi_id(xmi_id)
170
+ database.find_object_by_guid(Ea::GuidFormat.xmi_id_to_ea_guid(xmi_id))
171
+ end
172
+
151
173
  private
152
174
 
153
175
  attr_reader :database
@@ -169,13 +191,6 @@ module Ea
169
191
  end
170
192
  end
171
193
 
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
194
  def package_by_xmi_id(xmi_id)
180
195
  database.packages.find do |package|
181
196
  package.ea_guid &&
@@ -108,11 +108,14 @@ module Ea
108
108
  end
109
109
 
110
110
  # The drop-options contract shared by every drop: the QEA
111
- # lookup answers the cross-reference surface; there is no
112
- # xmi_root_model to walk (the drops tolerate its absence).
111
+ # lookup answers the cross-reference surface; the root-model
112
+ # stand-in carries the EA XMI export root name so
113
+ # KlassDrop#absolute_path reproduces the path shape the
114
+ # guidance files pin classes by.
113
115
  def drop_options
114
116
  {
115
117
  lookup: lookup,
118
+ xmi_root_model: RootModelFacade.new,
116
119
  with_gen: true,
117
120
  with_absolute_path: true
118
121
  }
@@ -303,11 +306,15 @@ module Ea
303
306
 
304
307
  # Stand-in for the xmi gem's root model: the klass-table cache
305
308
  # reads only its model name (to strip a leading path segment).
309
+ # The name must match the EA XMI export convention ("EA_Model"),
310
+ # because guidance files pin classes by the absolute path the
311
+ # XMI-shaped drops produce - e.g.
312
+ # "::EA_Model::Model::CityGML::Building::Building".
306
313
  class RootModelFacade
307
314
  Model = Struct.new(:name, keyword_init: true)
308
315
 
309
316
  def model
310
- Model.new(name: "EA Model")
317
+ Model.new(name: "EA_Model")
311
318
  end
312
319
  end
313
320
 
@@ -378,6 +385,10 @@ module Ea
378
385
  class IndexShim
379
386
  Record = Struct.new(:id, :name, :type, keyword_init: true)
380
387
 
388
+ MatchedElement = Struct.new(:id, :links, keyword_init: true)
389
+ LinksRef = Struct.new(:generalization, keyword_init: true)
390
+ GeneralizationRef = Struct.new(:id, :start, :end, keyword_init: true)
391
+
381
392
  def initialize(context)
382
393
  @context = context
383
394
  @by_type = nil
@@ -398,6 +409,34 @@ module Ea
398
409
  parents[id]
399
410
  end
400
411
 
412
+ # The links-bearing element record LookupService#find_matched_element
413
+ # consumes: KlassDrop#extract_inheritance_ids walks links.generalization
414
+ # entries (id / start / end) and keeps those whose end is the model
415
+ # itself, mirroring the xmi:Extension element-entry <links> shape where
416
+ # each entry restates every relation touching the element with
417
+ # start = child, end = parent.
418
+ def find_element(xmi_id)
419
+ object = @context.lookup.object_by_xmi_id(xmi_id)
420
+ return nil unless object
421
+
422
+ generalizations =
423
+ @context.database.connectors_for_object(object.ea_object_id)
424
+ .filter_map do |conn|
425
+ next unless conn.connector_type == "Generalization"
426
+
427
+ GeneralizationRef.new(
428
+ id: xmi_id_for_guid(conn.ea_guid),
429
+ start: object_xmi_id_for(conn.start_object_id),
430
+ end: object_xmi_id_for(conn.end_object_id)
431
+ )
432
+ end
433
+ .compact
434
+ MatchedElement.new(
435
+ id: xmi_id,
436
+ links: [LinksRef.new(generalization: generalizations)]
437
+ )
438
+ end
439
+
401
440
  private
402
441
 
403
442
  def by_type
@@ -451,6 +490,19 @@ module Ea
451
490
  map
452
491
  end
453
492
  end
493
+
494
+ def xmi_id_for_guid(guid)
495
+ return nil unless guid
496
+
497
+ Ea::GuidFormat.ea_guid_to_xmi_id(guid)
498
+ end
499
+
500
+ def object_xmi_id_for(ea_object_id)
501
+ object = ea_object_id && @context.database.find_object(ea_object_id)
502
+ return nil unless object&.ea_guid
503
+
504
+ Ea::GuidFormat.ea_guid_to_xmi_id(object.ea_guid)
505
+ end
454
506
  end
455
507
 
456
508
  # xmi_id -> Lutaml::Uml object, constructed on first access.
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.177".freeze
7
+ VERSION = "0.6.178".freeze
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.177
4
+ version: 0.6.178
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.