Skip to content

Commit 986288e

Browse files
committed
Fixes ARE
1 parent 454ae29 commit 986288e

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

basyx.submodelservice/basyx.submodelservice-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/InMemorySubmodelBackend.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.eclipse.digitaltwin.basyx.common.backend.inmemory.core.InMemoryCrudRepository;
3030
import org.eclipse.digitaltwin.basyx.core.exceptions.CollidingIdentifierException;
3131
import org.eclipse.digitaltwin.basyx.core.exceptions.ElementDoesNotExistException;
32+
import org.eclipse.digitaltwin.basyx.core.exceptions.SubmodelElementNotADataElementException;
3233
import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult;
3334
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo;
3435
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationSupport;
@@ -126,6 +127,13 @@ public synchronized void createSubmodelElement(String submodelId, String idShort
126127
} else if (parentSme instanceof Entity entity) {
127128
List<SubmodelElement> submodelElements = entity.getStatements();
128129
submodelElements.add(submodelElement);
130+
} else if (parentSme instanceof AnnotatedRelationshipElement are) {
131+
try {
132+
List<DataElement> annotations = are.getAnnotations();
133+
annotations.add((DataElement) submodelElement);
134+
} catch (ClassCastException e) {
135+
throw new SubmodelElementNotADataElementException(submodelElement.getIdShort());
136+
}
129137
}
130138
}
131139

basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/pathparsing/HierarchicalSubmodelElementIdShortPathToken.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
package org.eclipse.digitaltwin.basyx.submodelservice.pathparsing;
2626

2727
import java.util.Collection;
28+
import java.util.stream.Collectors;
2829

30+
import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement;
2931
import org.eclipse.digitaltwin.aas4j.v3.model.Entity;
3032
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
3133
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;
@@ -59,6 +61,12 @@ public SubmodelElement getSubmodelElement(SubmodelElement rootElement) {
5961
Entity entity = (Entity) rootElement;
6062

6163
return filterSubmodelElement(entity.getStatements());
64+
} else if (rootElement instanceof AnnotatedRelationshipElement) {
65+
AnnotatedRelationshipElement are = (AnnotatedRelationshipElement) rootElement;
66+
67+
return filterSubmodelElement(are.getAnnotations().stream()
68+
.map(de -> (SubmodelElement) de)
69+
.collect(Collectors.toList()));
6270
}
6371

6472
throw new ElementDoesNotExistException(token);

0 commit comments

Comments
 (0)