Class: Lutaml::Qea::Factory::GeneralizationTransformer

Inherits:
BaseTransformer show all
Defined in:
lib/lutaml/qea/factory/generalization_transformer.rb

Overview

Transforms EA connectors (Generalization type) to UML generalizations

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_connector, current_object) ⇒ Lutaml::Uml::Generalization

Transform EA connector to UML generalization EA connector model (nil for terminal nodes) Current object that owns this generalization

Parameters:

  • ea_connector (EaConnector, nil)
  • current_object (EaObject)

Returns:



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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/lutaml/qea/factory/generalization_transformer.rb', line 17

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

  # ea_connector can be nil for terminal nodes (classes with no parent)
  if ea_connector && !ea_connector.generalization?
    return nil
  end

  Lutaml::Uml::Generalization.new.tap do |gen| # rubocop:disable Metrics/BlockLength
    # Map properties from CURRENT object (not parent)
    # This matches XMI's self-referential pattern
    gen.general_id = normalize_guid_to_xmi_format(
      current_object.ea_guid, "EAID"
    )
    gen.general_name = current_object.name
    gen.name = current_object.name
    gen.type = "uml:Generalization"

    # Map definition from ea_connector notes
    if !ea_connector&.notes.nil? && !ea_connector&.notes&.empty?
      gen.definition = normalize_line_endings(ea_connector.notes)
    end

    # Map stereotype from current object
    gen.stereotype = current_object.stereotype unless
      current_object.stereotype.nil? || current_object.stereotype.empty?

    # Find the package/upper class for the current object
    if current_object.package_id
      current_package = find_package(current_object.package_id)
      if current_package
        gen.general_upper_klass =
          extract_package_prefix(current_package)
      end
    end

    # Set has_general flag based on whether parent exists
    # Use false (not nil) for terminal nodes to match XMI behavior
    gen.has_general = if ea_connector
                        !ea_connector.end_object_id.nil?
                      else
                        false
                      end

    # Note: general_attributes, attributes, owned_props, assoc_props,
    # general, inherited_props, inherited_assoc_props
    # will be populated in ClassTransformer.load_generalization
  end
end