Class: Lutaml::Xmi::LiquidDrops::DataTypeDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::Xmi::LiquidDrops::DataTypeDrop
- Includes:
- Parsers::XmiBase
- Defined in:
- lib/lutaml/xmi/liquid_drops/data_type_drop.rb
Instance Method Summary collapse
-
#associations ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength.
- #attributes ⇒ Object
- #constraints ⇒ Object
- #definition ⇒ Object
-
#initialize(model, options = {}) ⇒ DataTypeDrop
constructor
rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity.
-
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix.
- #name ⇒ Object
- #operations ⇒ Object
- #stereotype ⇒ Object
- #xmi_id ⇒ Object
Methods included from Parsers::XmiBase
Constructor Details
#initialize(model, options = {}) ⇒ DataTypeDrop
rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 9 def initialize(model, = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity @model = model @options = @xmi_root_model = [:xmi_root_model] @id_name_mapping = [:id_name_mapping] @owned_attributes = model&.owned_attribute&.select do |attr| attr.type?("uml:Property") end if @xmi_root_model @matched_element = @xmi_root_model&.extension&.elements&.element&.find do |e| # rubocop:disable Layout/LineLength,Style/SafeNavigationChainLength e.idref == @model.id end end end |
Instance Method Details
#associations ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 51 def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength return if !@matched_element || !@matched_element.links links = [] @matched_element.links.each do |link| links << link.association if link.association.any? end links.flatten.compact.filter_map do |assoc| link_member = assoc.start == xmi_id ? "end" : "start" link_owner_name = link_member == "start" ? "end" : "start" member_end, member_end_type, member_end_cardinality, member_end_attribute_name, member_end_xmi_id = serialize_member_type(xmi_id, assoc, link_member) owner_end = serialize_owned_type(xmi_id, assoc, link_owner_name) if member_end && ((member_end_type != "aggregation") || (member_end_type == "aggregation" && member_end_attribute_name)) doc_node_name = (link_member == "start" ? "source" : "target") definition = fetch_definition_node_value(assoc.id, doc_node_name) ::Lutaml::Xmi::LiquidDrops::AssociationDrop.new( xmi_id: assoc.id, member_end: member_end, member_end_type: member_end_type, member_end_cardinality: member_end_cardinality, member_end_attribute_name: member_end_attribute_name, member_end_xmi_id: member_end_xmi_id, owner_end: owner_end, owner_end_xmi_id: xmi_id, definition: definition, options: @options, ) end end end |
#attributes ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 34 def attributes @owned_attributes.filter_map do |owned_attr| if @options[:with_assoc] || owned_attr.association.nil? ::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr, @options) end end end |
#constraints ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 91 def constraints connector_node = fetch_connector(@model.id) return unless connector_node # In ea-xmi-2.5.1, constraints are moved to source/target under # connectors constraints = %i[source target].map do |st| connector_node.send(st).constraints.constraint end.flatten constraints.map do |constraint| ::Lutaml::Xmi::LiquidDrops::ConstraintDrop.new(constraint) end end |
#definition ⇒ Object
110 111 112 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 110 def definition doc_node_attribute_value(@model.id, "documentation") end |
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix
106 107 108 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 106 def is_abstract # rubocop:disable Naming/PredicateName,Naming/PredicatePrefix doc_node_attribute_value(@model.id, "isAbstract") end |
#name ⇒ Object
30 31 32 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 30 def name @model.name end |
#operations ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 43 def operations @model.owned_operation.filter_map do |operation| if operation.association.nil? ::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation) end end end |
#stereotype ⇒ Object
114 115 116 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 114 def stereotype doc_node_attribute_value(@model.id, "stereotype") end |
#xmi_id ⇒ Object
26 27 28 |
# File 'lib/lutaml/xmi/liquid_drops/data_type_drop.rb', line 26 def xmi_id @model.id end |