Skip to content

Commit

Permalink
Merge pull request #182 from bci-oss/SAMM_BAMM_Support-ESMF_SDK_2.3.2
Browse files Browse the repository at this point in the history
feat:Upgrade dependency to ESMF SDK 2.4.2
  • Loading branch information
tunacicek authored Dec 1, 2023
2 parents 6017942 + 8fd60be commit e15ce2f
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 1,387 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added helm upgrade feature into helm test
- Removed the docker apk upgrade and update commands.
- Upgrade dependency to ESMF SDK 2.4.2

### Fixed
=======
Expand Down
123 changes: 50 additions & 73 deletions DEPENDENCIES

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,6 @@
<dependency>
<groupId>org.eclipse.esmf</groupId>
<artifactId>esmf-aspect-model-starter</artifactId>
<exclusions>
<exclusion>
<groupId>guru.nidi</groupId>
<artifactId>graphviz-java-min-deps</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.npm</groupId>
<artifactId>viz.js-graphviz-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-bridge</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-transcoder</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-svgrasterizer</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--
The AASX generator uses this dependency to generate AASX XML files.
Expand Down Expand Up @@ -155,24 +133,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.openmanufacturing</groupId>
<artifactId>sds-aspect-model-starter</artifactId>
</dependency>
<dependency>
<groupId>io.openmanufacturing</groupId>
<artifactId>sds-aspect-model-aas-generator</artifactId>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<artifactId>maven-core</artifactId>
<groupId>org.apache.maven</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
********************************************************************************/
package org.eclipse.tractusx.semantics;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;




@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
import org.eclipse.tractusx.semantics.hub.api.ModelsApiDelegate;
import org.eclipse.tractusx.semantics.hub.domain.ModelPackageStatus;
import org.eclipse.tractusx.semantics.hub.domain.ModelPackageUrn;
import org.eclipse.tractusx.semantics.hub.model.AasFormat;
import org.eclipse.tractusx.semantics.hub.model.SemanticModel;
import org.eclipse.tractusx.semantics.hub.model.SemanticModelList;
import org.eclipse.tractusx.semantics.hub.model.SemanticModelStatus;
import org.eclipse.tractusx.semantics.hub.model.SemanticModelType;
import org.eclipse.tractusx.semantics.hub.persistence.PersistenceLayer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -38,10 +41,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Lists;

import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
import org.eclipse.tractusx.semantics.hub.persistence.PersistenceLayer;
import io.vavr.control.Try;
import org.eclipse.tractusx.semantics.hub.api.ModelsApiDelegate;

public class AspectModelService implements ModelsApiDelegate {

Expand Down Expand Up @@ -97,13 +97,11 @@ public ResponseEntity<SemanticModel> createModelWithUrn(final SemanticModelType

@Override
public ResponseEntity<org.springframework.core.io.Resource> getModelDiagram( final String urn ) {
// TODO: Fix Model Diagram server crash issue for bugger Models
// final Try<byte[]>pngBytes = sdkHelper.generatePng( urn );
// if ( pngBytes.isFailure() ) {
// throw new RuntimeException( String.format( "Failed to generate example payload for urn %s", urn ) );
// }
// return new ResponseEntity( pngBytes.get(), HttpStatus.OK );
return new ResponseEntity( HttpStatus.NOT_IMPLEMENTED );
final Try<byte[]>pngBytes = sdkHelper.generatePng( urn );
if ( pngBytes.isFailure() ) {
throw new RuntimeException( String.format( "Failed to generate example payload for urn %s", urn ) );
}
return new ResponseEntity( pngBytes.get(), HttpStatus.OK );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,24 @@

import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;

import org.eclipse.esmf.aspectmodel.VersionNumber;
import org.eclipse.tractusx.semantics.hub.bamm.SDKAccessHelperBAMM;
import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel;
import org.eclipse.esmf.aspectmodel.shacl.violation.Violation;
import org.eclipse.tractusx.semantics.hub.model.AasFormat;
import org.eclipse.tractusx.semantics.hub.persistence.PersistenceLayer;
import org.eclipse.tractusx.semantics.hub.samm.SDKAccessHelperSAMM;
import org.springframework.stereotype.Component;

import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel;
import org.eclipse.esmf.aspectmodel.shacl.violation.Violation;
import com.fasterxml.jackson.databind.JsonNode;

import io.vavr.control.Try;

@Component
public class SDKAccessHelper {

SDKAccessHelperBAMM sdkAccessHelperBAMM = new SDKAccessHelperBAMM();
SDKAccessHelperSAMM sdkAccessHelperSAMM = new SDKAccessHelperSAMM();

public void setPersistenceLayer( PersistenceLayer persistenceLayer ) {
sdkAccessHelperSAMM.setPersistenceLayer( persistenceLayer );
sdkAccessHelperBAMM.setPersistenceLayer( persistenceLayer );
}

private boolean isBAMM(String urn){
String BAMM_IDENTIFICATION_STRING = "bamm:";
return urn.contains( BAMM_IDENTIFICATION_STRING );
}

public List<Violation> validateModel( Try<VersionedModel> model ) {
Expand All @@ -57,68 +47,30 @@ public List<Violation> validateModel( Try<VersionedModel> model ) {
}

public Try<byte[]> generatePng( String urn ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.generatePng( urn );
}else {
return sdkAccessHelperSAMM.generatePng( urn );
}
return sdkAccessHelperSAMM.generatePng( urn );
}

public JsonNode getJsonSchema( String urn ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.getJsonSchema( urn );
}else {
return sdkAccessHelperSAMM.getJsonSchema( urn );
}
return sdkAccessHelperSAMM.getJsonSchema( urn );
}

public Try<byte[]> getHtmlDocu( String urn ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.getHtmlDocu( urn );
}else {
return sdkAccessHelperSAMM.getHtmlDocu( urn );
}
return sdkAccessHelperSAMM.getHtmlDocu( urn );
}

public String getOpenApiDefinitionJson( String urn, String baseUrl ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.getOpenApiDefinitionJson( urn, baseUrl );
}else {
return sdkAccessHelperSAMM.getOpenApiDefinitionJson( urn, baseUrl );
}
return sdkAccessHelperSAMM.getOpenApiDefinitionJson( urn, baseUrl );
}

public Try<String> getExamplePayloadJson( String urn ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.getExamplePayloadJson( urn );
}else {
return sdkAccessHelperSAMM.getExamplePayloadJson( urn );
}
return sdkAccessHelperSAMM.getExamplePayloadJson( urn );
}

public Try getAasSubmodelTemplate( String urn, AasFormat aasFormat ) {
if( isBAMM( urn )) {
return sdkAccessHelperBAMM.getAasSubmodelTemplate( urn, aasFormat );
}else {
return sdkAccessHelperSAMM.getAasSubmodelTemplate( urn, aasFormat );
}
return sdkAccessHelperSAMM.getAasSubmodelTemplate( urn, aasFormat );
}

public Try<VersionedModel> loadBammModel( String modelString ) {
if( isBAMM( modelString )) {
Try<io.openmanufacturing.sds.aspectmodel.resolver.services.VersionedModel> versionModel =
sdkAccessHelperBAMM.loadBammModel( modelString );
if ( versionModel.isFailure() ) {
throw new RuntimeException( "Failed to load aspect model", versionModel.getCause() );
}

VersionNumber versionNumber = new VersionNumber( versionModel.get().getMetaModelVersion().getMajor(),
versionModel.get().getMetaModelVersion().getMinor(),
versionModel.get().getMetaModelVersion().getMicro());

return Try.of( () -> new VersionedModel( versionModel.get().getModel(), versionNumber, versionModel.get().getRawModel()));
}else {
return sdkAccessHelperSAMM.loadSammModel( modelString );
}
return sdkAccessHelperSAMM.loadSammModel( modelString );
}
}
Loading

0 comments on commit e15ce2f

Please sign in to comment.