Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Marseu2022-09-07 09:40:20 +0000
committersaadia dhouib2022-09-08 13:37:49 +0000
commitf07c96dcd2cfc4e6ad09769858d5f3a9af427eba (patch)
treeb9907916afcf7c27664bb35adac7b36dc5c2a88c
parent6f4c8e4f1f72411610f8c0c102e198fe2d76c701 (diff)
downloadorg.eclipse.papyrus-manufacturing-f07c96dcd2cfc4e6ad09769858d5f3a9af427eba.tar.gz
org.eclipse.papyrus-manufacturing-f07c96dcd2cfc4e6ad09769858d5f3a9af427eba.tar.xz
org.eclipse.papyrus-manufacturing-f07c96dcd2cfc4e6ad09769858d5f3a9af427eba.zip
Fix SEC generation with nested dynamic SECs
BaSyx is stupid ... :/ In BaSyx you have several options how to add elements to a submodel element collection. The option which the code generator uses doesn't work when you add dynamic SECs to another SEC. That's because BaSyx is doing some transformations on the Collection<ISubmodelElement> we're passing into the setValue() method and these transformations trip over BaSyx' very own lambda handler feature. What this change does is replace the call to .setValue(Collection<ISubmodelElement>) with a call to .setElements(Map<String, Object>), which doesn't do any transformations. The collection is manually converted into a Map<String, Object>. Change-Id: I448bdcb7193562a779f24cf502f09c52daf1416d Signed-off-by: Moritz Marseu <moritz.marseu@festo.com>
-rw-r--r--aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/SubModelCreator.java3
-rw-r--r--aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/submodelelements/SECGenerator.java7
2 files changed, 6 insertions, 4 deletions
diff --git a/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/SubModelCreator.java b/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/SubModelCreator.java
index 91b702ab..bc4a591e 100644
--- a/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/SubModelCreator.java
+++ b/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/SubModelCreator.java
@@ -148,7 +148,8 @@ public class SubModelCreator {
+ " * DFKI - Tapanta Bhanja <tapanta.bhanja@dfki.de>\n"
+ " *******************************************************************************/ \r\n" +
"package " + this.nameSpace + ".module.submodels." + subModel.getIdShort().toLowerCase() + ";\r\n" +
- "\r\nimport java.util.function.Function;\r\n" +
+ "\r\nimport java.util.function.Function;\r\n" +
+ "import java.util.stream.Collectors;\r\n" +
"import java.util.ArrayList;\r\n" +
"import java.util.Collection;\r\n" +
"import java.util.HashMap;\r\n" +
diff --git a/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/submodelelements/SECGenerator.java b/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/submodelelements/SECGenerator.java
index b6a0a98c..a896b045 100644
--- a/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/submodelelements/SECGenerator.java
+++ b/aas/plugins/codegen/org.eclipse.aas.basyx.codegen/src/org/eclipse/aas/basyx/codegen/generator/submodel/submodelelements/SECGenerator.java
@@ -262,9 +262,10 @@ public class SECGenerator {
String comment4SetValue = " // Adding the SubmodelElements that belong to SubmodelElementCollection - " +
secInstance.getIdShort() + ". \r\n";
- String setValue = " " + parent + "_" + secInstance.getIdShort() +
- ".setValue(" + parent + "_" + secInstance.getIdShort() +
- "value);\r\n \r\n";
+ String parentQualifiedName = parent + "_" + secInstance.getIdShort();
+ String valueQualifiedName = parentQualifiedName + "value";
+ String setValue = " " + parentQualifiedName + ".setElements("
+ + valueQualifiedName + ".stream().collect(Collectors.toMap(ISubmodelElement::getIdShort, Function.identity())));\r\n \r\n";
return comment4SetValue + setValue;
}

Back to the top