Skip to content

Add semanticId to all list elements #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ private Reference buildReferenceForSubmodel( final String submodelId ) {
.build();
}

private Reference buildReferenceForCollection( final String submodelId ) {
final Key key = new DefaultKey.Builder()
.type( KeyTypes.SUBMODEL_ELEMENT_COLLECTION )
.value( submodelId )
.build();
return new DefaultReference.Builder()
.type( ReferenceTypes.MODEL_REFERENCE )
.keys( key )
.build();
}

private void createConceptDescription( final Property property, final Context context ) {
if ( property.getCharacteristic().isEmpty() ) {
return;
Expand Down Expand Up @@ -545,6 +556,8 @@ private <T extends Collection> Environment visitCollectionProperty( final T coll
final SubmodelElementBuilder builder = property ->
new DefaultSubmodelElementList.Builder()
.idShort( property.getName() )
.semanticId( buildReferenceForCollection( collection.getAspectModelUrn().isPresent()
? collection.getAspectModelUrn().get().getUrn().toString() : collection.getName() ) )
.typeValueListElement( AasSubmodelElements.DATA_ELEMENT )
.displayName( LangStringMapper.NAME.map( property.getPreferredNames() ) )
.description( LangStringMapper.TEXT.map( property.getDescriptions() ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void generateAasxWithAspectDataForMultilanguageText() throws DeserializationExce
.asList()
.hasSize( 2 )
.allSatisfy( langString ->
assertThat( List.of( "en", "de" ) ).contains( ( (AbstractLangString) langString ).getLanguage() ) ) ) );
assertThat( List.of( "en", "de" ) ).contains( ((AbstractLangString) langString).getLanguage() ) ) ) );
}

@Test
Expand Down Expand Up @@ -168,6 +168,8 @@ void testGenerateAasxFromAspectModelWithCollection() throws DeserializationExcep
assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT );
} );

assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.SUBMODEL_ELEMENT_COLLECTION );

getDataSpecificationIec61360( "urn:samm:org.eclipse.esmf.test:1.0.0#testProperty", env );
}

Expand All @@ -183,6 +185,8 @@ void testGenerateAasxFromAspectModelWithList() throws DeserializationException {
assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT );
} );

assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.SUBMODEL_ELEMENT_COLLECTION );

getDataSpecificationIec61360( "urn:samm:org.eclipse.esmf.test:1.0.0#testProperty", env );
}

Expand All @@ -197,6 +201,7 @@ void testGenerateAasxFromAspectModelWithSet() throws DeserializationException {
assertThat( submodelElementList.getIdShort() ).isEqualTo( "testProperty" );
assertThat( submodelElementList.getTypeValueListElement() ).isEqualTo( AasSubmodelElements.SUBMODEL_ELEMENT );
} );
assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.SUBMODEL_ELEMENT_COLLECTION );

getDataSpecificationIec61360( "urn:samm:org.eclipse.esmf.test:1.0.0#testProperty", env );
}
Expand All @@ -209,6 +214,7 @@ void testGenerateAasxFromAspectModelWithSortedSet() throws DeserializationExcept
final SubmodelElement submodelElement = env.getSubmodels().get( 0 ).getSubmodelElements().get( 0 );
assertThat( submodelElement ).as( "SubmodelElement is not a SubmodelElementList" ).isInstanceOf( SubmodelElementList.class );
assertThat( submodelElement.getIdShort() ).isEqualTo( "testProperty" );
assertThat( submodelElement.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.SUBMODEL_ELEMENT_COLLECTION );

getDataSpecificationIec61360( "urn:samm:org.eclipse.esmf.test:1.0.0#testProperty", env );
}
Expand Down
Loading