3. Data Types and Data Values

This Jupyter notebook demonstrates how Data Values in Capella can be handled. First, let’s load the model again…

[1]:
import capellambse

path_to_model = "../../../tests/data/models/test7_0/Model Test 7.0.aird"
model = capellambse.MelodyModel(path_to_model)
model
[1]:
<capellambse.model._model.MelodyModel at 0x72bcc64d7b30>

As explained in the notebook 01, please ignore the warning about PVMT missing above.

3.1. Example 1: Look into the Data package of the Logical Architecture

Let’s have a look into the data package on the Logical Architecture. It works the same with the other architectures, just replace the oa accordingly. We can see the defined classes, collections, enuemrations, and so on.

[2]:
model.la.data_pkg
[2]:

Data (org.polarsys.capella.core.data.information:DataPkg)

applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

associations

(Empty list)

classes
  1. Class "Wand" (c710f1c2-ede6-444e-9e2b-0ff30d7fd040)
  2. Class "Class 2" (1adf8097-18f9-474e-b136-6c845fc6d9e9)
  3. Class "Branch" (2b34c799-769c-42f2-8a1b-4533dba209a0)
collections

(Empty list)

complex_values

(Empty list)

constraints

(Empty list)

data_types
  1. Enumeration "Wand Core" (546cd75a-c7ac-4e07-9d2d-8a1f93d82419)
  2. Enumeration "Wand Wood" (60314ce6-bc96-4b57-8965-7187241148ae)
data_values

(Empty list)

description
diagrams
  1. [CDB] Harry's Wand (uuid: _kqj3UF9REe2rko4oG1H6IQ)
enumeration_property_types

(Empty list)

enumerations
  1. Enumeration "Wand Core" (546cd75a-c7ac-4e07-9d2d-8a1f93d82419)
  2. Enumeration "Wand Wood" (60314ce6-bc96-4b57-8965-7187241148ae)
exceptions

(Empty list)

exchange_items

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

is_visible_in_docFalse
is_visible_in_lmFalse
key_parts

(Empty list)

layerLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
message_references

(Empty list)

messages

(Empty list)

migrated_elements

(Empty list)

nameData
naming_rules

(Empty list)

packages
  1. DataPkg "Wand Objects" (880af86d-6fac-4fba-a559-2fffd036fa9a)
parentLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
progress_statusNOT_SET
property_value_groups

(Empty list)

property_value_pkgs

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for DataPkg "Data" (39e99d4a-a32c-4b70-b4b6-d03fec612e17)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
signals

(Empty list)

state_events

(Empty list)

statusNone
summary
traces

(Empty list)

unions

(Empty list)

units

(Empty list)

uuid39e99d4a-a32c-4b70-b4b6-d03fec612e17
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcbc33e8a0>
visibility<VisibilityKind.UNSET: 'UNSET'>
visible_on_diagrams

(Empty list)

For Enumerations we can see the Literals assigned to it. We can see both the literals that have been inherited by the specialized super class, and the literals that are defined within this model element (own_literals).

[3]:
model.la.data_pkg.enumerations[0]
[3]:

Wand Core (org.polarsys.capella.core.data.information.datatype:Enumeration)

applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

complex_values

(Empty list)

constraints

(Empty list)

data_values

(Empty list)

default_valueNone
description
diagrams

(Empty list)

domain_typeNone
enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

generalizations

(Empty list)

information_realizations

(Empty list)

is_abstractFalse
is_discreteFalse
is_finalFalse
is_max_inclusiveFalse
is_min_inclusiveFalse
is_visible_in_docFalse
is_visible_in_lmFalse
layerLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
literals
  1. EnumerationLiteral "Unicorn Hair": None (79263437-b45d-410d-a264-8aa28d7574d1)
  2. EnumerationLiteral "Dragon Heartstring": None (6bb9876c-f3a7-4d59-a6d1-819372368fa0)
  3. EnumerationLiteral "Pheonix Feather": None (492fd9ca-88cb-4e9d-b92e-df14a1c1543b)
  4. EnumerationLiteral "Thestral Tail-Hair": None (1e73d13b-1c26-4537-834d-e467f993befe)
max_valueNone
migrated_elements

(Empty list)

min_valueNone
nameWand Core
naming_rules

(Empty list)

null_valueNone
owned_literals
  1. EnumerationLiteral "Unicorn Hair": None (79263437-b45d-410d-a264-8aa28d7574d1)
  2. EnumerationLiteral "Dragon Heartstring": None (6bb9876c-f3a7-4d59-a6d1-819372368fa0)
  3. EnumerationLiteral "Pheonix Feather": None (492fd9ca-88cb-4e9d-b92e-df14a1c1543b)
  4. EnumerationLiteral "Thestral Tail-Hair": None (1e73d13b-1c26-4537-834d-e467f993befe)
parentDataPkg "Data" (39e99d4a-a32c-4b70-b4b6-d03fec612e17)
pattern
progress_statusNOT_SET
property_value_groups

(Empty list)

property_value_pkgs

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for Enumeration "Wand Core" (546cd75a-c7ac-4e07-9d2d-8a1f93d82419)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
statusNone
subBackreference to GeneralizableElement - omitted: can be slow to compute. Display this property directly to show.
summary
superNone
traces

(Empty list)

uuid546cd75a-c7ac-4e07-9d2d-8a1f93d82419
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcc431e4e0>
visibility<VisibilityKind.UNSET: 'UNSET'>
visible_on_diagrams
  1. [CDB] Harry's Wand (uuid: _kqj3UF9REe2rko4oG1H6IQ)

Let’s do the same for a class. Again, we can see the properties of the super class and the properties of the own model element.

Harry's Wand
[4]:
model.la.data_pkg.classes[0]
[4]:

Wand (org.polarsys.capella.core.data.information:Class)

applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

constraints

(Empty list)

data_values

(Empty list)

description
diagrams

(Empty list)

enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

generalizations
  1. Generalization (7b66d8fb-3960-40c7-85c6-1738aee234e5)
information_realizations
  1. InformationRealization (793520e1-acbf-4f93-a219-587840aa5a3b)
is_abstractFalse
is_finalFalse
is_primitiveFalse
is_visible_in_docFalse
is_visible_in_lmFalse
key_parts

(Empty list)

layerLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
migrated_elements

(Empty list)

nameWand
naming_rules

(Empty list)

nested_classes

(Empty list)

owned_features
  1. Property "owner" (9b1f6d9c-58d6-4e5e-a0f1-822cb5440a51)
  2. Property "core" (32f70910-a1fd-4ec9-8d22-4c585ceaf7b9)
  3. Property "wood" (df884a71-e774-49e1-8aee-0a675179c647)
owned_properties
  1. Property "owner" (9b1f6d9c-58d6-4e5e-a0f1-822cb5440a51)
  2. Property "core" (32f70910-a1fd-4ec9-8d22-4c585ceaf7b9)
  3. Property "wood" (df884a71-e774-49e1-8aee-0a675179c647)
parentDataPkg "Data" (39e99d4a-a32c-4b70-b4b6-d03fec612e17)
progress_statusNOT_SET
properties
  1. Property "owner" (9b1f6d9c-58d6-4e5e-a0f1-822cb5440a51)
  2. Property "core" (32f70910-a1fd-4ec9-8d22-4c585ceaf7b9)
  3. Property "wood" (df884a71-e774-49e1-8aee-0a675179c647)
  4. Property "wood" (87f356eb-c79e-4155-b297-8d733685621c)
property_value_groups

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for Class "Wand" (c710f1c2-ede6-444e-9e2b-0ff30d7fd040)
realized_byBackreference to Class - omitted: can be slow to compute. Display this property directly to show.
realized_classes
  1. Class "SpecialTwist" (0fef2887-04ce-4406-b1a1-a1b35e1ce0f3)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
state_machines

(Empty list)

statusNone
subBackreference to GeneralizableElement - omitted: can be slow to compute. Display this property directly to show.
summary
superClass "Branch" (2b34c799-769c-42f2-8a1b-4533dba209a0)
traces

(Empty list)

tree_viewTree view of Wand (uuid: c710f1c2-ede6-444e-9e2b-0ff30d7fd040_tree_view)
uuidc710f1c2-ede6-444e-9e2b-0ff30d7fd040
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcb2f72f60>
visibility<VisibilityKind.UNSET: 'UNSET'>
visible_on_diagrams
  1. [CDB] Harry's Wand (uuid: _kqj3UF9REe2rko4oG1H6IQ)

We can investigate the properties of a Class

[5]:
model.la.data_pkg.classes[0].properties[0]
[5]:

owner (org.polarsys.capella.core.data.information:Property)

aggregation_kind<AggregationKind.UNSET: 'UNSET'>
applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

associationBackreference to Association - omitted: can be slow to compute. Display this property directly to show.
constraints

(Empty list)

default_valueNone
description
diagrams

(Empty list)

enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

is_abstractFalse
is_derivedFalse
is_finalFalse
is_max_inclusiveFalse
is_min_inclusiveFalse
is_orderedFalse
is_part_of_keyFalse
is_read_onlyFalse
is_staticFalse
is_uniqueFalse
is_visible_in_docFalse
is_visible_in_lmFalse
layerLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
max_cardLiteralNumericValue: 1 (43e39098-ace4-47c4-8f1c-1df1986063e2)
max_lengthNone
max_valueNone
migrated_elements

(Empty list)

min_cardLiteralNumericValue: 1 (95d6a6e5-6442-408d-afb2-d8f7a24c5f56)
min_lengthNone
min_valueNone
nameowner
null_valueNone
parentClass "Wand" (c710f1c2-ede6-444e-9e2b-0ff30d7fd040)
progress_statusNOT_SET
property_value_groups

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for Property "owner" (9b1f6d9c-58d6-4e5e-a0f1-822cb5440a51)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
statusNone
summary
typeStringType "String" (b2f035e6-78c8-4dfd-99f0-bf4a40ea3e81)
uuid9b1f6d9c-58d6-4e5e-a0f1-822cb5440a51
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcb2f715b0>
visibility<VisibilityKind.UNSET: 'UNSET'>
visible_on_diagrams

(Empty list)

As you can see the kind attribute is UNSET. That means this property isn’t modelled as an association. An example for a COMPOSITION:

Waypoint
[6]:
prop = model.sa.all_classes.by_name("Trajectory").properties[0]
prop
[6]:

waypoints (org.polarsys.capella.core.data.information:Property)

aggregation_kind<AggregationKind.COMPOSITION: 'COMPOSITION'>
applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

associationBackreference to Association - omitted: can be slow to compute. Display this property directly to show.
constraints

(Empty list)

default_valueNone
description
diagrams

(Empty list)

enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

is_abstractFalse
is_derivedFalse
is_finalFalse
is_max_inclusiveFalse
is_min_inclusiveFalse
is_orderedFalse
is_part_of_keyFalse
is_read_onlyFalse
is_staticFalse
is_uniqueFalse
is_visible_in_docFalse
is_visible_in_lmFalse
layerSystemAnalysis "System Analysis" (79d35fe7-f172-4405-b499-48aef545148a)
max_cardLiteralNumericValue: * (57d146cf-6e40-42f4-9413-1cd0240d1431)
max_lengthNone
max_valueNone
migrated_elements

(Empty list)

min_cardLiteralNumericValue: 1 (1df38231-5a0a-4c47-8c99-96119b8b8af8)
min_lengthNone
min_valueNone
namewaypoints
null_valueNone
parentClass "Trajectory" (c3c96805-d6f6-4092-b9f4-df7970651cdc)
progress_statusNOT_SET
property_value_groups

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for Property "waypoints" (424efd65-eaa9-4220-b61b-fb3340dbc19a)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
statusNone
summary
typeClass "Waypoint" (c89849fd-0643-4708-a4da-74c9ea9ca7b1)
uuid424efd65-eaa9-4220-b61b-fb3340dbc19a
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcb2f70320>
visibility<VisibilityKind.UNSET: 'UNSET'>
visible_on_diagrams

(Empty list)

The role name is exposed as the name attribute of the property. As you can see the only navigable role is waypoints and its min- and max-card are also accessible. The Class can be accessed via the type attribute and the association is there to receive information about the incoming role/property. Let’s have a look at it:

[7]:
prop.association
[7]:

waypoint association (org.polarsys.capella.core.data.information:Association)

applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

constraints

(Empty list)

description
diagrams

(Empty list)

enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

is_visible_in_docFalse
is_visible_in_lmFalse
layerSystemAnalysis "System Analysis" (79d35fe7-f172-4405-b499-48aef545148a)
members
  1. Property "trajectory" (c0e5b34c-297e-4b3c-8957-58bbe4d36199)
migrated_elements

(Empty list)

namewaypoint association
naming_rules

(Empty list)

navigable_members
  1. Property "waypoints" (424efd65-eaa9-4220-b61b-fb3340dbc19a)
parentDataPkg "Data" (814464a3-3278-48eb-b66c-e255ed11afa8)
progress_statusNOT_SET
property_value_groups

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for Association "waypoint association" (3d738685-83e8-45f9-ade2-d5bcc6de1a0c)
realized_flow

(Empty list)

requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
roles
  1. Property "trajectory" (c0e5b34c-297e-4b3c-8957-58bbe4d36199)
  2. Property "waypoints" (424efd65-eaa9-4220-b61b-fb3340dbc19a)
sid
statusNone
summaryFind waypoints and you will finish consistently.
uuid3d738685-83e8-45f9-ade2-d5bcc6de1a0c
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcb2f71910>
visible_on_diagrams
  1. [CDB] Class tests (uuid: _KZRQIWA9Eey8erljvkS-pQ)

An Association has navigable_members which can be at most 2 (the source and target roles) and a source_role. Whenever the is Navigable option is ticked in Capella the property element will appear underneath the target Class of the Association.

3.2. Example 2: Complex Values (instances of Classes)

Capella allows to create Complex Values which have the type of a class model element. Complex Values can contain Value Parts that instantiate the properties of the class. Let’s have a look at Harry’s wand:

[8]:
instance = model.la.data_pkg.packages[0].data_values.by_class(
    "AbstractComplexValue"
)[0]
instance
[8]:

Harry's Wand (org.polarsys.capella.core.data.information.datavalue:ComplexValue)

applied_property_value_groups

(Empty list)

applied_property_values

(Empty list)

constraints

(Empty list)

description
diagrams

(Empty list)

enumeration_property_types

(Empty list)

extensions

(Empty list)

features

(Empty list)

filtering_criteria

(Empty list)

is_abstractFalse
is_visible_in_docFalse
is_visible_in_lmFalse
layerLogicalArchitecture "Logical Architecture" (853cb005-cba0-489b-8fe3-bb694ad4543b)
migrated_elements

(Empty list)

nameHarry's Wand
parentDataPkg "Wand Objects" (880af86d-6fac-4fba-a559-2fffd036fa9a)
parts
  1. ValuePart: LiteralStringValue "LiteralStringValue": Harry Potter (f7b00d88-cf53-4ae0-a0e6-bb2049b4bdea) (c996225b-5b1f-4d53-83cb-2bc72597e8ad)
  2. ValuePart: EnumerationReference "EnumerationReference": EnumerationLiteral "Pheonix Feather": None (492fd9ca-88cb-4e9d-b92e-df14a1c1543b) (3406b669-4572-44e9-b703-1e319c350e9b) (66da894f-6261-47ac-9ad7-217db04671d2)
  3. ValuePart: EnumerationReference "EnumerationReference": EnumerationLiteral "Holly": None (bfd550cb-7038-48db-9d7b-57cd0ca29d03) (9645687f-9485-45f0-a10b-01f8b9d24914) (a10de770-c6de-43fc-8d9f-868efe5cd29f)
progress_statusNOT_SET
property_value_groups

(Empty list)

property_values

(Empty list)

pvmtProperty Value Management for ComplexValue "Harry's Wand" (3a467d68-f53c-4d66-9d32-fe032a8cb2c5)
requirements

(Empty list)

requirements_relationsBackreference to AbstractRelation - omitted: can be slow to compute. Display this property directly to show.
review
sid
statusNone
summary
typeClass "Wand" (c710f1c2-ede6-444e-9e2b-0ff30d7fd040)
uuid3a467d68-f53c-4d66-9d32-fe032a8cb2c5
validation<capellambse.extensions.validation._validate.ElementValidation object at 0x72bcb2f73410>
visible_on_diagrams

(Empty list)

and let’s see what wood Harry’s wand is made of:

[9]:
from capellambse.metamodel.information import datavalue

for value_part in instance.parts:
    value = value_part.value.value
    if isinstance(value, datavalue.EnumerationLiteral):
        value = value.name

    print(
        f"The {value_part.referenced_property.name} of {instance.name} is {value}."
    )
The owner of Harry's Wand is Harry Potter.
The core of Harry's Wand is Pheonix Feather.
The wood of Harry's Wand is Holly.