Class: Lutaml::Xmi::LiquidDrops::KlassDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lutaml::Xmi::LiquidDrops::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
- #clients_dependencies ⇒ Object
- #constraints ⇒ Object
- #definition ⇒ Object
- #generalization ⇒ Object
- #has_guidance? ⇒ Boolean
- #inheritances ⇒ Object
-
#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
- #owned_attributes ⇒ Object
- #package ⇒ Object
- #stereotype ⇒ Object
- #subtype_of ⇒ Object
- #suppliers_dependencies ⇒ Object
- #type ⇒ Object
- #upper_packaged_element ⇒ 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
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 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 9 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 @clients_dependencies = select_dependencies_by_supplier(@model.id) @suppliers_dependencies = select_dependencies_by_client(@model.id) @inheritance_ids = @matched_element&.links&.map do |link| link.generalization.select do |gen| gen.end == @model.id end.map(&:id) end&.flatten&.compact || [] 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
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 54 def absolute_path absolute_path_arr = [@model.name] e = find_upper_level_packaged_element(@model.id) absolute_path_arr << e.name if e while e e = find_upper_level_packaged_element(e.id) absolute_path_arr << e.name if e end absolute_path_arr << "::#{@xmi_root_model.model.name}" absolute_path_arr.reverse.join("::") end |
#associations ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 120 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? links << link.generalization if link.generalization.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
84 85 86 87 88 89 90 91 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 84 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 |
#clients_dependencies ⇒ Object
105 106 107 108 109 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 105 def clients_dependencies @clients_dependencies.filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#constraints ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 169 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
215 216 217 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 215 def definition doc_node_attribute_value(@model.id, "documentation") end |
#generalization ⇒ Object
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 184 def generalization if @options[:with_gen] && @model.type?("uml:Class") generalization = serialize_generalization(@model, @options) return {} if generalization.nil? ::Lutaml::Xmi::LiquidDrops::GeneralizationDrop.new( generalization, @klass_guidance, @options ) end end |
#has_guidance? ⇒ Boolean
207 208 209 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 207 def has_guidance? !!@klass_guidance end |
#inheritances ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 111 def inheritances @inheritance_ids.filter_map do |inheritance_id| # ::Lutaml::Xmi::LiquidDrops::InheritanceDrop # .new(dependency, @options) connector = fetch_connector(inheritance_id) ::Lutaml::Xmi::LiquidDrops::ConnectorDrop.new(connector, @options) end end |
#is_abstract ⇒ Object
rubocop:disable Naming/PredicateName,Naming/PredicatePrefix
211 212 213 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 211 def is_abstract # rubocop:disable Naming/PredicateName,Naming/PredicatePrefix doc_node_attribute_value(@model.id, "isAbstract") end |
#name ⇒ Object
50 51 52 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 50 def name @model.name end |
#operations ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 161 def operations @model.owned_operation.filter_map do |operation| if operation.association.nil? ::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation) end end end |
#owned_attributes ⇒ Object
93 94 95 96 97 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 93 def owned_attributes @owned_attributes.filter_map do |owned_attr| ::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr, @options) end end |
#package ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 68 def package ::Lutaml::Xmi::LiquidDrops::PackageDrop.new( @package, @guidance, @options.merge( { absolute_path: "#{@options[:absolute_path]}::#{name}", }, ), ) end |
#stereotype ⇒ Object
219 220 221 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 219 def stereotype doc_node_attribute_value(@model.id, "stereotype") end |
#subtype_of ⇒ Object
202 203 204 205 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 202 def subtype_of find_subtype_of_from_generalization(@model.id) || find_subtype_of_from_owned_attribute_type(@model.id) end |
#suppliers_dependencies ⇒ Object
99 100 101 102 103 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 99 def suppliers_dependencies @suppliers_dependencies.filter_map do |dependency| ::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options) end end |
#type ⇒ Object
80 81 82 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 80 def type @model.type.split(":").last end |
#upper_packaged_element ⇒ Object
195 196 197 198 199 200 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 195 def upper_packaged_element if @options[:with_gen] e = find_upper_level_packaged_element(@model.id) e&.name end end |
#xmi_id ⇒ Object
46 47 48 |
# File 'lib/lutaml/xmi/liquid_drops/klass_drop.rb', line 46 def xmi_id @model.id end |