Skip to content

Commit

Permalink
Add submodel registry implementation (#39)
Browse files Browse the repository at this point in the history
* Reference new JsonPatch Based maven plugin

this plugin is a simpler approach to extend yaml or json files using jsonpatch

* Add extension search and combinedWith aggregation of queries

if extensionName is set in a search query, the path must point to the extension value
  - the extensionName is compared in addition using an equals test

- we use combinedWith in the search query to aggregate queries
  - for all paths outside of a sm all queries must match
  - for paths pointing to a submodelDescriptor property, there needs to be at least one sm that matches all these queries in order that the hole request matches for that shell

* Remove return value of path visitor

The return value is not needed in most cases and not reliable considered

* Add extension indeces

Speeds up searching by extension name and value

* Define source folders in POM

in some projects we use src/generated/lava or src/main/lombok as source folders
we define them now not in the .classpath but also in POM

* Add client documentation for aggregate and extension search

* Use fixed version for json patch

* Remove unused empty file

* Add submodel registry implementation

* Add submodel registry to parent aggregator

* Add and readme and fix readme files

* Enable kafak logs and increase connection timeout for tests
  • Loading branch information
geso02 authored Jun 30, 2023
1 parent 1d0d54c commit 873308f
Show file tree
Hide file tree
Showing 147 changed files with 9,966 additions and 30 deletions.
10 changes: 5 additions & 5 deletions basyx.aasregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ This is a Java-based implementation of the Asset Administration Shell Registry s

[basyx.aasregistry-service-basemodel](basyx.aasregistry-service-basemodel/README.md) provides a base model implementation that should be used if you do not need specific model annotations for your storage. It is used for the in-memory storage implementation and you need to add it explicitly as dependency for your server deployment as it is defined as 'provided' dependency in the [basyx.aasregistry-service](basyx.aasregistry-service/README.md) POM.

[basyx.aasregistry-service-base-tests](basyx.aasregistry-service-base-tests/README.md) provides helper classes and abstract test classes that can be extended in storage tests or integration tests. The abstract test classes already define test methods so that you will get a good test coverage without writing any additional test cases.
[basyx.aasregistry-service-basetests](basyx.aasregistry-service-basetests/README.md) provides helper classes and abstract test classes that can be extended in storage tests or integration tests. The abstract test classes already define test methods so that you will get a good test coverage without writing any additional test cases.

[basyx.aasregistry-service-mongodb-storage](basyx.aasregistry-service-mongodb-storage/README.md) provides a registry-storage implementation based on mongoDB that could be used as storage for [aasregistry-service](aasregistry-service/README.md). It comes with java-based model classes, annotated with mongoDB annotations.
[basyx.aasregistry-service-mongodb-storage](basyx.aasregistry-service-mongodb-storage/README.md) provides a registry-storage implementation based on mongoDB that could be used as storage for [aasregistry-service](basyx.aasregistry-service/README.md). It comes with java-based model classes, annotated with mongoDB annotations.

[basyx.aasregistry-service-inmemory-storage](basyx.aasregistry-service-inmemory-storage/README.md) provides a non-persistent registry-storage implementation where instances are stored in hash maps. It can be used as storage for [aasregistry-service](aasregistry-service/README.md).
[basyx.aasregistry-service-inmemory-storage](basyx.aasregistry-service-inmemory-storage/README.md) provides a non-persistent registry-storage implementation where instances are stored in hash maps. It can be used as storage for [aasregistry-service](basyx.aasregistry-service/README.md).

[basyx.aasregistry-service-kafka-events](basyx.aasregistry-service-kafka-events/README.md) extends basyx.aasregistry-service with a registry-event-sink implementation that delivers shell descriptor and submodel registration events using Apache Kafka. The default provided by aasregistry-service just logs the events.

Expand All @@ -33,7 +33,7 @@ A docker-compose file that illustrates the setup can be found in the [docker-com

# Important

The REST API and the client implementation will not be modified until a new major version is released or an update of the openAPI definition. All server-side classes and the plugins are not intended to be used as programming library. They could be updated or removed then a new minor version is released.
The REST API and the client implementation will not be modified - if not a SNAPSHOT version - until a new major version is released or an update of the openAPI definition. All server-side classes and the plugins are not intended to be used as programming library. They could be updated or removed then a new minor version is released.

# Build Resources

Expand All @@ -60,7 +60,7 @@ Or you can directly push them from maven.
``` shell
MAVEN_OPS='-Xmx2048 -Xms1024' mvn deploy -Ddocker.registry=docker.io -Ddocker.username=eclipsebasyx -Ddocker.password=pwd
```
In addition maven deploy will also deploy your maven artifacts, so you can do everything in one step.
In addition, maven deploy will also deploy your maven artifacts, so you can do everything in one step.

Have a look at the *docker-compose* sub-folder to see how the created images could be referenced in docker-compose files.

Expand Down
26 changes: 1 addition & 25 deletions basyx.aasregistry/basyx.aasregistry-plugins/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
# Basyx AAS Registry Plugins

This project provides two maven plugins.

Using the first plugin, you can perform an overlay operation based on two YAML files. This could be quite useful when you want to extend existing openAPI definitions or want to enhance a definition with annotations that should be processed by an openAPI-generator.

To use the plugin embed this snippet into your POM file and specify an appropriate version:

``` xml
<plugin>
<groupId> org.eclipse.digitaltwin.basyx.aasregistry.service</groupId>
<artifactId>basyx.aasregistry-plugins</artifactId>
<executions>
<execution>
<goals>
<goal>yaml-overlay</goal>
</goals>
</execution>
</executions>
<configuration>
<base>${project.basedir}/base.yaml</base>
<overlay>${project.basedir}/overlay.yaml</overlay>
<out>${project.basedir}/result.yaml</out>
</configuration>
</plugin>
```
The other maven plugin can be used to generate builder classes that create search paths for the registry-service-based POJO classes. The plugin traverses the referenced class and its fields and generates a class that can be used to set up these search paths.
This project provides a maven plugin that can be used to generate builder classes that create search paths for the registry-service-based POJO classes. The plugin traverses the referenced class and its fields and generates a class that can be used to set up these search paths.

As we use the same search path in our AAS registry client, this generator can also be used there. The main benefit is that we will avoid typos when using the generated client and do not need to specify the string directly.

Expand Down
63 changes: 63 additions & 0 deletions basyx.submodelregistry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Basyx Submodel Registry

This is a Java-based implementation of the Submodel Registry server and client based on the corresponding [Open-API specification](ttps://app.swaggerhub.com/apis/Plattform_i40/SubmodelRegistryServiceSpecification/V3.0.1_SSP-001) of the German Plattform Industrie 4.0.

[basyx.submodelregistry-client-native](basyx.submodelregistry-client-native/README.md) can be used to interact with the backend to register or unregister descriptors and submodels or perform search operations.

[basyx.submodelregistry-service](basyx.submodelregistry-service/README.md) provides the application server to access the submodel descriptor storage and offers an API for REST-based communication.

[basyx.submodelregistry-service-basemodel](basyx.submodelregistry-service-basemodel/README.md) provides a base model implementation that should be used if you do not need specific model annotations for your storage. It is used for the in-memory storage implementation and you need to add it explicitly as dependency for your server deployment as it is defined as 'provided' dependency in the [basyx.submodelregistry-service](basyx.submodelregistry-service/README.md) POM.

[basyx.submodelregistry-service-basetests](basyx.submodelregistry-service-basetests/README.md) provides helper classes and abstract test classes that can be extended in storage tests or integration tests. The abstract test classes already define test methods so that you will get a good test coverage without writing any additional test cases.

[basyx.submodelregistry-service-mongodb-storage](basyx.submodelregistry-service-mongodb-storage/README.md) provides a registry-storage implementation based on mongoDB that could be used as storage for [submodelregistry-service](basyx.submodelregistry-service/README.md). It comes with java-based model classes, annotated with mongoDB annotations.

[basyx.submodelregistry-service-inmemory-storage](basyx.submodelregistry-service-inmemory-storage/README.md) provides a non-persistent registry-storage implementation where instances are stored in hash maps. It can be used as storage for [submodelregistry-service](basyx.submodelregistry-service/README.md).

[basyx.submodelregistry-service-kafka-events](basyx.submodelregistry-service-kafka-events/README.md) extends basyx.submodelregistry-service with a registry-event-sink implementation that delivers shell descriptor and submodel registration events using Apache Kafka. The default provided by submodelregistry-service just logs the events.

[basyx.submodelregistry-service-release-kafka-mongodb](basyx.submodelregistry-service-release-kafka-mongodb/README.md) is used to combine the server artifacts to a release image that uses [Apache Kafka](https://kafka.apache.org/) as event sink and [MongoDB](https://www.mongodb.com/) as storage.

[basyx.submodelregistry-service-release-kafka-mem](basyx.submodelregistry-service-release-kafka-mem/README.md) is used to combine the server artifacts to a release image that uses Apache Kafka as event sink and an in-memory storage.

[basyx.submodelregistry-service-release-log-mongodb](basyx.submodelregistry-service-release-log-mongodb/README.md) is used to combine the server artifacts to a release image that logs registry events and uses MongoDB as data storage.

[basyx.submodelregistry-service-release-log-mem](basyx.submodelregistry-service-release-log-mem/README.md) is used to combine the server artifacts to a release image that logs registry events and an in-memory storage.

A docker-compose file that illustrates the setup can be found in the [docker-compose](docker-compose/docker-compose.yml) folder.


# Important

The REST API and the client implementation will not be modified - if not a SNAPSHOT version - until a new major version is released or an update of the openAPI definition. All server-side classes and the plugins are not intended to be used as programming library. They could be updated or removed then a new minor version is released.

# Build Resources

To build the images run these commands from this folder or for the parent project pom:

Install maven generate jars:

``` shell
mvn clean install
```

In order to build the docker images, you need to specify *docker.username* and *docker.password* properties (here without running tests):

``` shell
MAVEN_OPS='-Xmx2048 -Xms1024' mvn clean install -DskipTests -Ddocker.username=eclipsebasyx -Ddocker.password=""
```

You can now check your images from command-line and push the images:
``` shell
docker images ...
```
Or you can directly push them from maven.

``` shell
MAVEN_OPS='-Xmx2048 -Xms1024' mvn deploy -Ddocker.registry=docker.io -Ddocker.username=eclipsebasyx -Ddocker.password=pwd
```
In addition, maven deploy will also deploy your maven artifacts, so you can do everything in one step.

Have a look at the *docker-compose* sub-folder to see how the created images could be referenced in docker-compose files.

Consider updating the [image name pattern](pom.xml#L16) if you want a different image name.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Basyx Submodel Registry Client Native

This is the generated java openAPI client (based on native java with jackson parsing) that can be used to communicate with the submodel registry server.

To use the client in your maven projects define the following dependency:
```xml
<dependency>
<groupId>org.eclipse.digitaltwin.basyx.submodelregistry</groupId>
<artifactId>basyx.submodelregistry-client-native</artifactId>
</dependency>
```
Empty file.
130 changes: 130 additions & 0 deletions basyx.submodelregistry/basyx.submodelregistry-client-native/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.submodelregistry</artifactId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>

<artifactId>basyx.submodelregistry-client-native</artifactId>

<packaging>jar</packaging>
<properties>
<openapi.result.folder>${project.basedir}/${openapi.folder.name}</openapi.result.folder>
<openapi.result.file>${openapi.result.folder}/${openapi.name}</openapi.result.file>
</properties>
<build>
<sourceDirectory>${generated.folder}/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/${generated.folder}</directory>
<excludes>
<exclude>**/.gitkeep</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>${openapi.result.folder}</directory>
<excludes>
<exclude>**/.gitkeep</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>de.dfki.cos.basys.common</groupId>
<artifactId>jsonpatch-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>jsonpatch-maven-plugin</goal>
</goals>
<configuration>
<input>${project.basedir}/../${openapi.folder.name}/${openapi.base.name}</input>
<patch>${project.basedir}/../${openapi.folder.name}/${patch.base-extensions.name}</patch>
<output>${openapi.result.file}</output>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatorName>java</generatorName>
<library>native</library>
<inputSpec>${openapi.result.file}</inputSpec>
<output>${project.basedir}/${generated.folder}</output>
<apiPackage>org.eclipse.digitaltwin.basyx.submodelregistry.client.api</apiPackage>
<invokerPackage>org.eclipse.digitaltwin.basyx.submodelregistry.client</invokerPackage>
<modelPackage>org.eclipse.digitaltwin.basyx.submodelregistry.client.model</modelPackage>
<generateModels>true</generateModels>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateApiDocumentation>false</generateApiDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<templateDirectory>${project.basedir}/templates</templateDirectory>
<supportingFilesToGenerate>AbstractOpenApiSchema.java,ServerConfiguration.java,ServerVariable.java,Configuration.java,JSON.java,ApiException.java,ApiResponse.java,ApiClient.java,Pair.java,RFC3339DateFormat.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<sourceFolder>java</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.9.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 873308f

Please sign in to comment.