diff --git a/basyx/aas/adapter/json/json_serialization.py b/basyx/aas/adapter/json/json_serialization.py index 7b8aec24e..dbd4a813b 100644 --- a/basyx/aas/adapter/json/json_serialization.py +++ b/basyx/aas/adapter/json/json_serialization.py @@ -28,7 +28,7 @@ def object_store_to_json(data: model.AbstractObjectStore, **kwargs) -> str: the AAS meta model which should be serialized to a JSON file :param kwargs: Additional keyword arguments to be passed to :func:`json.dumps` """ - environment = data.get_environment() + environment = data.as_environment() # Serialize to a JSON-able mapping jsonable = jsonization.to_jsonable(environment) @@ -45,7 +45,7 @@ def write_aas_json_file(file: IO, data: model.AbstractObjectStore, **kwargs) -> the AAS meta model which should be serialized to a JSON file :param kwargs: Additional keyword arguments to be passed to `json.dump()` """ - environment = data.get_environment() + environment = data.as_environment() # Serialize to a JSON-able mapping jsonable = jsonization.to_jsonable(environment) diff --git a/basyx/aas/adapter/xml/xml_serialization.py b/basyx/aas/adapter/xml/xml_serialization.py index de82c62d0..636ac7003 100644 --- a/basyx/aas/adapter/xml/xml_serialization.py +++ b/basyx/aas/adapter/xml/xml_serialization.py @@ -33,4 +33,4 @@ def write_aas_xml_file(file: IO, the AAS meta model which should be serialized to an XML file """ - file.write(xmlization.to_str(data.get_environment())) + file.write(xmlization.to_str(data.as_environment())) diff --git a/basyx/aas/backend/couchdb.py b/basyx/aas/backend/couchdb.py index 9eb5ec54f..488905172 100644 --- a/basyx/aas/backend/couchdb.py +++ b/basyx/aas/backend/couchdb.py @@ -347,7 +347,7 @@ def add(self, x: model.Identifiable) -> None: """ logger.debug("Adding object %s to CouchDB database ...", repr(x)) # Serialize data - data = jsonization.to_jsonable(self.get_environment()) + data = jsonization.to_jsonable(self.as_environment()) # Create and issue HTTP request (raises HTTPError on status != 200) diff --git a/basyx/aas/model/provider.py b/basyx/aas/model/provider.py index 975c417eb..600fb8220 100644 --- a/basyx/aas/model/provider.py +++ b/basyx/aas/model/provider.py @@ -79,7 +79,8 @@ def update(self, other: Iterable[_IT]) -> None: for x in other: self.add(x) - def get_environment(self) -> Environment: + @abc.abstractmethod + def as_environment(self) -> Environment: pass @@ -97,7 +98,7 @@ def __init__(self, objects: Iterable[_IT] = ()) -> None: def get_identifiable(self, identifier: Identifier) -> _IT: return self._backend[identifier] - def get_environment(self) -> Environment: + def as_environment(self) -> Environment: asset_administration_shells: List[AssetAdministrationShell] = [] submodels: List[Submodel] = [] concept_descriptions: List[ConceptDescription] = []