Skip to content

Commit

Permalink
Fix constraint AASd-131
Browse files Browse the repository at this point in the history
attribute `specific_asset_id` is now also private and checks constraint AASd-131 when being set.
  • Loading branch information
David Niebert committed Jun 27, 2023
1 parent 791454f commit b3cbdd0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions basyx/aas/model/aas.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,32 @@ def __init__(self,
super().__init__()
self.asset_kind: base.AssetKind = asset_kind
self._global_asset_id: Optional[base.GlobalReference] = global_asset_id
self.specific_asset_id: Set[base.SpecificAssetId] = set() if specific_asset_id is None \
self._specific_asset_id: Set[base.SpecificAssetId] = set() if specific_asset_id is None \
else specific_asset_id
self.default_thumbnail: Optional[base.Resource] = default_thumbnail
if global_asset_id is None and (self.specific_asset_id is None or not self.specific_asset_id):
if self._global_asset_id is None and (self._specific_asset_id is None or not self._specific_asset_id):
raise base.AASConstraintViolation(131, "either global or specific asset id must be set")

def _get_global_asset_id(self):
return self._global_asset_id

def _set_global_asset_id(self, global_asset_id: Optional[base.GlobalReference]):
if global_asset_id is None and (self.specific_asset_id is None or not self.specific_asset_id):
if global_asset_id is None and (self._specific_asset_id is None or not self._specific_asset_id):
raise base.AASConstraintViolation(131, "either global or specific asset id must be set")
self._global_asset_id = global_asset_id

global_asset_id = property(_get_global_asset_id, _set_global_asset_id)

def _get_specific_asset_id(self):
return self._specific_asset_id

def _set_specific_asset_id(self, specific_asset_id: Optional[Set[base.SpecificAssetId]]):
if self._global_asset_id is None and (specific_asset_id is None or not specific_asset_id):
raise base.AASConstraintViolation(131, "either global or specific asset id must be set")
self._specific_asset_id = specific_asset_id

specific_asset_id = property(_get_specific_asset_id, _set_specific_asset_id)

def __repr__(self) -> str:
return "AssetInformation(assetKind={}, globalAssetId={}, specificAssetId={}, defaultThumbnail={})".format(
self.asset_kind, self._global_asset_id, str(self.specific_asset_id), str(self.default_thumbnail))
Expand Down

0 comments on commit b3cbdd0

Please sign in to comment.