Skip to content

Commit 7c9f2a6

Browse files
committed
Final fix
1 parent b6eea3c commit 7c9f2a6

1 file changed

Lines changed: 13 additions & 14 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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +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-
try {
94-
foundDescriptors.forEach(desc -> {
95-
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
93+
94+
for(int i = 0; i<foundDescriptors.size(); i++) {
95+
AssetAdministrationShellDescriptor desc = foundDescriptors.get(i);
9696
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
97-
desc.getSpecificAssetIds().forEach(sId -> {
97+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
98+
for(SpecificAssetId sId : desc.getSpecificAssetIds()) {
9899
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
99-
if (!sId.getSupplementalSemanticIds().isEmpty()) {
100+
if (sId.getSupplementalSemanticIds() != null) {
100101
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
101102
}
102103
if (sId.getSemanticId() != null) {
103104
newId.setSemanticId(sId.getSemanticId());
104105
}
105106
newIdsWithoutExternalSubjectID.add(newId);
106-
});
107+
}
107108
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
108109
}
109-
});
110-
} catch (Exception ignored){}
110+
}
111111
return new CursorResult<>(cursor, foundDescriptors);
112112
}
113113

@@ -166,22 +166,21 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
166166
if (descriptor == null) {
167167
throw new AasDescriptorNotFoundException(aasDescriptorId);
168168
}
169-
try{
170-
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
171169
if (descriptor.getSpecificAssetIds() != null || !descriptor.getSpecificAssetIds().isEmpty()) {
172-
descriptor.getSpecificAssetIds().forEach(sId -> {
170+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
171+
for(SpecificAssetId sId : descriptor.getSpecificAssetIds()) {
173172
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
174-
if (!sId.getSupplementalSemanticIds().isEmpty()) {
173+
if (sId.getSupplementalSemanticIds() != null) {
175174
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
176175
}
177176
if (sId.getSemanticId() != null) {
178177
newId.setSemanticId(sId.getSemanticId());
179178
}
180179
newIdsWithoutExternalSubjectID.add(newId);
181-
});
180+
}
182181
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
183182
}
184-
} catch (Exception ignored){}
183+
185184

186185
return descriptor;
187186
}

0 commit comments

Comments
 (0)