Skip to content

Commit 14cbfec

Browse files
committed
Final fix
1 parent 7c9f2a6 commit 14cbfec

2 files changed

Lines changed: 37 additions & 43 deletions

File tree

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,6 @@ 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-
94-
for(int i = 0; i<foundDescriptors.size(); i++) {
95-
AssetAdministrationShellDescriptor desc = foundDescriptors.get(i);
96-
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
97-
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
98-
for(SpecificAssetId sId : desc.getSpecificAssetIds()) {
99-
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
100-
if (sId.getSupplementalSemanticIds() != null) {
101-
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
102-
}
103-
if (sId.getSemanticId() != null) {
104-
newId.setSemanticId(sId.getSemanticId());
105-
}
106-
newIdsWithoutExternalSubjectID.add(newId);
107-
}
108-
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
109-
}
110-
}
11193
return new CursorResult<>(cursor, foundDescriptors);
11294
}
11395

@@ -166,22 +148,6 @@ public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDe
166148
if (descriptor == null) {
167149
throw new AasDescriptorNotFoundException(aasDescriptorId);
168150
}
169-
if (descriptor.getSpecificAssetIds() != null || !descriptor.getSpecificAssetIds().isEmpty()) {
170-
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
171-
for(SpecificAssetId sId : descriptor.getSpecificAssetIds()) {
172-
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
173-
if (sId.getSupplementalSemanticIds() != null) {
174-
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
175-
}
176-
if (sId.getSemanticId() != null) {
177-
newId.setSemanticId(sId.getSemanticId());
178-
}
179-
newIdsWithoutExternalSubjectID.add(newId);
180-
}
181-
descriptor.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
182-
}
183-
184-
185151
return descriptor;
186152
}
187153

basyx.aasregistry/basyx.aasregistry-service/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/api/BasyxRegistryApiDelegate.java

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626

2727
import jakarta.validation.Valid;
2828
import java.net.URI;
29+
import java.util.ArrayList;
2930
import java.util.List;
30-
import org.eclipse.digitaltwin.basyx.aasregistry.model.AssetAdministrationShellDescriptor;
31-
import org.eclipse.digitaltwin.basyx.aasregistry.model.AssetKind;
32-
import org.eclipse.digitaltwin.basyx.aasregistry.model.GetAssetAdministrationShellDescriptorsResult;
33-
import org.eclipse.digitaltwin.basyx.aasregistry.model.GetSubmodelDescriptorsResult;
34-
import org.eclipse.digitaltwin.basyx.aasregistry.model.PagedResultPagingMetadata;
35-
import org.eclipse.digitaltwin.basyx.aasregistry.model.SubmodelDescriptor;
31+
32+
import org.eclipse.digitaltwin.basyx.aasregistry.model.*;
3633
import org.eclipse.digitaltwin.basyx.aasregistry.service.events.RegistryEventSink;
3734
import org.eclipse.digitaltwin.basyx.aasregistry.service.storage.AasRegistryStorage;
3835
import org.eclipse.digitaltwin.basyx.aasregistry.service.storage.DescriptorFilter;
@@ -76,7 +73,23 @@ public ResponseEntity<GetAssetAdministrationShellDescriptorsResult> getAllAssetA
7673
GetAssetAdministrationShellDescriptorsResult result = new GetAssetAdministrationShellDescriptorsResult();
7774
result.setPagingMetadata(resolvePagingMeta(allDescriptors));
7875
result.setResult(allDescriptors.getResult());
79-
76+
for(int i = 0; i<allDescriptors.getResult().size(); i++) {
77+
AssetAdministrationShellDescriptor desc = allDescriptors.getResult().get(i);
78+
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
79+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
80+
for(SpecificAssetId sId : desc.getSpecificAssetIds()) {
81+
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
82+
if (sId.getSupplementalSemanticIds() != null) {
83+
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
84+
}
85+
if (sId.getSemanticId() != null) {
86+
newId.setSemanticId(sId.getSemanticId());
87+
}
88+
newIdsWithoutExternalSubjectID.add(newId);
89+
}
90+
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
91+
}
92+
}
8093
return new ResponseEntity<>(result, HttpStatus.OK);
8194
}
8295

@@ -94,8 +107,23 @@ public ResponseEntity<GetSubmodelDescriptorsResult> getAllSubmodelDescriptorsThr
94107

95108
@Override
96109
public ResponseEntity<AssetAdministrationShellDescriptor> getAssetAdministrationShellDescriptorById(String aasIdentifier) {
97-
AssetAdministrationShellDescriptor result = storage.getAasDescriptor(aasIdentifier);
98-
return new ResponseEntity<>(result, HttpStatus.OK);
110+
AssetAdministrationShellDescriptor desc = storage.getAasDescriptor(aasIdentifier);
111+
112+
if (desc.getSpecificAssetIds() != null || !desc.getSpecificAssetIds().isEmpty()) {
113+
List<SpecificAssetId> newIdsWithoutExternalSubjectID = new ArrayList<>();
114+
for(SpecificAssetId sId : desc.getSpecificAssetIds()) {
115+
SpecificAssetId newId = new SpecificAssetId(sId.getName(), sId.getValue());
116+
if (sId.getSupplementalSemanticIds() != null) {
117+
newId.setSupplementalSemanticIds(sId.getSupplementalSemanticIds());
118+
}
119+
if (sId.getSemanticId() != null) {
120+
newId.setSemanticId(sId.getSemanticId());
121+
}
122+
newIdsWithoutExternalSubjectID.add(newId);
123+
}
124+
desc.setSpecificAssetIds(newIdsWithoutExternalSubjectID);
125+
}
126+
return new ResponseEntity<>(desc, HttpStatus.OK);
99127
}
100128

101129
@Override

0 commit comments

Comments
 (0)