Module: Ea::Transformers::QeaToXmi::PrimitiveTypes
- Defined in:
- lib/ea/transformers/qea_to_xmi/primitive_types.rb
Overview
Owns the EAnone_ id shape and EA's EAnone_<name> PrimitiveType
definition, in table first-use order (attributes then operations
— verified to match the reference exports' ordering).
definition_id is also what the transformer's type REFERENCES
go through, so a reference and its definition normalize the name
identically and cannot end up as two different ids.
Names EA maps to OMG standard primitives are excluded on the attribute side only, and only when the classifier is blank, since that is the sole case where the attribute carries an href child instead of an idref.
KNOWN GAP: a non-blank classifier that resolves to nothing (a
numeric t_object id from a referenced model) still emits an
EAnone_ reference with no definition behind it. Defining those
here over-emits instead: this scan walks every row in the
database, including rows the package walk never exports, and EA's
own plateau export defines nothing for them. Closing it means
deriving definitions from the references the walk actually
emitted, which is its own change.
Constant Summary collapse
- HREF_NAMES =
EA primitive names that reference the OMG PrimitiveTypes library instead of a synthesized EAnone_ definition.
{ "int" => "Integer" }.freeze
- OMG_PRIMITIVES =
"http://www.omg.org/spec/UML/20110701/PrimitiveTypes.xmi"
Class Method Summary collapse
-
.attribute_names(database) ⇒ Object
An attribute reaches the OMG library through an href child only when it has no classifier to point at.
- .blank_classifier?(classifier) ⇒ Boolean
-
.definition_id(type_name) ⇒ String
The id EA gives a type name that has no classifier behind it.
-
.href_for(type, classifier) ⇒ String?
The OMG href replaces the EAnone_ idref only when there is no classifier to point at.
-
.normalize_name(type) ⇒ Object
EA type columns are free text; leading/trailing space is not part of the name.
-
.operation_names(database) ⇒ Object
Operation returns have no href mechanism — they reference EAnone_
directly, so every name they use must be defined here or the idref dangles. - .unresolved_name(type, classifier) ⇒ Object
-
.unresolved_names(database) ⇒ Array<String>
Distinct unresolved type names, first-use order.
Class Method Details
.attribute_names(database) ⇒ Object
An attribute reaches the OMG library through an href child only when it has no classifier to point at. One that names a classifier resolves against it instead, so it needs no definition here — see the KNOWN GAP above for the case where that classifier resolves to nothing.
49 50 51 52 53 54 55 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 49 def attribute_names(database) database.attributes.filter_map do |attr| next nil if href_for(attr.type, attr.classifier) unresolved_name(attr.type, attr.classifier) end end |
.blank_classifier?(classifier) ⇒ Boolean
98 99 100 101 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 98 def blank_classifier?(classifier) text = normalize_name(classifier) text.empty? || text == "0" end |
.definition_id(type_name) ⇒ String
The id EA gives a type name that has no classifier behind it. The reference and the definition both come from here, so they cannot normalize the name differently.
76 77 78 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 76 def definition_id(type_name) "EAnone_#{normalize_name(type_name)}" end |
.href_for(type, classifier) ⇒ String?
The OMG href replaces the EAnone_ idref only when there is no classifier to point at. Nil means "not an href target", so the definition side and the transformer read one expression rather than asking a predicate and then fetching what it proved.
91 92 93 94 95 96 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 91 def href_for(type, classifier) return nil unless blank_classifier?(classifier) target = HREF_NAMES[normalize_name(type)] target && "#{OMG_PRIMITIVES}##{target}" end |
.normalize_name(type) ⇒ Object
EA type columns are free text; leading/trailing space is not part of the name.
82 83 84 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 82 def normalize_name(type) type.to_s.strip end |
.operation_names(database) ⇒ Object
Operation returns have no href mechanism — they reference
EAnone_
60 61 62 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 60 def operation_names(database) database.operations.filter_map { |op| unresolved_name(op.type, op.classifier) } end |
.unresolved_name(type, classifier) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 64 def unresolved_name(type, classifier) name = normalize_name(type) return nil if name.empty? return nil unless blank_classifier?(classifier) name end |
.unresolved_names(database) ⇒ Array<String>
Returns distinct unresolved type names, first-use order.
40 41 42 |
# File 'lib/ea/transformers/qea_to_xmi/primitive_types.rb', line 40 def unresolved_names(database) (attribute_names(database) + operation_names(database)).uniq end |