From 188d9bb92ef5128613e7f762dc55c714b0238435 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Fri, 21 Jun 2024 16:03:08 +0300 Subject: [PATCH 1/6] Update SubModel SemanticId type to Global Reference --- .../esmf/aspectmodel/aas/AspectModelAasVisitor.java | 8 ++++---- .../esmf/aspectmodel/aas/DefaultPropertyMapper.java | 2 +- .../esmf/aspectmodel/aas/LangStringPropertyMapper.java | 2 +- .../org/eclipse/esmf/aspectmodel/aas/PropertyMapper.java | 2 +- .../esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java | 2 ++ 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index 24dc24065..da6b9eaa6 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -208,7 +208,7 @@ public Environment visitAspect( final Aspect aspect, final Context context ) { final Submodel submodel = usedContext.getSubmodel(); submodel.setIdShort( aspect.getName() ); submodel.setId( submodelId ); - submodel.setSemanticId( buildReferenceToConceptDescription( aspect ) ); + submodel.setSemanticId( buildAspectReferenceToGlobalReference( aspect ) ); submodel.setSupplementalSemanticIds( buildGlobalReferenceForSeeReferences( aspect ) ); submodel.setDescription( LangStringMapper.TEXT.map( aspect.getDescriptions() ) ); submodel.setKind( usedContext.getModelingKind() ); @@ -353,12 +353,12 @@ private Reference buildReferenceToEnumValue( final Enumeration enumeration, fina return new DefaultReference.Builder().type( ReferenceTypes.MODEL_REFERENCE ).keys( key ).build(); } - private Reference buildReferenceToConceptDescription( final Aspect aspect ) { + private Reference buildAspectReferenceToGlobalReference( final Aspect aspect ) { final Key key = new DefaultKey.Builder() - .type( KeyTypes.CONCEPT_DESCRIPTION ) + .type( KeyTypes.GLOBAL_REFERENCE ) .value( DEFAULT_MAPPER.determineIdentifierFor( aspect ) ) .build(); - return new DefaultReference.Builder().type( ReferenceTypes.MODEL_REFERENCE ).keys( key ).build(); + return new DefaultReference.Builder().type( ReferenceTypes.EXTERNAL_REFERENCE ).keys( key ).build(); } private Reference buildReferenceForSeeElement( final String seeReference ) { diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java index ef00bcbb5..4943f6ef9 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java @@ -28,7 +28,7 @@ public Property mapToAasProperty( final Type type, final org.eclipse.esmf.metamo .valueType( AasDataTypeMapper.mapAspectTypeToAasXsdDataType( mapType( type ) ) ) .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) .value( context.getPropertyValue( UNKNOWN_EXAMPLE ) ) - .semanticId( buildReferenceToGlobalReference( property ) ) + .semanticId( buildPropertyReferenceToGlobalReference( property ) ) .build(); } diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/LangStringPropertyMapper.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/LangStringPropertyMapper.java index d60552e31..92b26d780 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/LangStringPropertyMapper.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/LangStringPropertyMapper.java @@ -43,7 +43,7 @@ public MultiLanguageProperty mapToAasProperty( final Type type, final Property p return new DefaultMultiLanguageProperty.Builder().idShort( context.getPropertyShortId() ) .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) - .semanticId( buildReferenceToGlobalReference( property ) ) + .semanticId( buildPropertyReferenceToGlobalReference( property ) ) .value( extractLangStrings( property, context ) ) .build(); } diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/PropertyMapper.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/PropertyMapper.java index ecf206927..f961f9bf5 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/PropertyMapper.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/PropertyMapper.java @@ -61,7 +61,7 @@ default boolean canHandle( final Property property ) { * @param property the property to build the reference for * @return the newly created reference */ - default Reference buildReferenceToGlobalReference( final Property property ) { + default Reference buildPropertyReferenceToGlobalReference( final Property property ) { final Key key = new DefaultKey.Builder() .type( KeyTypes.GLOBAL_REFERENCE ) .value( determineIdentifierFor( property ) ) diff --git a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java index 9307ff3de..a4b2bf024 100644 --- a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java +++ b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java @@ -12,6 +12,7 @@ */ package org.eclipse.esmf.aspectmodel.aas; +import static org.assertj.core.api.Assertions.as; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.type; import static org.junit.jupiter.api.Assertions.fail; @@ -377,6 +378,7 @@ void testGeneratedAasxFromAspectModelSemanticIdsAreGlobalReferences() throws Des final Property property = (Property) environment.getSubmodels().get( 0 ).getSubmodelElements().get( 0 ); assertThat( environment.getSubmodels().get( 0 ).getSubmodelElements() ).hasSize( 1 ); + assertThat( environment.getSubmodels().get( 0 ).getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); assertThat( environment.getConceptDescriptions() ).hasSize( 2 ); assertThat( environment.getConceptDescriptions().get( 1 ).getEmbeddedDataSpecifications() ).hasSize( 1 ); assertThat( property.getDescription() ).isEmpty(); From 6375ef3208a68d4324b89965faca487fb0133cf8 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Fri, 21 Jun 2024 17:03:13 +0300 Subject: [PATCH 2/6] Update SubModel relevantOrder to false for Collections --- .../aas/AspectModelAasVisitor.java | 4 ++- .../aas/AspectModelAasGeneratorTest.java | 31 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index da6b9eaa6..757ef68bf 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -559,7 +559,8 @@ private Environment visitCollectionProperty( final T coll .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .value( List.of( decideOnMapping( property, context ) ) ) .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT ) - .supplementalSemanticIds( buildGlobalReferenceForSeeReferences( collection ) ); + .supplementalSemanticIds( buildGlobalReferenceForSeeReferences( collection ) ) + .orderRelevant( false ); if ( collection.getAspectModelUrn().isPresent() ) { submodelBuilder.semanticId( buildReferenceForCollection( collection.getAspectModelUrn().get().getUrn().toString() ) ); @@ -579,6 +580,7 @@ private Environment visitCollectionProperty( final T coll .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .value( values ) .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT ) + .orderRelevant( false ) .build(); }; createSubmodelElement( listBuilder, context ); diff --git a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java index a4b2bf024..aa1349187 100644 --- a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java +++ b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java @@ -110,18 +110,21 @@ void generateAasxWithAspectDataForNestedEntityLists() throws DeserializationExce assertThat( env.getSubmodels() ) .singleElement() .satisfies( subModel -> assertThat( subModel.getSubmodelElements() ) - .anySatisfy( sme -> - assertThat( sme ).asInstanceOf( type( SubmodelElementList.class ) ) - .extracting( SubmodelElementList::getValue ) - .asInstanceOf( InstanceOfAssertFactories.LIST ) - .anySatisfy( entity -> - assertThat( entity ).asInstanceOf( type( SubmodelElementCollection.class ) ) - .extracting( SubmodelElementCollection::getValue ) - .asInstanceOf( InstanceOfAssertFactories.LIST ) - .anySatisfy( property -> - assertThat( property ).asInstanceOf( type( Property.class ) ) - .extracting( Property::getValue ) - .isEqualTo( "2.25" ) ) ) ) ); + .anySatisfy( sme -> { + assertThat( sme ).asInstanceOf( type( SubmodelElementList.class ) ) + .extracting( SubmodelElementList::getValue ) + .asInstanceOf( InstanceOfAssertFactories.LIST ) + .anySatisfy( entity -> + assertThat( entity ).asInstanceOf( type( SubmodelElementCollection.class ) ) + .extracting( SubmodelElementCollection::getValue ) + .asInstanceOf( InstanceOfAssertFactories.LIST ) + .anySatisfy( property -> + assertThat( property ).asInstanceOf( type( Property.class ) ) + .extracting( Property::getValue ) + .isEqualTo( "2.25" ) ) ); + assertThat( ( ( SubmodelElementList ) sme ).getOrderRelevant() ).isFalse(); + } + ) ); } @Test @@ -169,6 +172,7 @@ void testGenerateAasxFromAspectModelWithCollection() throws DeserializationExcep .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); @@ -186,6 +190,7 @@ void testGenerateAasxFromAspectModelWithList() throws DeserializationException { .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); @@ -203,6 +208,7 @@ void testGenerateAasxFromAspectModelWithSet() throws DeserializationException { .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); @@ -216,6 +222,7 @@ void testGenerateAasxFromAspectModelWithSortedSet() throws DeserializationExcept assertThat( env.getSubmodels().get( 0 ).getSubmodelElements() ).hasSize( 1 ); final SubmodelElement submodelElement = env.getSubmodels().get( 0 ).getSubmodelElements().get( 0 ); assertThat( submodelElement ).as( "SubmodelElement is not a SubmodelElementList" ).isInstanceOf( SubmodelElementList.class ); + assertThat( ( ( ( SubmodelElementList ) submodelElement ) ).getOrderRelevant() ).isFalse(); assertThat( submodelElement.getIdShort() ).isEqualTo( "testProperty" ); assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); From 9712a7ea28f18639de38dbd38063a940b25f3880 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Fri, 21 Jun 2024 19:56:27 +0300 Subject: [PATCH 3/6] Update typeModelElementList to subModelElementCollection and remove empty value in property --- .../aspectmodel/aas/AspectModelAasVisitor.java | 5 +++-- .../aspectmodel/aas/DefaultPropertyMapper.java | 18 +++++++++++------- .../aas/AspectModelAasGeneratorTest.java | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index 757ef68bf..39d176504 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -552,13 +552,14 @@ public Environment visitSortedSet( final SortedSet sortedSet, final Context cont private Environment visitCollectionProperty( final T collection, final Context context ) { final SubmodelElementBuilder builder = property -> { + final DefaultSubmodelElementList.Builder submodelBuilder = new DefaultSubmodelElementList.Builder() .idShort( property.getName() ) .typeValueListElement( AasSubmodelElements.DATA_ELEMENT ) .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .value( List.of( decideOnMapping( property, context ) ) ) - .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT ) + .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ) .supplementalSemanticIds( buildGlobalReferenceForSeeReferences( collection ) ) .orderRelevant( false ); @@ -579,7 +580,7 @@ private Environment visitCollectionProperty( final T coll .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .value( values ) - .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT ) + .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ) .orderRelevant( false ) .build(); }; diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java index 4943f6ef9..545f32040 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/DefaultPropertyMapper.java @@ -23,13 +23,17 @@ public class DefaultPropertyMapper implements PropertyMapper { @Override public Property mapToAasProperty( final Type type, final org.eclipse.esmf.metamodel.Property property, final Context context ) { - return new DefaultProperty.Builder() - .idShort( context.getPropertyShortId() ) - .valueType( AasDataTypeMapper.mapAspectTypeToAasXsdDataType( mapType( type ) ) ) - .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) - .value( context.getPropertyValue( UNKNOWN_EXAMPLE ) ) - .semanticId( buildPropertyReferenceToGlobalReference( property ) ) - .build(); + final DefaultProperty defaultProperty = new DefaultProperty(); + defaultProperty.setIdShort( context.getPropertyShortId() ); + defaultProperty.setValueType( AasDataTypeMapper.mapAspectTypeToAasXsdDataType( mapType( type ) ) ); + defaultProperty.setDisplayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ); + defaultProperty.setSemanticId( buildPropertyReferenceToGlobalReference( property ) ); + + if ( !context.getPropertyValue( UNKNOWN_EXAMPLE ).equals( UNKNOWN_EXAMPLE ) ) { + defaultProperty.setValue( context.getPropertyValue( UNKNOWN_EXAMPLE ) ); + } + + return defaultProperty; } private String mapType( final Type type ) { diff --git a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java index aa1349187..8a749a69d 100644 --- a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java +++ b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java @@ -171,7 +171,7 @@ void testGenerateAasxFromAspectModelWithCollection() throws DeserializationExcep assertThat( submodelElement ).asInstanceOf( type( SubmodelElementList.class ) ) .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); - assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ); assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); @@ -189,7 +189,7 @@ void testGenerateAasxFromAspectModelWithList() throws DeserializationException { assertThat( submodelElement ).asInstanceOf( type( SubmodelElementList.class ) ) .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); - assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ); assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); @@ -207,7 +207,7 @@ void testGenerateAasxFromAspectModelWithSet() throws DeserializationException { assertThat( submodelElement ).asInstanceOf( type( SubmodelElementList.class ) ) .satisfies( submodelElementList -> { assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" ); - assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT ); + assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ); assertThat( ( submodelElementList ).getOrderRelevant() ).isFalse(); } ); assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE ); From cc439d6082512e0c3b507c6d58e0dd1b33fd9200 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Mon, 1 Jul 2024 12:36:56 +0300 Subject: [PATCH 4/6] Update valueReferencePairs element value generation --- .../aas/AspectModelAasVisitor.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index 39d176504..f9544740b 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -13,6 +13,8 @@ package org.eclipse.esmf.aspectmodel.aas; import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -110,6 +112,7 @@ public class AspectModelAasVisitor implements AspectVisitor Date: Tue, 9 Jul 2024 10:35:56 +0200 Subject: [PATCH 5/6] Fix code style --- .../aspectmodel/aas/AspectModelAasVisitor.java | 18 +++++++++--------- .../aas/AspectModelAasGeneratorTest.java | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index 3d71840a5..0b219abaa 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -350,7 +350,7 @@ private Reference buildReferenceToEnumValue( final Enumeration enumeration, fina final String updatedValue; try { updatedValue = !value.matches( ALLOWS_ENUMERATION_VALUE_REGEX ) ? transformEnumerationValue( value ) : value; - } catch ( NoSuchAlgorithmException e ) { + } catch ( final NoSuchAlgorithmException e ) { throw new IllegalStateException( e ); } final Key key = new DefaultKey.Builder() @@ -584,7 +584,7 @@ private Environment visitCollectionProperty( final T coll context.getRawPropertyValue() .filter( ArrayNode.class::isInstance ) .map( ArrayNode.class::cast ) - .map( arrayNode -> ( Property property ) -> { + .map( arrayNode -> ( final Property property ) -> { final List values = getValues( collection, property, context, arrayNode ); return new DefaultSubmodelElementList.Builder() .idShort( property.getName() ) @@ -755,18 +755,18 @@ public Environment visitEnumeration( final Enumeration enumeration, final Contex * @return the transformed string in the format "_role[8_characters_of_hash]" * @throws NoSuchAlgorithmException if the SHA-256 algorithm is not available */ - private String transformEnumerationValue( String enumValue ) throws NoSuchAlgorithmException { - String cleanedEnumValue = enumValue.replaceAll( ALLOWS_ENUMERATION_VALUE_REGEX, "" ); + private String transformEnumerationValue( final String enumValue ) throws NoSuchAlgorithmException { + final String cleanedEnumValue = enumValue.replaceAll( ALLOWS_ENUMERATION_VALUE_REGEX, "" ); - MessageDigest digest = MessageDigest.getInstance( "SHA-256" ); - byte[] hashBytes = digest.digest( cleanedEnumValue.getBytes( StandardCharsets.UTF_8 ) ); + final MessageDigest digest = MessageDigest.getInstance( "SHA-256" ); + final byte[] hashBytes = digest.digest( cleanedEnumValue.getBytes( StandardCharsets.UTF_8 ) ); - StringBuilder hexString = new StringBuilder(); - for ( byte b : hashBytes ) { + final StringBuilder hexString = new StringBuilder(); + for ( final byte b : hashBytes ) { hexString.append( String.format( "%02x", b ) ); } - String hashPrefix = hexString.substring( 0, 8 ); + final String hashPrefix = hexString.substring( 0, 8 ); return "_" + cleanedEnumValue + hashPrefix; } diff --git a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java index cdc97eda8..417ff6530 100644 --- a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java +++ b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Set; - import javax.xml.XMLConstants; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; From ab150dfcd321dd9e186999b2c7b5447a0686c121 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Wed, 21 Aug 2024 12:23:09 +0300 Subject: [PATCH 6/6] Change property type for element collection --- .../org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java index 0b219abaa..8fa491619 100644 --- a/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java +++ b/core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java @@ -591,7 +591,7 @@ private Environment visitCollectionProperty( final T coll .displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) ) .description( LangStringMapper.TEXT.map( property.getDescriptions() ) ) .value( values ) - .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION ) + .typeValueListElement( AasSubmodelElements.SUBMODEL_ELEMENT ) .orderRelevant( false ) .build(); } ) )