Skip to content

Commit 376e3f6

Browse files
authored
Update Spring Boot to 3.5.0 and fix SubmodelElement event path computation (#770)
* Remove deprecated includeLayerTools from spring-boot-maven-plugin and correct SubmodelElement path computation - Updated spring-boot-maven-plugin to 3.5.0 and removed includeLayerTools configuration as it was removed in this version. It's active by default - Fixed SubmodelElement path in event handling: now computes full path, including list index if parent is a SubmodelElementList. * Fix testcases * Also remove includeLayerTool tag from submodel registry * Increase spring version to 3.5.0
1 parent 64c70ec commit 376e3f6

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

basyx.aasregistry/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@
295295
<configuration>
296296
<layers>
297297
<enabled>true</enabled>
298-
<includeLayerTools>true</includeLayerTools>
299298
</layers>
300299
</configuration>
301300
<executions>

basyx.submodelregistry/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@
276276
<configuration>
277277
<layers>
278278
<enabled>true</enabled>
279-
<includeLayerTools>true</includeLayerTools>
280279
</layers>
281280
</configuration>
282281
<executions>

basyx.submodelrepository/basyx.submodelrepository-feature-kafka/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/feature/kafka/KafkaSubmodelRepository.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable;
3232
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
3333
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
34+
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList;
3435
import org.eclipse.digitaltwin.basyx.core.exceptions.CollidingIdentifierException;
3536
import org.eclipse.digitaltwin.basyx.core.exceptions.ElementDoesNotExistException;
3637
import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult;
@@ -114,10 +115,24 @@ public void createSubmodelElement(String submodelId, SubmodelElement submodelEle
114115
}
115116

116117
@Override
117-
public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement submodelElement)
118+
public void createSubmodelElement(String submodelId, String parentPath, SubmodelElement submodelElement)
118119
throws ElementDoesNotExistException {
119-
decorated.createSubmodelElement(submodelId, idShortPath, submodelElement);
120-
eventHandler.onSubmodelElementCreated(submodelElement, submodelId, idShortPath);
120+
decorated.createSubmodelElement(submodelId, parentPath, submodelElement);
121+
String path = computePath(submodelId, parentPath, submodelElement.getIdShort());
122+
eventHandler.onSubmodelElementCreated(submodelElement, submodelId, path);
123+
}
124+
125+
private String computePath(String submodelId, String parentPath, String smeIdShort) {
126+
SubmodelElement parent = getSubmodelElement(submodelId, parentPath);
127+
if (parent instanceof SubmodelElementList) {
128+
SubmodelElementList parentList = (SubmodelElementList) parent;
129+
int listSize = parentList.getValue().size();
130+
int pos = listSize -1; // already added starting with zero
131+
// new element is appended
132+
return parentPath + "[" + pos + "]";
133+
} else {
134+
return parentPath + "." + smeIdShort;
135+
}
121136
}
122137

123138
@Override

basyx.submodelrepository/basyx.submodelrepository-feature-kafka/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/feature/kafka/KafkaEventsInMemoryStorageIntegrationTest.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,27 @@ public void testSubmodelElementAddedUnderPath() {
238238
evt = adapter.next();
239239
Assert.assertEquals(SubmodelEventType.SME_CREATED, evt.getType());
240240
Assert.assertEquals(ID_SM1, evt.getId());
241-
Assert.assertEquals(TestSubmodels.IDSHORT_COLL, evt.getSmElementPath());
241+
Assert.assertEquals(TestSubmodels.IDSHORT_COLL + "." + TestSubmodels.IDSHORT_PROP_1, evt.getSmElementPath());
242+
Assert.assertNull(evt.getSubmodel());
243+
Assert.assertEquals(elem, evt.getSmElement());
244+
}
245+
246+
@Test
247+
public void testSubmodelElementAddedUnderListPath() {
248+
Submodel sm = TestSubmodels.createSubmodel(ID_SM1, TestSubmodels.IDSHORT_PROP_0, "7");
249+
sm.getSubmodelElements().add(new DefaultSubmodelElementList.Builder().idShort("List")
250+
.value(new DefaultProperty.Builder().idShort("P77").value("77").build())
251+
.build());
252+
repo.createSubmodel(sm);
253+
SubmodelEvent evt = adapter.next();
254+
Assert.assertEquals(SubmodelEventType.SM_CREATED, evt.getType());
255+
256+
SubmodelElement elem = TestSubmodels.submodelElement(TestSubmodels.IDSHORT_PROP_1, "88");
257+
repo.createSubmodelElement(ID_SM1, "List", elem);
258+
evt = adapter.next();
259+
Assert.assertEquals(SubmodelEventType.SME_CREATED, evt.getType());
260+
Assert.assertEquals(ID_SM1, evt.getId());
261+
Assert.assertEquals("List[1]", evt.getSmElementPath());
242262
Assert.assertNull(evt.getSubmodel());
243263
Assert.assertEquals(elem, evt.getSmElement());
244264
}
@@ -259,7 +279,7 @@ public void testSubmodelElementAddedAndBlobValueNotPartOfTheEvent() {
259279
SubmodelElementList expected = new DefaultSubmodelElementList.Builder().idShort(IDSHORT_LIST0).value(new DefaultBlob.Builder().idShort(IDSHORT_BLOB).build()).build();
260280

261281
Assert.assertEquals(TestSubmodels.ID_SM, evtCreated.getId());
262-
Assert.assertEquals(TestSubmodels.IDSHORT_COLL, evtCreated.getSmElementPath());
282+
Assert.assertEquals(TestSubmodels.IDSHORT_COLL + "." + IDSHORT_LIST0, evtCreated.getSmElementPath());
263283
Assert.assertEquals(expected, evtCreated.getSmElement());
264284
Assert.assertNull(evtCreated.getSubmodel());
265285
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.4.5</version>
8+
<version>3.5.0</version>
99
<relativePath />
1010
</parent>
1111
<groupId>org.eclipse.digitaltwin.basyx</groupId>

0 commit comments

Comments
 (0)