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 implementationType; - - protected ImplementationInfo(Class interfaceType, Class implementationType) { - this.interfaceType = interfaceType; - this.implementationType = implementationType; - } - - public Class getInterfaceType() { - return interfaceType; - } - - public Class 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 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 implementationType; + + protected ImplementationInfo(Class interfaceType, Class implementationType) { + this.interfaceType = interfaceType; + this.implementationType = implementationType; + } + + public Class getInterfaceType() { + return interfaceType; + } + + public Class 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 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 referenceType, Class 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 referenceType, Class 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 referenceType, Class 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 referenceType, Class 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 referenceType, + Class 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 referenceType, Class 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 referenceType, + Class 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 referenceType, Class 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 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 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 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 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 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 references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.isCaseOf(references); + } + } + ConceptDescription 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/DefaultDataSpecificationContentRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java new file mode 100644 index 000000000..8d3b497e8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java @@ -0,0 +1,37 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; + +public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationContent object) { + if (object instanceof DataSpecificationIec61360) { + return new DefaultDataSpecificationIEC61360RDFHandler().toModel((DataSpecificationIec61360) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known DataSpecificationContent"); + } + + @Override + public DataSpecificationContent fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + Statement typeStatement = model.getProperty(subjectToParse, RDF.type); + if (typeStatement.getResource().equals(AASNamespace.Types.DataSpecificationIec61360)) { + return new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, subjectToParse); + } + //Other data specification content should be discriminated here. + throw new IllegalArgumentException("Provided Resource " + + typeStatement.getResource().getURI() + + " is not a known DataSpecificationContent"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java new file mode 100644 index 000000000..5058e05e9 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java @@ -0,0 +1,202 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Resource; +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.dataspecificationiec61360.*; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultDataSpecificationIEC61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationIec61360 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.DataSpecificationIec61360); + if (object.getPreferredName() != null && !object.getPreferredName().isEmpty()) { + int index = 0; + for (LangStringPreferredNameTypeIec61360 langString : object.getPreferredName()) { + RDFSerializationResult res = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().toModel(langString); + model.add(subject, AASNamespace.DataSpecificationIec61360.preferredName, res.getResource()); + model.addLiteral(res.getResource(), AASNamespace.index, index); + model.add(res.getModel()); + index++; + } + } + if (object.getShortName() != null && !object.getShortName().isEmpty()) { + int index = 0; + for (LangStringShortNameTypeIec61360 langString : object.getShortName()) { + RDFSerializationResult res = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(langString); + model.add(subject, AASNamespace.DataSpecificationIec61360.shortName, res.getResource()); + model.addLiteral(res.getResource(), AASNamespace.index, index); + model.add(res.getModel()); + index++; + } + } + if (object.getDefinition() != null && !object.getDefinition().isEmpty()) { + int index = 0; + for (LangStringDefinitionTypeIec61360 langString : object.getDefinition()) { + RDFSerializationResult res = new DefaultLangStringDefinitionTypeIec61360RDFHandler().toModel(langString); + model.add(subject, AASNamespace.DataSpecificationIec61360.definition, res.getResource()); + model.addLiteral(res.getResource(), AASNamespace.index, index); + model.add(res.getModel()); + index++; + } + } + if (object.getUnit() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.unit, object.getUnit()); + } + if (object.getUnitId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getUnitId()); + model.add(subject, AASNamespace.DataSpecificationIec61360.unitId, res.getResource()); + model.add(res.getModel()); + } + if (object.getSourceOfDefinition() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.sourceOfDefinition, object.getSourceOfDefinition()); + } + if (object.getSymbol() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.symbol, object.getSymbol()); + } + if (object.getDataType() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.dataType, AASNamespace.DataTypeIec61360.valueOf(object.getDataType().name())); + } + if (object.getValueFormat() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.valueFormat, object.getValueFormat()); + } + if (object.getValue() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.value, object.getValue()); + } + if (object.getValueList() != null) { + RDFSerializationResult res = new DefaultValueListRDFHandler().toModel(object.getValueList()); + model.add(subject, AASNamespace.DataSpecificationIec61360.valueList, res.getResource()); + model.add(res.getModel()); + } + if (object.getLevelType() != null) { + RDFSerializationResult res = new DefaultLevelTypeRDFHandler().toModel(object.getLevelType()); + model.add(subject, AASNamespace.DataSpecificationIec61360.levelType, res.getResource()); + model.add(res.getModel()); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360)) { + throw new IncompatibleTypeException("DataSpecificationIec61360"); + } + DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); + + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.preferredName)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.preferredName); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringPreferredNameTypeIec61360 key = null; + try { + key = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().fromModel(model, node.asResource()); + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + + }); + if (keysMap.isEmpty() == false) { + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.preferredName(langStringList); + } + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringShortNameTypeIec61360 key = null; + try { + key = new DefaultLangStringShortNameTypeIec61360RDFHandler().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 langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.shortName(langStringList); + } + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.definition)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.definition); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringDefinitionTypeIec61360 key = null; + try { + key = new DefaultLangStringDefinitionTypeIec61360RDFHandler().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 langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.definition(langStringList); + } + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unit)) { + builder.unit(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unit).getString()); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unitId)) { + Reference reference = new DefaultReferenceRDFHandler() + .fromModel(model, + model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unitId) + .getResource()); + builder.unitId(reference); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition)) { + builder.sourceOfDefinition(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition).getString()); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol)) { + builder.symbol(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol).getString()); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.dataType)) { + DataTypeIec61360 type = AASNamespace.DataTypeIec61360.fromIRI(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.dataType).getResource().getURI()); + builder.dataType(type); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.valueFormat)) { + builder.valueFormat(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.valueFormat).getString()); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.valueList)) { + ValueList valueList = new DefaultValueListRDFHandler().fromModel( + model, + model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.valueList).getResource() + ); + builder.valueList(valueList); + } + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType)) { + LevelType levelType = new DefaultLevelTypeRDFHandler() + .fromModel(model, model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType).getResource()); + builder.levelType(levelType); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java new file mode 100644 index 000000000..010d71f1e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java @@ -0,0 +1,59 @@ +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.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; + +public class DefaultEmbeddedDataSpecificationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(EmbeddedDataSpecification 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.EmbeddedDataSpecification); + if (object.getDataSpecification() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getDataSpecification()); + model.add(subject, AASNamespace.EmbeddedDataSpecification.dataSpecification, res.getResource()); + model.add(res.getModel()); + } + if (object.getDataSpecificationContent() != null) { + RDFSerializationResult res = + new DefaultDataSpecificationContentRDFHandler().toModel(object.getDataSpecificationContent()); + model.add(subject, AASNamespace.EmbeddedDataSpecification.dataSpecificationContent, res.getResource()); + model.add(res.getModel()); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public EmbeddedDataSpecification fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification)) { + throw new IncompatibleTypeException("EmbeddedDataSpecification"); + } + DefaultEmbeddedDataSpecification.Builder builder = new DefaultEmbeddedDataSpecification.Builder(); + if (model.contains(subjectToParse, AASNamespace.EmbeddedDataSpecification.dataSpecification)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.EmbeddedDataSpecification.dataSpecification).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.dataSpecification(reference); + } + if (model.contains(subjectToParse, AASNamespace.EmbeddedDataSpecification.dataSpecificationContent)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.EmbeddedDataSpecification.dataSpecificationContent).getResource(); + + DataSpecificationContent dataSpecificationContent = + new DefaultDataSpecificationContentRDFHandler().fromModel(model, resource); + builder.dataSpecificationContent(dataSpecificationContent); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java new file mode 100644 index 000000000..850426423 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java @@ -0,0 +1,134 @@ +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.Entity; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEntity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultEntityRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Entity 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.Entity); + if (object.getEntityType() != null) { + model.add(subject, AASNamespace.Entity.entityType, AASNamespace.EntityType.valueOf(object.getEntityType().name())); + } + if (object.getStatements() != null) { + int index = 0; + for (SubmodelElement item : object.getStatements()) { + RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.Entity.statements, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + if (object.getGlobalAssetId() != null) { + model.add(subject, AASNamespace.Entity.globalAssetId, object.getGlobalAssetId()); + } + if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { + int index = 0; + for (SpecificAssetId item : object.getSpecificAssetIds()) { + RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.Entity.specificAssetIds, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //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 Entity fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Entity)) { + throw new IncompatibleTypeException("Entity"); + } + DefaultEntity.Builder builder = new DefaultEntity.Builder(); + if (model.contains(subjectToParse, AASNamespace.Entity.statements)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Entity.statements); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + SubmodelElement key = null; + try { + key = new DefaultSubmodelElementRDFHandler().fromModel(model, node.asResource()); + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + if (keysMap.isEmpty() == false) { + List submodelElements = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + submodelElements.add(keysMap.get(index)); + } + builder.statements(submodelElements); + } + } + if (model.contains(subjectToParse, AASNamespace.Entity.globalAssetId)) { + builder.globalAssetId(model.getProperty(subjectToParse, AASNamespace.Entity.globalAssetId).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Entity.entityType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Entity.entityType).getResource(); + builder.entityType(AASNamespace.EntityType.fromIRI(resource.getURI())); + } + if (model.contains(subjectToParse, AASNamespace.Entity.specificAssetIds)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Entity.specificAssetIds); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + SpecificAssetId key = null; + try { + key = new DefaultSpecificAssetIdRDFHandler().fromModel(model, node.asResource()); + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + 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); + } + } + Entity 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/DefaultEnvironmentRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEnvironmentRDFHandler.java new file mode 100644 index 000000000..e2c25b077 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEnvironmentRDFHandler.java @@ -0,0 +1,97 @@ +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.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; + +import java.util.LinkedList; +import java.util.List; + +public class DefaultEnvironmentRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Environment 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.Environment); + if (object.getAssetAdministrationShells() != null && object.getAssetAdministrationShells().isEmpty() == false) { + for (AssetAdministrationShell shell : object.getAssetAdministrationShells()) { + RDFSerializationResult res = new DefaultAssetAdministrationShellRDFHandler().toModel(shell); + model.add(subject, AASNamespace.Environment.assetAdministrationShells, res.getResource()); + model.add(res.getModel()); + } + } + if (object.getSubmodels() != null && object.getSubmodels().isEmpty() == false) { + for (Submodel submodel : object.getSubmodels()) { + RDFSerializationResult res = new DefaultSubmodelRDFHandler().toModel(submodel); + model.add(subject, AASNamespace.Environment.submodels, res.getResource()); + model.add(res.getModel()); + } + } + if (object.getConceptDescriptions() != null && object.getConceptDescriptions().isEmpty() == false) { + for (ConceptDescription submodel : object.getConceptDescriptions()) { + RDFSerializationResult res = new DefaultConceptDescriptionRDFHandler().toModel(submodel); + model.add(subject, AASNamespace.Environment.conceptDescriptions, res.getResource()); + model.add(res.getModel()); + } + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Environment fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Environment)) { + throw new IncompatibleTypeException("Environment"); + } + DefaultEnvironment.Builder builder = new DefaultEnvironment.Builder(); + + Environment object = builder.build(); + if (model.contains(subjectToParse, AASNamespace.Environment.assetAdministrationShells)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Environment.assetAdministrationShells); + List submodelElements = new LinkedList<>(); + nodeIterator.forEachRemaining(node -> { + try { + AssetAdministrationShell key = new DefaultAssetAdministrationShellRDFHandler().fromModel(model, node.asResource()); + submodelElements.add(key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + builder.assetAdministrationShells(submodelElements); + } + if (model.contains(subjectToParse, AASNamespace.Environment.submodels)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Environment.submodels); + List submodels = new LinkedList<>(); + nodeIterator.forEachRemaining(node -> { + try { + Submodel key = new DefaultSubmodelRDFHandler().fromModel(model, node.asResource()); + submodels.add(key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + builder.submodels(submodels); + } + if (model.contains(subjectToParse, AASNamespace.Environment.conceptDescriptions)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Environment.conceptDescriptions); + List conceptDescriptions = new LinkedList<>(); + nodeIterator.forEachRemaining(node -> { + try { + ConceptDescription key = new DefaultConceptDescriptionRDFHandler().fromModel(model, node.asResource()); + conceptDescriptions.add(key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + builder.conceptDescriptions(conceptDescriptions); + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java new file mode 100644 index 000000000..c48f84a3d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java @@ -0,0 +1,92 @@ +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.DefaultHasSemanticsRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultExtensionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Extension 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.Extension); + if (object.getName() != null) { + model.addLiteral(subject, AASNamespace.Extension.name, model.createTypedLiteral(object.getName())); + } + if (object.getValue() != null) { + model.addLiteral(subject, AASNamespace.Extension.value, model.createTypedLiteral(object.getValue())); + } + if (object.getValueType() != null) { + model.add(subject, AASNamespace.Extension.valueType, + AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); + } + if (object.getRefersTo() != null && !object.getRefersTo().isEmpty()) { + int index = 0; + for (Reference reference : object.getRefersTo()) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(reference); + model.add(subject, AASNamespace.Extension.refersTo, res.getResource()); + model.addLiteral(res.getResource(), AASNamespace.index, index); + model.add(res.getModel()); + index++; + } + } + //HasSemantics + new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Extension fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension)) { + throw new IncompatibleTypeException("Extension"); + } + DefaultExtension.Builder builder = new DefaultExtension.Builder(); + if (model.contains(subjectToParse, AASNamespace.Extension.name)) { + builder.name(model.getProperty(subjectToParse, AASNamespace.Extension.name).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Extension.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.Extension.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Extension.valueType)) { + String valueType = model.getProperty(subjectToParse, AASNamespace.Extension.valueType).getResource().getURI(); + builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(valueType)); + } + if (model.contains(subjectToParse, AASNamespace.Extension.refersTo)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Extension.refersTo); + 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.refersTo(references); + } + } + //HasSemantics + Extension object = builder.build(); + new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java new file mode 100644 index 000000000..e1343dfaa --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java @@ -0,0 +1,66 @@ +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.File; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultFile; + +public class DefaultFileRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(File 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.File); + if (object.getValue() != null) { + model.add(subject, AASNamespace.File.value, object.getValue()); + } + if (object.getContentType() != null) { + model.add(subject, AASNamespace.File.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 File fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.File)) { + throw new IncompatibleTypeException("File"); + } + DefaultFile.Builder builder = new DefaultFile.Builder(); + + if (model.contains(subjectToParse, AASNamespace.File.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.File.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.File.contentType)) { + builder.contentType(model.getProperty(subjectToParse, AASNamespace.File.contentType).getString()); + } + File 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/DefaultKeyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java new file mode 100644 index 000000000..d7c30d72c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java @@ -0,0 +1,46 @@ +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.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; + +public class DefaultKeyRDFHandler implements RDFHandler { + public RDFSerializationResult toModel(Key key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + subject.addProperty(RDF.type, AASNamespace.Types.Key); + if (key.getValue() != null) { + subject.addProperty(AASNamespace.Key.value, key.getValue()); + } + if (key.getType() != null) { + subject.addProperty(AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(key.getType().name())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + public Key fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key)) { + throw new IncompatibleTypeException("Key"); + } + DefaultKey.Builder builder = new DefaultKey.Builder(); + if (model.contains(subjectToParse, AASNamespace.Key.value)) { + String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); + builder.value(value); + } + if (model.contains(subjectToParse, AASNamespace.Key.type)) { + KeyTypes type = AASNamespace.KeyTypes.fromIRI(model.getProperty(subjectToParse, AASNamespace.Key.type).getResource().getURI()); + builder.type(type); + } + //Todo: in future instead of specific builder we can use a generic builder instantiator + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java new file mode 100644 index 000000000..f1b841edc --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java @@ -0,0 +1,45 @@ +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.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; + +public class DefaultLangStringNameTypeRDFHandler implements RDFHandler { + + @Override + public RDFSerializationResult toModel(LangStringNameType 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.LangStringNameType); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType)) { + throw new IncompatibleTypeException("LangStringNameType"); + } + DefaultLangStringNameType.Builder builder = new DefaultLangStringNameType.Builder(); + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { + builder.text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()); + } + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.language)) { + builder.language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java new file mode 100644 index 000000000..ea847cc72 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java @@ -0,0 +1,44 @@ +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.model.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringTextType; + +public class DefaultLangStringTextTypeRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(LangStringTextType 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.LangStringTextType); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType)) { + throw new IncompatibleTypeException("LangStringTextType"); + } + DefaultLangStringTextType.Builder builder = new DefaultLangStringTextType.Builder(); + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { + builder.text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()); + } + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.language)) { + builder.language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java new file mode 100644 index 000000000..b9d8fe0e0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java @@ -0,0 +1,97 @@ +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.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.MultiLanguageProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultMultiLanguageProperty; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultMultiLanguagePropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(MultiLanguageProperty 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.MultiLanguageProperty); + if (object.getValue() != null && object.getValue().isEmpty() == false) { + int index = 0; + for (LangStringTextType langString : object.getValue()) { + RDFSerializationResult res = new DefaultLangStringTextTypeRDFHandler().toModel(langString); + model.add(subject, AASNamespace.MultiLanguageProperty.value, res.getResource()); + model.addLiteral(res.getResource(), AASNamespace.index, index); + model.add(res.getModel()); + index++; + } + } + if (object.getValueId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(subject, AASNamespace.MultiLanguageProperty.valueId, 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 MultiLanguageProperty fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.MultiLanguageProperty)) { + throw new IncompatibleTypeException("MultiLanguageProperty"); + } + DefaultMultiLanguageProperty.Builder builder = new DefaultMultiLanguageProperty.Builder(); + + if (model.contains(subjectToParse, AASNamespace.MultiLanguageProperty.value)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.MultiLanguageProperty.value); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringTextType key = null; + try { + key = new DefaultLangStringTextTypeRDFHandler().fromModel(model, node.asResource()); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.value(langStringList); + } + if (model.contains(subjectToParse, AASNamespace.MultiLanguageProperty.valueId)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.MultiLanguageProperty.valueId).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.valueId(reference); + } + MultiLanguageProperty 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/DefaultOperationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java new file mode 100644 index 000000000..6422502dc --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java @@ -0,0 +1,152 @@ +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.Operation; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultOperationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Operation 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.Operation); + if (object.getInoutputVariables() != null && object.getInoutputVariables().isEmpty() == false) { + int index = 0; + for (OperationVariable item : object.getInoutputVariables()) { + RDFSerializationResult resultItem = new DefaultOperationVariableRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.Operation.inoutputVariables, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + if (object.getInputVariables() != null && object.getInputVariables().isEmpty() == false) { + int index = 0; + for (OperationVariable item : object.getInputVariables()) { + RDFSerializationResult resultItem = new DefaultOperationVariableRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.Operation.inputVariables, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + if (object.getOutputVariables() != null && object.getOutputVariables().isEmpty() == false) { + int index = 0; + for (OperationVariable item : object.getOutputVariables()) { + RDFSerializationResult resultItem = new DefaultOperationVariableRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.Operation.outputVariables, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //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 Operation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Operation)) { + throw new IncompatibleTypeException("Operation"); + } + DefaultOperation.Builder builder = new DefaultOperation.Builder(); + if (model.contains(subjectToParse, AASNamespace.Operation.inoutputVariables)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.inoutputVariables); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + OperationVariable key = null; + try { + key = new DefaultOperationVariableRDFHandler().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 operationVariables = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + operationVariables.add(keysMap.get(index)); + } + builder.inoutputVariables(operationVariables); + } + } + if (model.contains(subjectToParse, AASNamespace.Operation.inputVariables)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.inputVariables); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + OperationVariable key = null; + try { + key = new DefaultOperationVariableRDFHandler().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 operationVariables = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + operationVariables.add(keysMap.get(index)); + } + builder.inputVariables(operationVariables); + } + } + if (model.contains(subjectToParse, AASNamespace.Operation.outputVariables)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.outputVariables); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + OperationVariable key = null; + try { + key = new DefaultOperationVariableRDFHandler().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 operationVariables = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + operationVariables.add(keysMap.get(index)); + } + builder.outputVariables(operationVariables); + } + } + Operation 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/DefaultOperationVariableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationVariableRDFHandler.java new file mode 100644 index 000000000..5c01625df --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationVariableRDFHandler.java @@ -0,0 +1,43 @@ +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.model.OperationVariable; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationVariable; + +public class DefaultOperationVariableRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(OperationVariable 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.OperationVariable); + if (object.getValue() != null) { + RDFSerializationResult res = new DefaultSubmodelElementRDFHandler().toModel(object.getValue()); + model.add(subject, AASNamespace.OperationVariable.value, res.getResource()); + model.add(res.getModel()); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public OperationVariable fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.OperationVariable)) { + throw new IncompatibleTypeException("OperationVariable"); + } + DefaultOperationVariable.Builder builder = new DefaultOperationVariable.Builder(); + if (model.contains(subjectToParse, AASNamespace.OperationVariable.value)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.OperationVariable.value).getResource(); + SubmodelElement submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(model, resource); + builder.value(submodelElement); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java new file mode 100644 index 000000000..7f5b847eb --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java @@ -0,0 +1,79 @@ +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.Property; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; + +public class DefaultPropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Property 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.Property); + if (object.getValue() != null) { + model.add(subject, AASNamespace.Property.value, object.getValue()); + } + if (object.getValueId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(subject, AASNamespace.Property.valueId, res.getResource()); + model.add(res.getModel()); + } + if (object.getValueType() != null) { + model.add(subject, AASNamespace.Property.valueType, + AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); + } + //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 Property fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property)) { + throw new IncompatibleTypeException("Property"); + } + //TODO: Get this from supplier + Property object = new DefaultProperty(); + + if (model.contains(subjectToParse, AASNamespace.Property.value)) { + object.setValue(model.getProperty(subjectToParse, AASNamespace.Property.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Property.valueId)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueId).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + object.setValueId(reference); + } + if (model.contains(subjectToParse, AASNamespace.Property.valueType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueType).getResource(); + object.setValueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + //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/DefaultQualifierRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java new file mode 100644 index 000000000..16e860a43 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java @@ -0,0 +1,79 @@ +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.DefaultHasSemanticsRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultQualifier; + +public class DefaultQualifierRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Qualifier 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.Qualifier); + if (object.getKind() != null) { + model.add(subject, AASNamespace.Qualifier.kind, + AASNamespace.QualifierKind.valueOf(object.getKind().name())); + } + if (object.getType() != null) { + model.add(subject, AASNamespace.Qualifier.type, object.getType()); + } + if (object.getValue() != null) { + model.add(subject, AASNamespace.Qualifier.value, object.getValue()); + } + if (object.getValueId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(subject, AASNamespace.Qualifier.valueId, res.getResource()); + model.add(res.getModel()); + } + if (object.getValueType() != null) { + model.add(subject, AASNamespace.Qualifier.valueType, + AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); + } + + //HasSemantics + new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject); + + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Qualifier fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier)) { + throw new IncompatibleTypeException("Qualifier"); + } + DefaultQualifier.Builder builder = new DefaultQualifier.Builder(); + if (model.contains(subjectToParse, AASNamespace.Qualifier.kind)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Qualifier.kind).getResource(); + builder.kind(AASNamespace.QualifierKind.fromIRI(resource.getURI())); + } + if (model.contains(subjectToParse, AASNamespace.Qualifier.type)) { + builder.type(model.getProperty(subjectToParse, AASNamespace.Qualifier.type).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Qualifier.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.Qualifier.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Qualifier.valueId)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Qualifier.valueId).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.valueId(reference); + } + if (model.contains(subjectToParse, AASNamespace.Qualifier.valueType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Qualifier.valueType).getResource(); + builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + //HasSemantics + Qualifier object = builder.build(); + new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java new file mode 100644 index 000000000..e2c0ec2e0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java @@ -0,0 +1,73 @@ +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.Range; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultRange; + +public class DefaultRangeRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Range 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.Range); + if (object.getMax() != null) { + model.add(subject, AASNamespace.Range.max, object.getMax()); + } + if (object.getMin() != null) { + model.add(subject, AASNamespace.Range.min, object.getMin()); + } + if (object.getValueType() != null) { + model.add(subject, AASNamespace.Range.valueType, AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); + } + //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 Range fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Range)) { + throw new IncompatibleTypeException("Range"); + } + DefaultRange.Builder builder = new DefaultRange.Builder(); + + if (model.contains(subjectToParse, AASNamespace.Range.max)) { + builder.max(model.getProperty(subjectToParse, AASNamespace.Range.max).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Range.min)) { + builder.min(model.getProperty(subjectToParse, AASNamespace.Range.min).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Range.valueType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Range.valueType).getResource(); + builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + Range 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/DefaultReferableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java new file mode 100644 index 000000000..e234176d1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java @@ -0,0 +1,53 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +public class DefaultReferableRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Referable object) { + if (object instanceof AssetAdministrationShell) { + return new DefaultAssetAdministrationShellRDFHandler().toModel((AssetAdministrationShell) object); + } + if (object instanceof Submodel) { + return new DefaultSubmodelRDFHandler().toModel((Submodel) object); + } + if (object instanceof ConceptDescription) { + return new DefaultConceptDescriptionRDFHandler().toModel((ConceptDescription) object); + } + if (object instanceof SubmodelElement) { + return new DefaultSubmodelElementRDFHandler().toModel((SubmodelElement) object); + } + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known Referable"); + } + + @Override + public Referable fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + Statement typeStatement = model.getProperty(subjectToParse, RDF.type); + // Discriminate on the RDF.type value. + if (typeStatement.getResource().equals(AASNamespace.Types.AssetAdministrationShell)) { + return new DefaultAssetAdministrationShellRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Submodel)) { + return new DefaultSubmodelRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.ConceptDescription)) { + return new DefaultConceptDescriptionRDFHandler().fromModel(model, subjectToParse); + } + if (AASNamespace.Types.SUBMODEL_ELEMENTS.contains(typeStatement.getResource())) { + return new DefaultSubmodelElementRDFHandler().fromModel(model, subjectToParse); + } + throw new IllegalArgumentException("Provided Resource " + + typeStatement.getResource().getURI() + + " is not a SubmodelElement"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java new file mode 100644 index 000000000..4726edda2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java @@ -0,0 +1,65 @@ +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.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceElement; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReferenceElement; + +public class DefaultReferenceElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(ReferenceElement 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.ReferenceElement); + if (object.getValue() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getValue()); + model.add(subject, AASNamespace.ReferenceElement.value, 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 ReferenceElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ReferenceElement)) { + throw new IncompatibleTypeException("ReferenceElement"); + } + DefaultReferenceElement.Builder builder = new DefaultReferenceElement.Builder(); + + if (model.contains(subjectToParse, AASNamespace.ReferenceElement.value)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.ReferenceElement.value).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.value(reference); + } + ReferenceElement 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/DefaultReferenceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java new file mode 100644 index 000000000..20ec5c2ab --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java @@ -0,0 +1,66 @@ +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.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultReferenceRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Reference key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + subject.addProperty(RDF.type, AASNamespace.Types.Reference); + if (key.getType() != null) { + subject.addProperty(AASNamespace.Reference.type, AASNamespace.ReferenceTypes.valueOf(key.getType().name())); + } + int index = 0; + for (Key item : key.getKeys()) { + RDFSerializationResult resultItem = new DefaultKeyRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + subject.addProperty(AASNamespace.Reference.keys, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference)) { + throw new IncompatibleTypeException("Reference"); + } + String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); + Map keysMap = new HashMap<>(); + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); + keysIterator.forEachRemaining(node -> { + try { + Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index, key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + }); + List keys = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + keys.add(keysMap.get(index)); + } + return new DefaultReference.Builder() + .type(AASNamespace.ReferenceTypes.fromIRI(typeString)) + .keys(keys) + .build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java new file mode 100644 index 000000000..d722f40e7 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java @@ -0,0 +1,74 @@ +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.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultRelationshipElement; + +public class DefaultRelationshipElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(RelationshipElement 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.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 RelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.RelationshipElement)) { + throw new IncompatibleTypeException("RelationshipElement"); + } + DefaultRelationshipElement.Builder builder = new DefaultRelationshipElement.Builder(); + if (model.contains(subjectToParse, AASNamespace.RelationshipElement.second)) { + 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); + } + RelationshipElement 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/DefaultResourceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java new file mode 100644 index 000000000..f4c0308df --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java @@ -0,0 +1,43 @@ +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.ResourceFactory; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultResource; + +public class DefaultResourceRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Resource object) { + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + org.apache.jena.rdf.model.Resource subject = model.createResource(); + model.add(subject, RDF.type, AASNamespace.Types.Resource); + if (object.getPath() != null) { + model.add(subject, AASNamespace.Resource.path, object.getPath()); + } + if (object.getContentType() != null) { + model.add(subject, AASNamespace.Resource.contentType, object.getContentType()); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Resource)) { + throw new IncompatibleTypeException("Resource"); + } + DefaultResource.Builder builder = new DefaultResource.Builder(); + if (model.contains(subjectToParse, AASNamespace.Resource.path)) { + builder.path(model.getProperty(subjectToParse, AASNamespace.Resource.path).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Resource.contentType)) { + builder.contentType(model.getProperty(subjectToParse, AASNamespace.Resource.contentType).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java new file mode 100644 index 000000000..835d0b3e5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java @@ -0,0 +1,64 @@ +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.DefaultHasSemanticsRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId; + +public class DefaultSpecificAssetIdRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SpecificAssetId 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.SpecificAssetId); + if (object.getName() != null) { + model.add(subject, AASNamespace.SpecificAssetId.name, object.getName()); + } + if (object.getValue() != null) { + model.add(subject, AASNamespace.SpecificAssetId.value, object.getValue()); + } + if (object.getExternalSubjectId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getExternalSubjectId()); + model.add(subject, AASNamespace.SpecificAssetId.externalSubjectId, res.getResource()); + model.add(res.getModel()); + } + //HasSemantics + new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public SpecificAssetId fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId)) { + throw new IncompatibleTypeException("SpecificAssetId"); + } + DefaultSpecificAssetId.Builder builder = new DefaultSpecificAssetId.Builder(); + if (model.contains(subjectToParse, AASNamespace.SpecificAssetId.name)) { + builder.name(model.getProperty(subjectToParse, + AASNamespace.SpecificAssetId.name).getString()); + } + if (model.contains(subjectToParse, AASNamespace.SpecificAssetId.value)) { + builder.value(model.getProperty(subjectToParse, + AASNamespace.SpecificAssetId.value).getString()); + } + if (model.contains(subjectToParse, AASNamespace.SpecificAssetId.externalSubjectId)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.SpecificAssetId.externalSubjectId).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.externalSubjectId(reference); + } + //HasSemantics + SpecificAssetId object = builder.build(); + new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java new file mode 100644 index 000000000..06f527d4b --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java @@ -0,0 +1,88 @@ +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.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultSubmodelElementCollectionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElementCollection 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.SubmodelElementCollection); + if (object.getValue() != null && object.getValue().isEmpty() == false) { + int index = 0; + for (SubmodelElement item : object.getValue()) { + RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.SubmodelElementCollection.value, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //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 SubmodelElementCollection fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SubmodelElementCollection)) { + throw new IncompatibleTypeException("SubmodelElementCollection"); + } + DefaultSubmodelElementCollection.Builder builder = new DefaultSubmodelElementCollection.Builder(); + if (model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementCollection.value); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + SubmodelElement key = null; + try { + key = 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 submodelElements = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + submodelElements.add(keysMap.get(index)); + } + builder.value(submodelElements); + } + } + SubmodelElementCollection 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/DefaultSubmodelElementListRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java new file mode 100644 index 000000000..60cf1f3a8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java @@ -0,0 +1,126 @@ +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.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultSubmodelElementListRDFHandler implements RDFHandler { + + + @Override + public RDFSerializationResult toModel(SubmodelElementList 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.SubmodelElementList); + model.addLiteral(subject, AASNamespace.SubmodelElementList.orderRelevant, object.getOrderRelevant()); + if (object.getSemanticIdListElement() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getSemanticIdListElement()); + model.add(subject, AASNamespace.SubmodelElementList.semanticIdListElement, res.getResource()); + model.add(res.getModel()); + } + if (object.getValueTypeListElement() != null) { + model.add(subject, AASNamespace.SubmodelElementList.valueTypeListElement, + AASNamespace.DataTypeDefXsd.valueOf(object.getValueTypeListElement().name())); + } + if (object.getTypeValueListElement() != null) { + model.add(subject, AASNamespace.SubmodelElementList.typeValueListElement, + AASNamespace.AasSubmodelElements.valueOf(object.getTypeValueListElement().name())); + } + if (object.getValue() != null && object.getValue().isEmpty() == false) { + int index = 0; + for (SubmodelElement item : object.getValue()) { + RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + model.add(subject, AASNamespace.SubmodelElementList.value, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //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 SubmodelElementList fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SubmodelElementList)) { + throw new IncompatibleTypeException("SubmodelElementList"); + } + DefaultSubmodelElementList.Builder builder = new DefaultSubmodelElementList.Builder(); + builder.orderRelevant(true); + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant)) { + builder.orderRelevant(model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.semanticIdListElement)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.semanticIdListElement).getResource(); + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); + builder.semanticIdListElement(reference); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.valueTypeListElement)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.valueTypeListElement).getResource(); + builder.valueTypeListElement(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.typeValueListElement)) { + Resource resource = model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.typeValueListElement).getResource(); + builder.typeValueListElement(AASNamespace.AasSubmodelElements.fromIRI(resource.getURI())); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.value)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementList.value); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + SubmodelElement key = null; + try { + key = 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 submodelElements = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + submodelElements.add(keysMap.get(index)); + } + builder.value(submodelElements); + } + } + SubmodelElementList 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/DefaultSubmodelElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java new file mode 100644 index 000000000..b8f0add58 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java @@ -0,0 +1,116 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +public class DefaultSubmodelElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElement object) { + // it should be bottom up in hierarchy + if (object instanceof AnnotatedRelationshipElement) { + return new DefaultAnnotatedRelationshipElementRDFHandler().toModel((AnnotatedRelationshipElement) object); + } + if (object instanceof RelationshipElement) { + return new DefaultRelationshipElementRDFHandler().toModel((RelationshipElement) object); + } + if (object instanceof BasicEventElement) { + return new DefaultBasicEventElementRDFHandler().toModel((BasicEventElement) object); + } + if (object instanceof Blob) { + return new DefaultBlobRDFHandler().toModel((Blob) object); + } + if (object instanceof File) { + return new DefaultFileRDFHandler().toModel((File) object); + } + if (object instanceof MultiLanguageProperty) { + return new DefaultMultiLanguagePropertyRDFHandler().toModel((MultiLanguageProperty) object); + } + if (object instanceof Property) { + return new DefaultPropertyRDFHandler().toModel((Property) object); + } + if (object instanceof Range) { + return new DefaultRangeRDFHandler().toModel((Range) object); + } + if (object instanceof ReferenceElement) { + return new DefaultReferenceElementRDFHandler().toModel((ReferenceElement) object); + } + if (object instanceof SubmodelElementCollection) { + return new DefaultSubmodelElementCollectionRDFHandler().toModel((SubmodelElementCollection) object); + } + if (object instanceof SubmodelElementList) { + return new DefaultSubmodelElementListRDFHandler().toModel((SubmodelElementList) object); + } + if (object instanceof Entity) { + return new DefaultEntityRDFHandler().toModel((Entity) object); + } + if (object instanceof Capability) { + return new DefaultCapabilityRDFHandler().toModel((Capability) object); + } + if (object instanceof Operation) { + return new DefaultOperationRDFHandler().toModel((Operation) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known SubmodelElement"); + } + + @Override + public SubmodelElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + Statement typeStatement = model.getProperty(subjectToParse, RDF.type); + // Discriminate on the RDF.type value. + if (typeStatement.getResource().equals(AASNamespace.Types.AnnotatedRelationshipElement)) { + return new DefaultAnnotatedRelationshipElementRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.RelationshipElement)) { + return new DefaultRelationshipElementRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.BasicEventElement)) { + return new DefaultBasicEventElementRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Blob)) { + return new DefaultBlobRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.File)) { + return new DefaultFileRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.MultiLanguageProperty)) { + return new DefaultMultiLanguagePropertyRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Property)) { + return new DefaultPropertyRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Range)) { + return new DefaultRangeRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.ReferenceElement)) { + return new DefaultReferenceElementRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.SubmodelElementCollection)) { + return new DefaultSubmodelElementCollectionRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.SubmodelElementList)) { + return new DefaultSubmodelElementListRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Entity)) { + return new DefaultEntityRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Capability)) { + return new DefaultCapabilityRDFHandler().fromModel(model, subjectToParse); + } + if (typeStatement.getResource().equals(AASNamespace.Types.Operation)) { + return new DefaultOperationRDFHandler().fromModel(model, subjectToParse); + } + + throw new IllegalArgumentException("Provided Resource " + + typeStatement.getResource().getURI() + + " is not a SubmodelElement"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java new file mode 100644 index 000000000..9bf6a0893 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java @@ -0,0 +1,97 @@ +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.DefaultIdentifiableRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultQualifiableRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultSubmodelRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Submodel 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.Submodel); + if (object.getSubmodelElements() != null && object.getSubmodelElements().isEmpty() == false) { + int index = 0; + for (SubmodelElement item : object.getSubmodelElements()) { + RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + subject.addProperty(AASNamespace.Submodel.submodelElements, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //HasKind + if (object.getKind() != null) { + model.add(subject, AASNamespace.HasKind.kind, AASNamespace.ModellingKind.valueOf(object.getKind().name())); + } + //HasDataSpecification + new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, subject); + //HasSemantics + new DefaultHasSemanticsRDFPartialHandler().partialToModel(object, model, subject); + //Qualifiable + new DefaultQualifiableRDFPartialHandler().partialToModel(object, model, subject); + //Identifiable + new DefaultIdentifiableRDFPartialHandler().partialToModel(object, model, subject); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public Submodel fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Submodel)) { + throw new IncompatibleTypeException("Submodel"); + } + DefaultSubmodel.Builder builder = new DefaultSubmodel.Builder(); + if (model.contains(subjectToParse, AASNamespace.Submodel.submodelElements)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Submodel.submodelElements); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + SubmodelElement key = null; + try { + key = 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 submodelElements = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + submodelElements.add(keysMap.get(index)); + } + builder.submodelElements(submodelElements); + } + } + //HasKind + if (model.contains(subjectToParse, AASNamespace.HasKind.kind)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.HasKind.kind).getResource(); + builder.kind(AASNamespace.ModellingKind.fromIRI(resource.getURI())); + } + Submodel object = builder.build(); + //HasDataSpecification + new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse); + //HasSemantics + new DefaultHasSemanticsRDFPartialHandler().partialFromModel(object, model, subjectToParse); + //Qualifiable + new DefaultQualifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); + //Identifiable + new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java new file mode 100644 index 000000000..a9f9b91b2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java @@ -0,0 +1,44 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.model.LangStringDefinitionTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringDefinitionTypeIec61360; + +public class DefaultLangStringDefinitionTypeIec61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(LangStringDefinitionTypeIec61360 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.LangStringDefinitionTypeIec61360); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); + } + if (object.getText() != null) { + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LangStringDefinitionTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringDefinitionTypeIec61360)) { + throw new IncompatibleTypeException("LangStringDefinitionTypeIec61360"); + } + DefaultLangStringDefinitionTypeIec61360.Builder builder = new DefaultLangStringDefinitionTypeIec61360.Builder(); + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { + builder.text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()); + } + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.language)) { + builder.language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java new file mode 100644 index 000000000..8748566ba --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java @@ -0,0 +1,44 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.model.LangStringPreferredNameTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringPreferredNameTypeIec61360; + +public class DefaultLangStringPreferredNameTypeIec61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(LangStringPreferredNameTypeIec61360 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.LangStringPreferredNameTypeIec61360); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); + } + if (object.getText() != null) { + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LangStringPreferredNameTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringPreferredNameTypeIec61360)) { + throw new IncompatibleTypeException("LangStringPreferredNameTypeIec61360"); + } + DefaultLangStringPreferredNameTypeIec61360.Builder builder = new DefaultLangStringPreferredNameTypeIec61360.Builder(); + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { + builder.text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()); + } + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.language)) { + builder.language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java new file mode 100644 index 000000000..17e6a8656 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java @@ -0,0 +1,41 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.LangStringShortNameTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringShortNameTypeIec61360; + +public class DefaultLangStringShortNameTypeIec61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(LangStringShortNameTypeIec61360 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.LangStringShortNameTypeIec61360); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LangStringShortNameTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360)) { + throw new IncompatibleTypeException("LangStringShortNameTypeIec61360"); + } + DefaultLangStringShortNameTypeIec61360.Builder builder = new DefaultLangStringShortNameTypeIec61360.Builder(); + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { + builder.text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()); + } + if (model.contains(subjectToParse, AASNamespace.AbstractLangString.language)) { + builder.language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java new file mode 100644 index 000000000..876203b4f --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java @@ -0,0 +1,48 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.model.LevelType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLevelType; + +public class DefaultLevelTypeRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(LevelType 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.LevelType); + model.addLiteral(subject, AASNamespace.LevelType.min, object.getMin()); + model.addLiteral(subject, AASNamespace.LevelType.max, object.getMax()); + model.addLiteral(subject, AASNamespace.LevelType.nom, object.getNom()); + model.addLiteral(subject, AASNamespace.LevelType.typ, object.getTyp()); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public LevelType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LevelType)) { + throw new IncompatibleTypeException("LevelType"); + } + DefaultLevelType.Builder builder = new DefaultLevelType.Builder(); + if (model.contains(subjectToParse, AASNamespace.LevelType.min)) { + builder.min(model.getProperty(subjectToParse, AASNamespace.LevelType.min).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.LevelType.max)) { + builder.max(model.getProperty(subjectToParse, AASNamespace.LevelType.max).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.LevelType.nom)) { + builder.nom(model.getProperty(subjectToParse, AASNamespace.LevelType.nom).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.LevelType.min)) { + builder.typ(model.getProperty(subjectToParse, AASNamespace.LevelType.typ).getBoolean()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java new file mode 100644 index 000000000..97c802a47 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java @@ -0,0 +1,67 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.ValueList; +import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultValueList; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultValueListRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(ValueList 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.ValueList); + if (object.getValueReferencePairs() != null && object.getValueReferencePairs().isEmpty() == false) { + int index = 0; + for (ValueReferencePair valueReferencePair : object.getValueReferencePairs()) { + RDFSerializationResult valueReferencePairSerializationResult = new DefaultValueReferencePairRDFHandler().toModel(valueReferencePair); + model.add(subject, AASNamespace.ValueList.valueReferencePairs, valueReferencePairSerializationResult.getResource()); + model.addLiteral(valueReferencePairSerializationResult.getResource(), AASNamespace.index, index); + model.add(valueReferencePairSerializationResult.getModel()); + index++; + } + } + + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public ValueList fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueList)) { + throw new IncompatibleTypeException("ValueList"); + } + DefaultValueList.Builder builder = new DefaultValueList.Builder(); + if (model.contains(subjectToParse, AASNamespace.ValueList.valueReferencePairs)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ValueList.valueReferencePairs); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + ValueReferencePair key = null; + try { + key = new DefaultValueReferencePairRDFHandler().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 valueReferencePairList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + valueReferencePairList.add(keysMap.get(index)); + } + builder.valueReferencePairs(valueReferencePairList); + } + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java new file mode 100644 index 000000000..41b9f2e8f --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java @@ -0,0 +1,50 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360; + +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.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultValueReferencePair; + +public class DefaultValueReferencePairRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(ValueReferencePair 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.ValueReferencePair); + if (object.getValue() != null) { + model.add(subject, AASNamespace.ValueReferencePair.value, object.getValue()); + } + if (object.getValueId() != null) { + RDFSerializationResult referenceSerializationResult = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(subject, AASNamespace.ValueReferencePair.valueId, referenceSerializationResult.getResource()); + model.add(referenceSerializationResult.getModel()); + } + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public ValueReferencePair fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair)) { + throw new IncompatibleTypeException("ValueReferencePair"); + } + DefaultValueReferencePair.Builder builder = new DefaultValueReferencePair.Builder(); + if (model.contains(subjectToParse, AASNamespace.ValueReferencePair.valueId)) { + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, + model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.valueId).getResource()); + builder.valueId(reference); + } + if (model.contains(subjectToParse, AASNamespace.ValueReferencePair.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.value).getString()); + } + return builder.build(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasDataSpecificationRDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasDataSpecificationRDFPartialHandler.java new file mode 100644 index 000000000..a1e15f6a8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasDataSpecificationRDFPartialHandler.java @@ -0,0 +1,62 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.NodeIterator; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultHasDataSpecificationRDFPartialHandler implements RDFPartialHandler { + @Override + public void partialToModel(HasDataSpecification object, Model model, Resource parentNode) { + if (object.getEmbeddedDataSpecifications() != null && !object.getEmbeddedDataSpecifications().isEmpty()) { + int index = 0; + for (EmbeddedDataSpecification item : object.getEmbeddedDataSpecifications()) { + RDFSerializationResult resultItem = new DefaultEmbeddedDataSpecificationRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.HasDataSpecification.embeddedDataSpecifications, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + } + + @Override + public HasDataSpecification partialFromModel(HasDataSpecification object, Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, AASNamespace.HasDataSpecification.embeddedDataSpecifications)) { + Map keysMap = new HashMap<>(); + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, + AASNamespace.HasDataSpecification.embeddedDataSpecifications); + keysIterator.forEachRemaining(node -> { + EmbeddedDataSpecification key = null; + try { + key = new DefaultEmbeddedDataSpecificationRDFHandler().fromModel(model, (Resource) node); + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index, key); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + + }); + if (keysMap.isEmpty() == false) { + List embeddedDataSpecifications = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + embeddedDataSpecifications.add(keysMap.get(index)); + } + object.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java new file mode 100644 index 000000000..c6f7e4404 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java @@ -0,0 +1,71 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.NodeIterator; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultHasSemanticsRDFPartialHandler implements RDFPartialHandler { + + @Override + public void partialToModel(HasSemantics object, Model model, Resource parentNode) { + if (object.getSemanticId() != null) { + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getSemanticId()); + model.add(parentNode, AASNamespace.HasSemantics.semanticId, res.getResource()); + model.add(res.getModel()); + } + if (object.getSupplementalSemanticIds() != null && !object.getSupplementalSemanticIds().isEmpty()) { + int index = 0; + for (Reference item : object.getSupplementalSemanticIds()) { + RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.HasSemantics.supplementalSemanticIds, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + } + + @Override + public HasSemantics partialFromModel(HasSemantics object, Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, AASNamespace.HasSemantics.semanticId)) { + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, model.getProperty(subjectToParse, + AASNamespace.HasSemantics.semanticId).getResource()); + object.setSemanticId(reference); + } + if (model.contains(subjectToParse, AASNamespace.HasSemantics.supplementalSemanticIds)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasSemantics.supplementalSemanticIds); + 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)); + } + object.setSupplementalSemanticIds(references); + } + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFPartialHandler.java new file mode 100644 index 000000000..bfd1a4b5d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFPartialHandler.java @@ -0,0 +1,54 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultAdministrativeInformationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; + +public class DefaultIdentifiableRDFPartialHandler implements RDFPartialHandler { + + @Override + public void partialToModel(Identifiable object, Model model, Resource parentNode) { + //TODO: Side effect + if (object.getId() != null) { + parentNode.addProperty(AASNamespace.Identifiable.id, object.getId()); + } + if (object.getAdministration() != null) { + RDFSerializationResult administrativeResult = new DefaultAdministrativeInformationRDFHandler() + .toModel(object.getAdministration()); + parentNode.addProperty(AASNamespace.Identifiable.administration, + administrativeResult.getResource()); + model.add(administrativeResult.getModel()); + } + + //Referable + new DefaultReferableRDFPartialHandler().partialToModel(object, model, parentNode); + } + + @Override + public Identifiable partialFromModel(Identifiable object, Model model, Resource subjectToParse) throws IncompatibleTypeException { + //TODO: Side effect + if (model.contains(subjectToParse, AASNamespace.Identifiable.id)) { + String id = model.getProperty(subjectToParse, AASNamespace.Identifiable.id).getString(); + object.setId(id); + } + + if (model.contains(subjectToParse, AASNamespace.Identifiable.administration)) { + Resource administrationToParse = model.getProperty( + subjectToParse, + AASNamespace.Identifiable.administration).getResource(); + AdministrativeInformation administrativeInformation = new DefaultAdministrativeInformationRDFHandler() + .fromModel(model, administrationToParse); + object.setAdministration(administrativeInformation); + } + + //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/partial/DefaultQualifiableRDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java new file mode 100644 index 000000000..31eb55b22 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java @@ -0,0 +1,60 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.NodeIterator; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultQualifierRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultQualifiableRDFPartialHandler implements RDFPartialHandler { + @Override + public void partialToModel(Qualifiable object, Model model, Resource parentNode) { + if (object.getQualifiers() != null && !object.getQualifiers().isEmpty()) { + int index = 0; + for (Qualifier item : object.getQualifiers()) { + RDFSerializationResult resultItem = new DefaultQualifierRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.Qualifiable.qualifiers, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + } + + @Override + public Qualifiable partialFromModel(Qualifiable object, Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, AASNamespace.Qualifiable.qualifiers)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Qualifiable.qualifiers); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + Qualifier key = null; + try { + key = new DefaultQualifierRDFHandler().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 qualifiers = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + qualifiers.add(keysMap.get(index)); + } + object.setQualifiers(qualifiers); + } + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java new file mode 100644 index 000000000..fd39940e6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java @@ -0,0 +1,145 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.NodeIterator; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultExtensionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringNameTypeRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringTextTypeRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultReferableRDFPartialHandler implements RDFPartialHandler { + + + @Override + public void partialToModel(Referable object, Model model, Resource parentNode) { + if (object.getIdShort() != null) { + parentNode.addProperty(AASNamespace.Referable.idShort, object.getIdShort()); + } + if (object.getCategory() != null) { + parentNode.addProperty(AASNamespace.Referable.category, object.getCategory()); + } + if (object.getDescription() != null && !object.getDescription().isEmpty()) { + int index = 0; + for (LangStringTextType item : object.getDescription()) { + RDFSerializationResult resultItem = new DefaultLangStringTextTypeRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.Referable.description, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + if (object.getDisplayName() != null && !object.getDescription().isEmpty()) { + int index = 0; + for (LangStringNameType item : object.getDisplayName()) { + RDFSerializationResult resultItem = new DefaultLangStringNameTypeRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.Referable.displayName, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + //HasExtension + if (object.getExtensions() != null && !object.getExtensions().isEmpty()) { + int index = 0; + for (Extension item : object.getExtensions()) { + RDFSerializationResult resultItem = new DefaultExtensionRDFHandler().toModel(item); + resultItem.getResource().addLiteral(AASNamespace.index, index); + parentNode.addProperty(AASNamespace.HasExtensions.extensions, resultItem.getResource()); + // It is important where to put model.add + model.add(resultItem.getModel()); + index = index + 1; + } + } + } + + @Override + public Referable partialFromModel(Referable object, Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, AASNamespace.Referable.idShort)) { + object.setIdShort(model.getProperty(subjectToParse, AASNamespace.Referable.idShort).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Referable.category)) { + object.setCategory(model.getProperty(subjectToParse, AASNamespace.Referable.category).getString()); + } + if (model.contains(subjectToParse, AASNamespace.Referable.description)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.description); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringTextType key = null; + try { + key = new DefaultLangStringTextTypeRDFHandler().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 langStringTextTypes = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringTextTypes.add(keysMap.get(index)); + } + object.setDescription(langStringTextTypes); + } + } + if (model.contains(subjectToParse, AASNamespace.Referable.displayName)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.displayName); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + LangStringNameType key = null; + try { + key = new DefaultLangStringNameTypeRDFHandler().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 langStringNameTypes = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringNameTypes.add(keysMap.get(index)); + } + object.setDisplayName(langStringNameTypes); + } + } + + //HasExtension + if (model.contains(subjectToParse, AASNamespace.HasExtensions.extensions)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasExtensions.extensions); + Map keysMap = new HashMap<>(); + nodeIterator.forEachRemaining(node -> { + Extension key = null; + try { + key = new DefaultExtensionRDFHandler().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 extensions = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + extensions.add(keysMap.get(index)); + } + object.setExtensions(extensions); + } + } + return object; + } +} diff --git a/dataformat-rdf/src/main/resources/rdf-ontology.ttl b/dataformat-rdf/src/main/resources/rdf-ontology.ttl new file mode 100644 index 000000000..df8f50dff --- /dev/null +++ b/dataformat-rdf/src/main/resources/rdf-ontology.ttl @@ -0,0 +1,2058 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . +@base . + + rdf:type owl:Ontology ; + owl:versionInfo "V3.0" ; + rdfs:comment "This ontology represents the data model for the Asset Administration Shell according to the specification version V3.0."@en ; + rdfs:isDefinedBy ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements +aas:AasSubmodelElements rdf:type owl:Class ; + rdfs:label "AAS Submodel Elements"^^xs:string ; + rdfs:comment "Enumeration of all possible elements of a 'SubmodelElementList'."@en ; + owl:oneOf ( + + + + + + + + + + + + + + + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/AnnotatedRelationshipElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Annotated Relationship Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/BasicEventElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Basic Event Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Blob + rdf:type aas:AasSubmodelElements ; + rdfs:label "Blob"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Capability + rdf:type aas:AasSubmodelElements ; + rdfs:label "Capability"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/DataElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Data Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Entity + rdf:type aas:AasSubmodelElements ; + rdfs:label "Entity"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/EventElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Event Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/File + rdf:type aas:AasSubmodelElements ; + rdfs:label "File"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/MultiLanguageProperty + rdf:type aas:AasSubmodelElements ; + rdfs:label "Multi Language Property"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Operation + rdf:type aas:AasSubmodelElements ; + rdfs:label "Operation"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Property + rdf:type aas:AasSubmodelElements ; + rdfs:label "Property"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/Range + rdf:type aas:AasSubmodelElements ; + rdfs:label "Range"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/ReferenceElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Reference Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/RelationshipElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Relationship Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/SubmodelElement + rdf:type aas:AasSubmodelElements ; + rdfs:label "Submodel Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/SubmodelElementCollection + rdf:type aas:AasSubmodelElements ; + rdfs:label "Submodel Element Collection"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AasSubmodelElements/SubmodelElementList + rdf:type aas:AasSubmodelElements ; + rdfs:label "Submodel Element List"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/AbstractLangString +aas:AbstractLangString rdf:type owl:Class ; + rdfs:label "Abstract Lang String"^^xs:string ; + rdfs:comment "Strings with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/AbstractLangString/language + rdf:type owl:DatatypeProperty ; + rdfs:label "has language"^^xs:string ; + rdfs:domain aas:AbstractLangString ; + rdfs:range xs:string ; + rdfs:comment "Language tag conforming to BCP 47"@en ; +. + +### https://admin-shell.io/aas/3/0/AbstractLangString/text + rdf:type owl:DatatypeProperty ; + rdfs:label "has text"^^xs:string ; + rdfs:domain aas:AbstractLangString ; + rdfs:range xs:string ; + rdfs:comment "Text in the 'language'"@en ; +. + +### https://admin-shell.io/aas/3/0/AdministrativeInformation +aas:AdministrativeInformation rdf:type owl:Class ; + rdfs:subClassOf aas:HasDataSpecification ; + rdfs:label "Administrative Information"^^xs:string ; + rdfs:comment "Administrative meta-information for an element like version information."@en ; +. + +### https://admin-shell.io/aas/3/0/AdministrativeInformation/creator + rdf:type owl:ObjectProperty ; + rdfs:label "has creator"^^xs:string ; + rdfs:domain aas:AdministrativeInformation ; + rdfs:range aas:Reference ; + rdfs:comment "The subject ID of the subject responsible for making the element."@en ; +. + +### https://admin-shell.io/aas/3/0/AdministrativeInformation/revision + rdf:type owl:DatatypeProperty ; + rdfs:label "has revision"^^xs:string ; + rdfs:domain aas:AdministrativeInformation ; + rdfs:range xs:string ; + rdfs:comment "Revision of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/AdministrativeInformation/templateId + rdf:type owl:DatatypeProperty ; + rdfs:label "has template ID"^^xs:string ; + rdfs:domain aas:AdministrativeInformation ; + rdfs:range xs:string ; + rdfs:comment "Identifier of the template that guided the creation of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/AdministrativeInformation/version + rdf:type owl:DatatypeProperty ; + rdfs:label "has version"^^xs:string ; + rdfs:domain aas:AdministrativeInformation ; + rdfs:range xs:string ; + rdfs:comment "Version of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement +aas:AnnotatedRelationshipElement rdf:type owl:Class ; + rdfs:subClassOf aas:RelationshipElement ; + rdfs:label "Annotated Relationship Element"^^xs:string ; + rdfs:comment "An annotated relationship element is a relationship element that can be annotated with additional data elements."@en ; +. + +### https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotations + rdf:type owl:ObjectProperty ; + rdfs:label "has annotations"^^xs:string ; + rdfs:domain aas:AnnotatedRelationshipElement ; + rdfs:range aas:DataElement ; + rdfs:comment "A data element that represents an annotation that holds for the relationship between the two elements"@en ; +. + +### https://admin-shell.io/aas/3/0/AssetAdministrationShell +aas:AssetAdministrationShell rdf:type owl:Class ; + rdfs:subClassOf aas:Identifiable ; + rdfs:subClassOf aas:HasDataSpecification ; + rdfs:label "Asset Administration Shell"^^xs:string ; + rdfs:comment "An asset administration shell."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation + rdf:type owl:ObjectProperty ; + rdfs:label "has asset information"^^xs:string ; + rdfs:domain aas:AssetAdministrationShell ; + rdfs:range aas:AssetInformation ; + rdfs:comment "Meta-information about the asset the AAS is representing."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom + rdf:type owl:ObjectProperty ; + rdfs:label "has derived from"^^xs:string ; + rdfs:domain aas:AssetAdministrationShell ; + rdfs:range aas:Reference ; + rdfs:comment "The reference to the AAS the AAS was derived from."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodels + rdf:type owl:ObjectProperty ; + rdfs:label "has submodels"^^xs:string ; + rdfs:domain aas:AssetAdministrationShell ; + rdfs:range aas:Reference ; + rdfs:comment "References to submodels of the AAS."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation +aas:AssetInformation rdf:type owl:Class ; + rdfs:label "Asset Information"^^xs:string ; + rdfs:comment "In 'AssetInformation' identifying meta data of the asset that is represented by an AAS is defined."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation/assetKind + rdf:type owl:ObjectProperty ; + rdfs:label "has asset kind"^^xs:string ; + rdfs:domain aas:AssetInformation ; + rdfs:range aas:AssetKind ; + rdfs:comment "Denotes whether the Asset is of kind 'Type' or 'Instance'."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation/assetType + rdf:type owl:DatatypeProperty ; + rdfs:label "has asset type"^^xs:string ; + rdfs:domain aas:AssetInformation ; + rdfs:range xs:string ; + rdfs:comment "In case 'assetKind' is applicable the 'assetType' is the asset ID of the type asset of the asset under consideration as identified by 'globalAssetId'."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail + rdf:type owl:ObjectProperty ; + rdfs:label "has default thumbnail"^^xs:string ; + rdfs:domain aas:AssetInformation ; + rdfs:range aas:Resource ; + rdfs:comment "Thumbnail of the asset represented by the Asset Administration Shell."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId + rdf:type owl:DatatypeProperty ; + rdfs:label "has global asset ID"^^xs:string ; + rdfs:domain aas:AssetInformation ; + rdfs:range xs:string ; + rdfs:comment "Global identifier of the asset the AAS is representing."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds + rdf:type owl:ObjectProperty ; + rdfs:label "has specific asset IDs"^^xs:string ; + rdfs:domain aas:AssetInformation ; + rdfs:range aas:SpecificAssetId ; + rdfs:comment "Additional domain-specific, typically proprietary identifier for the asset like e.g., serial number etc."@en ; +. + +### https://admin-shell.io/aas/3/0/AssetKind +aas:AssetKind rdf:type owl:Class ; + rdfs:label "Asset Kind"^^xs:string ; + rdfs:comment "Enumeration for denoting whether an asset is a type asset or an instance asset."@en ; + owl:oneOf ( + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/AssetKind/Instance + rdf:type aas:AssetKind ; + rdfs:label "Instance"^^xs:string ; + rdfs:comment "Instance asset"@en ; +. + +### https://admin-shell.io/aas/3/0/AssetKind/NotApplicable + rdf:type aas:AssetKind ; + rdfs:label "Not Applicable"^^xs:string ; + rdfs:comment "Neither a type asset nor an instance asset"@en ; +. + +### https://admin-shell.io/aas/3/0/AssetKind/Type + rdf:type aas:AssetKind ; + rdfs:label "Type"^^xs:string ; + rdfs:comment "Type asset"@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement +aas:BasicEventElement rdf:type owl:Class ; + rdfs:subClassOf aas:EventElement ; + rdfs:label "Basic Event Element"^^xs:string ; + rdfs:comment "A basic event element."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/direction + rdf:type owl:ObjectProperty ; + rdfs:label "has direction"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range aas:Direction ; + rdfs:comment "Direction of event."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate + rdf:type owl:DatatypeProperty ; + rdfs:label "has last update"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range xs:string ; + rdfs:comment "Timestamp in UTC, when the last event was received (input direction) or sent (output direction)."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval + rdf:type owl:DatatypeProperty ; + rdfs:label "has max interval"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range xs:string ; + rdfs:comment "For input direction: not applicable."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker + rdf:type owl:ObjectProperty ; + rdfs:label "has message broker"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range aas:Reference ; + rdfs:comment "Information, which outer message infrastructure shall handle messages for the 'EventElement'. Refers to a 'Submodel', 'SubmodelElementList', 'SubmodelElementCollection' or 'Entity', which contains 'DataElement''s describing the proprietary specification for the message broker."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic + rdf:type owl:DatatypeProperty ; + rdfs:label "has message topic"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range xs:string ; + rdfs:comment "Information for the outer message infrastructure for scheduling the event to the respective communication channel."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/minInterval + rdf:type owl:DatatypeProperty ; + rdfs:label "has min interval"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range xs:string ; + rdfs:comment "For input direction, reports on the maximum frequency, the software entity behind the respective Referable can handle input events."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/observed + rdf:type owl:ObjectProperty ; + rdfs:label "has observed"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the 'Referable', which defines the scope of the event. Can be 'AssetAdministrationShell', 'Submodel', or 'SubmodelElement'."@en ; +. + +### https://admin-shell.io/aas/3/0/BasicEventElement/state + rdf:type owl:ObjectProperty ; + rdfs:label "has state"^^xs:string ; + rdfs:domain aas:BasicEventElement ; + rdfs:range aas:StateOfEvent ; + rdfs:comment "State of event."@en ; +. + +### https://admin-shell.io/aas/3/0/Blob +aas:Blob rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "Blob"^^xs:string ; + rdfs:comment "A 'Blob' is a data element that represents a file that is contained with its source code in the value attribute."@en ; +. + +### https://admin-shell.io/aas/3/0/Blob/contentType + rdf:type owl:DatatypeProperty ; + rdfs:label "has content type"^^xs:string ; + rdfs:domain aas:Blob ; + rdfs:range xs:string ; + rdfs:comment "Content type of the content of the 'Blob'."@en ; +. + +### https://admin-shell.io/aas/3/0/Blob/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:Blob ; + rdfs:range xs:base64Binary ; + rdfs:comment "The value of the 'Blob' instance of a blob data element."@en ; +. + +### https://admin-shell.io/aas/3/0/Capability +aas:Capability rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Capability"^^xs:string ; + rdfs:comment "A capability is the implementation-independent description of the potential of an asset to achieve a certain effect in the physical or virtual world."@en ; +. + +### https://admin-shell.io/aas/3/0/ConceptDescription +aas:ConceptDescription rdf:type owl:Class ; + rdfs:subClassOf aas:Identifiable ; + rdfs:subClassOf aas:HasDataSpecification ; + rdfs:label "Concept Description"^^xs:string ; + rdfs:comment "The semantics of a property or other elements that may have a semantic description is defined by a concept description."@en ; +. + +### https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf + rdf:type owl:ObjectProperty ; + rdfs:label "has is case of"^^xs:string ; + rdfs:domain aas:ConceptDescription ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to an external definition the concept is compatible to or was derived from."@en ; +. + +### https://admin-shell.io/aas/3/0/DataElement +aas:DataElement rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Data Element"^^xs:string ; + rdfs:comment "A data element is a submodel element that is not further composed out of other submodel elements."@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationContent +aas:DataSpecificationContent rdf:type owl:Class ; + rdfs:label "Data Specification Content"^^xs:string ; + rdfs:comment "Data specification content is part of a data specification template and defines which additional attributes shall be added to the element instance that references the data specification template and meta information about the template itself."@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360 +aas:DataSpecificationIec61360 rdf:type owl:Class ; + rdfs:subClassOf aas:DataSpecificationContent ; + rdfs:label "Data Specification IEC 61360"^^xs:string ; + rdfs:comment "Content of data specification template for concept descriptions for properties, values and value lists conformant to IEC 61360."@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType + rdf:type owl:ObjectProperty ; + rdfs:label "has data type"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:DataTypeIec61360 ; + rdfs:comment "Data Type"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition + rdf:type owl:ObjectProperty ; + rdfs:label "has definition"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:LangStringDefinitionTypeIec61360 ; + rdfs:comment "Definition in different languages"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType + rdf:type owl:ObjectProperty ; + rdfs:label "has level type"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:LevelType ; + rdfs:comment "Set of levels."@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName + rdf:type owl:ObjectProperty ; + rdfs:label "has preferred name"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:LangStringPreferredNameTypeIec61360 ; + rdfs:comment "Preferred name"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName + rdf:type owl:ObjectProperty ; + rdfs:label "has short name"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:LangStringShortNameTypeIec61360 ; + rdfs:comment "Short name"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition + rdf:type owl:DatatypeProperty ; + rdfs:label "has source of definition"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range xs:string ; + rdfs:comment "Source of definition"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol + rdf:type owl:DatatypeProperty ; + rdfs:label "has symbol"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range xs:string ; + rdfs:comment "Symbol"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit + rdf:type owl:DatatypeProperty ; + rdfs:label "has unit"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range xs:string ; + rdfs:comment "Unit"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId + rdf:type owl:ObjectProperty ; + rdfs:label "has unit ID"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:Reference ; + rdfs:comment "Unique unit id"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range xs:string ; + rdfs:comment "Value"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat + rdf:type owl:DatatypeProperty ; + rdfs:label "has value format"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range xs:string ; + rdfs:comment "Value Format"@en ; +. + +### https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList + rdf:type owl:ObjectProperty ; + rdfs:label "has value list"^^xs:string ; + rdfs:domain aas:DataSpecificationIec61360 ; + rdfs:range aas:ValueList ; + rdfs:comment "List of allowed values"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd +aas:DataTypeDefXsd rdf:type owl:Class ; + rdfs:label "Data Type Def XSD"^^xs:string ; + rdfs:comment "Enumeration listing all XSD anySimpleTypes"@en ; + owl:oneOf ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/AnyUri + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Any URI"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Base64Binary + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Base 64 Binary"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Boolean + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Boolean"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Byte + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Byte"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Date + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Date"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/DateTime + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Date Time"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Decimal + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Decimal"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Double + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Double"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Duration + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Duration"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Float + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Float"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/GDay + rdf:type aas:DataTypeDefXsd ; + rdfs:label "G Day"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/GMonth + rdf:type aas:DataTypeDefXsd ; + rdfs:label "G Month"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/GMonthDay + rdf:type aas:DataTypeDefXsd ; + rdfs:label "G Month Day"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/GYear + rdf:type aas:DataTypeDefXsd ; + rdfs:label "G Year"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/GYearMonth + rdf:type aas:DataTypeDefXsd ; + rdfs:label "G Year Month"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/HexBinary + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Hex Binary"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Int + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Int"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Integer + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Integer"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Long + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Long"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/NegativeInteger + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Negative Integer"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/NonNegativeInteger + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Non Negative Integer"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/NonPositiveInteger + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Non Positive Integer"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/PositiveInteger + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Positive Integer"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Short + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Short"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/String + rdf:type aas:DataTypeDefXsd ; + rdfs:label "String"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/Time + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Time"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/UnsignedByte + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Unsigned Byte"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/UnsignedInt + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Unsigned Int"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/UnsignedLong + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Unsigned Long"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeDefXsd/UnsignedShort + rdf:type aas:DataTypeDefXsd ; + rdfs:label "Unsigned Short"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360 +aas:DataTypeIec61360 rdf:type owl:Class ; + rdfs:label "Data Type IEC 61360"^^xs:string ; + owl:oneOf ( + + + + + + + + + + + + + + + + + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Blob + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Blob"^^xs:string ; + rdfs:comment "values containing the content of a file. Values may be binaries."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Boolean + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Boolean"^^xs:string ; + rdfs:comment "values representing truth of logic or Boolean algebra (TRUE, FALSE)"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Date + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Date"^^xs:string ; + rdfs:comment "values containing a calendar date, conformant to ISO 8601:2004 Format yyyy-mm-dd Example from IEC 61360-1:2017: \"1999-05-31\" is the [DATE] representation of: \"31 May 1999\"."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/File + rdf:type aas:DataTypeIec61360 ; + rdfs:label "File"^^xs:string ; + rdfs:comment "values containing an address to a file. The values are of type URI and can represent an absolute or relative path."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Html + rdf:type aas:DataTypeIec61360 ; + rdfs:label "HTML"^^xs:string ; + rdfs:comment "Values containing string with any sequence of characters, using the syntax of HTML5 (see W3C Recommendation 28:2014)"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/IntegerCount + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Integer Count"^^xs:string ; + rdfs:comment "values containing values of type INTEGER but are no currencies or measures"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/IntegerCurrency + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Integer Currency"^^xs:string ; + rdfs:comment "values containing values of type INTEGER that are currencies"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/IntegerMeasure + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Integer Measure"^^xs:string ; + rdfs:comment "values containing values that are measure of type INTEGER. In addition such a value comes with a physical unit."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Irdi + rdf:type aas:DataTypeIec61360 ; + rdfs:label "IRDI"^^xs:string ; + rdfs:comment "values conforming to ISO/IEC 11179 series global identifier sequences"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Iri + rdf:type aas:DataTypeIec61360 ; + rdfs:label "IRI"^^xs:string ; + rdfs:comment "values containing values of type STRING conformant to Rfc 3987"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Rational + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Rational"^^xs:string ; + rdfs:comment "values containing values of type rational"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/RationalMeasure + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Rational Measure"^^xs:string ; + rdfs:comment "values containing values of type rational. In addition such a value comes with a physical unit."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/RealCount + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Real Count"^^xs:string ; + rdfs:comment "values containing numbers that can be written as a terminating or non-terminating decimal; a rational or irrational number but are no currencies or measures"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/RealCurrency + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Real Currency"^^xs:string ; + rdfs:comment "values containing values of type REAL that are currencies"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/RealMeasure + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Real Measure"^^xs:string ; + rdfs:comment "values containing values that are measures of type REAL. In addition such a value comes with a physical unit."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/String + rdf:type aas:DataTypeIec61360 ; + rdfs:label "String"^^xs:string ; + rdfs:comment "values consisting of sequence of characters but cannot be translated into other languages"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/StringTranslatable + rdf:type aas:DataTypeIec61360 ; + rdfs:label "String Translatable"^^xs:string ; + rdfs:comment "values containing string but shall be represented as different string in different languages"@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Time + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Time"^^xs:string ; + rdfs:comment "values containing a time, conformant to ISO 8601:2004 but restricted to what is allowed in the corresponding type in xml."@en ; +. + +### https://admin-shell.io/aas/3/0/DataTypeIec61360/Timestamp + rdf:type aas:DataTypeIec61360 ; + rdfs:label "Timestamp"^^xs:string ; + rdfs:comment "values containing a time, conformant to ISO 8601:2004 but restricted to what is allowed in the corresponding type in xml."@en ; +. + +### https://admin-shell.io/aas/3/0/Direction +aas:Direction rdf:type owl:Class ; + rdfs:label "Direction"^^xs:string ; + rdfs:comment "Direction"@en ; + owl:oneOf ( + + + ) ; +. + +### https://admin-shell.io/aas/3/0/Direction/Input + rdf:type aas:Direction ; + rdfs:label "Input"^^xs:string ; + rdfs:comment "Input direction."@en ; +. + +### https://admin-shell.io/aas/3/0/Direction/Output + rdf:type aas:Direction ; + rdfs:label "Output"^^xs:string ; + rdfs:comment "Output direction"@en ; +. + +### https://admin-shell.io/aas/3/0/EmbeddedDataSpecification +aas:EmbeddedDataSpecification rdf:type owl:Class ; + rdfs:label "Embedded Data Specification"^^xs:string ; + rdfs:comment "Embed the content of a data specification."@en ; +. + +### https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification + rdf:type owl:ObjectProperty ; + rdfs:label "has data specification"^^xs:string ; + rdfs:domain aas:EmbeddedDataSpecification ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the data specification"@en ; +. + +### https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent + rdf:type owl:ObjectProperty ; + rdfs:label "has data specification content"^^xs:string ; + rdfs:domain aas:EmbeddedDataSpecification ; + rdfs:range aas:DataSpecificationContent ; + rdfs:comment "Actual content of the data specification"@en ; +. + +### https://admin-shell.io/aas/3/0/Entity +aas:Entity rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Entity"^^xs:string ; + rdfs:comment "An entity is a submodel element that is used to model entities."@en ; +. + +### https://admin-shell.io/aas/3/0/Entity/entityType + rdf:type owl:ObjectProperty ; + rdfs:label "has entity type"^^xs:string ; + rdfs:domain aas:Entity ; + rdfs:range aas:EntityType ; + rdfs:comment "Describes whether the entity is a co-managed entity or a self-managed entity."@en ; +. + +### https://admin-shell.io/aas/3/0/Entity/globalAssetId + rdf:type owl:DatatypeProperty ; + rdfs:label "has global asset ID"^^xs:string ; + rdfs:domain aas:Entity ; + rdfs:range xs:string ; + rdfs:comment "Global identifier of the asset the entity is representing."@en ; +. + +### https://admin-shell.io/aas/3/0/Entity/specificAssetIds + rdf:type owl:ObjectProperty ; + rdfs:label "has specific asset IDs"^^xs:string ; + rdfs:domain aas:Entity ; + rdfs:range aas:SpecificAssetId ; + rdfs:comment "Reference to a specific asset ID representing a supplementary identifier of the asset represented by the Asset Administration Shell."@en ; +. + +### https://admin-shell.io/aas/3/0/Entity/statements + rdf:type owl:ObjectProperty ; + rdfs:label "has statements"^^xs:string ; + rdfs:domain aas:Entity ; + rdfs:range aas:SubmodelElement ; + rdfs:comment "Describes statements applicable to the entity by a set of submodel elements, typically with a qualified value."@en ; +. + +### https://admin-shell.io/aas/3/0/EntityType +aas:EntityType rdf:type owl:Class ; + rdfs:label "Entity Type"^^xs:string ; + rdfs:comment "Enumeration for denoting whether an entity is a self-managed entity or a co-managed entity."@en ; + owl:oneOf ( + + + ) ; +. + +### https://admin-shell.io/aas/3/0/EntityType/CoManagedEntity + rdf:type aas:EntityType ; + rdfs:label "Co Managed Entity"^^xs:string ; + rdfs:comment "For co-managed entities there is no separate AAS. Co-managed entities need to be part of a self-managed entity."@en ; +. + +### https://admin-shell.io/aas/3/0/EntityType/SelfManagedEntity + rdf:type aas:EntityType ; + rdfs:label "Self Managed Entity"^^xs:string ; + rdfs:comment "Self-Managed Entities have their own AAS but can be part of the bill of material of a composite self-managed entity."@en ; +. + +### https://admin-shell.io/aas/3/0/Environment +aas:Environment rdf:type owl:Class ; + rdfs:label "Environment"^^xs:string ; + rdfs:comment "Container for the sets of different identifiables."@en ; +. + +### https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells + rdf:type owl:ObjectProperty ; + rdfs:label "has asset administration shells"^^xs:string ; + rdfs:domain aas:Environment ; + rdfs:range aas:AssetAdministrationShell ; + rdfs:comment "Asset administration shell"@en ; +. + +### https://admin-shell.io/aas/3/0/Environment/conceptDescriptions + rdf:type owl:ObjectProperty ; + rdfs:label "has concept descriptions"^^xs:string ; + rdfs:domain aas:Environment ; + rdfs:range aas:ConceptDescription ; + rdfs:comment "Concept description"@en ; +. + +### https://admin-shell.io/aas/3/0/Environment/submodels + rdf:type owl:ObjectProperty ; + rdfs:label "has submodels"^^xs:string ; + rdfs:domain aas:Environment ; + rdfs:range aas:Submodel ; + rdfs:comment "Submodel"@en ; +. + +### https://admin-shell.io/aas/3/0/EventElement +aas:EventElement rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Event Element"^^xs:string ; + rdfs:comment "An event element."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload +aas:EventPayload rdf:type owl:Class ; + rdfs:label "Event Payload"^^xs:string ; + rdfs:comment "Defines the necessary information of an event instance sent out or received."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/observableReference + rdf:type owl:ObjectProperty ; + rdfs:label "has observable reference"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the referable, which defines the scope of the event."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/observableSemanticId + rdf:type owl:ObjectProperty ; + rdfs:label "has observable semantic ID"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range aas:Reference ; + rdfs:comment "'semanticId' of the referable which defines the scope of the event, if available."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/payload + rdf:type owl:DatatypeProperty ; + rdfs:label "has payload"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range xs:base64Binary ; + rdfs:comment "Event specific payload."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/source + rdf:type owl:ObjectProperty ; + rdfs:label "has source"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the source event element, including identification of 'AssetAdministrationShell', 'Submodel', 'SubmodelElement''s."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/sourceSemanticId + rdf:type owl:ObjectProperty ; + rdfs:label "has source semantic ID"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range aas:Reference ; + rdfs:comment "'semanticId' of the source event element, if available"@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/subjectId + rdf:type owl:ObjectProperty ; + rdfs:label "has subject ID"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range aas:Reference ; + rdfs:comment "Subject, who/which initiated the creation."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/timeStamp + rdf:type owl:DatatypeProperty ; + rdfs:label "has time stamp"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range xs:string ; + rdfs:comment "Timestamp in UTC, when this event was triggered."@en ; +. + +### https://admin-shell.io/aas/3/0/EventPayload/topic + rdf:type owl:DatatypeProperty ; + rdfs:label "has topic"^^xs:string ; + rdfs:domain aas:EventPayload ; + rdfs:range xs:string ; + rdfs:comment "Information for the outer message infrastructure for scheduling the event to the respective communication channel."@en ; +. + +### https://admin-shell.io/aas/3/0/Extension +aas:Extension rdf:type owl:Class ; + rdfs:subClassOf aas:HasSemantics ; + rdfs:label "Extension"^^xs:string ; + rdfs:comment "Single extension of an element."@en ; +. + +### https://admin-shell.io/aas/3/0/Extension/name + rdf:type owl:DatatypeProperty ; + rdfs:label "has name"^^xs:string ; + rdfs:domain aas:Extension ; + rdfs:range xs:string ; + rdfs:comment "Name of the extension."@en ; +. + +### https://admin-shell.io/aas/3/0/Extension/refersTo + rdf:type owl:ObjectProperty ; + rdfs:label "has refers to"^^xs:string ; + rdfs:domain aas:Extension ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to an element the extension refers to."@en ; +. + +### https://admin-shell.io/aas/3/0/Extension/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:Extension ; + rdfs:range xs:string ; + rdfs:comment "Value of the extension"@en ; +. + +### https://admin-shell.io/aas/3/0/Extension/valueType + rdf:type owl:ObjectProperty ; + rdfs:label "has value type"^^xs:string ; + rdfs:domain aas:Extension ; + rdfs:range aas:DataTypeDefXsd ; + rdfs:comment "Type of the value of the extension."@en ; +. + +### https://admin-shell.io/aas/3/0/File +aas:File rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "File"^^xs:string ; + rdfs:comment "A File is a data element that represents an address to a file (a locator)."@en ; +. + +### https://admin-shell.io/aas/3/0/File/contentType + rdf:type owl:DatatypeProperty ; + rdfs:label "has content type"^^xs:string ; + rdfs:domain aas:File ; + rdfs:range xs:string ; + rdfs:comment "Content type of the content of the file."@en ; +. + +### https://admin-shell.io/aas/3/0/File/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:File ; + rdfs:range xs:string ; + rdfs:comment "Path and name of the referenced file (with file extension)."@en ; +. + +### https://admin-shell.io/aas/3/0/HasDataSpecification +aas:HasDataSpecification rdf:type owl:Class ; + rdfs:label "Has Data Specification"^^xs:string ; + rdfs:comment "Element that can be extended by using data specification templates."@en ; +. + +### https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications + rdf:type owl:ObjectProperty ; + rdfs:label "has embedded data specifications"^^xs:string ; + rdfs:domain aas:HasDataSpecification ; + rdfs:range aas:EmbeddedDataSpecification ; + rdfs:comment "Embedded data specification."@en ; +. + +### https://admin-shell.io/aas/3/0/HasExtensions +aas:HasExtensions rdf:type owl:Class ; + rdfs:label "Has Extensions"^^xs:string ; + rdfs:comment "Element that can be extended by proprietary extensions."@en ; +. + +### https://admin-shell.io/aas/3/0/HasExtensions/extensions + rdf:type owl:ObjectProperty ; + rdfs:label "has extensions"^^xs:string ; + rdfs:domain aas:HasExtensions ; + rdfs:range aas:Extension ; + rdfs:comment "An extension of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/HasKind +aas:HasKind rdf:type owl:Class ; + rdfs:label "Has Kind"^^xs:string ; + rdfs:comment "An element with a kind is an element that can either represent a template or an instance."@en ; +. + +### https://admin-shell.io/aas/3/0/HasKind/kind + rdf:type owl:ObjectProperty ; + rdfs:label "has kind"^^xs:string ; + rdfs:domain aas:HasKind ; + rdfs:range aas:ModellingKind ; + rdfs:comment "Kind of the element: either type or instance."@en ; +. + +### https://admin-shell.io/aas/3/0/HasSemantics +aas:HasSemantics rdf:type owl:Class ; + rdfs:label "Has Semantics"^^xs:string ; + rdfs:comment "Element that can have a semantic definition plus some supplemental semantic definitions."@en ; +. + +### https://admin-shell.io/aas/3/0/HasSemantics/semanticId + rdf:type owl:ObjectProperty ; + rdfs:label "has semantic ID"^^xs:string ; + rdfs:domain aas:HasSemantics ; + rdfs:range aas:Reference ; + rdfs:comment "Identifier of the semantic definition of the element. It is called semantic ID of the element or also main semantic ID of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds + rdf:type owl:ObjectProperty ; + rdfs:label "has supplemental semantic IDs"^^xs:string ; + rdfs:domain aas:HasSemantics ; + rdfs:range aas:Reference ; + rdfs:comment "Identifier of a supplemental semantic definition of the element. It is called supplemental semantic ID of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Identifiable +aas:Identifiable rdf:type owl:Class ; + rdfs:subClassOf aas:Referable ; + rdfs:label "Identifiable"^^xs:string ; + rdfs:comment "An element that has a globally unique identifier."@en ; +. + +### https://admin-shell.io/aas/3/0/Identifiable/administration + rdf:type owl:ObjectProperty ; + rdfs:label "has administration"^^xs:string ; + rdfs:domain aas:Identifiable ; + rdfs:range aas:AdministrativeInformation ; + rdfs:comment "Administrative information of an identifiable element."@en ; +. + +### https://admin-shell.io/aas/3/0/Identifiable/id + rdf:type owl:DatatypeProperty ; + rdfs:label "has ID"^^xs:string ; + rdfs:domain aas:Identifiable ; + rdfs:range xs:string ; + rdfs:comment "The globally unique identification of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Key +aas:Key rdf:type owl:Class ; + rdfs:label "Key"^^xs:string ; + rdfs:comment "A key is a reference to an element by its ID."@en ; +. + +### https://admin-shell.io/aas/3/0/Key/type + rdf:type owl:ObjectProperty ; + rdfs:label "has type"^^xs:string ; + rdfs:domain aas:Key ; + rdfs:range aas:KeyTypes ; + rdfs:comment "Denotes which kind of entity is referenced."@en ; +. + +### https://admin-shell.io/aas/3/0/Key/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:Key ; + rdfs:range xs:string ; + rdfs:comment "The key value, for example an IRDI or an URI"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes +aas:KeyTypes rdf:type owl:Class ; + rdfs:label "Key Types"^^xs:string ; + rdfs:comment "Enumeration of different key value types within a key."@en ; + owl:oneOf ( + + + + + + + + + + + + + + + + + + + + + + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/AnnotatedRelationshipElement + rdf:type aas:KeyTypes ; + rdfs:label "Annotated Relationship Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/AssetAdministrationShell + rdf:type aas:KeyTypes ; + rdfs:label "Asset Administration Shell"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/BasicEventElement + rdf:type aas:KeyTypes ; + rdfs:label "Basic Event Element"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Blob + rdf:type aas:KeyTypes ; + rdfs:label "Blob"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Capability + rdf:type aas:KeyTypes ; + rdfs:label "Capability"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/ConceptDescription + rdf:type aas:KeyTypes ; + rdfs:label "Concept Description"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/DataElement + rdf:type aas:KeyTypes ; + rdfs:label "Data Element"^^xs:string ; + rdfs:comment "Data element."@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Entity + rdf:type aas:KeyTypes ; + rdfs:label "Entity"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/EventElement + rdf:type aas:KeyTypes ; + rdfs:label "Event Element"^^xs:string ; + rdfs:comment "Event."@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/File + rdf:type aas:KeyTypes ; + rdfs:label "File"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/FragmentReference + rdf:type aas:KeyTypes ; + rdfs:label "Fragment Reference"^^xs:string ; + rdfs:comment "Bookmark or a similar local identifier of a subordinate part of a primary resource"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/GlobalReference + rdf:type aas:KeyTypes ; + rdfs:label "Global Reference"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Identifiable + rdf:type aas:KeyTypes ; + rdfs:label "Identifiable"^^xs:string ; + rdfs:comment "Identifiable."@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/MultiLanguageProperty + rdf:type aas:KeyTypes ; + rdfs:label "Multi Language Property"^^xs:string ; + rdfs:comment "Property with a value that can be provided in multiple languages"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Operation + rdf:type aas:KeyTypes ; + rdfs:label "Operation"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Property + rdf:type aas:KeyTypes ; + rdfs:label "Property"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Range + rdf:type aas:KeyTypes ; + rdfs:label "Range"^^xs:string ; + rdfs:comment "Range with min and max"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Referable + rdf:type aas:KeyTypes ; + rdfs:label "Referable"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/ReferenceElement + rdf:type aas:KeyTypes ; + rdfs:label "Reference Element"^^xs:string ; + rdfs:comment "Reference"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/RelationshipElement + rdf:type aas:KeyTypes ; + rdfs:label "Relationship Element"^^xs:string ; + rdfs:comment "Relationship"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/Submodel + rdf:type aas:KeyTypes ; + rdfs:label "Submodel"^^xs:string ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/SubmodelElement + rdf:type aas:KeyTypes ; + rdfs:label "Submodel Element"^^xs:string ; + rdfs:comment "Submodel Element"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/SubmodelElementCollection + rdf:type aas:KeyTypes ; + rdfs:label "Submodel Element Collection"^^xs:string ; + rdfs:comment "Struct of Submodel Elements"@en ; +. + +### https://admin-shell.io/aas/3/0/KeyTypes/SubmodelElementList + rdf:type aas:KeyTypes ; + rdfs:label "Submodel Element List"^^xs:string ; + rdfs:comment "List of Submodel Elements"@en ; +. + +### https://admin-shell.io/aas/3/0/LangStringDefinitionTypeIec61360 +aas:LangStringDefinitionTypeIec61360 rdf:type owl:Class ; + rdfs:subClassOf aas:AbstractLangString ; + rdfs:label "Lang String Definition Type IEC 61360"^^xs:string ; + rdfs:comment "String with length 1023 maximum and minimum 1 characters and with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/LangStringNameType +aas:LangStringNameType rdf:type owl:Class ; + rdfs:subClassOf aas:AbstractLangString ; + rdfs:label "Lang String Name Type"^^xs:string ; + rdfs:comment "String with length 128 maximum and minimum 1 characters and with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/LangStringPreferredNameTypeIec61360 +aas:LangStringPreferredNameTypeIec61360 rdf:type owl:Class ; + rdfs:subClassOf aas:AbstractLangString ; + rdfs:label "Lang String Preferred Name Type IEC 61360"^^xs:string ; + rdfs:comment "String with length 255 maximum and minimum 1 characters and with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/LangStringShortNameTypeIec61360 +aas:LangStringShortNameTypeIec61360 rdf:type owl:Class ; + rdfs:subClassOf aas:AbstractLangString ; + rdfs:label "Lang String Short Name Type IEC 61360"^^xs:string ; + rdfs:comment "String with length 18 maximum and minimum 1 characters and with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/LangStringTextType +aas:LangStringTextType rdf:type owl:Class ; + rdfs:subClassOf aas:AbstractLangString ; + rdfs:label "Lang String Text Type"^^xs:string ; + rdfs:comment "String with length 1023 maximum and minimum 1 characters and with language tags"@en ; +. + +### https://admin-shell.io/aas/3/0/LevelType +aas:LevelType rdf:type owl:Class ; + rdfs:label "Level Type"^^xs:string ; + rdfs:comment "Value represented by up to four variants of a numeric value in a specific role: MIN, NOM, TYP and MAX. True means that the value is available, false means the value is not available."@en ; +. + +### https://admin-shell.io/aas/3/0/LevelType/max + rdf:type owl:DatatypeProperty ; + rdfs:label "has max"^^xs:string ; + rdfs:domain aas:LevelType ; + rdfs:range xs:boolean ; + rdfs:comment "Maximum of the value"@en ; +. + +### https://admin-shell.io/aas/3/0/LevelType/min + rdf:type owl:DatatypeProperty ; + rdfs:label "has min"^^xs:string ; + rdfs:domain aas:LevelType ; + rdfs:range xs:boolean ; + rdfs:comment "Minimum of the value"@en ; +. + +### https://admin-shell.io/aas/3/0/LevelType/nom + rdf:type owl:DatatypeProperty ; + rdfs:label "has nom"^^xs:string ; + rdfs:domain aas:LevelType ; + rdfs:range xs:boolean ; + rdfs:comment "Nominal value (value as designated)"@en ; +. + +### https://admin-shell.io/aas/3/0/LevelType/typ + rdf:type owl:DatatypeProperty ; + rdfs:label "has typ"^^xs:string ; + rdfs:domain aas:LevelType ; + rdfs:range xs:boolean ; + rdfs:comment "Value as typically present"@en ; +. + +### https://admin-shell.io/aas/3/0/ModellingKind +aas:ModellingKind rdf:type owl:Class ; + rdfs:label "Modelling Kind"^^xs:string ; + rdfs:comment "Enumeration for denoting whether an element is a template or an instance."@en ; + owl:oneOf ( + + + ) ; +. + +### https://admin-shell.io/aas/3/0/ModellingKind/Instance + rdf:type aas:ModellingKind ; + rdfs:label "Instance"^^xs:string ; + rdfs:comment "Concrete, clearly identifiable element instance. Its creation and validation may be guided by a corresponding element template."@en ; +. + +### https://admin-shell.io/aas/3/0/ModellingKind/Template + rdf:type aas:ModellingKind ; + rdfs:label "Template"^^xs:string ; + rdfs:comment "Specification of the common features of a structured element in sufficient detail that such a instance can be instantiated using it"@en ; +. + +### https://admin-shell.io/aas/3/0/MultiLanguageProperty +aas:MultiLanguageProperty rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "Multi Language Property"^^xs:string ; + rdfs:comment "A property is a data element that has a multi-language value."@en ; +. + +### https://admin-shell.io/aas/3/0/MultiLanguageProperty/value + rdf:type owl:ObjectProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:MultiLanguageProperty ; + rdfs:range aas:LangStringTextType ; + rdfs:comment "The value of the property instance."@en ; +. + +### https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId + rdf:type owl:ObjectProperty ; + rdfs:label "has value ID"^^xs:string ; + rdfs:domain aas:MultiLanguageProperty ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the global unique ID of a coded value."@en ; +. + +### https://admin-shell.io/aas/3/0/Operation +aas:Operation rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Operation"^^xs:string ; + rdfs:comment "An operation is a submodel element with input and output variables."@en ; +. + +### https://admin-shell.io/aas/3/0/Operation/inoutputVariables + rdf:type owl:ObjectProperty ; + rdfs:label "has inoutput variables"^^xs:string ; + rdfs:domain aas:Operation ; + rdfs:range aas:OperationVariable ; + rdfs:comment "Parameter that is input and output of the operation."@en ; +. + +### https://admin-shell.io/aas/3/0/Operation/inputVariables + rdf:type owl:ObjectProperty ; + rdfs:label "has input variables"^^xs:string ; + rdfs:domain aas:Operation ; + rdfs:range aas:OperationVariable ; + rdfs:comment "Input parameter of the operation."@en ; +. + +### https://admin-shell.io/aas/3/0/Operation/outputVariables + rdf:type owl:ObjectProperty ; + rdfs:label "has output variables"^^xs:string ; + rdfs:domain aas:Operation ; + rdfs:range aas:OperationVariable ; + rdfs:comment "Output parameter of the operation."@en ; +. + +### https://admin-shell.io/aas/3/0/OperationVariable +aas:OperationVariable rdf:type owl:Class ; + rdfs:label "Operation Variable"^^xs:string ; + rdfs:comment "The value of an operation variable is a submodel element that is used as input and/or output variable of an operation."@en ; +. + +### https://admin-shell.io/aas/3/0/OperationVariable/value + rdf:type owl:ObjectProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:OperationVariable ; + rdfs:range aas:SubmodelElement ; + rdfs:comment "Describes an argument or result of an operation via a submodel element"@en ; +. + +### https://admin-shell.io/aas/3/0/Property +aas:Property rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "Property"^^xs:string ; + rdfs:comment "A property is a data element that has a single value."@en ; +. + +### https://admin-shell.io/aas/3/0/Property/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:Property ; + rdfs:range xs:string ; + rdfs:comment "The value of the property instance."@en ; +. + +### https://admin-shell.io/aas/3/0/Property/valueId + rdf:type owl:ObjectProperty ; + rdfs:label "has value ID"^^xs:string ; + rdfs:domain aas:Property ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the global unique ID of a coded value."@en ; +. + +### https://admin-shell.io/aas/3/0/Property/valueType + rdf:type owl:ObjectProperty ; + rdfs:label "has value type"^^xs:string ; + rdfs:domain aas:Property ; + rdfs:range aas:DataTypeDefXsd ; + rdfs:comment "Data type of the value"@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifiable +aas:Qualifiable rdf:type owl:Class ; + rdfs:label "Qualifiable"^^xs:string ; + rdfs:comment "The value of a qualifiable element may be further qualified by one or more qualifiers."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifiable/qualifiers + rdf:type owl:ObjectProperty ; + rdfs:label "has qualifiers"^^xs:string ; + rdfs:domain aas:Qualifiable ; + rdfs:range aas:Qualifier ; + rdfs:comment "Additional qualification of a qualifiable element."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier +aas:Qualifier rdf:type owl:Class ; + rdfs:subClassOf aas:HasSemantics ; + rdfs:label "Qualifier"^^xs:string ; + rdfs:comment "A qualifier is a type-value-pair that makes additional statements w.r.t. the value of the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier/kind + rdf:type owl:ObjectProperty ; + rdfs:label "has kind"^^xs:string ; + rdfs:domain aas:Qualifier ; + rdfs:range aas:QualifierKind ; + rdfs:comment "The qualifier kind describes the kind of the qualifier that is applied to the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier/type + rdf:type owl:DatatypeProperty ; + rdfs:label "has type"^^xs:string ; + rdfs:domain aas:Qualifier ; + rdfs:range xs:string ; + rdfs:comment "The qualifier type describes the type of the qualifier that is applied to the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:Qualifier ; + rdfs:range xs:string ; + rdfs:comment "The qualifier value is the value of the qualifier."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier/valueId + rdf:type owl:ObjectProperty ; + rdfs:label "has value ID"^^xs:string ; + rdfs:domain aas:Qualifier ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the global unique ID of a coded value."@en ; +. + +### https://admin-shell.io/aas/3/0/Qualifier/valueType + rdf:type owl:ObjectProperty ; + rdfs:label "has value type"^^xs:string ; + rdfs:domain aas:Qualifier ; + rdfs:range aas:DataTypeDefXsd ; + rdfs:comment "Data type of the qualifier value."@en ; +. + +### https://admin-shell.io/aas/3/0/QualifierKind +aas:QualifierKind rdf:type owl:Class ; + rdfs:label "Qualifier Kind"^^xs:string ; + rdfs:comment "Enumeration for kinds of qualifiers."@en ; + owl:oneOf ( + + + + ) ; +. + +### https://admin-shell.io/aas/3/0/QualifierKind/ConceptQualifier + rdf:type aas:QualifierKind ; + rdfs:label "Concept Qualifier"^^xs:string ; + rdfs:comment "qualifies the semantic definition the element is referring to ('semanticId')"@en ; +. + +### https://admin-shell.io/aas/3/0/QualifierKind/TemplateQualifier + rdf:type aas:QualifierKind ; + rdfs:label "Template Qualifier"^^xs:string ; + rdfs:comment "qualifies the elements within a specific submodel on concept level."@en ; +. + +### https://admin-shell.io/aas/3/0/QualifierKind/ValueQualifier + rdf:type aas:QualifierKind ; + rdfs:label "Value Qualifier"^^xs:string ; + rdfs:comment "qualifies the value of the element and can change during run-time."@en ; +. + +### https://admin-shell.io/aas/3/0/Range +aas:Range rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "Range"^^xs:string ; + rdfs:comment "A range data element is a data element that defines a range with min and max."@en ; +. + +### https://admin-shell.io/aas/3/0/Range/max + rdf:type owl:DatatypeProperty ; + rdfs:label "has max"^^xs:string ; + rdfs:domain aas:Range ; + rdfs:range xs:string ; + rdfs:comment "The maximum value of the range."@en ; +. + +### https://admin-shell.io/aas/3/0/Range/min + rdf:type owl:DatatypeProperty ; + rdfs:label "has min"^^xs:string ; + rdfs:domain aas:Range ; + rdfs:range xs:string ; + rdfs:comment "The minimum value of the range."@en ; +. + +### https://admin-shell.io/aas/3/0/Range/valueType + rdf:type owl:ObjectProperty ; + rdfs:label "has value type"^^xs:string ; + rdfs:domain aas:Range ; + rdfs:range aas:DataTypeDefXsd ; + rdfs:comment "Data type of the min und max"@en ; +. + +### https://admin-shell.io/aas/3/0/Referable +aas:Referable rdf:type owl:Class ; + rdfs:subClassOf aas:HasExtensions ; + rdfs:label "Referable"^^xs:string ; + rdfs:comment "An element that is referable by its 'idShort'."@en ; +. + +### https://admin-shell.io/aas/3/0/Referable/category + rdf:type owl:DatatypeProperty ; + rdfs:label "has category"^^xs:string ; + rdfs:domain aas:Referable ; + rdfs:range xs:string ; + rdfs:comment "The category is a value that gives further meta information w.r.t. to the class of the element. It affects the expected existence of attributes and the applicability of constraints."@en ; +. + +### https://admin-shell.io/aas/3/0/Referable/description + rdf:type owl:ObjectProperty ; + rdfs:label "has description"^^xs:string ; + rdfs:domain aas:Referable ; + rdfs:range aas:LangStringTextType ; + rdfs:comment "Description or comments on the element."@en ; +. + +### https://admin-shell.io/aas/3/0/Referable/displayName + rdf:type owl:ObjectProperty ; + rdfs:label "has display name"^^xs:string ; + rdfs:domain aas:Referable ; + rdfs:range aas:LangStringNameType ; + rdfs:comment "Display name. Can be provided in several languages."@en ; +. + +### https://admin-shell.io/aas/3/0/Referable/idShort + rdf:type owl:DatatypeProperty ; + rdfs:label "has ID short"^^xs:string ; + rdfs:domain aas:Referable ; + rdfs:range xs:string ; + rdfs:comment "In case of identifiables this attribute is a short name of the element. In case of referable this ID is an identifying string of the element within its name space."@en ; +. + +### https://admin-shell.io/aas/3/0/Reference +aas:Reference rdf:type owl:Class ; + rdfs:label "Reference"^^xs:string ; + rdfs:comment "Reference to either a model element of the same or another AAS or to an external entity."@en ; +. + +### https://admin-shell.io/aas/3/0/Reference/keys + rdf:type owl:ObjectProperty ; + rdfs:label "has keys"^^xs:string ; + rdfs:domain aas:Reference ; + rdfs:range aas:Key ; + rdfs:comment "Unique references in their name space."@en ; +. + +### https://admin-shell.io/aas/3/0/Reference/referredSemanticId + rdf:type owl:ObjectProperty ; + rdfs:label "has referred semantic ID"^^xs:string ; + rdfs:domain aas:Reference ; + rdfs:range aas:Reference ; + rdfs:comment "'semanticId' of the referenced model element ('type' = 'ModelReference')."@en ; +. + +### https://admin-shell.io/aas/3/0/Reference/type + rdf:type owl:ObjectProperty ; + rdfs:label "has type"^^xs:string ; + rdfs:domain aas:Reference ; + rdfs:range aas:ReferenceTypes ; + rdfs:comment "Type of the reference."@en ; +. + +### https://admin-shell.io/aas/3/0/ReferenceElement +aas:ReferenceElement rdf:type owl:Class ; + rdfs:subClassOf aas:DataElement ; + rdfs:label "Reference Element"^^xs:string ; + rdfs:comment "A reference element is a data element that defines a logical reference to another element within the same or another AAS or a reference to an external object or entity."@en ; +. + +### https://admin-shell.io/aas/3/0/ReferenceElement/value + rdf:type owl:ObjectProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:ReferenceElement ; + rdfs:range aas:Reference ; + rdfs:comment "Global reference to an external object or entity or a logical reference to another element within the same or another AAS (i.e. a model reference to a Referable)."@en ; +. + +### https://admin-shell.io/aas/3/0/ReferenceTypes +aas:ReferenceTypes rdf:type owl:Class ; + rdfs:label "Reference Types"^^xs:string ; + rdfs:comment "Reference types"@en ; + owl:oneOf ( + + + ) ; +. + +### https://admin-shell.io/aas/3/0/ReferenceTypes/ExternalReference + rdf:type aas:ReferenceTypes ; + rdfs:label "External Reference"^^xs:string ; + rdfs:comment "External reference."@en ; +. + +### https://admin-shell.io/aas/3/0/ReferenceTypes/ModelReference + rdf:type aas:ReferenceTypes ; + rdfs:label "Model Reference"^^xs:string ; + rdfs:comment "Model reference."@en ; +. + +### https://admin-shell.io/aas/3/0/RelationshipElement +aas:RelationshipElement rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Relationship Element"^^xs:string ; + rdfs:comment "A relationship element is used to define a relationship between two elements being either referable (model reference) or external (global reference)."@en ; +. + +### https://admin-shell.io/aas/3/0/RelationshipElement/first + rdf:type owl:ObjectProperty ; + rdfs:label "has first"^^xs:string ; + rdfs:domain aas:RelationshipElement ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the first element in the relationship taking the role of the subject."@en ; +. + +### https://admin-shell.io/aas/3/0/RelationshipElement/second + rdf:type owl:ObjectProperty ; + rdfs:label "has second"^^xs:string ; + rdfs:domain aas:RelationshipElement ; + rdfs:range aas:Reference ; + rdfs:comment "Reference to the second element in the relationship taking the role of the object."@en ; +. + +### https://admin-shell.io/aas/3/0/Resource +aas:Resource rdf:type owl:Class ; + rdfs:label "Resource"^^xs:string ; + rdfs:comment "Resource represents an address to a file (a locator). The value is an URI that can represent an absolute or relative path"@en ; +. + +### https://admin-shell.io/aas/3/0/Resource/contentType + rdf:type owl:DatatypeProperty ; + rdfs:label "has content type"^^xs:string ; + rdfs:domain aas:Resource ; + rdfs:range xs:string ; + rdfs:comment "Content type of the content of the file."@en ; +. + +### https://admin-shell.io/aas/3/0/Resource/path + rdf:type owl:DatatypeProperty ; + rdfs:label "has path"^^xs:string ; + rdfs:domain aas:Resource ; + rdfs:range xs:string ; + rdfs:comment "Path and name of the resource (with file extension)."@en ; +. + +### https://admin-shell.io/aas/3/0/SpecificAssetId +aas:SpecificAssetId rdf:type owl:Class ; + rdfs:subClassOf aas:HasSemantics ; + rdfs:label "Specific Asset ID"^^xs:string ; + rdfs:comment "A specific asset ID describes a generic supplementary identifying attribute of the asset."@en ; +. + +### https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId + rdf:type owl:ObjectProperty ; + rdfs:label "has external subject ID"^^xs:string ; + rdfs:domain aas:SpecificAssetId ; + rdfs:range aas:Reference ; + rdfs:comment "The (external) subject the key belongs to or has meaning to."@en ; +. + +### https://admin-shell.io/aas/3/0/SpecificAssetId/name + rdf:type owl:DatatypeProperty ; + rdfs:label "has name"^^xs:string ; + rdfs:domain aas:SpecificAssetId ; + rdfs:range xs:string ; + rdfs:comment "Name of the identifier"@en ; +. + +### https://admin-shell.io/aas/3/0/SpecificAssetId/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:SpecificAssetId ; + rdfs:range xs:string ; + rdfs:comment "The value of the specific asset identifier with the corresponding name."@en ; +. + +### https://admin-shell.io/aas/3/0/StateOfEvent +aas:StateOfEvent rdf:type owl:Class ; + rdfs:label "State Of Event"^^xs:string ; + rdfs:comment "State of an event"@en ; + owl:oneOf ( + + + ) ; +. + +### https://admin-shell.io/aas/3/0/StateOfEvent/Off + rdf:type aas:StateOfEvent ; + rdfs:label "Off"^^xs:string ; + rdfs:comment "Event is off."@en ; +. + +### https://admin-shell.io/aas/3/0/StateOfEvent/On + rdf:type aas:StateOfEvent ; + rdfs:label "On"^^xs:string ; + rdfs:comment "Event is on"@en ; +. + +### https://admin-shell.io/aas/3/0/Submodel +aas:Submodel rdf:type owl:Class ; + rdfs:subClassOf aas:Identifiable ; + rdfs:subClassOf aas:HasKind ; + rdfs:subClassOf aas:HasSemantics ; + rdfs:subClassOf aas:Qualifiable ; + rdfs:subClassOf aas:HasDataSpecification ; + rdfs:label "Submodel"^^xs:string ; + rdfs:comment "A submodel defines a specific aspect of the asset represented by the AAS."@en ; +. + +### https://admin-shell.io/aas/3/0/Submodel/submodelElements + rdf:type owl:ObjectProperty ; + rdfs:label "has submodel elements"^^xs:string ; + rdfs:domain aas:Submodel ; + rdfs:range aas:SubmodelElement ; + rdfs:comment "A submodel consists of zero or more submodel elements."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElement +aas:SubmodelElement rdf:type owl:Class ; + rdfs:subClassOf aas:Referable ; + rdfs:subClassOf aas:HasSemantics ; + rdfs:subClassOf aas:Qualifiable ; + rdfs:subClassOf aas:HasDataSpecification ; + rdfs:label "Submodel Element"^^xs:string ; + rdfs:comment "A submodel element is an element suitable for the description and differentiation of assets."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementCollection +aas:SubmodelElementCollection rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Submodel Element Collection"^^xs:string ; + rdfs:comment "A submodel element collection is a kind of struct, i.e. a a logical encapsulation of multiple named values. It has a fixed number of submodel elements."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementCollection/value + rdf:type owl:ObjectProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:SubmodelElementCollection ; + rdfs:range aas:SubmodelElement ; + rdfs:comment "Submodel element contained in the collection."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList +aas:SubmodelElementList rdf:type owl:Class ; + rdfs:subClassOf aas:SubmodelElement ; + rdfs:label "Submodel Element List"^^xs:string ; + rdfs:comment "A submodel element list is an ordered list of submodel elements."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant + rdf:type owl:DatatypeProperty ; + rdfs:label "has order relevant"^^xs:string ; + rdfs:domain aas:SubmodelElementList ; + rdfs:range xs:boolean ; + rdfs:comment "Defines whether order in list is relevant. If 'orderRelevant' = False then the list is representing a set or a bag."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement + rdf:type owl:ObjectProperty ; + rdfs:label "has semantic ID list element"^^xs:string ; + rdfs:domain aas:SubmodelElementList ; + rdfs:range aas:Reference ; + rdfs:comment "Semantic ID the submodel elements contained in the list match to."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement + rdf:type owl:ObjectProperty ; + rdfs:label "has type value list element"^^xs:string ; + rdfs:domain aas:SubmodelElementList ; + rdfs:range aas:AasSubmodelElements ; + rdfs:comment "The submodel element type of the submodel elements contained in the list."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList/value + rdf:type owl:ObjectProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:SubmodelElementList ; + rdfs:range aas:SubmodelElement ; + rdfs:comment "Submodel element contained in the list."@en ; +. + +### https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement + rdf:type owl:ObjectProperty ; + rdfs:label "has value type list element"^^xs:string ; + rdfs:domain aas:SubmodelElementList ; + rdfs:range aas:DataTypeDefXsd ; + rdfs:comment "The value type of the submodel element contained in the list."@en ; +. + +### https://admin-shell.io/aas/3/0/ValueList +aas:ValueList rdf:type owl:Class ; + rdfs:label "Value List"^^xs:string ; + rdfs:comment "A set of value reference pairs."@en ; +. + +### https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs + rdf:type owl:ObjectProperty ; + rdfs:label "has value reference pairs"^^xs:string ; + rdfs:domain aas:ValueList ; + rdfs:range aas:ValueReferencePair ; + rdfs:comment "A pair of a value together with its global unique id."@en ; +. + +### https://admin-shell.io/aas/3/0/ValueReferencePair +aas:ValueReferencePair rdf:type owl:Class ; + rdfs:label "Value Reference Pair"^^xs:string ; + rdfs:comment "A value reference pair within a value list. Each value has a global unique id defining its semantic."@en ; +. + +### https://admin-shell.io/aas/3/0/ValueReferencePair/value + rdf:type owl:DatatypeProperty ; + rdfs:label "has value"^^xs:string ; + rdfs:domain aas:ValueReferencePair ; + rdfs:range xs:string ; + rdfs:comment "The value of the referenced concept definition of the value in 'valueId'."@en ; +. + +### https://admin-shell.io/aas/3/0/ValueReferencePair/valueId + rdf:type owl:ObjectProperty ; + rdfs:label "has value ID"^^xs:string ; + rdfs:domain aas:ValueReferencePair ; + rdfs:range aas:Reference ; + rdfs:comment "Global unique id of the value."@en ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/main/resources/shacl-schema-original.ttl b/dataformat-rdf/src/main/resources/shacl-schema-original.ttl new file mode 100644 index 000000000..03ec931db --- /dev/null +++ b/dataformat-rdf/src/main/resources/shacl-schema-original.ttl @@ -0,0 +1,1325 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xs: . + +# Metadata + a owl:Ontology ; + owl:imports ; + owl:imports sh: ; + sh:declare [ + a sh:PrefixDeclaration ; + sh:namespace "https://admin-shell.io/aas/3/0/"^^xs:anyURI ; + sh:prefix "aas"^^xs:string ; + ] ; +. + +aas:AbstractLangStringShape a sh:NodeShape ; + sh:targetClass aas:AbstractLangString ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(AbstractLangStringShape): An aas:AbstractLangString is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:AbstractLangString) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:pattern "^(([a-zA-Z]{2,3}(-[a-zA-Z]{3}(-[a-zA-Z]{3}){2})?|[a-zA-Z]{4}|[a-zA-Z]{5,8})(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-(([a-zA-Z0-9]){5,8}|[0-9]([a-zA-Z0-9]){3}))*(-[0-9A-WY-Za-wy-z](-([a-zA-Z0-9]){2,8})+)*(-[xX](-([a-zA-Z0-9]){1,8})+)?|[xX](-([a-zA-Z0-9]){1,8})+|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; +. + +aas:AdministrativeInformationShape a sh:NodeShape ; + sh:targetClass aas:AdministrativeInformation ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 4 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^(0|[1-9][0-9]*)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 4 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^(0|[1-9][0-9]*)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; +. + +aas:AnnotatedRelationshipElementShape a sh:NodeShape ; + sh:targetClass aas:AnnotatedRelationshipElement ; + rdfs:subClassOf aas:RelationshipElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataElement ; + sh:minCount 0 ; + ] ; +. + +aas:AssetAdministrationShellShape a sh:NodeShape ; + sh:targetClass aas:AssetAdministrationShell ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetInformation ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:AssetInformationShape a sh:NodeShape ; + sh:targetClass aas:AssetInformation ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetKind ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SpecificAssetId ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Resource ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:BasicEventElementShape a sh:NodeShape ; + sh:targetClass aas:BasicEventElement ; + rdfs:subClassOf aas:EventElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Direction ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:StateOfEvent ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 255 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))$" ; + ] ; +. + +aas:BlobShape a sh:NodeShape ; + sh:targetClass aas:Blob ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:base64Binary ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:CapabilityShape a sh:NodeShape ; + sh:targetClass aas:Capability ; + rdfs:subClassOf aas:SubmodelElementShape ; +. + +aas:ConceptDescriptionShape a sh:NodeShape ; + sh:targetClass aas:ConceptDescription ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:DataElementShape a sh:NodeShape ; + sh:targetClass aas:DataElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(DataElementShape): An aas:DataElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:DataElement) + } + """ ; + ] ; +. + +aas:DataSpecificationContentShape a sh:NodeShape ; + sh:targetClass aas:DataSpecificationContent ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(DataSpecificationContentShape): An aas:DataSpecificationContent is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:DataSpecificationContent) + } + """ ; + ] ; +. + +aas:DataSpecificationIec61360Shape a sh:NodeShape ; + sh:targetClass aas:DataSpecificationIec61360 ; + rdfs:subClassOf aas:DataSpecificationContentShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringPreferredNameTypeIec61360 ; + sh:minCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringShortNameTypeIec61360 ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeIec61360 ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringDefinitionTypeIec61360 ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ValueList ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LevelType ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:EmbeddedDataSpecificationShape a sh:NodeShape ; + sh:targetClass aas:EmbeddedDataSpecification ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataSpecificationContent ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:EntityShape a sh:NodeShape ; + sh:targetClass aas:Entity ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:EntityType ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SpecificAssetId ; + sh:minCount 0 ; + ] ; +. + +aas:EnvironmentShape a sh:NodeShape ; + sh:targetClass aas:Environment ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetAdministrationShell ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Submodel ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ConceptDescription ; + sh:minCount 0 ; + ] ; +. + +aas:EventElementShape a sh:NodeShape ; + sh:targetClass aas:EventElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(EventElementShape): An aas:EventElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:EventElement) + } + """ ; + ] ; +. + +aas:EventPayloadShape a sh:NodeShape ; + sh:targetClass aas:EventPayload ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 255 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:pattern "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:base64Binary ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:ExtensionShape a sh:NodeShape ; + sh:targetClass aas:Extension ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:FileShape a sh:NodeShape ; + sh:targetClass aas:File ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^file:(//((localhost|(\\[((([0-9A-Fa-f]{1,4}:){6}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::([0-9A-Fa-f]{1,4}:){5}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|([0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){4}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){3}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){2}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){2}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){4}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(([0-9A-Fa-f]{1,4}:){6}[0-9A-Fa-f]{1,4})?::)|[vV][0-9A-Fa-f]+\\.([a-zA-Z0-9\\-._~]|[!$&'()*+,;=]|:)+)\\]|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=])*)))?/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?|/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:HasDataSpecificationShape a sh:NodeShape ; + sh:targetClass aas:HasDataSpecification ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasDataSpecificationShape): An aas:HasDataSpecification is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasDataSpecification) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:EmbeddedDataSpecification ; + sh:minCount 0 ; + ] ; +. + +aas:HasExtensionsShape a sh:NodeShape ; + sh:targetClass aas:HasExtensions ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasExtensionsShape): An aas:HasExtensions is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasExtensions) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Extension ; + sh:minCount 0 ; + ] ; +. + +aas:HasKindShape a sh:NodeShape ; + sh:targetClass aas:HasKind ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasKindShape): An aas:HasKind is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasKind) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ModellingKind ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:HasSemanticsShape a sh:NodeShape ; + sh:targetClass aas:HasSemantics ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasSemanticsShape): An aas:HasSemantics is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasSemantics) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:IdentifiableShape a sh:NodeShape ; + sh:targetClass aas:Identifiable ; + rdfs:subClassOf aas:ReferableShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(IdentifiableShape): An aas:Identifiable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Identifiable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AdministrativeInformation ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; +. + +aas:KeyShape a sh:NodeShape ; + sh:targetClass aas:Key ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:KeyTypes ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; +. + +aas:LangStringDefinitionTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringDefinitionTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 1023 ; + ] ; +. + +aas:LangStringNameTypeShape a sh:NodeShape ; + sh:targetClass aas:LangStringNameType ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 128 ; + ] ; +. + +aas:LangStringPreferredNameTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringPreferredNameTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 255 ; + ] ; +. + +aas:LangStringShortNameTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringShortNameTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 18 ; + ] ; +. + +aas:LangStringTextTypeShape a sh:NodeShape ; + sh:targetClass aas:LangStringTextType ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 1023 ; + ] ; +. + +aas:LevelTypeShape a sh:NodeShape ; + sh:targetClass aas:LevelType ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:MultiLanguagePropertyShape a sh:NodeShape ; + sh:targetClass aas:MultiLanguageProperty ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringTextType ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:OperationShape a sh:NodeShape ; + sh:targetClass aas:Operation ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; +. + +aas:OperationVariableShape a sh:NodeShape ; + sh:targetClass aas:OperationVariable ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:PropertyShape a sh:NodeShape ; + sh:targetClass aas:Property ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:QualifiableShape a sh:NodeShape ; + sh:targetClass aas:Qualifiable ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(QualifiableShape): An aas:Qualifiable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Qualifiable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Qualifier ; + sh:minCount 0 ; + ] ; +. + +aas:QualifierShape a sh:NodeShape ; + sh:targetClass aas:Qualifier ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:QualifierKind ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:RangeShape a sh:NodeShape ; + sh:targetClass aas:Range ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:ReferableShape a sh:NodeShape ; + sh:targetClass aas:Referable ; + rdfs:subClassOf aas:HasExtensionsShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(ReferableShape): An aas:Referable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Referable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^[a-zA-Z][a-zA-Z0-9_]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringNameType ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringTextType ; + sh:minCount 0 ; + ] ; +. + +aas:ReferenceShape a sh:NodeShape ; + sh:targetClass aas:Reference ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ReferenceTypes ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Key ; + sh:minCount 1 ; + ] ; +. + +aas:ReferenceElementShape a sh:NodeShape ; + sh:targetClass aas:ReferenceElement ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:RelationshipElementShape a sh:NodeShape ; + sh:targetClass aas:RelationshipElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:ResourceShape a sh:NodeShape ; + sh:targetClass aas:Resource ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^file:(//((localhost|(\\[((([0-9A-Fa-f]{1,4}:){6}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::([0-9A-Fa-f]{1,4}:){5}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|([0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){4}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){3}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){2}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){2}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){4}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(([0-9A-Fa-f]{1,4}:){6}[0-9A-Fa-f]{1,4})?::)|[vV][0-9A-Fa-f]+\\.([a-zA-Z0-9\\-._~]|[!$&'()*+,;=]|:)+)\\]|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=])*)))?/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?|/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:SpecificAssetIdShape a sh:NodeShape ; + sh:targetClass aas:SpecificAssetId ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 64 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:SubmodelShape a sh:NodeShape ; + sh:targetClass aas:Submodel ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasKindShape ; + rdfs:subClassOf aas:HasSemanticsShape ; + rdfs:subClassOf aas:QualifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:SubmodelElementShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElement ; + rdfs:subClassOf aas:ReferableShape ; + rdfs:subClassOf aas:HasSemanticsShape ; + rdfs:subClassOf aas:QualifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(SubmodelElementShape): An aas:SubmodelElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:SubmodelElement) + } + """ ; + ] ; +. + +aas:SubmodelElementCollectionShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElementCollection ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:SubmodelElementListShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElementList ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AasSubmodelElements ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:ValueListShape a sh:NodeShape ; + sh:targetClass aas:ValueList ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ValueReferencePair ; + sh:minCount 1 ; + ] ; +. + +aas:ValueReferencePairShape a sh:NodeShape ; + sh:targetClass aas:ValueReferencePair ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/main/resources/shacl-schema.ttl b/dataformat-rdf/src/main/resources/shacl-schema.ttl new file mode 100644 index 000000000..145069e23 --- /dev/null +++ b/dataformat-rdf/src/main/resources/shacl-schema.ttl @@ -0,0 +1,1337 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xs: . + +# Metadata + a owl:Ontology ; + owl:imports ; + owl:imports sh: ; + sh:declare [ + a sh:PrefixDeclaration ; + sh:namespace "https://admin-shell.io/aas/3/0/"^^xs:anyURI ; + sh:prefix "aas"^^xs:string ; + ] ; +. + +aas:AbstractLangStringShape a sh:NodeShape ; + sh:targetClass aas:AbstractLangString ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(AbstractLangStringShape): An aas:AbstractLangString is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:AbstractLangString) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:pattern "^(([a-zA-Z]{2,3}(-[a-zA-Z]{3}(-[a-zA-Z]{3}){2})?|[a-zA-Z]{4}|[a-zA-Z]{5,8})(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-(([a-zA-Z0-9]){5,8}|[0-9]([a-zA-Z0-9]){3}))*(-[0-9A-WY-Za-wy-z](-([a-zA-Z0-9]){2,8})+)*(-[xX](-([a-zA-Z0-9]){1,8})+)?|[xX](-([a-zA-Z0-9]){1,8})+|((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)))$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; +. + +aas:AdministrativeInformationShape a sh:NodeShape ; + sh:targetClass aas:AdministrativeInformation ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 4 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$"; + sh:pattern "^(0|[1-9][0-9]*)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 4 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^(0|[1-9][0-9]*)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; +. + +aas:AnnotatedRelationshipElementShape a sh:NodeShape ; + sh:targetClass aas:AnnotatedRelationshipElement ; + rdfs:subClassOf aas:RelationshipElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataElement ; + sh:minCount 0 ; + ] ; +. + +aas:AssetAdministrationShellShape a sh:NodeShape ; + sh:targetClass aas:AssetAdministrationShell ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetInformation ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:AssetInformationShape a sh:NodeShape ; + sh:targetClass aas:AssetInformation ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetKind ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SpecificAssetId ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Resource ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:BasicEventElementShape a sh:NodeShape ; + sh:targetClass aas:BasicEventElement ; + rdfs:subClassOf aas:EventElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Direction ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:StateOfEvent ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 255 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:pattern "^-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))$" ; + ] ; +. + +aas:BlobShape a sh:NodeShape ; + sh:targetClass aas:Blob ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:base64Binary ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:CapabilityShape a sh:NodeShape ; + sh:targetClass aas:Capability ; + rdfs:subClassOf aas:SubmodelElementShape ; +. + +aas:ConceptDescriptionShape a sh:NodeShape ; + sh:targetClass aas:ConceptDescription ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:DataElementShape a sh:NodeShape ; + sh:targetClass aas:DataElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(DataElementShape): An aas:DataElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:DataElement) + } + """ ; + ] ; +. + +aas:DataSpecificationContentShape a sh:NodeShape ; + sh:targetClass aas:DataSpecificationContent ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(DataSpecificationContentShape): An aas:DataSpecificationContent is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:DataSpecificationContent) + } + """ ; + ] ; +. + +aas:DataSpecificationIec61360Shape a sh:NodeShape ; + sh:targetClass aas:DataSpecificationIec61360 ; + rdfs:subClassOf aas:DataSpecificationContentShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringPreferredNameTypeIec61360 ; + sh:minCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringShortNameTypeIec61360 ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeIec61360 ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringDefinitionTypeIec61360 ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ValueList ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LevelType ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:EmbeddedDataSpecificationShape a sh:NodeShape ; + sh:targetClass aas:EmbeddedDataSpecification ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataSpecificationContent ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:EntityShape a sh:NodeShape ; + sh:targetClass aas:Entity ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:EntityType ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SpecificAssetId ; + sh:minCount 0 ; + ] ; +. + +aas:EnvironmentShape a sh:NodeShape ; + sh:targetClass aas:Environment ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AssetAdministrationShell ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Submodel ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ConceptDescription ; + sh:minCount 0 ; + ] ; +. + +aas:EventElementShape a sh:NodeShape ; + sh:targetClass aas:EventElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(EventElementShape): An aas:EventElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:EventElement) + } + """ ; + ] ; +. + +aas:EventPayloadShape a sh:NodeShape ; + sh:targetClass aas:EventPayload ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 255 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:pattern "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:base64Binary ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:ExtensionShape a sh:NodeShape ; + sh:targetClass aas:Extension ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:FileShape a sh:NodeShape ; + sh:targetClass aas:File ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^file:(//((localhost|(\\[((([0-9A-Fa-f]{1,4}:){6}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::([0-9A-Fa-f]{1,4}:){5}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|([0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){4}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){3}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){2}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){2}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){4}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(([0-9A-Fa-f]{1,4}:){6}[0-9A-Fa-f]{1,4})?::)|[vV][0-9A-Fa-f]+\\.([a-zA-Z0-9\\-._~]|[!$&'()*+,;=]|:)+)\\]|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=])*)))?/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?|/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:HasDataSpecificationShape a sh:NodeShape ; + sh:targetClass aas:HasDataSpecification ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasDataSpecificationShape): An aas:HasDataSpecification is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasDataSpecification) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:EmbeddedDataSpecification ; + sh:minCount 0 ; + ] ; +. + +aas:HasExtensionsShape a sh:NodeShape ; + sh:targetClass aas:HasExtensions ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasExtensionsShape): An aas:HasExtensions is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasExtensions) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Extension ; + sh:minCount 0 ; + ] ; +. + +aas:HasKindShape a sh:NodeShape ; + sh:targetClass aas:HasKind ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasKindShape): An aas:HasKind is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasKind) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ModellingKind ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:HasSemanticsShape a sh:NodeShape ; + sh:targetClass aas:HasSemantics ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(HasSemanticsShape): An aas:HasSemantics is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:HasSemantics) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + ] ; +. + +aas:IdentifiableShape a sh:NodeShape ; + sh:targetClass aas:Identifiable ; + rdfs:subClassOf aas:ReferableShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(IdentifiableShape): An aas:Identifiable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Identifiable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AdministrativeInformation ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; +. + +aas:KeyShape a sh:NodeShape ; + sh:targetClass aas:Key ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:KeyTypes ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; +. + +aas:LangStringDefinitionTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringDefinitionTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 1023 ; + ] ; +. + +aas:LangStringNameTypeShape a sh:NodeShape ; + sh:targetClass aas:LangStringNameType ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 128 ; + ] ; +. + +aas:LangStringPreferredNameTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringPreferredNameTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 255 ; + ] ; +. + +aas:LangStringShortNameTypeIec61360Shape a sh:NodeShape ; + sh:targetClass aas:LangStringShortNameTypeIec61360 ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 18 ; + ] ; +. + +aas:LangStringTextTypeShape a sh:NodeShape ; + sh:targetClass aas:LangStringTextType ; + rdfs:subClassOf aas:AbstractLangStringShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:maxLength 1023 ; + ] ; +. + +aas:LevelTypeShape a sh:NodeShape ; + sh:targetClass aas:LevelType ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:MultiLanguagePropertyShape a sh:NodeShape ; + sh:targetClass aas:MultiLanguageProperty ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringTextType ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:OperationShape a sh:NodeShape ; + sh:targetClass aas:Operation ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:OperationVariable ; + sh:minCount 0 ; + ] ; +. + +aas:OperationVariableShape a sh:NodeShape ; + sh:targetClass aas:OperationVariable ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:PropertyShape a sh:NodeShape ; + sh:targetClass aas:Property ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:QualifiableShape a sh:NodeShape ; + sh:targetClass aas:Qualifiable ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(QualifiableShape): An aas:Qualifiable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Qualifiable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Qualifier ; + sh:minCount 0 ; + ] ; +. + +aas:QualifierShape a sh:NodeShape ; + sh:targetClass aas:Qualifier ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:QualifierKind ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:RangeShape a sh:NodeShape ; + sh:targetClass aas:Range ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:ReferableShape a sh:NodeShape ; + sh:targetClass aas:Referable ; + rdfs:subClassOf aas:HasExtensionsShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(ReferableShape): An aas:Referable is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:Referable) + } + """ ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 128 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^[a-zA-Z][a-zA-Z0-9_]*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringNameType ; + sh:minCount 0 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:LangStringTextType ; + sh:minCount 0 ; + ] ; +. + +aas:ReferenceShape a sh:NodeShape ; + sh:targetClass aas:Reference ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ReferenceTypes ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Key ; + sh:minCount 1 ; + ] ; +. + +aas:ReferenceElementShape a sh:NodeShape ; + sh:targetClass aas:ReferenceElement ; + rdfs:subClassOf aas:DataElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:RelationshipElementShape a sh:NodeShape ; + sh:targetClass aas:RelationshipElement ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. + +aas:ResourceShape a sh:NodeShape ; + sh:targetClass aas:Resource ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^file:(//((localhost|(\\[((([0-9A-Fa-f]{1,4}:){6}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::([0-9A-Fa-f]{1,4}:){5}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|([0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){4}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){3}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){2}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:){2}([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){4}[0-9A-Fa-f]{1,4})?::([0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(([0-9A-Fa-f]{1,4}:){5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(([0-9A-Fa-f]{1,4}:){6}[0-9A-Fa-f]{1,4})?::)|[vV][0-9A-Fa-f]+\\.([a-zA-Z0-9\\-._~]|[!$&'()*+,;=]|:)+)\\]|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=])*)))?/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?|/((([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))+(/(([a-zA-Z0-9\\-._~]|%[0-9A-Fa-f][0-9A-Fa-f]|[!$&'()*+,;=]|[:@]))*)*)?)$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 100 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + sh:pattern "^([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+/([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+([ ]*;[ ]*([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+=(([!#$%&'*+\\-.^_`|~0-9a-zA-Z])+|\"(([ !#-\\[\\]-~]|[\\x80-\\xff])|\\\\([ !-~]|[\\x80-\\xff]))*\"))*$" ; + ] ; +. + +aas:SpecificAssetIdShape a sh:NodeShape ; + sh:targetClass aas:SpecificAssetId ; + rdfs:subClassOf aas:HasSemanticsShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 64 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; +. + +aas:SubmodelShape a sh:NodeShape ; + sh:targetClass aas:Submodel ; + rdfs:subClassOf aas:IdentifiableShape ; + rdfs:subClassOf aas:HasKindShape ; + rdfs:subClassOf aas:HasSemanticsShape ; + rdfs:subClassOf aas:QualifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:SubmodelElementShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElement ; + rdfs:subClassOf aas:ReferableShape ; + rdfs:subClassOf aas:HasSemanticsShape ; + rdfs:subClassOf aas:QualifiableShape ; + rdfs:subClassOf aas:HasDataSpecificationShape ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "(SubmodelElementShape): An aas:SubmodelElement is an abstract class. Please use one of the subclasses for the generation of instances."@en ; + sh:prefixes aas: ; + sh:select """ + PREFIX rdf: + SELECT ?this ?type + WHERE { + ?this rdf:type ?type . + FILTER (?type = aas:SubmodelElement) + } + """ ; + ] ; +. + +aas:SubmodelElementCollectionShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElementCollection ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:SubmodelElementListShape a sh:NodeShape ; + sh:targetClass aas:SubmodelElementList ; + rdfs:subClassOf aas:SubmodelElementShape ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:boolean ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:AasSubmodelElements ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:DataTypeDefXsd ; + sh:minCount 0 ; + sh:maxCount 1 ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:SubmodelElement ; + sh:minCount 0 ; + ] ; +. + +aas:ValueListShape a sh:NodeShape ; + sh:targetClass aas:ValueList ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:ValueReferencePair ; + sh:minCount 1 ; + ] ; +. + +aas:ValueReferencePairShape a sh:NodeShape ; + sh:targetClass aas:ValueReferencePair ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:datatype xs:string ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:minLength 1 ; + sh:maxLength 2000 ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:path ; + sh:class aas:Reference ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java new file mode 100644 index 000000000..d97c1b92a --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java @@ -0,0 +1,51 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultAssetAdministrationShellRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class AssetAdministrationShellTest { + @Parameterized.Parameter + public AssetAdministrationShell shell; + + @Parameterized.Parameters(name = "{index}: Shell - {0}") + public static Object[] data() { + List list = new LinkedList<>(); + list.add(SerializerUtil.getMaximalAssetAdministrationShell()); + list.add(SerializerUtil.getMinimalAssetAdministrationShell()); + list.add(AASFull.AAS_1); + list.add(AASFull.AAS_2); + list.add(AASFull.AAS_3); + list.add(AASFull.AAS_4); + list.add(AASSimple.AAS); + return list.toArray(); + } + + + @Test + public void testAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = shell; + RDFSerializationResult rdfSerializationResult = new DefaultAssetAdministrationShellRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.AssetAdministrationShell); + + AssetAdministrationShell recreatedObject = new DefaultAssetAdministrationShellRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assertEquals(object, recreatedObject); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java new file mode 100644 index 000000000..4dfd9e272 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java @@ -0,0 +1,57 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class ConceptDescriptionTest { + + + @Parameterized.Parameter + public ConceptDescription concept; + + @Parameterized.Parameters(name = "{index}: CD - {0}") + public static Object[] data() { + List list = new LinkedList<>(); + list.add(SerializerUtil.getMinimalConceptDescription()); + list.add(SerializerUtil.getMaximalConceptDescription()); + list.add(AASFull.CONCEPT_DESCRIPTION_1); + list.add(AASFull.CONCEPT_DESCRIPTION_2); + list.add(AASFull.CONCEPT_DESCRIPTION_3); + list.add(AASFull.CONCEPT_DESCRIPTION_4); + list.add(AASSimple.CONCEPT_DESCRIPTION_DIGITALFILE); + list.add(AASSimple.CONCEPT_DESCRIPTION_TITLE); + list.add(AASSimple.CONCEPT_DESCRIPTION_DOCUMENT); + list.add(AASSimple.CONCEPT_DESCRIPTION_ROTATIONSPEED); + list.add(AASSimple.CONCEPT_DESCRIPTION_MAXROTATIONSPEED); + return list.toArray(); + } + + @Test + public void testConceptDescription() throws IncompatibleTypeException { + + ConceptDescription object = concept; + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.ConceptDescription); + + ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assertEquals(object, recreatedObject); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java new file mode 100644 index 000000000..50bd9aeec --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java @@ -0,0 +1,39 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.CustomSubProperty; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferableRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public class CustomClassTest { + + @Test + public void testCustomProperty() throws IncompatibleTypeException { + List one = new ArrayList<>(); + one.add("test"); + List two = new LinkedList<>(); + two.add("test"); + assert one.equals(two); + + + CustomSubProperty object = new CustomSubProperty(); + object.setIdShort("test"); + RDFSerializationResult rdfSerializationResult = new DefaultReferableRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + + Referable recreatedObject = new DefaultReferableRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assertEquals(object, recreatedObject); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java new file mode 100644 index 000000000..a14e9012e --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java @@ -0,0 +1,178 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultDataSpecificationIEC61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringShortNameTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLevelTypeRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultValueListRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.junit.Test; + +import java.util.List; + +import static org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.SerializerUtil.getDataSpecificationIec61360; + +public class DataSpecificationIec61360Test { + + @Test + public void testLevelType() throws IncompatibleTypeException { + LevelType levelType = new DefaultLevelType.Builder() + .max(true) + .min(false) + .typ(true) + .nom(false) + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultLevelTypeRDFHandler().toModel(levelType); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.LevelType); + assert model.containsLiteral(createdResource, AASNamespace.LevelType.max, levelType.getMax()); + assert model.containsLiteral(createdResource, AASNamespace.LevelType.min, levelType.getMin()); + assert model.containsLiteral(createdResource, AASNamespace.LevelType.typ, levelType.getTyp()); + assert model.containsLiteral(createdResource, AASNamespace.LevelType.nom, levelType.getNom()); + + LevelType recreatedLevelType = new DefaultLevelTypeRDFHandler().fromModel(model, createdResource); + assert levelType.equals(recreatedLevelType); + } + + @Test + public void testEmbeddedDataSpecification() throws IncompatibleTypeException { + EmbeddedDataSpecification object = SerializerUtil.getEmbeddedDataSpecifications(); + RDFSerializationResult rdfSerializationResult = new DefaultEmbeddedDataSpecificationRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + EmbeddedDataSpecification recreatedObject = new DefaultEmbeddedDataSpecificationRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + + } + + @Test + public void testMaximalEmbeddedDataSpecification() throws IncompatibleTypeException { + EmbeddedDataSpecification object = SerializerUtil.getMaximalEmbeddedDataSpecifications(); + RDFSerializationResult rdfSerializationResult = new DefaultEmbeddedDataSpecificationRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + EmbeddedDataSpecification recreatedObject = new DefaultEmbeddedDataSpecificationRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + + } + + @Test + public void testDataSpecificationIec61360() throws IncompatibleTypeException { + DataSpecificationIec61360 dataSpecificationIec61360 = new DefaultDataSpecificationIec61360.Builder() + .preferredName(List.of(new DefaultLangStringPreferredNameTypeIec61360.Builder() + .language("en") + .text("preferred name") + .build())) + .build(); + RDFSerializationResult rdfSerializationResult = new DefaultDataSpecificationIEC61360RDFHandler().toModel(dataSpecificationIec61360); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.DataSpecificationIec61360); + + DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert dataSpecificationIec61360.equals(recreatedDataSpecification); + } + + @Test + public void testLangStrings() throws IncompatibleTypeException { + DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() + .text("test") + .language("en") + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360); + assert model.containsLiteral(createdResource, AASNamespace.AbstractLangString.language, object.getLanguage()); + assert model.containsLiteral(createdResource, AASNamespace.AbstractLangString.text, object.getText()); + + LangStringShortNameTypeIec61360 recreatedObject = new DefaultLangStringShortNameTypeIec61360RDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testValueList() throws IncompatibleTypeException { + ValueList object = new DefaultValueList.Builder() + .valueReferencePairs(List.of( + new DefaultValueReferencePair.Builder() + .valueId(new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(List.of(new DefaultKey.Builder() + .value("Global1") + .type(KeyTypes.GLOBAL_REFERENCE) + .build())) + .build()) + .value("value1") + .build(), + new DefaultValueReferencePair.Builder() + .valueId(new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(List.of(new DefaultKey.Builder() + .value("Global2") + .type(KeyTypes.GLOBAL_REFERENCE) + .build())) + .build()) + .value("value2") + .build() + ) + ) + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultValueListRDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.ValueList); + + ValueList recreatedObject = new DefaultValueListRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMinimalDataSpecificationIec61360() throws IncompatibleTypeException { + DataSpecificationIec61360 object = new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.STRING) + .levelType(new DefaultLevelType.Builder() + .build()) + .build(); + RDFSerializationResult rdfSerializationResult = new DefaultDataSpecificationIEC61360RDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.DataSpecificationIec61360); + DataSpecificationIec61360 recreatedObject = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalDataSpecificationIec61360() throws IncompatibleTypeException { + DataSpecificationIec61360 object = getDataSpecificationIec61360(); + RDFSerializationResult rdfSerializationResult = new DefaultDataSpecificationIEC61360RDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.DataSpecificationIec61360); + DataSpecificationIec61360 recreatedObject = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java new file mode 100644 index 000000000..4437b4868 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java @@ -0,0 +1,52 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEnvironmentRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class EnvironmentTest { + @Parameterized.Parameter + public Environment environment; + + @Parameterized.Parameters(name = "{index}: Shell - {0}") + public static Object[] data() { + List list = new LinkedList<>(); +// list.add(SerializerUtil.getMaximalAssetAdministrationShell()); +// list.add(SerializerUtil.getMinimalAssetAdministrationShell()); + list.add(AASFull.createEnvironment()); + list.add(AASSimple.createEnvironment()); + return list.toArray(); + } + + @Test + public void testEnvironment() throws IncompatibleTypeException { + Environment object = environment; + RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Environment); + + Environment recreatedObject = new DefaultEnvironmentRDFHandler().fromModel(model, createdResource); + assertEquals(object.getConceptDescriptions().size(), + recreatedObject.getConceptDescriptions().size()); + assertEquals(object.getSubmodels().size(), + recreatedObject.getSubmodels().size()); + assertEquals(object.getAssetAdministrationShells().size(), + recreatedObject.getAssetAdministrationShells().size()); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java new file mode 100644 index 000000000..bfc09cd47 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java @@ -0,0 +1,4 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +public class RDFDeserializerTest { +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java new file mode 100644 index 000000000..b328ae158 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java @@ -0,0 +1,268 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; + +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.rdf.handlers.*; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.junit.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class RDFHandlersTest { + @Test + public void testKey() throws IOException, IncompatibleTypeException { + Key simpleKey = new DefaultKey.Builder() + .value("simple") + .type(KeyTypes.GLOBAL_REFERENCE) + .build(); + RDFSerializationResult rdfSerializationResult = new DefaultKeyRDFHandler().toModel(simpleKey); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Key); + assert rdfSerializationResult.getModel().contains(createdResource, AASNamespace.Key.value, simpleKey.getValue()); + assert rdfSerializationResult.getModel().contains(createdResource, AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(simpleKey.getType().name())); + + Key recreatedKey = new DefaultKeyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert simpleKey.equals(recreatedKey); + } + + @Test + public void testMinimalAdministrativeInformation() throws IncompatibleTypeException { + AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultAdministrativeInformationRDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.AdministrativeInformation); + + AdministrativeInformation recreatedObject = new DefaultAdministrativeInformationRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAdministrativeInformation() throws IncompatibleTypeException { + AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("1") + .templateId("template") + .creator(new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .value("Ref1") + .type(KeyTypes.GLOBAL_REFERENCE) + .build() + )) + .build() + ) + .embeddedDataSpecifications(SerializerUtil.getEmbeddedDataSpecifications()) + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultAdministrativeInformationRDFHandler().toModel(object); + + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.AdministrativeInformation); + + AdministrativeInformation recreatedObject = new DefaultAdministrativeInformationRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testReference() throws IncompatibleTypeException { + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.GLOBAL_REFERENCE) + .build(), + new DefaultKey.Builder() + .value("fragment") + .type(KeyTypes.FRAGMENT_REFERENCE) + .build())) + .build(); + RDFSerializationResult rdfSerializationResult = new DefaultReferenceRDFHandler().toModel(reference); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Reference); + + Reference recreatedKey = new DefaultReferenceRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert reference.equals(recreatedKey); + } +// +// @Test +// public void invalidEqualsLogic() { +// List withArraysAsList = Arrays.asList( +// new DefaultLangStringTextType.Builder().text("").language("en-us").build(), +// new DefaultLangStringTextType.Builder().text("Ein Beispiel-Teilmodell für eine Test-Anwendung").language("de").build() +// ); +// List withListOf = List.of( +// new DefaultLangStringTextType.Builder().text("An example submodel for the test application").language("en-us").build(), +// new DefaultLangStringTextType.Builder().text("Ein Beispiel-Teilmodell für eine Test-Anwendung").language("de").build() +// ); +// assert withListOf.equals(withArraysAsList); +// assertEquals(withListOf,withArraysAsList); +// } + + @Test + public void testExtension() throws IncompatibleTypeException { + Extension object = SerializerUtil.getMaximalExtension(); + RDFSerializationResult rdfSerializationResult = new DefaultExtensionRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Extension); + + Extension recreatedObject = new DefaultExtensionRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + + @Test + public void testMinimalQualifier() throws IncompatibleTypeException { + Qualifier object = SerializerUtil.getMinimalQualifier(); + RDFSerializationResult rdfSerializationResult = new DefaultQualifierRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Qualifier); + + Qualifier recreatedObject = new DefaultQualifierRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalQualifier() throws IncompatibleTypeException { + Qualifier object = SerializerUtil.getMaximalQualifier(); + RDFSerializationResult rdfSerializationResult = new DefaultQualifierRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Qualifier); + + Qualifier recreatedObject = new DefaultQualifierRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + + @Test + public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { + + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() + .id("test") + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .build()) + .description( + List.of( + new DefaultLangStringTextType.Builder() + .text("This is a test AAS") + .language("en-us").build())) + .displayName(List.of(new DefaultLangStringNameType.Builder() + .text("Anzeigename 2").language("de").build(), + new DefaultLangStringNameType.Builder().text("Display Name 1") + .language("en").build())).build(); + + Submodel submodel = new DefaultSubmodel.Builder() + .id("example") + .description( + List.of(new DefaultLangStringTextType.Builder() + .text("My Submodel") + .language("en-us") + .build())) + .displayName(List.of(new DefaultLangStringNameType.Builder() + .text("First Submodel Element name") + .language("en").build(), + new DefaultLangStringNameType.Builder() + .text("Second Submodel Element name") + .language("en").build())). + category("Example category").build(); + + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("concept1") + .embeddedDataSpecifications(new DefaultEmbeddedDataSpecification.Builder() + .dataSpecification( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.org") + .build()).build()) + .dataSpecificationContent( + new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.RATIONAL) + .build()).build()) + .build(); + + List aasList = new ArrayList<>(Collections.singletonList(aas)); + Environment aasEnv = new DefaultEnvironment.Builder().assetAdministrationShells(aasList).submodels(submodel).conceptDescriptions(conceptDescription).build(); + + String output = new RDFSerializer().write(aasEnv); + System.out.println(output); + } + + @Test + public void testMaximalSpecificAssetId() throws IncompatibleTypeException { + SpecificAssetId object = SerializerUtil.getMaximalSpecificAssetId(); + RDFSerializationResult rdfSerializationResult = new DefaultSpecificAssetIdRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.SpecificAssetId); + + SpecificAssetId recreatedObject = new DefaultSpecificAssetIdRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testResource() throws IncompatibleTypeException { + org.eclipse.digitaltwin.aas4j.v3.model.Resource object = SerializerUtil.getResource(); + RDFSerializationResult rdfSerializationResult = new DefaultResourceRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Resource); + + + org.eclipse.digitaltwin.aas4j.v3.model.Resource recreatedObject = new DefaultResourceRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMinimalAssetInformation() throws IncompatibleTypeException { + AssetInformation object = SerializerUtil.getMinimalAssetInformation(); + RDFSerializationResult rdfSerializationResult = new DefaultAssetInformationRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.AssetInformation); + + + AssetInformation recreatedObject = new DefaultAssetInformationRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAssetInformation() throws IncompatibleTypeException { + AssetInformation object = SerializerUtil.getMaximalAssetInformation(); + RDFSerializationResult rdfSerializationResult = new DefaultAssetInformationRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.AssetInformation); + + + AssetInformation recreatedObject = new DefaultAssetInformationRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java new file mode 100644 index 000000000..b24805f08 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java @@ -0,0 +1,4 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +public class RDFSerializerTest { +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java new file mode 100644 index 000000000..99d8e9749 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java @@ -0,0 +1,70 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.junit.Test; + +import java.util.Set; + +public class SchemaValidatorTest { + @Test + public void testSimpleKey(){ + String payload = "@prefix aas: .\n" + + "@prefix owl: .\n" + + "@prefix rdf: .\n" + + "@prefix rdfs: .\n" + + "@prefix xs: .\n" + + "\n" + + " rdf:type aas:AssetAdministrationShell ;\n" + + " [\n" + + " rdf:type aas:AdministrativeInformation ;\n" + + " [\n" + + " rdf:type aas:EmbeddedDataSpecification ;\n" + + " [\n" + + " rdf:type aas:Reference ;\n" + + " ;\n" + + " [\n" + + " rdf:type aas:Key ;\n" + + " ;\n" + + " \"urn:something14:18179b7a\"^^xs:string ;\n" + + " ] ;\n" + + " ] ;\n" + + " [\n" + + " rdf:type aas:DataSpecificationIec61360 ;\n" + + " [\n" + + " rdf:type aas:LangStringPreferredNameTypeIec61360 ;\n" + + " \"x-Sw4u3ZDO-nJLabnE\"^^xs:string ;\n" + + " \"something_7282cc23\"^^xs:string ;\n" + + " ] ;\n" + + " [\n" + + " rdf:type aas:LangStringPreferredNameTypeIec61360 ;\n" + + " \"en-UK\"^^xs:string ;\n" + + " \"Something random in English 0843a1d1\"^^xs:string ;\n" + + " ] ;\n" + + " \"something_bebf64f0\"^^xs:string ;\n" + + " ] ;\n" + + " ] ;\n" + + " \"1230\"^^xs:string ;\n" + + " \"0\"^^xs:string ;\n" + + " [\n" + + " rdf:type aas:Reference ;\n" + + " ;\n" + + " [\n" + + " rdf:type aas:Key ;\n" + + " ;\n" + + " \"urn:something11:6a596807\"^^xs:string ;\n" + + " ] ;\n" + + " ] ;\n" + + " \"something_cb08d136\"^^xs:string ;\n" + + " ] ;\n" + + " \"something_142922d6\"^^xs:string ;\n" + + " [\n" + + " rdf:type aas:AssetInformation ;\n" + + " ;\n" + + " \"something_eea66fa1\"^^xs:string ;\n" + + " ] ;\n" + + "."; + System.out.println(payload); + Set strings = new RDFSchemaValidator().validateSchema(payload); + assert strings.size() == 0; + + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java new file mode 100644 index 000000000..fe48499c7 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java @@ -0,0 +1,725 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + + +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; + +import java.util.Base64; +import java.util.List; + + +public class SerializerUtil { + public static ConceptDescription getMinimalConceptDescription() { + return new DefaultConceptDescription.Builder() + .id("simple") + .build(); + } + + public static ConceptDescription getMaximalConceptDescription() { + return new DefaultConceptDescription.Builder() + .id("complex") + .extensions(SerializerUtil.getExtensionList()) + .category("myCategory") + .idShort("exampleIdShort") + .displayName(SerializerUtil.getDisplayNames()) + .description(SerializerUtil.getDescriptions()) + .administration(SerializerUtil.getAdministrativeInformation()) + .isCaseOf(SerializerUtil.getIsCaseOfs()) + .embeddedDataSpecifications(SerializerUtil.getMaximalEmbeddedDataSpecifications()) + .build(); + } + + public static DataSpecificationIec61360 getDataSpecificationIec61360() { + return new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.STRING) + .value("exampleValue") + .symbol("g") + .unit("gram") + .sourceOfDefinition("external") + .valueList(new DefaultValueList.Builder() + .valueReferencePairs(List.of( + new DefaultValueReferencePair.Builder() + .value("refVal1") + .valueId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("externalKey1") + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .build() + , new DefaultValueReferencePair.Builder() + .value("refVal2") + .valueId(new DefaultReference.Builder() + .keys(List.of( + new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("externalKey2") + .build(), + new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value("fragment2") + .build() + )) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .build() + )) + .build() + ) + .definition(List.of( + new DefaultLangStringDefinitionTypeIec61360.Builder() + .text("definition1") + .language("en") + .build(), + new DefaultLangStringDefinitionTypeIec61360.Builder() + .text("definition2") + .language("de") + .build() + )) + .preferredName(List.of( + new DefaultLangStringPreferredNameTypeIec61360.Builder() + .text("preferred1") + .language("en") + .build(), + new DefaultLangStringPreferredNameTypeIec61360.Builder() + .text("preferred2") + .language("de") + .build() + )) + .shortName(List.of( + new DefaultLangStringShortNameTypeIec61360.Builder() + .text("short1") + .language("en") + .build(), + new DefaultLangStringShortNameTypeIec61360.Builder() + .text("short2") + .language("de") + .build() + )) + .levelType(new DefaultLevelType.Builder() + .build()) + .build(); + } + + public static EmbeddedDataSpecification getEmbeddedDataSpecifications() { + return new DefaultEmbeddedDataSpecification.Builder() + .dataSpecification( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0") + .type(KeyTypes.GLOBAL_REFERENCE).build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .dataSpecificationContent( + new DefaultDataSpecificationIec61360.Builder() + .levelType(new DefaultLevelType.Builder() + .max(true).min(true).nom(false).typ(false) + .build()) + .unit("gram") + .symbol("g") + .dataType(DataTypeIec61360.INTEGER_MEASURE).build()) + .build(); + } + + public static EmbeddedDataSpecification getMaximalEmbeddedDataSpecifications() { + return new DefaultEmbeddedDataSpecification.Builder() + .dataSpecification( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0") + .type(KeyTypes.GLOBAL_REFERENCE).build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .dataSpecificationContent(getDataSpecificationIec61360()) + .build(); + } + + static List getIsCaseOfs() { + return List.of( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.com/outside") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build()); + } + + static AdministrativeInformation getAdministrativeInformation() { + return new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .creator(getMaximalReference()) + .build(); + } + + static List getDescriptions() { + return List.of( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build()); + } + + static List getDisplayNames() { + return List.of( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build()); + } + + static Extension getMaximalExtension() { + return new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .valueType(DataTypeDefXsd.ANY_URI) + .refersTo(getMaximalReference()) + .semanticId(getMaximalReference()) + .supplementalSemanticIds(getMaximalReferenceList()) + .build(); + } + + static Reference getMinimalReference() { + return new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("minimal") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build(); + } + + static Reference getMaximalReference() { + return new DefaultReference.Builder().keys( + List.of(new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.GLOBAL_REFERENCE) + .build(), + new DefaultKey.Builder() + .value("fragment") + .type(KeyTypes.FRAGMENT_REFERENCE) + .build())) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build(); + } + + static List getMaximalReferenceList() { + return List.of( + getMaximalReference(), + getMinimalReference(), + new DefaultReference.Builder() + .keys( + List.of( + new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.SUBMODEL) + .build(), + new DefaultKey.Builder() + .value("property") + .type(KeyTypes.PROPERTY) + .build()) + ) + .type(ReferenceTypes.MODEL_REFERENCE) + .build(), + new DefaultReference.Builder() + .keys( + List.of( + new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.CONCEPT_DESCRIPTION) + .build()) + ) + .type(ReferenceTypes.MODEL_REFERENCE) + .build(), + new DefaultReference.Builder().keys( + List.of( + new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.SUBMODEL) + .build(), + new DefaultKey.Builder() + .value("ANNOTATED_RELATIONSHIP_ELEMENT") + .type(KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT) + .build()) + ) + .type(ReferenceTypes.MODEL_REFERENCE) + .build(), + new DefaultReference.Builder().keys( + List.of( + new DefaultKey.Builder() + .value("https://example.com") + .type(KeyTypes.SUBMODEL) + .build(), + new DefaultKey.Builder() + .value("BASIC_EVENT_ELEMENT") + .type(KeyTypes.BASIC_EVENT_ELEMENT) + .build()) + ) + .type(ReferenceTypes.MODEL_REFERENCE) + .build() + + ); + } + + static Qualifier getMinimalQualifier() { + return new DefaultQualifier.Builder() + .type("type1") + .valueType(DataTypeDefXsd.STRING) + .build(); + } + + static Qualifier getMaximalQualifier() { + return new DefaultQualifier.Builder() + .type("type1") + .kind(QualifierKind.CONCEPT_QUALIFIER) + .valueId(getMinimalReference()) + .supplementalSemanticIds(getMinimalReference()) + .semanticId(getMinimalReference()) + .value("value1") + .valueType(DataTypeDefXsd.STRING) + .build(); + } + + static SpecificAssetId getMaximalSpecificAssetId() { + return new DefaultSpecificAssetId.Builder() + .semanticId(getMinimalReference()) + .supplementalSemanticIds(getMinimalReference()) + .externalSubjectId(getMinimalReference()) + .name("name1") + .value("value1") + .build(); + } + + static SpecificAssetId getMinimalSpecificAssetId() { + return new DefaultSpecificAssetId.Builder() + .name("name1") + .value("value1") + .build(); + } + + static Property getMinimalProperty() { + return new DefaultProperty.Builder() + .idShort("idShort1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + + static List getMinimalSubmodelElementsList() { + return List.of( + SerializerUtil.getMinimalAnnotatedRelationshipElement(), + SerializerUtil.getMinimalBasicEventElement(), + SerializerUtil.getMinimalBlob(), + SerializerUtil.getMinimalCapability(), + SerializerUtil.getMinimalEntity(), + SerializerUtil.getMinimalFile(), + SerializerUtil.getMinimalMultiLanguageProperty(), + SerializerUtil.getMinimalOperation(), + SerializerUtil.getMinimalProperty(), + SerializerUtil.getMinimalRange(), + SerializerUtil.getMinimalReferenceElement(), + SerializerUtil.getMinimalRelationshipElement(), + SerializerUtil.getMinimalSubmodelElementCollection(), + SerializerUtil.getMinimalSubmodelElementList() + ); + } + + static List getMaximalSubmodelElementsList() { + return List.of( + SerializerUtil.getMaximalAnnotatedRelationshipElement(), + SerializerUtil.getMaximalBasicEventElement(), + SerializerUtil.getMaximalBlob(), + SerializerUtil.getMaximalCapability(), + SerializerUtil.getMaximalEntity(), + SerializerUtil.getMaximalFile(), + SerializerUtil.getMaximalMultiLanguageProperty(), + SerializerUtil.getMaximalOperation(), + SerializerUtil.getMaximalProperty(), + SerializerUtil.getMaximalRange(), + SerializerUtil.getMaximalReferenceElement(), + SerializerUtil.getMaximalRelationshipElement(), + SerializerUtil.getMaximalSubmodelElementCollection(), + SerializerUtil.getMaximalSubmodelElementList(), + SerializerUtil.getMaximalAnnotatedRelationshipElement(), + SerializerUtil.getMaximalBasicEventElement(), + SerializerUtil.getMaximalBlob(), + SerializerUtil.getMaximalCapability(), + SerializerUtil.getMaximalEntity(), + SerializerUtil.getMaximalFile(), + SerializerUtil.getMaximalMultiLanguageProperty(), + SerializerUtil.getMaximalOperation(), + SerializerUtil.getMaximalProperty(), + SerializerUtil.getMaximalRange(), + SerializerUtil.getMaximalReferenceElement(), + SerializerUtil.getMaximalRelationshipElement(), + SerializerUtil.getMaximalSubmodelElementCollection(), + SerializerUtil.getMaximalSubmodelElementList() + ); + } + + static Property getMaximalProperty() { + return new DefaultProperty.Builder() + .idShort("idShort1") + .valueType(DataTypeDefXsd.DECIMAL) + .value("12.2") + .valueId(getMinimalReference()) + .category("category1") + .description(getDescriptions()) + .displayName(getDisplayNames()) + .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) + .extensions(getMaximalExtension()) + .supplementalSemanticIds(getIsCaseOfs()) + .semanticId(getMinimalReference()) + .qualifiers(List.of(getMaximalQualifier(), getMinimalQualifier())) + .build(); + } + + static MultiLanguageProperty getMaximalMultiLanguageProperty() { + return new DefaultMultiLanguageProperty.Builder() + .idShort("MLP1") + .value(getDescriptions()) + .valueId(getMinimalReference()) + .category("category1") + .description(getDescriptions()) + .displayName(getDisplayNames()) + .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) + .extensions(getMaximalExtension()) + .supplementalSemanticIds(getIsCaseOfs()) + .semanticId(getMinimalReference()) + .qualifiers(List.of(getMaximalQualifier(), getMinimalQualifier())) + .build(); + + } + + static AnnotatedRelationshipElement getMinimalAnnotatedRelationshipElement() { + return new DefaultAnnotatedRelationshipElement.Builder() + .idShort("ARE1") + .first(new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("submodel_") + .build(), + new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("submodel_") + .build() + )).build()) + .second(new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .type(KeyTypes.CONCEPT_DESCRIPTION) + .value("concept_") + .build() + )).build()) + .build(); + } + + static AnnotatedRelationshipElement getMaximalAnnotatedRelationshipElement() { + return new DefaultAnnotatedRelationshipElement.Builder() + .idShort("ARE1_complex") + .first(new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("submodel_") + .build(), + new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("submodel_") + .build() + )).build()) + .second(new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(List.of( + new DefaultKey.Builder() + .type(KeyTypes.CONCEPT_DESCRIPTION) + .value("concept_") + .build() + )).build()) + .build(); + } + + static BasicEventElement getMinimalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .observed(getMinimalReference()) + .build(); + } + + static BasicEventElement getMaximalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .messageBroker(getMaximalReference()) + .messageTopic("topic") + .minInterval("1s") + .maxInterval("2s") + .lastUpdate("3s") + .semanticId(getMinimalReference()) + .observed(getMinimalReference()) + .build(); + } + + static Blob getMinimalBlob() { + return new DefaultBlob.Builder() + .idShort("B1") + .value(Base64.getDecoder().decode("aGVsbG8=")) // a `hello` in a text file + .contentType("plain/text") + .build(); + } + + static Blob getMaximalBlob() { + return new DefaultBlob.Builder() + .idShort("B1") + .value(Base64.getDecoder().decode("aGVsbG8=")) // a `hello` in a text file + .contentType("plain/text") + .build(); + } + + static Capability getMinimalCapability() { + return new DefaultCapability.Builder() + .idShort("C1") + .build(); + } + + static Capability getMaximalCapability() { + return new DefaultCapability.Builder() + .idShort("C1") + .build(); + } + + static Entity getMinimalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .build(); + } + + static Entity getMaximalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .statements(List.of(getMinimalProperty(), getMinimalAnnotatedRelationshipElement())) + .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) + .globalAssetId("global") + .specificAssetIds(getMaximalSpecificAssetId()) + .description(getDescriptions()) + .displayName(getDisplayNames()) + .qualifiers(getMaximalQualifier()) + .supplementalSemanticIds(getMaximalReferenceList()) + .build(); + } + + static File getMinimalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + + static File getMaximalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + + static Range getMinimalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + + static Range getMaximalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .max("19") + .min("10") + + .build(); + } + + static ReferenceElement getMinimalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .build(); + } + + static ReferenceElement getMaximalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .value(getMaximalReference()) + .build(); + } + + static RelationshipElement getMinimalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .build(); + } + + static RelationshipElement getMaximalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .first(getMaximalReference()) + .second(getMinimalReference()) + .build(); + } + + static SubmodelElementCollection getMinimalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("MinimalSubmodelElementCollection") + .build(); + } + + static SubmodelElementCollection getMaximalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("MaximalSubmodelElementCollection") + .value( + List.of( + getMinimalSubmodelElementCollection(), + getMaximalFile(), + getMinimalSubmodelElementCollection(), + SerializerUtil.getMinimalAnnotatedRelationshipElement(), + SerializerUtil.getMinimalBasicEventElement(), + SerializerUtil.getMinimalBlob(), + SerializerUtil.getMinimalCapability(), + SerializerUtil.getMinimalEntity(), + SerializerUtil.getMinimalFile(), + SerializerUtil.getMinimalMultiLanguageProperty(), + SerializerUtil.getMinimalOperation(), + SerializerUtil.getMinimalProperty(), + SerializerUtil.getMinimalRange(), + SerializerUtil.getMinimalReferenceElement(), + SerializerUtil.getMinimalRelationshipElement(), + SerializerUtil.getMinimalSubmodelElementCollection(), + SerializerUtil.getMinimalSubmodelElementList(), + SerializerUtil.getMaximalAnnotatedRelationshipElement(), + SerializerUtil.getMaximalBasicEventElement(), + SerializerUtil.getMaximalBlob(), + SerializerUtil.getMaximalCapability(), + SerializerUtil.getMaximalEntity(), + SerializerUtil.getMaximalFile(), + SerializerUtil.getMaximalMultiLanguageProperty(), + SerializerUtil.getMaximalOperation(), + SerializerUtil.getMaximalProperty(), + SerializerUtil.getMaximalRange(), + SerializerUtil.getMaximalReferenceElement(), + SerializerUtil.getMaximalRelationshipElement() + ) + ) + .build(); + } + + static SubmodelElementList getMinimalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .build(); + } + + static SubmodelElementList getMaximalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .semanticIdListElement(getMaximalReference()) + .valueTypeListElement(DataTypeDefXsd.STRING) + .build(); + } + + static Operation getMinimalOperation() { + return new DefaultOperation.Builder() + .idShort("O1") + .build(); + } + + static Operation getMaximalOperation() { + return new DefaultOperation.Builder() + .idShort("O1") + .build(); + } + + static MultiLanguageProperty getMinimalMultiLanguageProperty() { + return new DefaultMultiLanguageProperty.Builder() + .idShort("mlp1") + .build(); + } + + static Extension getMiniamlExtension() { + return new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build(); + } + + static Resource getResource() { + return new DefaultResource.Builder() + .path("path://") + .contentType("content/type") + .build(); + } + + static AssetInformation getMinimalAssetInformation() { + return new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .globalAssetId("global1") + .build(); + } + + static AssetInformation getMaximalAssetInformation() { + return new DefaultAssetInformation.Builder() + .assetKind(AssetKind.NOT_APPLICABLE) + .globalAssetId("global2") + .assetType("type2") + .specificAssetIds(getMaximalSpecificAssetId()) + .defaultThumbnail(new DefaultResource.Builder() + .contentType("image/png") + .path("s3://test.org") + .build()) + .build(); + } + + static AssetAdministrationShell getMinimalAssetAdministrationShell() { + return new DefaultAssetAdministrationShell.Builder() + .assetInformation(getMinimalAssetInformation()) + .id("AssetAdministrationShell_minimal") + .build(); + } + + static AssetAdministrationShell getMaximalAssetAdministrationShell() { + return new DefaultAssetAdministrationShell.Builder() + .assetInformation(getMaximalAssetInformation()) + .administration(getAdministrativeInformation()) + .category("category1") + .derivedFrom(getMinimalReference()) + .extensions(getMaximalExtension()) + .description(getDescriptions()) + .displayName(getDisplayNames()) + .embeddedDataSpecifications(getEmbeddedDataSpecifications()) + .submodels(getIsCaseOfs()) + .id("https://example.com") + .build(); + } + + + static List getExtensionList() { + return List.of( + getMaximalExtension(), + getMiniamlExtension()); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java new file mode 100644 index 000000000..5b80674fc --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java @@ -0,0 +1,42 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSubmodelElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class SubmodelElementTest { + @Parameter + public SubmodelElement submodelElement; + + @Parameters(name = "{index}: SME - {0}") + public static Object[] data() { + List list = new LinkedList<>(); + list.addAll(SerializerUtil.getMaximalSubmodelElementsList()); + list.addAll(SerializerUtil.getMinimalSubmodelElementsList()); + return list.toArray(); + } + + @Test + public void testGenericSubmodelElement() throws IncompatibleTypeException { + SubmodelElement object = submodelElement; + RDFSerializationResult rdfSerializationResult = new DefaultSubmodelElementRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + SubmodelElement recreatedObject = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assertEquals(object, recreatedObject); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java new file mode 100644 index 000000000..d98d197db --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java @@ -0,0 +1,68 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSubmodelRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.LinkedList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class SubmodelTest { + @Parameterized.Parameter + public Submodel submodel; + + @Parameterized.Parameters(name = "{index}: Submodel - {0}") + public static Object[] data() { + List list = new LinkedList<>(); +// list.add(SerializerUtil.gets()); +// list.add(SerializerUtil.getMaximalConceptDescription()); + list.add(AASFull.createSubmodel1()); + list.add(AASFull.createSubmodel2()); + list.add(AASFull.createSubmodel3()); + list.add(AASFull.createSubmodel4()); + list.add(AASFull.createSubmodel5()); + list.add(AASFull.createSubmodel6()); + list.add(AASFull.createSubmodel7()); + list.add(AASSimple.createSubmodelDocumentation()); + list.add(AASSimple.createSubmodelOperationalData()); + list.add(AASSimple.createSubmodelTechnicalData()); + return list.toArray(); + } + + @Test + public void testSubmodel() throws IncompatibleTypeException { + + Submodel object = submodel; + RDFSerializationResult rdfSerializationResult = new DefaultSubmodelRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Submodel); + + Submodel recreatedObject = new DefaultSubmodelRDFHandler().fromModel(model, createdResource); +// assertEquals(object, recreatedObject); +// List submodelElements1 = object.getSubmodelElements(); +// +// List submodelElements2 = recreatedObject.getSubmodelElements(); +// for(int i=0;i deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { TreeNode treeNode = DeserializationHelper.getRootTreeNode(parser); if (treeNode instanceof TextNode) { - return Collections.emptyList(); + return new ArrayList<>(); } ObjectNode node = (ObjectNode) treeNode; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/DeserializationHelper.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DeserializationHelper.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/DeserializationHelper.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DeserializationHelper.java index 6b5e559c6..9e106483f 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/DeserializationHelper.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DeserializationHelper.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.TreeNode; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/EmbeddedDataSpecificationsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/EmbeddedDataSpecificationsDeserializer.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/EmbeddedDataSpecificationsDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/EmbeddedDataSpecificationsDeserializer.java index ea0b54ff6..c7bee01b4 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/EmbeddedDataSpecificationsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/EmbeddedDataSpecificationsDeserializer.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; import java.io.IOException; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeyDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeyDeserializer.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeyDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeyDeserializer.java index 044fc3f1c..421d43354 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeyDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeyDeserializer.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonNode; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeysDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeysDeserializer.java similarity index 91% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeysDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeysDeserializer.java index 6ebee33d9..b050ff8b6 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/KeysDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/KeysDeserializer.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import org.eclipse.digitaltwin.aas4j.v3.model.Key; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringContentDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringContentDeserializer.java similarity index 86% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringContentDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringContentDeserializer.java index 000fcd369..7cb741f9c 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringContentDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringContentDeserializer.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonNode; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; import java.io.IOException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; + public class LangStringContentDeserializer implements CustomJsonNodeDeserializer { @Override public LangStringContent readValue(JsonNode node, JsonParser parser) throws IOException { diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java similarity index 88% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java index 6979ff592..c3e6cb63b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringDefinitionTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsNameTypeDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsNameTypeDeserializer.java similarity index 87% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsNameTypeDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsNameTypeDeserializer.java index 3a605ae5b..2030944b5 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsNameTypeDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsNameTypeDeserializer.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java similarity index 89% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java index ba55c0b7c..77761280a 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringPreferredNameTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsShortNameTypeIec61360Deserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsShortNameTypeIec61360Deserializer.java similarity index 88% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsShortNameTypeIec61360Deserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsShortNameTypeIec61360Deserializer.java index 7d03df54c..d0bbb37b3 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsShortNameTypeIec61360Deserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsShortNameTypeIec61360Deserializer.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringShortNameTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringShortNameTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsTextTypeDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsTextTypeDeserializer.java similarity index 87% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsTextTypeDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsTextTypeDeserializer.java index 0979967fd..edea9160c 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/LangStringsTextTypeDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/LangStringsTextTypeDeserializer.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.helper.LangStringContent; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util.LangStringContent; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringTextType; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/NoEntryWrapperListDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java similarity index 90% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/NoEntryWrapperListDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java index 320ea53f0..550a2fe3c 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/NoEntryWrapperListDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.slf4j.Logger; @@ -30,6 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.Lists; /** * Custom deserializer for lists without individual list entry wrappers for parametrized classes. @@ -57,7 +57,7 @@ public List deserialize(JsonParser parser, DeserializationContext ctxt) throw return createEntriesFromArrayNode((ArrayNode) langStringNode, parser); } } catch (ClassCastException e) { - logger.info("Found empty list items (e.g., '' of dataSpecificationIec61360) in XML. This is most likely an error."); + logger.info("Found empty list item (e.g., '' of dataSpecificationIec61360) in XML. This is most likely an error."); return new ArrayList(); } } @@ -73,6 +73,6 @@ private List createEntriesFromArrayNode(ArrayNode langStringsNode, JsonParser private List createEntriesFromObjectNode(JsonNode langStringNode, JsonParser parser) throws IOException { T entry = nodeDeserializer.readValue(langStringNode, parser); - return Collections.singletonList(entry); + return Lists.newArrayList(entry); } } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/OperationVariableDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java similarity index 60% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/OperationVariableDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java index 441a20e85..a67fbd3f7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/OperationVariableDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java @@ -14,7 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -23,30 +31,31 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; +import com.google.common.collect.Lists; public class OperationVariableDeserializer extends JsonDeserializer> { + private static Logger logger = LoggerFactory.getLogger(OperationVariableDeserializer.class); @Override public List deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { - ObjectNode node = DeserializationHelper.getRootObjectNode(parser); + try { + ObjectNode node = DeserializationHelper.getRootObjectNode(parser); - if (!node.has("operationVariable")) { - return Collections.emptyList(); + if (!node.has("operationVariable")) { + return new ArrayList<>(); + } + JsonNode operationVariableNode = node.get("operationVariable"); + if (operationVariableNode.isArray()) { + return createOperationVariablesFromArrayNode(parser, node); + } else { + OperationVariable operationVariable = DeserializationHelper.createInstanceFromNode(parser, operationVariableNode, OperationVariable.class); + return Lists.newArrayList(operationVariable); + } + } catch (ClassCastException e) { + logger.info("Found empty list item in Operation (e.g., '') in XML. This is most likely an error."); + return new ArrayList<>(); } - JsonNode operationVariableNode = node.get("operationVariable"); - if (operationVariableNode.isArray()) { - return createOperationVariablesFromArrayNode(parser, node); - } else { - OperationVariable operationVariable = DeserializationHelper.createInstanceFromNode(parser, operationVariableNode, OperationVariable.class); - return Collections.singletonList(operationVariable); - } - } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/QualifierDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java similarity index 73% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/QualifierDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java index c20002096..5f9cffa9d 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/QualifierDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java @@ -39,7 +39,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -48,28 +56,31 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - +import com.google.common.collect.Lists; public class QualifierDeserializer extends JsonDeserializer> { + private static Logger logger = LoggerFactory.getLogger(QualifierDeserializer.class); + @Override public List deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { - ObjectNode node = DeserializationHelper.getRootObjectNode(parser); + try { + ObjectNode node = DeserializationHelper.getRootObjectNode(parser); - if (!node.has("qualifier")) { - return Collections.emptyList(); - } - JsonNode qualifierNode = node.get("qualifier"); - if (qualifierNode.isArray()) { - return createConstraintsFromArrayNode(parser, node); - } else { - Qualifier qualifier = DeserializationHelper.createInstanceFromNode(parser, qualifierNode, Qualifier.class); - return Collections.singletonList(qualifier); + if (!node.has("qualifier")) { + return new ArrayList<>(); + } + JsonNode qualifierNode = node.get("qualifier"); + if (qualifierNode.isArray()) { + return createConstraintsFromArrayNode(parser, node); + } else { + Qualifier qualifier = DeserializationHelper.createInstanceFromNode(parser, qualifierNode, + Qualifier.class); + return Lists.newArrayList(qualifier); + } + } catch (ClassCastException e) { + logger.info("Found empty list item of qualifiers ('') in XML. This is most likely an error."); + return new ArrayList(); } } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ReferencesDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ReferencesDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java index 6aac5f8ba..df02b914b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ReferencesDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java @@ -13,7 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -22,19 +28,14 @@ import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import com.google.common.collect.Lists; public class ReferencesDeserializer extends JsonDeserializer> { @Override public List deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { TreeNode treeNode = DeserializationHelper.getRootTreeNode(parser); - treeNode = treeNode.get("reference"); + treeNode = treeNode.get("reference"); if (treeNode.isArray()) { return createReferencesFromArray(parser, (ArrayNode) treeNode); } else { @@ -44,7 +45,7 @@ public List deserialize(JsonParser parser, DeserializationContext ctx private List createReferencesFromObjectNode(JsonParser parser, ObjectNode node) throws IOException { Reference reference = createReference(parser, node); - return Collections.singletonList(reference); + return Lists.newArrayList(reference); } private List createReferencesFromArray(JsonParser parser, ArrayNode arrayNode) throws IOException { diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementDeserializer.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementDeserializer.java index ee5a2c233..346091cd3 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementDeserializer.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementsDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.java index 987ade7a3..e77e85e9b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/SubmodelElementsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -29,7 +29,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -48,14 +47,14 @@ public SubmodelElementsDeserializer() { public List deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { TreeNode treeNode = DeserializationHelper.getRootTreeNode(parser); if (treeNode instanceof TextNode) { - return Collections.emptyList(); + return new ArrayList<>(); } else { return createSubmodelElements(parser, ctxt, treeNode); } } private List createSubmodelElements(JsonParser parser, DeserializationContext ctxt, TreeNode treeNode) throws IOException, JsonProcessingException { - if (treeNode.isArray()) { + if (treeNode.isArray()) { return getSubmodelElementsFromArrayNode(parser, ctxt, (ArrayNode) treeNode); } else { return getSubmodelElementsFromObjectNode(parser, ctxt, (JsonNode) treeNode); @@ -100,7 +99,7 @@ private List getSubmodelElementsFromArrayNode(JsonParser parser private SubmodelElement getSubmodelElementFromJsonNode(JsonParser parser, DeserializationContext ctxt, JsonNode nodeSubmodelElement) throws IOException, JsonProcessingException { JsonParser parserReference = parser.getCodec().getFactory().getCodec().treeAsTokens(nodeSubmodelElement); - return deserializer.deserialize(parserReference, ctxt); + return deserializer.deserialize(parserReference, ctxt); } } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairNodeDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairNodeDeserializer.java similarity index 94% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairNodeDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairNodeDeserializer.java index 0d4c23a07..b30635b15 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairNodeDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairNodeDeserializer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonNode; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairsDeserializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairsDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairsDeserializer.java index 9b8fcc78e..1a7f1d20f 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/ValueReferencePairsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ValueReferencePairsDeserializer.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.xml.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization; import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AdministrativeInformationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AdministrativeInformationMixin.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AdministrativeInformationMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AdministrativeInformationMixin.java index 4a2eaa89f..c00ca6da0 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AdministrativeInformationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AdministrativeInformationMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AnnotatedRelationshipElementMixin.java similarity index 79% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AnnotatedRelationshipElementMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AnnotatedRelationshipElementMixin.java index ae16bbcb3..dc412810f 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AnnotatedRelationshipElementMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AnnotatedRelationshipElementMixin.java @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.DataElementsDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.DataElementsSerializer; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.DataElementsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.DataElementsSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AssetAdministrationShellMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AssetAdministrationShellMixin.java index 83f36a12a..a86fbe4f6 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetInformationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AssetInformationMixin.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetInformationMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AssetInformationMixin.java index ae73124a9..d535001e8 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetInformationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/AssetInformationMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ConceptDescriptionMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ConceptDescriptionMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ConceptDescriptionMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ConceptDescriptionMixin.java index f7d7f7643..938c32d62 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ConceptDescriptionMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ConceptDescriptionMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/DataSpecificationIec61360Mixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/DataSpecificationIec61360Mixin.java similarity index 83% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/DataSpecificationIec61360Mixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/DataSpecificationIec61360Mixin.java index 64cf17940..1bb111ecd 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/DataSpecificationIec61360Mixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/DataSpecificationIec61360Mixin.java @@ -13,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization.EnumSerializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsDefinitionTypeIec61360Deserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsPreferredNameTypeIec61360Deserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsShortNameTypeIec61360Deserializer; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.LangStringsDefinitionTypeIec61360Serializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.LangStringsPreferredNameTypeIec61360Serializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.LangStringsShortNameTypeIec61360Serializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsDefinitionTypeIec61360Deserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsPreferredNameTypeIec61360Deserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsShortNameTypeIec61360Deserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.LangStringsDefinitionTypeIec61360Serializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.LangStringsPreferredNameTypeIec61360Serializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.LangStringsShortNameTypeIec61360Serializer; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java similarity index 86% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EmbeddedDataSpecificationMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java index ed615bf18..971d0d7ce 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EmbeddedDataSpecificationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java @@ -1,45 +1,46 @@ -/* - * 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.xml.mixins; - -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.EmbeddedDataSpecificationsDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.EmbeddedDataSpecificationSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonPropertyOrder({"dataSpecification", "dataSpecificationContent"}) -public interface EmbeddedDataSpecificationMixin { - - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecification") - public Reference getDataSpecification(); - - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecification") - public void setDataSpecification(Reference dataSpecification); - - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecificationContent") - @JsonSerialize(using = EmbeddedDataSpecificationSerializer.class) - public DataSpecificationContent getDataSpecificationContent(); - - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecificationContent") - @JsonDeserialize(using = EmbeddedDataSpecificationsDeserializer.class) - public void setDataSpecificationContent(DataSpecificationContent dataSpecificationIEC61360); - +/* + * 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.xml.internal.mixins; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.EmbeddedDataSpecificationsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.EmbeddedDataSpecificationSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonPropertyOrder({"dataSpecification", "dataSpecificationContent"}) +public interface EmbeddedDataSpecificationMixin { + + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecification") + public Reference getDataSpecification(); + + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecification") + public void setDataSpecification(Reference dataSpecification); + + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecificationContent") + @JsonSerialize(using = EmbeddedDataSpecificationSerializer.class) + public DataSpecificationContent getDataSpecificationContent(); + + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "dataSpecificationContent") + @JsonDeserialize(using = EmbeddedDataSpecificationsDeserializer.class) + public void setDataSpecificationContent(DataSpecificationContent dataSpecificationIEC61360); + } \ No newline at end of file diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EntityMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EntityMixin.java similarity index 84% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EntityMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EntityMixin.java index 0a2f38932..4635a7a5a 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EntityMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EntityMixin.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementsDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.SubmodelElementsSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.SubmodelElementsSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EnvironmentMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EnvironmentMixin.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EnvironmentMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EnvironmentMixin.java index 31e29a9b0..0ad244fb3 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/EnvironmentMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ExtensionMixin.java similarity index 86% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ExtensionMixin.java index 2c279d707..5a31c4d03 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ExtensionMixin.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.RefersToSerializer; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.RefersToSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasDataSpecificationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasDataSpecificationMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasDataSpecificationMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasDataSpecificationMixin.java index ca344f604..404e26f29 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasDataSpecificationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasDataSpecificationMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasExtensionsMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasExtensionsMixin.java similarity index 94% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasExtensionsMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasExtensionsMixin.java index c5228f9a0..b7641ba79 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasExtensionsMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasExtensionsMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasSemanticsMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasSemanticsMixin.java similarity index 90% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasSemanticsMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasSemanticsMixin.java index cd2ae17ee..3a7596e33 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/HasSemanticsMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/HasSemanticsMixin.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.ReferencesDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.ReferencesDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/KeyMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/KeyMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/KeyMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/KeyMixin.java index 78190506e..c1d197557 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/KeyMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/LevelTypeMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/LevelTypeMixin.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/LevelTypeMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/LevelTypeMixin.java index db54e96eb..5e3555d25 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/LevelTypeMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/LevelTypeMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/MultiLanguagePropertyMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/MultiLanguagePropertyMixin.java similarity index 89% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/MultiLanguagePropertyMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/MultiLanguagePropertyMixin.java index 66437999d..747aba825 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/MultiLanguagePropertyMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/MultiLanguagePropertyMixin.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsTextTypeDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsTextTypeDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationMixin.java similarity index 87% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationMixin.java index 14926181b..0e78c1fb4 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationMixin.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.OperationVariableDeserializer; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.OperationVariableDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationVariableMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationVariableMixin.java similarity index 83% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationVariableMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationVariableMixin.java index 582926deb..f1fae21a7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/OperationVariableMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/OperationVariableMixin.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.SubmodelElementSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.SubmodelElementSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; public interface OperationVariableMixin { diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/PropertyMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/PropertyMixin.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/PropertyMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/PropertyMixin.java index 68a0c229e..c6eddadc4 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/PropertyMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/PropertyMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifiableMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifiableMixin.java similarity index 90% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifiableMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifiableMixin.java index 871c4daba..d231c82c4 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifiableMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifiableMixin.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.QualifierDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.QualifierDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifierMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifierMixin.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifierMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifierMixin.java index 29f0b0775..5dba27387 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/QualifierMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/QualifierMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferableMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferableMixin.java similarity index 80% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferableMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferableMixin.java index af190e8f5..4c91318b4 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferableMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferableMixin.java @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsNameTypeDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.LangStringsTextTypeDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.LangStringsNameTypeSerializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.LangStringsTextTypeSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsNameTypeDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.LangStringsTextTypeDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.LangStringsNameTypeSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.LangStringsTextTypeSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferenceMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferenceMixin.java similarity index 91% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferenceMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferenceMixin.java index c6a2a26b8..a8eacf3c1 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ReferenceMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ReferenceMixin.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.KeysDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.KeysDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.Key; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ResourceMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ResourceMixin.java similarity index 94% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ResourceMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ResourceMixin.java index 21a6963e8..ae2f10e93 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ResourceMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ResourceMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SpecificAssetIdMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SpecificAssetIdMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SpecificAssetIdMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SpecificAssetIdMixin.java index cc15f92f7..e03c0b401 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SpecificAssetIdMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SpecificAssetIdMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementCollectionMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementCollectionMixin.java similarity index 82% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementCollectionMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementCollectionMixin.java index 511c53779..bd11afad7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementCollectionMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementCollectionMixin.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementsDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.SubmodelElementsSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.SubmodelElementsSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementListMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementListMixin.java similarity index 90% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementListMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementListMixin.java index 9ee63793f..5da6ae1ae 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementListMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementListMixin.java @@ -14,14 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementsDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.SubmodelElementsSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.SubmodelElementsSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementMixin.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementMixin.java index 4992fb50f..b2c981b42 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelElementMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelElementMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelMixin.java similarity index 85% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelMixin.java index 4e9525647..d69cd5e17 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/SubmodelMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/SubmodelMixin.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementsDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.SubmodelElementsSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementsDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.SubmodelElementsSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueListMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueListMixin.java similarity index 90% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueListMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueListMixin.java index 6121f1230..71c626640 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueListMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueListMixin.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.ValueReferencePairsDeserializer; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.ValueReferencePairsDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; import java.util.List; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueReferencePairMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueReferencePairMixin.java similarity index 94% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueReferencePairMixin.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueReferencePairMixin.java index a09a92494..3ba0e496b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ValueReferencePairMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/ValueReferencePairMixin.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.xml.mixins; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringSerializer.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringSerializer.java index 4f88b81ee..22d3f47cf 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringSerializer.java @@ -17,7 +17,7 @@ /** * */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringsSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringsSerializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringsSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringsSerializer.java index 5937ab007..505980d9d 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AbstractLangStringsSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AbstractLangStringsSerializer.java @@ -14,12 +14,13 @@ * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.SubmodelElementManager; import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AssetAdministrationShellEnvironmentSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AssetAdministrationShellEnvironmentSerializer.java similarity index 97% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AssetAdministrationShellEnvironmentSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AssetAdministrationShellEnvironmentSerializer.java index ea3261e55..2c608b8b6 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/AssetAdministrationShellEnvironmentSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/AssetAdministrationShellEnvironmentSerializer.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/DataElementsSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/DataElementsSerializer.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/DataElementsSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/DataElementsSerializer.java index 3e0a20e5a..96c18d879 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/DataElementsSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/DataElementsSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/EmbeddedDataSpecificationSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/EmbeddedDataSpecificationSerializer.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/EmbeddedDataSpecificationSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/EmbeddedDataSpecificationSerializer.java index b70aaf051..88bc537c0 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/EmbeddedDataSpecificationSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/EmbeddedDataSpecificationSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsDefinitionTypeIec61360Serializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsDefinitionTypeIec61360Serializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsDefinitionTypeIec61360Serializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsDefinitionTypeIec61360Serializer.java index c80f8f3d5..da102f4cb 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsDefinitionTypeIec61360Serializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsDefinitionTypeIec61360Serializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsNameTypeSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsNameTypeSerializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsNameTypeSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsNameTypeSerializer.java index f22a61c91..7f2604ef7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsNameTypeSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsNameTypeSerializer.java @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.SubmodelElementManager; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsPreferredNameTypeIec61360Serializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsPreferredNameTypeIec61360Serializer.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsPreferredNameTypeIec61360Serializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsPreferredNameTypeIec61360Serializer.java index af86ea5cf..f3d83321f 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsPreferredNameTypeIec61360Serializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsPreferredNameTypeIec61360Serializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsShortNameTypeIec61360Serializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsShortNameTypeIec61360Serializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsShortNameTypeIec61360Serializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsShortNameTypeIec61360Serializer.java index 6fdd248f9..5ffc734ec 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsShortNameTypeIec61360Serializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsShortNameTypeIec61360Serializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringShortNameTypeIec61360; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsTextTypeSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsTextTypeSerializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsTextTypeSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsTextTypeSerializer.java index a7749b6da..f539b8c0d 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/LangStringsTextTypeSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/LangStringsTextTypeSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/NoEntryWrapperListSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/NoEntryWrapperListSerializer.java similarity index 97% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/NoEntryWrapperListSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/NoEntryWrapperListSerializer.java index ca6c57055..f548b8761 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/NoEntryWrapperListSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/NoEntryWrapperListSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/OperationVariableSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/OperationVariableSerializer.java similarity index 95% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/OperationVariableSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/OperationVariableSerializer.java index cb79710fa..7d37b3a1e 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/OperationVariableSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/OperationVariableSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/RefersToSerializer.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/RefersToSerializer.java index 653fc24f2..38701d3d0 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/RefersToSerializer.java @@ -23,13 +23,14 @@ * SPDX-License-Identifier: MIT ******************************************************************************/ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins.HasSemanticsMixin; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.mixins.HasSemanticsMixin; import org.eclipse.digitaltwin.aas4j.v3.model.Extension; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementSerializer.java similarity index 96% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementSerializer.java index 75361c374..a73b2b641 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementSerializer.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.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementsSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementsSerializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementsSerializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementsSerializer.java index 66e2b626f..b1d05a419 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/SubmodelElementsSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/serialization/SubmodelElementsSerializer.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.SubmodelElementManager; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/helper/LangStringContent.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/util/LangStringContent.java similarity index 93% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/helper/LangStringContent.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/util/LangStringContent.java index 014b559d6..afc3e2fdf 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/helper/LangStringContent.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/util/LangStringContent.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.xml.helper; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.util; /** * diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java index db1ba2ec6..d1e8a6e3b 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java @@ -18,11 +18,11 @@ import java.io.FileNotFoundException; import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; 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.Examples; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Operation; import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java index 47c409603..0be7247f5 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java @@ -17,12 +17,12 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; 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.Examples; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; +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.xml.internal.AasXmlNamespaceContext; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; diff --git a/docs/.gitignore b/docs/.gitignore deleted file mode 100644 index 4378419e7..000000000 --- a/docs/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -############### -# folder # -############### -/**/DROP/ -/**/TEMP/ -/**/packages/ -/**/bin/ -/**/obj/ -_site diff --git a/docs/articles/building.md b/docs/articles/building.md deleted file mode 100644 index 9a2d7d690..000000000 --- a/docs/articles/building.md +++ /dev/null @@ -1,28 +0,0 @@ -# Building - -You can download and build the repository by yourself by following these steps: - -- Clone the GitHub repository: - -```sh - git clone https://github.com/eclipse-aas4j/aas4j.git -``` - -- Use [Maven](https://maven.apache.org/) to build the project -```sh - mvn clean package -``` - -- **OR** use Maven to build and install the artifacts in your local Maven repository -```sh - mvn clean install -``` - -> [!NOTE] -> -> If the project is built locally, the artifact version is set to the `revision` variable in the `pom.xml` in the project root folder. -> ```xml -> 1.1.0 -> ${revision} -> ``` -> If you change the version of your local built, the `model.version` is also set to the updated artifact version from the [java-model](https://github.com/eclipse-aas4j/aas4j/tree/main/model) project. For the same version number, both artifacts are compatible. diff --git a/docs/articles/development_workflow.md b/docs/articles/development_workflow.md deleted file mode 100644 index 207c760e3..000000000 --- a/docs/articles/development_workflow.md +++ /dev/null @@ -1,37 +0,0 @@ -# Development Workflow - -We develop with Github using pull requests (see this [Github guide](https://guides.github.com/introduction/flow/) for a short introduction). - -**Development branch.** The development branch is always `development`. Expect changes on this branch from time to time. - -**Releases.** The releases mark the development milestones on the `main` branch with a certain feature completeness. - -## Pull Requests - -**Feature branches.** We develop using the feature branches, see this [section of the Git book](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows). We use `feature/'feature-name'` and `bugfix/'bugfix-name'` as a naming convention. - -If you are a member of the development team, create a feature branch directly within the repository. - -Otherwise, if you are a non-member contributor, fork the repository and create the feature branch in your forked repository. See this Github tuturial for more guidance. - -**Branch Prefix.** Each PullRequest must contained a list of the changed topics, for instance as a list of bulletpoints. Simply refering to the commit messages is not sufficient. - -**Reviews.** Each PullRequest is reviewed by the Maintainers of the project. In order to simplify the workflow, please assign the PullRequest directly to the Maintainer you think is most knowledgable about your changes. - -## CI Workflows -There are three workflows that will automatically handle specific events for the repository: -- Pull requests on one of the branches mentioned above will trigger CI actions that will automatically check, if all tests pass successfully -- Additionally, new commits on `main` will build the release artifacts and publish them on [Maven Central](https://mvnrepository.com/artifact/io.admin-shell.aas) -- The documentation found in /docs is automatically build with docFX and published to gh-pages, when a new release is pushed to the `main` branch - -## Commit Messages - -The commit messages should follow the guidelines from https://chris.beams.io/posts/git-commit: - -- Separate subject from body with a blank line -- Limit the subject line to 50 characters -- Capitalize the subject line -- Do not end the subject line with a period -- Use the imperative mood in the subject line -- Wrap the body at 72 characters -- Use the body to explain what and why (instead of how) diff --git a/docs/articles/intro.md b/docs/articles/intro.md deleted file mode 100644 index c43b4705e..000000000 --- a/docs/articles/intro.md +++ /dev/null @@ -1,16 +0,0 @@ -# Introduction - -The [AAS Java Dataformat Library](https://github.com/admin-shell-io/java-serializer/) is a collection of software modules to serialize and deserialze instances of the Asset Administration Shell from and to Java instances. De-/serialization works according to the dataformat schemas published in the document 'Details of the Asset Administration Shell', published on www.plattform-i40.de. - -The serialization library and all its modules depend on the Java implementation for the metamodel from the project [java-model](https://github.com/admin-shell-io/java-model). - -## Project Structure - -The project contains several modules: - -- `dataformat-parent` Maven parent module that contains the respective de-/serializers for the different data formats. -- `dataformat-core` Location of the general classes and interfaces that are used by more than one de-/serializer. -- `dataformat-aasx` AASX de-/serializer -- `dataformat-json` JSON de-/serializer -- `dataformat-xml` XML de-/serializer -- `dataformat-uanodeset` OPC UA I4AAS NodeSet de-/serializer \ No newline at end of file diff --git a/docs/articles/releasing.md b/docs/articles/releasing.md deleted file mode 100644 index 918d11fea..000000000 --- a/docs/articles/releasing.md +++ /dev/null @@ -1,5 +0,0 @@ -# Versioning - -We version using **semantic versioning** (e.g., `1.0.4`). The first position indicates the major release. Different major releases canvas contain breaking changes and are not necessarily compliant. The second number indicates the minor releas or revision, which contains new features compared to an older revision. The last position is used for hotfixes or bugfixes. - -Note, that the versioning scheme of this project is not directly aligned with the release process of the metamodel! For instance, the version 1.0.3 targets the metamodel version 3.0.RC02 \ No newline at end of file diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml deleted file mode 100644 index 26e4f9cfa..000000000 --- a/docs/articles/toc.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: Introduction - href: intro.md -- name: Usage - href: usage.md -- name: Building - href: building.md -- name: Development Workflow - href: development_workflow.md -- name: Releasing - href: releasing.md diff --git a/docs/articles/usage.md b/docs/articles/usage.md deleted file mode 100644 index 4f1f6190c..000000000 --- a/docs/articles/usage.md +++ /dev/null @@ -1,85 +0,0 @@ -# Usage - -The library and its modules are released at Maven Central. Thus, you can use the respective serializers in your Java Maven project by adding the following dependency: - -```xml - - io.admin-shell.aas - dataformat-**serializer** - **version** - -``` - -For example, uses the following dependency declaration to embed the `JSON dataformat`: - -```xml - - io.admin-shell.aas - dataformat-json - 1.1.1 - -``` - - -> [!NOTE] -> -> Maven will automatically resolve the dependencies of the library and therefore also include the model implementation from the [java-model](https://github.com/admin-shell-io/java-model) project. - -## Serialization - -The library supports serialization of an AAS environment to a `File`, `OutputStream` or `String`. See the following interface to get more details on what methods can be used to serialize an environment: - -https://github.com/admin-shell-io/java-serializer/blob/main/dataformat-core/src/main/java/io/adminshell/aas/v3/dataformat/Serializer.java - -Here is a small example on how to serialize a given environment to a JSON-`String`: - -```Java -AssetAdministrationShellEnvironment env = ...; -String serializedEnvironment = new JsonSerializer().write(env); -``` - -## Deserialization - -Likewise, you can deserialize an AAS environment from a `File`, `InputStream` or `String`. See the following interface to get more details on what methods can be used to deserialize an environment: - -https://github.com/admin-shell-io/java-serializer/blob/main/dataformat-core/src/main/java/io/adminshell/aas/v3/dataformat/Deserializer.java - -Here is a small example on how to deserialize a given JSON-`String` and draw some information out of the returned model: - -```Java -String serializedEnvironment = "..."; -AssetAdministrationShellEnvironment env = new JsonDeserializer().read(serializedEnvironment); -List aasList = env.getAssetAdministrationShells(); -aasList.forEach(aas -> System.out.println("Environment contains AAS: " + aas.getIdShort())); -``` - -## AASX - -In order to be able to also embed files into a serialized environment, it is possible to create an .aasx-package. The AASX module makes use of the xml-dataformat to handle the `AASEnvironment`. - -```Java -byte[] fileContent = ...; -AssetAdministrationShellEnvironment env = ...; -InMemoryFile file = new InMemoryFile(fileContent, "aasx/MyFile.pdf"); -List fileList = new ArrayList<>() -fileList.add(file); -ByteArrayOutputStream out = new ByteArrayOutputStream(); -new AASXSerializer().write(env, fileList, out); -``` - -> [!NOTE] -> -> The given filepath is relative to the .aasx package root and has to correspondent to the relative path given in the `File`-`SubmodelElement` that points to this file. - -## Constraint Validation - -According to the AAS specification in "Details of The Asset Administration Shell", there are a number of constraints a valid model has to fulfill. The java-model implementation allows the creation of models that are not valid according to these constraints. The java-dataformat library contains a validation module to test them. The following snippet shows a submodel with an invalid idShort. Therefore, this snippet will throw a `ValidationException`. - -```Java -Referable invalidReferable = new DefaultSubmodel.Builder() - .identification( - new DefaultIdentifier.Builder().identifier("submodel").idType(IdentifierType.CUSTOM).build()) - .idShort("_idShort") - .build(); -ShaclValidator.getInstance().validate(invalidReferable); -``` diff --git a/docs/adr/branching_strategy.png b/docs/branching_strategy.png similarity index 100% rename from docs/adr/branching_strategy.png rename to docs/branching_strategy.png diff --git a/docs/adr/decision_records.md b/docs/decision_records.md similarity index 100% rename from docs/adr/decision_records.md rename to docs/decision_records.md diff --git a/docs/adr/development_process.md b/docs/development_process.md similarity index 100% rename from docs/adr/development_process.md rename to docs/development_process.md diff --git a/docs/docfx.json b/docs/docfx.json deleted file mode 100644 index 1fe4ab650..000000000 --- a/docs/docfx.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "build": { - "content": [ - { - "files": [ - "articles/**.md", - "**/*.yml", - "*.md", - "toc.yml" - ] - } - ], - "resource": [ - { - "files": [ - "images/**" - ] - } - ], - "dest": "_site", - "globalMetadata": { - "_appTitle": "java-serializer Documentation", - "_appFaviconPath": "images/favicon.ico", - "_appLogoPath": "images/adminshellio-48x48.jpg", - "_enableSearch": true - }, - "globalMetadataFiles": [], - "fileMetadataFiles": [], - "template": [ - "default" - ], - "postProcessors": [], - "markdownEngineName": "markdig", - "noLangKeyword": false, - "keepFileLink": false, - "cleanupCacheHistory": false, - "disableGitFeatures": false - } -} \ No newline at end of file diff --git a/docs/images/adminshellio-48x48.jpg b/docs/images/adminshellio-48x48.jpg deleted file mode 100644 index 820c4136d..000000000 Binary files a/docs/images/adminshellio-48x48.jpg and /dev/null differ diff --git a/docs/images/favicon-16x16.png b/docs/images/favicon-16x16.png deleted file mode 100644 index 283f77d16..000000000 Binary files a/docs/images/favicon-16x16.png and /dev/null differ diff --git a/docs/images/favicon-32x32.png b/docs/images/favicon-32x32.png deleted file mode 100644 index bc1d21954..000000000 Binary files a/docs/images/favicon-32x32.png and /dev/null differ diff --git a/docs/images/favicon-96x96.png b/docs/images/favicon-96x96.png deleted file mode 100644 index d45b1f8ad..000000000 Binary files a/docs/images/favicon-96x96.png and /dev/null differ diff --git a/docs/images/favicon.ico b/docs/images/favicon.ico deleted file mode 100644 index e0dff0fd1..000000000 Binary files a/docs/images/favicon.ico and /dev/null differ diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 7fd7f9d1f..000000000 --- a/docs/index.md +++ /dev/null @@ -1,6 +0,0 @@ -# Devdoc for the AAS Java Serializer -This is the documentation for the contributors and developers of AAS Java Serializer. - -For the general introduction and the description of the tool, please see the Github repository: https://github.com/admin-shell-io/java-serializer. - -[Getting Started](articles/intro.md) explains how to use the library and submit contributions. \ No newline at end of file diff --git a/docs/toc.yml b/docs/toc.yml deleted file mode 100644 index 5f0a4d069..000000000 --- a/docs/toc.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: Getting Started - href: articles/ diff --git a/model/pom.xml b/model/pom.xml index 33773f8bb..37fd2e703 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -21,8 +21,8 @@ 1.8 1.8 1.6.0 - 3.6.3 - 3.5.0 + 3.11.2 + 3.8.0 @@ -76,7 +76,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.7 ${gpg.keyname} ${gpg.keyname} diff --git a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/Identifiable.java b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/Identifiable.java index f878c8cbb..e33f108ef 100644 --- a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/Identifiable.java +++ b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/Identifiable.java @@ -29,7 +29,6 @@ @KnownSubtypes.Type(value = Submodel.class) }) public interface Identifiable extends Referable { - /** * Administrative information of an identifiable element. * diff --git a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/OperationResult.java b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/OperationResult.java index 7ba79ee45..bc22534e4 100644 --- a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/OperationResult.java +++ b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/OperationResult.java @@ -27,7 +27,7 @@ @KnownSubtypes({ @KnownSubtypes.Type(value = DefaultOperationResult.class) }) -public interface OperationResult { +public interface OperationResult extends BaseOperationResult { /** * diff --git a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/builder/OperationResultBuilder.java b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/builder/OperationResultBuilder.java index edf5b944f..ed36ee475 100644 --- a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/builder/OperationResultBuilder.java +++ b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/builder/OperationResultBuilder.java @@ -1,12 +1,9 @@ /* * 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 @@ -19,14 +16,28 @@ import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; import java.util.List; +import org.eclipse.digitaltwin.aas4j.v3.model.ExecutionState; +import org.eclipse.digitaltwin.aas4j.v3.model.Message; public abstract class OperationResultBuilder> - extends ExtendableBuilder { + extends ExtendableBuilder { + + /** + * This function allows setting a value for executionState + * + * @param executionState desired value to be set + * @return Builder object with new value for executionState + */ + public B executionState(ExecutionState executionState) { + getBuildingInstance().setExecutionState(executionState); + return getSelf(); + } + /** * This function allows setting a value for inoutputArguments - * + * * @param inoutputArguments desired value to be set * @return Builder object with new value for inoutputArguments */ @@ -35,9 +46,10 @@ public B inoutputArguments(List inoutputArguments) { return getSelf(); } + /** * This function allows adding a value to the List inoutputArguments - * + * * @param inoutputArguments desired value to be added * @return Builder object with new value for inoutputArguments */ @@ -46,9 +58,34 @@ public B inoutputArguments(OperationVariable inoutputArguments) { return getSelf(); } + + /** + * This function allows setting a value for messages + * + * @param messages desired value to be set + * @return Builder object with new value for messages + */ + public B messages(List messages) { + getBuildingInstance().setMessages(messages); + return getSelf(); + } + + + /** + * This function allows adding a value to the List messages + * + * @param messages desired value to be added + * @return Builder object with new value for messages + */ + public B messages(Message messages) { + getBuildingInstance().getMessages().add(messages); + return getSelf(); + } + + /** * This function allows setting a value for outputArguments - * + * * @param outputArguments desired value to be set * @return Builder object with new value for outputArguments */ @@ -57,9 +94,10 @@ public B outputArguments(List outputArguments) { return getSelf(); } + /** * This function allows adding a value to the List outputArguments - * + * * @param outputArguments desired value to be added * @return Builder object with new value for outputArguments */ @@ -67,4 +105,17 @@ public B outputArguments(OperationVariable outputArguments) { getBuildingInstance().getOutputArguments().add(outputArguments); return getSelf(); } + + + /** + * This function allows setting a value for success + * + * @param success desired value to be set + * @return Builder object with new value for success + */ + public B success(boolean success) { + getBuildingInstance().setSuccess(success); + return getSelf(); + } + } diff --git a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultBaseOperationResult.java b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultBaseOperationResult.java index e9507263c..4997b8631 100644 --- a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultBaseOperationResult.java +++ b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultBaseOperationResult.java @@ -1,12 +1,9 @@ /* * 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 @@ -73,37 +70,44 @@ public ExecutionState getExecutionState() { return executionState; } + @Override public void setExecutionState(ExecutionState executionState) { this.executionState = executionState; } + @Override public boolean getSuccess() { return success; } + @Override public void setSuccess(boolean success) { this.success = success; } + @Override public List getMessages() { return messages; } + @Override public void setMessages(List messages) { this.messages = messages; } + public String toString() { return String.format( - "DefaultBaseOperationResult (" + "executionState=%s," - + "success=%s," - + ")", - this.executionState, this.success); + "DefaultBaseOperationResult (" + "executionState=%s," + + "messages=%s," + + "success=%s," + + ")", + this.executionState, this.messages, this.success); } /** @@ -116,6 +120,7 @@ protected Builder getSelf() { return this; } + @Override protected DefaultBaseOperationResult newBuildingInstance() { return new DefaultBaseOperationResult(); diff --git a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultOperationResult.java b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultOperationResult.java index 763676200..a01d84323 100644 --- a/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultOperationResult.java +++ b/model/src/main/java/org/eclipse/digitaltwin/aas4j/v3/model/impl/DefaultOperationResult.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import org.eclipse.digitaltwin.aas4j.v3.model.ExecutionState; +import org.eclipse.digitaltwin.aas4j.v3.model.Message; /** @@ -33,6 +35,15 @@ @IRI("aas:OperationResult") public class DefaultOperationResult implements OperationResult { + @IRI("https://admin-shell.io/aas/3/0/BaseOperationResult/executionState") + protected ExecutionState executionState; + + @IRI("https://admin-shell.io/aas/3/0/BaseOperationResult/success") + protected boolean success; + + @IRI("https://admin-shell.io/aas/3/0/Result/messages") + protected List messages = new ArrayList<>(); + @IRI("https://admin-shell.io/aas/3/0/OperationResult/inoutputArguments") protected List inoutputArguments = new ArrayList<>(); @@ -41,12 +52,17 @@ public class DefaultOperationResult implements OperationResult { public DefaultOperationResult() {} + @Override public int hashCode() { - return Objects.hash(this.inoutputArguments, - this.outputArguments); + return Objects.hash(this.executionState, + this.success, + this.messages, + this.inoutputArguments, + this.outputArguments); } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -58,36 +74,83 @@ public boolean equals(Object obj) { } else { DefaultOperationResult other = (DefaultOperationResult) obj; return Objects.equals(this.inoutputArguments, other.inoutputArguments) && - Objects.equals(this.outputArguments, other.outputArguments); + Objects.equals(this.outputArguments, other.outputArguments) && + Objects.equals(this.executionState, other.executionState) && + Objects.equals(this.success, other.success) && + Objects.equals(this.messages, other.messages); } } + @Override public List getInoutputArguments() { return inoutputArguments; } + @Override public void setInoutputArguments(List inoutputArguments) { this.inoutputArguments = inoutputArguments; } + @Override public List getOutputArguments() { return outputArguments; } + @Override public void setOutputArguments(List outputArguments) { this.outputArguments = outputArguments; } + + @Override + public ExecutionState getExecutionState() { + return executionState; + } + + + @Override + public void setExecutionState(ExecutionState executionState) { + this.executionState = executionState; + } + + + @Override + public boolean getSuccess() { + return success; + } + + + @Override + public void setSuccess(boolean success) { + this.success = success; + } + + + @Override + public List getMessages() { + return messages; + } + + + @Override + public void setMessages(List messages) { + this.messages = messages; + } + + public String toString() { return String.format( - "DefaultOperationResult (" + "inoutputArguments=%s," - + "outputArguments=%s," - + ")", - this.inoutputArguments, this.outputArguments); + "DefaultOperationResult (" + "executionState=%s," + + "inoutputArguments=%s," + + "messages=%s," + + "outputArguments=%s," + + "success=%s," + + ")", + this.executionState, this.inoutputArguments, this.messages, this.outputArguments, this.success); } /** @@ -100,6 +163,7 @@ protected Builder getSelf() { return this; } + @Override protected DefaultOperationResult newBuildingInstance() { return new DefaultOperationResult(); diff --git a/pom.xml b/pom.xml index 0a3d86ed8..559a2d2aa 100644 --- a/pom.xml +++ b/pom.xml @@ -1,414 +1,414 @@ - - - - - Eclipse AAS Model for Java (AAS4J) implements the specification of the Asset Administration Shell (AAS) such as metamodels, submodels, serialization and deserialization modules, and validators based on the AAS specifications.. - Eclipse Digital Twin - AAS Model for Java (AAS4J) - https://github.com/eclipse-digitaltwin/aas4j - - - SAP SE - https://projects.eclipse.org/projects/dt.aas4j/who - - - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. - https://projects.eclipse.org/projects/dt.aas4j/who - - - - - scm:git:git://github.com/eclipse-digitaltwin/aas4j.git - scm:git:git:github.com/eclipse-digitaltwin/aas4j.git - https://github.com/eclipse-digitaltwin/aas4j/tree/main - - - 4.0.0 - org.eclipse.digitaltwin.aas4j - aas4j-dataformat-parent - ${revision} - pom - - model - dataformat-aasx - dataformat-core - dataformat-json - dataformat-xml - - - 1 - 0 - 0 - -RC1 - ${revision.major}.${revision.minor}.${revision.patch}${revision.suffix} - 1.0.0-RC1 - - UTF-8 - UTF-8 - - 3.12.1 - 3.3.1 - 1.6.0 - 3.0.1 - 3.3.0 - 3.6.3 - 3.5.0 - 3.3.0 - 0.8.11 - 4.8.165 - 1.15 - 2.15.1 - 1.25.0 - 3.14.0 - 33.0.0-jre - 5.0.1 - 2.2 - 2.16.1 - 2.0.1.Final - 2.3.1 - 2.1.0 - 4.1.0 - 1.5.1 - 1.3.1 - 4.13.2 - 1.1.1 - 2.7.8 - 5.2.5 - 2.0.12 - 1.3.2 - 4.4.1 - 2.12.1 - 2.9.1 - 5.10.0 - 0.0.20131108.vaadin1 - - - - - org.jacoco - jacoco-maven-plugin - ${plugin.jacoco.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - jacoco-check - - check - - - - - GROUP - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${plugin.compiler.version} - - 11 - 11 - - - - org.codehaus.mojo - flatten-maven-plugin - ${plugin.flatten.version} - - true - - - - - - - - - - - flatten - process-resources - - flatten - - - - flatten.clean - clean - - clean - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - ${plugin.projectinfo.version} - - - org.apache.maven.plugins - maven-source-plugin - ${plugin.source.version} - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${plugin.javadoc.version} - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.6.1 - - - - - - - - MavenCentral - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.1.0 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - ossrh - https://oss.sonatype.org/ - true - - - - - - - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - - - - org.apache.commons - commons-compress - ${commons-compress.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - junit - junit - ${junit.version} - test - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - org.hamcrest - hamcrest - ${hamcrest.version} - test - - - ${project.groupId} - aas4j-dataformat-core - ${revision} - - - ${project.groupId} - aas4j-dataformat-xml - ${revision} - - - ${project.groupId} - aas4j-model - ${model.version} - - - ${project.groupId} - aas4j-dataformat-core - tests - ${revision} - - - org.apache.poi - poi-ooxml - ${poi.version} - - - commons-io - commons-io - ${commons-io.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - io.github.classgraph - classgraph - ${classgraph.version} - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - pl.pragmatists - JUnitParams - ${junit-params.version} - - - com.vaadin.external.google - android-json - ${vaadin.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - - - org.xmlunit - xmlunit-core - ${xmlunit.version} - test - - - org.xmlunit - xmlunit-matchers - ${xmlunit.version} - test - - - org.hamcrest - hamcrest-core - ${hamcrest.version} - test - - - com.networknt - json-schema-validator - ${json-schema-validator.version} - - - org.skyscreamer - jsonassert - ${jsonassert.version} - test - - - - - - - github - GitHub Apache Maven Packages - https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} - - - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - + + + + + Eclipse AAS Model for Java (AAS4J) implements the specification of the Asset Administration Shell (AAS) such as metamodels, submodels, serialization and deserialization modules, and validators based on the AAS specifications.. + Eclipse Digital Twin - AAS Model for Java (AAS4J) + https://github.com/eclipse-digitaltwin/aas4j + + + SAP SE + https://projects.eclipse.org/projects/dt.aas4j/who + + + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + https://projects.eclipse.org/projects/dt.aas4j/who + + + + + scm:git:git://github.com/eclipse-digitaltwin/aas4j.git + scm:git:git:github.com/eclipse-digitaltwin/aas4j.git + https://github.com/eclipse-digitaltwin/aas4j/tree/main + + + 4.0.0 + org.eclipse.digitaltwin.aas4j + aas4j-dataformat-parent + ${revision} + pom + + model + dataformat-aasx + dataformat-core + dataformat-json + dataformat-xml + dataformat-rdf + + + 1 + 1 + 0-SNAPSHOT + ${revision.major}.${revision.minor}.${revision.patch} + 1.1.0-SNAPSHOT + + UTF-8 + UTF-8 + + 3.13.0 + 3.3.1 + 1.6.0 + 3.0.1 + 3.4.2 + 3.11.2 + 3.8.0 + 3.3.1 + 0.8.12 + 4.8.179 + 1.15 + 2.18.0 + 1.27.1 + 3.17.0 + 33.4.0-jre + 5.0.1 + 3.0 + 2.18.2 + 2.0.1.Final + 2.3.1 + 2.1.0 + 5.3.0 + 1.5.3 + 1.5.5 + 4.13.2 + 1.1.1 + 2.7.8 + 5.4.0 + 2.0.16 + 1.3.2 + 4.4.1 + 2.12.1 + 2.10.0 + 5.15.2 + 0.0.20131108.vaadin1 + + + + + org.jacoco + jacoco-maven-plugin + ${plugin.jacoco.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + jacoco-check + + check + + + + + GROUP + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${plugin.compiler.version} + + 11 + 11 + + + + org.codehaus.mojo + flatten-maven-plugin + ${plugin.flatten.version} + + true + + + + + + + + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${plugin.projectinfo.version} + + + org.apache.maven.plugins + maven-source-plugin + ${plugin.source.version} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${plugin.javadoc.version} + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + + + + + + + + MavenCentral + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + + + org.apache.commons + commons-compress + ${commons-compress.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + junit + junit + ${junit.version} + test + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + org.hamcrest + hamcrest + ${hamcrest.version} + test + + + ${project.groupId} + aas4j-dataformat-core + ${revision} + + + ${project.groupId} + aas4j-dataformat-xml + ${revision} + + + ${project.groupId} + aas4j-model + ${model.version} + + + ${project.groupId} + aas4j-dataformat-core + tests + ${revision} + + + org.apache.poi + poi-ooxml + ${poi.version} + + + commons-io + commons-io + ${commons-io.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + io.github.classgraph + classgraph + ${classgraph.version} + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + pl.pragmatists + JUnitParams + ${junit-params.version} + + + com.vaadin.external.google + android-json + ${vaadin.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + + + org.xmlunit + xmlunit-core + ${xmlunit.version} + test + + + org.xmlunit + xmlunit-matchers + ${xmlunit.version} + test + + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + + + com.networknt + json-schema-validator + ${json-schema-validator.version} + + + org.skyscreamer + jsonassert + ${jsonassert.version} + test + + + + + + + github + GitHub Apache Maven Packages + https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} + + + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + +