Class: Lutaml::XMI::KlassDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::XMI::KlassDrop
- Includes:
- Parsers::XMIBase
- Defined in:
- lib/lutaml/xmi/liquid_drops/klass_drop.rb
Instance Method Summary collapse
- #absolute_path ⇒ Object
-
#associations ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength.
- #attributes ⇒ Object
- #constraints ⇒ Object
- #definition ⇒ Object
- #generalization ⇒ Object
- #has_guidance? ⇒ Boolean
-
#initialize(model, guidance = nil, options = {}) ⇒ KlassDrop
constructor
rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity.
-
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix.
- #name ⇒ Object
- #operations ⇒ Object
- #package ⇒ Object
- #stereotype ⇒ Object
- #type ⇒ Object
- #xmi_id ⇒ Object
Methods included from Parsers::XMIBase
Constructor Details
#initialize(model, guidance = nil, options = {}) ⇒ KlassDrop
rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 8 def initialize(model, guidance = nil, = {}) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity @model = model @guidance = guidance @options = @xmi_root_model = [:xmi_root_model] @id_name_mapping = [:id_name_mapping] @package = model&.packaged_element&.find do |e| e.type?("uml:Package") end @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 if guidance @klass_guidance = guidance["classes"].find do |klass| klass["name"] == name || klass["name"] == absolute_path end end end |
Instance Method Details
#absolute_path ⇒ Object
44 45 46 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 44 def absolute_path "#{@options[:absolute_path]}::#{name}" end |
#associations ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 72 def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength return if !@matched_element || !@matched_element.links || ( @matched_element.links.association.empty? && @matched_element.links.generalization.empty? ) links = @matched_element.links.association + @matched_element.links.generalization links.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::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.compact end |
#attributes ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 64 def attributes @owned_attributes.map do |owned_attr| if @options[:with_assoc] || owned_attr.association.nil? ::Lutaml::XMI::AttributeDrop.new(owned_attr, @options) end end.compact end |
#constraints ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 122 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::ConstraintDrop.new(constraint) end end |
#definition ⇒ Object
156 157 158 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 156 def definition doc_node_attribute_value(@model.id, "documentation") end |
#generalization ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 137 def generalization if @options[:with_gen] && @model.type?("uml:Class") generalization = serialize_generalization(@model) return {} if generalization.nil? ::Lutaml::XMI::GeneralizationDrop.new( generalization, @klass_guidance, @options ) end end |
#has_guidance? ⇒ Boolean
148 149 150 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 148 def has_guidance? !!@klass_guidance end |
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix
152 153 154 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 152 def is_abstract # rubocop:disable Naming/PredicateName,Naming/PredicatePrefix doc_node_attribute_value(@model.id, "isAbstract") end |
#name ⇒ Object
40 41 42 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 40 def name @model.name end |
#operations ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 114 def operations @model.owned_operation.map do |operation| if operation.association.nil? ::Lutaml::XMI::OperationDrop.new(operation) end end.compact end |
#package ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 48 def package ::Lutaml::XMI::PackageDrop.new( @package, @guidance, @options.merge( { absolute_path: "#{@options[:absolute_path]}::#{name}", }, ), ) end |
#stereotype ⇒ Object
160 161 162 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 160 def stereotype doc_node_attribute_value(@model.id, "stereotype") end |
#type ⇒ Object
60 61 62 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 60 def type @model.type.split(":").last end |
#xmi_id ⇒ Object
36 37 38 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 36 def xmi_id @model.id end |