Class: Lutaml::Qea::Factory::AttributeTransformer

Inherits:
BaseTransformer show all
Defined in:
lib/lutaml/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

#initialize, #transform_collection

Constructor Details

This class inherits a constructor from Lutaml::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:



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
45
46
47
48
# File 'lib/lutaml/qea/factory/attribute_transformer.rb', line 15

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