Skip to content

Commit ed0da73

Browse files
authored
Merge pull request #9 from FriedJannik/feat/noExtSubj
Adapts things
2 parents 65dbbd3 + b6eea3c commit ed0da73

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

  • basyx.aasregistry/basyx.aasregistry-service-mongodb-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/mongodb

basyx.aasregistry/basyx.aasregistry-service-mongodb-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/mongodb/MongoDbAasRegistryStorage.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,24 @@ public CursorResult<List<AssetAdministrationShellDescriptor>> getAllAasDescripto
9090
AggregationResults<AssetAdministrationShellDescriptor> results = template.aggregate(Aggregation.newAggregation(allAggregations), collectionName, AssetAdministrationShellDescriptor.class);
9191
List<AssetAdministrationShellDescriptor> foundDescriptors = results.getMappedResults();
9292
String cursor = resolveCursor(pRequest, foundDescriptors, AssetAdministrationShellDescriptor::getId);
93-
foundDescriptors.forEach(desc -> {
94-
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
95-
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
96-
desc.getSpecificAssetIds().forEach(sId -> {
97-
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
98-
if (!sId.getSupplementalSemanticIds().isEmpty()){
99-
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
100-
}
101-
if (sId.getSemanticId() != null) {
102-
newId.setSemanticId(sId.getSemanticId());
103-
}
104-
newIdsWithoutExternalSubjectID.add(newId);
105-
});
106-
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
107-
}
108-
});
93+
try {
94+
foundDescriptors.forEach(desc -> {
95+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
96+
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
97+
desc.getSpecificAssetIds().forEach(sId -> {
98+
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
99+
if (!sId.getSupplementalSemanticIds().isEmpty()) {
100+
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
101+
}
102+
if (sId.getSemanticId() != null) {
103+
newId.setSemanticId(sId.getSemanticId());
104+
}
105+
newIdsWithoutExternalSubjectID.add(newId);
106+
});
107+
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
108+
}
109+
});
110+
} catch (Exception ignored){}
109111
return new CursorResult<>(cursor, foundDescriptors);
110112
}
111113

@@ -164,6 +166,7 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
164166
if (descriptor == null) {
165167
throw new AasDescriptorNotFoundException(aasDescriptorId);
166168
}
169+
try{
167170
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
168171
if (descriptor.getSpecificAssetIds() != null || !descriptor.getSpecificAssetIds().isEmpty()) {
169172
descriptor.getSpecificAssetIds().forEach(sId -> {
@@ -178,6 +181,8 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
178181
});
179182
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
180183
}
184+
} catch (Exception ignored){}
185+
181186
return descriptor;
182187
}
183188

0 commit comments

Comments
 (0)