From 704e239c9c91f643487c7eb791a492c13bb03065 Mon Sep 17 00:00:00 2001 From: zrgt Date: Fri, 20 Oct 2023 13:27:17 +0200 Subject: [PATCH] Add Constraint AASd-133 in SpecificAssetId Check if external_subject_id is ExternalReference --- basyx/aas/model/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/basyx/aas/model/base.py b/basyx/aas/model/base.py index e96bf4a1d..4d9c13b93 100644 --- a/basyx/aas/model/base.py +++ b/basyx/aas/model/base.py @@ -2130,6 +2130,9 @@ class SpecificAssetId(HasSemantics): A specific asset ID describes a generic supplementary identifying attribute of the asset. The specific asset ID is not necessarily globally unique. + *Constraint AASd-133:* SpecificAssetId/externalSubjectId shall be a global reference, + i.e. Reference/type = ExternalReference + :ivar name: Key of the identifier :ivar value: The value of the identifier with the corresponding key. :ivar external_subject_id: The (external) subject the key belongs to or has meaning to. @@ -2153,6 +2156,10 @@ def __init__(self, raise ValueError("value is not allowed to be an empty string") _string_constraints.check_label_type(name) _string_constraints.check_identifier(value) + if external_subject_id is not None and not isinstance(external_subject_id, ExternalReference): + raise AASConstraintViolation(133, f"external_subject_id shall be a global reference, given: " + f"{external_subject_id}") + self.name: LabelType self.value: Identifier self.external_subject_id: ExternalReference