Class: Ea::Sources::Xmi::PropertyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/xmi/property_builder.rb

Overview

Translates XMI OwnedAttribute elements into Ea::Model::Property instances. Multiplicity comes from lower_value / upper_value (LiteralInteger / LiteralUnlimitedNatural polymorphic children).

Instance Method Summary collapse

Instance Method Details

#build_all_for(classifier) ⇒ Object



11
12
13
# File 'lib/ea/sources/xmi/property_builder.rb', line 11

def build_all_for(classifier)
  classifier.owned_attribute.map { |attr| build_one(attr, classifier) }
end

#build_one(attr, owner) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ea/sources/xmi/property_builder.rb', line 15

def build_one(attr, owner)
  id = IdNormalizer.from_xmi_id(attr.id) ||
       IdNormalizer.synthetic_id(owner.id, "attr", attr.name)
  Ea::Model::Property.new(
    id: id,
    name: attr.name,
    owner_id: owner.id,
    type_name: type_name_for(attr),
    qualified_name: "#{owner.name}::#{attr.name}",
    multiplicity_lower: parse_lower(attr),
    multiplicity_upper: parse_upper(attr),
    default_value: default_value_for(attr),
    is_derived: boolean(attr.is_derived),
    is_readonly: boolean(attr.is_read_only),
    is_ordered: boolean(attr.is_ordered),
    is_unique: boolean(attr.is_unique),
    aggregation: attr.aggregation || "none",
    visibility: attr.visibility,
    annotations: AnnotationBuilder.from_element(attr, id)
  )
end