Skip to content

Update generation of ExternalReference. #581

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 all 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 @@ -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( buildReferenceToConceptDescription( property ) )
.semanticId( buildReferenceToGlobalReference( property ) )
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( buildReferenceToConceptDescription( property ) )
.semanticId( buildReferenceToGlobalReference( property ) )
.value( extractLangStrings( property, context ) )
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ default boolean canHandle( final Property property ) {
* @param property the property to build the reference for
* @return the newly created reference
*/
default Reference buildReferenceToConceptDescription( final Property property ) {
default Reference buildReferenceToGlobalReference( final Property property ) {
final Key key = new DefaultKey.Builder()
.type( KeyTypes.CONCEPT_DESCRIPTION )
.type( KeyTypes.GLOBAL_REFERENCE )
.value( determineIdentifierFor( property ) )
.build();
return new DefaultReference.Builder().type( ReferenceTypes.EXTERNAL_REFERENCE ).keys( key ).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -361,6 +362,19 @@ void testGeneratedAasxFromAspectModelWithPropertiesWithDescriptions() throws Des
assertThat( property.getDescription() ).isEmpty();
}

@Test
void testGeneratedAasxFromAspectModelSemanticIdsAreGlobalReferences() throws DeserializationException {
final Environment environment = getAssetAdministrationShellFromAspect( TestAspect.ASPECT_WITH_PROPERTY_WITH_DESCRIPTIONS );

final Property property = (Property) environment.getSubmodels().get( 0 ).getSubmodelElements().get( 0 );

assertThat( environment.getSubmodels().get( 0 ).getSubmodelElements() ).hasSize( 1 );
assertThat( environment.getConceptDescriptions() ).hasSize( 2 );
assertThat( environment.getConceptDescriptions().get( 1 ).getEmbeddedDataSpecifications() ).hasSize( 1 );
assertThat( property.getDescription() ).isEmpty();
assertThat( property.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE );
}

private void checkDataSpecificationIec61360( final Set<String> semanticIds, final Environment env ) {
semanticIds.forEach( x -> getDataSpecificationIec61360( x, env ) );
}
Expand Down
Loading