Skip to content

Commit

Permalink
AAS serializer: de-serialization: finished
Browse files Browse the repository at this point in the history
  • Loading branch information
tiptr committed Dec 22, 2022
1 parent 8b16e15 commit 4eeba3f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion backend/aas_deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from backend.knowledge_graph.KnowledgeGraphPersistenceService import (
KnowledgeGraphPersistenceService,
)
from backend.knowledge_graph.dao.AssetNodesDao import AssetsDao
from graph_domain.main_digital_twin.SupplementaryFileNode import (
SupplementaryFileNodeDeep,
)
Expand All @@ -33,6 +34,8 @@ def deserialize_from_aasx(
object_store = model.DictObjectStore([])
file_store = aasx.DictSupplementaryFileContainer()

asset_similarities = []

# Read the archive
with aasx.AASXReader(aasx_file_path) as reader:
identifiers: Set[Identifier] = reader.read_into(
Expand Down Expand Up @@ -104,6 +107,17 @@ def deserialize_from_aasx(
visualization_positioning_y=positions[1] if positions is not None else None,
)

# asset similarities
similarities_properties = [
detail
for detail in sindit_submodel.submodel_element
if detail.id_short == "asset_similarities"
]
if len(similarities_properties) > 0:
new_similarities_json = similarities_properties[0].value
new_similarities_list = json.loads(new_similarities_json)
asset_similarities.extend(new_similarities_list)

# Files
for file_meta in files_submodel.submodel_element:
submodel_elements = [el for el in file_meta.value]
Expand Down Expand Up @@ -499,4 +513,11 @@ def deserialize_from_aasx(
for asset in assets_list:
ps.graph.push(asset)

pass
# Add similarity relationships:
ASSETS_DAO: AssetsDao = AssetsDao.instance()
for similarity in asset_similarities:
ASSETS_DAO.add_asset_similarity(
asset1_iri=similarity.get("asset1"),
asset2_iri=similarity.get("asset2"),
similarity_score=similarity.get("similarity_score"),
)

0 comments on commit 4eeba3f

Please sign in to comment.