Skip to content

Commit

Permalink
Update aas-core-meta, codegen to 02712de, 5864f75 (#5)
Browse files Browse the repository at this point in the history
We update and re-generate the code and the documentation to:
* [aas-core-meta 02712de], and
* [aas-core-codegen 5864f75].

This is a big change where we introduce strengthening of properties in
the children classes.

[aas-core-meta 02712de]: aas-core-works/aas-core-meta@02712de
[aas-core-codegen 5864f75]: aas-core-works/aas-core-codegen@5864f75
  • Loading branch information
mristin committed Mar 22, 2023
1 parent a9acef6 commit 84a9932
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 85 deletions.
24 changes: 15 additions & 9 deletions aas_core3/jsonization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,9 @@ def asset_administration_shell_from_jsonable(
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

Expand All @@ -1075,11 +1078,11 @@ def asset_administration_shell_from_jsonable(
)

return aas_types.AssetAdministrationShell(
setter.id_short,
setter.id,
setter.asset_information,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -1652,14 +1655,17 @@ def submodel_from_jsonable(jsonable: Jsonable) -> aas_types.Submodel:
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

return aas_types.Submodel(
setter.id_short,
setter.id,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -5993,14 +5999,17 @@ def concept_description_from_jsonable(
exception.path._prepend(PropertySegment(jsonable_value, key))
raise exception

if setter.id_short is None:
raise DeserializationException("The required property 'idShort' is missing")

if setter.id is None:
raise DeserializationException("The required property 'id' is missing")

return aas_types.ConceptDescription(
setter.id_short,
setter.id,
setter.extensions,
setter.category,
setter.id_short,
setter.display_name,
setter.description,
setter.administration,
Expand Down Expand Up @@ -8116,8 +8125,7 @@ def transform_asset_administration_shell(
if that.category is not None:
jsonable["category"] = that.category

if that.id_short is not None:
jsonable["idShort"] = that.id_short
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down Expand Up @@ -8220,8 +8228,7 @@ def transform_submodel(self, that: aas_types.Submodel) -> MutableJsonable:
if that.category is not None:
jsonable["category"] = that.category

if that.id_short is not None:
jsonable["idShort"] = that.id_short
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down Expand Up @@ -9049,8 +9056,7 @@ def transform_concept_description(
if that.category is not None:
jsonable["category"] = that.category

if that.id_short is not None:
jsonable["idShort"] = that.id_short
jsonable["idShort"] = that.id_short

if that.display_name is not None:
jsonable["displayName"] = [
Expand Down
57 changes: 50 additions & 7 deletions aas_core3/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,37 @@ def __init__(
class Identifiable(Referable):
"""An element that has a globally unique identifier."""

#: In case of identifiables this attribute is a short name of the element.
#: In case of referable this ID is an identifying string of the element within
#: its name space.
#:
#: .. note::
#:
#: In case the element is a property and the property has a semantic definition
#: (:py:attr:`HasSemantics.semantic_id`) conformant to IEC61360
#: the :py:attr:`id_short` is typically identical to the short name in English.
#:
#: :py:attr:`id_short` is strengthened to required in this class,
#: see :ref:`Constraint AASd-117 <constraint_AASd-117>`.
id_short: str

# region Strengthening of id_short
@property # type: ignore
def id_short(self) -> str:
# pylint: disable=missing-function-docstring
return self._id_short

@id_short.setter
def id_short(self, new_id_short: Optional[str]) -> None:
if new_id_short is None:
raise ValueError(
"Unexpected None id_short assigned to an instance of Identifiable"
)

self._id_short = new_id_short

# endregion

#: Administrative information of an identifiable element.
#:
#: .. note::
Expand All @@ -410,10 +441,10 @@ class Identifiable(Referable):

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -424,6 +455,9 @@ def __init__(
)
self.id = id
self.administration = administration
# region Strengthening
self._id_short = id_short
# endregion


class ModellingKind(enum.Enum):
Expand Down Expand Up @@ -931,11 +965,11 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
asset_information: "AssetInformation",
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -948,10 +982,10 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
Expand All @@ -960,6 +994,9 @@ def __init__(
self.derived_from = derived_from
self.asset_information = asset_information
self.submodels = submodels
# region Strengthening
self._id_short = id_short
# endregion


class AssetInformation(Class):
Expand Down Expand Up @@ -1448,10 +1485,10 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -1467,10 +1504,10 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
Expand All @@ -1480,6 +1517,9 @@ def __init__(
Qualifiable.__init__(self, qualifiers)
HasDataSpecification.__init__(self, embedded_data_specifications)
self.submodel_elements = submodel_elements
# region Strengthening
self._id_short = id_short
# endregion


class SubmodelElement(Referable, HasSemantics, Qualifiable, HasDataSpecification):
Expand Down Expand Up @@ -4499,10 +4539,10 @@ def transform_with_context(

def __init__(
self,
id_short: str,
id: str,
extensions: Optional[List["Extension"]] = None,
category: Optional[str] = None,
id_short: Optional[str] = None,
display_name: Optional[List["LangStringNameType"]] = None,
description: Optional[List["LangStringTextType"]] = None,
administration: Optional["AdministrativeInformation"] = None,
Expand All @@ -4514,16 +4554,19 @@ def __init__(
"""Initialize with the given values."""
Identifiable.__init__(
self,
id_short,
id,
extensions,
category,
id_short,
display_name,
description,
administration,
)
HasDataSpecification.__init__(self, embedded_data_specifications)
self.is_case_of = is_case_of
# region Strengthening
self._id_short = id_short
# endregion


class ReferenceTypes(enum.Enum):
Expand Down
63 changes: 9 additions & 54 deletions aas_core3/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,13 +2103,6 @@ def transform_asset_administration_shell(
):
yield Error("Display name specifies no duplicate languages.")

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
Expand Down Expand Up @@ -2156,10 +2149,9 @@ def transform_asset_administration_shell(
error.path._prepend(PropertySegment(that, "category"))
yield error

if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error

if that.display_name is not None:
for i, another_item in enumerate(that.display_name):
Expand Down Expand Up @@ -2400,13 +2392,6 @@ def transform_submodel(self, that: aas_types.Submodel) -> Iterator[Error]:
):
yield Error("Display name specifies no duplicate languages.")

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
Expand Down Expand Up @@ -2536,10 +2521,9 @@ def transform_submodel(self, that: aas_types.Submodel) -> Iterator[Error]:
error.path._prepend(PropertySegment(that, "category"))
yield error

if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error

if that.display_name is not None:
for i, another_item in enumerate(that.display_name):
Expand Down Expand Up @@ -2684,13 +2668,6 @@ def transform_relationship_element(
+ "at least one item."
)

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if that.extensions is not None:
for i, an_item in enumerate(that.extensions):
for error in self.transform(an_item):
Expand Down Expand Up @@ -4237,13 +4214,6 @@ def transform_annotated_relationship_element(
+ "at least one item."
)

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if not (not (that.annotations is not None) or (len(that.annotations) >= 1)):
yield Error(
"Annotations must be either not set or have at least one " + "item."
Expand Down Expand Up @@ -4693,13 +4663,6 @@ def transform_basic_event_element(
+ "at least one item."
)

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if not (
not (that.direction == aas_types.Direction.INPUT)
or (that.max_interval is None)
Expand Down Expand Up @@ -5202,13 +5165,6 @@ def transform_concept_description(
):
yield Error("Display name specifies no duplicate languages.")

if not (that.id_short is not None):
yield Error(
"Constraint AASd-117: ID-short of Referables not being "
+ "a direct child of a Submodel element list shall be "
+ "specified."
)

if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
Expand Down Expand Up @@ -5332,10 +5288,9 @@ def transform_concept_description(
error.path._prepend(PropertySegment(that, "category"))
yield error

if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error

if that.display_name is not None:
for i, another_item in enumerate(that.display_name):
Expand Down
Loading

0 comments on commit 84a9932

Please sign in to comment.