Skip to content

Commit 68c03b7

Browse files
authored
Merge pull request #7 from FriedJannik/feat/noExtSubj
Adapts things
2 parents 770096a + cefcc1d commit 68c03b7

1 file changed

Lines changed: 26 additions & 22 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: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,19 @@ public CursorResult<List<AssetAdministrationShellDescriptor>> getAllAasDescripto
9292
String cursor = resolveCursor(pRequest, foundDescriptors, AssetAdministrationShellDescriptor::getId);
9393
foundDescriptors.forEach(desc -> {
9494
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
95-
desc.getSpecificAssetIds().forEach(sId -> {
96-
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
97-
if (!sId.getSupplementalSemanticIds().isEmpty()){
98-
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
99-
}
100-
if (sId.getSemanticId() != null) {
101-
newId.setSemanticId(sId.getSemanticId());
102-
}
103-
newIdsWithoutExternalSubjectID.add(newId);
104-
});
105-
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
95+
if (!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+
}
106108
});
107109
return new CursorResult<>(cursor, foundDescriptors);
108110
}
@@ -163,17 +165,19 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
163165
throw new AasDescriptorNotFoundException(aasDescriptorId);
164166
}
165167
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
166-
descriptor.getSpecificAssetIds().forEach(sId -> {
167-
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
168-
if (!sId.getSupplementalSemanticIds().isEmpty()){
169-
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
170-
}
171-
if (sId.getSemanticId() != null) {
172-
newId.setSemanticId(sId.getSemanticId());
173-
}
174-
newIdsWithoutExternalSubjectID.add(newId);
175-
});
176-
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
168+
if (!descriptor.getSpecificAssetIds().isEmpty()) {
169+
descriptor.getSpecificAssetIds().forEach(sId -> {
170+
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
171+
if (!sId.getSupplementalSemanticIds().isEmpty()) {
172+
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
173+
}
174+
if (sId.getSemanticId() != null) {
175+
newId.setSemanticId(sId.getSemanticId());
176+
}
177+
newIdsWithoutExternalSubjectID.add(newId);
178+
});
179+
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
180+
}
177181
return descriptor;
178182
}
179183

0 commit comments

Comments
 (0)