Skip to content

Commit b0e2bbc

Browse files
committed
Adapts things
1 parent e52666c commit b0e2bbc

1 file changed

Lines changed: 22 additions & 8 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: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
import java.util.stream.Collectors;
3737
import lombok.NonNull;
3838
import lombok.RequiredArgsConstructor;
39-
import org.eclipse.digitaltwin.basyx.aasregistry.model.AssetAdministrationShellDescriptor;
40-
import org.eclipse.digitaltwin.basyx.aasregistry.model.AssetKind;
41-
import org.eclipse.digitaltwin.basyx.aasregistry.model.ShellDescriptorQuery;
42-
import org.eclipse.digitaltwin.basyx.aasregistry.model.ShellDescriptorSearchRequest;
43-
import org.eclipse.digitaltwin.basyx.aasregistry.model.ShellDescriptorSearchResponse;
44-
import org.eclipse.digitaltwin.basyx.aasregistry.model.SubmodelDescriptor;
39+
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference;
40+
import org.eclipse.digitaltwin.basyx.aasregistry.model.*;
4541
import org.eclipse.digitaltwin.basyx.aasregistry.service.errors.AasDescriptorAlreadyExistsException;
4642
import org.eclipse.digitaltwin.basyx.aasregistry.service.errors.AasDescriptorNotFoundException;
4743
import org.eclipse.digitaltwin.basyx.aasregistry.service.errors.SubmodelAlreadyExistsException;
@@ -95,9 +91,18 @@ public CursorResult<List<AssetAdministrationShellDescriptor>> getAllAasDescripto
9591
List<AssetAdministrationShellDescriptor> foundDescriptors = results.getMappedResults();
9692
String cursor = resolveCursor(pRequest, foundDescriptors, AssetAdministrationShellDescriptor::getId);
9793
foundDescriptors.forEach(desc -> {
94+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
9895
desc.getSpecificAssetIds().forEach(sId -> {
99-
sId.setExternalSubjectId(null);
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);
100104
});
105+
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
101106
});
102107
return new CursorResult<>(cursor, foundDescriptors);
103108
}
@@ -157,9 +162,18 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
157162
if (descriptor == null) {
158163
throw new AasDescriptorNotFoundException(aasDescriptorId);
159164
}
165+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
160166
descriptor.getSpecificAssetIds().forEach(sId -> {
161-
sId.setExternalSubjectId(null);
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);
162175
});
176+
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
163177
return descriptor;
164178
}
165179

0 commit comments

Comments
 (0)