diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..e18bc2e45
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,62 @@
+# Handle line endings automatically for files detected as text
+# and leave all files detected as binary untouched.
+* text=auto
+
+# Java sources
+*.java text diff=java
+*.kt text diff=kotlin
+*.groovy text diff=java
+*.scala text diff=java
+*.gradle text diff=java
+*.gradle.kts text diff=kotlin
+
+# These files are text and should be normalized (Convert crlf => lf)
+*.css text diff=css
+*.scss text diff=css
+*.sass text
+*.df text
+*.htm text diff=html
+*.html text diff=html
+*.js text
+*.mjs text
+*.cjs text
+*.jsp text
+*.jspf text
+*.jspx text
+*.properties text
+*.tld text
+*.tag text
+*.tagx text
+*.xml text
+
+# These files are binary and should be left untouched
+# (binary is a macro for -text -diff)
+*.class binary
+*.dll binary
+*.ear binary
+*.jar binary
+*.so binary
+*.war binary
+*.jks binary
+
+
+# Graphics
+*.png binary
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.tif binary
+*.tiff binary
+*.ico binary
+
+# Documents
+*.md text diff=markdown
+
+# Serialisation
+*.json text
+*.toml text
+*.xml text
+*.yaml text
+*.yml text
+
+
diff --git a/.github/workflows/docfx-build-publish.yml b/.github/workflows/docfx-build-publish.yml
deleted file mode 100644
index 8cc5c73d8..000000000
--- a/.github/workflows/docfx-build-publish.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-# This workflow will build and publish documentation with docfx
-# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
-
-name: Documentation Publish
-
-on:
- push:
- branches:
- - main
-
-jobs:
- build_docs:
- runs-on: ubuntu-latest
- name: Build and publish documentation
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Build docfx
- uses: nikeee/docfx-action@v1.0.0
- with:
- args: docs/docfx.json
-
- - name: Publish
- uses: peaceiris/actions-gh-pages@v3
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: docs/_site
- force_orphan: true
diff --git a/.github/workflows/maven-publish-snapshots.yml b/.github/workflows/maven-publish-snapshots.yml
index 97274da10..31d974da5 100644
--- a/.github/workflows/maven-publish-snapshots.yml
+++ b/.github/workflows/maven-publish-snapshots.yml
@@ -30,49 +30,49 @@ jobs:
run: mvn -B package --file pom.xml
- name: Delete old dataformat-parent package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-parent'
- name: Delete old dataformat-core package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-core'
- name: Delete old dataformat-aasx package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-aasx'
- name: Delete old dataformat-xml package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-xml'
- name: Delete old dataformat-aml package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-aml'
- name: Delete old dataformat-rdf package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-rdf'
- name: Delete old dataformat-json package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.dataformat-json'
- name: Delete old validator package
- uses: actions/delete-package-versions@v4
+ uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'io.admin-shell.aas.validator'
diff --git a/README.md b/README.md
index 7ff8ea555..0bec109af 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Eclipse AAS4J
-> :newspaper: The _`Eclipse AAS4J 1.0.0-RC1`_ release is available on Maven Central Repository and includes the
+> :newspaper: The _`Eclipse AAS4J 1.0.4`_ release is available on [Maven Central Repository](https://oss.sonatype.org/#nexus-search;quick~org.eclipse.digitaltwin.aas4j) and includes the
> following artifacts implementing the _AAS Specs – Part 1 V3.0 (final)_: `aas4j-dataformat-core`, `aas4j-dataformat-aasx`,
> `aas4j-dataformat-xml`, `aas4j-dataformat-json`, `aas4j-dataformat-parent`, and `aas4j-model`.
@@ -37,8 +37,6 @@ Please refer to [AAS Model README](model/README.md) for more information.
## Build and Use
-Some examples can be found on the [documentation webpage](https://admin-shell-io.github.io/java-serializer/).
-
You can build the project using Maven by simply executing at the repository
root:
@@ -50,9 +48,9 @@ or by integrating the respective modules as dependencies from [Maven Central](ht
```
org.eclipse.digitaltwin.aas4j
- aas4j-dataformat-json
- latest-version
-
+ aas4j-model
+ 1.0.4
+
```
## AAS4J Project Structure
diff --git a/dataformat-aasx/pom.xml b/dataformat-aasx/pom.xml
index 83054e604..121da2131 100644
--- a/dataformat-aasx/pom.xml
+++ b/dataformat-aasx/pom.xml
@@ -16,6 +16,10 @@
${project.groupId}
aas4j-dataformat-xml
+
+ ${project.groupId}
+ aas4j-dataformat-json
+
${project.groupId}
aas4j-dataformat-core
diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java
index 111f140cc..dc38c5250 100644
--- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java
+++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java
@@ -21,7 +21,6 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@@ -31,13 +30,13 @@
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.internal.AASXUtils;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementWalkerVisitor;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.File;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +53,8 @@ public class AASXDeserializer {
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
- private final XmlDeserializer deserializer;
+ private final XmlDeserializer xmlDeserializer;
+ private final JsonDeserializer jsonDeserializer;
private Environment environment;
private final OPCPackage aasxRoot;
@@ -68,20 +68,40 @@ public class AASXDeserializer {
*/
public AASXDeserializer(InputStream inputStream) throws InvalidFormatException, IOException {
aasxRoot = OPCPackage.open(inputStream);
- this.deserializer = new XmlDeserializer();
+ this.xmlDeserializer = new XmlDeserializer();
+ this.jsonDeserializer = new JsonDeserializer();
}
/**
- * Constructor for custom XML deserialization
- *
- * @param deserializer a custom deserializer used for deserializing the aas environment
+ * Constructor for custom deserialization
+ *
+ * @param xmlDeserializer a custom XML deserializer used for deserializing the aas environment
+ * @param inputStream an input stream to an aasx package that can be read with this instance
+ * @throws InvalidFormatException if aasx package format is invalid
+ * @throws IOException if creating input streams for aasx fails
+ */
+ public AASXDeserializer(XmlDeserializer xmlDeserializer,
+ InputStream inputStream) throws InvalidFormatException, IOException {
+ aasxRoot = OPCPackage.open(inputStream);
+ this.xmlDeserializer = xmlDeserializer;
+ this.jsonDeserializer = new JsonDeserializer();
+ }
+
+ /**
+ * Constructor for custom deserialization
+ *
+ * @param xmlDeserializer a custom XML deserializer used for deserializing the aas environment
+ * @param jsonDeserializer a custom JSON deserializer used for deserializing the aas environment
* @param inputStream an input stream to an aasx package that can be read with this instance
* @throws InvalidFormatException if aasx package format is invalid
* @throws IOException if creating input streams for aasx fails
*/
- public AASXDeserializer(XmlDeserializer deserializer, InputStream inputStream) throws InvalidFormatException, IOException {
+ public AASXDeserializer(XmlDeserializer xmlDeserializer,
+ JsonDeserializer jsonDeserializer,
+ InputStream inputStream) throws InvalidFormatException, IOException {
aasxRoot = OPCPackage.open(inputStream);
- this.deserializer = deserializer;
+ this.xmlDeserializer = xmlDeserializer;
+ this.jsonDeserializer = jsonDeserializer;
}
/**
@@ -98,18 +118,61 @@ public Environment read() throws InvalidFormatException, IOException, Deserializ
if (environment != null) {
return environment;
}
- environment = deserializer.read(getXMLResourceString(aasxRoot));
+ if (MetamodelContentType.XML.equals(getContentType())) {
+ environment = xmlDeserializer.read(getResourceString(aasxRoot));
+ }
+ if (MetamodelContentType.JSON.equals(getContentType())) {
+ environment = jsonDeserializer.read(getResourceString(aasxRoot), Environment.class);
+ }
return environment;
}
+ /**
+ * Currently XML and JSON are supported for deserializing.
+ * @return The content type of the metafile
+ * @throws InvalidFormatException if aasx package format is invalid
+ * @throws IOException if creating input streams for aasx fails
+ */
+ protected MetamodelContentType getContentType() throws InvalidFormatException, IOException {
+ MetamodelContentType contentType;
+ PackagePart packagePart = getPackagePart(aasxRoot);
+ // We also check for the none official content types "test/xml" and "text/json", which are commonly used
+ switch (packagePart.getContentType()) {
+ case "text/xml":
+ case "application/xml":
+ contentType = MetamodelContentType.XML;
+ break;
+ case "text/json":
+ case "application/json":
+ contentType = MetamodelContentType.JSON;
+ break;
+ default:
+ throw new RuntimeException("The following content type is not supported: " + packagePart.getContentType());
+ }
+ return contentType;
+ }
+
/**
* Return the Content of the xml file in the aasx-package as String
- *
+ *
+ * @deprecated This method will be replaced by the method {@link AASXDeserializer#getResourceString()}.
+ *
* @throws InvalidFormatException if aasx package format is invalid
* @throws IOException if creating input streams for aasx fails
*/
+ @Deprecated
public String getXMLResourceString() throws InvalidFormatException, IOException {
- return getXMLResourceString(this.aasxRoot);
+ return getResourceString(this.aasxRoot);
+ }
+
+ /**
+ * Return the Content of the xml or json file in the aasx-package as String
+ *
+ * @throws InvalidFormatException if aasx package format is invalid
+ * @throws IOException if creating input streams for aasx fails
+ */
+ public String getResourceString() throws InvalidFormatException, IOException {
+ return getResourceString(this.aasxRoot);
}
/**
@@ -136,13 +199,14 @@ public List getRelatedFiles() throws InvalidFormatException, IOExc
return files;
}
- private String getXMLResourceString(OPCPackage aasxPackage) throws InvalidFormatException, IOException {
+ private PackagePart getPackagePart(OPCPackage aasxPackage) throws InvalidFormatException, IOException {
PackagePart originPart = getOriginPart(aasxPackage);
-
PackageRelationshipCollection originRelationships = getXMLDocumentRelation(originPart);
+ return originPart.getRelatedPart(originRelationships.getRelationship(0));
+ }
- PackagePart xmlPart = originPart.getRelatedPart(originRelationships.getRelationship(0));
-
+ private String getResourceString(OPCPackage aasxPackage) throws InvalidFormatException, IOException {
+ PackagePart xmlPart = getPackagePart(aasxPackage);
return readContentFromPackagePart(xmlPart);
}
@@ -207,27 +271,14 @@ private List parseReferencedFilePathsFromAASX() throws IOException, Inva
&& aas.getAssetInformation().getDefaultThumbnail() != null
&& aas.getAssetInformation().getDefaultThumbnail().getPath() != null)
.forEach(aas -> paths.add(aas.getAssetInformation().getDefaultThumbnail().getPath()));
- environment.getSubmodels().forEach(sm -> paths.addAll(parseElements(sm.getSubmodelElements())));
- return paths;
- }
-
- /**
- * Gets the file paths from a collection of ISubmodelElement
- *
- * @param elements the submodel elements to process
- * @return the Paths from the File elements
- */
- private List parseElements(Collection elements) {
- List paths = new ArrayList<>();
- for (SubmodelElement element : elements) {
- if (element instanceof File) {
- File file = (File) element;
- paths.add(file.getValue());
- } else if (element instanceof SubmodelElementCollection) {
- SubmodelElementCollection collection = (SubmodelElementCollection) element;
- paths.addAll(parseElements(collection.getValue()));
+ new AssetAdministrationShellElementWalkerVisitor() {
+ @Override
+ public void visit(File file) {
+ if(file != null && file.getValue() != null) {
+ paths.add(file.getValue());
+ }
}
- }
+ }.visit(environment);
return paths;
}
diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java
index b8d13befd..75690d487 100644
--- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java
+++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java
@@ -19,8 +19,8 @@
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.UUID;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -31,14 +31,13 @@
import org.apache.poi.openxml4j.opc.RelationshipSource;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.internal.AASXUtils;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementWalkerVisitor;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonSerializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlSerializer;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.File;
-import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,41 +50,60 @@ public class AASXSerializer {
private static final String MIME_PLAINTXT = "text/plain";
private static final String MIME_XML = "application/xml";
+ private static final String MIME_JSON = "application/json";
+ public static final String OPC_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/relationships";
public static final String AASX_NAMESPACE = "http://admin-shell.io/aasx/relationships";
public static final String ORIGIN_RELTYPE = AASX_NAMESPACE + "/aasx-origin";
public static final String ORIGIN_PATH = "/aasx/aasx-origin";
- public static final String ORIGIN_CONTENT = "Intentionally empty.";
+ public static final String ORIGIN_CONTENT = "Intentionally empty";
public static final String AASSPEC_RELTYPE = AASX_NAMESPACE + "/aas-spec";
public static final String XML_PATH = "/aasx/xml/content.xml";
+ public static final String JSON_PATH = "/aasx/json/content.json";
public static final String AASSUPPL_RELTYPE = AASX_NAMESPACE + "/aas-suppl";
+ public static final String AAS_THUMBNAIL_RELTYPE = OPC_NAMESPACE + "/metadata/thumbnail";
+
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
private final XmlSerializer xmlSerializer;
+ private final JsonSerializer jsonSerializer;
/**
* Default constructor
*/
public AASXSerializer() {
this.xmlSerializer = new XmlSerializer();
+ this.jsonSerializer = new JsonSerializer();
}
/**
- * Constructor with a custom serializer for serializing the aas environment
- *
- * @param xmlSerializer a custom serializer used for serializing the aas environment
+ * Constructor with a custom XML serializer for serializing the aas environment
+ *
+ * @param xmlSerializer a custom serializer used for serializing the aas environment in XML
*/
public AASXSerializer(XmlSerializer xmlSerializer) {
this.xmlSerializer = xmlSerializer;
+ this.jsonSerializer = new JsonSerializer();
}
/**
- * Generates the .aasx file and writes it to the given OutputStream
- *
+ * Constructor with custom serializers for serializing the aas environment
+ *
+ * @param xmlSerializer a custom serializer used for serializing the aas environment in XML
+ * @param jsonSerializer a custom serializer used for serializing the aas environment in JSON
+ */
+ public AASXSerializer(XmlSerializer xmlSerializer, JsonSerializer jsonSerializer) {
+ this.xmlSerializer = xmlSerializer;
+ this.jsonSerializer = jsonSerializer;
+ }
+
+ /**
+ * Generates the .aasx file and writes it to the given OutputStream, by using XML as the default content type.
+ *
* @param environment the aas environment that will be included in the aasx package as an xml serialization
* @param files related inMemory files that belong to the given aas environment
* @param os an output stream for writing the aasx package
@@ -94,7 +112,22 @@ public AASXSerializer(XmlSerializer xmlSerializer) {
*/
public void write(Environment environment, Collection files, OutputStream os)
throws SerializationException, IOException {
- prepareFilePaths(environment.getSubmodels());
+
+ write(environment, files, os, MetamodelContentType.XML);
+ }
+
+ /**
+ * Generates the .aasx file and writes it to the given OutputStream
+ *
+ * @param environment the aas environment that will be included in the aasx package as an xml serialization
+ * @param files related inMemory files that belong to the given aas environment
+ * @param os an output stream for writing the aasx package
+ * @param contentType the content type for the metamodel serialization
+ * @throws SerializationException if serializing the given elements fails
+ * @throws IOException if creating output streams for aasx fails
+ */
+ public void write(Environment environment, Collection files, OutputStream os, MetamodelContentType contentType)
+ throws SerializationException, IOException {
OPCPackage rootPackage = OPCPackage.create(os);
@@ -102,20 +135,38 @@ public void write(Environment environment, Collection files, Outpu
PackagePart origin = createAASXPart(rootPackage, rootPackage, ORIGIN_PATH, MIME_PLAINTXT, ORIGIN_RELTYPE,
ORIGIN_CONTENT.getBytes());
- // Convert the given Metamodels to XML
- String xml = xmlSerializer.write(environment);
-
- // Save the XML to aasx/xml/content.xml
- PackagePart xmlPart = createAASXPart(rootPackage, origin, XML_PATH, MIME_XML, AASSPEC_RELTYPE, xml.getBytes(DEFAULT_CHARSET));
+ PackagePart packagePart;
+ switch (contentType) {
+ case JSON:
+ // Convert the given Metamodels to JSON
+ String json = jsonSerializer.write(environment);
+ // Save the JSON to aasx/json/content.json
+ packagePart = createAASXPart(rootPackage, origin, JSON_PATH, MIME_JSON, AASSPEC_RELTYPE, json.getBytes(DEFAULT_CHARSET));
+ break;
+ case XML:
+ // Convert the given Metamodels to XML
+ String xml = xmlSerializer.write(environment);
+ // Save the XML to aasx/xml/content.xml
+ packagePart = createAASXPart(rootPackage, origin, XML_PATH, MIME_XML, AASSPEC_RELTYPE, xml.getBytes(DEFAULT_CHARSET));
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported content type: " + contentType);
+ }
- storeFilesInAASX(environment, files, rootPackage, xmlPart);
+ environment.getAssetAdministrationShells().stream().filter(aas -> aas.getAssetInformation() != null
+ && aas.getAssetInformation().getDefaultThumbnail() != null
+ && aas.getAssetInformation().getDefaultThumbnail().getPath() != null)
+ .forEach(aas -> createParts(files,
+ AASXUtils.removeFilePartOfURI(aas.getAssetInformation().getDefaultThumbnail().getPath()),
+ rootPackage, rootPackage, aas.getAssetInformation().getDefaultThumbnail().getContentType(), AAS_THUMBNAIL_RELTYPE));
+ storeFilesInAASX(environment, files, rootPackage, packagePart);
saveAASX(os, rootPackage);
}
/**
* Stores the files from the Submodels in the .aasx file
- *
+ *
* @param environment the Environment
* @param files the content of the files
* @param rootPackage the OPCPackage
@@ -123,15 +174,8 @@ public void write(Environment environment, Collection files, Outpu
*/
private void storeFilesInAASX(Environment environment, Collection files, OPCPackage rootPackage,
PackagePart xmlPart) {
- environment.getAssetAdministrationShells().stream().filter(aas -> aas.getAssetInformation() != null
- && aas.getAssetInformation().getDefaultThumbnail() != null
- && aas.getAssetInformation().getDefaultThumbnail().getPath() != null)
- .forEach(aas -> createParts(files,
- AASXUtils.removeFilePartOfURI(aas.getAssetInformation().getDefaultThumbnail().getPath()),
- rootPackage, xmlPart, aas.getAssetInformation().getDefaultThumbnail().getContentType()));
- environment.getSubmodels().forEach(sm ->
- findFileElements(sm.getSubmodelElements()).forEach(file -> createParts(files,
- AASXUtils.removeFilePartOfURI(file.getValue()), rootPackage, xmlPart, file.getContentType())));
+ findFileElements(environment).forEach(file -> createParts(files,
+ AASXUtils.removeFilePartOfURI(file.getValue()), rootPackage, xmlPart, file.getContentType(), AASSUPPL_RELTYPE));
}
/**
@@ -142,13 +186,14 @@ private void storeFilesInAASX(Environment environment, Collection
* @param rootPackage the OPCPackage
* @param xmlPart the Part the files should be related to
* @param contentType the contentType of the file
+ * @param relType the relationship type
*/
private void createParts(Collection files, String filePath, OPCPackage rootPackage,
- PackagePart xmlPart, String contentType) {
+ RelationshipSource xmlPart, String contentType, String relType) {
try {
InMemoryFile content = findFileByPath(files, filePath);
logger.trace("Writing file '{}' to .aasx.", filePath);
- createAASXPart(rootPackage, xmlPart, filePath, contentType, AASSUPPL_RELTYPE, content.getFileContent());
+ createAASXPart(rootPackage, xmlPart, filePath, contentType, relType, content.getFileContent());
} catch (RuntimeException e) {
// Log that a file is missing and continue building the .aasx
logger.warn("Could not add File '{}'. It was not contained in given InMemoryFiles.", filePath, e);
@@ -157,7 +202,7 @@ private void createParts(Collection files, String filePath, OPCPac
/**
* Saves the OPCPackage to the given OutputStream
- *
+ *
* @param os the Stream to be saved to
* @param rootPackage the Package to be saved
* @throws IOException if creating output streams for aasx fails
@@ -170,7 +215,7 @@ private void saveAASX(OutputStream os, OPCPackage rootPackage) throws IOExceptio
/**
* Generates a UUID. Every element of the .aasx needs a unique Id according to
* the specification
- *
+ *
* @return UUID
*/
private String createUniqueID() {
@@ -180,7 +225,7 @@ private String createUniqueID() {
/**
* Creates a Part (a file in the .aasx) of the .aasx and adds it to the Package
- *
+ *
* @param root the OPCPackage
* @param relateTo the Part of the OPC the relationship of the new Part should be added to
* @param path the path inside the .aasx where the new Part should be created
@@ -206,13 +251,13 @@ private PackagePart createAASXPart(OPCPackage root, RelationshipSource relateTo,
}
writeDataToPart(part, content);
root.registerPartAndContentType(part);
- relateTo.addRelationship(partName, TargetMode.INTERNAL, relType, createUniqueID());
+ relateTo.addRelationship(partName, TargetMode.EXTERNAL, relType, createUniqueID());
return part;
}
/**
* Writes the content of a byte[] to a Part
- *
+ *
* @param part the Part to be written to
* @param content the content to be written to the part
*/
@@ -226,40 +271,28 @@ private void writeDataToPart(PackagePart part, byte[] content) {
}
/**
- * Gets the File elements from a collection of elements Also recursively
+ * Gets the File elements from an environment
* searches in SubmodelElementCollections
- *
- * @param elements the Elements to be searched for File elements
+ *
+ * @param environment the Environment
* @return the found Files
*/
- private Collection findFileElements(Collection elements) {
- Collection files = new ArrayList<>();
-
- for (SubmodelElement element : elements) {
- if (element instanceof File) {
- files.add((File) element);
- } else if (element instanceof SubmodelElementCollection) {
- // Recursive call to deal with SubmodelElementCollections
- files.addAll(findFileElements(((SubmodelElementCollection) element).getValue()));
+ private Collection findFileElements(Environment environment) {
+ Collection files = new HashSet<>();
+ new AssetAdministrationShellElementWalkerVisitor() {
+ @Override
+ public void visit(File file) {
+ if(file != null && file.getValue() != null) {
+ files.add(file);
+ }
}
- }
-
+ }.visit(environment);
return files;
}
- /**
- * Replaces the path in all File Elements with the result of preparePath
- *
- * @param submodels the Submodels
- */
- private void prepareFilePaths(Collection submodels) {
- submodels.stream()
- .forEach(sm -> findFileElements(sm.getSubmodelElements()).stream().forEach(f -> f.setValue(preparePath(f.getValue()))));
- }
-
/**
* Finds an InMemoryFile by its path
- *
+ *
* @param files the InMemoryFiles
* @param path the path of the wanted file
* @return the InMemoryFile if it was found; else null
@@ -273,17 +306,4 @@ private InMemoryFile findFileByPath(Collection files, String path)
throw new RuntimeException("The wanted file '" + path + "' was not found in the given files.");
}
- /**
- * Removes the serverpart from a path and ensures it starts with "file://"
- *
- * @param path the path to be prepared
- * @return the prepared path
- */
- private String preparePath(String path) {
- if (path.startsWith("/")) {
- path = "file://" + path;
- }
- return path;
- }
-
}
diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXValidator.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXValidator.java
index c11a8544c..a92ed8837 100644
--- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXValidator.java
+++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXValidator.java
@@ -16,6 +16,8 @@
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonSchemaValidator;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlSchemaValidator;
import org.xml.sax.SAXException;
@@ -29,10 +31,12 @@
public class AASXValidator {
private XmlSchemaValidator xmlValidator;
+ private JsonSchemaValidator jsonValidator;
private AASXDeserializer deserializer;
public AASXValidator(InputStream is) throws SAXException, IOException, InvalidFormatException {
this.xmlValidator = new XmlSchemaValidator();
+ this.jsonValidator = new JsonSchemaValidator();
this.deserializer = new AASXDeserializer(is);
}
@@ -44,8 +48,15 @@ public AASXValidator(InputStream is) throws SAXException, IOException, InvalidFo
* @throws InvalidFormatException specified URI is invalid
*/
public Set validateSchema() throws IOException, InvalidFormatException {
- String file = deserializer.getXMLResourceString();
- return xmlValidator.validateSchema(file);
+ String file = deserializer.getResourceString();
+ Set errorMessages = null;
+ if (MetamodelContentType.XML.equals(deserializer.getContentType())) {
+ errorMessages = xmlValidator.validateSchema(file);
+ }
+ else if (MetamodelContentType.JSON.equals(deserializer.getContentType())) {
+ errorMessages = jsonValidator.validateSchema(file);
+ }
+ return errorMessages;
}
}
diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/MetamodelContentType.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/MetamodelContentType.java
new file mode 100644
index 000000000..f6b1ccb4a
--- /dev/null
+++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/MetamodelContentType.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;
+
+/**
+ * Supported ContentType's for serializing and deserializing Metamodels.
+ */
+public enum MetamodelContentType {
+
+ JSON,
+ XML
+
+}
diff --git a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/AASXDeserializerTest.java b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/AASXDeserializerTest.java
index c13042781..84ab7eb7f 100644
--- a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/AASXDeserializerTest.java
+++ b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/AASXDeserializerTest.java
@@ -31,12 +31,13 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXSerializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.InMemoryFile;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.MetamodelContentType;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.File;
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
@@ -44,6 +45,7 @@
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultFile;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -64,8 +66,8 @@ public void roundTrip() throws SerializationException, IOException, InvalidForma
fileList.add(inMemoryFile);
fileList.add(inMemoryFileThumbnail);
- java.io.File file = tempFolder.newFile("output.aasx");
-
+ // check round trip with XML content
+ java.io.File file = tempFolder.newFile("output-xml.aasx");
new AASXSerializer().write(AASSimple.createEnvironment(), fileList, new FileOutputStream(file));
InputStream in = new FileInputStream(file);
@@ -73,8 +75,17 @@ public void roundTrip() throws SerializationException, IOException, InvalidForma
assertEquals(AASSimple.createEnvironment(), deserializer.read());
assertTrue(CollectionUtils.isEqualCollection(fileList, deserializer.getRelatedFiles()));
- }
+ // check round trip with JSON content
+ file = tempFolder.newFile("output-json.aasx");
+ new AASXSerializer().write(AASSimple.createEnvironment(), fileList, new FileOutputStream(file), MetamodelContentType.JSON);
+
+ in = new FileInputStream(file);
+ deserializer = new AASXDeserializer(in);
+
+ assertEquals(AASSimple.createEnvironment(), deserializer.read());
+ assertTrue(CollectionUtils.isEqualCollection(fileList, deserializer.getRelatedFiles()));
+ }
@Test
public void relatedFilesAreOnlyResolvedIfWithinAASX() throws IOException, SerializationException, InvalidFormatException, DeserializationException {
Submodel fileSm = new DefaultSubmodel.Builder().id("doesNotMatter").submodelElements(createFileSubmodelElements()).build();
@@ -92,6 +103,37 @@ public void relatedFilesAreOnlyResolvedIfWithinAASX() throws IOException, Serial
assertEquals(Collections.singletonList(inMemoryFile), deserializer.getRelatedFiles());
}
+ @Test
+ public void emptyFiles() throws IOException, SerializationException, InvalidFormatException, DeserializationException {
+ File emptyFile = new DefaultFile.Builder().idShort("emptyFile").contentType(null).value(null).build();
+ Submodel fileSm = new DefaultSubmodel.Builder().id("doesNotMatter").submodelElements(emptyFile).build();
+ Environment env = new DefaultEnvironment.Builder().submodels(fileSm).build();
+
+ java.io.File file = tempFolder.newFile("output.aasx");
+ new AASXSerializer().write(env, null, new FileOutputStream(file));
+
+ InputStream in = new FileInputStream(file);
+ AASXDeserializer deserializer = new AASXDeserializer(in);
+ assertTrue(deserializer.getRelatedFiles().isEmpty());
+ }
+
+ @Test
+ public void filesInElementList() throws IOException, SerializationException, InvalidFormatException, DeserializationException {
+ DefaultSubmodelElementList elementList = new DefaultSubmodelElementList.Builder().value(createFileSubmodelElements()).build();
+ Submodel fileSm = new DefaultSubmodel.Builder().id("doesNotMatter").submodelElements(elementList).build();
+ Environment env = new DefaultEnvironment.Builder().submodels(fileSm).build();
+
+ byte[] image = { 0, 1, 2, 3, 4 };
+ InMemoryFile inMemoryFile = new InMemoryFile(image, "file:///aasx/internalFile.jpg");
+
+ java.io.File file = tempFolder.newFile("output.aasx");
+ new AASXSerializer().write(env, Collections.singleton(inMemoryFile), new FileOutputStream(file));
+
+ InputStream in = new FileInputStream(file);
+ AASXDeserializer deserializer = new AASXDeserializer(in);
+ assertEquals(Collections.singletonList(inMemoryFile), deserializer.getRelatedFiles());
+ }
+
private static List createFileSubmodelElements() {
File internalFile = new DefaultFile.Builder().idShort("internalFile").contentType("image/jpeg").value("file:///aasx/internalFile.jpg").build();
File externalFile = new DefaultFile.Builder().idShort("externalFile").contentType("image/jpeg").value("http://doesNotMatter.com/image").build();
diff --git a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java
index 856ed8916..9d77fbf0c 100644
--- a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java
+++ b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java
@@ -16,12 +16,12 @@
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.deserialization;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXSerializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXValidator;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.InMemoryFile;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -48,8 +48,11 @@ public class ValidationTest {
public void validateXmlInsideAasx() throws SerializationException, IOException, InvalidFormatException, DeserializationException, ParserConfigurationException, SAXException {
List fileList = new ArrayList<>();
byte[] operationManualContent = { 0, 1, 2, 3, 4 };
+ byte[] thumbnail = { 0, 1, 2, 3, 4 };
InMemoryFile inMemoryFile = new InMemoryFile(operationManualContent, "file:///aasx/OperatingManual.pdf");
+ InMemoryFile inMemoryFileThumbnail = new InMemoryFile(thumbnail, "file:///master/verwaltungsschale-detail-part1.png");
fileList.add(inMemoryFile);
+ fileList.add(inMemoryFileThumbnail);
File file = tempFolder.newFile("output.aasx");
diff --git a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/serialization/AASXSerializerTest.java b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/serialization/AASXSerializerTest.java
index aee0d6031..15c64ec8f 100644
--- a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/serialization/AASXSerializerTest.java
+++ b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/serialization/AASXSerializerTest.java
@@ -16,11 +16,12 @@
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.serialization;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXSerializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.InMemoryFile;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.MetamodelContentType;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple;
-import org.junit.Before;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
import org.junit.Test;
import javax.xml.parsers.ParserConfigurationException;
@@ -28,8 +29,10 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.BiConsumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -38,57 +41,76 @@
public class AASXSerializerTest {
+ private static final String RELS_PATH_URI = "file:///_rels/.rels";
private static final String XML_PATH_URI = "file:///aasx/xml/content.xml";
+ private static final String JSON_PATH_URI = "file:///aasx/json/content.json";
private static final String ORIGIN_PATH_URI = "file:///aasx/aasx-origin";
private List fileList = new ArrayList<>();
- @Before
- public void setup() throws IOException {
+ @Test
+ public void testBuildAASXFull() throws IOException, TransformerException, ParserConfigurationException, SerializationException {
byte[] operationManualContent = { 0, 1, 2, 3, 4 };
+ InMemoryFile file = new InMemoryFile(operationManualContent, "file:///TestFile.pdf");
+ fileList.add(file);
+ // This stream can be used to write the .aasx directly to a file
+ // FileOutputStream out = new FileOutputStream("path/to/test.aasx");
+
+ // This stream keeps the output of the AASXFactory only in memory
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ // validate AASX with XML content
+ new AASXSerializer().write(AASFull.createEnvironment(), fileList, out, MetamodelContentType.XML);
+ validateAASX(out, XML_PATH_URI, List.of(AASXSerializerTest::assertRootXml));
+
+ out = new ByteArrayOutputStream();
+ // validate AASX with JSON content
+ new AASXSerializer().write(AASFull.createEnvironment(), fileList, out, MetamodelContentType.JSON);
+ validateAASX(out, JSON_PATH_URI, List.of(AASXSerializerTest::assertRootJson));
+ }
+
+ @Test
+ public void testBuildAASXSimple() throws IOException, TransformerException, ParserConfigurationException, SerializationException {
byte[] thumbnail = { 0, 1, 2, 3, 4 };
+ byte[] operationManualContent = { 0, 1, 2, 3, 4 };
InMemoryFile file = new InMemoryFile(operationManualContent, "file:///aasx/OperatingManual.pdf");
InMemoryFile inMemoryFileThumbnail = new InMemoryFile(thumbnail, "file:///master/verwaltungsschale-detail-part1.png");
fileList.add(file);
fileList.add(inMemoryFileThumbnail);
- }
-
- @Test
- public void testBuildAASX() throws IOException, TransformerException, ParserConfigurationException, SerializationException {
-
// This stream can be used to write the .aasx directly to a file
// FileOutputStream out = new FileOutputStream("path/to/test.aasx");
// This stream keeps the output of the AASXFactory only in memory
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+ // validate AASX with XML content
new AASXSerializer().write(AASSimple.createEnvironment(), fileList, out);
+ validateAASX(out, XML_PATH_URI, List.of(AASXSerializerTest::assertRootXml, AASXSerializerTest::assertThumbnailReference));
- validateAASX(out);
+ out = new ByteArrayOutputStream();
+ // validate AASX with JSON content
+ new AASXSerializer().write(AASSimple.createEnvironment(), fileList, out, MetamodelContentType.JSON);
+ validateAASX(out, JSON_PATH_URI, List.of(AASXSerializerTest::assertRootJson, AASXSerializerTest::assertThumbnailReference));
}
- private void validateAASX(ByteArrayOutputStream byteStream) throws IOException {
+ private void validateAASX(ByteArrayOutputStream byteStream, String contentFilePath, List> fileValidators) {
ZipInputStream in = new ZipInputStream(new ByteArrayInputStream(byteStream.toByteArray()));
- ZipEntry zipEntry = null;
+ ZipEntry zipEntry;
ArrayList filePaths = new ArrayList<>();
- while ((zipEntry = in.getNextEntry()) != null) {
- if (zipEntry.getName().equals(XML_PATH_URI)) {
-
- // Read the first 5 bytes of the XML file to make sure it is in fact XML file
- // No further test of XML file necessary as XML-Converter is tested separately
- byte[] buf = new byte[5];
- in.read(buf);
- assertEquals(" validator : fileValidators) {
+ validator.accept(zipEntry, in);
+ }
+ // Write the paths of all files contained in the .aasx into filePaths
+ filePaths.add("file:///" + zipEntry.getName());
}
-
- // Write the paths of all files contained in the .aasx into filePaths
- filePaths.add("file:///" + zipEntry.getName());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- assertTrue(filePaths.contains(XML_PATH_URI));
+ assertTrue(filePaths.contains(contentFilePath));
assertTrue(filePaths.contains(ORIGIN_PATH_URI));
// Check if all expected files are present
@@ -99,4 +121,48 @@ private void validateAASX(ByteArrayOutputStream byteStream) throws IOException {
}
}
+
+ private static void assertRootXml(ZipEntry zipEntry, ZipInputStream in) {
+ if (!XML_PATH_URI.endsWith(zipEntry.getName())) {
+ return;
+ }
+ // Read the first 5 bytes of the XML file to make sure it is in fact XML file
+ // No further test of XML file necessary as XML-Converter is tested separately
+ byte[] buf = new byte[5];
+ try {
+ in.read(buf);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ assertEquals("> MODEL_TYPE_SUPERCLASSES = Set.of(Referable.class, DataSpecificationContent.class);
- /**
- * Expanded list of all classes that shall be annotated with the modelType
- * property.
- */
- public static final Set> TYPES_WITH_MODEL_TYPE;
- /**
- * Map of all interfaces and their subinterfaces defined in the
- * MODEL_PACKAGE_NAME package.
- */
- public static final Map, Set>> SUBTYPES;
- /**
- * List of all interfaces classes defined by the AAS.
- */
- @SuppressWarnings("rawtypes")
- public static final Set INTERFACES;
- /**
- * Expanded list of all mixin classes defined in the
- * JSON_MIXINS_PACKAGE_NAME package together with the corresponding class
- * they should be applied to.
- */
- public static final Map, Class>> JSON_MIXINS;
- /**
- * Expanded list of all mixin classes defined in the XML_MIXINS_PACKAGE_NAME
- * package together with the corresponding class they should be applied to.
- */
- public static final Map, Class>> XML_MIXINS;
- /**
- * Expanded list of all default implementations in the
- * DEFAULT_IMPLEMENTATION_PACKAGE_NAME package together with the interface
- * from the MODEL_PACKAGE_NAME package they are implementing.
- */
- @SuppressWarnings("rawtypes")
- public static final List DEFAULT_IMPLEMENTATIONS;
- /**
- * List of interfaces from the MODEL_PACKAGE_NAME package that are known to
- * not have any default implementation and therefore are excluded
- * explicitely.
- */
- public static final Set> INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION;
- /**
- * List of enums from the MODEL_PACKAGE_NAME package.
- */
- @SuppressWarnings("rawtypes")
- public static final List> ENUMS;
-
- public static class ImplementationInfo {
-
- private final Class interfaceType;
- private final Class extends T> implementationType;
-
- protected ImplementationInfo(Class interfaceType, Class extends T> implementationType) {
- this.interfaceType = interfaceType;
- this.implementationType = implementationType;
- }
-
- public Class getInterfaceType() {
- return interfaceType;
- }
-
- public Class extends T> getImplementationType() {
- return implementationType;
- }
- }
-
- /**
- * Returns whether the given class is an interface and from within the
- * MODEL_PACKAGE_NAME package
- *
- * @param type the class to check
- * @return whether the given class is an interface and from within the
- * MODEL_PACKAGE_NAME package
- */
- public static boolean isModelInterface(Class> type) {
- return type.isInterface() && MODEL_PACKAGE_NAME.equals(type.getPackageName());
- }
-
- /**
- * Returns whether the given class is a default implementation or not
- *
- * @param type the class to check
- * @return whether the given class is a default implementation or not
- */
- public static boolean isDefaultImplementation(Class> type) {
- return DEFAULT_IMPLEMENTATIONS.stream().anyMatch(x -> Objects.equals(x.getImplementationType(), type));
- }
-
- /**
- * Returns whether the given interface has a default implementation or not
- *
- * @param interfaceType the interface to check
- * @return whether the given interface has a default implementation or not
- */
- public static boolean hasDefaultImplementation(Class> interfaceType) {
- return DEFAULT_IMPLEMENTATIONS.stream().anyMatch(x -> x.getInterfaceType().equals(interfaceType));
- }
-
- /**
- * Returns the default implementation for an aas interface or null if the
- * class is no aas interface or does not have default implementation
- *
- * @param interfaceType the interface to check
- * @param the implementing class
- * @return the default implementation type for given interfaceType or null
- * if the class is no aas interface or does not have default implementation
- */
- @SuppressWarnings("unchecked")
- public static Class extends T> getDefaultImplementation(Class interfaceType) {
- if (isDefaultImplementation(interfaceType)) {
- return interfaceType;
- }
- if (hasDefaultImplementation(interfaceType)) {
- return DEFAULT_IMPLEMENTATIONS.stream()
- .filter(x -> x.getInterfaceType().equals(interfaceType))
- .findFirst().get()
- .getImplementationType();
- }
- return null;
- }
-
- /**
- * Returns whether the given class is an interface from within the
- * MODEL_PACKAGE_NAME package as well as a default implementation or not
- *
- * @param type the class to check
- * @return whether the given class is an interface from within the
- * MODEL_PACKAGE_NAME package as well as a default implementation or not
- */
- public static boolean isModelInterfaceOrDefaultImplementation(Class> type) {
- return isModelInterface(type) || isDefaultImplementation(type);
- }
-
- public static Class> getAasInterface(Class> type) {
- Set> implementedAasInterfaces = getAasInterfaces(type);
- if (implementedAasInterfaces.isEmpty()) {
- return null;
- }
- if (implementedAasInterfaces.size() == 1) {
- return implementedAasInterfaces.iterator().next();
- }
- logger.debug("class '{}' implements more than one AAS interface, but only most specific one is returned", type.getName());
- return implementedAasInterfaces.stream().map(x -> TypeToken.of(x))
- .sorted(new MostSpecificTypeTokenComparator())
- .findFirst().get()
- .getRawType();
- }
-
- public static Set> getAasInterfaces(Class> type) {
- Set> result = new HashSet<>();
- if (type != null) {
- if (INTERFACES.contains(type)) {
- result.add(type);
- }
- result.addAll(ClassUtils.getAllInterfaces(type).stream().filter(x -> INTERFACES.contains(x)).collect(Collectors.toSet()));
- }
- return result;
- }
-
- /**
- * Returns the AAS type information used for de-/serialization for a given
- * class or null if type information should not be included
- *
- * @param clazz the class to find the type information for
- * @return the type information for the given class or null if there is no
- * type information or type information should not be included
- */
- public static String getModelType(Class> clazz) {
- Class> type = getMostSpecificTypeWithModelType(clazz);
- if (type != null) {
- return type.getSimpleName();
- }
- for (Class> interfaceClass : clazz.getInterfaces()) {
- String result = getModelType(interfaceClass);
- if (result != null) {
- return result;
- }
- }
- Class> superClass = clazz.getSuperclass();
- if (superClass != null) {
- return getModelType(superClass);
- }
- return null;
- }
-
- /**
- * Returns the most specific supertype that contains some AAS type
- * information or null if there is none
- *
- * @param clazz the class to find the type for
- * @return the most specific supertype of given class that contains some AAS
- * type information or null if there is none
- */
- public static Class> getMostSpecificTypeWithModelType(Class> clazz) {
- if (clazz == null) {
- return null;
- }
- return TYPES_WITH_MODEL_TYPE.stream()
- .filter(x -> clazz.isInterface() ? x.equals(clazz) : x.isAssignableFrom(clazz))
- .sorted((Class> o1, Class> o2) -> {
- // -1: o1 more special than o2
- // 0: o1 equals o2 or on same samelevel
- // 1: o2 more special than o1
- if (o1.isAssignableFrom(o2)) {
- if (o2.isAssignableFrom(o1)) {
- return 0;
- }
- return 1;
- }
- if (o2.isAssignableFrom(o1)) {
- return -1;
- }
- return 0;
- })
- .findFirst()
- .orElse(null);
- }
-
- static {
- ScanResult modelScan = new ClassGraph()
- .enableClassInfo()
- .acceptPackagesNonRecursive(MODEL_PACKAGE_NAME)
- .scan();
- TYPES_WITH_MODEL_TYPE = scanModelTypes(modelScan);
- SUBTYPES = scanSubtypes(modelScan);
- JSON_MIXINS = scanMixins(modelScan, JSON_MIXINS_PACKAGE_NAME);
- XML_MIXINS = scanMixins(modelScan, XML_MIXINS_PACKAGE_NAME);
- DEFAULT_IMPLEMENTATIONS = scanDefaultImplementations(modelScan);
- INTERFACES = scanAasInterfaces();
- ENUMS = modelScan.getAllEnums().loadClasses(Enum.class);
- INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION = getInterfacesWithoutDefaultImplementation(modelScan);
- }
-
- private static Set> getInterfacesWithoutDefaultImplementation(ScanResult modelScan) {
- return modelScan.getAllInterfaces().loadClasses().stream()
- .filter(x -> !hasDefaultImplementation(x))
- .collect(Collectors.toSet());
- }
-
- public static Set> getSuperTypes(Class> clazz, boolean recursive) {
- Set> result = SUBTYPES.entrySet().stream()
- .filter(x -> x.getValue().contains(clazz))
- .map(x -> x.getKey())
- .collect(Collectors.toSet());
- if (recursive) {
- result.addAll(result.stream()
- .flatMap(x -> getSuperTypes(x, true).stream())
- .collect(Collectors.toSet()));
- }
- return result;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private static List scanDefaultImplementations(ScanResult modelScan) {
- ScanResult defaulImplementationScan = new ClassGraph()
- .enableClassInfo()
- .acceptPackagesNonRecursive(DEFAULT_IMPLEMENTATION_PACKAGE_NAME)
- .scan();
- List defaultImplementations = new ArrayList<>();
- defaulImplementationScan.getAllClasses()
- .filter(x -> x.getSimpleName().startsWith(DEFAULT_IMPLEMENTATION_PREFIX))
- .loadClasses()
- .stream()
- .forEach(x -> {
- String interfaceName = x.getSimpleName().substring(DEFAULT_IMPLEMENTATION_PREFIX.length());// using conventions
- ClassInfoList interfaceClassInfos = modelScan.getAllClasses().filter(y -> y.isInterface() && Objects.equals(y.getSimpleName(), interfaceName));
- if (interfaceClassInfos.isEmpty()) {
- logger.warn("could not find interface realized by default implementation class '{}'", x.getSimpleName());
- } else {
- Class> implementedClass = interfaceClassInfos.get(0).loadClass();
- defaultImplementations.add(new ImplementationInfo(implementedClass, x));
- logger.debug("using default implementation class '{}' for interface '{}'",
- x.getSimpleName(),
- interfaceClassInfos.get(0).getName());
-
- }
- });
- return defaultImplementations;
- }
-
- @SuppressWarnings("rawtypes")
- private static Set scanAasInterfaces() {
- return DEFAULT_IMPLEMENTATIONS.stream().map(x -> x.interfaceType).collect(Collectors.toSet());
- }
-
- private static Map, Class>> scanMixins(ScanResult modelScan, String packageName) {
- ScanResult mixinScan = new ClassGraph()
- .enableClassInfo()
- .acceptPackagesNonRecursive(packageName)
- .scan();
- Map, Class>> mixins = new HashMap<>();
- mixinScan.getAllClasses()
- .filter(x -> x.getSimpleName().endsWith(MIXIN_SUFFIX))
- .loadClasses()
- .forEach(x -> {
- String modelClassName = x.getSimpleName().substring(0, x.getSimpleName().length() - MIXIN_SUFFIX.length());
- ClassInfoList modelClassInfos = modelScan.getAllClasses().filter(y -> Objects.equals(y.getSimpleName(), modelClassName));
- if (modelClassInfos.isEmpty()) {
- logger.warn("could not auto-resolve target class for mixin '{}'", x.getSimpleName());
- } else {
- mixins.put(modelClassInfos.get(0).loadClass(), x);
- logger.debug("using mixin '{}' for class '{}'",
- x.getSimpleName(),
- modelClassInfos.get(0).getName());
- }
- });
- return mixins;
- }
-
- private static Map, Set>> scanSubtypes(ScanResult modelScan) {
- return modelScan.getAllInterfaces().stream()
- .filter(ReflectionHelper::hasSubclass)
- .collect(Collectors.toMap(ClassInfo::loadClass, ReflectionHelper::getSubclasses));
- }
-
- private static Set> getSubclasses(ClassInfo clazzInfo) {
- return clazzInfo.getClassesImplementing()
- .directOnly()
- .filter(ClassInfo::isInterface)
- .loadClasses()
- .stream()
- .collect(Collectors.toSet());
- }
-
- private static boolean hasSubclass(ClassInfo clazzInfo) {
- return !getSubclasses(clazzInfo).isEmpty();
- }
-
- private static Set> scanModelTypes(ScanResult modelScan) {
- Set> typesWithModelTypes;
- typesWithModelTypes = MODEL_TYPE_SUPERCLASSES.stream()
- .flatMap(x -> modelScan.getClassesImplementing(x.getName()).loadClasses().stream())
- .collect(Collectors.toSet());
- typesWithModelTypes.addAll(MODEL_TYPE_SUPERCLASSES);
- return typesWithModelTypes;
- }
-
- private ReflectionHelper() {
- }
-
- /**
- * Overrides empty list fields with null
- * @param element to perform the empty-to-null conversion on
- */
- public static List setEmptyListsToNull(Object element) {
- List resetRunnables = new ArrayList<>();
-
- Field[] fields = element.getClass().getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- field.setAccessible(true);
- try {
- if (field.getType().isAssignableFrom(List.class) && field.get(element)!=null && ((List>) field.get(element)).isEmpty()) {
- resetRunnables.add(createResetRunnable(element, field));
- field.set(element, null);
- }
- } catch (IllegalAccessException e) {
- // do nothing
- }
- field.setAccessible(false);
- }
-
- return resetRunnables;
- }
-
- private static Runnable createResetRunnable(Object element, Field field) throws IllegalAccessException {
- List> originalValue = (List>) field.get(element);
- Runnable resetRunnable = () -> {
- field.setAccessible(true);
- try {
- field.set(element, originalValue);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- e.printStackTrace();
- }
- field.setAccessible(false);
- };
- return resetRunnable;
- }
-}
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent;
+import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.reflect.TypeToken;
+
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ClassInfoList;
+import io.github.classgraph.ScanResult;
+
+/**
+ * Helper class to collect relevant data needed for
+ * ReflectionAnnotationIntrospector via reflection.
+ */
+public class ReflectionHelper {
+
+ private static final Logger logger = LoggerFactory.getLogger(ReflectionHelper.class);
+ private static final String ROOT_PACKAGE_NAME = "org.eclipse.digitaltwin.aas4j.v3";
+ /**
+ * Name of package where the generated model classes are defined
+ */
+ public static final String MODEL_PACKAGE_NAME = ROOT_PACKAGE_NAME + ".model";
+ /**
+ * Name of package where the generated default implementation files are
+ * defined
+ */
+ public static final String DEFAULT_IMPLEMENTATION_PACKAGE_NAME = MODEL_PACKAGE_NAME + ".impl";
+ /**
+ * Name of package where the json mixins are defined. These mixins are
+ * automatically added to JsonSerializer and JsonDeserializer.
+ */
+ public static final String JSON_MIXINS_PACKAGE_NAME = ROOT_PACKAGE_NAME + ".dataformat.json.internal.mixins";
+ /**
+ * Name of package where the xml mixins are defined. These mixins are
+ * automatically added to XmlSerializer and XmlDeserializer.
+ */
+ public static final String XML_MIXINS_PACKAGE_NAME = ROOT_PACKAGE_NAME + ".dataformat.xml.internal.mixins";
+ /**
+ * Suffix that identifies a class as a mixin.
+ */
+ public static final String MIXIN_SUFFIX = "Mixin";
+ /**
+ * Prefix that defines a class as a default implementation
+ */
+ public static final String DEFAULT_IMPLEMENTATION_PREFIX = "Default";
+ /**
+ * Distinct root superclasses of which classify a class to include type
+ * information via the modelType property
+ */
+ public static final Set> MODEL_TYPE_SUPERCLASSES = Set.of(Referable.class, DataSpecificationContent.class);
+ /**
+ * Expanded list of all classes that shall be annotated with the modelType
+ * property.
+ */
+ public static final Set> TYPES_WITH_MODEL_TYPE;
+ /**
+ * Map of all interfaces and their subinterfaces defined in the
+ * MODEL_PACKAGE_NAME package.
+ */
+ public static final Map, Set>> SUBTYPES;
+ /**
+ * List of all interfaces classes defined by the AAS.
+ */
+ @SuppressWarnings("rawtypes")
+ public static final Set INTERFACES;
+ /**
+ * Expanded list of all mixin classes defined in the
+ * JSON_MIXINS_PACKAGE_NAME package together with the corresponding class
+ * they should be applied to.
+ */
+ public static final Map, Class>> JSON_MIXINS;
+ /**
+ * Expanded list of all mixin classes defined in the XML_MIXINS_PACKAGE_NAME
+ * package together with the corresponding class they should be applied to.
+ */
+ public static final Map, Class>> XML_MIXINS;
+ /**
+ * Expanded list of all default implementations in the
+ * DEFAULT_IMPLEMENTATION_PACKAGE_NAME package together with the interface
+ * from the MODEL_PACKAGE_NAME package they are implementing.
+ */
+ @SuppressWarnings("rawtypes")
+ public static final List DEFAULT_IMPLEMENTATIONS;
+ /**
+ * List of interfaces from the MODEL_PACKAGE_NAME package that are known to
+ * not have any default implementation and therefore are excluded
+ * explicitely.
+ */
+ public static final Set> INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION;
+ /**
+ * List of enums from the MODEL_PACKAGE_NAME package.
+ */
+ @SuppressWarnings("rawtypes")
+ public static final List> ENUMS;
+
+ public static class ImplementationInfo {
+
+ private final Class interfaceType;
+ private final Class extends T> implementationType;
+
+ protected ImplementationInfo(Class interfaceType, Class extends T> implementationType) {
+ this.interfaceType = interfaceType;
+ this.implementationType = implementationType;
+ }
+
+ public Class getInterfaceType() {
+ return interfaceType;
+ }
+
+ public Class extends T> getImplementationType() {
+ return implementationType;
+ }
+ }
+
+ /**
+ * Returns whether the given class is an interface and from within the
+ * MODEL_PACKAGE_NAME package
+ *
+ * @param type the class to check
+ * @return whether the given class is an interface and from within the
+ * MODEL_PACKAGE_NAME package
+ */
+ public static boolean isModelInterface(Class> type) {
+ return type.isInterface() && MODEL_PACKAGE_NAME.equals(type.getPackageName());
+ }
+
+ /**
+ * Returns whether the given class is a default implementation or not
+ *
+ * @param type the class to check
+ * @return whether the given class is a default implementation or not
+ */
+ public static boolean isDefaultImplementation(Class> type) {
+ return DEFAULT_IMPLEMENTATIONS.stream().anyMatch(x -> Objects.equals(x.getImplementationType(), type));
+ }
+
+ /**
+ * Returns whether the given interface has a default implementation or not
+ *
+ * @param interfaceType the interface to check
+ * @return whether the given interface has a default implementation or not
+ */
+ public static boolean hasDefaultImplementation(Class> interfaceType) {
+ return DEFAULT_IMPLEMENTATIONS.stream().anyMatch(x -> x.getInterfaceType().equals(interfaceType));
+ }
+
+ /**
+ * Returns the default implementation for an aas interface or null if the
+ * class is no aas interface or does not have default implementation
+ *
+ * @param interfaceType the interface to check
+ * @param the implementing class
+ * @return the default implementation type for given interfaceType or null
+ * if the class is no aas interface or does not have default implementation
+ */
+ @SuppressWarnings("unchecked")
+ public static Class extends T> getDefaultImplementation(Class interfaceType) {
+ if (isDefaultImplementation(interfaceType)) {
+ return interfaceType;
+ }
+ if (hasDefaultImplementation(interfaceType)) {
+ return DEFAULT_IMPLEMENTATIONS.stream()
+ .filter(x -> x.getInterfaceType().equals(interfaceType))
+ .findFirst().get()
+ .getImplementationType();
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether the given class is an interface from within the
+ * MODEL_PACKAGE_NAME package as well as a default implementation or not
+ *
+ * @param type the class to check
+ * @return whether the given class is an interface from within the
+ * MODEL_PACKAGE_NAME package as well as a default implementation or not
+ */
+ public static boolean isModelInterfaceOrDefaultImplementation(Class> type) {
+ return isModelInterface(type) || isDefaultImplementation(type);
+ }
+
+ public static Class> getAasInterface(Class> type) {
+ Set> implementedAasInterfaces = getAasInterfaces(type);
+ if (implementedAasInterfaces.isEmpty()) {
+ return null;
+ }
+ if (implementedAasInterfaces.size() == 1) {
+ return implementedAasInterfaces.iterator().next();
+ }
+ logger.debug("class '{}' implements more than one AAS interface, but only most specific one is returned", type.getName());
+ return implementedAasInterfaces.stream().map(x -> TypeToken.of(x))
+ .sorted(new MostSpecificTypeTokenComparator())
+ .findFirst().get()
+ .getRawType();
+ }
+
+ public static Set> getAasInterfaces(Class> type) {
+ Set> result = new HashSet<>();
+ if (type != null) {
+ if (INTERFACES.contains(type)) {
+ result.add(type);
+ }
+ result.addAll(ClassUtils.getAllInterfaces(type).stream().filter(x -> INTERFACES.contains(x)).collect(Collectors.toSet()));
+ }
+ return result;
+ }
+
+ /**
+ * Returns the AAS type information used for de-/serialization for a given
+ * class or null if type information should not be included
+ *
+ * @param clazz the class to find the type information for
+ * @return the type information for the given class or null if there is no
+ * type information or type information should not be included
+ */
+ public static String getModelType(Class> clazz) {
+ Class> type = getMostSpecificTypeWithModelType(clazz);
+ if (type != null) {
+ return type.getSimpleName();
+ }
+ for (Class> interfaceClass : clazz.getInterfaces()) {
+ String result = getModelType(interfaceClass);
+ if (result != null) {
+ return result;
+ }
+ }
+ Class> superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ return getModelType(superClass);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the most specific supertype that contains some AAS type
+ * information or null if there is none
+ *
+ * @param clazz the class to find the type for
+ * @return the most specific supertype of given class that contains some AAS
+ * type information or null if there is none
+ */
+ public static Class> getMostSpecificTypeWithModelType(Class> clazz) {
+ if (clazz == null) {
+ return null;
+ }
+ return TYPES_WITH_MODEL_TYPE.stream()
+ .filter(x -> clazz.isInterface() ? x.equals(clazz) : x.isAssignableFrom(clazz))
+ .sorted((Class> o1, Class> o2) -> {
+ // -1: o1 more special than o2
+ // 0: o1 equals o2 or on same samelevel
+ // 1: o2 more special than o1
+ if (o1.isAssignableFrom(o2)) {
+ if (o2.isAssignableFrom(o1)) {
+ return 0;
+ }
+ return 1;
+ }
+ if (o2.isAssignableFrom(o1)) {
+ return -1;
+ }
+ return 0;
+ })
+ .findFirst()
+ .orElse(null);
+ }
+
+ static {
+ ScanResult modelScan = new ClassGraph()
+ .enableClassInfo()
+ .acceptPackagesNonRecursive(MODEL_PACKAGE_NAME)
+ .scan();
+ TYPES_WITH_MODEL_TYPE = scanModelTypes(modelScan);
+ SUBTYPES = scanSubtypes(modelScan);
+ JSON_MIXINS = scanMixins(modelScan, JSON_MIXINS_PACKAGE_NAME);
+ XML_MIXINS = scanMixins(modelScan, XML_MIXINS_PACKAGE_NAME);
+ DEFAULT_IMPLEMENTATIONS = scanDefaultImplementations(modelScan);
+ INTERFACES = scanAasInterfaces();
+ ENUMS = modelScan.getAllEnums().loadClasses(Enum.class);
+ INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION = getInterfacesWithoutDefaultImplementation(modelScan);
+ }
+
+ private static Set> getInterfacesWithoutDefaultImplementation(ScanResult modelScan) {
+ return modelScan.getAllInterfaces().loadClasses().stream()
+ .filter(x -> !hasDefaultImplementation(x))
+ .collect(Collectors.toSet());
+ }
+
+ public static Set> getSuperTypes(Class> clazz, boolean recursive) {
+ Set> result = SUBTYPES.entrySet().stream()
+ .filter(x -> x.getValue().contains(clazz))
+ .map(x -> x.getKey())
+ .collect(Collectors.toSet());
+ if (recursive) {
+ result.addAll(result.stream()
+ .flatMap(x -> getSuperTypes(x, true).stream())
+ .collect(Collectors.toSet()));
+ }
+ return result;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private static List scanDefaultImplementations(ScanResult modelScan) {
+ ScanResult defaulImplementationScan = new ClassGraph()
+ .enableClassInfo()
+ .acceptPackagesNonRecursive(DEFAULT_IMPLEMENTATION_PACKAGE_NAME)
+ .scan();
+ List defaultImplementations = new ArrayList<>();
+ defaulImplementationScan.getAllClasses()
+ .filter(x -> x.getSimpleName().startsWith(DEFAULT_IMPLEMENTATION_PREFIX))
+ .loadClasses()
+ .stream()
+ .forEach(x -> {
+ String interfaceName = x.getSimpleName().substring(DEFAULT_IMPLEMENTATION_PREFIX.length());// using conventions
+ ClassInfoList interfaceClassInfos = modelScan.getAllClasses().filter(y -> y.isInterface() && Objects.equals(y.getSimpleName(), interfaceName));
+ if (interfaceClassInfos.isEmpty()) {
+ logger.warn("could not find interface realized by default implementation class '{}'", x.getSimpleName());
+ } else {
+ Class> implementedClass = interfaceClassInfos.get(0).loadClass();
+ defaultImplementations.add(new ImplementationInfo(implementedClass, x));
+ logger.debug("using default implementation class '{}' for interface '{}'",
+ x.getSimpleName(),
+ interfaceClassInfos.get(0).getName());
+
+ }
+ });
+ return defaultImplementations;
+ }
+
+ @SuppressWarnings("rawtypes")
+ private static Set scanAasInterfaces() {
+ return DEFAULT_IMPLEMENTATIONS.stream().map(x -> x.interfaceType).collect(Collectors.toSet());
+ }
+
+ private static Map, Class>> scanMixins(ScanResult modelScan, String packageName) {
+ ScanResult mixinScan = new ClassGraph()
+ .enableClassInfo()
+ .acceptPackagesNonRecursive(packageName)
+ .scan();
+ Map, Class>> mixins = new HashMap<>();
+ mixinScan.getAllClasses()
+ .filter(x -> x.getSimpleName().endsWith(MIXIN_SUFFIX))
+ .loadClasses()
+ .forEach(x -> {
+ String modelClassName = x.getSimpleName().substring(0, x.getSimpleName().length() - MIXIN_SUFFIX.length());
+ ClassInfoList modelClassInfos = modelScan.getAllClasses().filter(y -> Objects.equals(y.getSimpleName(), modelClassName));
+ if (modelClassInfos.isEmpty()) {
+ logger.warn("could not auto-resolve target class for mixin '{}'", x.getSimpleName());
+ } else {
+ mixins.put(modelClassInfos.get(0).loadClass(), x);
+ logger.debug("using mixin '{}' for class '{}'",
+ x.getSimpleName(),
+ modelClassInfos.get(0).getName());
+ }
+ });
+ return mixins;
+ }
+
+ private static Map, Set>> scanSubtypes(ScanResult modelScan) {
+ return modelScan.getAllInterfaces().stream()
+ .filter(ReflectionHelper::hasSubclass)
+ .collect(Collectors.toMap(ClassInfo::loadClass, ReflectionHelper::getSubclasses));
+ }
+
+ private static Set> getSubclasses(ClassInfo clazzInfo) {
+ return clazzInfo.getClassesImplementing()
+ .directOnly()
+ .filter(ClassInfo::isInterface)
+ .loadClasses()
+ .stream()
+ .collect(Collectors.toSet());
+ }
+
+ private static boolean hasSubclass(ClassInfo clazzInfo) {
+ return !getSubclasses(clazzInfo).isEmpty();
+ }
+
+ private static Set> scanModelTypes(ScanResult modelScan) {
+ Set> typesWithModelTypes;
+ typesWithModelTypes = MODEL_TYPE_SUPERCLASSES.stream()
+ .flatMap(x -> modelScan.getClassesImplementing(x.getName()).loadClasses().stream())
+ .collect(Collectors.toSet());
+ typesWithModelTypes.addAll(MODEL_TYPE_SUPERCLASSES);
+ return typesWithModelTypes;
+ }
+
+ private ReflectionHelper() {
+ }
+
+ /**
+ * Overrides empty list fields with null
+ * @param element to perform the empty-to-null conversion on
+ */
+ public static List setEmptyListsToNull(Object element) {
+ List resetRunnables = new ArrayList<>();
+
+ Field[] fields = element.getClass().getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ field.setAccessible(true);
+ try {
+ if (field.getType().isAssignableFrom(List.class) && field.get(element)!=null && ((List>) field.get(element)).isEmpty()) {
+ resetRunnables.add(createResetRunnable(element, field));
+ field.set(element, null);
+ }
+ } catch (IllegalAccessException e) {
+ // do nothing
+ }
+ field.setAccessible(false);
+ }
+
+ return resetRunnables;
+ }
+
+ private static Runnable createResetRunnable(Object element, Field field) throws IllegalAccessException {
+ List> originalValue = (List>) field.get(element);
+ Runnable resetRunnable = () -> {
+ field.setAccessible(true);
+ try {
+ field.set(element, originalValue);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ field.setAccessible(false);
+ };
+ return resetRunnable;
+ }
+}
diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtils.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtils.java
index fac5cfeb7..db81f646c 100644
--- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtils.java
+++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtils.java
@@ -1,419 +1,438 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util;
-
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.deserialization.EnumDeserializer;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.MostSpecificTypeTokenComparator;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization.EnumSerializer;
-import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
-import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable;
-import org.eclipse.digitaltwin.aas4j.v3.model.Key;
-import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
-import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
-import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
-import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.reflect.TypeToken;
-import java.util.Map;
-import java.util.Objects;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.GetChildrenVisitor;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.GetIdentifierVisitor;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList;
-
-/**
- * Provides utility functions related to AAS
- */
-public class AasUtils {
-
- private static final Logger log = LoggerFactory.getLogger(AasUtils.class);
-
- private static final String REFERENCE_ELEMENT_DELIMITER = ", ";
-
- private static final Map REFERENCE_TYPE_REPRESENTATION = Map.of(
- ReferenceTypes.EXTERNAL_REFERENCE, "ExternalRef",
- ReferenceTypes.MODEL_REFERENCE, "ModelRef");
-
- private AasUtils() {
- }
-
- /**
- * Formats a Reference as string
- *
- * @param reference Reference to serialize
- * @return string representation of the reference for serialization, null if reference is null
- */
- public static String asString(Reference reference) {
- return asString(reference, true, true);
- }
-
- /**
- * Serializes a {@link Reference} to string.
- *
- * @param reference the reference to serialize
- * @param includeReferenceType if reference type information should be included
- * @param includeReferredSemanticId if referred semanticId should be included
- * @return the serialized reference or null if reference is null, reference.keys is null or reference does not
- * contain any keys
- */
- public static String asString(Reference reference, boolean includeReferenceType, boolean includeReferredSemanticId) {
- if (Objects.isNull(reference) || Objects.isNull(reference.getKeys()) || reference.getKeys().isEmpty()) {
- return null;
- }
- String result = "";
- if (includeReferenceType) {
- String referredSemanticId = includeReferredSemanticId
- ? asString(reference.getReferredSemanticId(), includeReferenceType, false)
- : "";
- result = String.format("[%s%s]",
- asString(reference.getType()),
- (Objects.nonNull(referredSemanticId) && !referredSemanticId.isBlank()) ? String.format("- %s -", referredSemanticId)
- : "");
- }
- result += reference.getKeys().stream()
- .map(x -> String.format("(%s)%s",
- EnumSerializer.serializeEnumName(x.getType().name()),
- x.getValue()))
- .collect(Collectors.joining(", "));
- return result;
- }
-
- private static String asString(ReferenceTypes referenceType) {
- if (!REFERENCE_TYPE_REPRESENTATION.containsKey(referenceType)) {
- throw new IllegalArgumentException(String.format("Unsupported reference type '%s'", referenceType));
- }
- return REFERENCE_TYPE_REPRESENTATION.get(referenceType);
- }
-
- /**
- * Creates a reference for an Identifiable instance using provided implementation types for reference and key
- *
- * @param identifiable the identifiable to create the reference for
- * @param referenceType implementation type of Reference interface
- * @param keyType implementation type of Key interface
- * @return a reference representing the identifiable
- */
- public static Reference toReference(Identifiable identifiable, Class extends Reference> referenceType, Class extends Key> keyType) {
- try {
- Reference reference = referenceType.getConstructor().newInstance();
- reference.setType(ReferenceTypes.MODEL_REFERENCE);
- Key key = keyType.getConstructor().newInstance();
- key.setType(referableToKeyType(identifiable));
- key.setValue(identifiable.getId());
- reference.setKeys(List.of(key));
- return reference;
- } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
- throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
- }
- }
-
- /**
- * Creates a reference for an Identifiable instance
- *
- * @param identifiable the identifiable to create the reference for
- * @return a reference representing the identifiable
- */
- public static Reference toReference(Identifiable identifiable) {
- return toReference(identifiable, ReflectionHelper.getDefaultImplementation(Reference.class), ReflectionHelper.getDefaultImplementation(Key.class));
- }
-
- /**
- * Gets the KeyElements type matching the provided Referable
- *
- * @param referable The referable to convert to KeyElements type
- * @return the most specific KeyElements type representing the Referable, i.e. abstract types like SUBMODEL_ELEMENT
- * or DATA_ELEMENT are never returned; null if there is no corresponding KeyElements type
- */
- public static KeyTypes referableToKeyType(Referable referable) {
- Class> aasInterface = ReflectionHelper.getAasInterface(referable.getClass());
- if (aasInterface != null) {
- return KeyTypes.valueOf(EnumDeserializer.deserializeEnumName(aasInterface.getSimpleName()));
- }
- return null;
- }
-
- /**
- * Gets a Java interface representing the type provided by key.
- *
- * @param key The KeyElements type
- * @return a Java interface representing the provided KeyElements type or null if no matching Class/interface could
- * be found. It also returns abstract types like SUBMODEL_ELEMENT or DATA_ELEMENT
- */
- private static Class> keyTypeToClass(KeyTypes key) {
- return Stream.concat(ReflectionHelper.INTERFACES.stream(), ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream())
- .filter(x -> x.getSimpleName().equals(EnumSerializer.serializeEnumName(key.name())))
- .findAny()
- .orElse(null);
- }
-
- /**
- * Creates a reference for an element given a potential parent using provided implementation types for reference and
- * key
- *
- * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
- * result will always be null
- * @param element the element to create a reference for
- * @param referenceType implementation type of Reference interface
- * @param keyType implementation type of Key interface
- *
- * @return A reference representing the element or null if either element is null or parent is null and element not
- * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
- * contain one key pointing directly to the element.
- */
- public static Reference toReference(Reference parent, Referable element, Class extends Reference> referenceType, Class extends Key> keyType) {
- if (element == null) {
- return null;
- } else if (Identifiable.class.isAssignableFrom(element.getClass())) {
- return toReference((Identifiable) element, referenceType, keyType);
- } else {
- Reference result = clone(parent, referenceType, keyType);
- if (result != null) {
- try {
- Key newKey = keyType.getConstructor().newInstance();
- newKey.setType(AasUtils.referableToKeyType(element));
- newKey.setValue(element.getIdShort());
- result.getKeys().add(newKey);
- } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
- throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
- }
- }
- return result;
- }
- }
-
- /**
- * Creates a reference for an element given a potential parent
- *
- * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
- * result will always be null
- * @param element the element to create a reference for
- * @return A reference representing the element or null if either element is null or parent is null and element not
- * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
- * contain one key pointing directly to the element.
- */
- public static Reference toReference(Reference parent, Referable element) {
- return toReference(parent,
- element,
- ReflectionHelper.getDefaultImplementation(Reference.class),
- ReflectionHelper.getDefaultImplementation(Key.class));
- }
-
- /**
- * Checks if two references are refering to the same element ignoring referredSemanticId.
- *
- * @param ref1 reference 1
- * @param ref2 reference 2
- * @return returns true if both references are refering to the same element, otherwise false
- */
- public static boolean sameAs(Reference ref1, Reference ref2) {
- return sameAs(ref1, ref2, false);
- }
-
- /**
- * Checks if two references are referring to the same element.
- *
- * @param ref1 reference 1
- * @param ref2 reference 2
- * @param compareReferredSemanticId true if referredSemanticId should be compared, false otherwise
- * @return returns true if both references are referring to the same element, otherwise false
- */
- public static boolean sameAs(Reference ref1, Reference ref2, boolean compareReferredSemanticId) {
- boolean ref1Empty = ref1 == null || ref1.getKeys() == null || ref1.getKeys().isEmpty();
- boolean ref2Empty = ref2 == null || ref2.getKeys() == null || ref2.getKeys().isEmpty();
- if (ref1Empty != ref2Empty) {
- return false;
- }
- if (ref1.getType() != ref2.getType()) {
- return false;
- }
- if (compareReferredSemanticId && !sameAs(ref1.getReferredSemanticId(), ref2.getReferredSemanticId())) {
- return false;
- }
- if (ref1Empty && ref2Empty) {
- return true;
- }
- if (ref1.getKeys().size() != ref2.getKeys().size()) {
- return false;
- }
- for (int i = 0; i < ref1.getKeys().size(); i++) {
- Key key1 = ref1.getKeys().get(ref1.getKeys().size() - (i + 1));
- Key key2 = ref2.getKeys().get(ref2.getKeys().size() - (i + 1));
- if (Objects.isNull(key1) != Objects.isNull(key2)) {
- return false;
- }
- if (Objects.isNull(key1)) {
- return true;
- }
- if (!Objects.equals(key1.getValue(), key2.getValue())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Creates a deep-copy clone of a reference using provided implementation types for reference and key
- *
- * @param reference the reference to clone
- * @param referenceType implementation type of Reference interface
- * @param keyType implementation type of Key interface
- *
- * @return the cloned reference
- */
- private static Reference clone(Reference reference, Class extends Reference> referenceType, Class extends Key> keyType) {
- if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) {
- return null;
- }
- try {
- Reference result = referenceType.getConstructor().newInstance();
- List newKeys = new ArrayList<>();
- result.setType(reference.getType());
- for (Key key : reference.getKeys()) {
- Key newKey = keyType.getConstructor().newInstance();
- newKey.setType(key.getType());
- newKey.setValue(key.getValue());
- newKeys.add(newKey);
- }
- result.setKeys(newKeys);
- return result;
- } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
- throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
- }
- }
-
- /**
- * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available,
- * null otherwise
- *
- *
- * @param reference The reference to resolve
- * @param env The AssetAdministrationShellEnvironment to resolve the reference against
- * @return returns an instance of T if the reference could successfully be resolved, otherwise null
- * @throws IllegalArgumentException if something goes wrong while resolving
- */
- public static Referable resolve(Reference reference, Environment env) {
- return resolve(reference, env, Referable.class);
- }
-
- /**
- * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available,
- * null otherwise
- *
- * @param sub-type of Referable of the targeted type. If unknown use Referable.class
- * @param reference The reference to resolve
- * @param env The AssetAdministrationShellEnvironment to resolve the reference against
- * @param type desired return type, use Referable.class is unknwon/not needed
- * @return returns an instance of T if the reference could successfully be resolved, otherwise null
- * @throws IllegalArgumentException if something goes wrong while resolving
- */
- @SuppressWarnings("unchecked")
- public static T resolve(Reference reference, Environment env, Class type) {
- if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) {
- return null;
- }
- GetChildrenVisitor findChildrenVisitor = new GetChildrenVisitor(env);
- findChildrenVisitor.visit(env);
- Referable current = null;
- for (int i = 0; i < reference.getKeys().size(); i++) {
- Key key = reference.getKeys().get(i);
- try {
- int index = Integer.parseInt(key.getValue());
- if (Objects.isNull(current) || !SubmodelElementList.class.isAssignableFrom(current.getClass())) {
- throw new IllegalArgumentException("reference uses index notation on an element that is not a SubmodelElementList");
- }
- List list = ((SubmodelElementList) current).getValue();
- if (list.size() <= index) {
- throw new IllegalArgumentException(String.format(
- "index notation out of bounds (list size: %s, requested index: %s)",
- list.size(),
- index));
- }
- current = list.get(index);
- } catch (NumberFormatException e) {
- current = findChildrenVisitor.getChildren().stream()
- .filter(x -> Objects.equals(key.getValue(), GetIdentifierVisitor.getIdentifier(x)))
- .findFirst()
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "unable to resolve reference '%s' as element '%s' does not exist",
- asString(reference),
- key.getValue())));
- }
- findChildrenVisitor.reset();
- findChildrenVisitor.visit(current);
- }
- if (current == null) {
- return null;
- }
- if (!type.isAssignableFrom(current.getClass())) {
- throw new IllegalArgumentException(String.format(
- "reference '%s' could not be resolved as target type is not assignable from actual type (target: %s, actual: %s)",
- asString(reference),
- type.getName(),
- current.getClass().getName()));
- }
- return type.cast(current);
- }
-
- /**
- * Gets a list of all properties defined for a class implementing at least one AAS interface.
- *
- * @param type A class implementing at least one AAS interface. If it is does not implement any AAS interface the
- * result will be an empty list
- * @return a list of all properties defined in any of AAS interface implemented by type. If type does not implement
- * any AAS interface an empty list is returned.
- */
- private static List getAasProperties(Class> type) {
- Class> aasType = ReflectionHelper.getAasInterface(type);
- if (aasType == null) {
- aasType = ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream()
- .filter(x -> x.isAssignableFrom(type))
- .map(x -> TypeToken.of(x))
- .sorted(new MostSpecificTypeTokenComparator())
- .findFirst().get()
- .getRawType();
- }
- Set> types = new HashSet<>();
- if (aasType != null) {
- types.add(aasType);
- types.addAll(ReflectionHelper.getSuperTypes(aasType, true));
- }
- return types.stream()
- .flatMap(x -> {
- try {
- return Stream.of(Introspector.getBeanInfo(x).getPropertyDescriptors());
- } catch (IntrospectionException ex) {
- log.warn("error finding properties of class '{}'", type, ex);
- }
- return Stream.empty();
- })
- .sorted(Comparator.comparing(x -> x.getName()))
- .collect(Collectors.toList());
- }
-}
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.GetChildrenVisitor;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.GetIdentifierVisitor;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper;
+import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
+import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics;
+import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable;
+import org.eclipse.digitaltwin.aas4j.v3.model.Key;
+import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
+import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes;
+import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
+import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList;
+
+/**
+ * Provides utility functions related to AAS
+ */
+public class AasUtils {
+ private static final Map REFERENCE_TYPE_REPRESENTATION = Map.of(
+ ReferenceTypes.EXTERNAL_REFERENCE, "ExternalRef",
+ ReferenceTypes.MODEL_REFERENCE, "ModelRef");
+
+ private AasUtils() {
+ }
+
+ /**
+ * Formats a Reference as string
+ *
+ * @param reference Reference to serialize
+ * @return string representation of the reference for serialization, null if reference is null
+ */
+ public static String asString(Reference reference) {
+ return asString(reference, true, true);
+ }
+
+ /**
+ * Serializes a {@link Reference} to string.
+ *
+ * @param reference the reference to serialize
+ * @param includeReferenceType if reference type information should be included
+ * @param includeReferredSemanticId if referred semanticId should be included
+ * @return the serialized reference or null if reference is null, reference.keys is null or reference does not
+ * contain any keys
+ */
+ public static String asString(Reference reference, boolean includeReferenceType, boolean includeReferredSemanticId) {
+ if (Objects.isNull(reference) || Objects.isNull(reference.getKeys()) || reference.getKeys().isEmpty()) {
+ return null;
+ }
+ String result = "";
+ if (includeReferenceType) {
+ String referredSemanticId = includeReferredSemanticId
+ ? asString(reference.getReferredSemanticId(), includeReferenceType, false)
+ : "";
+ result = String.format("[%s%s]",
+ asString(reference.getType()),
+ (Objects.nonNull(referredSemanticId) && !referredSemanticId.isBlank()) ? String.format("- %s -", referredSemanticId)
+ : "");
+ }
+ result += reference.getKeys().stream()
+ .map(x -> String.format("(%s)%s",
+ EnumSerializer.serializeEnumName(x.getType().name()),
+ x.getValue()))
+ .collect(Collectors.joining(", "));
+ return result;
+ }
+
+ private static String asString(ReferenceTypes referenceType) {
+ if (!REFERENCE_TYPE_REPRESENTATION.containsKey(referenceType)) {
+ throw new IllegalArgumentException(String.format("Unsupported reference type '%s'", referenceType));
+ }
+ return REFERENCE_TYPE_REPRESENTATION.get(referenceType);
+ }
+
+ /**
+ * Creates a reference for an Identifiable instance using provided implementation types for reference and key
+ *
+ * @param identifiable the identifiable to create the reference for
+ * @param referenceType implementation type of Reference interface
+ * @param keyType implementation type of Key interface
+ * @return a reference representing the identifiable
+ */
+ public static Reference toReference(Identifiable identifiable, Class extends Reference> referenceType, Class extends Key> keyType) {
+ try {
+ Reference reference = referenceType.getConstructor().newInstance();
+ reference.setType(ReferenceTypes.MODEL_REFERENCE);
+
+
+ Key key = keyType.getConstructor().newInstance();
+ key.setType(referableToKeyType(identifiable));
+ key.setValue(identifiable.getId());
+ reference.setKeys(List.of(key));
+ return reference;
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+ throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
+ }
+ }
+
+ /**
+ * Creates a reference for an Identifiable instance using provided implementation types for reference and key
+ *
+ * @param identifiable the identifiable to create the reference for
+ * @param referenceType implementation type of Reference interface
+ * @param keyType implementation type of Key interface
+ * @param setReferredSemanticIdIfHasSemantics if the referredSemanticId should be set if the identifiable is of HasSemantics
+ * @return a reference representing the identifiable
+ */
+ public static Reference toReference(Identifiable identifiable, Class extends Reference> referenceType,
+ Class extends Key> keyType, boolean setReferredSemanticIdIfHasSemantics) {
+ Reference reference = toReference(identifiable, referenceType, keyType);
+
+ return handleReferredSemanticId(identifiable, setReferredSemanticIdIfHasSemantics, reference);
+ }
+
+
+ /**
+ * Creates a reference for an Identifiable instance
+ *
+ * @param identifiable the identifiable to create the reference for
+ * @return a reference representing the identifiable
+ */
+ public static Reference toReference(Identifiable identifiable) {
+ return toReference(identifiable, ReflectionHelper.getDefaultImplementation(Reference.class), ReflectionHelper.getDefaultImplementation(Key.class));
+ }
+
+ /**
+ * Creates a reference for an Identifiable instance
+ *
+ * @param identifiable the identifiable to create the reference for
+ * @param setReferredSemanticIdIfHasSemantics if the referredSemanticId should be set if the identifiable is of HasSemantics
+ * @return a reference representing the identifiable
+ */
+ public static Reference toReference(Identifiable identifiable, boolean setReferredSemanticIdIfHasSemantics) {
+ Reference reference = toReference(identifiable);
+
+ return handleReferredSemanticId(identifiable, setReferredSemanticIdIfHasSemantics, reference);
+ }
+
+ /**
+ * Creates a reference for an element given a potential parent using provided implementation types for reference and
+ * key
+ *
+ * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
+ * result will always be null
+ * @param element the element to create a reference for
+ * @param referenceType implementation type of Reference interface
+ * @param keyType implementation type of Key interface
+ *
+ * @return A reference representing the element or null if either element is null or parent is null and element not
+ * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
+ * contain one key pointing directly to the element.
+ */
+ public static Reference toReference(Reference parent, Referable element, Class extends Reference> referenceType, Class extends Key> keyType) {
+ if (element == null) {
+ return null;
+ } else if (Identifiable.class.isAssignableFrom(element.getClass())) {
+ return toReference((Identifiable) element, referenceType, keyType);
+ } else {
+ Reference result = clone(parent, referenceType, keyType);
+ if (result != null) {
+ try {
+ Key newKey = keyType.getConstructor().newInstance();
+ newKey.setType(AasUtils.referableToKeyType(element));
+ newKey.setValue(element.getIdShort());
+ result.getKeys().add(newKey);
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+ throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
+ }
+ }
+ return result;
+ }
+ }
+
+ /**
+ * Creates a reference for an element given a potential parent using provided implementation types for reference and
+ * key
+ *
+ * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
+ * result will always be null
+ * @param element the element to create a reference for
+ * @param referenceType implementation type of Reference interface
+ * @param keyType implementation type of Key interface
+ * @param setReferredSemanticIdIfHasSemantics if the referredSemanticId should be set if the identifiable is of HasSemantics
+ *
+ * @return A reference representing the element or null if either element is null or parent is null and element not
+ * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
+ * contain one key pointing directly to the element.
+ */
+ public static Reference toReference(Reference parent, Referable element, Class extends Reference> referenceType,
+ Class extends Key> keyType, boolean setReferredSemanticIdIfHasSemantics) {
+ Reference reference = toReference(parent, element, referenceType, keyType);
+ return handleReferredSemanticId(element, setReferredSemanticIdIfHasSemantics, reference);
+ }
+
+ /**
+ * Creates a reference for an element given a potential parent
+ *
+ * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
+ * result will always be null
+ * @param element the element to create a reference for
+ * @return A reference representing the element or null if either element is null or parent is null and element not
+ * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
+ * contain one key pointing directly to the element.
+ */
+ public static Reference toReference(Reference parent, Referable element) {
+ return toReference(parent,
+ element,
+ ReflectionHelper.getDefaultImplementation(Reference.class),
+ ReflectionHelper.getDefaultImplementation(Key.class));
+ }
+
+ /**
+ * Creates a reference for an element given a potential parent
+ *
+ * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise
+ * result will always be null
+ * @param element the element to create a reference for
+ * @param setReferredSemanticIdIfHasSemantics if the referredSemanticId should be set if the identifiable is of HasSemantics
+ *
+ * @return A reference representing the element or null if either element is null or parent is null and element not
+ * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only
+ * contain one key pointing directly to the element.
+ */
+ public static Reference toReference(Reference parent, Referable element, boolean setReferredSemanticIdIfHasSemantics) {
+ return toReference(parent,
+ element,
+ ReflectionHelper.getDefaultImplementation(Reference.class),
+ ReflectionHelper.getDefaultImplementation(Key.class),
+ setReferredSemanticIdIfHasSemantics);
+ }
+
+ /**
+ * Gets the KeyElements type matching the provided Referable
+ *
+ * @param referable The referable to convert to KeyElements type
+ * @return the most specific KeyElements type representing the Referable, i.e. abstract types like SUBMODEL_ELEMENT
+ * or DATA_ELEMENT are never returned; null if there is no corresponding KeyElements type
+ */
+ public static KeyTypes referableToKeyType(Referable referable) {
+ Class> aasInterface = ReflectionHelper.getAasInterface(referable.getClass());
+ if (aasInterface != null) {
+ return KeyTypes.valueOf(EnumDeserializer.deserializeEnumName(aasInterface.getSimpleName()));
+ }
+ return null;
+ }
+
+
+ /**
+ * Checks if two references are refering to the same element ignoring referredSemanticId.
+ *
+ * @param ref1 reference 1
+ * @param ref2 reference 2
+ * @return returns true if both references are refering to the same element, otherwise false
+ */
+ public static boolean sameAs(Reference ref1, Reference ref2) {
+ return sameAs(ref1, ref2, false);
+ }
+
+ /**
+ * Checks if two references are referring to the same element.
+ *
+ * @param ref1 reference 1
+ * @param ref2 reference 2
+ * @param compareReferredSemanticId true if referredSemanticId should be compared, false otherwise
+ * @return returns true if both references are referring to the same element, otherwise false
+ */
+ public static boolean sameAs(Reference ref1, Reference ref2, boolean compareReferredSemanticId) {
+ boolean ref1Empty = ref1 == null || ref1.getKeys() == null || ref1.getKeys().isEmpty();
+ boolean ref2Empty = ref2 == null || ref2.getKeys() == null || ref2.getKeys().isEmpty();
+ if (ref1Empty != ref2Empty) {
+ return false;
+ }
+ if (ref1.getType() != ref2.getType()) {
+ return false;
+ }
+ if (compareReferredSemanticId && !sameAs(ref1.getReferredSemanticId(), ref2.getReferredSemanticId())) {
+ return false;
+ }
+ if (ref1Empty && ref2Empty) {
+ return true;
+ }
+ if (ref1.getKeys().size() != ref2.getKeys().size()) {
+ return false;
+ }
+ for (int i = 0; i < ref1.getKeys().size(); i++) {
+ Key key1 = ref1.getKeys().get(ref1.getKeys().size() - (i + 1));
+ Key key2 = ref2.getKeys().get(ref2.getKeys().size() - (i + 1));
+ if (Objects.isNull(key1) != Objects.isNull(key2)) {
+ return false;
+ }
+ if (Objects.isNull(key1)) {
+ return true;
+ }
+ if (!Objects.equals(key1.getValue(), key2.getValue())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Creates a deep-copy clone of a reference using provided implementation types for reference and key
+ *
+ * @param reference the reference to clone
+ * @param referenceType implementation type of Reference interface
+ * @param keyType implementation type of Key interface
+ *
+ * @return the cloned reference
+ */
+ private static Reference clone(Reference reference, Class extends Reference> referenceType, Class extends Key> keyType) {
+ if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) {
+ return null;
+ }
+ try {
+ Reference result = referenceType.getConstructor().newInstance();
+ List newKeys = new ArrayList<>();
+ result.setType(reference.getType());
+ for (Key key : reference.getKeys()) {
+ Key newKey = keyType.getConstructor().newInstance();
+ newKey.setType(key.getType());
+ newKey.setValue(key.getValue());
+ newKeys.add(newKey);
+ }
+ result.setKeys(newKeys);
+ return result;
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+ throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex);
+ }
+ }
+
+ /**
+ * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available,
+ * null otherwise
+ *
+ *
+ * @param reference The reference to resolve
+ * @param env The AssetAdministrationShellEnvironment to resolve the reference against
+ * @return returns an instance of T if the reference could successfully be resolved, otherwise null
+ * @throws IllegalArgumentException if something goes wrong while resolving
+ */
+ public static Referable resolve(Reference reference, Environment env) {
+ return resolve(reference, env, Referable.class);
+ }
+
+ /**
+ * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available,
+ * null otherwise
+ *
+ * @param sub-type of Referable of the targeted type. If unknown use Referable.class
+ * @param reference The reference to resolve
+ * @param env The AssetAdministrationShellEnvironment to resolve the reference against
+ * @param type desired return type, use Referable.class is unknwon/not needed
+ * @return returns an instance of T if the reference could successfully be resolved, otherwise null
+ * @throws IllegalArgumentException if something goes wrong while resolving
+ */
+ @SuppressWarnings("unchecked")
+ public static T resolve(Reference reference, Environment env, Class type) {
+ if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) {
+ return null;
+ }
+ GetChildrenVisitor findChildrenVisitor = new GetChildrenVisitor(env);
+ findChildrenVisitor.visit(env);
+ Referable current = null;
+ for (int i = 0; i < reference.getKeys().size(); i++) {
+ Key key = reference.getKeys().get(i);
+ try {
+ int index = Integer.parseInt(key.getValue());
+ if (Objects.isNull(current) || !SubmodelElementList.class.isAssignableFrom(current.getClass())) {
+ throw new IllegalArgumentException("reference uses index notation on an element that is not a SubmodelElementList");
+ }
+ List list = ((SubmodelElementList) current).getValue();
+ if (list.size() <= index) {
+ throw new IllegalArgumentException(String.format(
+ "index notation out of bounds (list size: %s, requested index: %s)",
+ list.size(),
+ index));
+ }
+ current = list.get(index);
+ } catch (NumberFormatException e) {
+ current = findChildrenVisitor.getChildren().stream()
+ .filter(x -> Objects.equals(key.getValue(), GetIdentifierVisitor.getIdentifier(x)))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException(String.format(
+ "unable to resolve reference '%s' as element '%s' does not exist",
+ asString(reference),
+ key.getValue())));
+ }
+ findChildrenVisitor.reset();
+ findChildrenVisitor.visit(current);
+ }
+ if (current == null) {
+ return null;
+ }
+ if (!type.isAssignableFrom(current.getClass())) {
+ throw new IllegalArgumentException(String.format(
+ "reference '%s' could not be resolved as target type is not assignable from actual type (target: %s, actual: %s)",
+ asString(reference),
+ type.getName(),
+ current.getClass().getName()));
+ }
+ return type.cast(current);
+ }
+
+ private static Reference handleReferredSemanticId(Referable referable,
+ boolean setReferredSemanticIdIfHasSemantics, Reference reference) {
+ if (setReferredSemanticIdIfHasSemantics && referable instanceof HasSemantics) {
+ reference.setReferredSemanticId(((HasSemantics) referable).getSemanticId());
+ }
+
+ return reference;
+ }
+
+}
diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/CustomProperty.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/CustomProperty.java
index 65a7029d4..562361322 100644
--- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/CustomProperty.java
+++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/CustomProperty.java
@@ -26,15 +26,14 @@
import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier;
import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class CustomProperty implements Property {
- protected List embeddedDataSpecifications;
-
- protected List dataSpecifications;
+ protected List embeddedDataSpecifications = new ArrayList<>();
protected ModellingKind kind;
@@ -46,19 +45,19 @@ public class CustomProperty implements Property {
protected DataTypeDefXsd valueType;
- protected List qualifiers;
+ protected List qualifiers = new ArrayList<>();
protected String category;
- protected List description;
+ protected List description = new ArrayList<>();
- protected List displayName;
+ protected List displayName = new ArrayList<>();
protected String idShort;
- protected List extensions;
+ protected List extensions = new ArrayList<>();
- protected List supplementalSemanticIds;
+ protected List supplementalSemanticIds = new ArrayList<>();
protected CustomProperty() {
}
diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumDeserializerTest.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumDeserializerTest.java
index 93ddbd6cf..b902d4b26 100644
--- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumDeserializerTest.java
+++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumDeserializerTest.java
@@ -18,7 +18,8 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.deserialization.EnumDeserializer;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360;
import org.eclipse.digitaltwin.aas4j.v3.model.Direction;
import org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent;
diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumSerializerTest.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumSerializerTest.java
index 33cae0017..88971eb85 100644
--- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumSerializerTest.java
+++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/EnumSerializerTest.java
@@ -18,7 +18,8 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization.EnumSerializer;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer;
import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360;
import org.eclipse.digitaltwin.aas4j.v3.model.Direction;
import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind;
diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java
index 247888ff4..3d5c9d264 100644
--- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java
+++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java
@@ -1,508 +1,567 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- * Copyright (C) 2023 SAP SE or an SAP affiliate company.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util;
-
-import junitparams.JUnitParamsRunner;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull;
-import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
-import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
-import org.eclipse.digitaltwin.aas4j.v3.model.Operation;
-import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
-import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
-import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes;
-import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;
-import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection;
-import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-@RunWith(JUnitParamsRunner.class)
-public class AasUtilsTest {
-
- @Test
- public void whenResolve_withProperty_success() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- SubmodelElement expected = new DefaultProperty.Builder()
- .idShort(submodelElementIdShort)
- .value("bar")
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(expected)
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value(submodelElementIdShort)
- .build())
- .build();
- Referable actual = AasUtils.resolve(reference, environment);
- Assert.assertEquals(expected, actual);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void whenResolve_withInvalidType_fail() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- SubmodelElement expected = new DefaultProperty.Builder()
- .idShort(submodelElementIdShort)
- .value("bar")
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(expected)
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .type(ReferenceTypes.MODEL_REFERENCE)
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value(submodelElementIdShort)
- .build())
- .build();
- AasUtils.resolve(reference, environment, Operation.class);
- }
-
- @Test
- public void whenResolve_insideSubmodelElementList_success() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- String submodelElementListIdShort = "list";
- SubmodelElement expected = new DefaultProperty.Builder()
- .idShort(submodelElementIdShort)
- .value("bar")
- .build();
- SubmodelElementList list = new DefaultSubmodelElementList.Builder()
- .idShort(submodelElementListIdShort)
- .value(expected)
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(list)
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
- .value(submodelElementListIdShort)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value("0")
- .build())
- .build();
- Referable actual = AasUtils.resolve(reference, environment);
- Assert.assertEquals(expected, actual);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void whenResolve_insideSubmodelElementList_indexOutOfBounds() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- String submodelElementListIdShort = "list";
- SubmodelElement expected = new DefaultProperty.Builder()
- .idShort(submodelElementIdShort)
- .value("bar")
- .build();
- SubmodelElementList list = new DefaultSubmodelElementList.Builder()
- .idShort(submodelElementListIdShort)
- .value(expected)
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(list)
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
- .value(submodelElementListIdShort)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value("1")
- .build())
- .build();
- AasUtils.resolve(reference, environment);
- }
-
- @Test
- public void whenResolve_insideSubmodelElementCollection_success() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- String submodelElementListIdShort = "list";
- SubmodelElement expected = new DefaultProperty.Builder()
- .idShort(submodelElementIdShort)
- .value("bar")
- .build();
- SubmodelElementCollection list = new DefaultSubmodelElementCollection.Builder()
- .idShort(submodelElementListIdShort)
- .value(expected)
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(list)
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
- .value(submodelElementListIdShort)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value(submodelElementIdShort)
- .build())
- .build();
- Referable actual = AasUtils.resolve(reference, environment);
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void whenResolve_withSubmodel_success() {
- Environment environment = AASFull.createEnvironment();
- Reference submodelRef = AASFull.AAS_1.getSubmodels().get(0);
- Submodel expected = AASFull.SUBMODEL_3;
- Referable asReferable = AasUtils.resolve(submodelRef, environment);
- assertEquals(expected, asReferable);
- Submodel asSubmodel = AasUtils.resolve(submodelRef, environment, Submodel.class);
- assertEquals(expected, asSubmodel);
- }
-
- @Test
- public void whenResolve_withElementWithinSubmodelElementList_success() {
- String submodelId = "http://example.org/submodel";
- String submodelElementIdShort = "foo";
- SubmodelElement expected = new DefaultProperty.Builder()
- .value("bar")
- .build();
- Environment environment = new DefaultEnvironment.Builder()
- .submodels(new DefaultSubmodel.Builder()
- .id(submodelId)
- .submodelElements(new DefaultSubmodelElementList.Builder()
- .idShort(submodelElementIdShort)
- .value(expected)
- .build())
- .build())
- .build();
- Reference reference = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value(submodelId)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value(submodelElementIdShort)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT)
- .value("0")
- .build())
- .build();
- Referable actual = AasUtils.resolve(reference, environment);
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void whenSameAs_withDifferentKeyTypesButSameValues_success() {
- String value = "0173-1#01-ADS698#010";
- Reference ref1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.FRAGMENT_REFERENCE)
- .value(value)
- .build())
- .build();
- Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withoutKeys_success() {
- Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
- ref1.setKeys(null);
- Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
- ref2.setKeys(new ArrayList<>());
- Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withoutKeysAndDifferentTypes_fail() {
- Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
- ref1.setKeys(null);
- Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).build();
- ref2.setKeys(new ArrayList<>());
- Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withoutKeysAndDifferentSemaniticIDs_fail() {
- Reference semanticId1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .value("value1")
- .build())
- .build();
- Reference semanticId2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.FRAGMENT_REFERENCE)
- .value("value2")
- .build())
- .build();
- Reference ref1 = new DefaultReference.Builder()
- .referredSemanticId(semanticId1)
- .build();
- ref1.setKeys(null);
- Reference ref2 = new DefaultReference.Builder()
- .referredSemanticId(semanticId2)
- .build();
- ref2.setKeys(new ArrayList<>());
- Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true));
- }
-
- @Test
- public void whenSameAs_withDifferentKeyTypesButSameValuesAndSemanticIDs_success() {
- String value = "0173-1#01-ADS698#010";
- Reference semanticId1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference semanticId2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.FRAGMENT_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference ref1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .referredSemanticId(semanticId1)
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.FRAGMENT_REFERENCE)
- .value(value)
- .build())
- .referredSemanticId(semanticId2)
- .build();
- Assert.assertTrue(AasUtils.sameAs(ref1, ref2, true));
- }
-
- @Test
- public void whenSameAs_withDifferentKeyTypesAndValues_fail() {
- Reference ref1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("foo")
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.FRAGMENT_REFERENCE)
- .value("bar")
- .build())
- .build();
- Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withSameKeyTypesAndValues_success() {
- String value = "0173-1#01-ADS698#010";
- Reference ref1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withSameKeyTypesButDifferentValues_fail() {
- Reference ref1 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("foo")
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("bar")
- .build())
- .build();
- Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withDifferentReferredSemanticId_success() {
- String value = "0173-1#01-ADS698#010";
- Reference ref1 = new DefaultReference.Builder()
- .referredSemanticId(new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("foo")
- .build())
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .referredSemanticId(new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("bar")
- .build())
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
- }
-
- @Test
- public void whenSameAs_withDifferentReferredSemanticId_fail() {
- String value = "0173-1#01-ADS698#010";
- Reference ref1 = new DefaultReference.Builder()
- .referredSemanticId(new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("foo")
- .build())
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Reference ref2 = new DefaultReference.Builder()
- .referredSemanticId(new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("bar")
- .build())
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true));
- }
-
- @Test
- public void whenAsString_withSubmodelElementList_success() {
- Reference reference = new DefaultReference.Builder()
- .type(ReferenceTypes.MODEL_REFERENCE)
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL)
- .value("submodel")
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
- .value("list")
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.PROPERTY)
- .value("0")
- .build())
- .build();
- String expected = "[ModelRef](Submodel)submodel, (SubmodelElementList)list, (Property)0";
- String actual = AasUtils.asString(reference);
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void whenAsString_withReferredSemanticId_success() {
- String value = "0173-1#01-ADS698#010";
- Reference reference = new DefaultReference.Builder()
- .type(ReferenceTypes.EXTERNAL_REFERENCE)
- .referredSemanticId(new DefaultReference.Builder()
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value("foo")
- .build())
- .type(ReferenceTypes.MODEL_REFERENCE)
- .build())
- .keys(new DefaultKey.Builder()
- .type(KeyTypes.GLOBAL_REFERENCE)
- .value(value)
- .build())
- .build();
- String expected = "[ExternalRef- [ModelRef](GlobalReference)foo -](GlobalReference)0173-1#01-ADS698#010";
- String actual = AasUtils.asString(reference);
- Assert.assertEquals(expected, actual);
- }
-}
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ * Copyright (C) 2023 SAP SE or an SAP affiliate company.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull;
+import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd;
+import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
+import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
+import org.eclipse.digitaltwin.aas4j.v3.model.Operation;
+import org.eclipse.digitaltwin.aas4j.v3.model.Property;
+import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes;
+import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
+import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
+import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;
+import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import junitparams.JUnitParamsRunner;
+
+@RunWith(JUnitParamsRunner.class)
+public class AasUtilsTest {
+
+ @Test
+ public void whenResolve_withProperty_success() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .idShort(submodelElementIdShort)
+ .value("bar")
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(expected)
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value(submodelElementIdShort)
+ .build())
+ .build();
+ Referable actual = AasUtils.resolve(reference, environment);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void whenResolve_withInvalidType_fail() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .idShort(submodelElementIdShort)
+ .value("bar")
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(expected)
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .type(ReferenceTypes.MODEL_REFERENCE)
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value(submodelElementIdShort)
+ .build())
+ .build();
+ AasUtils.resolve(reference, environment, Operation.class);
+ }
+
+ @Test
+ public void whenResolve_insideSubmodelElementList_success() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ String submodelElementListIdShort = "list";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .idShort(submodelElementIdShort)
+ .value("bar")
+ .build();
+ SubmodelElementList list = new DefaultSubmodelElementList.Builder()
+ .idShort(submodelElementListIdShort)
+ .value(expected)
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(list)
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
+ .value(submodelElementListIdShort)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value("0")
+ .build())
+ .build();
+ Referable actual = AasUtils.resolve(reference, environment);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void whenResolve_insideSubmodelElementList_indexOutOfBounds() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ String submodelElementListIdShort = "list";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .idShort(submodelElementIdShort)
+ .value("bar")
+ .build();
+ SubmodelElementList list = new DefaultSubmodelElementList.Builder()
+ .idShort(submodelElementListIdShort)
+ .value(expected)
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(list)
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
+ .value(submodelElementListIdShort)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value("1")
+ .build())
+ .build();
+ AasUtils.resolve(reference, environment);
+ }
+
+ @Test
+ public void whenResolve_insideSubmodelElementCollection_success() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ String submodelElementListIdShort = "list";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .idShort(submodelElementIdShort)
+ .value("bar")
+ .build();
+ SubmodelElementCollection list = new DefaultSubmodelElementCollection.Builder()
+ .idShort(submodelElementListIdShort)
+ .value(expected)
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(list)
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
+ .value(submodelElementListIdShort)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value(submodelElementIdShort)
+ .build())
+ .build();
+ Referable actual = AasUtils.resolve(reference, environment);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void whenResolve_withSubmodel_success() {
+ Environment environment = AASFull.createEnvironment();
+ Reference submodelRef = AASFull.AAS_1.getSubmodels().get(0);
+ Submodel expected = AASFull.SUBMODEL_3;
+ Referable asReferable = AasUtils.resolve(submodelRef, environment);
+ assertEquals(expected, asReferable);
+ Submodel asSubmodel = AasUtils.resolve(submodelRef, environment, Submodel.class);
+ assertEquals(expected, asSubmodel);
+ }
+
+ @Test
+ public void whenResolve_withElementWithinSubmodelElementList_success() {
+ String submodelId = "http://example.org/submodel";
+ String submodelElementIdShort = "foo";
+ SubmodelElement expected = new DefaultProperty.Builder()
+ .value("bar")
+ .build();
+ Environment environment = new DefaultEnvironment.Builder()
+ .submodels(new DefaultSubmodel.Builder()
+ .id(submodelId)
+ .submodelElements(new DefaultSubmodelElementList.Builder()
+ .idShort(submodelElementIdShort)
+ .value(expected)
+ .build())
+ .build())
+ .build();
+ Reference reference = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value(submodelId)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value(submodelElementIdShort)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT)
+ .value("0")
+ .build())
+ .build();
+ Referable actual = AasUtils.resolve(reference, environment);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void whenSameAs_withDifferentKeyTypesButSameValues_success() {
+ String value = "0173-1#01-ADS698#010";
+ Reference ref1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.FRAGMENT_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withoutKeys_success() {
+ Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
+ ref1.setKeys(null);
+ Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
+ ref2.setKeys(new ArrayList<>());
+ Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withoutKeysAndDifferentTypes_fail() {
+ Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build();
+ ref1.setKeys(null);
+ Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).build();
+ ref2.setKeys(new ArrayList<>());
+ Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withoutKeysAndDifferentSemaniticIDs_fail() {
+ Reference semanticId1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .value("value1")
+ .build())
+ .build();
+ Reference semanticId2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.FRAGMENT_REFERENCE)
+ .value("value2")
+ .build())
+ .build();
+ Reference ref1 = new DefaultReference.Builder()
+ .referredSemanticId(semanticId1)
+ .build();
+ ref1.setKeys(null);
+ Reference ref2 = new DefaultReference.Builder()
+ .referredSemanticId(semanticId2)
+ .build();
+ ref2.setKeys(new ArrayList<>());
+ Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true));
+ }
+
+ @Test
+ public void whenSameAs_withDifferentKeyTypesButSameValuesAndSemanticIDs_success() {
+ String value = "0173-1#01-ADS698#010";
+ Reference semanticId1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference semanticId2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.FRAGMENT_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference ref1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .referredSemanticId(semanticId1)
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.FRAGMENT_REFERENCE)
+ .value(value)
+ .build())
+ .referredSemanticId(semanticId2)
+ .build();
+ Assert.assertTrue(AasUtils.sameAs(ref1, ref2, true));
+ }
+
+ @Test
+ public void whenSameAs_withDifferentKeyTypesAndValues_fail() {
+ Reference ref1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("foo")
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.FRAGMENT_REFERENCE)
+ .value("bar")
+ .build())
+ .build();
+ Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withSameKeyTypesAndValues_success() {
+ String value = "0173-1#01-ADS698#010";
+ Reference ref1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withSameKeyTypesButDifferentValues_fail() {
+ Reference ref1 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("foo")
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("bar")
+ .build())
+ .build();
+ Assert.assertFalse(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withDifferentReferredSemanticId_success() {
+ String value = "0173-1#01-ADS698#010";
+ Reference ref1 = new DefaultReference.Builder()
+ .referredSemanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("foo")
+ .build())
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .referredSemanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("bar")
+ .build())
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Assert.assertTrue(AasUtils.sameAs(ref1, ref2));
+ }
+
+ @Test
+ public void whenSameAs_withDifferentReferredSemanticId_fail() {
+ String value = "0173-1#01-ADS698#010";
+ Reference ref1 = new DefaultReference.Builder()
+ .referredSemanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("foo")
+ .build())
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Reference ref2 = new DefaultReference.Builder()
+ .referredSemanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("bar")
+ .build())
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true));
+ }
+
+ @Test
+ public void whenAsString_withSubmodelElementList_success() {
+ Reference reference = new DefaultReference.Builder()
+ .type(ReferenceTypes.MODEL_REFERENCE)
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL)
+ .value("submodel")
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.SUBMODEL_ELEMENT_LIST)
+ .value("list")
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.PROPERTY)
+ .value("0")
+ .build())
+ .build();
+ String expected = "[ModelRef](Submodel)submodel, (SubmodelElementList)list, (Property)0";
+ String actual = AasUtils.asString(reference);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void whenAsString_withReferredSemanticId_success() {
+ String value = "0173-1#01-ADS698#010";
+ Reference reference = new DefaultReference.Builder()
+ .type(ReferenceTypes.EXTERNAL_REFERENCE)
+ .referredSemanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("foo")
+ .build())
+ .type(ReferenceTypes.MODEL_REFERENCE)
+ .build())
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value(value)
+ .build())
+ .build();
+ String expected = "[ExternalRef- [ModelRef](GlobalReference)foo -](GlobalReference)0173-1#01-ADS698#010";
+ String actual = AasUtils.asString(reference);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void whenAsReferenceWithReferredSemanticId_IdentifiableWithSemanticId_success() {
+ Submodel submodel = AASFull.SUBMODEL_3;
+ Reference ref = AasUtils.toReference(submodel, true);
+ assertEquals(submodel.getSemanticId(), ref.getReferredSemanticId());
+ }
+
+ @Test
+ public void whenAsReferenceWithoutReferredSemanticId_IdentifiableWithSemanticId_success() {
+ Submodel submodel = AASFull.SUBMODEL_3;
+ Reference ref = AasUtils.toReference(submodel, false);
+ assertEquals(null, ref.getReferredSemanticId());
+ }
+
+ @Test
+ public void whenAsReferenceWithReferredSemanticId_PropertyWithSemanticId_success() {
+ Property prop = createPropertyWithSemanticId();
+ Reference reference = new DefaultReference.Builder()
+ .type(ReferenceTypes.EXTERNAL_REFERENCE)
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("bar")
+ .build())
+ .build();
+ Reference ref = AasUtils.toReference(reference, prop, true);
+ assertEquals(prop.getSemanticId(), ref.getReferredSemanticId());
+ }
+
+ @Test
+ public void whenAsReferenceWithoutReferredSemanticId_PropertyWithSemanticId_success() {
+ Property prop = createPropertyWithSemanticId();
+ Reference reference = new DefaultReference.Builder()
+ .type(ReferenceTypes.EXTERNAL_REFERENCE)
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("bar")
+ .build())
+ .build();
+ Reference ref = AasUtils.toReference(reference, prop, false);
+ assertEquals(null, ref.getReferredSemanticId());
+ }
+
+ private Property createPropertyWithSemanticId() {
+ return new DefaultProperty.Builder()
+ .idShort("ExampleProperty1")
+ .semanticId(new DefaultReference.Builder()
+ .keys(new DefaultKey.Builder()
+ .type(KeyTypes.GLOBAL_REFERENCE)
+ .value("http://acplt.org/Properties/ExampleProperty")
+ .build())
+ .type(ReferenceTypes.EXTERNAL_REFERENCE)
+ .build())
+ .value("http://acplt.org/ValueId/ExampleValueId")
+ .valueType(DataTypeDefXsd.STRING)
+ .build();
+ }
+}
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializer.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializer.java
index 785769cd9..ded7c4345 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializer.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializer.java
@@ -1,195 +1,195 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- * Copyright (C) 2023 SAP SE or an SAP affiliate company.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
-
-/**
- * Class for deserializing/parsing AAS JSON documents.
- */
-public class JsonDeserializer {
- protected JsonMapper mapper;
- protected SimpleAbstractTypeResolver typeResolver;
- private JsonMapperFactory jsonMapperFactory;
-
- public JsonDeserializer() {
- typeResolver = new SimpleAbstractTypeResolverFactory().create();
- jsonMapperFactory = new JsonMapperFactory();
- mapper = jsonMapperFactory.create(typeResolver);
- }
-
- /**
- * Enables usage of custom implementation to be used for deserialization instead of default implementation, e.g.
- * defining a custom implementation of the Submodel interface {@code class
- * CustomSubmodel implements Submodel {}} and calling
- * {@code useImplementation(Submodel.class, CustomSubmodel.class);} will result in all instances of Submodel will be
- * deserialized as CustomSubmodel. Subsequent class with the same aasInterface parameter will override the effects
- * of all previous calls.
- *
- * @param the type of the interface to replace
- * @param aasInterface the class of the interface to replace
- * @param implementation the class implementing the interface that should be used for deserialization.
- */
- public void useImplementation(Class aasInterface, Class extends T> implementation) {
- typeResolver.addMapping(aasInterface, implementation);
- mapper = jsonMapperFactory.create(typeResolver);
- }
-
- /**
- * Generic method to deserialize a given string into instance of an AAS type
- *
- * @param value a string representation of the AAS instance
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return the instance
- * @throws DeserializationException if deserialization fails
- */
- public T read(String value, Class valueType) throws DeserializationException {
- try {
- return mapper.readValue(value, valueType);
- } catch (JsonProcessingException ex) {
- throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
- }
- }
-
- /**
- * Generic method to deserialize a given string into a list of AAS instances
- *
- * @param value a string representation of the AAS instances list
- * @param valueType the class type of the instance. Not null.
- * @param the AAS type
- * @return a list of AAS instances
- * @throws DeserializationException if deserialization fails
- */
- public List readList(String value, Class valueType) throws DeserializationException {
- try {
- return mapper.readValue(value, mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
- } catch (JsonProcessingException ex) {
- throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
- }
- }
-
- /**
- * Generic method to deserialize a given InputStream into instance of an AAS type, using the default UTF-8 charset
- *
- * @param stream An InputStream containing the string representation of the AAS instance
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return an AAS instance
- * @throws DeserializationException if deserialization fails
- */
- public T read(InputStream stream, Class valueType) throws DeserializationException {
- return read(stream, StandardCharsets.UTF_8, valueType);
- }
-
- /**
- * Generic method to deserialize a given InputStream into instance of an AAS type, using a given charset
- *
- * @param stream An InputStream containing the string representation of the AAS instance
- * @param charset the charset to use for deserialization
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return an AAS instance
- * @throws DeserializationException if deserialization fails
- */
- public T read(InputStream stream, Charset charset, Class valueType) throws DeserializationException {
- try {
- return mapper.readValue(new InputStreamReader(stream, charset), valueType);
- } catch (IOException ex) {
- throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
- }
- }
-
- /**
- * Deserializes a given input stream into a list of AAS instances using the default UTF-8 charset
- *
- * @param stream An InputStream containing the string representation of the AAS instances list
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return a list of AAS instances
- * @throws DeserializationException if deserialization fails
- */
- public List readList(InputStream stream, Class valueType) throws DeserializationException {
- return readList(stream, StandardCharsets.UTF_8, valueType);
- }
-
- /**
- * Deserializes a given input stream into a list of AAS instances
- *
- * @param stream An InputStream containing the string representation of the AAS instances list
- * @param charset the charset to use for deserialization
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return a list of AAS instances
- * @throws DeserializationException if deserialization fails
- */
- public List readList(InputStream stream, Charset charset, Class valueType) throws DeserializationException {
- try {
- return mapper.readValue(new InputStreamReader(stream, charset),
- mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
- } catch (Exception ex) {
- throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
- }
- }
-
- /**
- * Generic method to deserialize a given JSON node into instance of an AAS type
- *
- * @param node the node to parse
- * @param valueType the class type of the AAS instance. Not null.
- * @param the AAS type
- * @return an AAS instance
- *
- * @throws DeserializationException if deserialization fails
- */
- public T read(JsonNode node, Class valueType) throws DeserializationException {
- try {
- return mapper.treeToValue(node, valueType);
- } catch (JsonProcessingException ex) {
- throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
- }
- }
-
- /**
- * Deserializes a given JsonArray into a list of AAS instances
- *
- * @param node a JsonArray representing the AAS instances list
- * @param valueType the class type of the instance. Not null.
- * @param the AAS type
- * @return a list of AAS instances
- * @throws DeserializationException if deserialization fails
- */
- public List readList(JsonNode node, Class valueType) throws DeserializationException {
- try {
- return mapper.treeToValue(node, mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
- } catch (JsonProcessingException ex) {
- throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
- }
- }
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ * Copyright (C) 2023 SAP SE or an SAP affiliate company.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
+
+/**
+ * Class for deserializing/parsing AAS JSON documents.
+ */
+public class JsonDeserializer {
+ protected JsonMapper mapper;
+ protected SimpleAbstractTypeResolver typeResolver;
+ private JsonMapperFactory jsonMapperFactory;
+
+ public JsonDeserializer() {
+ typeResolver = new SimpleAbstractTypeResolverFactory().create();
+ jsonMapperFactory = new JsonMapperFactory();
+ mapper = jsonMapperFactory.create(typeResolver);
+ }
+
+ /**
+ * Enables usage of custom implementation to be used for deserialization instead of default implementation, e.g.
+ * defining a custom implementation of the Submodel interface {@code class
+ * CustomSubmodel implements Submodel {}} and calling
+ * {@code useImplementation(Submodel.class, CustomSubmodel.class);} will result in all instances of Submodel will be
+ * deserialized as CustomSubmodel. Subsequent class with the same aasInterface parameter will override the effects
+ * of all previous calls.
+ *
+ * @param the type of the interface to replace
+ * @param aasInterface the class of the interface to replace
+ * @param implementation the class implementing the interface that should be used for deserialization.
+ */
+ public void useImplementation(Class aasInterface, Class extends T> implementation) {
+ typeResolver.addMapping(aasInterface, implementation);
+ mapper = jsonMapperFactory.create(typeResolver);
+ }
+
+ /**
+ * Generic method to deserialize a given string into instance of an AAS type
+ *
+ * @param value a string representation of the AAS instance
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return the instance
+ * @throws DeserializationException if deserialization fails
+ */
+ public T read(String value, Class valueType) throws DeserializationException {
+ try {
+ return mapper.readValue(value, valueType);
+ } catch (JsonProcessingException ex) {
+ throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Generic method to deserialize a given string into a list of AAS instances
+ *
+ * @param value a string representation of the AAS instances list
+ * @param valueType the class type of the instance. Not null.
+ * @param the AAS type
+ * @return a list of AAS instances
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readList(String value, Class valueType) throws DeserializationException {
+ try {
+ return mapper.readValue(value, mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
+ } catch (JsonProcessingException ex) {
+ throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Generic method to deserialize a given InputStream into instance of an AAS type, using the default UTF-8 charset
+ *
+ * @param stream An InputStream containing the string representation of the AAS instance
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return an AAS instance
+ * @throws DeserializationException if deserialization fails
+ */
+ public T read(InputStream stream, Class valueType) throws DeserializationException {
+ return read(stream, StandardCharsets.UTF_8, valueType);
+ }
+
+ /**
+ * Generic method to deserialize a given InputStream into instance of an AAS type, using a given charset
+ *
+ * @param stream An InputStream containing the string representation of the AAS instance
+ * @param charset the charset to use for deserialization
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return an AAS instance
+ * @throws DeserializationException if deserialization fails
+ */
+ public T read(InputStream stream, Charset charset, Class valueType) throws DeserializationException {
+ try {
+ return mapper.readValue(new InputStreamReader(stream, charset), valueType);
+ } catch (IOException ex) {
+ throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Deserializes a given input stream into a list of AAS instances using the default UTF-8 charset
+ *
+ * @param stream An InputStream containing the string representation of the AAS instances list
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return a list of AAS instances
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readList(InputStream stream, Class valueType) throws DeserializationException {
+ return readList(stream, StandardCharsets.UTF_8, valueType);
+ }
+
+ /**
+ * Deserializes a given input stream into a list of AAS instances
+ *
+ * @param stream An InputStream containing the string representation of the AAS instances list
+ * @param charset the charset to use for deserialization
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return a list of AAS instances
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readList(InputStream stream, Charset charset, Class valueType) throws DeserializationException {
+ try {
+ return mapper.readValue(new InputStreamReader(stream, charset),
+ mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Generic method to deserialize a given JSON node into instance of an AAS type
+ *
+ * @param node the node to parse
+ * @param valueType the class type of the AAS instance. Not null.
+ * @param the AAS type
+ * @return an AAS instance
+ *
+ * @throws DeserializationException if deserialization fails
+ */
+ public T read(JsonNode node, Class valueType) throws DeserializationException {
+ try {
+ return mapper.treeToValue(node, valueType);
+ } catch (JsonProcessingException ex) {
+ throw new DeserializationException("error deserializing " + valueType.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Deserializes a given JsonArray into a list of AAS instances
+ *
+ * @param node a JsonArray representing the AAS instances list
+ * @param valueType the class type of the instance. Not null.
+ * @param the AAS type
+ * @return a list of AAS instances
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readList(JsonNode node, Class valueType) throws DeserializationException {
+ try {
+ return mapper.treeToValue(node, mapper.getTypeFactory().constructCollectionLikeType(List.class, valueType));
+ } catch (JsonProcessingException ex) {
+ throw new DeserializationException("error deserializing list of " + valueType.getSimpleName(), ex);
+ }
+ }
}
\ No newline at end of file
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonMapperFactory.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonMapperFactory.java
index a849c7370..4083f3ac3 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonMapperFactory.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonMapperFactory.java
@@ -19,9 +19,9 @@
import java.util.Arrays;
import java.util.List;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.deserialization.EnumDeserializer;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization.EnumSerializer;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.ReflectionAnnotationIntrospector;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSchemaValidator.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSchemaValidator.java
index d873e4407..437a8351a 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSchemaValidator.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSchemaValidator.java
@@ -22,7 +22,6 @@
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersionDetector;
import com.networknt.schema.ValidationMessage;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SchemaValidator;
import java.io.BufferedReader;
import java.io.IOException;
@@ -31,6 +30,8 @@
import java.util.Set;
import java.util.stream.Collectors;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SchemaValidator;
+
/**
* Class for validating a serialized instance of AssetAdministrationShellEnvironment against a json-schema.
*/
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializer.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializer.java
index 527468176..1ad323402 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializer.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializer.java
@@ -1,169 +1,169 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- * Copyright (C) 2023 SAP SE or an SAP affiliate company.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-
-/**
- * Class for serializing of AAS instances.
- */
-public class JsonSerializer {
- protected JsonMapper mapper;
-
- public JsonSerializer() {
- mapper = new JsonMapperFactory().create(new SimpleAbstractTypeResolverFactory().create());
- }
-
- /**
- * Generic method to serialize a given AAS instance to a string
- *
- * @param aasInstance the AAS instance to serialize
- * @return the string representation
- * @throws SerializationException if serialization fails
- */
- public String write(Object aasInstance) throws SerializationException {
- try {
- return mapper.writeValueAsString(aasInstance);
- } catch (JsonProcessingException ex) {
- throw new SerializationException(
- String.format("error serializing %s", aasInstance.getClass().getSimpleName()), ex);
- }
- }
-
- /**
- * Generic method to serialize a collection.
- * @param collection the collection to serialize. Not null.
- * @return the string representation of the collection.
- * @throws SerializationException if serialization fails
- */
- public String writeList(Collection> collection) throws SerializationException {
- if (collection == null || collection.isEmpty()) {
- return write(collection);
- }
-
- Class clazz = collection.iterator().next().getClass();
- try {
- return mapper.writerFor(mapper.getTypeFactory().constructCollectionType(List.class, clazz))
- .writeValueAsString(collection);
- } catch (JsonProcessingException ex) {
- throw new SerializationException("error serializing list of " + clazz.getSimpleName(), ex);
- }
- }
-
- /**
- * Generic method to convert a given AAS instance to a JSON node
- *
- * @param aasInstance the AAS instance to serialize
- * @return the JSON node representation
- * @throws IllegalArgumentException
- */
- public JsonNode toNode(Object aasInstance) {
- return mapper.valueToTree(aasInstance);
- }
-
- /**
- * Generic method to convert a collection of AAS instances to a JSON array
- *
- * @param aasInstances the list of AAS instances to convert
- * @return the JSON array representation
- * @throws IllegalArgumentException
- */
- public JsonNode toArrayNode(Collection> aasInstances) {
- if(aasInstances == null) {
- return JsonNodeFactory.instance.nullNode();
- }
- ArrayNode result = JsonNodeFactory.instance.arrayNode();
- for (Object obj : aasInstances) {
- result.add(toNode(obj));
- }
- return result;
- }
-
- /**
- * Generic method to serialize a given AAS instance to an output stream using given charset
- *
- * @param out the output stream to serialize to
- * @param charset the charset to use for serialization
- * @param aasInstance the AAS instance to serialize
- * @throws SerializationException if serialization fails
- */
- public void write(OutputStream out, Charset charset, Object aasInstance) throws SerializationException {
- try {
- mapper.writeValue(new OutputStreamWriter(out, charset), aasInstance);
- } catch (IOException ex) {
- throw new SerializationException("error serializing " + aasInstance.getClass().getSimpleName() , ex);
- }
- }
-
- /**
- * Generic method to serialize a given AAS instance to an output stream using UTF-8 charset
- *
- * @param out the output stream to serialize to
- * @param aasInstance the AAS instance to serialize
- * @throws SerializationException if serialization fails
- */
- public void write(OutputStream out, Object aasInstance) throws SerializationException {
- write(out, StandardCharsets.UTF_8, aasInstance);
- }
-
- /**
- * Generic method to serialize a collection of AAS instances to an output stream using given charset
- *
- * @param out the output stream to serialize to
- * @param charset the charset to use for serialization
- * @param collection the collection of AAS instances to serialize
- * @throws SerializationException if serialization fails
- */
- public void writeList(OutputStream out, Charset charset, Collection> collection) throws SerializationException {
- if (collection == null || collection.isEmpty()) {
- write(out, charset, collection);
- } else {
- Class clazz = collection.iterator().next().getClass();
- try {
- mapper.writerFor(mapper.getTypeFactory().constructCollectionType(List.class, clazz))
- .writeValue(new OutputStreamWriter(out, charset), collection);
- } catch (IOException ex) {
- throw new SerializationException("error serializing list of " + clazz.getSimpleName(), ex);
- }
- }
- }
-
- /**
- * Generic method to serialize a collection of AAS instances to an output stream using UTF-8 charset
- *
- * @param out the output stream to serialize to
- * @param collection the collection of AAS instances to serialize
- * @throws SerializationException if serialization fails
- */
- public void writeList(OutputStream out, Collection> collection) throws SerializationException {
- writeList(out, StandardCharsets.UTF_8, collection);
- }
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ * Copyright (C) 2023 SAP SE or an SAP affiliate company.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+/**
+ * Class for serializing of AAS instances.
+ */
+public class JsonSerializer {
+ protected JsonMapper mapper;
+
+ public JsonSerializer() {
+ mapper = new JsonMapperFactory().create(new SimpleAbstractTypeResolverFactory().create());
+ }
+
+ /**
+ * Generic method to serialize a given AAS instance to a string
+ *
+ * @param aasInstance the AAS instance to serialize
+ * @return the string representation
+ * @throws SerializationException if serialization fails
+ */
+ public String write(Object aasInstance) throws SerializationException {
+ try {
+ return mapper.writeValueAsString(aasInstance);
+ } catch (JsonProcessingException ex) {
+ throw new SerializationException(
+ String.format("error serializing %s", aasInstance.getClass().getSimpleName()), ex);
+ }
+ }
+
+ /**
+ * Generic method to serialize a collection.
+ * @param collection the collection to serialize. Not null.
+ * @return the string representation of the collection.
+ * @throws SerializationException if serialization fails
+ */
+ public String writeList(Collection> collection) throws SerializationException {
+ if (collection == null || collection.isEmpty()) {
+ return write(collection);
+ }
+
+ Class clazz = collection.iterator().next().getClass();
+ try {
+ return mapper.writerFor(mapper.getTypeFactory().constructCollectionType(List.class, clazz))
+ .writeValueAsString(collection);
+ } catch (JsonProcessingException ex) {
+ throw new SerializationException("error serializing list of " + clazz.getSimpleName(), ex);
+ }
+ }
+
+ /**
+ * Generic method to convert a given AAS instance to a JSON node
+ *
+ * @param aasInstance the AAS instance to serialize
+ * @return the JSON node representation
+ * @throws IllegalArgumentException
+ */
+ public JsonNode toNode(Object aasInstance) {
+ return mapper.valueToTree(aasInstance);
+ }
+
+ /**
+ * Generic method to convert a collection of AAS instances to a JSON array
+ *
+ * @param aasInstances the list of AAS instances to convert
+ * @return the JSON array representation
+ * @throws IllegalArgumentException
+ */
+ public JsonNode toArrayNode(Collection> aasInstances) {
+ if(aasInstances == null) {
+ return JsonNodeFactory.instance.nullNode();
+ }
+ ArrayNode result = JsonNodeFactory.instance.arrayNode();
+ for (Object obj : aasInstances) {
+ result.add(toNode(obj));
+ }
+ return result;
+ }
+
+ /**
+ * Generic method to serialize a given AAS instance to an output stream using given charset
+ *
+ * @param out the output stream to serialize to
+ * @param charset the charset to use for serialization
+ * @param aasInstance the AAS instance to serialize
+ * @throws SerializationException if serialization fails
+ */
+ public void write(OutputStream out, Charset charset, Object aasInstance) throws SerializationException {
+ try {
+ mapper.writeValue(new OutputStreamWriter(out, charset), aasInstance);
+ } catch (IOException ex) {
+ throw new SerializationException("error serializing " + aasInstance.getClass().getSimpleName() , ex);
+ }
+ }
+
+ /**
+ * Generic method to serialize a given AAS instance to an output stream using UTF-8 charset
+ *
+ * @param out the output stream to serialize to
+ * @param aasInstance the AAS instance to serialize
+ * @throws SerializationException if serialization fails
+ */
+ public void write(OutputStream out, Object aasInstance) throws SerializationException {
+ write(out, StandardCharsets.UTF_8, aasInstance);
+ }
+
+ /**
+ * Generic method to serialize a collection of AAS instances to an output stream using given charset
+ *
+ * @param out the output stream to serialize to
+ * @param charset the charset to use for serialization
+ * @param collection the collection of AAS instances to serialize
+ * @throws SerializationException if serialization fails
+ */
+ public void writeList(OutputStream out, Charset charset, Collection> collection) throws SerializationException {
+ if (collection == null || collection.isEmpty()) {
+ write(out, charset, collection);
+ } else {
+ Class clazz = collection.iterator().next().getClass();
+ try {
+ mapper.writerFor(mapper.getTypeFactory().constructCollectionType(List.class, clazz))
+ .writeValue(new OutputStreamWriter(out, charset), collection);
+ } catch (IOException ex) {
+ throw new SerializationException("error serializing list of " + clazz.getSimpleName(), ex);
+ }
+ }
+ }
+
+ /**
+ * Generic method to serialize a collection of AAS instances to an output stream using UTF-8 charset
+ *
+ * @param out the output stream to serialize to
+ * @param collection the collection of AAS instances to serialize
+ * @throws SerializationException if serialization fails
+ */
+ public void writeList(OutputStream out, Collection> collection) throws SerializationException {
+ writeList(out, StandardCharsets.UTF_8, collection);
+ }
}
\ No newline at end of file
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/SimpleAbstractTypeResolverFactory.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/SimpleAbstractTypeResolverFactory.java
index 742af85ab..9a39c4d17 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/SimpleAbstractTypeResolverFactory.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/SimpleAbstractTypeResolverFactory.java
@@ -16,7 +16,7 @@
package org.eclipse.digitaltwin.aas4j.v3.dataformat.json;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper;
import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/ReflectionAnnotationIntrospector.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/ReflectionAnnotationIntrospector.java
index a461709b8..adbd3ead8 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/ReflectionAnnotationIntrospector.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/ReflectionAnnotationIntrospector.java
@@ -25,12 +25,13 @@
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper;
+
/**
* This class helps to dynamically decide how to de-/serialize classes and
* properties defined in the AAS model library.
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetAdministrationShellMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetAdministrationShellMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetAdministrationShellMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetAdministrationShellMixin.java
index b71c21b9e..df0a20a04 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetAdministrationShellMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetAdministrationShellMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetInformationMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetInformationMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetInformationMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetInformationMixin.java
index d5fc45b33..db04219fb 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/AssetInformationMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/AssetInformationMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/BlobMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/BlobMixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/BlobMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/BlobMixin.java
index 23ed61c3f..2eee52732 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/BlobMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/BlobMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/DataSpecificationIec61360Mixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/DataSpecificationIec61360Mixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/DataSpecificationIec61360Mixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/DataSpecificationIec61360Mixin.java
index 9653720d3..02f044946 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/DataSpecificationIec61360Mixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/DataSpecificationIec61360Mixin.java
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
-
-import java.util.List;
-
-import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-public interface DataSpecificationIec61360Mixin {
- @JsonInclude(JsonInclude.Include.ALWAYS)
- List getPreferredName();
-}
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
+
+import java.util.List;
+
+import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+public interface DataSpecificationIec61360Mixin {
+ @JsonInclude(JsonInclude.Include.ALWAYS)
+ List getPreferredName();
+}
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EndpointMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EndpointMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EndpointMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EndpointMixin.java
index da1f46232..7a99100f9 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EndpointMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EndpointMixin.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EntityMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EntityMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EntityMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EntityMixin.java
index 189a273ce..12752806f 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EntityMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EntityMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.EntityType;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EnvironmentMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EnvironmentMixin.java
similarity index 94%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EnvironmentMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EnvironmentMixin.java
index 11261f1b3..f1472970c 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/EnvironmentMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/EnvironmentMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import java.util.List;
import java.util.Set;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ExtensionMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ExtensionMixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ExtensionMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ExtensionMixin.java
index 06240b00a..391591e61 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ExtensionMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ExtensionMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/FileMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/FileMixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/FileMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/FileMixin.java
index e32942542..2efe8d5bb 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/FileMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/FileMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/IdentifiableMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/IdentifiableMixin.java
similarity index 90%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/IdentifiableMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/IdentifiableMixin.java
index 96d0dfd8d..298648d59 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/IdentifiableMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/IdentifiableMixin.java
@@ -1,23 +1,23 @@
-/*
- * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-public interface IdentifiableMixin {
- @JsonInclude(JsonInclude.Include.ALWAYS)
- String getId();
-}
+/*
+ * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+public interface IdentifiableMixin {
+ @JsonInclude(JsonInclude.Include.ALWAYS)
+ String getId();
+}
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/KeyMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/KeyMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/KeyMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/KeyMixin.java
index 26de3024d..81195aa82 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/KeyMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/KeyMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/OperationVariableMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/OperationVariableMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/OperationVariableMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/OperationVariableMixin.java
index aec20388d..ebefc1a6f 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/OperationVariableMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/OperationVariableMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/QualifierMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/QualifierMixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/QualifierMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/QualifierMixin.java
index 53f937f59..1ec9ad926 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/QualifierMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/QualifierMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RangeMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RangeMixin.java
similarity index 91%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RangeMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RangeMixin.java
index d7b609ac4..8fdf23376 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RangeMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RangeMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ReferenceMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ReferenceMixin.java
similarity index 93%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ReferenceMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ReferenceMixin.java
index 222de6026..b9020a071 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/ReferenceMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/ReferenceMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import java.util.List;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RelationshipElementMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RelationshipElementMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RelationshipElementMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RelationshipElementMixin.java
index cc3adb685..bba53c0ce 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/RelationshipElementMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/RelationshipElementMixin.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/SubmodelElementListMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/SubmodelElementListMixin.java
similarity index 92%
rename from dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/SubmodelElementListMixin.java
rename to dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/SubmodelElementListMixin.java
index 3ea2fa1b1..d4e9fbff0 100644
--- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/SubmodelElementListMixin.java
+++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/SubmodelElementListMixin.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.mixins;
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.mixins;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
index 45761420b..b82589878 100644
--- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
+++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
@@ -23,12 +23,13 @@
import java.util.Set;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
+
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.CustomProperty;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.CustomSubmodel;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.CustomSubmodel2;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.ExampleData;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.Examples;
import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShellDescriptor;
diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
index 43ed8361b..d857cd195 100644
--- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
+++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
@@ -29,7 +29,7 @@
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.JsonNode;
-import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.ExampleData;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.Examples;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml
new file mode 100644
index 000000000..4017ce587
--- /dev/null
+++ b/dataformat-rdf/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+ org.eclipse.digitaltwin.aas4j
+ aas4j-dataformat-parent
+ ${revision}
+
+ aas4j-dataformat-rdf
+ Asset Administration Shell RDF-Serializer
+
+
+
+ ${project.groupId}
+ aas4j-dataformat-core
+
+
+ ${project.groupId}
+ aas4j-dataformat-core
+ tests
+ test
+
+
+ org.apache.jena
+ jena-arq
+ ${jena.version}
+
+
+ org.apache.jena
+ jena-shacl
+ ${jena.version}
+
+
+ org.slf4j
+ slf4j-api
+
+
+ pl.pragmatists
+ JUnitParams
+ test
+
+
+ junit
+ junit
+ test
+
+
+
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java
new file mode 100644
index 000000000..8ebe2468d
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java
@@ -0,0 +1,1432 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.ResourceFactory;
+
+import java.util.List;
+
+/**
+ * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and org.apache.jena.rdf.model.Property compatible with Apache Jena.
+ */
+public final class AASNamespace {
+ public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/";
+
+ public static final org.apache.jena.rdf.model.Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index");
+
+ private AASNamespace() {
+
+ }
+
+ /**
+ * A key is a reference to an element by its ID.
+ *
+ * @see AASNamespace.KeyTypes
+ */
+ public static final class Key {
+ /**
+ * The key value, for example an IRDI or an URI
+ */
+ public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/value");
+ /**
+ * Denotes which kind of entity is referenced.
+ */
+ public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type");
+ }
+
+ public static final class Reference {
+ public static final org.apache.jena.rdf.model.Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys");
+ public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type");
+ }
+
+ public static final class HasExtensions {
+ public static final org.apache.jena.rdf.model.Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions");
+ }
+
+ public static final class Referable {
+ public static final org.apache.jena.rdf.model.Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort");
+ public static final org.apache.jena.rdf.model.Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName");
+ public static final org.apache.jena.rdf.model.Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description");
+ public static final org.apache.jena.rdf.model.Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category");
+ }
+
+ public static final class Identifiable {
+ public static final org.apache.jena.rdf.model.Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id");
+ public static final org.apache.jena.rdf.model.Property administration = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/administration");
+ }
+
+ /**
+ * The semantics of a property or other elements that may have a semantic description is defined by a concept description.
+ */
+ public static class ConceptDescription {
+ public static final org.apache.jena.rdf.model.Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf");
+ }
+
+ /**
+ * Enumeration of different key value types within a key.
+ *
+ * @see AASNamespace.Key
+ */
+ public static final class KeyTypes {
+ public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AssetAdministrationShell");
+ public static final org.apache.jena.rdf.model.Resource BasicEventElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/BasicEventElement");
+ public static final org.apache.jena.rdf.model.Resource Blob =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Blob");
+ public static final org.apache.jena.rdf.model.Resource Capability =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Capability");
+ public static final org.apache.jena.rdf.model.Resource ConceptDescription =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ConceptDescription");
+ public static final org.apache.jena.rdf.model.Resource DataElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/DataElement");
+ public static final org.apache.jena.rdf.model.Resource Entity =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Entity");
+ public static final org.apache.jena.rdf.model.Resource EventElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/EventElement");
+ public static final org.apache.jena.rdf.model.Resource File =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/File");
+ public static final org.apache.jena.rdf.model.Resource FragmentReference =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/FragmentReference");
+ public static final org.apache.jena.rdf.model.Resource GlobalReference =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/GlobalReference");
+ public static final org.apache.jena.rdf.model.Resource Identifiable =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Identifiable");
+ public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/MultiLanguageProperty");
+ public static final org.apache.jena.rdf.model.Resource Operation =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Operation");
+ public static final org.apache.jena.rdf.model.Resource Property =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Property");
+ public static final org.apache.jena.rdf.model.Resource Range =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Range");
+ public static final org.apache.jena.rdf.model.Resource ReferenceElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ReferenceElement");
+ public static final org.apache.jena.rdf.model.Resource RelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/RelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource Submodel =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Submodel");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElement");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementList =
+ ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementList");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI) {
+ if (stringIRI.equals(AnnotatedRelationshipElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT;
+ }
+ if (stringIRI.equals(AssetAdministrationShell.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ASSET_ADMINISTRATION_SHELL;
+ }
+ if (stringIRI.equals(BasicEventElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.BASIC_EVENT_ELEMENT;
+ }
+ if (stringIRI.equals(Blob.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.BLOB;
+ }
+ if (stringIRI.equals(Capability.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.CAPABILITY;
+ }
+ if (stringIRI.equals(ConceptDescription.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.CONCEPT_DESCRIPTION;
+ }
+ if (stringIRI.equals(DataElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.DATA_ELEMENT;
+ }
+ if (stringIRI.equals(Entity.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ENTITY;
+ }
+ if (stringIRI.equals(EventElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.EVENT_ELEMENT;
+ }
+ if (stringIRI.equals(File.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FILE;
+ }
+ if (stringIRI.equals(FragmentReference.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE;
+ }
+ if (stringIRI.equals(GlobalReference.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.GLOBAL_REFERENCE;
+ }
+ if (stringIRI.equals(Identifiable.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.IDENTIFIABLE;
+ }
+ if (stringIRI.equals(MultiLanguageProperty.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.MULTI_LANGUAGE_PROPERTY;
+ }
+ if (stringIRI.equals(Operation.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.OPERATION;
+ }
+ if (stringIRI.equals(Property.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.PROPERTY;
+ }
+ if (stringIRI.equals(Range.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.RANGE;
+ }
+ if (stringIRI.equals(ReferenceElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.REFERENCE_ELEMENT;
+ }
+ if (stringIRI.equals(RelationshipElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.RELATIONSHIP_ELEMENT;
+ }
+ if (stringIRI.equals(Submodel.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL;
+ }
+ if (stringIRI.equals(SubmodelElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT;
+ }
+ if (stringIRI.equals(SubmodelElementCollection.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT_COLLECTION;
+ }
+ if (stringIRI.equals(SubmodelElementList.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT_LIST;
+ }
+ throw new IllegalArgumentException("Invalid KeyTypes IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT.name())) {
+ return AnnotatedRelationshipElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.GLOBAL_REFERENCE.name())) {
+ return GlobalReference;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE.name())) {
+ return FragmentReference;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT.name())) {
+ return AnnotatedRelationshipElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ASSET_ADMINISTRATION_SHELL.name())) {
+ return AssetAdministrationShell;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.BASIC_EVENT_ELEMENT.name())) {
+ return BasicEventElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.BLOB.name())) {
+ return Blob;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.CAPABILITY.name())) {
+ return Capability;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.CONCEPT_DESCRIPTION.name())) {
+ return ConceptDescription;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.DATA_ELEMENT.name())) {
+ return DataElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ENTITY.name())) {
+ return Entity;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.EVENT_ELEMENT.name())) {
+ return EventElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FILE.name())) {
+ return File;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE.name())) {
+ return FragmentReference;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.GLOBAL_REFERENCE.name())) {
+ return GlobalReference;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.IDENTIFIABLE.name())) {
+ return Identifiable;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.MULTI_LANGUAGE_PROPERTY.name())) {
+ return MultiLanguageProperty;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.OPERATION.name())) {
+ return Operation;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.PROPERTY.name())) {
+ return Property;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.RANGE.name())) {
+ return Range;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.REFERENCE_ELEMENT.name())) {
+ return ReferenceElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.RELATIONSHIP_ELEMENT.name())) {
+ return RelationshipElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL.name())) {
+ return Submodel;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT.name())) {
+ return SubmodelElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT_COLLECTION.name())) {
+ return SubmodelElementCollection;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.SUBMODEL_ELEMENT_LIST.name())) {
+ return SubmodelElementList;
+ }
+
+ throw new IllegalArgumentException("Invalid KeyTypes provided.");
+ }
+ }
+
+ public static final class AasSubmodelElements {
+ public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/AnnotatedRelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource BasicEventElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/BasicEventElement");
+ public static final org.apache.jena.rdf.model.Resource Blob =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Blob");
+ public static final org.apache.jena.rdf.model.Resource Capability =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Capability");
+ public static final org.apache.jena.rdf.model.Resource DataElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/DataElement");
+ public static final org.apache.jena.rdf.model.Resource Entity =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Entity");
+ public static final org.apache.jena.rdf.model.Resource EventElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/EventElement");
+ public static final org.apache.jena.rdf.model.Resource File =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/File");
+ public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/MultiLanguageProperty");
+ public static final org.apache.jena.rdf.model.Resource Operation =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Operation");
+ public static final org.apache.jena.rdf.model.Resource Property =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Property");
+ public static final org.apache.jena.rdf.model.Resource Range =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/Range");
+ public static final org.apache.jena.rdf.model.Resource ReferenceElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/ReferenceElement");
+ public static final org.apache.jena.rdf.model.Resource RelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/RelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/SubmodelElement");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/SubmodelElementCollection");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementList =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AasSubmodelElements/SubmodelElementList");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements fromIRI(String stringIRI) {
+ if (stringIRI.equals(AnnotatedRelationshipElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT;
+ }
+ if (stringIRI.equals(BasicEventElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.BASIC_EVENT_ELEMENT;
+ }
+ if (stringIRI.equals(Blob.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.BLOB;
+ }
+ if (stringIRI.equals(Capability.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.CAPABILITY;
+ }
+ if (stringIRI.equals(DataElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.DATA_ELEMENT;
+ }
+ if (stringIRI.equals(Entity.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.ENTITY;
+ }
+ if (stringIRI.equals(EventElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.EVENT_ELEMENT;
+ }
+ if (stringIRI.equals(File.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.FILE;
+ }
+ if (stringIRI.equals(MultiLanguageProperty.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.MULTI_LANGUAGE_PROPERTY;
+ }
+ if (stringIRI.equals(Operation.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.OPERATION;
+ }
+ if (stringIRI.equals(Property.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.PROPERTY;
+ }
+ if (stringIRI.equals(Range.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.RANGE;
+ }
+ if (stringIRI.equals(ReferenceElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.REFERENCE_ELEMENT;
+ }
+ if (stringIRI.equals(RelationshipElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.RELATIONSHIP_ELEMENT;
+ }
+ if (stringIRI.equals(SubmodelElement.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT;
+ }
+ if (stringIRI.equals(SubmodelElementCollection.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION;
+ }
+ if (stringIRI.equals(SubmodelElementList.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT_LIST;
+ }
+ throw new IllegalArgumentException("Invalid AasSubmodelElements IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT.name())) {
+ return AnnotatedRelationshipElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.BASIC_EVENT_ELEMENT.name())) {
+ return BasicEventElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.BLOB.name())) {
+ return Blob;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.CAPABILITY.name())) {
+ return Capability;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.DATA_ELEMENT.name())) {
+ return DataElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.ENTITY.name())) {
+ return Entity;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.EVENT_ELEMENT.name())) {
+ return EventElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.FILE.name())) {
+ return File;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.MULTI_LANGUAGE_PROPERTY.name())) {
+ return MultiLanguageProperty;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.OPERATION.name())) {
+ return Operation;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.PROPERTY.name())) {
+ return Property;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.RANGE.name())) {
+ return Range;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.REFERENCE_ELEMENT.name())) {
+ return ReferenceElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.RELATIONSHIP_ELEMENT.name())) {
+ return RelationshipElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT.name())) {
+ return SubmodelElement;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION.name())) {
+ return SubmodelElementCollection;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements.SUBMODEL_ELEMENT_LIST.name())) {
+ return SubmodelElementList;
+ }
+ throw new IllegalArgumentException("Invalid AasSubmodelElements provided.");
+ }
+
+
+ }
+
+ public static final class ReferenceTypes {
+ public static final org.apache.jena.rdf.model.Resource ExternalReference =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference");
+ public static final org.apache.jena.rdf.model.Resource ModelReference =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ModelReference");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes fromIRI(String stringIRI) {
+ if (stringIRI.equals(ModelReference.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.MODEL_REFERENCE;
+ }
+ if (stringIRI.equals(ExternalReference.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE;
+ }
+ throw new IllegalArgumentException("Invalid ReferenceType IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE.name())) {
+ return ExternalReference;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.MODEL_REFERENCE.name())) {
+ return ModelReference;
+ }
+ throw new IllegalArgumentException("Invalid ReferenceType provided.");
+ }
+ }
+
+ public static final class Types {
+
+
+ public static final org.apache.jena.rdf.model.Resource Environment =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Environment");
+
+ public static final org.apache.jena.rdf.model.Resource AdministrativeInformation =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation");
+ public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AnnotatedRelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AssetAdministrationShell");
+ public static final org.apache.jena.rdf.model.Resource AssetInformation =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AssetInformation");
+ public static final org.apache.jena.rdf.model.Resource BasicEventElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "BasicEventElement");
+ public static final org.apache.jena.rdf.model.Resource Blob =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Blob");
+ public static final org.apache.jena.rdf.model.Resource Capability =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Capability");
+ public static final org.apache.jena.rdf.model.Resource ConceptDescription =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ConceptDescription");
+ public static final org.apache.jena.rdf.model.Resource DataSpecificationIec61360 =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataSpecificationIec61360");
+ public static final org.apache.jena.rdf.model.Resource EmbeddedDataSpecification =
+ ResourceFactory.createResource(AAS_NAMESPACE + "EmbeddedDataSpecification");
+ public static final org.apache.jena.rdf.model.Resource Entity =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Entity");
+ public static final org.apache.jena.rdf.model.Resource Extension =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Extension");
+ public static final org.apache.jena.rdf.model.Resource File =
+ ResourceFactory.createResource(AAS_NAMESPACE + "File");
+
+ public static final org.apache.jena.rdf.model.Resource Key =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Key");
+ public static final org.apache.jena.rdf.model.Resource LangStringDefinitionTypeIec61360 =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LangStringDefinitionTypeIec61360");
+ public static final org.apache.jena.rdf.model.Resource LangStringNameType =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LangStringNameType");
+ public static final org.apache.jena.rdf.model.Resource LangStringPreferredNameTypeIec61360 =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LangStringPreferredNameTypeIec61360");
+ public static final org.apache.jena.rdf.model.Resource LangStringShortNameTypeIec61360 =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LangStringShortNameTypeIec61360");
+ public static final org.apache.jena.rdf.model.Resource LangStringTextType =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LangStringTextType");
+ public static final org.apache.jena.rdf.model.Resource LevelType =
+ ResourceFactory.createResource(AAS_NAMESPACE + "LevelType");
+ public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty =
+ ResourceFactory.createResource(AAS_NAMESPACE + "MultiLanguageProperty");
+ public static final org.apache.jena.rdf.model.Resource Operation =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Operation");
+ public static final org.apache.jena.rdf.model.Resource OperationVariable =
+ ResourceFactory.createResource(AAS_NAMESPACE + "OperationVariable");
+ public static final org.apache.jena.rdf.model.Resource Property =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Property");
+ public static final org.apache.jena.rdf.model.Resource Qualifier =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Qualifier");
+ public static final org.apache.jena.rdf.model.Resource Range =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Range");
+ public static final org.apache.jena.rdf.model.Resource Reference =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Reference");
+ public static final org.apache.jena.rdf.model.Resource ReferenceElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceElement");
+ public static final org.apache.jena.rdf.model.Resource RelationshipElement =
+ ResourceFactory.createResource(AAS_NAMESPACE + "RelationshipElement");
+ public static final org.apache.jena.rdf.model.Resource Resource =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Resource");
+ public static final org.apache.jena.rdf.model.Resource SpecificAssetId =
+ ResourceFactory.createResource(AAS_NAMESPACE + "SpecificAssetId");
+ public static final org.apache.jena.rdf.model.Resource Submodel =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Submodel");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection =
+ ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementCollection");
+ public static final org.apache.jena.rdf.model.Resource SubmodelElementList =
+ ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementList");
+ public static final org.apache.jena.rdf.model.Resource ValueList =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ValueList");
+ public static final org.apache.jena.rdf.model.Resource ValueReferencePair =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair");
+
+ public static List SUBMODEL_ELEMENTS =
+ List.of(
+ AnnotatedRelationshipElement,
+ BasicEventElement,
+ Blob,
+ Capability,
+ Entity,
+ File,
+ MultiLanguageProperty,
+ Operation,
+ Property,
+ Range,
+ ReferenceElement,
+ RelationshipElement,
+ SubmodelElementCollection,
+ SubmodelElementList
+ );
+ }
+
+ public static final class LevelType {
+ public static final org.apache.jena.rdf.model.Property min = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/min");
+ public static final org.apache.jena.rdf.model.Property nom = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/nom");
+ public static final org.apache.jena.rdf.model.Property typ = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/typ");
+ public static final org.apache.jena.rdf.model.Property max = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/max");
+ }
+
+ public static final class AbstractLangString {
+ public static final org.apache.jena.rdf.model.Property language = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/language");
+ public static final org.apache.jena.rdf.model.Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text");
+ }
+
+ public static final class Extension {
+ public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/value");
+ public static final org.apache.jena.rdf.model.Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/valueType");
+ public static final org.apache.jena.rdf.model.Property refersTo = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/refersTo");
+ public static final org.apache.jena.rdf.model.Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/name");
+
+ }
+
+ public static final class ValueReferencePair {
+ public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value");
+ public static final org.apache.jena.rdf.model.Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId");
+ }
+
+ public static final class ValueList {
+ public static final org.apache.jena.rdf.model.Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs");
+ }
+
+ public static final class EmbeddedDataSpecification {
+ public static final org.apache.jena.rdf.model.Property dataSpecification =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification");
+ public static final org.apache.jena.rdf.model.Property dataSpecificationContent =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent");
+ }
+
+ public static final class HasDataSpecification {
+ public static final org.apache.jena.rdf.model.Property embeddedDataSpecifications =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications");
+ }
+
+ public static final class HasSemantics {
+ public static final org.apache.jena.rdf.model.Property semanticId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId");
+ public static final org.apache.jena.rdf.model.Property supplementalSemanticIds =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds");
+
+ }
+
+ public static final class Qualifiable {
+ public static final org.apache.jena.rdf.model.Property qualifiers =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifiable/qualifiers");
+
+ }
+
+ public static final class Qualifier {
+ public static final org.apache.jena.rdf.model.Property kind =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/kind");
+ public static final org.apache.jena.rdf.model.Property type =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/type");
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/value");
+ public static final org.apache.jena.rdf.model.Property valueId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueId");
+ public static final org.apache.jena.rdf.model.Property valueType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueType");
+
+
+ }
+
+ public static final class AdministrativeInformation {
+ public static final org.apache.jena.rdf.model.Property version =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version");
+ public static final org.apache.jena.rdf.model.Property revision =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/revision");
+ public static final org.apache.jena.rdf.model.Property creator =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator");
+ public static final org.apache.jena.rdf.model.Property templateId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId");
+ }
+
+ public static final class SpecificAssetId {
+ public static final org.apache.jena.rdf.model.Property externalSubjectId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/externalSubjectId");
+ public static final org.apache.jena.rdf.model.Property name =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/name");
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/value");
+ }
+
+ public static final class AnnotatedRelationshipElement {
+ public static final org.apache.jena.rdf.model.Property annotations =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AnnotatedRelationshipElement/annotations");
+ }
+
+ public static final class RelationshipElement {
+ public static final org.apache.jena.rdf.model.Property first =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "RelationshipElement/first");
+ public static final org.apache.jena.rdf.model.Property second =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "RelationshipElement/second");
+ }
+
+ public static final class Property {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Property/value");
+ public static final org.apache.jena.rdf.model.Property valueId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Property/valueId");
+ public static final org.apache.jena.rdf.model.Property valueType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Property/valueType");
+ }
+
+ public static final class MultiLanguageProperty {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "MultiLanguageProperty/value");
+ public static final org.apache.jena.rdf.model.Property valueId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "MultiLanguageProperty/valueId");
+ }
+
+ public static final class Submodel {
+ public static final org.apache.jena.rdf.model.Property submodelElements =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Submodel/submodelElements");
+ }
+
+ public static final class Range {
+ public static final org.apache.jena.rdf.model.Property max =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Range/max");
+ public static final org.apache.jena.rdf.model.Property min =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Range/min");
+ public static final org.apache.jena.rdf.model.Property valueType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Range/valueType");
+ }
+
+ public static final class ReferenceElement {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "ReferenceElement/value");
+ }
+
+ public static final class Entity {
+ public static final org.apache.jena.rdf.model.Property entityType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Entity/entityType");
+
+ public static final org.apache.jena.rdf.model.Property globalAssetId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Entity/globalAssetId");
+ public static final org.apache.jena.rdf.model.Property specificAssetIds =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Entity/specificAssetIds");
+ public static final org.apache.jena.rdf.model.Property statements =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Entity/statements");
+ }
+
+ public static final class OperationVariable {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "OperationVariable/value");
+ }
+
+ public static final class Environment {
+ public static final org.apache.jena.rdf.model.Property assetAdministrationShells =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Environment/assetAdministrationShells");
+ public static final org.apache.jena.rdf.model.Property conceptDescriptions =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Environment/conceptDescriptions");
+ public static final org.apache.jena.rdf.model.Property submodels =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Environment/submodels");
+ }
+
+ public static final class BasicEventElement {
+ public static final org.apache.jena.rdf.model.Property direction =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/direction");
+ public static final org.apache.jena.rdf.model.Property lastUpdate =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/lastUpdate");
+ public static final org.apache.jena.rdf.model.Property maxInterval =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/maxInterval");
+ public static final org.apache.jena.rdf.model.Property messageBroker =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/messageBroker");
+ public static final org.apache.jena.rdf.model.Property messageTopic =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/messageTopic");
+ public static final org.apache.jena.rdf.model.Property minInterval =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/minInterval");
+ public static final org.apache.jena.rdf.model.Property observed =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/observed");
+ public static final org.apache.jena.rdf.model.Property state =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "BasicEventElement/state");
+
+ }
+
+
+ public static final class Operation {
+ public static final org.apache.jena.rdf.model.Property inoutputVariables =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Operation/inoutputVariables");
+ public static final org.apache.jena.rdf.model.Property inputVariables =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Operation/inputVariables");
+ public static final org.apache.jena.rdf.model.Property outputVariables =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Operation/outputVariables");
+ }
+
+ public static final class File {
+ public static final org.apache.jena.rdf.model.Property contentType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "File/contentType");
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "File/value");
+ }
+
+ public static final class Blob {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value");
+ public static final org.apache.jena.rdf.model.Property contentType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/contentType");
+ }
+
+ public static final class SubmodelElementCollection {
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementCollection/value");
+
+ }
+
+ public static final class SubmodelElementList {
+ public static final org.apache.jena.rdf.model.Property orderRelevant =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementList/orderRelevant");
+ public static final org.apache.jena.rdf.model.Property semanticIdListElement =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementList/semanticIdListElement");
+ public static final org.apache.jena.rdf.model.Property typeValueListElement =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementList/typeValueListElement");
+ public static final org.apache.jena.rdf.model.Property value =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementList/value");
+ public static final org.apache.jena.rdf.model.Property valueTypeListElement =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "SubmodelElementList/valueTypeListElement");
+
+ }
+
+ public static final class AssetAdministrationShell {
+ public static final org.apache.jena.rdf.model.Property assetInformation =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation");
+ public static final org.apache.jena.rdf.model.Property derivedFrom =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/derivedFrom");
+ public static final org.apache.jena.rdf.model.Property submodels =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/submodels");
+ }
+
+ public static final class AssetInformation {
+ public static final org.apache.jena.rdf.model.Property assetType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetType");
+ public static final org.apache.jena.rdf.model.Property defaultThumbnail =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/defaultThumbnail");
+ public static final org.apache.jena.rdf.model.Property globalAssetId =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/globalAssetId");
+ public static final org.apache.jena.rdf.model.Property specificAssetIds =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/specificAssetIds");
+
+ public static final org.apache.jena.rdf.model.Property assetKind =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetKind");
+
+ }
+
+ public static final class Resource {
+ public static final org.apache.jena.rdf.model.Property contentType =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/contentType");
+ public static final org.apache.jena.rdf.model.Property path =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/path");
+ }
+
+ public static final class HasKind {
+ public static final org.apache.jena.rdf.model.Property kind =
+ ResourceFactory.createProperty(AAS_NAMESPACE + "HasKind/kind");
+ }
+
+
+ public static final class DataSpecificationIec61360 {
+ public static final org.apache.jena.rdf.model.Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType");
+ public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/value");
+ public static final org.apache.jena.rdf.model.Property valueFormat = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueFormat");
+ public static final org.apache.jena.rdf.model.Property definition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/definition");
+ public static final org.apache.jena.rdf.model.Property dataType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/dataType");
+ public static final org.apache.jena.rdf.model.Property symbol = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/symbol");
+ public static final org.apache.jena.rdf.model.Property sourceOfDefinition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/sourceOfDefinition");
+ public static final org.apache.jena.rdf.model.Property unitId = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unitId");
+ public static final org.apache.jena.rdf.model.Property unit = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unit");
+ public static final org.apache.jena.rdf.model.Property shortName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/shortName");
+ public static final org.apache.jena.rdf.model.Property preferredName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/preferredName");
+ public static final org.apache.jena.rdf.model.Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList");
+ }
+
+ public static final class ModellingKind {
+ public static final org.apache.jena.rdf.model.Resource Instance =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ModellingKind/Instance");
+ public static final org.apache.jena.rdf.model.Resource Template =
+ ResourceFactory.createResource(AAS_NAMESPACE + "ModellingKind/Template");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind fromIRI(String stringIRI) {
+ if (stringIRI.equals(Instance.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind.INSTANCE;
+ }
+ if (stringIRI.equals(Template.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind.TEMPLATE;
+ }
+ throw new IllegalArgumentException("Invalid ModellingKind IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind.INSTANCE.name())) {
+ return Instance;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind.TEMPLATE.name())) {
+ return Template;
+ }
+ throw new IllegalArgumentException("Invalid ModellingKind provided.");
+ }
+ }
+
+ public static final class AssetKind {
+ public static final org.apache.jena.rdf.model.Resource Instance =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AssetKind/Instance");
+ public static final org.apache.jena.rdf.model.Resource Type =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AssetKind/Type");
+ public static final org.apache.jena.rdf.model.Resource NotApplicable =
+ ResourceFactory.createResource(AAS_NAMESPACE + "AssetKind/NotApplicable");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.AssetKind fromIRI(String stringIRI) {
+ if (stringIRI.equals(Instance.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.INSTANCE;
+ }
+ if (stringIRI.equals(Type.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.TYPE;
+ }
+ if (stringIRI.equals(NotApplicable.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.NOT_APPLICABLE;
+ }
+ throw new IllegalArgumentException("Invalid AssetKind IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.INSTANCE.name())) {
+ return Instance;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.TYPE.name())) {
+ return Type;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.AssetKind.NOT_APPLICABLE.name())) {
+ return NotApplicable;
+ }
+
+ throw new IllegalArgumentException("Invalid AssetKind provided.");
+ }
+ }
+
+ public static final class EntityType {
+ public static final org.apache.jena.rdf.model.Resource CoManagedEntity =
+ ResourceFactory.createResource(AAS_NAMESPACE + "EntityType/CoManagedEntity");
+ public static final org.apache.jena.rdf.model.Resource SelfManagedEntity =
+ ResourceFactory.createResource(AAS_NAMESPACE + "EntityType/SelfManagedEntity");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.EntityType fromIRI(String stringIRI) {
+ if (stringIRI.equals(CoManagedEntity.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.EntityType.CO_MANAGED_ENTITY;
+ }
+ if (stringIRI.equals(SelfManagedEntity.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.EntityType.SELF_MANAGED_ENTITY;
+ }
+ throw new IllegalArgumentException("Invalid EntityType IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.EntityType.CO_MANAGED_ENTITY.name())) {
+ return CoManagedEntity;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.EntityType.SELF_MANAGED_ENTITY.name())) {
+ return SelfManagedEntity;
+ }
+
+ throw new IllegalArgumentException("Invalid EntityType provided.");
+ }
+ }
+
+ public static final class StateOfEvent {
+ public static final org.apache.jena.rdf.model.Resource Off =
+ ResourceFactory.createResource(AAS_NAMESPACE + "StateOfEvent/Off");
+ public static final org.apache.jena.rdf.model.Resource On =
+ ResourceFactory.createResource(AAS_NAMESPACE + "StateOfEvent/On");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent fromIRI(String stringIRI) {
+ if (stringIRI.equals(Off.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent.OFF;
+ }
+ if (stringIRI.equals(On.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent.ON;
+ }
+ throw new IllegalArgumentException("Invalid StateOfEvent IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent.OFF.name())) {
+ return Off;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent.ON.name())) {
+ return On;
+ }
+
+ throw new IllegalArgumentException("Invalid StateOfEvent provided.");
+ }
+ }
+
+ public static final class Direction {
+ public static final org.apache.jena.rdf.model.Resource Input =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Direction/Input");
+ public static final org.apache.jena.rdf.model.Resource Output =
+ ResourceFactory.createResource(AAS_NAMESPACE + "Direction/Output");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.Direction fromIRI(String stringIRI) {
+ if (stringIRI.equals(Input.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.Direction.INPUT;
+ }
+ if (stringIRI.equals(Output.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.Direction.OUTPUT;
+ }
+ throw new IllegalArgumentException("Invalid Direction IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.Direction.INPUT.name())) {
+ return Input;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.Direction.OUTPUT.name())) {
+ return Output;
+ }
+
+ throw new IllegalArgumentException("Invalid Direction provided.");
+ }
+ }
+
+
+ public static final class DataTypeIec61360 {
+ public static final org.apache.jena.rdf.model.Resource Blob =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Blob");
+ public static final org.apache.jena.rdf.model.Resource Boolean =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Boolean");
+ public static final org.apache.jena.rdf.model.Resource Date =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Date");
+ public static final org.apache.jena.rdf.model.Resource File =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/File");
+ public static final org.apache.jena.rdf.model.Resource Html =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Html");
+ public static final org.apache.jena.rdf.model.Resource IntegerCount =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCount");
+ public static final org.apache.jena.rdf.model.Resource IntegerCurrency =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCurrency");
+ public static final org.apache.jena.rdf.model.Resource IntegerMeasure =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerMeasure");
+ public static final org.apache.jena.rdf.model.Resource Irdi =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Irdi");
+ public static final org.apache.jena.rdf.model.Resource Iri =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Iri");
+ public static final org.apache.jena.rdf.model.Resource Rational =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Rational");
+ public static final org.apache.jena.rdf.model.Resource RationalMeasure =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RationalMeasure");
+ public static final org.apache.jena.rdf.model.Resource RealCount =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCount");
+ public static final org.apache.jena.rdf.model.Resource RealCurrency =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCurrency");
+ public static final org.apache.jena.rdf.model.Resource RealMeasure =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealMeasure");
+ public static final org.apache.jena.rdf.model.Resource String =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/String");
+ public static final org.apache.jena.rdf.model.Resource StringTranslatable =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/StringTranslatable");
+ public static final org.apache.jena.rdf.model.Resource Time =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Time");
+ public static final org.apache.jena.rdf.model.Resource Timestamp =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Timestamp");
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360 fromIRI(String stringIRI) {
+ if (stringIRI.equals(Blob.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.BLOB;
+ }
+ if (stringIRI.equals(Boolean.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.BOOLEAN;
+ }
+ if (stringIRI.equals(Date.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.DATE;
+ }
+ if (stringIRI.equals(File.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.FILE;
+ }
+ if (stringIRI.equals(Html.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.HTML;
+ }
+ if (stringIRI.equals(IntegerCount.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_COUNT;
+ }
+ if (stringIRI.equals(IntegerCurrency.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_CURRENCY;
+ }
+ if (stringIRI.equals(IntegerMeasure.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_MEASURE;
+ }
+ if (stringIRI.equals(Irdi.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.IRDI;
+ }
+ if (stringIRI.equals(Iri.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.IRI;
+ }
+ if (stringIRI.equals(Rational.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.RATIONAL;
+ }
+ if (stringIRI.equals(RationalMeasure.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.RATIONAL_MEASURE;
+ }
+ if (stringIRI.equals(RealCount.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_COUNT;
+ }
+ if (stringIRI.equals(RealCurrency.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_CURRENCY;
+ }
+ if (stringIRI.equals(RealMeasure.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_MEASURE;
+ }
+ if (stringIRI.equals(String.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.STRING;
+ }
+ if (stringIRI.equals(StringTranslatable.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.STRING_TRANSLATABLE;
+ }
+ if (stringIRI.equals(Time.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.TIME;
+ }
+ if (stringIRI.equals(Timestamp.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.TIMESTAMP;
+ }
+
+ throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.BLOB.name())) {
+ return Blob;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.BOOLEAN.name())) {
+ return Boolean;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.DATE.name())) {
+ return Date;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.FILE.name())) {
+ return File;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.HTML.name())) {
+ return Html;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_COUNT.name())) {
+ return IntegerCount;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_CURRENCY.name())) {
+ return IntegerCurrency;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.INTEGER_MEASURE.name())) {
+ return IntegerMeasure;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.IRDI.name())) {
+ return Irdi;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.IRI.name())) {
+ return Iri;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.RATIONAL.name())) {
+ return Rational;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.RATIONAL_MEASURE.name())) {
+ return RationalMeasure;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_COUNT.name())) {
+ return RealCount;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_CURRENCY.name())) {
+ return RealCurrency;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.REAL_MEASURE.name())) {
+ return RealMeasure;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.STRING.name())) {
+ return String;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.STRING_TRANSLATABLE.name())) {
+ return StringTranslatable;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.TIME.name())) {
+ return Time;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360.TIMESTAMP.name())) {
+ return Timestamp;
+ }
+
+ throw new IllegalArgumentException("Invalid DataTypeIec61360 provided.");
+ }
+ }
+
+ public static final class DataTypeDefXsd {
+ public static final org.apache.jena.rdf.model.Resource AnyUri =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/AnyUri");
+ public static final org.apache.jena.rdf.model.Resource Base64Binary =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Base64Binary");
+ public static final org.apache.jena.rdf.model.Resource Boolean =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Boolean");
+ public static final org.apache.jena.rdf.model.Resource Byte =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Byte");
+ public static final org.apache.jena.rdf.model.Resource Date =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Date");
+ public static final org.apache.jena.rdf.model.Resource DateTime =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/DateTime");
+ public static final org.apache.jena.rdf.model.Resource Decimal =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Decimal");
+ public static final org.apache.jena.rdf.model.Resource Double =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Double");
+ public static final org.apache.jena.rdf.model.Resource Duration =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Duration");
+ public static final org.apache.jena.rdf.model.Resource Float =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Float");
+ public static final org.apache.jena.rdf.model.Resource GDay =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GDay");
+ public static final org.apache.jena.rdf.model.Resource GMonth =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonth");
+ public static final org.apache.jena.rdf.model.Resource GMonthDay =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonthDay");
+ public static final org.apache.jena.rdf.model.Resource GYear =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYear");
+ public static final org.apache.jena.rdf.model.Resource GYearMonth =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYearMonth");
+ public static final org.apache.jena.rdf.model.Resource HexBinary =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/HexBinary");
+ public static final org.apache.jena.rdf.model.Resource Int =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Int");
+ public static final org.apache.jena.rdf.model.Resource Integer =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Integer");
+ public static final org.apache.jena.rdf.model.Resource Long =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Long");
+ public static final org.apache.jena.rdf.model.Resource NegativeInteger =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NegativeInteger");
+ public static final org.apache.jena.rdf.model.Resource NonNegativeInteger =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonNegativeInteger");
+ public static final org.apache.jena.rdf.model.Resource NonPositiveInteger =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonPositiveInteger");
+ public static final org.apache.jena.rdf.model.Resource PositiveInteger =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/PositiveInteger");
+ public static final org.apache.jena.rdf.model.Resource Short =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Short");
+ public static final org.apache.jena.rdf.model.Resource String =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/String");
+ public static final org.apache.jena.rdf.model.Resource Time =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Time");
+ public static final org.apache.jena.rdf.model.Resource UnsignedByte =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedByte");
+ public static final org.apache.jena.rdf.model.Resource UnsignedInt =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedInt");
+ public static final org.apache.jena.rdf.model.Resource UnsignedLong =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedLong");
+ public static final org.apache.jena.rdf.model.Resource UnsignedShort =
+ ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedShort");
+
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd fromIRI(String stringIRI) {
+ if (stringIRI.equals(AnyUri.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.ANY_URI;
+ }
+ if (stringIRI.equals(Base64Binary.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BASE64BINARY;
+ }
+ if (stringIRI.equals(Boolean.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BOOLEAN;
+ }
+ if (stringIRI.equals(Byte.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BYTE;
+ }
+ if (stringIRI.equals(Date.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DATE;
+ }
+ if (stringIRI.equals(DateTime.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DATE_TIME;
+ }
+ if (stringIRI.equals(Decimal.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DECIMAL;
+ }
+ if (stringIRI.equals(Double.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DOUBLE;
+ }
+ if (stringIRI.equals(Duration.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DURATION;
+ }
+ if (stringIRI.equals(Float.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.FLOAT;
+ }
+ if (stringIRI.equals(GDay.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GDAY;
+ }
+ if (stringIRI.equals(GMonth.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GMONTH;
+ }
+ if (stringIRI.equals(GMonthDay.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GMONTH_DAY;
+ }
+ if (stringIRI.equals(GYear.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GYEAR;
+ }
+ if (stringIRI.equals(GYearMonth.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GYEAR_MONTH;
+ }
+ if (stringIRI.equals(HexBinary.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.HEX_BINARY;
+ }
+ if (stringIRI.equals(Int.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.INT;
+ }
+ if (stringIRI.equals(Integer.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.INTEGER;
+ }
+ if (stringIRI.equals(Long.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.LONG;
+ }
+ if (stringIRI.equals(NegativeInteger.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.NEGATIVE_INTEGER;
+ }
+ if (stringIRI.equals(NonNegativeInteger.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.NON_NEGATIVE_INTEGER;
+ }
+ if (stringIRI.equals(NonPositiveInteger.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.NON_POSITIVE_INTEGER;
+ }
+ if (stringIRI.equals(PositiveInteger.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.POSITIVE_INTEGER;
+ }
+ if (stringIRI.equals(Short.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.SHORT;
+ }
+ if (stringIRI.equals(String.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.STRING;
+ }
+ if (stringIRI.equals(Time.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.TIME;
+ }
+ if (stringIRI.equals(UnsignedByte.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_BYTE;
+ }
+ if (stringIRI.equals(UnsignedInt.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_INT;
+ }
+ if (stringIRI.equals(UnsignedLong.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_LONG;
+ }
+ if (stringIRI.equals(UnsignedShort.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_SHORT;
+ }
+
+ throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.ANY_URI.name())) {
+ return AnyUri;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BASE64BINARY.name())) {
+ return Base64Binary;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BOOLEAN.name())) {
+ return Boolean;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.BYTE.name())) {
+ return Byte;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DATE.name())) {
+ return Date;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DATE_TIME.name())) {
+ return DateTime;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DECIMAL.name())) {
+ return Decimal;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DOUBLE.name())) {
+ return Double;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.DURATION.name())) {
+ return Duration;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.FLOAT.name())) {
+ return Float;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GDAY.name())) {
+ return GDay;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GMONTH.name())) {
+ return GMonth;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GMONTH_DAY.name())) {
+ return GMonthDay;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GYEAR.name())) {
+ return GYear;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.GYEAR_MONTH.name())) {
+ return GYearMonth;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.HEX_BINARY.name())) {
+ return HexBinary;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.INT.name())) {
+ return Int;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.INTEGER.name())) {
+ return Integer;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.LONG.name())) {
+ return Long;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.NEGATIVE_INTEGER.name())) {
+ return NegativeInteger;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.NON_NEGATIVE_INTEGER.name())) {
+ return NonNegativeInteger;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.SHORT.name())) {
+ return Short;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.STRING.name())) {
+ return String;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.TIME.name())) {
+ return Time;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_BYTE.name())) {
+ return UnsignedByte;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_INT.name())) {
+ return UnsignedInt;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_LONG.name())) {
+ return UnsignedLong;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd.UNSIGNED_SHORT.name())) {
+ return UnsignedShort;
+ }
+
+
+ throw new IllegalArgumentException("Invalid DataTypeIec61360 provided.");
+ }
+
+
+ }
+
+ public static final class QualifierKind {
+ public static final org.apache.jena.rdf.model.Resource ConceptQualifier =
+ ResourceFactory.createResource(AAS_NAMESPACE + "QualifierKind/ConceptQualifier");
+ public static final org.apache.jena.rdf.model.Resource TemplateQualifier =
+ ResourceFactory.createResource(AAS_NAMESPACE + "QualifierKind/TemplateQualifier");
+ public static final org.apache.jena.rdf.model.Resource ValueQualifier =
+ ResourceFactory.createResource(AAS_NAMESPACE + "QualifierKind/ValueQualifier");
+
+
+ public static org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind fromIRI(String stringIRI) {
+ if (stringIRI.equals(ConceptQualifier.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.CONCEPT_QUALIFIER;
+ }
+ if (stringIRI.equals(TemplateQualifier.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.TEMPLATE_QUALIFIER;
+ }
+ if (stringIRI.equals(ValueQualifier.getURI())) {
+ return org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.VALUE_QUALIFIER;
+ }
+
+
+ throw new IllegalArgumentException("Invalid QualifierKind IRI provided.");
+ }
+
+ public static org.apache.jena.rdf.model.Resource valueOf(String type) {
+
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.CONCEPT_QUALIFIER.name())) {
+ return ConceptQualifier;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.TEMPLATE_QUALIFIER.name())) {
+ return TemplateQualifier;
+ }
+ if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.QualifierKind.VALUE_QUALIFIER.name())) {
+ return ValueQualifier;
+ }
+
+ throw new IllegalArgumentException("Invalid QualifierKind provided.");
+ }
+ }
+
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java
new file mode 100644
index 000000000..3319a5dfc
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java
@@ -0,0 +1,30 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+
+public class DefaultRDFHandlerResult implements RDFSerializationResult {
+ private final Model model;
+ private final Resource resource;
+
+ public DefaultRDFHandlerResult(Model model, Resource resource) {
+ if (model == null) {
+ throw new IllegalArgumentException("Model can't be null");
+ }
+ if (resource == null) {
+ throw new IllegalArgumentException("Resource can't be null");
+ }
+ this.model = model;
+ this.resource = resource;
+ }
+
+ @Override
+ public Model getModel() {
+ return model;
+ }
+
+ @Override
+ public Resource getResource() {
+ return resource;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java
new file mode 100644
index 000000000..972cf9e14
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java
@@ -0,0 +1,11 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+public class IncompatibleTypeException extends Exception {
+ public IncompatibleTypeException() {
+ super("The RDF root node either has no type (rdf:type) or it does not match");
+ }
+
+ public IncompatibleTypeException(String message) {
+ super("The RDF root node does not match with " + message);
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java
new file mode 100644
index 000000000..3316efdb3
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java
@@ -0,0 +1,4 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+public class RDFDeserializer {
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java
new file mode 100644
index 000000000..0f6078a8b
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java
@@ -0,0 +1,32 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * RDFHandler provides functionality to convert
+ * an object to its RDF representation and vice versa
+ *
+ * @param The type of the object that the RDFHandler should support
+ */
+public interface RDFHandler {
+ /**
+ * Convert to RDF model. This method should be side effect free and idempotent.
+ *
+ * @param object the object that should be converted to an RDF model
+ * @return a {@link RDFSerializationResult} which holds the Model and created node that
+ * represent the created root node in the model.
+ */
+ RDFSerializationResult toModel(T object);
+
+ /**
+ * Converts an Apache Jena's Resource in an RDF graph to the desired object.
+ * This method should be side effect free and idempotent.
+ *
+ * @param model The graph model that holds information.
+ * @param subjectToParse Root element that correspond to the object.
+ * @return instance of the object
+ * @throws IncompatibleTypeException the rdf:type should match with the object type.
+ */
+ T fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException;
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java
new file mode 100644
index 000000000..a60634a2b
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java
@@ -0,0 +1,316 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.jena.rdf.model.Resource;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
+import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
+import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
+
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class RDFParser {
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+
+ /**
+ * Deserializes a given string into an instance of AssetAdministrationShellEnvironment
+ *
+ * @param value a string representation of the AssetAdministrationShellEnvironment
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(String value) throws DeserializationException {
+// try {
+// return mapper.readValue(value, Environment.class);
+// } catch (JsonProcessingException ex) {
+// throw new DeserializationException("error deserializing AssetAdministrationShellEnvironment", ex);
+// }
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given JSON node into an instance of AssetAdministrationShellEnvironment
+ *
+ * @param root root node of the document to parse
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(Resource root) throws DeserializationException {
+// try {
+// return mapper.treeToValue(root, Environment.class);
+// } catch (JsonProcessingException ex) {
+// throw new DeserializationException("error deserializing AssetAdministrationShellEnvironment", ex);
+// }
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given InputStream into an instance of AssetAdministrationShellEnvironment using DEFAULT_CHARSET
+ *
+ * @param src an InputStream containing the string representation of the AssetAdministrationShellEnvironment
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(InputStream src) throws DeserializationException {
+ return read(src, DEFAULT_CHARSET);
+ }
+
+ /**
+ * Deserializes a given InputStream into an instance of AssetAdministrationShellEnvironment using a given charset
+ *
+ * @param src An InputStream containing the string representation of the AssetAdministrationShellEnvironment
+ * @param charset the charset to use for deserialization
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(InputStream src, Charset charset) throws DeserializationException {
+ return read(new BufferedReader(
+ new InputStreamReader(src, charset))
+ .lines()
+ .collect(Collectors.joining(System.lineSeparator())));
+ }
+
+ /**
+ * Deserializes a given File into an instance of AssetAdministrationShellEnvironment using DEFAULT_CHARSET
+ *
+ * @param file A java.io.File containing the string representation of the AssetAdministrationShellEnvironment
+ * @param charset the charset to use for deserialization
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws FileNotFoundException if file is not present
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(java.io.File file, Charset charset)
+ throws FileNotFoundException, DeserializationException {
+ return read(new FileInputStream(file), charset);
+ }
+
+ /**
+ * Deserializes a given File into an instance of AssetAdministrationShellEnvironment using a given charset
+ *
+ * @param file a java.io.File containing the string representation of the AssetAdministrationShellEnvironment
+ * @return an instance of AssetAdministrationShellEnvironment
+ * @throws FileNotFoundException if the file is not present
+ * @throws DeserializationException if deserialization fails
+ */
+ public Environment read(java.io.File file) throws FileNotFoundException, DeserializationException {
+ return read(file, DEFAULT_CHARSET);
+ }
+
+
+ /**
+ * Enables usage of custom implementation to be used for deserialization instead of default implementation, e.g.
+ * defining a custom implementation of the Submodel interface {@code class
+ * CustomSubmodel implements Submodel {}} and calling
+ * {@code useImplementation(Submodel.class, CustomSubmodel.class);} will result in all instances of Submodel will be
+ * deserialized as CustomSubmodel. Subsequent class with the same aasInterface parameter will override the effects
+ * of all previous calls.
+ *
+ * @param the type of the interface to replace
+ * @param aasInterface the class of the interface to replace
+ * @param implementation the class implementing the interface that should be used for deserialization.
+ */
+ public void useImplementation(Class aasInterface, Class extends T> implementation) {
+// typeResolver.addMapping(aasInterface, implementation);
+// mapper = jsonMapperFactory.create(typeResolver);
+ }
+
+ /**
+ * Deserializes a given string into an instance of the given Referable
+ *
+ * @param src a string representation of the Referable
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public T readReferable(String src, Class outputClass) throws DeserializationException {
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET
+ *
+ * @param src a input stream representing a Referable
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public T readReferable(InputStream src, Class outputClass) throws DeserializationException {
+ return readReferable(src, DEFAULT_CHARSET, outputClass);
+ }
+
+ /**
+ * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET
+ *
+ * @param root Apache Jena Resource
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public T readReferable(JsonNode root, Class outputClass) throws DeserializationException {
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given input stream into an instance of the given Referable
+ *
+ * @param src a input stream representing a Referable
+ * @param charset the charset to use
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public T readReferable(InputStream src, Charset charset, Class outputClass) throws DeserializationException {
+ return readReferable(new BufferedReader(
+ new InputStreamReader(src, charset))
+ .lines()
+ .collect(Collectors.joining(System.lineSeparator())),
+ outputClass);
+ }
+
+ /**
+ * Deserializes a given file into an instance of the given Referable using DEFAULT_CHARSET
+ *
+ * @param src a file containing string representation of a Referable
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ * @throws java.io.FileNotFoundException if file is not found
+ */
+ public T readReferable(File src, Class outputClass) throws DeserializationException, FileNotFoundException {
+ return readReferable(src, DEFAULT_CHARSET, outputClass);
+ }
+
+ /**
+ * Deserializes a given file into an instance of the given Referable
+ *
+ * @param src a file containing string representation of a Referable
+ * @param charset the charset to use
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ * @throws java.io.FileNotFoundException if file is not found
+ */
+ public T readReferable(File src, Charset charset, Class outputClass) throws DeserializationException, FileNotFoundException {
+ return readReferable(new FileInputStream(src), charset, outputClass);
+ }
+
+ /**
+ * Deserializes a given string into an instance of a list of the given Referables
+ *
+ * @param referables a string representation of an array of Referables
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of a list of the referables
+ * @throws DeserializationException if deserialization of referable fails
+ */
+ public List readReferables(String referables, Class outputClass) throws DeserializationException {
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given string into an instance of a list of the given Referables
+ *
+ * @param root Apache Jena Resource
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of a list of the referables
+ * @throws DeserializationException if deserialization of referable fails
+ */
+ public List readReferables(Resource root, Class outputClass) throws DeserializationException {
+ try {
+ throw new RuntimeException("Not Implemented");
+ } catch (Exception ex) {
+ throw new DeserializationException("error deserializing list of Referable", ex);
+ }
+ }
+
+ /**
+ * Deserializes a given input stream into an instance of a list of the given Referable using DEFAULT_CHARSET
+ *
+ * @param src a input stream representing a Referable
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readReferables(InputStream src, Class outputClass) throws DeserializationException {
+ return readReferables(src, DEFAULT_CHARSET, outputClass);
+ }
+
+ /**
+ * Deserializes a given input stream into an instance of a list of the given Referable
+ *
+ * @param src a input stream representing a Referable
+ * @param charset the charset to use
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ */
+ public List readReferables(InputStream src, Charset charset, Class outputClass) throws DeserializationException {
+ return readReferables(new BufferedReader(
+ new InputStreamReader(src, charset))
+ .lines()
+ .collect(Collectors.joining(System.lineSeparator())),
+ outputClass);
+ }
+
+ /**
+ * Deserializes a given file into an instance of a list of the given Referable using DEFAULT_CHARSET
+ *
+ * @param src a file containing string representation of a Referable
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ * @throws java.io.FileNotFoundException if file is not found
+ */
+ public List readReferables(File src, Class outputClass) throws DeserializationException, FileNotFoundException {
+ return readReferables(src, DEFAULT_CHARSET, outputClass);
+ }
+
+ /**
+ * Deserializes a given file into an instance of a list of the given Referable
+ *
+ * @param src a file containing string representation of a Referable
+ * @param charset the charset to use
+ * @param outputClass most specific class of the given Referable
+ * @param type of the returned element
+ * @return an instance of the referable
+ * @throws DeserializationException if deserialization fails
+ * @throws java.io.FileNotFoundException if file is not found
+ */
+ public List readReferables(File src, Charset charset, Class outputClass) throws DeserializationException, FileNotFoundException {
+ return readReferables(new FileInputStream(src), charset, outputClass);
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java
new file mode 100644
index 000000000..981c59f85
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java
@@ -0,0 +1,11 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+
+public interface RDFPartialHandler {
+
+ void partialToModel(T object, Model model, Resource parentNode);
+
+ T partialFromModel(T object, Model model, Resource subjectToParse) throws IncompatibleTypeException;
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java
new file mode 100644
index 000000000..dc3f3d26d
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java
@@ -0,0 +1,54 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFLanguages;
+import org.apache.jena.shacl.ShaclValidator;
+import org.apache.jena.shacl.ValidationReport;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SchemaValidator;
+
+import java.io.StringReader;
+import java.util.Set;
+
+public class RDFSchemaValidator implements SchemaValidator {
+ @Override
+ public Set validateSchema(String serializedAASEntity) {
+ Model dataModel = ModelFactory.createDefaultModel();
+ dataModel.setNsPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ dataModel.setNsPrefix("xs","http://www.w3.org/2001/XMLSchema#");
+ dataModel.setNsPrefix("aas","https://admin-shell.io/aas/3/0/");
+ dataModel.setNsPrefix("owl","http://www.w3.org/2002/07/owl#");
+ dataModel.setNsPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ dataModel.setNsPrefix("rdfs","http://www.w3.org/2000/01/rdf-schema#");
+
+ try (StringReader reader = new StringReader(serializedAASEntity)) {
+ dataModel.read( reader, null, "TURTLE");
+ }
+ String shapeGraph = "src/main/resources/shacl-schema-original.ttl";
+ String aasGraph = "src/main/resources/rdf-ontology.ttl";
+
+ Model aasModel = RDFDataMgr.loadModel(aasGraph);
+
+ Model merged = ModelFactory.createDefaultModel();
+ merged.add(aasModel);
+ merged.add(dataModel);
+
+ // Load SHACL shapes from shapes.ttl
+ Model shapesModel = RDFDataMgr.loadModel(shapeGraph);
+
+ // Validate data against SHACL shapes
+ ValidationReport report = ShaclValidator.get().validate(shapesModel.getGraph(), merged.getGraph());
+
+ // Print validation report
+ if (report.conforms()) {
+ System.out.println("Validation successful! The data conforms to the SHACL shapes.");
+ } else {
+ System.out.println("Validation failed! The data does not conform to the SHACL shapes.");
+ System.out.println("Validation Report:\n");
+ report.getModel().write(System.out);
+ }
+ return null;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java
new file mode 100644
index 000000000..e2bb09145
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java
@@ -0,0 +1,24 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * RDF Serialization result
+ */
+public interface RDFSerializationResult {
+ /**
+ * Apache Jena {@link org.apache.jena.rdf.model.Model} that is the RDF graph
+ *
+ * @return the Graph model
+ */
+ Model getModel();
+
+ /**
+ * Corresponding node created in the graph as a starting point.
+ * Note that this is an Apache Jena's {@link org.apache.jena.rdf.model.Resource}
+ *
+ * @return created Resource in the graph
+ */
+ Resource getResource();
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java
new file mode 100644
index 000000000..ec7394591
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java
@@ -0,0 +1,196 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;
+
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFLanguages;
+
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEnvironmentRDFHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferableRDFHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
+import org.eclipse.digitaltwin.aas4j.v3.model.Referable;
+
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+public class RDFSerializer {
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+
+
+ /**
+ * Serializes a given instance of AssetAdministrationShellEnvironment to string
+ *
+ * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize
+ * @param serializationFormat the serialization format such as JSON-LD, RDF/Turtle, ...
+ * @return the string representation of the environment
+ * @throws SerializationException if serialization fails
+ */
+ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException {
+ try {
+ RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(aasEnvironment);
+ StringWriter stringWriter = new StringWriter();
+ rdfSerializationResult.getModel().write(stringWriter, Lang.TTL.getName());
+ return stringWriter.toString();
+ } catch (Exception ex) {
+ throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex);
+ }
+ }
+
+ /**
+ * Serializes a given instance of AssetAdministrationShellEnvironment to string
+ *
+ * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize
+ * @return the string representation of the environment
+ * @throws SerializationException if serialization fails
+ */
+ public String write(Environment aasEnvironment) throws SerializationException {
+ return write(aasEnvironment, RDFLanguages.TTL);
+ }
+
+ /**
+ * Serializes a given instance of a Referable to string
+ *
+ * @param referable the referable to serialize
+ * @param serializationFormat the serialization format such as JSON-LD, RDF/Turtle, ...
+ * @return the string representation of the referable
+ * @throws SerializationException if serialization fails
+ */
+ public String write(Referable referable, Lang serializationFormat) throws SerializationException {
+ try {
+ RDFSerializationResult rdfSerializationResult = new DefaultReferableRDFHandler().toModel(referable);
+ StringWriter stringWriter = new StringWriter();
+ rdfSerializationResult.getModel().write(stringWriter, serializationFormat.getName());
+ return stringWriter.toString();
+ } catch (Exception ex) {
+ throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex);
+ }
+ }
+
+ /**
+ * Serializes a given instance of a Referable to string
+ *
+ * @param referable the referable to serialize
+ * @return the string representation of the referable
+ * @throws SerializationException if serialization fails
+ */
+ public String write(Referable referable) throws SerializationException {
+ return write(referable, RDFLanguages.TTL);
+ }
+
+ /**
+ * Converts a given instance of AssetAdministrationShellEnvironment as RDF Model.
+ *
+ * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize
+ * @return the Jena Model
+ */
+ public RDFSerializationResult toModel(Environment aasEnvironment) {
+ RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(aasEnvironment);
+ return rdfSerializationResult;
+ }
+
+ /**
+ * Converts a given instance of a Referable to a JSON node.
+ *
+ * @param referable the referable to serialize
+ * @return the RDFSerializationResult contains the Apache Jena model as well as the corresponding created resource
+ */
+ public RDFSerializationResult toModel(Referable referable) {
+ RDFSerializationResult rdfSerializationResult = new DefaultReferableRDFHandler().toModel(referable);
+ return rdfSerializationResult;
+ }
+
+
+ /**
+ * Serializes a given instance of Environment to an OutputStream using DEFAULT_CHARSET
+ *
+ * @param out the Outputstream to serialize to
+ * @param aasEnvironment the Environment to serialize
+ * @throws IOException if writing to the stream fails
+ * @throws SerializationException if serialization fails
+ */
+ void write(OutputStream out, Environment aasEnvironment) throws IOException, SerializationException {
+ write(out, DEFAULT_CHARSET, aasEnvironment);
+ }
+
+ /**
+ * Serializes a given instance of Environment to an OutputStream using given charset
+ *
+ * @param out the Outputstream to serialize to
+ * @param charset the Charset to use for serialization
+ * @param aasEnvironment the Environment to serialize
+ * @throws IOException if writing to the stream fails
+ * @throws SerializationException if serialization fails
+ */
+ void write(OutputStream out, Charset charset, Environment aasEnvironment)
+ throws IOException, SerializationException {
+ try (OutputStreamWriter writer = new OutputStreamWriter(out, charset)) {
+ writer.write(write(aasEnvironment));
+ }
+ }
+
+ // Note that the AAS also defines a file class
+
+ /**
+ * Serializes a given instance of Environment to a java.io.File using DEFAULT_CHARSET
+ *
+ * @param file the java.io.File to serialize to
+ * @param charset the Charset to use for serialization
+ * @param aasEnvironment the Environment to serialize
+ * @throws FileNotFoundException if the fail does not exist
+ * @throws IOException if writing to the file fails
+ * @throws SerializationException if serialization fails
+ */
+ void write(java.io.File file, Charset charset, Environment aasEnvironment)
+ throws FileNotFoundException, IOException, SerializationException {
+ try (OutputStream out = new FileOutputStream(file)) {
+ write(out, charset, aasEnvironment);
+ }
+ }
+
+ /**
+ * Serializes a given instance of Environment to a java.io.File using given charset
+ *
+ * @param file the java.io.File to serialize to
+ * @param aasEnvironment the Environment to serialize
+ * @throws FileNotFoundException if the fail does not exist
+ * @throws IOException if writing to the file fails
+ * @throws SerializationException if serialization fails
+ */
+ void write(java.io.File file, Environment aasEnvironment)
+ throws FileNotFoundException, IOException, SerializationException {
+ write(file, DEFAULT_CHARSET, aasEnvironment);
+ }
+
+
+// /**
+// *
+// * @param referables the referables to serialize
+// * @return the string representation of the list of referables
+// * @throws SerializationException if serialization fails
+// */
+// public String write(Collection extends Referable> referables) throws SerializationException {
+// try {
+// throw new RuntimeException("Not Implemented");
+// } catch (Exception ex) {
+// throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex);
+// }
+// }
+
+// /**
+// *
+// * @param referables the referables to serialize
+// * @return the string representation of the list of referables
+// */
+// public Model toModel(Collection extends Referable> referables) {
+// throw new RuntimeException("Not Implemented");
+// }
+
+
+// public String writeReferables(List referables) throws SerializationException {
+// try {
+// throw new RuntimeException("Not Implemented");
+// } catch (Exception ex) {
+// throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex);
+// }
+// }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/doc.md b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/doc.md
new file mode 100644
index 000000000..a0ba78fd1
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/doc.md
@@ -0,0 +1,9 @@
+Why the Key interface should have any idea about its known subtype?
+
+The goal is to have the least possible side effect, so that's why i don't pass model (as much as i can).
+
+Thread-safety of partial handlers?
+
+Ordering of model merging?
+
+
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java
new file mode 100644
index 000000000..dc2a43b53
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java
@@ -0,0 +1,71 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAdministrativeInformation;
+
+public class DefaultAdministrativeInformationRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(AdministrativeInformation object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.AdministrativeInformation);
+ if (object.getVersion() != null) {
+ model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, model.createTypedLiteral(object.getVersion()));
+ }
+ if (object.getRevision() != null) {
+ model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, model.createTypedLiteral(object.getRevision()));
+ }
+ if (object.getTemplateId() != null) {
+ model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, model.createTypedLiteral(object.getTemplateId()));
+ }
+ if (object.getCreator() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator());
+ model.add(subject, AASNamespace.AdministrativeInformation.creator, res.getResource());
+ model.add(res.getModel());
+ }
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public AdministrativeInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation)) {
+ throw new IncompatibleTypeException("AdministrativeInformation");
+ }
+ DefaultAdministrativeInformation.Builder builder = new DefaultAdministrativeInformation.Builder();
+ if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.version)) {
+ builder.version(model.getProperty(subjectToParse,
+ AASNamespace.AdministrativeInformation.version).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.revision)) {
+ builder.revision(model.getProperty(subjectToParse,
+ AASNamespace.AdministrativeInformation.revision).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.templateId)) {
+ builder.templateId(model.getProperty(subjectToParse,
+ AASNamespace.AdministrativeInformation.templateId).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.creator)) {
+ Resource resource = model.getProperty(subjectToParse,
+ AASNamespace.AdministrativeInformation.creator).getResource();
+ Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.creator(reference);
+ }
+ DefaultAdministrativeInformation object = builder.build();
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java
new file mode 100644
index 000000000..a4b854983
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java
@@ -0,0 +1,114 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultQualifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement;
+import org.eclipse.digitaltwin.aas4j.v3.model.DataElement;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAnnotatedRelationshipElement;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultAnnotatedRelationshipElementRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.AnnotatedRelationshipElement);
+
+ if (object.getAnnotations() != null && object.getAnnotations().isEmpty() == false) {
+ int index = 0;
+ for (DataElement item : object.getAnnotations()) {
+ RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item);
+ resultItem.getResource().addLiteral(AASNamespace.index, index);
+ model.add(subject, AASNamespace.AnnotatedRelationshipElement.annotations, resultItem.getResource());
+ // It is important where to put model.add
+ model.add(resultItem.getModel());
+ index = index + 1;
+ }
+ }
+ //RelationshipElement
+ if (object.getFirst() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getFirst());
+ model.add(subject, AASNamespace.RelationshipElement.first, res.getResource());
+ model.add(res.getModel());
+ }
+ if (object.getSecond() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getSecond());
+ model.add(subject, AASNamespace.RelationshipElement.second, res.getResource());
+ model.add(res.getModel());
+ }
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialToModel(object, model, subject);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AnnotatedRelationshipElement)) {
+ throw new IncompatibleTypeException("AnnotatedRelationshipElement");
+ }
+ DefaultAnnotatedRelationshipElement.Builder builder = new DefaultAnnotatedRelationshipElement.Builder();
+
+ if (model.contains(subjectToParse, AASNamespace.AnnotatedRelationshipElement.annotations)) {
+ NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AnnotatedRelationshipElement.annotations);
+ Map keysMap = new HashMap<>();
+ nodeIterator.forEachRemaining(node -> {
+ DataElement key = null;
+ try {
+ //TODO: catch exception for cast or introduce new RDF handler
+ key = (DataElement) new DefaultSubmodelElementRDFHandler().fromModel(model, node.asResource());
+ } catch (IncompatibleTypeException e) {
+ throw new RuntimeException(e);
+ }
+ int index = model.getProperty(node.asResource(), AASNamespace.index).getInt();
+ keysMap.put(index, key);
+ });
+ if (keysMap.isEmpty() == false) {
+ List dataElements = new ArrayList<>();
+ for (int index = 0; index < keysMap.keySet().size(); index++) {
+ dataElements.add(keysMap.get(index));
+ }
+ builder.annotations(dataElements);
+ }
+ }
+ //RelationshipElement
+ if (model.contains(subjectToParse, AASNamespace.RelationshipElement.first)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.RelationshipElement.first).getResource();
+ Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.first(reference);
+ }
+ if (model.contains(subjectToParse, AASNamespace.RelationshipElement.second)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.RelationshipElement.second).getResource();
+ Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.second(reference);
+ }
+ AnnotatedRelationshipElement object = builder.build();
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java
new file mode 100644
index 000000000..425858d0f
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java
@@ -0,0 +1,100 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultIdentifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell;
+import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultAssetAdministrationShellRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(AssetAdministrationShell object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource(object.getId());
+ model.add(subject, RDF.type, AASNamespace.Types.AssetAdministrationShell);
+ if (object.getAssetInformation() != null) {
+ RDFSerializationResult res = new DefaultAssetInformationRDFHandler().toModel(object.getAssetInformation());
+ model.add(subject, AASNamespace.AssetAdministrationShell.assetInformation, res.getResource());
+ model.add(res.getModel());
+ }
+ if (object.getSubmodels() != null && !object.getSubmodels().isEmpty()) {
+ int index = 0;
+ for (Reference item : object.getSubmodels()) {
+ RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item);
+ resultItem.getResource().addLiteral(AASNamespace.index, index);
+ subject.addProperty(AASNamespace.AssetAdministrationShell.submodels, resultItem.getResource());
+ // It is important where to put model.add
+ model.add(resultItem.getModel());
+ index = index + 1;
+ }
+ }
+ if (object.getDerivedFrom() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getDerivedFrom());
+ model.add(subject, AASNamespace.AssetAdministrationShell.derivedFrom, res.getResource());
+ model.add(res.getModel());
+ }
+ //Identifiable
+ new DefaultIdentifiableRDFPartialHandler().partialToModel(object, model, subject);
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell)) {
+ throw new IncompatibleTypeException("AssetAdministrationShell");
+ }
+ DefaultAssetAdministrationShell.Builder builder = new DefaultAssetAdministrationShell.Builder();
+ if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.assetInformation)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetAdministrationShell.assetInformation).getResource();
+ AssetInformation assetInformation = new DefaultAssetInformationRDFHandler().fromModel(model, resource);
+ builder.assetInformation(assetInformation);
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.submodels)) {
+ NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetAdministrationShell.submodels);
+ Map keysMap = new HashMap<>();
+ nodeIterator.forEachRemaining(node -> {
+ Reference key = null;
+ try {
+ key = new DefaultReferenceRDFHandler().fromModel(model, node.asResource());
+ } catch (IncompatibleTypeException e) {
+ throw new RuntimeException(e);
+ }
+ int index = model.getProperty(node.asResource(), AASNamespace.index).getInt();
+ keysMap.put(index, key);
+ });
+ if (keysMap.isEmpty() == false) {
+ List references = new ArrayList<>();
+ for (int index = 0; index < keysMap.keySet().size(); index++) {
+ references.add(keysMap.get(index));
+ }
+ builder.submodels(references);
+ }
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom).getResource();
+ Reference derivedFrom = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.derivedFrom(derivedFrom);
+ }
+ AssetAdministrationShell object = builder.build();
+ //Identifiable
+ new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java
new file mode 100644
index 000000000..e9ee94179
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java
@@ -0,0 +1,103 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation;
+import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultAssetInformationRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(AssetInformation object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.AssetInformation);
+ if (object.getAssetKind() != null) {
+ model.add(subject, AASNamespace.AssetInformation.assetKind,
+ AASNamespace.AssetKind.valueOf(object.getAssetKind().name()));
+ }
+ if (object.getAssetType() != null) {
+ model.add(subject, AASNamespace.AssetInformation.assetType,
+ object.getAssetType());
+ }
+ if (object.getDefaultThumbnail() != null) {
+ RDFSerializationResult res = new DefaultResourceRDFHandler().toModel(object.getDefaultThumbnail());
+ model.add(subject, AASNamespace.AssetInformation.defaultThumbnail,
+ res.getResource());
+ model.add(res.getModel());
+ }
+ if (object.getGlobalAssetId() != null) {
+ model.add(subject, AASNamespace.AssetInformation.globalAssetId,
+ object.getGlobalAssetId());
+ }
+ if (object.getSpecificAssetIds() != null && !object.getSpecificAssetIds().isEmpty()) {
+ int index = 0;
+ for (SpecificAssetId item : object.getSpecificAssetIds()) {
+ RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item);
+ resultItem.getResource().addLiteral(AASNamespace.index, index);
+ model.add(subject, AASNamespace.AssetInformation.specificAssetIds, resultItem.getResource());
+ // It is important where to put model.add
+ model.add(resultItem.getModel());
+ index = index + 1;
+ }
+ }
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation)) {
+ throw new IncompatibleTypeException("AssetInformation");
+ }
+ DefaultAssetInformation.Builder builder = new DefaultAssetInformation.Builder();
+ if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetKind)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetInformation.assetKind).getResource();
+ builder.assetKind(AASNamespace.AssetKind.fromIRI(resource.getURI()));
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetType)) {
+ builder.assetType(model.getProperty(subjectToParse,
+ AASNamespace.AssetInformation.assetType).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetInformation.defaultThumbnail)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetInformation.defaultThumbnail).getResource();
+
+ org.eclipse.digitaltwin.aas4j.v3.model.Resource res = new DefaultResourceRDFHandler().fromModel(model, resource);
+ builder.defaultThumbnail(res);
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetInformation.globalAssetId)) {
+ builder.globalAssetId(model.getProperty(subjectToParse,
+ AASNamespace.AssetInformation.globalAssetId).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.AssetInformation.specificAssetIds)) {
+ NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetInformation.specificAssetIds);
+ Map keysMap = new HashMap<>();
+ nodeIterator.forEachRemaining(node -> {
+ SpecificAssetId key = null;
+ try {
+ key = new DefaultSpecificAssetIdRDFHandler().fromModel(model, node.asResource());
+ } catch (IncompatibleTypeException e) {
+ throw new RuntimeException(e);
+ }
+ int index = model.getProperty(node.asResource(), AASNamespace.index).getInt();
+ keysMap.put(index, key);
+ });
+ if (keysMap.isEmpty() == false) {
+ List specificAssetIds = new ArrayList<>();
+ for (int index = 0; index < keysMap.keySet().size(); index++) {
+ specificAssetIds.add(keysMap.get(index));
+ }
+ builder.specificAssetIds(specificAssetIds);
+ }
+ }
+ return builder.build();
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java
new file mode 100644
index 000000000..39b1cc5da
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java
@@ -0,0 +1,114 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultQualifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultBasicEventElement;
+
+public class DefaultBasicEventElementRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(BasicEventElement object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.BasicEventElement);
+ if (object.getDirection() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.direction,
+ AASNamespace.Direction.valueOf(object.getDirection().name()));
+ }
+ if (object.getLastUpdate() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.lastUpdate, object.getLastUpdate());
+ }
+ if (object.getMaxInterval() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.maxInterval, object.getMaxInterval());
+ }
+ if (object.getMinInterval() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.minInterval, object.getMinInterval());
+ }
+ if (object.getMessageTopic() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.messageTopic, object.getMessageTopic());
+ }
+ if (object.getMessageBroker() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getMessageBroker());
+ model.add(subject, AASNamespace.BasicEventElement.messageBroker, res.getResource());
+ model.add(res.getModel());
+ }
+ if (object.getState() != null) {
+ model.add(subject, AASNamespace.BasicEventElement.state,
+ AASNamespace.StateOfEvent.valueOf(object.getState().name()));
+ }
+ if (object.getObserved() != null) {
+ RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getObserved());
+ model.add(subject, AASNamespace.BasicEventElement.observed, res.getResource());
+ model.add(res.getModel());
+ }
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialToModel(object, model, subject);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public BasicEventElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.BasicEventElement)) {
+ throw new IncompatibleTypeException("Capability");
+ }
+ DefaultBasicEventElement.Builder builder = new DefaultBasicEventElement.Builder();
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.state)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.BasicEventElement.state).getResource();
+ builder.state(AASNamespace.StateOfEvent.fromIRI(resource.getURI()));
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.observed)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.BasicEventElement.observed).getResource();
+ Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.observed(reference);
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.messageBroker)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.BasicEventElement.messageBroker).getResource();
+ Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource);
+ builder.messageBroker(reference);
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.messageTopic)) {
+ builder.messageTopic(model.getProperty(subjectToParse, AASNamespace.BasicEventElement.messageTopic).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.direction)) {
+ Resource resource = model.getProperty(subjectToParse, AASNamespace.BasicEventElement.direction).getResource();
+ builder.direction(AASNamespace.Direction.fromIRI(resource.getURI()));
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.minInterval)) {
+ builder.minInterval(model.getProperty(subjectToParse, AASNamespace.BasicEventElement.minInterval).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.maxInterval)) {
+ builder.maxInterval(model.getProperty(subjectToParse, AASNamespace.BasicEventElement.maxInterval).getString());
+ }
+ if (model.contains(subjectToParse, AASNamespace.BasicEventElement.lastUpdate)) {
+ builder.lastUpdate(model.getProperty(subjectToParse, AASNamespace.BasicEventElement.lastUpdate).getString());
+ }
+ BasicEventElement object = builder.build();
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java
new file mode 100644
index 000000000..4dc157d6f
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java
@@ -0,0 +1,71 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultQualifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.Blob;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultBlob;
+
+import java.util.Base64;
+
+public class DefaultBlobRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(Blob object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.Blob);
+ if (object.getValue() != null) {
+ byte[] encoded = Base64.getEncoder().encode(object.getValue());
+ String contentBase64 = new String(encoded);//Convert the content of the file to base64
+ model.add(subject, AASNamespace.Blob.value, contentBase64, XSDDatatype.XSDbase64Binary);
+ }
+ if (object.getContentType() != null) {
+ model.add(subject, AASNamespace.Blob.contentType, object.getContentType());
+ }
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialToModel(object, model, subject);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public Blob fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Blob)) {
+ throw new IncompatibleTypeException("Blob");
+ }
+ DefaultBlob.Builder builder = new DefaultBlob.Builder();
+ if (model.contains(subjectToParse, AASNamespace.Blob.value)) {
+ String base64BinaryContent = model.getProperty(subjectToParse, AASNamespace.Blob.value).getString();
+ builder.value(Base64.getDecoder().decode(base64BinaryContent));
+ }
+ if (model.contains(subjectToParse, AASNamespace.Blob.contentType)) {
+ builder.contentType(model.getProperty(subjectToParse, AASNamespace.Blob.contentType).getString());
+ }
+ Blob object = builder.build();
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java
new file mode 100644
index 000000000..f9791b6ff
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java
@@ -0,0 +1,54 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultQualifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.Capability;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultCapability;
+
+public class DefaultCapabilityRDFHandler implements RDFHandler {
+ @Override
+ public RDFSerializationResult toModel(Capability object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource subject = model.createResource();
+ model.add(subject, RDF.type, AASNamespace.Types.Capability);
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialToModel(object, model, subject);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialToModel(object, model, subject);
+ return new DefaultRDFHandlerResult(model, subject);
+ }
+
+ @Override
+ public Capability fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Capability)) {
+ throw new IncompatibleTypeException("Capability");
+ }
+ DefaultCapability.Builder builder = new DefaultCapability.Builder();
+
+ Capability object = builder.build();
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //HasSemantics
+ new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Qualifiable
+ new DefaultQualifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ //Referable
+ new DefaultReferableRDFPartialHandler().partialFromModel(object, model, subjectToParse);
+ return object;
+ }
+}
diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java
new file mode 100644
index 000000000..feac5988b
--- /dev/null
+++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java
@@ -0,0 +1,83 @@
+package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;
+
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.vocabulary.RDF;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasDataSpecificationRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultIdentifiableRDFPartialHandler;
+import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription;
+import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
+import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultConceptDescriptionRDFHandler implements RDFHandler {
+
+ @Override
+ public RDFSerializationResult toModel(ConceptDescription object) {
+ Model model = ModelFactory.createDefaultModel();
+ if (object == null) {
+ return new DefaultRDFHandlerResult(model, ResourceFactory.createResource());
+ }
+ Resource conceptDescriptionResource = model.createResource(object.getId());
+ model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription);
+
+ if (object.getIsCaseOf() != null && !object.getIsCaseOf().isEmpty()) {
+ int index = 0;
+ for (Reference item : object.getIsCaseOf()) {
+ RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item);
+ resultItem.getResource().addLiteral(AASNamespace.index, index);
+ model.add(conceptDescriptionResource, AASNamespace.ConceptDescription.isCaseOf, resultItem.getResource());
+ // It is important where to put model.add
+ model.add(resultItem.getModel());
+ index = index + 1;
+ }
+ }
+
+
+ //Identifiable
+ new DefaultIdentifiableRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource);
+ //HasDataSpecification
+ new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource);
+ return new DefaultRDFHandlerResult(model, conceptDescriptionResource);
+ }
+
+ @Override
+ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException {
+ if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription)) {
+ throw new IncompatibleTypeException();
+ }
+ DefaultConceptDescription.Builder builder = new DefaultConceptDescription.Builder();
+
+ if (model.contains(subjectToParse, AASNamespace.ConceptDescription.isCaseOf)) {
+ NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf);
+ Map keysMap = new HashMap<>();
+ nodeIterator.forEachRemaining(node -> {
+ Reference key = null;
+ try {
+ key = new DefaultReferenceRDFHandler().fromModel(model, node.asResource());
+ } catch (IncompatibleTypeException e) {
+ throw new RuntimeException(e);
+ }
+ int index = model.getProperty(node.asResource(), AASNamespace.index).getInt();
+ keysMap.put(index, key);
+ });
+ if (keysMap.isEmpty() == false) {
+ List