Class: Lutaml::Qea::Factory::PackageTransformer

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

Overview

Transforms EA packages to UML packages

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_package) ⇒ Lutaml::Uml::Package

Transform EA package to UML package

Parameters:

  • ea_package (EaPackage)

    EA package model

Returns:



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
# File 'lib/lutaml/qea/factory/package_transformer.rb', line 16

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

  Lutaml::Uml::Package.new.tap do |pkg|
    # Map basic properties
    pkg.name = ea_package.name
    pkg.xmi_id = normalize_guid_to_xmi_format(ea_package.ea_guid,
                                              "EAPK")

    # Map definition/notes
    pkg.definition = ea_package.notes unless
      ea_package.notes.nil? || ea_package.notes.empty?

    # Load and transform tagged values
    # TODO: Fix tagged_values assignment - temporarily commented out
    # pkg.tagged_values = load_tagged_values(ea_package.ea_guid)

    # Load stereotype from t_xref
    stereotype = load_stereotype(ea_package.ea_guid)
    pkg.stereotype = stereotype if stereotype

    # Note: Child packages and contents will be loaded separately
    # to avoid circular dependencies and allow lazy loading
    # Don't initialize collections - they have default values
  end
end

#transform_with_hierarchy(ea_package, include_children: true) ⇒ Lutaml::Uml::Package

Transform and build complete package hierarchy

Parameters:

  • ea_package (EaPackage)

    Root EA package

  • include_children (Boolean) (defaults to: true)

    Whether to recursively load children

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/lutaml/qea/factory/package_transformer.rb', line 47

def transform_with_hierarchy(ea_package, include_children: true)
  pkg = transform(ea_package)
  return pkg unless include_children

  # Load child packages
  child_packages = load_child_packages(ea_package.package_id)
  pkg.packages = child_packages.map do |child_pkg|
    transform_with_hierarchy(child_pkg, include_children: true)
  end

  # Load package contents (classes, diagrams, etc.)
  load_package_contents(pkg, ea_package.package_id)

  pkg
end