Skip to content

Commit

Permalink
Merge pull request #240 from bci-oss/feature/swtich-to-svg-diagram
Browse files Browse the repository at this point in the history
Generate Diagrams with SVG Format
  • Loading branch information
tunacicek authored Feb 19, 2024
2 parents 52a340b + af051a1 commit 139f4a8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 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.0
### Added

### Fixed
- Generate diagrams with SVG Format

## 0.2.16
### Added

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -97,7 +97,7 @@ public ResponseEntity<SemanticModel> createModelWithUrn(final SemanticModelType

@Override
public ResponseEntity<org.springframework.core.io.Resource> getModelDiagram( final String urn ) {
final Try<byte[]>pngBytes = sdkHelper.generatePng( urn );
final Try<byte[]>pngBytes = sdkHelper.generateSvg( urn );
if ( pngBytes.isFailure() ) {
throw new RuntimeException( String.format( "Failed to generate example payload for urn %s", urn ) );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
* Copyright (c) 2021-2023 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2021-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -21,6 +21,7 @@

import java.util.List;

import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator;
import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel;
import org.eclipse.esmf.aspectmodel.shacl.violation.Violation;
import org.eclipse.tractusx.semantics.hub.model.AasFormat;
Expand All @@ -46,8 +47,8 @@ public List<Violation> validateModel( Try<VersionedModel> model ) {
return sdkAccessHelperSAMM.validateModel( model );
}

public Try<byte[]> generatePng( String urn ) {
return sdkAccessHelperSAMM.generatePng( urn );
public Try<byte[]> generateSvg( String urn ) {
return sdkAccessHelperSAMM.generateDiagram( urn, AspectModelDiagramGenerator.Format.SVG );
}

public JsonNode getJsonSchema( String urn ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
* Copyright (c) 2021-2023 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2021-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -71,7 +71,7 @@ public List<Violation> validateModel( Try<VersionedModel> model ) {
return validator.validateModel( model );
}

public Try<byte[]> generatePng( String urn ) {
public Try<byte[]> generateDiagram( String urn, Format format ) {

VersionedModel versionedModel = getVersionedModel( urn );

Expand All @@ -80,7 +80,7 @@ public Try<byte[]> generatePng( String urn ) {
final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( new AspectContext( versionedModel, aspect ) );

try ( ByteArrayOutputStream output = new ByteArrayOutputStream() ) {
generator.generateDiagram( Format.PNG, Locale.ENGLISH, output );
generator.generateDiagram( format , Locale.ENGLISH, output );
final byte[] bytes = output.toByteArray();

return Try.success( bytes );
Expand Down
6 changes: 3 additions & 3 deletions backend/src/main/resources/static/semantic-hub-openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################
# Copyright (c) 2021-2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021-2023 Contributors to the Eclipse Foundation
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand Down Expand Up @@ -563,7 +563,7 @@ components:
SemanticModelDiagram:
description: OK
content:
image/png:
image/svg:
schema:

Check warning on line 567 in backend/src/main/resources/static/semantic-hub-openapi.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Additional Properties Too Permissive

Objects should not accept 'additionalProperties' if it is possible

Check warning on line 567 in backend/src/main/resources/static/semantic-hub-openapi.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Additional Properties Too Permissive

Objects should not accept 'additionalProperties' if it is possible
type: string
format: binary
Expand Down

0 comments on commit 139f4a8

Please sign in to comment.