Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/375-javabeans-bool-spec-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
atextor authored Oct 26, 2023
2 parents 6ed2dfa + 9514d79 commit 9d7e213
Show file tree
Hide file tree
Showing 82 changed files with 789 additions and 567 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/dependency-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Dependency Update

on:
push:
branches:
- 'main'
workflow_dispatch:

permissions:
contents: write

jobs:
dependency:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Submit Dependency Snapshot
uses: advanced-security/maven-dependency-submission-action@v3
13 changes: 13 additions & 0 deletions .github/workflows/pull-request-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ jobs:
mvn -B verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
shell: bash

- name: Switch to Temurin JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false

- name: Test executable jar on Temurin
if: matrix.os == 'ubuntu-20.04'
run: |
cd tools/samm-cli
mvn -B -Denforcer.skip -Dskip.maven.surefire failsafe:integration-test -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
- name: Upload executable jar
# We only need one OS job to upload the jar
if: matrix.os == 'ubuntu-20.04'
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ jobs:
env:
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}

- name: Switch to Temurin JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false

- name: Test executable jar on Temurin
run: |
cd tools/samm-cli
mvn -B -Denforcer.skip -Dskip.maven.surefire failsafe:integration-test -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
- name: Upload staging directory and Linux binary
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ details that are specific to the static case through the component `esmf-aspect-
The diagram generator takes any Aspect Model and provides a rendering of a diagram representing the
Aspect Model with all its elements.

Possible output formats are `png`, `svg` and `dot`.
Possible output formats are `png` and `svg`.

### Aspect Model Documentation Generator

Expand Down
9 changes: 4 additions & 5 deletions core/esmf-aspect-model-aas-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<groupId>org.eclipse.digitaltwin.aas4j</groupId>
<artifactId>dataformat-json</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.esmf</groupId>
<artifactId>esmf-test-resources</artifactId>
Expand All @@ -53,10 +57,5 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
57 changes: 20 additions & 37 deletions core/esmf-aspect-model-document-generators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,17 @@ Aspect Model.

## Diagram Generator

The diagram generator can generate an image in SVG, PNG or DOT format.

The `boxmodel.ttl` file contains the definition of an intermediate format which describes the boxes
in the diagram as well as the edges between these boxes. For each SAMM element a SPARQL construct
query resides in its own file, see the `*2boxmodel.sparql` files, which creates a box or edge for
the SAMM element. Finally the `boxmodel2dot.sparql` construct query creates DOT statements from the
boxes created for an Aspect Model. These statements are then added to the `aspect2dot.mustache`
template to create the final digraph required by Graphviz. Graphviz is then used to render an image
in the specified format.
The diagram generator can generate an image in SVG or PNG format.

### How it works

1. For each specified language the `Aspect to Box Model` files (.sparql) are loaded
2. The resulting query is executed against the loaded Aspect Model to create box for each Aspect
Model element as well as the connections between them
3. The `Box Model to DOT` query is executed against the resulting Model containing these boxes
4. The final digraph is rendered using the `Aspect to DOT` mustache template applied to the
resulting DOT string
5. If the requested format was DOT, the result is directly written to the specified location
6. For the SVG and PNG formats the result is passed to the Graphviz engine to be rendered in the
corresponding format and written to the specified location
For more information on SPARQL construct queries, Graphviz and Mustache see:
- [SPARQL Construct](https://www.w3.org/TR/rdf-sparql-query/#construct)
- [Graphviz](https://www.graphviz.org/)
- [Mustache](https://mustache.github.io/)
1. The Aspect Model file (.ttl) is loaded
2. The Aspect Java model is instantiated with the contents of the loaded Aspect Model
3. A graph representation of the model is built
4. The graph representation is rendered into SVG
5. The used font is embedded as a Base64 encoded string
6. If necessary, the adjusted SVG is rendered into a PNG
7. The result is written to the specified location

## Document Generator

Expand All @@ -39,15 +25,14 @@ page to run standalone without dependencies to the internet.

### How it works

For the generation the aspect java meta model is used.
For the generation the Aspect Java model is used.

1. The Aspect Model definition file (.ttl) is loaded
2. The aspect meta model is instantiated with the contents of the loaded aspect meta model
definition
3. The instantiated aspect meta model is used to generate the HTML page using Velocity templates
1. The Aspect Model file (.ttl) is loaded
2. The Aspect Java model is instantiated with the contents of the loaded Aspect Model
3. The instantiated Aspect Model is used to generate the HTML page using Velocity templates
4. The diagram for the Aspect Model is generated in SVG format and embedded into the HTML as a
Base64 encoded String
5. The required JavaScript, styles and font will be embedded into the HTML as a String
Base64 encoded string
5. The required JavaScript, styles and font are embedded in the HTML
6. The HTML is written to the specified location

The HTML page is generated for each language which is present in the Aspect Model.
Expand Down Expand Up @@ -80,11 +65,9 @@ The JSON generator creates a sample JSON payload for an Aspect Model.

For the generation the Aspect Java model is used.

1. The Aspect Model definition file (.ttl) is loaded
2. The aspect meta model is instantiated with the contents of the loaded aspect meta model
definition
3. The instantiated aspect meta model is used to generate the JSON payload by iterating the
elements of the aspect meta model and extracting the given example values for the properties. If
no example value is given a random value is generated
4. The generated JSON is written to the specified location

1. The Aspect Model file (.ttl) is loaded
2. The Aspect Java model is instantiated with the contents of the loaded Aspect Model
3. The instantiated Aspect Model is used to generate the JSON payload by iterating the
elements of the Aspect Model and extracting the given example values for the properties. If
no example value is given a random value with the correct type is generated
4. The generated JSON is written to the specified location
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@
import java.util.function.Predicate;

import org.eclipse.esmf.aspectmodel.generator.AbstractGenerator;
import org.eclipse.esmf.aspectmodel.generator.I18nLanguageBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.io.CharStreams;

import org.eclipse.esmf.aspectmodel.generator.AspectModelHelper;
import org.eclipse.esmf.aspectmodel.generator.I18nLanguageBundle;
import org.eclipse.esmf.aspectmodel.generator.LanguageCollector;
import org.eclipse.esmf.aspectmodel.generator.TemplateEngine;
import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator;
Expand All @@ -46,6 +41,11 @@
import org.eclipse.esmf.metamodel.Scalar;
import org.eclipse.esmf.metamodel.visitor.AspectStreamTraversalVisitor;

import com.google.common.io.CharStreams;
import org.apache.velocity.runtime.RuntimeConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Asciidoc generator for a aspect model.
*/
Expand Down Expand Up @@ -93,27 +93,30 @@ public AspectModelDocumentationGenerator( final String language, final AspectCon
* (e.g., "FooAspect_en") via the callback function. The caller needs to provide an {@link OutputStream}
* for the respective artifact, e.g. a suitable FileOutputStream.
*
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param generationOptions Additional optional options that control the document generation. See {@link
* HtmlGenerationOption} for the usable keys.
* HtmlGenerationOption} for the usable keys.
* @throws IOException when serialization or deserialization fails
*/
public void generate( final Function<String, OutputStream> nameMapper, final Map<HtmlGenerationOption, String> generationOptions ) throws IOException {
public void generate( final Function<String, OutputStream> nameMapper, final Map<HtmlGenerationOption, String> generationOptions )
throws IOException {
final BufferingNameMapper bufferingMapper = new BufferingNameMapper();
generateHtmlDocu( bufferingMapper, Format.NONE );
generateInternal( nameMapper, generationOptions, bufferingMapper );
}

/**
* Generates HTML documentation for Aspect Models. This version generates the document only for the language explicitly requested by the user.
* Generates HTML documentation for Aspect Models. This version generates the document only for the language explicitly requested by the
* user.
*
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param generationOptions Additional optional options that control the document generation. See {@link
* HtmlGenerationOption} for the usable keys.
* @param language The language for which a document should be generated
* HtmlGenerationOption} for the usable keys.
* @param language The language for which a document should be generated
* @throws IOException when serialization or deserialization fails
*/
public void generate( final Function<String, OutputStream> nameMapper, final Map<HtmlGenerationOption, String> generationOptions, final Locale language )
public void generate( final Function<String, OutputStream> nameMapper, final Map<HtmlGenerationOption, String> generationOptions,
final Locale language )
throws IOException {
final BufferingNameMapper bufferingMapper = new BufferingNameMapper();
generateHtmlDocu( bufferingMapper, Format.NONE, language );
Expand All @@ -126,12 +129,13 @@ public void generate( final Function<String, OutputStream> nameMapper, final Map
* (e.g., "FooAspect_en") via the callback function. The caller needs to provide an {@link OutputStream}
* for the respective artifact, e.g. a suitable FileOutputStream.
*
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param nameMapper The callback function that maps documentation artifact names to OutputStreams
* @param generationOptions Additional optional options that control the document generation. See {@link
* HtmlGenerationOption} for the usable keys.
* HtmlGenerationOption} for the usable keys.
* @throws IOException when serialization or deserialization fails
*/
private void generateInternal( final Function<String, OutputStream> nameMapper, final Map<HtmlGenerationOption, String> generationOptions,
private void generateInternal( final Function<String, OutputStream> nameMapper,
final Map<HtmlGenerationOption, String> generationOptions,
final BufferingNameMapper bufferingMapper ) throws IOException {
for ( final Map.Entry<String, ByteArrayOutputStream> entry : bufferingMapper.artifacts.entrySet() ) {
final String artifactName = entry.getKey();
Expand Down Expand Up @@ -177,9 +181,9 @@ private void generateHtmlDocu( final Function<String, OutputStream> nameMapper,
configuration.put( "aspectModelHelper", new AspectModelHelper( context.aspect().getMetaModelVersion() ) );

final Properties engineConfiguration = new Properties();
engineConfiguration.put( "file.resource.loader.path", ".," + DOCU_TEMPLATE_ROOT_DIR + "/html" );
engineConfiguration.put( RuntimeConstants.FILE_RESOURCE_LOADER_PATH, ".," + DOCU_TEMPLATE_ROOT_DIR + "/html" );
engineConfiguration.put( "event_handler.reference_insertion.class", "org.apache.velocity.app.event.implement.EscapeHtmlReference" );
engineConfiguration.put( "velocimacro.library",
engineConfiguration.put( RuntimeConstants.VM_LIBRARY,
DOCU_TEMPLATE_ROOT_DIR + "/html/characteristic-documentation-lib.vm," +
DOCU_TEMPLATE_ROOT_DIR + "/html/constraint-documentation-lib.vm," +
DOCU_TEMPLATE_ROOT_DIR + "/html/diagram-documentation-lib.vm," +
Expand All @@ -188,7 +192,8 @@ private void generateHtmlDocu( final Function<String, OutputStream> nameMapper,
DOCU_TEMPLATE_ROOT_DIR + "/html/property-documentation-lib.vm," +
DOCU_TEMPLATE_ROOT_DIR + "/html/common-documentation-lib.vm" );

final Predicate<Locale> byLanguage = locale -> selectedLanguage == null || locale.getLanguage().equals( selectedLanguage.getLanguage() );
final Predicate<Locale> byLanguage = locale -> selectedLanguage == null || locale.getLanguage()
.equals( selectedLanguage.getLanguage() );
languages.stream().filter( byLanguage ).forEach( language -> {

logMissingTranslations( context.aspect(), language );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ private Optional<DateFormat> getDateFormat( final String urn ) {
if ( XSD.duration.getURI().equals( urn ) ) {
return Optional.of( new SimpleDateFormat( "PddD" ) );
}
if ( XSD.date.getURI().equals( urn ) ) {
return Optional.of( new SimpleDateFormat( "yyyy-MM-dd" ) );
}
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
#end

#if( !$property.isAbstract() && $property.getCharacteristic().get() )
#if( !$property.isAbstract() && $property.getCharacteristic().isPresent() )
<div class="flex border-b pb-1 py-4">
<div class="w-80">$i18n.getText( "docu.label.characteristic" )</div>
<div class="w-full">
Expand All @@ -52,7 +52,7 @@
</div>
#end

#if( $property.getExampleValue() )
#if( $property.getExampleValue().isPresent() )
<div class="flex border-b pb-1 py-4">
<div class="w-80">$i18n.getText( "docu.label.example" )</div>
<div class="w-full">$property.getExampleValue().get().getValue()</div>
Expand Down
Loading

0 comments on commit 9d7e213

Please sign in to comment.