ea 0.6.186 → 0.6.187
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/qea_lookup.rb +8 -2
- data/lib/ea/qea/lazy_drops.rb +9 -5
- data/lib/ea/rules/tree_order.rb +9 -0
- data/lib/ea/transformers/qea_to_xmi/extension_serializer.rb +14 -2
- data/lib/ea/transformers/qea_to_xmi/transformer.rb +53 -0
- data/lib/ea/version.rb +1 -1
- data/lib/ea/xmi/parser.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: 6c53fbc9326d04b469bdb265f6eca87a7c6433bce0455206baf90103ed81946b
|
|
4
|
+
data.tar.gz: 3e21f4deef03073c48a0319c6c4f84a7e7450d9d1223d4ce5a70a72116bdf662
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b54c6ef65454ed9e51514f9d709524771250a996aa68ff8b5de0e67afae31807ebc555abcb30fed8af9a1b31ef9623c4b124773d3c8c5a786a41a4c5165e9195
|
|
7
|
+
data.tar.gz: 1369623845b994ec3ffb91c0866ffc7c0ed39c4467b888e7738ef57d2ce07e13357f88b5a314e8dc82870d90ae09cd123287ae1c2d374c529984d7ce491b02ef
|
|
@@ -103,7 +103,7 @@ module Ea
|
|
|
103
103
|
|
|
104
104
|
def lookup_assoc_def(association)
|
|
105
105
|
conn = connector_by_xmi_id(association)
|
|
106
|
-
conn ?
|
|
106
|
+
conn ? note_text(conn.notes) : nil
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def lookup_connector_def_by_associationclass(_association)
|
|
@@ -114,7 +114,7 @@ module Ea
|
|
|
114
114
|
return unless node_name.to_s == "documentation"
|
|
115
115
|
|
|
116
116
|
conn = connector_by_xmi_id(link_id)
|
|
117
|
-
conn ?
|
|
117
|
+
conn ? note_text(conn.notes) : nil
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
# Dependency connectors whose supplier (end) or client (start)
|
|
@@ -241,6 +241,12 @@ module Ea
|
|
|
241
241
|
|
|
242
242
|
Documentation.new(value: Ea::Rtf.to_text(notes.to_s))
|
|
243
243
|
end
|
|
244
|
+
|
|
245
|
+
# A connector's note as an association or role definition goes
|
|
246
|
+
# through the shared note rule, so both routes agree on it.
|
|
247
|
+
def note_text(notes)
|
|
248
|
+
Ea::Rules::NoteText.normalize(Ea::Rtf.to_text(notes.to_s))
|
|
249
|
+
end
|
|
244
250
|
end
|
|
245
251
|
end
|
|
246
252
|
end
|
data/lib/ea/qea/lazy_drops.rb
CHANGED
|
@@ -415,7 +415,7 @@ module Ea
|
|
|
415
415
|
# stand-ins carrying id/name — construction happens through
|
|
416
416
|
# the lazy id index.
|
|
417
417
|
class IndexShim
|
|
418
|
-
Record = Struct.new(:id, :name, :type, keyword_init: true)
|
|
418
|
+
Record = Struct.new(:id, :name, :type, :object, keyword_init: true)
|
|
419
419
|
|
|
420
420
|
MatchedElement = Struct.new(:id, :links, keyword_init: true)
|
|
421
421
|
LinksRef = Struct.new(:generalization, keyword_init: true)
|
|
@@ -427,10 +427,14 @@ module Ea
|
|
|
427
427
|
@parents = nil
|
|
428
428
|
end
|
|
429
429
|
|
|
430
|
+
# The same-named candidate EA's tree order offers first, as the
|
|
431
|
+
# XMI lookup's first document-order match does for an export.
|
|
430
432
|
def find_packaged_by_name_and_types(name, types)
|
|
431
|
-
types.filter_map { |type| packaged_elements_of_type(type) }
|
|
432
|
-
|
|
433
|
-
|
|
433
|
+
candidates = types.filter_map { |type| packaged_elements_of_type(type) }
|
|
434
|
+
.flatten
|
|
435
|
+
.select { |record| record.name == name }
|
|
436
|
+
resolved = Ea::Rules::TreeOrder.resolve(candidates.map(&:object))
|
|
437
|
+
candidates.find { |record| record.object.equal?(resolved) }
|
|
434
438
|
end
|
|
435
439
|
|
|
436
440
|
def packaged_elements_of_type(type)
|
|
@@ -488,7 +492,7 @@ module Ea
|
|
|
488
492
|
next unless object&.name
|
|
489
493
|
|
|
490
494
|
Record.new(id: @context.object_xmi_id(object), name: object.name,
|
|
491
|
-
type: type)
|
|
495
|
+
type: type, object: object)
|
|
492
496
|
end
|
|
493
497
|
end
|
|
494
498
|
|
data/lib/ea/rules/tree_order.rb
CHANGED
|
@@ -14,6 +14,15 @@ module Ea
|
|
|
14
14
|
def key(element)
|
|
15
15
|
[element.sort_position, element.name.to_s.downcase]
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
# The element a lookup offers first among same-named candidates:
|
|
19
|
+
# the one earliest in the project-tree order.
|
|
20
|
+
#
|
|
21
|
+
# @param candidates [Array<Models::EaObject, Models::EaPackage>] same-named rows
|
|
22
|
+
# @return [Models::EaObject, Models::EaPackage, nil] the first in tree order
|
|
23
|
+
def resolve(candidates)
|
|
24
|
+
candidates.min_by { |element| key(element) }
|
|
25
|
+
end
|
|
17
26
|
end
|
|
18
27
|
end
|
|
19
28
|
end
|
|
@@ -256,7 +256,10 @@ module Ea
|
|
|
256
256
|
# Classifier types that own attributes in their <attributes>
|
|
257
257
|
# extension block. Enumerations use <ownedLiteral> instead;
|
|
258
258
|
# InstanceSpecifications have no attributes.
|
|
259
|
-
|
|
259
|
+
# An enumeration's literals are t_attribute rows too; EA lists
|
|
260
|
+
# them in the element's <attributes> block with their notes.
|
|
261
|
+
ATTRIBUTE_OWNERS = %w[Class Interface DataType PrimitiveType
|
|
262
|
+
Enumeration].freeze
|
|
260
263
|
|
|
261
264
|
def attributes_block_for(obj)
|
|
262
265
|
return "" unless ATTRIBUTE_OWNERS.include?(obj.object_type)
|
|
@@ -503,7 +506,7 @@ module Ea
|
|
|
503
506
|
%(\t\t\t<properties ea_type="#{escape(ea_type)}" direction="Unspecified"/>),
|
|
504
507
|
"\t\t\t<modifiers isRoot=\"false\" isLeaf=\"false\"/>",
|
|
505
508
|
"\t\t\t<parameterSubstitutions/>",
|
|
506
|
-
|
|
509
|
+
connector_documentation(conn),
|
|
507
510
|
"\t\t\t<appearance linemode=\"3\" linecolor=\"-1\" linewidth=\"0\" " \
|
|
508
511
|
"seqno=\"0\" headStyle=\"0\" lineStyle=\"0\"/>",
|
|
509
512
|
"\t\t\t<extendedProperties virtualInheritance=\"0\"/>",
|
|
@@ -514,6 +517,15 @@ module Ea
|
|
|
514
517
|
"#{lines.join("\n")}\n"
|
|
515
518
|
end
|
|
516
519
|
|
|
520
|
+
# The connector's note is the definition of both its roles; a
|
|
521
|
+
# blank one keeps the empty element EA writes.
|
|
522
|
+
def connector_documentation(conn)
|
|
523
|
+
note = Ea::Rtf.to_text(conn.notes.to_s)
|
|
524
|
+
return "\t\t\t<documentation/>" if note.strip.empty?
|
|
525
|
+
|
|
526
|
+
%(\t\t\t<documentation value="#{escape(note)}"/>)
|
|
527
|
+
end
|
|
528
|
+
|
|
517
529
|
# ---- <xrefs> ----------------------------------------------------
|
|
518
530
|
|
|
519
531
|
# EA renders t_xref rows as a $XREFPROP mini-language string in
|
|
@@ -282,9 +282,21 @@ module Ea
|
|
|
282
282
|
preallocate_attribute_bounds(obj)
|
|
283
283
|
element = build_classifier(obj)
|
|
284
284
|
preallocate_end_bounds(obj)
|
|
285
|
+
attach_role_attributes(element, obj)
|
|
285
286
|
element
|
|
286
287
|
end
|
|
287
288
|
|
|
289
|
+
# The classifier-side role attributes are appended after the
|
|
290
|
+
# end bounds are allocated, so their bounds reuse the ids the
|
|
291
|
+
# Association's ends took and the literal counter keeps its order.
|
|
292
|
+
def attach_role_attributes(element, obj)
|
|
293
|
+
return unless emits_attributes?(obj)
|
|
294
|
+
|
|
295
|
+
roles = association_role_attributes(obj)
|
|
296
|
+
roles = roles.sort_by { |attr| attr.name.to_s.downcase } if obj.data_type?
|
|
297
|
+
element.owned_attribute = Array(element.owned_attribute) + roles
|
|
298
|
+
end
|
|
299
|
+
|
|
288
300
|
# EA allocates a classifier's attribute LI bounds in attribute
|
|
289
301
|
# NAME order, while the document emits attributes in Pos order.
|
|
290
302
|
# Pre-allocating here (memoized) makes the later Pos-ordered
|
|
@@ -493,6 +505,47 @@ module Ea
|
|
|
493
505
|
.map { |attr| build_attribute(attr) }
|
|
494
506
|
end
|
|
495
507
|
|
|
508
|
+
# A classifier lists its association-end roles after its own
|
|
509
|
+
# attributes, the way EA's export does: the end whose role belongs
|
|
510
|
+
# to the classifier, i.e. the destination end for the connector's
|
|
511
|
+
# source object and the source end for its target object (a
|
|
512
|
+
# reflexive connector lists its destination end once).
|
|
513
|
+
def association_role_attributes(obj)
|
|
514
|
+
@context.connectors_for(obj.ea_object_id).filter_map do |conn|
|
|
515
|
+
side = anchored_role_side(conn, obj.ea_object_id)
|
|
516
|
+
next unless side
|
|
517
|
+
next if role_name_for(conn, side).to_s.empty?
|
|
518
|
+
|
|
519
|
+
role_attribute(build_association_end(conn, side: side).model)
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def anchored_role_side(conn, object_id)
|
|
524
|
+
return unless RELATIONSHIP_AT_PACKAGE_LEVEL[conn.connector_type] == :association
|
|
525
|
+
|
|
526
|
+
if conn.start_object_id == object_id
|
|
527
|
+
:destination
|
|
528
|
+
elsif conn.end_object_id == object_id
|
|
529
|
+
:source
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
# The classifier-side copy of an association end: the same id, so
|
|
534
|
+
# the XMI reader pairs it with the end the Association carries.
|
|
535
|
+
def role_attribute(end_model)
|
|
536
|
+
::Xmi::Uml::OwnedAttribute.new(
|
|
537
|
+
type: "uml:Property",
|
|
538
|
+
id: end_model.id,
|
|
539
|
+
name: end_model.name,
|
|
540
|
+
visibility: end_model.visibility,
|
|
541
|
+
aggregation: end_model.aggregation,
|
|
542
|
+
association: end_model.association,
|
|
543
|
+
uml_type: end_model.uml_type,
|
|
544
|
+
upper_value: end_model.upper_value,
|
|
545
|
+
lower_value: end_model.lower_value
|
|
546
|
+
)
|
|
547
|
+
end
|
|
548
|
+
|
|
496
549
|
def operations_for(obj)
|
|
497
550
|
@context.sorted_by_position(@context.operations_for(obj.ea_object_id))
|
|
498
551
|
.map { |op| build_operation(op) }
|
data/lib/ea/version.rb
CHANGED
data/lib/ea/xmi/parser.rb
CHANGED
|
@@ -199,7 +199,7 @@ module Ea
|
|
|
199
199
|
|
|
200
200
|
def lookup_assoc_def(association)
|
|
201
201
|
connector = fetch_connector(association)
|
|
202
|
-
connector&.documentation&.value
|
|
202
|
+
Ea::Rules::NoteText.normalize(connector&.documentation&.value)
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
def lookup_connector_def_by_associationclass(association)
|