Class: Ea::Sources::Qea::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/qea/adapter.rb

Overview

Driving port: produces an Ea::Model::Document from a parsed Ea::Qea::Database. Walks the SQLite-derived collections once and delegates to per-domain builders (OCP/MECE — new model types or source columns touch one builder).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, qea_path = nil, mdg_registry: nil) ⇒ Adapter

Returns a new instance of Adapter.



13
14
15
16
17
# File 'lib/ea/sources/qea/adapter.rb', line 13

def initialize(database, qea_path = nil, mdg_registry: nil)
  @database = database
  @qea_path = qea_path
  @mdg_registry = mdg_registry
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



11
12
13
# File 'lib/ea/sources/qea/adapter.rb', line 11

def database
  @database
end

#mdg_registryObject (readonly)

Returns the value of attribute mdg_registry.



11
12
13
# File 'lib/ea/sources/qea/adapter.rb', line 11

def mdg_registry
  @mdg_registry
end

#qea_pathObject (readonly)

Returns the value of attribute qea_path.



11
12
13
# File 'lib/ea/sources/qea/adapter.rb', line 11

def qea_path
  @qea_path
end

Class Method Details

.from_path(qea_path, mdg_registry: nil) ⇒ Object

Convenience: build a document directly from a .qea file path. The file is parsed via the existing Ea::Qea pipeline.

mdg_registry: an optional Ea::Mdg::Registry. When provided, ClassifierBuilder consults it to resolve inherited attributes from MDG-defined parent classes (e.g. phantom attributes like +lod1ImplicitRepresentation on CityGML ImplicitGeometry, whose stereotype maps to an MDG class).



27
28
29
# File 'lib/ea/sources/qea/adapter.rb', line 27

def self.from_path(qea_path, mdg_registry: nil)
  new(Ea.parse(qea_path), qea_path, mdg_registry: mdg_registry).to_document
end

Instance Method Details

#to_documentObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ea/sources/qea/adapter.rb', line 31

def to_document
  Ea::Model::Document.new(
    metadata: ,
    packages: packages,
    classifiers: classifiers,
    relationships: relationships,
    stereotypes: stereotypes,
    notes: notes,
    instance_specifications: instance_specifications,
    diagrams: diagrams
  )
end