Class: Archimate::DataModel::Model
- Inherits:
-
Object
- Object
- Archimate::DataModel::Model
- Includes:
- Comparison
- Defined in:
- lib/archimate/data_model/model.rb
Overview
This is the root model type.
It is a container for the elements, relationships, diagrams and organizations of the model.
Instance Attribute Summary collapse
-
#archimate_version ⇒ Symbol
readonly
One of [Archimate::ARCHIMATE_VERSIONS], default
:archimate_3_0
. - #diagrams ⇒ Array<Diagram> readonly
-
#documentation ⇒ PreservedLangString, NilClass
readonly
Model documentation.
- #elements ⇒ Array<Element> readonly
-
#file_format ⇒ Symbol, NilClass
readonly
Supported Archimate format [Archimate::SUPPORTED_FORMATS] or
nil
. - #filename ⇒ String readonly
-
#id ⇒ String
readonly
Unique identifier of this model.
-
#metadata ⇒ Metadata, NilClass
readonly
Model metadata.
-
#name ⇒ LangString
readonly
Name of the model.
- #namespaces ⇒ Hash readonly
- #organizations ⇒ Array<Organization> readonly
-
#properties ⇒ Array<Property>
readonly
Model properties.
- #property_definitions ⇒ Array<PropertyDefinition> readonly
- #relationships ⇒ Array<Relationship> readonly
- #schema_locations ⇒ Array<String> readonly
- #version ⇒ String, NilClass readonly
- #viewpoints ⇒ Array<Viewpoint> readonly
Instance Method Summary collapse
-
#entities ⇒ Object
Called only by [Lint::DuplicateEntities].
-
#initialize(id:, name:, documentation: nil, properties: [], metadata: nil, elements: [], relationships: [], organizations: [], property_definitions: [], version: nil, diagrams: [], viewpoints: [], filename: nil, file_format: nil, archimate_version: :archimate_3_0, namespaces: {}, schema_locations: []) ⇒ Model
constructor
Constructor.
- #lookup(id) ⇒ Object
-
#organize ⇒ Object
Iterate through the model and ensure that elements, relationships, and diagrams are all present in the model’s organizations.
-
#rebuild_index(missing_id = :model_creation_event) ⇒ Object
Called only by [Diff::Merge].
-
#referenced_identified_nodes ⇒ Object
Only used by [Diff::DeletedItemsReferencedConflict].
- #to_s ⇒ Object
-
#unreferenced_nodes ⇒ Object
This is used only by the model [Cli::Cleanup] class.
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #pretty_print, #to_h
Constructor Details
#initialize(id:, name:, documentation: nil, properties: [], metadata: nil, elements: [], relationships: [], organizations: [], property_definitions: [], version: nil, diagrams: [], viewpoints: [], filename: nil, file_format: nil, archimate_version: :archimate_3_0, namespaces: {}, schema_locations: []) ⇒ Model
Constructor
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 |
# File 'lib/archimate/data_model/model.rb', line 75 def initialize(id:, name:, documentation: nil, properties: [], metadata: nil, elements: [], relationships: [], organizations: [], property_definitions: [], version: nil, diagrams: [], viewpoints: [], filename: nil, file_format: nil, archimate_version: :archimate_3_0, namespaces: {}, schema_locations: []) @id = id @name = name @documentation = documentation @properties = properties @metadata = @elements = elements @relationships = relationships @organizations = organizations @property_definitions = property_definitions @version = version @diagrams = diagrams @viewpoints = viewpoints @filename = filename @file_format = file_format @archimate_version = archimate_version @namespaces = namespaces @schema_locations = schema_locations rebuild_index end |
Instance Attribute Details
#archimate_version ⇒ Symbol (readonly)
Returns one of [Archimate::ARCHIMATE_VERSIONS], default :archimate_3_0
.
60 |
# File 'lib/archimate/data_model/model.rb', line 60 model_attr :archimate_version |
#diagrams ⇒ Array<Diagram> (readonly)
45 |
# File 'lib/archimate/data_model/model.rb', line 45 model_attr :diagrams |
#documentation ⇒ PreservedLangString, NilClass (readonly)
Returns model documentation.
21 |
# File 'lib/archimate/data_model/model.rb', line 21 model_attr :documentation |
#elements ⇒ Array<Element> (readonly)
30 |
# File 'lib/archimate/data_model/model.rb', line 30 model_attr :elements |
#file_format ⇒ Symbol, NilClass (readonly)
Returns supported Archimate format [Archimate::SUPPORTED_FORMATS] or nil
.
57 |
# File 'lib/archimate/data_model/model.rb', line 57 model_attr :file_format |
#filename ⇒ String (readonly)
53 |
# File 'lib/archimate/data_model/model.rb', line 53 model_attr :filename |
#id ⇒ String (readonly)
Returns unique identifier of this model.
14 |
# File 'lib/archimate/data_model/model.rb', line 14 model_attr :id |
#metadata ⇒ Metadata, NilClass (readonly)
Returns model metadata.
27 |
# File 'lib/archimate/data_model/model.rb', line 27 model_attr :metadata |
#name ⇒ LangString (readonly)
Returns name of the model.
17 |
# File 'lib/archimate/data_model/model.rb', line 17 model_attr :name |
#namespaces ⇒ Hash (readonly)
64 |
# File 'lib/archimate/data_model/model.rb', line 64 model_attr :namespaces |
#organizations ⇒ Array<Organization> (readonly)
36 |
# File 'lib/archimate/data_model/model.rb', line 36 model_attr :organizations |
#properties ⇒ Array<Property> (readonly)
Returns model properties.
24 |
# File 'lib/archimate/data_model/model.rb', line 24 model_attr :properties |
#property_definitions ⇒ Array<PropertyDefinition> (readonly)
39 |
# File 'lib/archimate/data_model/model.rb', line 39 model_attr :property_definitions |
#relationships ⇒ Array<Relationship> (readonly)
33 |
# File 'lib/archimate/data_model/model.rb', line 33 model_attr :relationships |
#schema_locations ⇒ Array<String> (readonly)
67 |
# File 'lib/archimate/data_model/model.rb', line 67 model_attr :schema_locations |
#version ⇒ String, NilClass (readonly)
42 |
# File 'lib/archimate/data_model/model.rb', line 42 model_attr :version |
#viewpoints ⇒ Array<Viewpoint> (readonly)
48 |
# File 'lib/archimate/data_model/model.rb', line 48 model_attr :viewpoints |
Instance Method Details
#entities ⇒ Object
Called only by [Lint::DuplicateEntities]
107 108 109 |
# File 'lib/archimate/data_model/model.rb', line 107 def entities @index_hash.values end |
#lookup(id) ⇒ Object
101 102 103 104 |
# File 'lib/archimate/data_model/model.rb', line 101 def lookup(id) rebuild_index(id) unless @index_hash.include?(id) @index_hash[id] end |
#organize ⇒ Object
this is only called by [Diff::Merge]
Iterate through the model and ensure that elements, relationships, and diagrams are all present in the model’s organizations. If an item is missing then move it into the default top-level element for the item type.
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/archimate/data_model/model.rb', line 127 def organize [] .concat(elements) .concat(relationships) .concat(diagrams).each do |item| if find_in_organizations(item).nil? default_organization = default_organization_for(item) default_organization.items.push(item.id) unless default_organization.items.include?(item.id) end end self end |
#rebuild_index(missing_id = :model_creation_event) ⇒ Object
Called only by [Diff::Merge]
112 113 114 115 116 |
# File 'lib/archimate/data_model/model.rb', line 112 def rebuild_index(missing_id = :model_creation_event) return self unless missing_id @index_hash = build_index self end |
#referenced_identified_nodes ⇒ Object
Only used by [Diff::DeletedItemsReferencedConflict]
141 142 143 144 145 146 147 148 149 |
# File 'lib/archimate/data_model/model.rb', line 141 def referenced_identified_nodes classes = [Diagram, ViewNode, Connection, Organization, Relationship].freeze @index_hash .values .select { |entity| classes.include?(entity.class) } .map(&:referenced_identified_nodes) .flatten .uniq end |
#to_s ⇒ Object
118 119 120 |
# File 'lib/archimate/data_model/model.rb', line 118 def to_s "#{Archimate::Color.data_model('Model')}<#{id}>[#{Archimate::Color.color(name, %i[white underline])}]" end |
#unreferenced_nodes ⇒ Object
This is used only by the model [Cli::Cleanup] class.
152 153 154 |
# File 'lib/archimate/data_model/model.rb', line 152 def unreferenced_nodes identified_nodes - referenced_identified_nodes end |