From 561dd11fd342a48d53b65dc627ee694e402ad0a0 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 20 Jun 2023 21:07:57 +0200 Subject: [PATCH 01/10] Include dependencies in generated pom --- build.gradle | 13 +++++++------ settings.gradle | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 0123bb5..2cd144a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - SPDX-FileCopyrightText: (C)2021 SAP SE or an affiliate company and aas-transformation-library contributors. All rights reserved. + SPDX-FileCopyrightText: (C)2021 SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -154,7 +154,7 @@ spotless { trimTrailingWhitespace() indentWithSpaces() endWithNewline() - licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */','\\w') + licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */','\\w') } // format 'xmlaml', { @@ -162,7 +162,7 @@ spotless { // trimTrailingWhitespace() // indentWithSpaces() // endWithNewline() - // licenseHeader('','<[^!]') + // licenseHeader('','<[^!]') // } java { @@ -172,7 +172,7 @@ spotless { endWithNewline() eclipse('4.12.0').configFile 'codestyle/EclipseFormatterProfile.xml' importOrderFile('codestyle/EclipseOrganizeImports.importorder') - licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */') + licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */') } } @@ -228,11 +228,11 @@ task build(overwrite: true) { shadowJar { destinationDirectory = file("${buildDir}/distributions") - archiveClassifier.set("") + archiveClassifier.set("shadow") exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/LICENSE' - archiveBaseName.set("aas-transformation-library") + archiveBaseName.set("aas4j-transformation-library") archiveAppendix.set("shadow") archiveExtension.set("jar") } @@ -255,6 +255,7 @@ publishing { publications { gpr(MavenPublication) { artifact jar + from (components.java) } } } diff --git a/settings.gradle b/settings.gradle index 5b4144a..b8158c1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,4 @@ SPDX-License-Identifier: Apache-2.0 */ -rootProject.name = 'aas-transformation-library' +rootProject.name = 'aas4j-transformation-library' From 1cb6e5046168b14bedde8035321fedc8419c87a0 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 20 Jun 2023 21:29:10 +0200 Subject: [PATCH 02/10] Implement id-generation --- .../digitaltwin/aas4j/expressions/Expressions.java | 12 +++++------- .../aas4j/ua/transform/UaIntegrationTest.java | 2 ++ src/test/resources/ua/uaIntegrationTest.json | 8 ++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java index 1861512..d225f24 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java @@ -6,13 +6,7 @@ package org.eclipse.digitaltwin.aas4j.expressions; import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -135,6 +129,10 @@ public class Expressions { return Hashing.sha256().hashString(concatenated, StandardCharsets.UTF_8).toString(); }); + functions.put("generateId", args -> + "urn:uuid:" + UUID.randomUUID().toString() + ); + // string encoding functions.put("base64", args -> { Stream stream = (Stream) Helpers.valueToStream(args); diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java index fe65aeb..4ac0076 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java @@ -50,6 +50,8 @@ void testIntegration() throws Exception { boolean idInEnv = shellEnv.getSubmodels().stream().map(s -> s.getIdentification().getIdentifier()) .collect(Collectors.toList()).contains("http://exp.organization.com/UA/BigMachine/ns=4;i=1281"); assertTrue(idInEnv); + + assertTrue(shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier().startsWith("urn:uuid")); } @Test diff --git a/src/test/resources/ua/uaIntegrationTest.json b/src/test/resources/ua/uaIntegrationTest.json index 4e58242..a7c910b 100644 --- a/src/test/resources/ua/uaIntegrationTest.json +++ b/src/test/resources/ua/uaIntegrationTest.json @@ -13,8 +13,12 @@ { "idShort": "UaAdminShell", "identification": { - "idType": "Custom", - "id": "UaAdminShellId" + "@bind": { + "idType": "Custom", + "id": { + "@generateId": "someIgnoredArg" + } + } }, "assetInformation": { "@bind": { From 54671ac5c3a6cc313030c7bdfd9c9b1a24da02d4 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Wed, 21 Jun 2023 09:36:13 +0200 Subject: [PATCH 03/10] publish full pom and shade to gpr --- build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 2cd144a..c3025f2 100644 --- a/build.gradle +++ b/build.gradle @@ -218,8 +218,8 @@ task buildJar (type: Jar) { exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES' - archiveExtension.set('jar') with jar + archiveExtension.set('jar') } task build(overwrite: true) { @@ -228,12 +228,12 @@ task build(overwrite: true) { shadowJar { destinationDirectory = file("${buildDir}/distributions") - archiveClassifier.set("shadow") exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/LICENSE' archiveBaseName.set("aas4j-transformation-library") archiveAppendix.set("shadow") + archiveClassifier.set("shadedJar") archiveExtension.set("jar") } @@ -254,7 +254,6 @@ publishing { } publications { gpr(MavenPublication) { - artifact jar from (components.java) } } From 226dd036e3bbb25feae32e8727dd69cd4ab0929f Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Wed, 21 Jun 2023 11:47:09 +0200 Subject: [PATCH 04/10] bump jackson and set to snapshot --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c3025f2..d0c0dc7 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { } group = 'org.eclipse.digitaltwin.aas4j' -version = '0.1.2' +version = '0.1.3-SNAPSHOT' application { group = group @@ -266,7 +266,7 @@ dependencies { def mockito_version = "3.2.4" def dom4j_version = "2.1.3" def apache_poi_version = "4.1.2" - def jackson_version = "2.11.3" + def jackson_version = "2.14.2" def truth_version = "1.1" def slf4j_version = "1.7.30" def json_schema_validator_version = "1.0.45" From b7a76dfd85d28bfc56f7d17d65aa53fd40f8d8ff Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Wed, 21 Jun 2023 17:37:08 +0200 Subject: [PATCH 05/10] change signature due to collision in dataSpecificationContent class --- .../digitaltwin/aas4j/mapping/TransformationContext.java | 4 ++-- .../aas4j/mapping/model/LangStringTemplate.java | 8 ++++---- .../eclipse/digitaltwin/aas4j/mapping/model/Template.java | 4 ++-- .../digitaltwin/aas4j/mapping/model/TemplateSupport.java | 4 ++-- .../aas4j/mapping/TransformationContextTest.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContext.java b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContext.java index 4d59433..9dcf058 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContext.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContext.java @@ -56,8 +56,8 @@ static TransformationContext buildContext(TransformationContext parentCtx, Objec } // add and/or override with template context if (template != null) { - if (template.getDefinitions() != null) { - build.definitions.putAll(template.getDefinitions()); + if (template.getTemplateDefinitions() != null) { + build.definitions.putAll(template.getTemplateDefinitions()); } if (template.getVariables() != null) { template.getVariables().forEach((key, expr) -> { diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/LangStringTemplate.java b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/LangStringTemplate.java index 42ac937..7722ebd 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/LangStringTemplate.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/LangStringTemplate.java @@ -38,13 +38,13 @@ public void setForeachExpression(Expression expression) { } @Override - public Map getDefinitions() { - return template.getDefinitions(); + public Map getTemplateDefinitions() { + return template.getTemplateDefinitions(); } @Override - public void setDefinitions(Map definitions) { - template.setDefinitions(definitions); + public void setTemplateDefinitions(Map definitions) { + template.setTemplateDefinitions(definitions); } @Override diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/Template.java b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/Template.java index 3bd6170..c587c1e 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/Template.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/Template.java @@ -24,10 +24,10 @@ public interface Template { @JsonProperty("@foreach") void setForeachExpression(Expression expression); - Map getDefinitions(); + Map getTemplateDefinitions(); @JsonProperty("@definitions") - void setDefinitions(Map definitions); + void setTemplateDefinitions(Map definitions); Map getVariables(); diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/TemplateSupport.java b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/TemplateSupport.java index ee7f7a7..2e3d2f5 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/TemplateSupport.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/mapping/model/TemplateSupport.java @@ -53,12 +53,12 @@ public void setForeachExpression(Expression foreachExpression) { } @Override - public Map getDefinitions() { + public Map getTemplateDefinitions() { return definitions; } @Override - public void setDefinitions(Map definitions) { + public void setTemplateDefinitions(Map definitions) { this.definitions = definitions; } diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContextTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContextTest.java index df4ebce..29ecc31 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContextTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/mapping/TransformationContextTest.java @@ -26,14 +26,14 @@ void setup() { mockDefs1.put("myDef", Expressions.getConstantByName("pi")); mockTemplate1 = Mockito.mock(Template.class); Mockito.when(mockTemplate1.getVariables()).thenReturn(null); - Mockito.when(mockTemplate1.getDefinitions()).thenReturn(mockDefs1); + Mockito.when(mockTemplate1.getTemplateDefinitions()).thenReturn(mockDefs1); HashMap mockDefs2 = new HashMap<>(); mockDefs2.put("myDef", Expressions.getConstantByName("NaN")); mockDefs2.put("myDef2", Expressions.getConstantByName("e")); mockTemplate2 = Mockito.mock(Template.class); Mockito.when(mockTemplate2.getVariables()).thenReturn(null); - Mockito.when(mockTemplate2.getDefinitions()).thenReturn(mockDefs2); + Mockito.when(mockTemplate2.getTemplateDefinitions()).thenReturn(mockDefs2); } From 29f80728a43440e573b8a5a65e1a2f555bc856a1 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 27 Jun 2023 17:12:40 +0200 Subject: [PATCH 06/10] make @generateUuid take arguments --- .../aas4j/expressions/Expressions.java | 10 +++- .../GenericDocumentTransformerTest.java | 21 +++++++- .../aas4j/ua/transform/UaIntegrationTest.java | 6 ++- .../mappings/generic/nestedForEach.json | 52 +++++++++++++++++++ src/test/resources/ua/uaIntegrationTest.json | 8 ++- src/test/resources/xml/groupable.xml | 27 ++++++++++ 6 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/mappings/generic/nestedForEach.json create mode 100644 src/test/resources/xml/groupable.xml diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java index d225f24..b2905a3 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java @@ -15,6 +15,7 @@ import org.dom4j.Node; import com.google.common.hash.Hashing; +import org.eclipse.digitaltwin.aas4j.exceptions.TransformationException; public class Expressions { @@ -129,8 +130,13 @@ public class Expressions { return Hashing.sha256().hashString(concatenated, StandardCharsets.UTF_8).toString(); }); - functions.put("generateId", args -> - "urn:uuid:" + UUID.randomUUID().toString() + functions.put("generateUuid", args -> + { + boolean isEmpty = Helpers.valueToStream(args).allMatch(element -> element.equals("")); + return args == null || isEmpty ? "urn:uuid:" + UUID.randomUUID() : "urn:uuid:" + UUID.nameUUIDFromBytes( + nodeListsToString(Helpers.valueToStream(args)) + .collect(Collectors.joining()).getBytes()); + } ); // string encoding diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/transform/GenericDocumentTransformerTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/transform/GenericDocumentTransformerTest.java index fc808b5..07de68f 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/transform/GenericDocumentTransformerTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/transform/GenericDocumentTransformerTest.java @@ -23,10 +23,16 @@ import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + class GenericDocumentTransformerTest { public static final String XML_INPUT = "src/test/resources/ua/aasfull.xml"; public static final String JSON_CONFIG = "src/test/resources/ua/genericSampleConfig.json"; + public static final String SPARQL_XML_INPUT = "src/test/resources/xml/groupable.xml"; + public static final String NESTED_FOR_EACH_JSON_CONFIG = "src/test/resources/mappings/generic/nestedForEach.json"; + private InputStream testInputStream; @@ -39,7 +45,6 @@ static void tearDownAfterClass() throws Exception {} @BeforeEach void setUp() throws Exception { TestUtils.resetBindings(); - testInputStream = Files.newInputStream(Paths.get(XML_INPUT)); } @AfterEach @@ -47,6 +52,7 @@ void tearDown() throws Exception {} @Test void testNsBindings() throws TransformationException, IOException { + testInputStream = Files.newInputStream(Paths.get(XML_INPUT)); DocumentTransformer transformer = new GenericDocumentTransformer(); MappingSpecification mapping = new MappingSpecificationParser().loadMappingSpecification(JSON_CONFIG); @@ -56,4 +62,17 @@ void testNsBindings() throws TransformationException, IOException { Assert.assertEquals(71, transform.getSubmodels().size()); } + @Test + void testNestedForEach() throws IOException, TransformationException { + testInputStream = Files.newInputStream(Paths.get(SPARQL_XML_INPUT)); + DocumentTransformer transformer = new GenericDocumentTransformer(); + + MappingSpecification mapping = new MappingSpecificationParser().loadMappingSpecification(NESTED_FOR_EACH_JSON_CONFIG); + + AssetAdministrationShellEnvironment transform = transformer.execute(testInputStream, mapping); + + assertEquals(2, transform.getSubmodels().size()); + assertTrue(transform.getSubmodels().stream().anyMatch(sm -> sm.getIdShort().equals("131"))); + } + } diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java index 4ac0076..a0d84c2 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java @@ -51,7 +51,11 @@ void testIntegration() throws Exception { .collect(Collectors.toList()).contains("http://exp.organization.com/UA/BigMachine/ns=4;i=1281"); assertTrue(idInEnv); - assertTrue(shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier().startsWith("urn:uuid")); + assertEquals("urn:uuid:407ef772-7040-3b9e-b51a-80286d1c8e49", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); + + //this value was extracted from the first run. Since it should change + assertNotEquals("urn:uuid:6b6dcb8f-352c-49f7-8267-e2586601e858", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); + } @Test diff --git a/src/test/resources/mappings/generic/nestedForEach.json b/src/test/resources/mappings/generic/nestedForEach.json new file mode 100644 index 0000000..342602f --- /dev/null +++ b/src/test/resources/mappings/generic/nestedForEach.json @@ -0,0 +1,52 @@ +{ + "@header": { + "version": "1.0.0", + "aasVersion": "3.0RC01", + "@namespaces": { + "ns": "http://ns.org/" + } + }, + "aasEnvironmentMapping": { + "submodels": [ + { + "@foreach": { + "@xpath": "//ns:a/ns:c[not(.=../following::ns:c)]" + }, + "@variables": { + "here": { + "@xpath": "." + } + }, + "semanticId": { + "keys": [ + { + "@bind": { + "value": { + "@var": "here" + } + }, + "idType": "Iri", + "type": "Submodel" + } + ] + }, + "@bind": { + "idShort": { + "@concatenate": [ + { + "@xpath": { + "@concatenate": [ + "//ns:a[ns:c='", + { + "@var": "here" + }, + "']/ns:b[@name='prop_b']" + ] + } + }] + } + } + } + ] + } +} diff --git a/src/test/resources/ua/uaIntegrationTest.json b/src/test/resources/ua/uaIntegrationTest.json index a7c910b..9f4d04b 100644 --- a/src/test/resources/ua/uaIntegrationTest.json +++ b/src/test/resources/ua/uaIntegrationTest.json @@ -11,12 +11,16 @@ "assets": [], "assetAdministrationShells": [ { - "idShort": "UaAdminShell", + "@bind": { + "idShort": { + "@generateUuid": "" + } + }, "identification": { "@bind": { "idType": "Custom", "id": { - "@generateId": "someIgnoredArg" + "@generateUuid": "someStringAsSeed" } } }, diff --git a/src/test/resources/xml/groupable.xml b/src/test/resources/xml/groupable.xml new file mode 100644 index 0000000..1e582c0 --- /dev/null +++ b/src/test/resources/xml/groupable.xml @@ -0,0 +1,27 @@ + + + foo + 1 + 2 + + + foo + 3 + 3 + + + foo + 1 + 2 + + + bar + 4 + 5 + + + bar + 4 + 8 + + \ No newline at end of file From b44edafdca7d78bd42d14d8485def4ce5af15c90 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 27 Jun 2023 17:15:14 +0200 Subject: [PATCH 07/10] bugfix uaintegrationtest --- .../digitaltwin/aas4j/ua/transform/UaIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java index a0d84c2..df4a4c7 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java @@ -54,7 +54,7 @@ void testIntegration() throws Exception { assertEquals("urn:uuid:407ef772-7040-3b9e-b51a-80286d1c8e49", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); //this value was extracted from the first run. Since it should change - assertNotEquals("urn:uuid:6b6dcb8f-352c-49f7-8267-e2586601e858", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); + assertNotEquals("urn:uuid:6b6dcb8f-352c-49f7-8267-e2586601e858", shellEnv.getAssetAdministrationShells().get(0).getIdShort()); } From 29dfb67280eed68d4ce6c6abb2581fe0af0eef95 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Mon, 10 Jul 2023 14:54:41 +0200 Subject: [PATCH 08/10] fix seeded id_generation --- .../digitaltwin/aas4j/expressions/Expressions.java | 11 +++++++---- .../aas4j/ua/transform/UaIntegrationTest.java | 4 ++-- src/test/resources/ua/uaIntegrationTest.json | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java index b2905a3..4c1ec4d 100644 --- a/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java +++ b/src/main/java/org/eclipse/digitaltwin/aas4j/expressions/Expressions.java @@ -130,12 +130,15 @@ public class Expressions { return Hashing.sha256().hashString(concatenated, StandardCharsets.UTF_8).toString(); }); - functions.put("generateUuid", args -> + functions.put("generate_uuid", args -> { boolean isEmpty = Helpers.valueToStream(args).allMatch(element -> element.equals("")); - return args == null || isEmpty ? "urn:uuid:" + UUID.randomUUID() : "urn:uuid:" + UUID.nameUUIDFromBytes( - nodeListsToString(Helpers.valueToStream(args)) - .collect(Collectors.joining()).getBytes()); + if (args == null || isEmpty) { + return UUID.randomUUID(); + } else { + String input = nodeListsToString(Helpers.valueToStream(args)).collect(Collectors.joining()); + return UUID.nameUUIDFromBytes(input.getBytes()); + } } ); diff --git a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java index df4a4c7..1e4ced1 100644 --- a/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java +++ b/src/test/java/org/eclipse/digitaltwin/aas4j/ua/transform/UaIntegrationTest.java @@ -51,10 +51,10 @@ void testIntegration() throws Exception { .collect(Collectors.toList()).contains("http://exp.organization.com/UA/BigMachine/ns=4;i=1281"); assertTrue(idInEnv); - assertEquals("urn:uuid:407ef772-7040-3b9e-b51a-80286d1c8e49", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); + assertEquals("407ef772-7040-3b9e-b51a-80286d1c8e49", shellEnv.getAssetAdministrationShells().get(0).getIdentification().getIdentifier()); //this value was extracted from the first run. Since it should change - assertNotEquals("urn:uuid:6b6dcb8f-352c-49f7-8267-e2586601e858", shellEnv.getAssetAdministrationShells().get(0).getIdShort()); + assertNotEquals("6b6dcb8f-352c-49f7-8267-e2586601e858", shellEnv.getAssetAdministrationShells().get(0).getIdShort()); } diff --git a/src/test/resources/ua/uaIntegrationTest.json b/src/test/resources/ua/uaIntegrationTest.json index 9f4d04b..cb0a0ad 100644 --- a/src/test/resources/ua/uaIntegrationTest.json +++ b/src/test/resources/ua/uaIntegrationTest.json @@ -13,14 +13,14 @@ { "@bind": { "idShort": { - "@generateUuid": "" + "@generate_uuid": "" } }, "identification": { "@bind": { "idType": "Custom", "id": { - "@generateUuid": "someStringAsSeed" + "@generate_uuid": "someStringAsSeed" } } }, From d5415dd1ea0d45bcd3e8b810ea76f4991092af93 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 11 Jul 2023 18:33:24 +0200 Subject: [PATCH 09/10] adjust gh action to coordinates --- .github/workflows/gradle-publish-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle-publish-package.yml b/.github/workflows/gradle-publish-package.yml index 5d972d2..494a2cc 100644 --- a/.github/workflows/gradle-publish-package.yml +++ b/.github/workflows/gradle-publish-package.yml @@ -27,7 +27,7 @@ jobs: uses: actions/delete-package-versions@v4 continue-on-error: true with: - package-name: 'com.sap.dsc.aas.lib.aas-transformation-library' + package-name: 'org.eclipse.digitaltwin.aas4j.aas4j-transformation-library' - name: Publish package run: ./gradlew -i publish env: From cea0956b29802db151153c7d330d444e4eb5a482 Mon Sep 17 00:00:00 2001 From: arnoweiss Date: Tue, 11 Jul 2023 18:47:50 +0200 Subject: [PATCH 10/10] prepare 0.1.3 release --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d0c0dc7..5e82d27 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { } group = 'org.eclipse.digitaltwin.aas4j' -version = '0.1.3-SNAPSHOT' +version = '0.1.3' application { group = group @@ -254,7 +254,7 @@ publishing { } publications { gpr(MavenPublication) { - from (components.java) + from components.java } } }