diff --git a/basyx/aas/adapter/json/json_deserialization.py b/basyx/aas/adapter/json/json_deserialization.py index 3cbabe990..0ad19fb01 100644 --- a/basyx/aas/adapter/json/json_deserialization.py +++ b/basyx/aas/adapter/json/json_deserialization.py @@ -413,14 +413,19 @@ def _construct_value_reference_pair(cls, dct: Dict[str, object], value_format: m @classmethod def _construct_asset_information(cls, dct: Dict[str, object], object_class=model.AssetInformation)\ -> model.AssetInformation: - ret = object_class(asset_kind=ASSET_KIND_INVERSE[_get_ts(dct, 'assetKind', str)]) - cls._amend_abstract_attributes(ret, dct) + global_asset_id = None + specific_asset_id = None if 'globalAssetId' in dct: - ret.global_asset_id = cls._construct_reference(_get_ts(dct, 'globalAssetId', dict)) + global_asset_id = cls._construct_reference(_get_ts(dct, 'globalAssetId', dict)) if 'specificAssetIds' in dct: + specific_asset_id = [] for desc_data in _get_ts(dct, "specificAssetIds", list): - ret.specific_asset_id.add(cls._construct_specific_asset_id(desc_data, - model.SpecificAssetId)) + specific_asset_id.add(cls._construct_specific_asset_id(desc_data, model.SpecificAssetId)) + ret = object_class(asset_kind=ASSET_KIND_INVERSE[_get_ts(dct, 'assetKind', str)], + global_asset_id=global_asset_id, + specific_asset_id=specific_asset_id) + cls._amend_abstract_attributes(ret, dct) + if 'defaultThumbnail' in dct: ret.default_thumbnail = cls._construct_resource(_get_ts(dct, 'defaultThumbnail', dict)) return ret diff --git a/basyx/aas/adapter/xml/xml_deserialization.py b/basyx/aas/adapter/xml/xml_deserialization.py index f5e85101c..c1fe2c584 100644 --- a/basyx/aas/adapter/xml/xml_deserialization.py +++ b/basyx/aas/adapter/xml/xml_deserialization.py @@ -985,18 +985,13 @@ def construct_specific_asset_id(cls, element: etree.Element, object_class=model. @classmethod def construct_asset_information(cls, element: etree.Element, object_class=model.AssetInformation, **_kwargs: Any) \ -> model.AssetInformation: - asset_information = object_class( - _child_text_mandatory_mapped(element, NS_AAS + "assetKind", ASSET_KIND_INVERSE), - ) global_asset_id = _failsafe_construct(element.find(NS_AAS + "globalAssetId"), cls.construct_reference, cls.failsafe) - if global_asset_id is not None: - asset_information.global_asset_id = global_asset_id specific_assset_ids = element.find(NS_AAS + "specificAssetIds") - if specific_assset_ids is not None: - for id in _child_construct_multiple(specific_assset_ids, NS_AAS + "specificAssetId", - cls.construct_specific_asset_id, cls.failsafe): - asset_information.specific_asset_id.add(id) + asset_information = object_class(asset_kind=_child_text_mandatory_mapped(element, NS_AAS + "assetKind", + ASSET_KIND_INVERSE), + global_asset_id=global_asset_id, + specific_asset_id=specific_assset_ids) thumbnail = _failsafe_construct(element.find(NS_AAS + "defaultThumbnail"), cls.construct_resource, cls.failsafe) if thumbnail is not None: