Skip to content

Commit

Permalink
Temporary fix done for getting SemanticID in Submodel response
Browse files Browse the repository at this point in the history
  • Loading branch information
agg3fe committed Jul 12, 2023
1 parent bfb7eda commit a8a4474
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.8-M1
### Added

## fixed
- In this version, fix is given for adjusting SemanticID in submodel response. This is only temporary workaround.

## 0.3.7-M1
### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@

import org.eclipse.tractusx.semantics.aas.registry.model.Endpoint;
import org.eclipse.tractusx.semantics.aas.registry.model.Key;
import org.eclipse.tractusx.semantics.aas.registry.model.KeyTypes;
import org.eclipse.tractusx.semantics.aas.registry.model.LangStringTextType;
import org.eclipse.tractusx.semantics.aas.registry.model.Reference;
import org.eclipse.tractusx.semantics.aas.registry.model.ReferenceTypes;
import org.eclipse.tractusx.semantics.aas.registry.model.SubmodelDescriptor;
import org.eclipse.tractusx.semantics.registry.model.Submodel;
import org.eclipse.tractusx.semantics.registry.model.SubmodelDescription;
import org.eclipse.tractusx.semantics.registry.model.SubmodelEndpoint;
import org.mapstruct.AfterMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.NullValuePropertyMappingStrategy;
Expand Down Expand Up @@ -114,9 +117,19 @@ default Reference map(String semanticId){
Reference reference = new Reference();
reference.setType( ReferenceTypes.EXTERNALREFERENCE );
Key key = new Key();
key.setType( KeyTypes.SUBMODEL );
key.setValue( semanticId );
reference.setKeys( List.of(key) );
return reference;
}

@AfterMapping
default Submodel mapSemanticIds( SubmodelDescriptor apiDto, @MappingTarget Submodel submodel){
if(apiDto.getSemanticId().getKeys()!=null){
return submodel.withSemanticId( apiDto.getSemanticId().getKeys().get( 0 ).getValue() );
}else{
return submodel.withSemanticId( "" );
}
}

}

0 comments on commit a8a4474

Please sign in to comment.