Class: Ea::Qea::Factory::AttributeTransformer

Inherits:
BaseTransformer show all
Defined in:
lib/ea/qea/factory/attribute_transformer.rb

Overview

Transforms EA attributes to UML attributes

Instance Attribute Summary

Attributes inherited from BaseTransformer

#database

Instance Method Summary collapse

Methods inherited from BaseTransformer

#find_object_by_id, #initialize, #load_attributes, #load_constraints, #load_object_properties, #load_operations, #load_tagged_values, #map_visibility, #normalize_guid_to_xmi_format, #normalize_guid_to_xmi_src_dst_format, #normalize_line_endings, #parse_cardinality, #to_boolean, #transform_collection

Constructor Details

This class inherits a constructor from Ea::Qea::Factory::BaseTransformer

Instance Method Details

#transform(ea_attribute) ⇒ Lutaml::Uml::TopElementAttribute

Transform EA attribute to UML attribute

Parameters:

  • ea_attribute (EaAttribute)

    EA attribute model

Returns:

  • (Lutaml::Uml::TopElementAttribute)

    UML attribute



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ea/qea/factory/attribute_transformer.rb', line 11

def transform(ea_attribute) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
  return nil if ea_attribute.nil?

  Lutaml::Uml::TopElementAttribute.new.tap do |attr|
    attr.name = ea_attribute.name
    attr.type = ea_attribute.type
    attr.visibility = map_visibility(ea_attribute.scope)

    # XMI uses the TYPE's XMI ID, not the attribute's ID
    type_xmi_id = lookup_type_xmi_id(ea_attribute.classifier)
    attr.xmi_id = type_xmi_id || normalize_guid_to_xmi_format(
      ea_attribute.ea_guid, "EAID"
    )

    attr.id = normalize_guid_to_xmi_format(ea_attribute.ea_guid, "EAID")
    attr.static = ea_attribute.static? ? "true" : nil
    attr.is_derived = ea_attribute.derived == "1"

    # Map cardinality if bounds are present
    if ea_attribute.lowerbound || ea_attribute.upperbound
      attr.cardinality = build_cardinality(
        ea_attribute.lowerbound,
        ea_attribute.upperbound,
      )
    end

    # Map definition/notes
    attr.definition = normalize_line_endings(ea_attribute.notes) unless
      ea_attribute.notes.nil? || ea_attribute.notes.empty?

    # Load and transform attribute tags
    attr.tagged_values = load_attribute_tags(ea_attribute.id)
  end
end