From a46a3e3b305d33ca5cfee6a7496b2c7f7ea46ea0 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 16:59:13 +0100 Subject: [PATCH 001/160] Revert old rdf module --- dataformat-rdf/pom.xml | 45 + .../v3/dataformat/rdf/FallbackSerializer.java | 42 + .../v3/dataformat/rdf/IgnoreTypeMixIn.java | 22 + .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 52 + .../v3/dataformat/rdf/JsonLDSerializer.java | 196 +++ .../rdf/JsonLDSerializerModifier.java | 44 + .../dataformat/rdf/JsonLdEnumSerializer.java | 88 ++ .../dataformat/rdf/LangStringSerializer.java | 53 + .../aas4j/v3/dataformat/rdf/Parser.java | 1170 +++++++++++++++++ .../aas4j/v3/dataformat/rdf/Serializer.java | 308 +++++ .../v3/dataformat/rdf/UriSerializer.java | 53 + .../rdf/custom/BigDecimalSerializer.java | 42 + .../rdf/custom/JsonLdEnumMixin.java | 23 + .../rdf/custom/LangStringMixin.java | 35 + .../rdf/custom/ReflectiveMixInResolver.java | 41 + .../XMLGregorianCalendarDeserializer.java | 49 + .../XMLGregorianCalendarSerializer.java | 47 + .../AdministrativeInformationMixin.java | 38 + .../AnnotatedRelationshipElementMixin.java | 33 + .../mixins/AssetAdministrationShellMixin.java | 47 + .../rdf/mixins/AssetInformationMixin.java | 60 + .../rdf/mixins/BasicEventElementMixin.java | 79 ++ .../v3/dataformat/rdf/mixins/BlobMixin.java | 38 + .../rdf/mixins/CapabilityMixin.java | 27 + .../rdf/mixins/ConceptDescriptionMixin.java | 33 + .../rdf/mixins/DataElementMixin.java | 37 + .../mixins/DataSpecificationContentMixin.java | 33 + .../DataSpecificationIEC61360Mixin.java | 106 ++ .../DataSpecificationPhysicalUnitMixin.java | 99 ++ .../EmbeddedDataSpecificationMixin.java | 44 + .../v3/dataformat/rdf/mixins/EntityMixin.java | 54 + .../rdf/mixins/EnvironmentMixin.java | 47 + .../rdf/mixins/EventElementMixin.java | 33 + .../rdf/mixins/EventMessageMixin.java | 27 + .../dataformat/rdf/mixins/ExtensionMixin.java | 50 + .../v3/dataformat/rdf/mixins/FileMixin.java | 38 + .../dataformat/rdf/mixins/FormulaMixin.java | 33 + .../rdf/mixins/HasDataSpecificationMixin.java | 49 + .../rdf/mixins/HasExtensionsMixin.java | 33 + .../dataformat/rdf/mixins/HasKindMixin.java | 39 + .../rdf/mixins/HasSemanticsMixin.java | 49 + .../rdf/mixins/IdentifiableMixin.java | 47 + .../mixins/IdentifierKeyValuePairMixin.java | 44 + .../rdf/mixins/IdentifierMixin.java | 31 + .../v3/dataformat/rdf/mixins/KeyMixin.java | 39 + .../mixins/MultiLanguagePropertyMixin.java | 40 + .../rdf/mixins/ObjectAttributesMixin.java | 33 + .../dataformat/rdf/mixins/OperationMixin.java | 45 + .../rdf/mixins/OperationVariableMixin.java | 32 + .../rdf/mixins/PolicyDecisionPointMixin.java | 32 + .../mixins/PolicyEnforcementPointsMixin.java | 32 + .../mixins/PolicyInformationPointsMixin.java | 39 + .../dataformat/rdf/mixins/PropertyMixin.java | 44 + .../rdf/mixins/QualifiableMixin.java | 40 + .../dataformat/rdf/mixins/QualifierMixin.java | 50 + .../v3/dataformat/rdf/mixins/RangeMixin.java | 44 + .../dataformat/rdf/mixins/ReferableMixin.java | 58 + .../rdf/mixins/ReferenceElementMixin.java | 32 + .../dataformat/rdf/mixins/ReferenceMixin.java | 41 + .../rdf/mixins/RelationshipElementMixin.java | 43 + .../dataformat/rdf/mixins/ResourceMixin.java | 40 + .../rdf/mixins/SpecificAssetIdMixin.java | 47 + .../rdf/mixins/SubjectAttributesMixin.java | 33 + .../SubmodelElementCollectionMixin.java | 45 + .../rdf/mixins/SubmodelElementListMixin.java | 61 + .../rdf/mixins/SubmodelElementMixin.java | 40 + .../dataformat/rdf/mixins/SubmodelMixin.java | 33 + .../dataformat/rdf/mixins/ValueListMixin.java | 36 + .../rdf/mixins/ValueReferencePairMixin.java | 38 + .../v3/dataformat/rdf/mixins/ViewMixin.java | 33 + .../rdf/preprocessing/BasePreprocessor.java | 53 + .../rdf/preprocessing/JsonPreprocessor.java | 42 + .../preprocessing/TypeNamePreprocessor.java | 194 +++ .../aas4j/v3/dataformat/rdf/ParserTest.java | 153 +++ .../v3/dataformat/rdf/SerializerTest.java | 100 ++ .../v3/dataformat/rdf/SerializerUtil.java | 45 + dataformat-rdf/src/test/resources/AASFull.ttl | 354 +++++ .../resources/AAS_Reference_shortExample.nt | 16 + .../resources/AAS_Reference_shortExample.ttl | 27 + .../AssetAdministrationShell_Example.ttl | 56 + .../src/test/resources/Complete_Example.ttl | 347 +++++ .../src/test/resources/Overall-Example.nt | 253 ++++ .../src/test/resources/ReferenceExample.ttl | 18 + .../Submodel_SubmodelElement_Example.ttl | 137 ++ .../Submodel_SubmodelElement_shortExample.nt | 25 + .../Submodel_SubmodelElement_shortExample.ttl | 42 + .../resources/example-from-serializer.jsonld | 88 ++ 87 files changed, 6558 insertions(+) create mode 100644 dataformat-rdf/pom.xml create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java create mode 100644 dataformat-rdf/src/test/resources/AASFull.ttl create mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt create mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl create mode 100644 dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Complete_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Overall-Example.nt create mode 100644 dataformat-rdf/src/test/resources/ReferenceExample.ttl create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl create mode 100644 dataformat-rdf/src/test/resources/example-from-serializer.jsonld diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml new file mode 100644 index 000000000..8d65df6de --- /dev/null +++ b/dataformat-rdf/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + org.eclipse.digitaltwin.aas4j + dataformat-parent + ${revision} + + dataformat-rdf + Asset Administration Shell RDF-Serializer + + + + ${groupId} + dataformat-core + ${revision} + + + ${groupId} + dataformat-core + ${revision} + tests + test + + + org.apache.jena + jena-arq + ${jena.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + pl.pragmatists + JUnitParams + ${junit-params.version} + test + + + diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java new file mode 100644 index 000000000..1522e476d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java @@ -0,0 +1,42 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import java.io.IOException; +import java.util.Map; + +public class FallbackSerializer extends StdSerializer> { + + + public FallbackSerializer() { + this(null); + } + + public FallbackSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(Map value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeString(value.toString()); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java new file mode 100644 index 000000000..816c77d39 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java @@ -0,0 +1,22 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonIgnoreType; + +@JsonIgnoreType +public class IgnoreTypeMixIn { +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java new file mode 100644 index 000000000..b5a790d60 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java @@ -0,0 +1,52 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +import java.math.BigDecimal; +import java.net.URI; +import java.util.Map; + + +import javax.xml.datatype.XMLGregorianCalendar; + + +/** + * Jackson module which provides support for JSON-LD serialization + */ +public class JsonLDModule extends SimpleModule { + + + public JsonLDModule(Map idMap) { + super(); + + setSerializerModifier(new JsonLDSerializerModifier(idMap)); + + addSerializer(XMLGregorianCalendar.class, new XMLGregorianCalendarSerializer()); + addDeserializer(XMLGregorianCalendar.class, new XMLGregorianCalendarDeserializer()); + addSerializer(BigDecimal.class, new BigDecimalSerializer()); + + addSerializer(URI.class, new UriSerializer()); + addSerializer(LangString.class, new LangStringSerializer()); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java new file mode 100644 index 000000000..853fe1847 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java @@ -0,0 +1,196 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.WritableTypeId; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import com.fasterxml.jackson.databind.ser.BeanSerializer; +import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.math.BigInteger; +import java.util.*; +import java.util.stream.Stream; + + +public class JsonLDSerializer extends BeanSerializer { + + private final Logger logger = LoggerFactory.getLogger(JsonLDSerializer.class); + + private static int currentRecursionDepth = 0; + + static final Map contextItems = new HashMap<>(); + + private final Map idMap; + + JsonLDSerializer(BeanSerializerBase src, Map idMap) { + super(src); + this.idMap = Objects.requireNonNullElseGet(idMap, HashMap::new); + } + + + + @Override + public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { + gen.setCurrentValue(bean); + + currentRecursionDepth++; + gen.writeStartObject(); + + if (currentRecursionDepth == 1) { + Map filteredContext = new HashMap<>(); + filterContextWrtBean(bean, filteredContext); + gen.writeObjectField("@context", filteredContext); + //gen.writeStringField("@context", "https://jira.iais.fraunhofer.de/stash/projects/ICTSL/repos/ids-infomodel-commons/raw/jsonld-context/3.0.0/context.jsonld"); // only add @context on top level + + } + + if(idMap.containsKey(bean)) + { + gen.writeStringField("@id", idMap.get(bean)); + } + else + { + String randomUri = "https://admin-shell.io/autogen/" + bean.getClass().getSimpleName() + "/" + UUID.randomUUID(); + idMap.put(bean, randomUri); + gen.writeStringField("@id", randomUri); + } + + WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_OBJECT); + String resolvedTypeId = typeIdDef.id != null ? typeIdDef.id.toString() : typeSer.getTypeIdResolver().idFromValue(bean); + if (resolvedTypeId != null) { + gen.writeStringField(typeIdDef.asProperty, resolvedTypeId); + } + if (_propertyFilterId != null) { + serializeFieldsFiltered(bean, gen, provider); + } else { + serializeFields(bean, gen, provider); + } + gen.writeEndObject(); + currentRecursionDepth--; + } + + + private void filterContextWrtBean(Object bean, Map filteredContext) { + //Some default entries for AAS + filteredContext.put("aas", "https://admin-shell.io/aas/3/0/RC02/"); + //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); + + if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion + + //Check if RdfResource or TypedLiteral is used. They contain a field called "type" which can reference to any namespace + //Therefore it is vital to also check the value of the type field for prefixes that need to be included in the context + if(bean.getClass().getSimpleName().equals("LangString")) + { + //LangString is of type rdf:langString, so this must be present + filteredContext.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + } + contextItems.forEach((p, u) -> { + JsonTypeName typeNameAnnotation = bean.getClass().getAnnotation(JsonTypeName.class); + if(typeNameAnnotation != null && typeNameAnnotation.value().contains(p)) { + filteredContext.put(p, u); + } + Stream.of(bean.getClass().getMethods()).forEach(m -> { + JsonProperty propertyAnnotation = m.getAnnotation(JsonProperty.class); + if(propertyAnnotation != null && propertyAnnotation.value().contains(p)) { + filteredContext.put(p, u); + } + }); + }); + Stream.of(bean.getClass().getMethods()).forEach(m -> { + // run though all properties and check annotations. These annotations should contain the prefixes + JsonProperty prop = m.getAnnotation(JsonProperty.class); + if(prop != null) + { + for(Map.Entry entry : contextItems.entrySet()) + { + if(prop.value().startsWith(entry.getKey())) + { + filteredContext.put(entry.getKey(), entry.getValue()); + break; + } + } + } + }); + // run through fields recursively + for(Field f : getAllFields(new HashSet<>(), bean.getClass())) { + + if(Collection.class.isAssignableFrom(f.getType())) + { + try { + if(f.getType().getName().startsWith("java.") && !f.getType().getName().startsWith("java.util")) continue; + boolean accessible = f.isAccessible(); + f.setAccessible(true); + Collection c = (Collection) f.get(bean); + if(c == null) { + continue; + } + for(Object o : c) + { + filterContextWrtBean(o, filteredContext); + } + f.setAccessible(accessible); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (f.getType().isPrimitive() || f.getType().isEnum() || f.getType().isArray() + || f.getType().getName().contains("java.") + || f.getType().getName().contains("javax.")) continue; + + try { + boolean wasAccessible = f.isAccessible(); + f.setAccessible(true); + filterContextWrtBean(f.get(bean), filteredContext); + f.setAccessible(wasAccessible); + } catch (IllegalAccessException ignored) { + //logger.error("setting accessible failed"); //We can catch that here, as IllegalReflectiveAccess cannot occur on our own packages + } + + //f.trySetAccessible(wasAccessible); + + } + + } + + /** + * This function retrieves a set of all available fields of a class, including inherited fields + * @param fields Set to which discovered fields will be added. An empty HashSet should do the trick + * @param type The class for which fields should be discovered + * @return set of all available fields + */ + private static Set getAllFields(Set fields, Class type) { + fields.addAll(Arrays.asList(type.getDeclaredFields())); + + if (type.getSuperclass() != null) { + getAllFields(fields, type.getSuperclass()); + } + + return fields; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java new file mode 100644 index 000000000..d1bff7f5c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java @@ -0,0 +1,44 @@ +/* + * 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.rdf; + + +import com.fasterxml.jackson.databind.BeanDescription; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; +import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; + +import java.util.Map; + + +public class JsonLDSerializerModifier extends BeanSerializerModifier { + + private final Map idMap; + + public JsonLDSerializerModifier(Map idMap) { + this.idMap = idMap; + } + + @Override + public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer serializer) { + if (serializer instanceof BeanSerializerBase) { + return new JsonLDSerializer((BeanSerializerBase) serializer, idMap); + } else { + return serializer; + } + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java new file mode 100644 index 000000000..8d544ab14 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java @@ -0,0 +1,88 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.io.IOException; + +public class JsonLdEnumSerializer extends JsonSerializer> { + + + @Override + public void serialize(Enum value, JsonGenerator gen, SerializerProvider provider) throws IOException { + //Generated Enum classes of the admin shell have @IRI annotations, which need to be used to provide proper RDF + if(value.getClass().isEnum() && value.getClass().getName().startsWith("org.eclipse.digitaltwin.aas4j.")) + { + //Try to get annotation value to get the IRI used in the ontology + if(value.getClass().getAnnotation(IRI.class) != null && value.getClass().getAnnotation(IRI.class).value().length > 0) + { + gen.writeStartObject(); + gen.writeStringField("@type", value.getClass().getAnnotation(IRI.class).value()[0]); + + //Try to extract exact IRI of the enum value, if present + try { + var annotation = value.getClass().getField(value.name()).getAnnotation(IRI.class); + if(annotation != null && annotation.value().length > 0) + { + gen.writeStringField("@id", annotation.value()[0]); + } + else + { + //Didn't find an @IRI annotation - fall back to using class annotation + field name + gen.writeStringField("@id", translate(value.getClass(), value.name())); + } + } + //Should be impossible + catch (NoSuchFieldException e) + { + //Didn't find an @IRI annotation - fall back to using class annotation + field name + gen.writeStringField("@id", translate(value.getClass(), value.name())); + } + gen.writeEndObject(); + } + else + { + gen.writeString(translate(value.getClass(), value.name())); + } + + + } else { + provider.findValueSerializer(Enum.class).serialize(value, gen, provider); + } + } + + + + public static String translate(Class enumClass, String input) { + String[] iriValues = enumClass.getAnnotation(IRI.class).value(); + String result = ""; + if(iriValues.length > 0) + { + result = iriValues[0]; + if(!result.endsWith("/")) + { + result += "/"; + } + } + result += input; + return result; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java new file mode 100644 index 000000000..e90100562 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java @@ -0,0 +1,53 @@ +/* + * 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.rdf; + +import java.io.IOException; + + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +public class LangStringSerializer extends StdSerializer { + + + public LangStringSerializer() { + this(null); + } + + public LangStringSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(LangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeStartObject(); + if(value.getLanguage() != null && !value.getLanguage().isEmpty()) + { + gen.writeStringField("@language", value.getLanguage()); + } + else + { + gen.writeStringField("@type", "rdf:langString"); + } + gen.writeStringField("@value", value.getText()); + gen.writeEndObject(); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java new file mode 100644 index 000000000..c995160e5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java @@ -0,0 +1,1170 @@ +/* + * 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.rdf; + +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangString; +import org.apache.jena.datatypes.DatatypeFormatException; +import org.apache.jena.query.*; +import org.apache.jena.rdf.model.*; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; +import org.apache.jena.riot.RDFLanguages; +import org.apache.jena.riot.RiotException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.lang.reflect.*; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.ZonedDateTime; +import java.time.format.DateTimeParseException; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * Internal class to handle the parsing of JSON-LD into java objects + * @author maboeckmann + */ +class Parser { + + private final Logger logger = LoggerFactory.getLogger(Parser.class); + + private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); + + static Map knownNamespaces = new HashMap<>(); + + /** + * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle + * @param inputModel Model on which queries are to be evaluated from which information can be retrieved + * @param objectUri URI of the object to be handled + * @param targetClass Variable containing the class which should be returned + * @param Class which should be returned + * @return Object of desired class, filled with the values extracted from inputModel + * @throws IOException thrown if the parsing fails + */ + private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { + try { + + //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on + //Check whether we are dealing with an instantiable class (i.e. no interface and no abstract class) + boolean currentObjectIsBlankNode = false; + if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { + //We don't know the desired class yet (current targetClass is not instantiable). This is only known for the root object + ArrayList> implementingClasses = getImplementingClasses(targetClass); + String queryString; + //Get a list of all "rdf:type" statements in our model + //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax + try { + new URL(objectUri); + } + catch (MalformedURLException e) + { + currentObjectIsBlankNode = true; + } + if(currentObjectIsBlankNode) + { + //Object is a blank node, so the subject URI cannot be used + queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; + } + else + { + //Not a blank node, so we can work with the subject URI + queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; + } + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); + ResultSet resultSet = queryExecution.execSelect(); + + if (!resultSet.hasNext()) { + queryExecution.close(); + throw new IOException("Could not extract class of child object. ID: " + objectUri); + } + + //Class candidateClass = null; + + String fullName = "No triple present indicating type."; + while (resultSet.hasNext()) { + QuerySolution solution = resultSet.nextSolution(); + fullName = solution.get("type").toString(); + + //Expected URI is something like https://w3id.org/idsa/core/ClassName (and we want ClassName) + String className = fullName.substring(fullName.lastIndexOf('/') + 1); + + //Some namespaces use "#" instead of "/" + if (className.contains("#")) { + className = className.substring(className.lastIndexOf("#") + 1); + } + + for (Class currentClass : implementingClasses) { + //Is this class instantiable? + if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { + //candidateClass = currentClass; + if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + targetClass = (Class) currentClass; + break; + } + } + } + } + queryExecution.close(); + //Did we find "the" class, i.e. instantiable and name matches? + if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { + //No, the current targetClass cannot be instantiated. Do we have a candidate class? + //if (candidateClass != null) { + throw new IOException("Did not find an instantiable class for " + objectUri + " matching expected class name (" + targetClass.getSimpleName() + "). Object has type: " + fullName); + //targetClass = (Class) candidateClass; + //} + } + } + + //Enums have no constructors + if(targetClass.isEnum()) + { + return handleEnum(targetClass, objectUri); + } + + //Get constructor (which is package private for our classes) and make it accessible + Constructor constructor = targetClass.getDeclaredConstructor(); + constructor.setAccessible(true); + + //Instantiate new object, which will be returned at the end + T returnObject = constructor.newInstance(); + + //Get methods + Method[] methods = returnObject.getClass().getDeclaredMethods(); + + //Store methods in map. Key is the name of the RDF property without ids prefix + Map methodMap = new HashMap<>(); + + //Get all relevant methods (setters, but not for label, comment or external properties) + Arrays.stream(methods).filter(method -> { + String name = method.getName(); + //Filter out irrelevant methods + return name.startsWith("set") && !name.equals("setProperty") && !name.equals("setComment") && !name.equals("setLabel"); // && !name.equals("setId"); + }).forEach(method -> { + //Remove "set" part + String reducedName = method.getName().substring(3); + + //Turn first character to lower case + char[] c = reducedName.toCharArray(); + c[0] = Character.toLowerCase(c[0]); + String finalName = new String(c); + methodMap.put(finalName, method); + + }); + + //There is no "setId" method in our CodeGen generated classes, so we get the field + /* TODO: No "id" field yet + Field idField = returnObject.getClass().getDeclaredField("id"); + + //Store whether or not it was accessible, so that we can undo making it accessible + boolean wasAccessible = idField.isAccessible(); + idField.setAccessible(true); + + //Set the ID of the object to be identical with the objectUri parameter + idField.set(returnObject, new URI(objectUri)); + idField.setAccessible(wasAccessible); + */ + + //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal + if(methodMap.isEmpty()) + { + return returnObject; + } + + + //A list which stores all those parameter names which may occur only once (i.e. those occurring in the GROUP BY clause) + List groupByKeys = new ArrayList<>(); + + StringBuilder queryStringBuilder = new StringBuilder(); + + for(Map.Entry entry : knownNamespaces.entrySet()) + { + queryStringBuilder.append("PREFIX ").append(entry.getKey()); + if(!entry.getKey().endsWith(":")) + { + queryStringBuilder.append(":"); + } + queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); + } + queryStringBuilder.append("SELECT"); + methodMap.forEach((key1, value) -> { + //Is the return type some sort of List? + if (Collection.class.isAssignableFrom(value.getParameterTypes()[0])) { + boolean isTypedLiteral = false; + //Yes, it is assignable multiple times. Concatenate multiple values together using some delimiter + try { + //ArrayLists are generics. We need to extract the name of the generic parameter as string and interpret that + String typeName = extractTypeNameFromCollection(value.getGenericParameterTypes()[0]); + + if (typeName.endsWith("LangString")) + isTypedLiteral = true; + } catch (IOException e) { + e.printStackTrace(); + } + if (isTypedLiteral) { + queryStringBuilder.append(" (GROUP_CONCAT(CONCAT('\"',?").append(key1).append(",'\"@', lang(?").append(key1).append("));separator=\"||\") AS ?").append(key1).append("sLang) "); + } + queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append(";separator=\"||\") AS ?").append(key1).append("s) "); + + //Additional case for blank nodes + queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append("Blank;separator=\"||\") AS ?").append(key1).append("sBlank) "); + + + } else { + //No, it's not a list. No need to aggregate + queryStringBuilder.append(" ?").append(key1); + //We will have to GROUP BY this variable though... + groupByKeys.add(key1); + } + }); + //Start the "WHERE" part - Fuseki does not expect the "WHERE" keyword, but just an "{" + queryStringBuilder.append(" { "); + + //In case of blank nodes, we can't work with the subject URI + if(currentObjectIsBlankNode) + { + queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); + } + else + { + queryStringBuilder.append(" <").append(objectUri).append(">"); + } + + //Make sure that the object is of the correct type + //This is particularly relevant in case of all fields being optional -- then one could simply parse a random object + queryStringBuilder.append(" a ").append(wrapIfUri(targetClass.getAnnotation(IRI.class).value()[0])).append(". "); + + for (Map.Entry entry : methodMap.entrySet()) { + //Is this a field which is annotated by NOT NULL? + //Attempt to find a field matching the setter method name + //E.g. for "setSomething", we search for a field with name "_something" (IDS way) and "something" + Field field = getFieldByName(targetClass, entry.getKey()); + + + //In AAS, every field is optional, as there are no validation annotations in the model + queryStringBuilder.append(" OPTIONAL {"); + + if(currentObjectIsBlankNode) + { + queryStringBuilder.append(" ?s "); + } + else { + queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function + } + //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) + //Find the annotation value containing a colon and interpret this as "prefix:predicate" + boolean foundAnnotation = false; + if(field.getAnnotation(IRI.class) != null) { + Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); + currentAnnotation.ifPresent(queryStringBuilder::append); + foundAnnotation = true; + } + if(!foundAnnotation) + { + logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); + queryStringBuilder.append("aas:").append(entry.getKey()); + } + //if(isBlank(?entry.getKey(), use value of artificial, use original value) + queryStringBuilder.append(" ?").append(entry.getKey()).append(" ."); //object + + //In case of the object being a blank node, we construct a second result variable with the blank node id + queryStringBuilder.append("OPTIONAL { ?").append(entry.getKey()).append(" <").append(blankNodeIdPropertyUri).append("> ?").append(entry.getKey()).append("Blank . } "); + + queryStringBuilder.append("} "); + } + + + queryStringBuilder.append(" } "); + + //Do we need to group? We do, if there is at least one property which can occur multiple times + //We added all those properties, which may only occur once, to the groupByKeys list + if (!groupByKeys.isEmpty()) { + queryStringBuilder.append("GROUP BY"); + for (String key : groupByKeys) { + queryStringBuilder.append(" ?").append(key); + } + } + + String queryString = queryStringBuilder.toString(); + + StringBuilder queryForOtherProperties = new StringBuilder(); + //Query for all unknown properties and their values + //Select properties and values only + + if(!targetClass.equals(LangString.class)) { //LangString has no additional properties map. Skip this step + + //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } + for (Map.Entry entry : knownNamespaces.entrySet()) { + queryForOtherProperties.append("PREFIX ").append(entry.getKey()); + if (!entry.getKey().endsWith(":")) { + queryForOtherProperties.append(":"); + } + queryForOtherProperties.append(" <").append(entry.getValue()).append(">\n"); + } + + + //Respect ALL properties and values + queryForOtherProperties.append(" SELECT ?p ?o { <").append(objectUri).append("> ?p ?o .\n"); + + //Exclude known properties + queryForOtherProperties.append("FILTER (?p NOT IN (rdf:type"); + + //Predicates usually look like: .append("ids:").append(entry.getKey()) + for (Map.Entry entry : methodMap.entrySet()) { + queryForOtherProperties.append(", "); + + Field field = getFieldByName(targetClass, entry.getKey()); + Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).filter(annotation -> annotation.contains(":")).filter(s -> s.length() > 1).findFirst(); + if (currentAnnotation.isPresent()) { + queryForOtherProperties.append(wrapIfUri(currentAnnotation.get())); + } else { + logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); + queryForOtherProperties.append("aas:").append(entry.getKey()); + } + } + + queryForOtherProperties.append(")). } "); + + + //Now that we searched for all "known properties", let's search for all unrecognized content and append it to a generic properties map + + Query externalPropertiesQuery = QueryFactory.create(queryForOtherProperties.toString()); + QueryExecution externalPropertiesQueryExecution = QueryExecutionFactory.create(externalPropertiesQuery, inputModel); + ResultSet externalPropertiesResultSet = externalPropertiesQueryExecution.execSelect(); + + // now as all declared instances and classes are treated, which are also represented in the respective java + // dependency, take care about the ones within foreign namespaces and add those to the 'properties' field + // note that not all models (e.g. AAS) have such methods. In case they do not exist, skip adding external properties + + try { + Method setProperty = returnObject.getClass().getDeclaredMethod("setProperty", String.class, Object.class); + Method getProperties = returnObject.getClass().getDeclaredMethod("getProperties"); + + while (externalPropertiesResultSet.hasNext()) { + QuerySolution externalPropertySolution = externalPropertiesResultSet.next(); + + HashMap currentProperties = (HashMap) getProperties.invoke(returnObject); + + //Avoid NullPointerException + if (currentProperties == null) { + currentProperties = new HashMap<>(); + } + + String propertyUri = externalPropertySolution.get("p").toString(); + + //Does this key already exist? If yes, we need to store the value as array to not override them + if (currentProperties.containsKey(propertyUri)) { + //If it is not an array list yet, turn it into one + if (!(currentProperties.get(propertyUri) instanceof ArrayList)) { + ArrayList newList = new ArrayList<>(); + newList.add(currentProperties.get(propertyUri)); + currentProperties.put(propertyUri, newList); + } + } + + //Literals and complex objects need to be handled differently + //Literals can be treated as flat values, whereas complex objects require recursive calls + if (externalPropertySolution.get("o").isLiteral()) { + Object o = handleForeignLiteral(externalPropertySolution.getLiteral("o")); + //If it is already an ArrayList, add new value to it + if (currentProperties.containsKey(propertyUri)) { + ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); + currentPropertyArray.add(o); + setProperty.invoke(returnObject, propertyUri, currentPropertyArray); + } + //Otherwise save as new plain value + else { + setProperty.invoke(returnObject, propertyUri, o); + } + } else { + //It is a complex object. Distinguish whether or not we need to store as array + HashMap subMap = handleForeignNode(externalPropertySolution.getResource("o"), new HashMap<>(), inputModel); + subMap.put("@id", externalPropertySolution.getResource("o").getURI()); + if (currentProperties.containsKey(propertyUri)) { + ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); + currentPropertyArray.add(subMap); + setProperty.invoke(returnObject, propertyUri, currentPropertyArray); + } else { + setProperty.invoke(returnObject, propertyUri, subMap); + } + } + } + externalPropertiesQueryExecution.close(); + } + catch (NoSuchMethodException ignored) + { + //Method does not exist, skip + } + } + + + + Query query; + try { + query = QueryFactory.create(queryString); + } + catch (QueryParseException e) + { + logger.error(queryString); + throw e; + } + + //Evaluate query + QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); + ResultSet resultSet = queryExecution.execSelect(); + + + if (!resultSet.hasNext()) { + queryExecution.close(); + //no content... + return returnObject; + } + + //SPARQL binding present, iterate over result and construct return object + while (resultSet.hasNext()) { + QuerySolution querySolution = resultSet.next(); + + //Check if there are fields which have more values than allowed + if (resultSet.hasNext()) { + String value1 = "", value2 = "", parameterName = ""; + QuerySolution querySolution2 = resultSet.next(); + Iterator varNamesIt = querySolution2.varNames(); + while(varNamesIt.hasNext()) + { + String varName = varNamesIt.next(); + if(querySolution.contains(varName)) + { + if(!querySolution.get(varName).equals(querySolution2.get(varName))) + { + parameterName = varName; + value1 = querySolution.get(varName).toString(); + value2 = querySolution2.get(varName).toString(); + break; + } + } + } + if(!value1.isEmpty()) + { + throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); + } + throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); + } + + //No value occurs more often than allowed + for (Map.Entry entry : methodMap.entrySet()) { + + //What is this method setting? Get the expected parameter type and check whether it is some complex sub-object and whether this is a list + Class currentType = entry.getValue().getParameterTypes()[0]; + + String sparqlParameterName = entry.getKey(); + + if (Collection.class.isAssignableFrom(currentType)) { + sparqlParameterName += "s"; //plural form for the concatenated values + } + if(!querySolution.contains(sparqlParameterName)) + { + sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead + //TODO: Note: This would not yield full results yet in case some of the values are encapsulated + // in blank nodes and some are not, for the same property + } + if (querySolution.contains(sparqlParameterName)) { + String currentSparqlBinding = querySolution.get(sparqlParameterName).toString(); + + boolean objectIsBlankNode = querySolution.get(sparqlParameterName).isResource() && querySolution.get(sparqlParameterName).asNode().isBlank(); + String blankNodeId = ""; + //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject + //For that case, we add some artificial identifiers here + if(objectIsBlankNode) { + blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); + } + if (currentType.isEnum()) { + //Two possibilities: + //1: The URI of the enum value is given directly e.g. ?s ?p + //2: The URI of the enum value is encapsulated in a blank node, e.g. + // ?s ?p [ a demo:myEnum, demo:enumValue ] + if(objectIsBlankNode) + { + + Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); + QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); + ResultSet innerEnumQueryExecutionResultSet = innerEnumQueryExecution.execSelect(); + + //Only throw this if there is no successful execution + IOException anyIOException = null; + boolean oneSuccessfulEnumFound = false; + while(innerEnumQueryExecutionResultSet.hasNext()) + { + try { + entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); + oneSuccessfulEnumFound = true; + break; //Stop after the first successful execution + } + catch (IOException e) //There might be errors, if multiple types are present, see example above + { + anyIOException = e; + } + } + //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception + if(anyIOException != null && !oneSuccessfulEnumFound) + throw new IOException("Could not parse Enum. ", anyIOException); + innerEnumQueryExecution.close(); + } + else { + entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); + } + continue; + } + + + //There is a binding. If it is a complex sub-object, we need to recursively call this function + if (Collection.class.isAssignableFrom(currentType)) { + //We are working with ArrayLists. + //Here, we need to work with the GenericParameterTypes instead to find out what kind of ArrayList we are dealing with + String typeName = extractTypeNameFromCollection(entry.getValue().getGenericParameterTypes()[0]); + if (isArrayListTypePrimitive(entry.getValue().getGenericParameterTypes()[0])) { + if (typeName.endsWith("LangString")) { + try { + currentSparqlBinding = querySolution.get(sparqlParameterName + "Lang").toString(); + } catch (NullPointerException e) { + //logger.warn("Failed to retrieve localized/typed values of " + currentSparqlBinding + ". Make sure that namespaces used in this property are known and valid. Proceeding without localized values and interpreting as string."); + //logger.warn("Query was: " + queryString); + //logger.warn("Attempted to fetch: " + sparqlParameterName + "Lang"); + } + } + ArrayList list = new ArrayList<>(); + //Two pipes were used as delimiter above + //Introduce set to deduplicate + Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); + for (String s : allElements) { + Literal literal; + //querySolution.get(sparqlParameterName). + if (s.endsWith("@")) { + s = s.substring(2, s.length() - 3); + literal = ResourceFactory.createStringLiteral(s); + } else if (s.startsWith("\\")) { + //turn something like \"my Desc 1\"@en to "my Desc 1"@en + s = s.substring(1).replace("\\\"@", "\"@"); + literal = ResourceFactory.createLangLiteral(s.substring(1, s.lastIndexOf("@") - 1), s.substring(s.lastIndexOf("@") + 1)); + } else { + literal = ResourceFactory.createPlainLiteral(s); + } + + //Is the type of the ArrayList some built in Java primitive? + + if (builtInMap.containsKey(typeName)) { + //Yes, it is. We MUST NOT call Class.forName(name)! + list.add(handlePrimitive(builtInMap.get(typeName), literal, null)); + } else { + //Not a Java primitive, we may call Class.forName(name) + list.add(handlePrimitive(Class.forName(typeName), literal, s)); + } + } + entry.getValue().invoke(returnObject, list); + } else { + //List of complex sub-objects, such as a list of Resources in a ResourceCatalog + ArrayList list = new ArrayList<>(); + Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); + for (String s : allElements) { + if (Class.forName(typeName).isEnum()) { + list.add(handleEnum(Class.forName(typeName), s)); + } else { + list.add(handleObject(inputModel, s, Class.forName(typeName))); + } + } + entry.getValue().invoke(returnObject, list); + } + } + + //Not an ArrayList of objects expected, but rather one object + else { + //Our implementation of checking for primitives (i.e. also includes URLs, Strings, XMLGregorianCalendars, ...) + if (isPrimitive(currentType)) { + + Literal literal = null; + try { + literal = querySolution.getLiteral(sparqlParameterName); + } catch (Exception ignored) { + } + + entry.getValue().invoke(returnObject, handlePrimitive(currentType, literal, currentSparqlBinding)); + + } else { + //Not a primitive object, but a complex sub-object. Recursively call this function to handle it + if (objectIsBlankNode) { + entry.getValue().invoke(returnObject, handleObject(inputModel, blankNodeId, entry.getValue().getParameterTypes()[0])); + } else { + + entry.getValue().invoke(returnObject, handleObject(inputModel, currentSparqlBinding, entry.getValue().getParameterTypes()[0])); + } + } + } + } + + } + } + queryExecution.close(); + + return returnObject; + } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchFieldException | URISyntaxException | DatatypeConfigurationException | ClassNotFoundException e) { + throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); + } + } + + /** + * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" + * @param input Input URI, possibly a prefixed value + * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" + */ + private String wrapIfUri(String input) + { + if(input.startsWith("http://") || input.startsWith("https://")) + { + return "<" + input + ">"; + } + else { + return input; + } + } + + private Object handleForeignLiteral(Literal literal) throws URISyntaxException { + if(literal.getLanguage() != null && !literal.getLanguage().equals("")) + { + return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); + } + //If not, does it have some datatype URI? + //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) + //{ + // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); + //} + //If both is not true, add it as normal string + else + { + return literal.getString(); + } + } + + private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { + //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map + //Literals must be handled "one recursion step above" + if(node.isLiteral()) + { + throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); + } + + //Run SPARQL query retrieving all information (only one hop!) about this node + String queryString = "SELECT ?s ?p ?o { BIND(<" + node.asNode().getURI() + "> AS ?s) . ?s ?p ?o . } "; + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, model); + ResultSet resultSet = queryExecution.execSelect(); + + + + //Handle outgoing properties of this foreign node + while(resultSet.hasNext()) + { + QuerySolution querySolution = resultSet.next(); + + String propertyUri = querySolution.get("p").toString(); + + if(map.containsKey(propertyUri)) { + //If it is not an array list yet, turn it into one + if (!(map.get(propertyUri) instanceof ArrayList)) { + ArrayList newList = new ArrayList<>(); + newList.add(map.get(propertyUri)); + map.put(propertyUri, newList); + } + } + + //Check the type of object we have. If it is a literal, just add it as "flat value" to the map + if(querySolution.get("o").isLiteral()) + { + //Handle some small literal. This function will turn this into a TypedLiteral if appropriate + Object o = handleForeignLiteral(querySolution.getLiteral("o")); + if(map.containsKey(propertyUri)) + { + map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(o)); + } + else + { + map.put(querySolution.get("p").toString(), o); + } + } + + //If it is not a literal, we need to call this function recursively. Create new map for sub object + else + { + //logger.info("Calling handleForeignNode for " + querySolution.getResource("o").toString()); + if(querySolution.getResource("s").toString().equals(querySolution.getResource("o").toString())) + { + logger.warn("Found self-reference on " + querySolution.getResource("s").toString() + " via predicate " + querySolution.getResource("p").toString() + " ."); + continue; + } + HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); + subMap.put("@id", querySolution.getResource("o").getURI()); + if(map.containsKey(propertyUri)) + { + map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(subMap)); + } + else { + map.put(querySolution.get("p").toString(), subMap); + } + } + } + queryExecution.close(); + return map; + } + + + /** + * Utility function, used to obtain the field corresponding to a setter function + * @param targetClass Class object in which we search for a field + * @param fieldName Guessed name of the field to search for + * @return Field object matching the name (possibly with leading underscore) + * @throws NoSuchFieldException thrown, if no such field exists + */ + private Field getFieldByName(Class targetClass, String fieldName) throws NoSuchFieldException { + try { + return targetClass.getDeclaredField("_" + fieldName); + } catch (NoSuchFieldException e) { + try { + return targetClass.getDeclaredField(fieldName); + } catch (NoSuchFieldException e2) { + try { + return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); + } + catch (NoSuchFieldException e3) + { + throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); + } + } + } + } + + /** + * Internal function to create a single enum object from a given desired class and a URL + * @param enumClass The enum class + * @param url The URL of the enum value + * @param Enum class + * @return Value of enumClass matching the input URL + * @throws IOException thrown if no matching enum value could be found + */ + private T handleEnum(Class enumClass, String url) throws IOException { + if (!enumClass.isEnum()) { + throw new RuntimeException("Non-Enum class passed to handleEnum function."); + } + T[] constants = enumClass.getEnumConstants(); + if(url.contains("/")) + { + url = url.substring(url.lastIndexOf("/") + 1); + } + for (T constant : constants) { + //We artificially added some underscores in the AAS ontology. TODO: This might be a bit dangerous for other ontologies, which really contain underscores in enum names + if (url.equalsIgnoreCase(constant.toString()) || url.equalsIgnoreCase(constant.toString().replace("_", ""))) { + return constant; + } + } + throw new IOException("Failed to find matching enum value for " + url + " . Available enums are: " + Arrays.stream(constants).map(Object::toString).collect(Collectors.joining(", "))); + } + + /** + * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) + * @param currentType Input Class (or primitive) + * @param literal Value as literal (can be null in some cases) + * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) + * @return Object of type currentType + * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI + * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails + * @throws IOException thrown, if no matching "simple class" could be found + */ + private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { + //Java way of checking for primitives, i.e. int, char, float, double, ... + if (currentType.isPrimitive()) { + if (literal == null) { + throw new IOException("Trying to handle Java primitive, but got no literal value"); + } + //If it is an actual primitive, there is no need to instantiate anything. Just give it to the function + switch (currentType.getSimpleName()) { + case "int": + return literal.getInt(); + case "boolean": + return literal.getBoolean(); + case "long": + return literal.getLong(); + case "short": + return literal.getShort(); + case "float": + return literal.getFloat(); + case "double": + return literal.getDouble(); + case "byte": + return literal.getByte(); + } + } + + //Check for the more complex literals + + //URI + if (URI.class.isAssignableFrom(currentType)) { + return new URI(currentSparqlBinding); + } + + //String + if (String.class.isAssignableFrom(currentType)) { + return currentSparqlBinding; + } + + //XMLGregorianCalendar + if (XMLGregorianCalendar.class.isAssignableFrom(currentType)) { + //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown + try { + return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); + } + catch (DatatypeFormatException | DateTimeParseException ignored) + { + //Not a valid dateTimeStamp. Try parsing just to Date + try { + Date date = new SimpleDateFormat().parse(literal.getValue().toString()); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(date); + return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); + } + catch (ParseException | DateTimeParseException | DatatypeFormatException e2) + { + //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException + throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); + } + } + } + + //TypedLiteral + if (LangString.class.isAssignableFrom(currentType)) { + //Either a language tagged string OR literal with type. Only one allowed + if (!literal.getLanguage().equals("")) { + return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); + } + return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag + } + + //BigInteger + if (BigInteger.class.isAssignableFrom(currentType)) { + return new BigInteger(literal.getString()); + } + + //BigDecimal + if (BigDecimal.class.isAssignableFrom(currentType)) { + return new BigDecimal(literal.getString()); + } + + //byte[] + if (byte[].class.isAssignableFrom(currentType)) { + return currentSparqlBinding.getBytes(); + } + + //Duration + if (Duration.class.isAssignableFrom(currentType)) { + return DatatypeFactory.newInstance().newDuration(currentSparqlBinding); + } + + throw new IOException("Unrecognized primitive type: " + currentType.getName()); + } + + /** + * This list contains all primitive Java types + */ + private final Map> builtInMap = new HashMap<>(); + { + builtInMap.put("int", Integer.TYPE); + builtInMap.put("long", Long.TYPE); + builtInMap.put("double", Double.TYPE); + builtInMap.put("float", Float.TYPE); + builtInMap.put("bool", Boolean.TYPE); + builtInMap.put("char", Character.TYPE); + builtInMap.put("byte", Byte.TYPE); + builtInMap.put("void", Void.TYPE); + builtInMap.put("short", Short.TYPE); + } + + private boolean isArrayListTypePrimitive(Type t) throws IOException { + String typeName = extractTypeNameFromCollection(t); + + try { + //Do not try to call Class.forName(primitive) -- that would throw an exception + if (builtInMap.containsKey(typeName)) return true; + return isPrimitive(Class.forName(typeName)); + } catch (ClassNotFoundException e) { + throw new IOException("Unable to retrieve class from generic", e); + } + } + + private String extractTypeNameFromCollection(Type t) throws IOException { + String typeName = t.getTypeName(); + if (!typeName.startsWith("java.util.ArrayList<") && !typeName.startsWith("java.util.List<") && !typeName.startsWith("java.util.Collection<")) { + throw new IOException("Illegal argument encountered while interpreting type parameter"); + } + //"" or super instead of extends + if(typeName.contains("?")) + { + //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces + return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); + } + //No extends + else + { + return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); + } + } + + private boolean isPrimitive(Class input) throws IOException { + //Collections are not simple + if (Collection.class.isAssignableFrom(input)) { + throw new IOException("Encountered collection in isPrimitive. Use isArrayListTypePrimitive instead"); + } + + //check for: plain/typed literal, XMLGregorianCalendar, byte[], RdfResource + //covers int, long, short, float, double, boolean, byte + if (input.isPrimitive()) return true; + + return (URI.class.isAssignableFrom(input) || + String.class.isAssignableFrom(input) || + XMLGregorianCalendar.class.isAssignableFrom(input) || + LangString.class.isAssignableFrom(input) || + BigInteger.class.isAssignableFrom(input) || + BigDecimal.class.isAssignableFrom(input) || + byte[].class.isAssignableFrom(input) || + Duration.class.isAssignableFrom(input)); + } + + /** + * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) + * @param rdfModel RDF input to be parsed + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(Model rdfModel, Class targetClass) throws IOException { + addArtificialBlankNodeLabels(rdfModel); + ArrayList> implementingClasses = getImplementingClasses(targetClass); + + // Query to retrieve all instances in the input graph that have a class assignment + // Assumption: if the class name (?type) is equal to the target class, this should be the + // instance we actually want to parse + String queryString = "SELECT ?id ?type { ?id a ?type . }"; + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, rdfModel); + ResultSet resultSet = queryExecution.execSelect(); + + if (!resultSet.hasNext()) { + throw new IOException("Could not extract class from input message"); + } + + Map> returnCandidates = new HashMap<>(); + + while (resultSet.hasNext()) { + QuerySolution solution = resultSet.nextSolution(); + String fullName = solution.get("type").toString(); + String className = fullName.substring(fullName.lastIndexOf('/') + 1); + + //In case of hash-namespaces + if(className.contains("#")) { + className = className.substring(className.lastIndexOf("#")); + } + + //For legacy purposes... + if (className.startsWith("ids:") || className.startsWith("aas:")) { + className = className.substring(4); + } + + for (Class currentClass : implementingClasses) { + if (currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + returnCandidates.put(solution.get("id").toString(), currentClass); + } + } + //if (returnCandidates.size() > 0) break; + } + queryExecution.close(); + + if (returnCandidates.size() == 0) { + throw new IOException("Could not transform input to an appropriate implementing class for " + targetClass.getName()); + } + + //At this point, we parsed the model and know to which implementing class we want to parse + //Check if there are several options available + if(returnCandidates.size() > 1) + { + String bestCandidateId = null; + Class bestCandidateClass = null; + long bestNumRelations = -1L; + for(Map.Entry> entry : returnCandidates.entrySet()) + { + String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + + " WHERE {" + + " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + + " OPTIONAL {?o ?p2 ?o2 . OPTIONAL {?o2 ?p3 ?o3 . OPTIONAL {?o3 ?p4 ?o4 . OPTIONAL {?o4 ?p5 ?o5 . } } } } }"; + Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); + QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); + long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); + if(graphSize > bestNumRelations) + { + bestNumRelations = graphSize; + bestCandidateId = entry.getKey(); + bestCandidateClass = entry.getValue(); + } + + determineBestCandidateQueryExecution.close(); + + } + logger.debug("The RDF graph contains multiple objects which can be parsed to " + targetClass.getSimpleName() + ". Determined " + bestCandidateId + " as best candidate."); + return (T) handleObject(rdfModel, bestCandidateId, bestCandidateClass); + } + + //We only reach this spot, if there is exactly one return candidate. Let's return it + Map.Entry> singularEntry = returnCandidates.entrySet().iterator().next(); + return (T) handleObject(rdfModel, singularEntry.getKey(), singularEntry.getValue()); + + } + + + /** + * Entry point to this class. Takes a message and a desired target class (can be an interface) + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(String message, Class targetClass) throws IOException { + Model model = readMessage(message); + return parseMessage(model, targetClass); + } + + /** + * Entry point to this class. Takes a message and a desired target class (can be an interface) + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param serializationFormat Input RDF format + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(String message, Class targetClass, Lang serializationFormat) throws IOException { + Model model = readMessage(message, serializationFormat); + return parseMessage(model, targetClass); + } + + /** + * Reads a message into an Apache Jena model, guessing the input language. + * Note: Guessing the language may cause some error messages during parsing attempts + * + * @param message Message to be read + * @return The model of the message + */ + private Model readMessage(String message) throws IOException { + + List supportedLanguages = new ArrayList<>( + Arrays.asList( + RDFLanguages.JSONLD, //JSON-LD first + RDFLanguages.TURTLE, //N-TRIPLE is a subset of Turtle + RDFLanguages.RDFXML + )); + + for (Lang lang : supportedLanguages) { + try { + return readMessage(message, lang); + } catch (IOException ignored) { + } + } + throw new IOException("Could not parse string as any supported RDF format (JSON-LD, Turtle/N-Triple, RDF-XML)."); + } + + /** + * Reads a message into an Apache Jena model, guessing the input language. + * Note: Guessing the language may cause some error messages during parsing attempts + * + * @param message Message to be read + * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML + * @return The model of the message + */ + private Model readMessage(String message, Lang language) throws IOException { + + Model targetModel = ModelFactory.createDefaultModel(); + + try { + RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); + } + catch (RiotException e) + { + throw new IOException("Failed to parse input as " + language, e); + } + return targetModel; + } + + /** + * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated + * @param someClass Input class of which implementable subclasses need to be found + * @return ArrayList of instantiable subclasses + */ + ArrayList> getImplementingClasses(Class someClass) { + ArrayList> result = new ArrayList<>(); + KnownSubtypes subTypeAnnotation = someClass.getAnnotation(KnownSubtypes.class); + if (subTypeAnnotation != null) { + KnownSubtypes.Type[] types = subTypeAnnotation.value(); + for (KnownSubtypes.Type type : types) { + result.addAll(getImplementingClasses(type.value())); + } + } + if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { + result.add(Serializer.customImplementationMap.getOrDefault(someClass, someClass)); + } + return result; + } + + private void addArtificialBlankNodeLabels(Model m) + { + //Get all blank nodes + Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); + QueryExecution qe = QueryExecutionFactory.create(q, m); + ResultSet rs = qe.execSelect(); + List statementsToAdd = new ArrayList<>(); + while(rs.hasNext()) + { + QuerySolution qs = rs.next(); + statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), + ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), + ResourceFactory.createStringLiteral(qs.get("?s").toString()))); + } + qe.close(); + m.add(statementsToAdd); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java new file mode 100644 index 000000000..b18f0567d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java @@ -0,0 +1,308 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.Deserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class Serializer implements org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer, Deserializer { + + private static final ObjectMapper mapper = new ObjectMapper(); + private final List preprocessors; + private final Logger logger = LoggerFactory.getLogger(Serializer.class); + + public static String implementingClassesNamePrefix = "Default"; + public static String implementingClassesNameSuffix = ""; + + static Map, Class> customImplementationMap = new HashMap<>(); + + private static boolean charsetWarningPrinted = false; + + public Serializer() { + mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); + mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + mapper.setMixInResolver(new ReflectiveMixInResolver()); + + preprocessors = new ArrayList<>(); + this.addPreprocessor(new TypeNamePreprocessor()); + + if(!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) + { + charsetWarningPrinted = true; + logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); + } + + //Default namespaces for AAS + addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); + addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); + addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/RC02/"); + //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); + + } + + /** + * Serializes an object to an RDF representation. In order to support RDF, the input instance must be + * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). + * + * @param instance the instance to be serialized + * @return RDF serialization of the provided object graph + * @throws IOException if the serialization fails + */ + public String serialize(Object instance) throws IOException { + return serialize(instance, RDFLanguages.TTL, new HashMap<>()); + } + + /** + * Serializes an object to an RDF representation of a given RDF serialization format. In order to support RDF, the + * input instance must be annotated using AAS Metamodel annotations. + * + * @param instance the instance to be serialized + * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) + * @return RDF serialization of the provided object graph + * @throws IOException if the serialization fails + */ + public synchronized String serialize(Object instance, Lang format) throws IOException { + return serialize(instance, format, new HashMap<>() ); + } + + + //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function + public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { + if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { + throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); + } + mapper.registerModule(new JsonLDModule(idMap)); + String jsonLD = (instance instanceof Collection) + ? serializeCollection((Collection) instance) + : mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); + if (format == RDFLanguages.JSONLD) return jsonLD; + else return convertJsonLdToOtherRdfFormat(jsonLD, format); + } + + private String serializeCollection(Collection collection) throws IOException { + String lineSep = System.lineSeparator(); + StringBuilder jsonLDBuilder = new StringBuilder(); + + if (collection.isEmpty()) { + jsonLDBuilder.append("[]"); + } else { + jsonLDBuilder.append("["); + jsonLDBuilder.append(lineSep); + for (Object item : collection) { + jsonLDBuilder.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(item)); + jsonLDBuilder.append(","); + jsonLDBuilder.append(lineSep); + } + int lastComma = jsonLDBuilder.lastIndexOf(","); + jsonLDBuilder.replace(lastComma, lastComma + 1, ""); + jsonLDBuilder.append("]"); + } + jsonLDBuilder.append(lineSep); + + return jsonLDBuilder.toString(); + } + + public String convertJsonLdToOtherRdfFormat(String jsonLd, Lang format) { + Model model = ModelFactory.createDefaultModel(); + RDFDataMgr.read(model, new ByteArrayInputStream(jsonLd.getBytes()), RDFLanguages.JSONLD); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + RDFDataMgr.write(os, model, format); + return os.toString(); + } + + public String serializePlainJson(Object instance) throws JsonProcessingException { + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); + } + + /** + * Inverse method of "serialize" + * + * @param serialization JSON(-LD) string + * @param valueType class of top level type + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(String serialization, Class valueType) throws DeserializationException { + try { + return new Parser().parseMessage(serialization, valueType); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Inverse method of "serialize" + * + * @param serialization JSON(-LD) string + * @param valueType class of top level type + * @param serializationFormat RDF input format + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(String serialization, Class valueType, Lang serializationFormat) throws DeserializationException { + try { + + return new Parser().parseMessage(serialization, valueType, serializationFormat); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Inverse method of "serialize" + * + * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes + * @param valueType class of top level type + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { + try { + return new Parser().parseMessage(rdfModel, valueType); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". + * @param prefix Prefix to be added + * @param namespaceUrl URL of the prefix + */ + public static void addKnownNamespace(String prefix, String namespaceUrl) + { + Parser.knownNamespaces.put(prefix, namespaceUrl); + JsonLDSerializer.contextItems.put(prefix, namespaceUrl); + } + + /** + * Method to add a preprocessor for deserialization. + *

+ * Important note: The preprocessors are executed in the same order they were added. + * + * @param preprocessor the preprocessor to add + */ + public void addPreprocessor(JsonPreprocessor preprocessor) { + preprocessors.add(preprocessor); + } + + /** + * Method to add a preprocessor for deserialization. + *

+ * Important note: The preprocessors are executed in the same order they were added. + * + * @param preprocessor the preprocessor to add + * @param validate set whether the preprocessors output should be checked by RDF4j + */ + public void addPreprocessor(JsonPreprocessor preprocessor, boolean validate) { + preprocessor.enableRDFValidation(validate); + addPreprocessor(preprocessor); + } + + /** + * remove a preprocessor if no longer needed + * + * @param preprocessor the preprocessor to remove + */ + public void removePreprocessor(JsonPreprocessor preprocessor) { + preprocessors.remove(preprocessor); + } + + @Override + public String write(Environment aasEnvironment) throws SerializationException { + try { + return serialize(aasEnvironment); + } + catch (IOException e) + { + throw new SerializationException("Failed to serialize environment.", e); + } + } + + public String write(Environment aasEnvironment, Lang format) throws SerializationException { + return write(aasEnvironment, format, new HashMap<>()); + } + + public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { + try { + return serialize(aasEnvironment, format, idMap); + } + catch (IOException e) + { + throw new SerializationException("Failed to serialize environment.", e); + } + } + @Override + public Environment read(String value) throws DeserializationException { + try { + return new Parser().parseMessage(value, Environment.class); + } + catch (IOException e) + { + throw new DeserializationException("Could not deserialize to environment.", e); + } + } + + public Environment read(String value, Lang serializationFormat) throws DeserializationException { + try { + return new Parser().parseMessage(value, Environment.class, serializationFormat); + } + catch (IOException e) + { + throw new DeserializationException("Could not deserialize to environment.", e); + } + } + + @Override + public void useImplementation(Class aasInterface, Class implementation) { + customImplementationMap.put(aasInterface, implementation); + //throw new NotImplementedException("Custom implementation support not yet implemented"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java new file mode 100644 index 000000000..a889ae103 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java @@ -0,0 +1,53 @@ +/* + * 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.rdf; + +import java.io.IOException; +import java.net.URI; + + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonStreamContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class UriSerializer extends StdSerializer { + + + public UriSerializer() { + this(null); + } + + public UriSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(URI value, JsonGenerator gen, SerializerProvider provider) throws IOException { + String serializedUri = value.toString(); + // String idPattern = "{\"@id\": \"" + serializedUri + "\"}"; + JsonStreamContext context = gen.getOutputContext(); + if (context.getCurrentName() != null && context.getCurrentName().contains("@id")) { + gen.writeString(serializedUri); + } else { + gen.writeStartObject(); + gen.writeStringField("@id", serializedUri); + gen.writeEndObject(); + } + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java new file mode 100644 index 000000000..a05f77d44 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java @@ -0,0 +1,42 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import java.io.IOException; +import java.math.BigDecimal; + +public class BigDecimalSerializer extends StdSerializer { + + public BigDecimalSerializer() { + this(null); + } + + public BigDecimalSerializer(Class clazz) { + super(clazz); + } + + @Override + public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeStartObject(); + gen.writeStringField("@value", value.toString()); + gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#decimal"); + gen.writeEndObject(); + } +} \ No newline at end of file diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java new file mode 100644 index 000000000..ff1374e20 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java @@ -0,0 +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.rdf.custom; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.JsonLdEnumSerializer; + +@JsonSerialize(using = JsonLdEnumSerializer.class) +public class JsonLdEnumMixin { +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java new file mode 100644 index 000000000..a1f0ec779 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java @@ -0,0 +1,35 @@ +/* + * 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.rdf.custom; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + + +import java.util.List; + +@JsonTypeName("rdf:langString") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface LangStringMixin { + @JsonProperty("@value") + public String getValue(); + + @JsonProperty("@language") + public String getLanguage(); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java new file mode 100644 index 000000000..54692477e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java @@ -0,0 +1,41 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.databind.introspect.ClassIntrospector; + +public class ReflectiveMixInResolver implements ClassIntrospector.MixInResolver { + + @Override + public Class findMixInClassFor(Class cls) { + if (cls.isEnum()) + { + return JsonLdEnumMixin.class; + } + try { + return Class.forName("org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins." + cls.getSimpleName() + "Mixin"); + } + catch (ClassNotFoundException ignored) + { + return null; + } + } + + @Override + public ClassIntrospector.MixInResolver copy() { + return new ReflectiveMixInResolver(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java new file mode 100644 index 000000000..28006cbb8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.IOException; +import java.time.ZonedDateTime; +import java.util.GregorianCalendar; + +public class XMLGregorianCalendarDeserializer extends StdDeserializer { + + public XMLGregorianCalendarDeserializer() { + this(XMLGregorianCalendar.class); + } + + public XMLGregorianCalendarDeserializer(Class clazz) { + super(clazz); + } + + @Override + public XMLGregorianCalendar deserialize(JsonParser p, DeserializationContext context) throws IOException { + XMLGregorianCalendar xgc = null; + try { + xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(p.getValueAsString()))); + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + return xgc; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java new file mode 100644 index 000000000..b80718d93 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.IOException; +import java.text.SimpleDateFormat; + +public class XMLGregorianCalendarSerializer extends StdSerializer { + + public XMLGregorianCalendarSerializer() { + this(null); + } + + public XMLGregorianCalendarSerializer(Class clazz) { + super(clazz); + } + + @Override + public void serialize(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider) throws IOException { + SimpleDateFormat xsdDateTimeStampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + xsdDateTimeStampFormat.setCalendar(value.toGregorianCalendar()); + String xsdDateTimeStampFormatted = xsdDateTimeStampFormat.format(value.toGregorianCalendar().getTime()); + gen.writeStartObject(); + gen.writeStringField("@value", xsdDateTimeStampFormatted); + gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#dateTimeStamp"); + gen.writeEndObject(); + + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java new file mode 100644 index 000000000..e967dd795 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:AdministrativeInformation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + String getVersion(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + void setVersion(String version); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + String getRevision(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + void setRevision(String revision); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java new file mode 100644 index 000000000..2b8c30171 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; + +import java.util.List; + +@JsonTypeName("aas:AnnotatedRelationshipElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + List getAnnotations(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + void setAnnotations(List annotations); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java new file mode 100644 index 000000000..9a49ca42c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:AssetAdministrationShell") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + AssetInformation getAssetInformation(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + void setAssetInformation(AssetInformation assetInformation); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + Reference getDerivedFrom(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + void setDerivedFrom(Reference derivedFrom); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + List getSubmodels(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + void setSubmodels(List submodels); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java new file mode 100644 index 000000000..08a7e1715 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java @@ -0,0 +1,60 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.File; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:AssetInformation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AssetInformationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + AssetKind getAssetKind(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + void setAssetKind(AssetKind assetKind); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + Reference getGlobalAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + void setGlobalAssetId(Reference globalAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + List getSpecificAssetIds(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + void setSpecificAssetIds(List specificAssetIds); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + List getBillOfMaterials(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + void setBillOfMaterials(List billOfMaterials); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + File getDefaultThumbnail(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + void setDefaultThumbnail(File defaultThumbnail); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java new file mode 100644 index 000000000..803e6c037 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java @@ -0,0 +1,79 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Direction; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +@JsonTypeName("aas:BasicEventElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface BasicEventElementMixin extends EventElementMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + Direction getDirection(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + void setDirection(Direction direction); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + String getLastUpdate(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + void setLastUpdate(String lastUpdate); + + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + String getMaxInterval(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + void setMaxInterval(String maxInterval); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + Reference getMessageBroker(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + void setMessageBroker(Reference messageBroker); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + String getMessageTopic(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + void setMessageTopic(String messageTopic); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + String getMinInterval(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + void setMinInterval(String minInterval); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + Reference getObserved(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + void setObserved(Reference observed); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + StateOfEvent getState(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + void setState(StateOfEvent state); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java new file mode 100644 index 000000000..267158c70 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Blob") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface BlobMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + void setConentType(String mimeType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + byte[] getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + void setValue(byte[] value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java new file mode 100644 index 000000000..d37450ab5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java @@ -0,0 +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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Capability") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface CapabilityMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java new file mode 100644 index 000000000..7cc22006c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:ConceptDescription") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + List getIsCaseOf(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + void setIsCaseOf(List isCaseOf); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java new file mode 100644 index 000000000..dab2fb7be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java @@ -0,0 +1,37 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +@JsonTypeName("aas:DataElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = File.class), + @JsonSubTypes.Type(value = Blob.class), + @JsonSubTypes.Type(value = MultiLanguageProperty.class), + @JsonSubTypes.Type(value = Property.class), + @JsonSubTypes.Type(value = Range.class), + @JsonSubTypes.Type(value = ReferenceElement.class) +}) +public interface DataElementMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java new file mode 100644 index 000000000..e9d69f2d1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationContent") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = DataSpecificationIEC61360.class) +}) +public interface DataSpecificationContentMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java new file mode 100644 index 000000000..672645918 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java @@ -0,0 +1,106 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationIEC61360") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationIEC61360Mixin extends DataSpecificationContentMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") + public DataTypeIEC61360 getDataType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") + public void setDataType(DataTypeIEC61360 dataType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") + public List getDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") + public void setDefinitions(List definition); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") + public LevelType getLevelType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") + public void setLevelType(LevelType levelType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") + public List getPreferredName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") + public void setPreferredName(List preferredName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") + public List getShortName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") + public void setShortName(List shortName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") + public String getSourceOfDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") + public void setSourceOfDefinition(String sourceOfDefinition); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") + public String getSymbol(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") + public void setSymbol(String symbol); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") + public String getUnit(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") + public void setUnit(String unit); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") + public Reference getUnitId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") + public void setUnitId(Reference unitId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") + public String getValueFormat(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") + public void setValueFormat(String valueFormat); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") + public String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") + public void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") + public ValueList getValueList(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") + public void setValueList(ValueList valueList); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") + public Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") + public void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java new file mode 100644 index 000000000..d299d0399 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java @@ -0,0 +1,99 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +import java.util.List; + +@JsonTypeName("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationPhysicalUnitMixin { + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") + String getConversionFactor(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") + void setConversionFactor(String conversionFactor); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") + List getDefinitions(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") + void setDefinitions(List definitions); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") + String getDinNotation(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") + void setDinNotation(String dinNotation); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") + String getEceCode(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") + void setEceCode(String eceCode); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") + String getEceName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") + void setEceName(String eceName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") + String getNistName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") + void setNistName(String nistName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") + String getSiName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") + void setSiName(String siName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") + String getSiNotation(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") + void setSiNotation(String siNotation); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") + String getRegistrationAuthorityId(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") + void setRegistrationAuthorityId(String registrationAuthorityId); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") + String getSupplier(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") + void setSupplier(String supplier); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") + String getUnitName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") + void setUnitName(String unitName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") + String getUnitSymbol(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") + void setUnitSymbol(String unitSymbol); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java new file mode 100644 index 000000000..b1fe7ac33 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIEC61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:EmbeddedDataSpecification") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EmbeddedDataSpecificationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") + public DataSpecificationIEC61360 getDataSpecificationContent(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") + public void setDataSpecificationContent(DataSpecificationIEC61360 dataSpecificationContent); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + public Reference getDataSpecification(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + public void setDataSpecification(Reference dataSpecification); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java new file mode 100644 index 000000000..6a2636737 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java @@ -0,0 +1,54 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.EntityType; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Entity") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EntityMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + Reference getGlobalAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + void setGlobalAssetId(Reference globalAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + SpecificAssetId getSpecificAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + void setSpecificAssetId(SpecificAssetId specificAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + EntityType getEntityType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + void setEntityType(EntityType entityType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + List getStatements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + void setStatements(List statements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java new file mode 100644 index 000000000..97a7028be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; + +import java.util.List; + +@JsonTypeName("aas:Environment") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EnvironmentMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + List getAssetAdministrationShells(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + void setAssetAdministrationShells(List assetAdministrationShells); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + List getConceptDescriptions(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + void setConceptDescriptions(List conceptDescriptions); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + List getSubmodels(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + void setSubmodels(List submodels); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java new file mode 100644 index 000000000..e3e7ed1c0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; + + +@JsonTypeName("aas:EventElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = BasicEventElement.class) +}) +public interface EventElementMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java new file mode 100644 index 000000000..26bc5c128 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java @@ -0,0 +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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:EventMessage") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EventMessageMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java new file mode 100644 index 000000000..62322c3b1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java @@ -0,0 +1,50 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Extension") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ExtensionMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + String getName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + void setName(String name); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + Reference getRefersTo(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + void setRefersTo(Reference refersTo); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java new file mode 100644 index 000000000..c4c234413 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:File") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface FileMixin extends DataElementMixin, SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + void setContentType(String contentType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + void setValue(String value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java new file mode 100644 index 000000000..cc5a8707e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:Formula") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface FormulaMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + List getDependsOns(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + void setDependsOns(List dependsOns); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java new file mode 100644 index 000000000..b0693d8d6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +import java.util.List; + +@JsonTypeName("aas:HasDataSpecification") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = AdministrativeInformation.class), + @JsonSubTypes.Type(value = AssetAdministrationShell.class), + @JsonSubTypes.Type(value = ConceptDescription.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface HasDataSpecificationMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + List getDataSpecifications(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + void setDataSpecifications(List dataSpecifications); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + List getEmbeddedDataSpecifications(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + void setEmbeddedDataSpecifications(List embeddedDataSpecifications); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java new file mode 100644 index 000000000..772a10c3e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; + +import java.util.List; + +@JsonTypeName("aas:HasExtensions") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface HasExtensionsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + List getExtensions(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + void setExtensions(List extensions); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java new file mode 100644 index 000000000..d3f87470a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.ModelingKind; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +@JsonTypeName("aas:HasKind") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface HasKindMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") + ModelingKind getKind(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") + void setKind(ModelingKind kind); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java new file mode 100644 index 000000000..a194d33dd --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + + +@JsonTypeName("aas:HasSemantics") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SpecificAssetId.class), + @JsonSubTypes.Type(value = SubmodelElement.class), + @JsonSubTypes.Type(value = Qualifier.class), + @JsonSubTypes.Type(value = Extension.class) +}) +public interface HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + Reference getSemanticId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + void setSemanticId(Reference semanticId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + List getSupplementalSemanticIds(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + void setSupplementalSemanticIds(List references); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java new file mode 100644 index 000000000..c9590fd02 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; + +@JsonTypeName("aas:Identifiable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = AssetAdministrationShell.class), + @JsonSubTypes.Type(value = ConceptDescription.class) +}) +public interface IdentifiableMixin extends ReferableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + AdministrativeInformation getAdministration(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + void setAdministration(AdministrativeInformation administration); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + String getId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + void setId(String id); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java new file mode 100644 index 000000000..7594d6bd0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:IdentifierKeyValuePair") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + String getKey(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + void setKey(String key); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + Reference getExternalSubjectId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + void setExternalSubjectId(Reference externalSubjectId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java new file mode 100644 index 000000000..5c30d2b41 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java @@ -0,0 +1,31 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Identifier") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface IdentifierMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + String getIdentifier(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + void setIdentifier(String identifier); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java new file mode 100644 index 000000000..972dca9a1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; + +@JsonTypeName("aas:Key") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface KeyMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + KeyTypes getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + void setType(KeyTypes type); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + void setValue(String value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java new file mode 100644 index 000000000..71b17e055 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:MultiLanguageProperty") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface MultiLanguagePropertyMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") + List getValues(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") + void setValues(List values); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java new file mode 100644 index 000000000..a91d8f9aa --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:ObjectAttributes") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ObjectAttributesMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + List getObjectAttributes(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + void setObjectAttributes(List objectAttributes); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java new file mode 100644 index 000000000..c37547418 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java @@ -0,0 +1,45 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; + +import java.util.List; + +@JsonTypeName("aas:Operation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface OperationMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + List getInputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + void setInputVariables(List inputVariables); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + List getInoutputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + void setInoutputVariables(List inoutputVariables); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + List getOutputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + void setOutputVariables(List outputVariables); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java new file mode 100644 index 000000000..3e21e6918 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +@JsonTypeName("aas:OperationVariable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface OperationVariableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + SubmodelElement getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + void setValue(SubmodelElement value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java new file mode 100644 index 000000000..f6a0023c8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:PolicyDecisionPoint") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyDecisionPointMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + boolean getExternalPolicyDecisionPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java new file mode 100644 index 000000000..7eb2bd1a8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:PolicyEnforcementPoints") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyEnforcementPointsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + boolean getExternalPolicyEnforcementPoint(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java new file mode 100644 index 000000000..db74d7242 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:PolicyInformationPoints") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyInformationPointsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + boolean getExternalInformationPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + void setExternalInformationPoints(boolean externalInformationPoints); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + List getInternalInformationPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + void setInternalInformationPoints(List internalInformationPoints); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java new file mode 100644 index 000000000..162cda7a2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Property") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PropertyMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java new file mode 100644 index 000000000..be2e8c0c9 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; + +import java.util.List; + +@JsonTypeName("aas:Qualifiable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface QualifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + List getQualifiers(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + void setQualifiers(List qualifiers); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java new file mode 100644 index 000000000..941567e52 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java @@ -0,0 +1,50 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Qualifier") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface QualifierMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + String getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + void setType(String type); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java new file mode 100644 index 000000000..b46e6de2c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Range") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface RangeMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + String getMax(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + void setMax(String max); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + String getMin(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + void setMin(String min); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java new file mode 100644 index 000000000..349c27b6e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java @@ -0,0 +1,58 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Referable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Identifiable.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface ReferableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + String getCategory(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + void setCategory(String category); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") + List getDescription(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") + void setDescription(List description); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") + List getDisplayName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") + void setDisplayName(List displayName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + String getIdShort(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + void setIdShort(String idShort); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java new file mode 100644 index 000000000..6df2a7be1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:ReferenceElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ReferenceElementMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + Reference getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + void setValue(Reference value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java new file mode 100644 index 000000000..0af5ae449 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java @@ -0,0 +1,41 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.util.List; + +@JsonTypeName("aas:Reference") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ReferenceMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + List getKeys(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + void setKeys(List keys); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + ReferenceTypes getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + void setType(ReferenceTypes type); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java new file mode 100644 index 000000000..31fefc0c7 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java @@ -0,0 +1,43 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:RelationshipElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) +}) +public interface RelationshipElementMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + Reference getFirst(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + void setFirst(Reference first); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + Reference getSecond(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + void setSecond(Reference second); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java new file mode 100644 index 000000000..4d25d1637 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; + +import java.util.List; + +@JsonTypeName("aas:Resource") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ResourceMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + void setContentType(String contentType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + String getPath(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + void setPath(String path); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java new file mode 100644 index 000000000..0380783e6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.File; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; + +@JsonTypeName("aas:SpecificAssetId") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SpecificAssetIdMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + String getName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + void setName(String name); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + Reference getExternalSubjectId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + void setExternalSubjectId(Reference reference); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java new file mode 100644 index 000000000..f0451e1f4 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; + +import java.util.List; + +@JsonTypeName("aas:SubjectAttributes") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubjectAttributesMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + List getSubjectAttributes(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + void setSubjectAttributes(List subjectAttributes); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java new file mode 100644 index 000000000..722fc32ab --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java @@ -0,0 +1,45 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.Collection; + +@JsonTypeName("aas:SubmodelElementCollection") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + boolean getAllowDuplicates(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + void setAllowDuplicates(boolean allowDuplicates); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + boolean getOrdered(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + void setOrdered(boolean ordered); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + Collection getValues(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + void setValues(Collection values); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java new file mode 100644 index 000000000..9387f7570 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java @@ -0,0 +1,61 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.util.List; + +@JsonTypeName("aas:SubmodelElementList") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelElementListMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + boolean getOrderRelevant(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + void setOrderRelevant(boolean orderRelevant); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + Reference getSemanticIdListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + void setSemanticIdListElement(Reference semanticIdListElement); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + AasSubmodelElements getTypeValueListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + void setTypeValueListElement(AasSubmodelElements typeValueListElement); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + List getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + void setValue(List value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + DataTypeDefXsd getValueTypeListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java new file mode 100644 index 000000000..1bb5e50b5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +@JsonTypeName("aas:SubmodelElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = RelationshipElement.class), + @JsonSubTypes.Type(value = DataElement.class), + @JsonSubTypes.Type(value = File.class), + @JsonSubTypes.Type(value = Capability.class), + @JsonSubTypes.Type(value = Entity.class), + @JsonSubTypes.Type(value = EventElement.class), + @JsonSubTypes.Type(value = EventPayload.class), + @JsonSubTypes.Type(value = Operation.class), + @JsonSubTypes.Type(value = SubmodelElementCollection.class) +}) +public interface SubmodelElementMixin extends ReferableMixin, QualifiableMixin, HasDataSpecificationMixin, HasKindMixin, HasSemanticsMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java new file mode 100644 index 000000000..df693d6a2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Submodel") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + List getSubmodelElements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + void setSubmodelElements(List submodelElements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java new file mode 100644 index 000000000..2cb4a878c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java @@ -0,0 +1,36 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; + +import java.util.List; + + +@JsonTypeName("aas:ValueList") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ValueListMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + List getValueReferencePairs(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + void setValueReferencePairs(List valueReferencePairs); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java new file mode 100644 index 000000000..d9502ad58 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:ValueReferencePair") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ValueReferencePairMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java new file mode 100644 index 000000000..fd1aa933c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:View") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + List getContainedElements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + void setContainedElements(List containedElements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java new file mode 100644 index 000000000..2bf5c6603 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java @@ -0,0 +1,53 @@ +/* + * 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.rdf.preprocessing; + + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.riot.RDFDataMgr; +import org.apache.jena.riot.RDFLanguages; + + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/** + * basic implementation of {@code JsonPreprocessor} that encapsulates validation. + * By default, validation is disabled for performance reasons (@context has to be downloaded each time). + */ +public abstract class BasePreprocessor implements JsonPreprocessor { + + private boolean validate = false; + + + @Override + public final String preprocess(String input) throws IOException { + String result = preprocess_impl(input); + if(validate) { + Model m = ModelFactory.createDefaultModel(); + RDFDataMgr.read(m, new ByteArrayInputStream(result.getBytes()), RDFLanguages.JSONLD); + } + return result; + } + + abstract String preprocess_impl(String input) throws IOException; + + @Override + public void enableRDFValidation(boolean validate) { + this.validate = validate; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java new file mode 100644 index 000000000..a76739850 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java @@ -0,0 +1,42 @@ +/* + * 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.rdf.preprocessing; + +import java.io.IOException; + +/** + * Interface for JSON-LD preprocessors which should transform JSON-LD inputs + * before they are deserialized by Jackson. + * + * Implementations used at the same time must not interfere with each other. + */ +public interface JsonPreprocessor { + + /** + * preprocessing method + * @param input of the transformation, the original JSON-LD + * @return the transformation´s result + * @throws IOException if preprocessing fails, e.g. because the input is not valid RDF + */ + public String preprocess(String input) throws IOException; + + /** + * specify wheter the transformation's result should be validated to + * be parsable by RDF4j + * @param validate enable/disable switch + */ + public void enableRDFValidation(boolean validate); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java new file mode 100644 index 000000000..9de954912 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java @@ -0,0 +1,194 @@ +/* + * 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.rdf.preprocessing; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +public class TypeNamePreprocessor extends BasePreprocessor { + + private static final Map prefixes; + + static { + prefixes = new HashMap<>(); + prefixes.put("ids:", "https://w3id.org/idsa/core/"); + prefixes.put("idsc:", "https://w3id.org/idsa/code/"); + prefixes.put("info:", "http://www.fraunhofer.de/fraunhofer-digital/infomodell#"); + prefixes.put("kdsf:", "http://kerndatensatz-forschung.de/version1/technisches_datenmodell/owl/Basis#"); + } + + @Override + String preprocess_impl(String input) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + Map inMap = mapper.readValue(input, Map.class); + Map outMap = unifyTypeURIPrefix(inMap); + return mapper.writeValueAsString(outMap); + } + + + private Map unifyTypeURIPrefix(Map in) { + Map out = new LinkedHashMap<>(); + in.forEach((k,v) -> { + if(v instanceof String && k instanceof String && k.equals("@type")) { + + + // if key is @type and value is a string: add 'ids:' if no other namespace at the value + AtomicReference modifiableValue = new AtomicReference<>((String) v); + prefixes.forEach((p, u) -> modifiableValue.set(modifiableValue.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableValue.get().startsWith("ids:") + || modifiableValue.get().startsWith("idsc:") + || modifiableValue.get().startsWith("info:") + || modifiableValue.get().startsWith("kdsf:") + || modifiableValue.get().startsWith("xsd:") + || modifiableValue.get().startsWith("http://") + || modifiableValue.get().startsWith("https://"))) { + modifiableValue.set("ids:".concat(modifiableValue.get())); // default to ids prefix for backwards compatibility + } + out.put(k, modifiableValue.get()); + + + } else if(v instanceof Map) { + AtomicReference modifiableKey = new AtomicReference<>((String) k); + + prefixes.forEach((prefix, uri) -> modifiableKey.set(modifiableKey.get().replace(uri, prefix))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://") + || modifiableKey.get().startsWith("@context"))) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + + + // shorten an @id Map + if (((Map) v).containsKey("@id") && ((Map) v).keySet().size() == 1) { + Map idMap = new LinkedHashMap<>(); + idMap.put(k, ((Map) v).get("@id")); + + out.putAll(unifyTypeURIPrefix(idMap)); + + } else if (((Map) v).containsKey("@value") && + ((Map) v).containsKey("@type")) + { + if( ((Map) v).get("@type").toString().contains("dateTime") ) + { + + // shorten an @value Map with xsd:dateTimes + Object date = ((Map) v).get("@value"); + out.put(modifiableKey, date); + } + else if(((Map) v).get("@type").toString().equals("xsd:integer")) + { + int value = Integer.parseInt(((Map) v).get("@value").toString()); + out.put(modifiableKey, value); + } + else { //Do the same as below + out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); + } + + } else { + + out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); + + + } + + } else if(v instanceof ArrayList) { + + + AtomicReference modifiableKey = new AtomicReference<>((String) k); + prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://"))) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + + Iterator iter = new ArrayList((ArrayList) v).iterator(); //making a copy of the old array so the iterator does not get confused by the element deletions + while (iter.hasNext()) { + Object child = iter.next(); + if (child instanceof Map && ((Map) child).containsKey("@id") && ((Map) child).keySet().size() == 1) { + ((ArrayList) v).remove(child); + ((ArrayList) v).add(((Map) child).get("@id")); + } + } + + out.put(modifiableKey, unifyTypeURIPrefix((ArrayList) v)); // TODO: What happens with an Array inside the Array? + + + } else { + + + AtomicReference modifiableKey = new AtomicReference<>((String) k); + prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://") + || modifiableKey.get().startsWith("@"))) { + //in the context definition, a pair might look like this: "ids" : "http://www.someURL.com" + //Here, we start with "ids", not "ids:". So we also need to check that the key is not contained in our prefixes + if(!prefixes.containsKey(modifiableKey.get() + ":")) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + } + + out.put(modifiableKey, v); // modify nothing if not @type or a map + } + }); + return out; + } + + + private ArrayList unifyTypeURIPrefix(ArrayList in) { + ArrayList out = new ArrayList<>(); + + Iterator iter = in.iterator(); + + while (iter.hasNext()) { + Object v = iter.next(); + if(v instanceof Map) { + + + if (!((Map) v).isEmpty()) + out.add( unifyTypeURIPrefix((Map) v)); + + + } else if (v instanceof String) { + + out.add(v); // modify nothing if not @type or a map + } else { + out.add(v); + } + } + return out; + } + + + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java new file mode 100644 index 000000000..9a3e79235 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -0,0 +1,153 @@ +/* + * 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.rdf; + + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; + +import org.apache.jena.riot.RDFLanguages; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import java.io.IOException; + +@RunWith(JUnitParamsRunner.class) +public class ParserTest { + + @Test + public void parseAasEnvironmentTest() throws IOException, DeserializationException { + String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); + Environment aasEnv = new Serializer().read(aasEnvAsString); + Assert.assertEquals(1, aasEnv.getSubmodels().size()); + Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); + Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); + + Assert.assertEquals("de", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(0).getLanguage()); + Assert.assertEquals("en", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(1).getLanguage()); + Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); + + } + + @Test + @Ignore + public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { + String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); + Environment environment = new Serializer().read(aasEnvAsString); + + // TODO continue providing a correct AASFull Turtle representation + // TODO test for LangStrings + Assert.assertEquals(AASFull.ENVIRONMENT, environment); + } + + + @Test + @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", + "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) + public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + + AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); + } + + @Test + @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) + public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + + AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); + } + + @Test + @Parameters({"Submodel_SubmodelElement_Example.ttl"}) + public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + //These work + + Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); + + + //The following examples do not work yet, as they are semantically problematic + //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); + //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); + } + + + + + @Test + public void deserializeConceptDescription() throws IOException, DeserializationException { + String conceptDescription = "{\n" + + " \"@context\" : {\n" + + " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + + " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + + " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + + " },\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + + " \"@type\" : \"aas:ConceptDescription\",\n" + + " \"isCaseOf\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + + " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + + " \"@type\" : \"aas:Reference\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + + " \"@type\" : \"aas:Key\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + + " } ]\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + + " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + + " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + + " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + + " } ]\n" + + "}"; + + Serializer serializer = new Serializer(); + ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); + + Assert.assertNotNull(c); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java new file mode 100644 index 000000000..58da78d90 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -0,0 +1,100 @@ +/* + * 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.rdf; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIEC61360; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class SerializerTest { + + //TODO: Optional: Prefixes instead of full URIs + //TODO: Optional: Do not serialize empty collections + + @Test + public void serializeEnvironment() throws IOException, DeserializationException { + + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .build()) + .description(Arrays.asList(new DefaultLangString.Builder().text("This is a test AAS").language("en-us").build())) + .displayName(Arrays.asList( + new DefaultLangString.Builder().text("Anzeigename 2").language("de").build(), + new DefaultLangString.Builder().text("Display Name 1").language("en").build() + )) + .build(); + + Submodel submodel = new DefaultSubmodel.Builder() + .description(Arrays.asList(new DefaultLangString.Builder().text("My Submodel").language("en-us").build())) + .displayName(Arrays.asList( + new DefaultLangString.Builder().text("First Submodel Element name").language("en").build(), + new DefaultLangString.Builder().text("Second Submodel Element name").language("en").build() + )) + .category("Example category") + .build(); + + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .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 Serializer().serialize(aasEnv, RDFLanguages.JSONLD); + //System.out.println(output); + + Assert.assertTrue(output.contains("@context")); + // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? + Assert.assertTrue(output.contains("\"@type\" : \"aas:Environment\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:AssetAdministrationShell\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:Submodel\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:ConceptDescription\"")); + + Environment environment = new Serializer().deserialize(output, Environment.class); + Assert.assertNotNull(environment); + + // Assert.assertTrue(aasEnv.equals(environment)); // TODO: Serialising and parsing to/from RDF looses the sequence of e.g. LangStrings, therefore this test fails also for semantically equal objects + } +} 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..e970d8e9f --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java @@ -0,0 +1,45 @@ +/* + * 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.rdf; + + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; + +import org.apache.commons.io.IOUtils; + +/** + * Helper class for Serializer Tests + * + * @author sbader + * + */ +public class SerializerUtil { + + public static String readResourceToString(String resourceName) throws IOException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream(resourceName); + StringWriter writer = new StringWriter(); + IOUtils.copy(is, writer, "UTF-8"); + return writer.toString(); + } + + public static String stripWhitespaces(String input) { + return input.replaceAll("\\s+", ""); + } + +} diff --git a/dataformat-rdf/src/test/resources/AASFull.ttl b/dataformat-rdf/src/test/resources/AASFull.ttl new file mode 100644 index 000000000..8c11c4546 --- /dev/null +++ b/dataformat-rdf/src/test/resources/AASFull.ttl @@ -0,0 +1,354 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + +# AAS Environment + rdf:type aas:Environment ; + ; + ; + ; +. + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "MaxRotationSpeed"^^xs:string ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "PARAMETER"^^xs:string ; + "0173-1#02-BAA120#008"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Max. rotation speed"@en, "max. Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; + . + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "RotationSpeed"^^xs:string ; + rdfs:label "RotationSpeed"^^xs:string ; + "PROPERTY"^^xs:string ; + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] . + + rdf:type aas:DataSpecificationIEC61360 ; + "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Document"^^xs:string ; + rdfs:label "Document"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Document"@en, "Dokument"@de ; + "Document"@en ; + "[ISO 15519-1:2010]"^^xs:string ; + ; + "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Title"^^xs:string ; + rdfs:label "Title"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; + . + + rdf:type aas:DataSpecificationIEC61360 ; + "Titel"@en, "Titel"@de ; + "Titel"@en ; + ; + "Sprachabhängiger Titel des Dokuments."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "DigitalFile"^^xs:string ; + rdfs:label "DigitalFile"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + + rdf:type aas:DataSpecificationIEC61360 ; + "Digital File"@en ; + "DigitalFile"@en ; + ; + "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt new file mode 100644 index 000000000..65b752bdc --- /dev/null +++ b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt @@ -0,0 +1,16 @@ + . + "ExampleMotor"^^ . + "ExampleMotor"^^ . + "A very short description of the AAS instance"@en . + "A very short description of the AAS instance."^^ . + "https://customer.com/aas/9175_7013_7091_9168"^^ . + _:AssetInformation . +_:AssetInformation . +_:AssetInformation _:GlobalAssetId . +_:AssetInformation . +_:GlobalAssetId . +_:GlobalAssetId . +_:GlobalAssetId _:Key . +_:Key . +_:Key . +_:Key "https://customer.com/assets/KHBVZJSQKIY"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl new file mode 100644 index 000000000..e22b250fd --- /dev/null +++ b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl @@ -0,0 +1,27 @@ +@prefix : . +@prefix aas: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; +. diff --git a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl new file mode 100644 index 000000000..e5f25bfe6 --- /dev/null +++ b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl @@ -0,0 +1,56 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Complete_Example.ttl b/dataformat-rdf/src/test/resources/Complete_Example.ttl new file mode 100644 index 000000000..0c800f8d1 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Complete_Example.ttl @@ -0,0 +1,347 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "MaxRotationSpeed"^^xs:string ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "PARAMETER"^^xs:string ; + "0173-1#02-BAA120#008"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Max. rotation speed"@en, "max. Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; + . + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "RotationSpeed"^^xs:string ; + rdfs:label "RotationSpeed"^^xs:string ; + "PROPERTY"^^xs:string ; + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] . + + rdf:type aas:DataSpecificationIEC61360 ; + "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Document"^^xs:string ; + rdfs:label "Document"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Document"@en, "Dokument"@de ; + "Document"@en ; + "[ISO 15519-1:2010]"^^xs:string ; + ; + "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Title"^^xs:string ; + rdfs:label "Title"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; + . + + rdf:type aas:DataSpecificationIEC61360 ; + "Titel"@en, "Titel"@de ; + "Titel"@en ; + ; + "Sprachabhängiger Titel des Dokuments."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "DigitalFile"^^xs:string ; + rdfs:label "DigitalFile"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + + rdf:type aas:DataSpecificationIEC61360 ; + "Digital File"@en ; + "DigitalFile"@en ; + ; + "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Overall-Example.nt b/dataformat-rdf/src/test/resources/Overall-Example.nt new file mode 100644 index 000000000..3921c9aff --- /dev/null +++ b/dataformat-rdf/src/test/resources/Overall-Example.nt @@ -0,0 +1,253 @@ + . + "ExampleMotor"^^ . + "ExampleMotor"^^ . + "A very short description of the AAS instance"@en . + "A very short description of the AAS instance."^^ . + "https://customer.com/aas/9175_7013_7091_9168"^^ . + _:AssetInformation . + _:Submodel1 . + _:Submodel2 . + _:Submodel3 . +_:AssetInformation . +_:AssetInformation _:GlobalAssetId1 . +_:AssetInformation . +_:GlobalAssetId1 . +_:GlobalAssetId1 . +_:GlobalAssetId1 _:Key1 . +_:Key1 . +_:Key1 . +_:Key1 "https://customer.com/assets/KHBVZJSQKIY"^^ . +_:Submodel1 . +_:Submodel1 . +_:Submodel1 _:Key2 . +_:Key2 . +_:Key2 . +_:Key2 "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . +_:Submodel2 . +_:Submodel2 . +_:Submodel2 _:Key3 . +_:Key3 . +_:Key3 . +_:Key3 "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . +_:Submodel3 . +_:Submodel3 . +_:Submodel3 _:Key4 . +_:Key4 . +_:Key4 . +_:Key4 "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^ . + . + "TechnicalData"^^ . + "TechnicalData"^^ . + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . + . + _:SemanticId1 . + _:SubmodelElement1 . +_:SemanticId1 . +_:SemanticId1 . +_:SemanticId1 _:Key5 . +_:Key5 . +_:Key5 . +_:Key5 "0173-1#01-AFZ615#016"^^ . +_:SubmodelElement1 . +_:SubmodelElement1 "MaxRotationSpeed"^^ . +_:SubmodelElement1 "MaxRotationSpeed"^^ . +_:SubmodelElement1 . +_:SubmodelElement1 _:ValueId1 . +_:SubmodelElement1 "5000"^^ . +_:ValueId1 . +_:ValueId1 . +_:ValueId1 _:Key6 . +_:Key6 . +_:Key6 . +_:Key6 "0173-1#02-BAA120#008"^^ . + . + "OperationalData"^^ . + "OperationalData"^^ . + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . + . + _:SubmodelElement2 . +_:SubmodelElement2 . +_:SubmodelElement2 "RotationSpeed"^^ . +_:SubmodelElement2 "RotationSpeed"^^ . +_:SubmodelElement2 . +_:SubmodelElement2 . +_:SubmodelElement2 _:ValueId2 . +_:SubmodelElement2 "4370"^^ . +_:ValueId2 . +_:ValueId2 . +_:ValueId2 _:Key7 . +_:Key7 . +_:Key7 . +_:Key7 "http://customer.com/cd/1/1/18EBD56F6B43D895"^^ . + . + "Documentation"^^ . + "Documentation"^^ . + " . + . + _:SubmodelElement3 . +_:SubmodelElement3 . +_:SubmodelElement3 "OperatingManual"^^ . +_:SubmodelElement3 "OperatingManual"^^ . +_:SubmodelElement3 _:SemanticIdListElement1 . +_:SubmodelElement3 . +_:SubmodelElement3 _:Value1 . +_:SubmodelElement3 _:Value3 . +_:SubmodelElement3 . +_:SemanticIdListElement1 . +_:SemanticIdListElement1 . +_:SemanticIdListElement1 _:Key8 . +_:Key8 . +_:Key8 . +_:Key8 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . +_:Value1 . +_:Value1 _:Value2 . +_:Value2 . +_:Value2 . +_:Value2 "Title"^^ . +_:Value2 "application/pdf" . +_:Value2 "file:///aas/OperatingManual.pdf"^^ . +_:Value2 "Title"^^ . +_:Value2 "CONSTANT"^^ . +_:Value2 _:SemanticId2 . +_:Value2 . +_:SemanticId2 . +_:SemanticId2 . +_:SemanticId2 _:Key9 . +_:Key9 . +_:Key9 . +_:Key9 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . +_:Value3 . +_:Value3 _:Value4 . +_:Value4 . +_:Value4 . +_:Value4 "DigitalFile_PDF"^^ . +_:Value4 "application/pdf" . +_:Value4 "file:///aasx/OperatingManual.pdf"^^ . +_:Value4 "DigitalFile_PDF"^^ . +_:Value4 "CONSTANT"^^ . +_:Value4 _:SemanticId3. +_:Value4 . +_:SemanticId3 . +_:SemanticId3 . +_:SemanticId3 _:Key10 . +_:Key10 . +_:Key10 . +_:Key10 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^ . + . + "MaxRotationSpeed"^^ . + "MaxRotationSpeed"^^ . + "PARAMETER"^^ . + "0173-1#02-BAA120#008"^^ . + _:EmbeddedDataSpecification1 . +_:EmbeddedDataSpecification1 . +_:EmbeddedDataSpecification1 _:DataSpecification1 . +_:EmbeddedDataSpecification1 . +_:DataSpecification1 . +_:DataSpecification1 . +_:DataSpecification1 _:Key11 . +_:Key11 . +_:Key11 . +_:Key11 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Max. rotation speed"@en . + "max. Drehzahl"@de . + "1/min"^^ . + _:UnitId1 . + . + "H\u00F6chste zul\u00E4ssige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de . + "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en . +_:UnitId1 . +_:UnitId1 . +_:UnitId1 _:Key12 . +_:Key12 . +_:Key12 . +_:Key12 "0173-1#05-AAA650#002"^^ . + . + "RotationSpeed"^^ . + "RotationSpeed"^^ . + "PROPERTY"^^ . + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^ . + _:EmbeddedDataSpecification2 . +_:EmbeddedDataSpecification2 . +_:EmbeddedDataSpecification2 _:DataSpecification2 . +_:EmbeddedDataSpecification2 . +_:DataSpecification2 . +_:DataSpecification2 . +_:DataSpecification2 _:Key13 . +_:Key13 . +_:Key13 . +_:Key13 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Actual rotation speed"@en . + "Aktuelle Drehzahl"@de . + "1/min"^^ . + _:UnitId2 . + . + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de . + "Actual rotation speed with which the motor or feeding unit is operated."@en . +_:UnitId2 . +_:UnitId2 . +_:UnitId2 _:Key14 . +_:Key14 . +_:Key14 . +_:Key14 "0173-1#05-AAA650#002"^^ . + . + "Document"^^ . + "Document"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . + _:EmbeddedDataSpecification3 . +_:EmbeddedDataSpecification3 . +_:EmbeddedDataSpecification3 _:DataSpecification3 . +_:EmbeddedDataSpecification3 . +_:DataSpecification3 . +_:DataSpecification3 . +_:DataSpecification3 _:Key15 . +_:Key15 . +_:Key15 . +_:Key15 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Document"@en . + "Dokument"@de . + "Document"@en . + "[ISO 15519-1:2010]"^^ . + . + "Feste und geordnete Menge von f\u00FCr die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de . + . + "Title"^^ . + "Title"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . + _:EmbeddedDataSpecification4 . +_:EmbeddedDataSpecification4 . +_:EmbeddedDataSpecification4 _:DataSpecification4 . +_:EmbeddedDataSpecification4 . +_:DataSpecification4 . +_:DataSpecification4 . +_:DataSpecification4 _:Key16 . +_:Key16 . +_:Key16 . +_:Key16 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Titel"@en . + "Titel"@de . + "Titel"@en . + . + "Sprachabh\u00E4ngiger Titel des Dokuments."@de . + . + "DigitalFile"^^ . + "DigitalFile"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^ . + _:EmbeddedDataSpecification5 . +_:EmbeddedDataSpecification5 . +_:EmbeddedDataSpecification5 _:DataSpecification5 . +_:EmbeddedDataSpecification5 . +_:DataSpecification5 . +_:DataSpecification5 . +_:DataSpecification5 _:Key17 . +_:Key17 . +_:Key17 . +_:Key17 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Digital File"@en . + "DigitalFile"@en . + . + "Eine Datei, die die DocumentVersion repr\u00E4sentiert. Neben der obligatorischen PDF/A Datei k\u00F6nnen weitere Dateien angegeben werden."@de . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/ReferenceExample.ttl b/dataformat-rdf/src/test/resources/ReferenceExample.ttl new file mode 100644 index 000000000..a18db83e5 --- /dev/null +++ b/dataformat-rdf/src/test/resources/ReferenceExample.ttl @@ -0,0 +1,18 @@ +@prefix xs: . + +# 1) Reference with KeyElements + a ; + [ + a ; + ; + [ + a ; + ; + [ + a ; + ; + "http://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] + ] + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl new file mode 100644 index 000000000..3e50807d6 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl @@ -0,0 +1,137 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt new file mode 100644 index 000000000..2733f1131 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt @@ -0,0 +1,25 @@ + . + "TechnicalData"^^ . + "TechnicalData"^^ . + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . + . + _:SemanticId . + _:SubmodelElements . +_:SemanticId . +_:SemanticId . +_:SemanticId _:Key1 . +_:Key1 . +_:Key1 . +_:Key1 "0173-1#01-AFZ615#016"^^ . +_:SubmodelElements . +_:SubmodelElements "MaxRotationSpeed"^^ . +_:SubmodelElements "MaxRotationSpeed"^^ . +_:SubmodelElements . +_:SubmodelElements _:ValueId . +_:SubmodelElements "5000"^^ . +_:ValueId . +_:ValueId . +_:ValueId _:Key2 . +_:Key2 . +_:Key2 . +_:Key2 "0173-1#02-BAA120#008"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl new file mode 100644 index 000000000..9c1d7f8c4 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl @@ -0,0 +1,42 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. diff --git a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld new file mode 100644 index 000000000..7eac7fa6c --- /dev/null +++ b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld @@ -0,0 +1,88 @@ +{ + "@context" : { + "aas" : "https://admin-shell.io/aas/3/0/RC02/" + }, + "@id" : "https://admin-shell.io/autogen/DefaultEnvironment/7e646a58-7419-41e2-99e8-163a7abb7b46", + "@type" : "aas:Environment", + "https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultAssetAdministrationShell/b869a629-8d69-4754-9c50-804b0e9eb35a", + "@type" : "aas:AssetAdministrationShell", + "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation" : { + "@id" : "https://admin-shell.io/autogen/DefaultAssetInformation/6882a093-6831-445d-a884-f2ebc37aaa29", + "@type" : "aas:AssetInformation", + "https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind" : { + "@type" : "aas:AssetKind", + "@id" : "https://admin-shell.io/aas/3/0/RC02/AssetKind/Instance" + }, + "https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds" : [ ] + }, + "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { + "@language" : "en-us", + "@value" : "This is a test AAS" + } ], + "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { + "@language" : "de", + "@value" : "Anzeigename 2" + }, { + "@language" : "en", + "@value" : "Display Name 1" + } ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] + } ], + "https://admin-shell.io/aas/3/0/RC02/Environment/conceptdescriptions" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultConceptDescription/14b4a819-7ca0-4cb2-b2c7-33a1c443c899", + "@type" : "aas:ConceptDescription", + "https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultDataSpecification/66cf9a6c-e656-4c95-91be-2ddc1779ec71", + "@type" : "aas:EmbeddedDataSpecification", + "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation" : { + "@id" : "https://admin-shell.io/autogen/DefaultReference/251d9f19-b36b-4c39-b517-3d7e93bd8c96", + "@type" : "aas:Reference", + "https://admin-shell.io/aas/3/0/RC02/Reference/key" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultKey/ad4e8527-e002-4776-87ca-7049e7be440f", + "@type" : "aas:Key", + "https://admin-shell.io/aas/3/0/RC02/Key/value" : "https://example.org" + } ] + } , + "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent" : { + "@id" : "https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/5319d62e-7ca1-4954-addf-76db6bf1e241", + "@type" : "aas:DataSpecificationIEC61360", + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType" : { + "@type" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/DataTypeIEC61360", + "@id" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/RATIONAL" + }, + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition" : [ ], + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName" : [ ], + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName" : [ ] + }, + "https://admin-shell.io/aas/3/0/RC02/DataSpecification/id" : "http://example.org/DataSpecification1" + } ] + } ], + "https://admin-shell.io/aas/3/0/RC02/Environment/submodels" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultSubmodel/18810336-c309-42f8-9986-438f7068f0d6", + "@type" : "aas:Submodel", + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Referable/category" : "Example category", + "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { + "@language" : "en-us", + "@value" : "My Submodel" + } ], + "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { + "@language" : "en", + "@value" : "First Submodel Element name" + }, { + "@language" : "en", + "@value" : "Second Submodel Element name" + } ], + "https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] + } ] +} \ No newline at end of file From 4a8770e1c62695c27664dfd55473e1881e1fd6dd Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 17:08:41 +0100 Subject: [PATCH 002/160] Add rdf module to pom.xml and bump jena version --- dataformat-rdf/pom.xml | 9 ++++++--- pom.xml | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index 8d65df6de..0de21eabc 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -31,14 +31,17 @@ org.slf4j - slf4j-simple - ${slf4j.version} + slf4j-api test pl.pragmatists JUnitParams - ${junit-params.version} + test + + + junit + junit test diff --git a/pom.xml b/pom.xml index d2b698b2a..c3d458265 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ dataformat-core dataformat-json dataformat-xml + dataformat-rdf 1 @@ -68,7 +69,7 @@ 2.0.1.Final 2.3.1 2.1.0 - 4.1.0 + 4.10.0 1.5.1 1.1.0 4.13.2 From 30eede8d0cb1bec68078d1e2847e6e2ef8731bd6 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 19:00:41 +0100 Subject: [PATCH 003/160] Fix compile issues Serializer produce output. Deserializer can't handle LangStrings --- dataformat-rdf/pom.xml | 1 - .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 4 +- .../v3/dataformat/rdf/JsonLDSerializer.java | 4 +- .../dataformat/rdf/LangStringSerializer.java | 6 +- .../aas4j/v3/dataformat/rdf/Parser.java | 48 ++++---- .../aas4j/v3/dataformat/rdf/Serializer.java | 90 ++++++--------- .../AdministrativeInformationMixin.java | 8 +- .../AnnotatedRelationshipElementMixin.java | 4 +- .../mixins/AssetAdministrationShellMixin.java | 12 +- .../rdf/mixins/AssetInformationMixin.java | 20 ++-- .../rdf/mixins/BasicEventElementMixin.java | 32 +++--- .../v3/dataformat/rdf/mixins/BlobMixin.java | 8 +- .../rdf/mixins/ConceptDescriptionMixin.java | 4 +- .../mixins/DataSpecificationContentMixin.java | 5 +- .../DataSpecificationIEC61360Mixin.java | 106 ------------------ .../DataSpecificationIec61360Mixin.java | 106 ++++++++++++++++++ .../DataSpecificationPhysicalUnitMixin.java | 99 ---------------- .../EmbeddedDataSpecificationMixin.java | 16 ++- .../v3/dataformat/rdf/mixins/EntityMixin.java | 16 +-- .../rdf/mixins/EnvironmentMixin.java | 12 +- .../dataformat/rdf/mixins/ExtensionMixin.java | 16 +-- .../v3/dataformat/rdf/mixins/FileMixin.java | 8 +- .../dataformat/rdf/mixins/FormulaMixin.java | 4 +- .../rdf/mixins/HasDataSpecificationMixin.java | 8 +- .../rdf/mixins/HasExtensionsMixin.java | 4 +- .../dataformat/rdf/mixins/HasKindMixin.java | 10 +- .../rdf/mixins/HasSemanticsMixin.java | 8 +- .../rdf/mixins/IdentifiableMixin.java | 8 +- .../mixins/IdentifierKeyValuePairMixin.java | 12 +- .../rdf/mixins/IdentifierMixin.java | 4 +- .../v3/dataformat/rdf/mixins/KeyMixin.java | 8 +- .../mixins/MultiLanguagePropertyMixin.java | 14 +-- .../rdf/mixins/ObjectAttributesMixin.java | 4 +- .../dataformat/rdf/mixins/OperationMixin.java | 12 +- .../rdf/mixins/OperationVariableMixin.java | 4 +- .../rdf/mixins/PolicyDecisionPointMixin.java | 4 +- .../mixins/PolicyEnforcementPointsMixin.java | 4 +- .../mixins/PolicyInformationPointsMixin.java | 8 +- .../dataformat/rdf/mixins/PropertyMixin.java | 12 +- .../rdf/mixins/QualifiableMixin.java | 4 +- .../dataformat/rdf/mixins/QualifierMixin.java | 16 +-- .../v3/dataformat/rdf/mixins/RangeMixin.java | 12 +- .../dataformat/rdf/mixins/ReferableMixin.java | 27 ++--- .../rdf/mixins/ReferenceElementMixin.java | 4 +- .../dataformat/rdf/mixins/ReferenceMixin.java | 8 +- .../rdf/mixins/RelationshipElementMixin.java | 8 +- .../dataformat/rdf/mixins/ResourceMixin.java | 8 +- .../rdf/mixins/SpecificAssetIdMixin.java | 12 +- .../rdf/mixins/SubjectAttributesMixin.java | 4 +- .../SubmodelElementCollectionMixin.java | 12 +- .../rdf/mixins/SubmodelElementListMixin.java | 20 ++-- .../dataformat/rdf/mixins/SubmodelMixin.java | 4 +- .../dataformat/rdf/mixins/ValueListMixin.java | 4 +- .../rdf/mixins/ValueReferencePairMixin.java | 8 +- .../v3/dataformat/rdf/mixins/ViewMixin.java | 4 +- .../v3/dataformat/rdf/SerializerTest.java | 25 ++--- 56 files changed, 406 insertions(+), 527 deletions(-) delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index 0de21eabc..bd72cb847 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -32,7 +32,6 @@ org.slf4j slf4j-api - test pl.pragmatists diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java index b5a790d60..0f403a1d7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java @@ -20,7 +20,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; import java.math.BigDecimal; import java.net.URI; @@ -46,7 +46,7 @@ public JsonLDModule(Map idMap) { addSerializer(BigDecimal.class, new BigDecimalSerializer()); addSerializer(URI.class, new UriSerializer()); - addSerializer(LangString.class, new LangStringSerializer()); + addSerializer(AbstractLangString.class, new LangStringSerializer()); } } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java index 853fe1847..5c28c71c3 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java @@ -95,8 +95,8 @@ public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider private void filterContextWrtBean(Object bean, Map filteredContext) { //Some default entries for AAS - filteredContext.put("aas", "https://admin-shell.io/aas/3/0/RC02/"); - //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + filteredContext.put("aas", "https://admin-shell.io/aas/3/0/"); + //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java index e90100562..cdd3409db 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; -public class LangStringSerializer extends StdSerializer { +public class LangStringSerializer extends StdSerializer { public LangStringSerializer() { @@ -36,7 +36,7 @@ public LangStringSerializer(Class clazz) { @Override - public void serialize(LangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AbstractLangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeStartObject(); if(value.getLanguage() != null && !value.getLanguage().isEmpty()) { diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java index c995160e5..cc6434777 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java @@ -15,10 +15,9 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangString; import org.apache.jena.datatypes.DatatypeFormatException; import org.apache.jena.query.*; import org.apache.jena.rdf.model.*; @@ -72,6 +71,7 @@ class Parser { * @throws IOException thrown if the parsing fails */ private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { + try { //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on @@ -321,7 +321,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Query for all unknown properties and their values //Select properties and values only - if(!targetClass.equals(LangString.class)) { //LangString has no additional properties map. Skip this step + if(!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } for (Map.Entry entry : knownNamespaces.entrySet()) { @@ -657,20 +657,25 @@ private String wrapIfUri(String input) } private Object handleForeignLiteral(Literal literal) throws URISyntaxException { - if(literal.getLanguage() != null && !literal.getLanguage().equals("")) - { - return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); - } +// // TODO: LangTag is not native +// START +// if(literal.getLanguage() != null && !literal.getLanguage().equals("")) +// { +// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); +// } +// +// else +// { +// return literal.getString(); +// } +// END //If not, does it have some datatype URI? //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) //{ // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); //} //If both is not true, add it as normal string - else - { - return literal.getString(); - } + return literal.getString(); } private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { @@ -866,14 +871,17 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur } } - //TypedLiteral - if (LangString.class.isAssignableFrom(currentType)) { - //Either a language tagged string OR literal with type. Only one allowed - if (!literal.getLanguage().equals("")) { - return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); - } - return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag - } +// // TODO: Abstract lan is no longer native type +// START +// //TypedLiteral +// if (LangString.class.isAssignableFrom(currentType)) { +// //Either a language tagged string OR literal with type. Only one allowed +// if (!literal.getLanguage().equals("")) { +// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); +// } +// return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag +// } +// END //BigInteger if (BigInteger.class.isAssignableFrom(currentType)) { @@ -957,7 +965,7 @@ private boolean isPrimitive(Class input) throws IOException { return (URI.class.isAssignableFrom(input) || String.class.isAssignableFrom(input) || XMLGregorianCalendar.class.isAssignableFrom(input) || - LangString.class.isAssignableFrom(input) || + AbstractLangString.class.isAssignableFrom(input) || BigInteger.class.isAssignableFrom(input) || BigDecimal.class.isAssignableFrom(input) || byte[].class.isAssignableFrom(input) || diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java index b18f0567d..375e4b82f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java @@ -23,7 +23,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.Deserializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; @@ -40,18 +39,15 @@ import java.nio.charset.StandardCharsets; import java.util.*; -public class Serializer implements org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer, Deserializer { +public class Serializer { private static final ObjectMapper mapper = new ObjectMapper(); - private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(Serializer.class); - public static String implementingClassesNamePrefix = "Default"; public static String implementingClassesNameSuffix = ""; - static Map, Class> customImplementationMap = new HashMap<>(); - private static boolean charsetWarningPrinted = false; + private final List preprocessors; + private final Logger logger = LoggerFactory.getLogger(Serializer.class); public Serializer() { mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); @@ -61,8 +57,7 @@ public Serializer() { preprocessors = new ArrayList<>(); this.addPreprocessor(new TypeNamePreprocessor()); - if(!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) - { + if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) { charsetWarningPrinted = true; logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); } @@ -71,12 +66,23 @@ public Serializer() { addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/RC02/"); - //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/"); + //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); } + /** + * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". + * + * @param prefix Prefix to be added + * @param namespaceUrl URL of the prefix + */ + public static void addKnownNamespace(String prefix, String namespaceUrl) { + Parser.knownNamespaces.put(prefix, namespaceUrl); + JsonLDSerializer.contextItems.put(prefix, namespaceUrl); + } + /** * Serializes an object to an RDF representation. In order to support RDF, the input instance must be * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). @@ -94,15 +100,14 @@ public String serialize(Object instance) throws IOException { * input instance must be annotated using AAS Metamodel annotations. * * @param instance the instance to be serialized - * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) + * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) * @return RDF serialization of the provided object graph * @throws IOException if the serialization fails */ public synchronized String serialize(Object instance, Lang format) throws IOException { - return serialize(instance, format, new HashMap<>() ); + return serialize(instance, format, new HashMap<>()); } - //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { @@ -164,9 +169,7 @@ public String serializePlainJson(Object instance) throws JsonProcessingException public T deserialize(String serialization, Class valueType) throws DeserializationException { try { return new Parser().parseMessage(serialization, valueType); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } @@ -174,10 +177,10 @@ public T deserialize(String serialization, Class valueType) throws Deseri /** * Inverse method of "serialize" * - * @param serialization JSON(-LD) string - * @param valueType class of top level type + * @param serialization JSON(-LD) string + * @param valueType class of top level type * @param serializationFormat RDF input format - * @param deserialized type + * @param deserialized type * @return an object representing the provided JSON(-LD) structure * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF */ @@ -185,9 +188,7 @@ public T deserialize(String serialization, Class valueType, Lang serializ try { return new Parser().parseMessage(serialization, valueType, serializationFormat); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } @@ -195,33 +196,20 @@ public T deserialize(String serialization, Class valueType, Lang serializ /** * Inverse method of "serialize" * - * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes - * @param valueType class of top level type - * @param deserialized type + * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes + * @param valueType class of top level type + * @param deserialized type * @return an object representing the provided JSON(-LD) structure * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF */ public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { try { return new Parser().parseMessage(rdfModel, valueType); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } - /** - * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". - * @param prefix Prefix to be added - * @param namespaceUrl URL of the prefix - */ - public static void addKnownNamespace(String prefix, String namespaceUrl) - { - Parser.knownNamespaces.put(prefix, namespaceUrl); - JsonLDSerializer.contextItems.put(prefix, namespaceUrl); - } - /** * Method to add a preprocessor for deserialization. *

@@ -255,13 +243,11 @@ public void removePreprocessor(JsonPreprocessor preprocessor) { preprocessors.remove(preprocessor); } - @Override + public String write(Environment aasEnvironment) throws SerializationException { try { return serialize(aasEnvironment); - } - catch (IOException e) - { + } catch (IOException e) { throw new SerializationException("Failed to serialize environment.", e); } } @@ -273,19 +259,15 @@ public String write(Environment aasEnvironment, Lang format) throws Serializatio public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { try { return serialize(aasEnvironment, format, idMap); - } - catch (IOException e) - { + } catch (IOException e) { throw new SerializationException("Failed to serialize environment.", e); } } - @Override + public Environment read(String value) throws DeserializationException { try { return new Parser().parseMessage(value, Environment.class); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Could not deserialize to environment.", e); } } @@ -293,14 +275,12 @@ public Environment read(String value) throws DeserializationException { public Environment read(String value, Lang serializationFormat) throws DeserializationException { try { return new Parser().parseMessage(value, Environment.class, serializationFormat); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Could not deserialize to environment.", e); } } - @Override + public void useImplementation(Class aasInterface, Class implementation) { customImplementationMap.put(aasInterface, implementation); //throw new NotImplementedException("Custom implementation support not yet implemented"); diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java index e967dd795..6c692e3c5 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:AdministrativeInformation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") String getVersion(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") void setVersion(String version); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") String getRevision(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") void setRevision(String revision); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java index 2b8c30171..63e182fdf 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:AnnotatedRelationshipElement") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") List getAnnotations(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") void setAnnotations(List annotations); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java index 9a49ca42c..31fb53258 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java @@ -26,22 +26,22 @@ @JsonTypeName("aas:AssetAdministrationShell") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") AssetInformation getAssetInformation(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") void setAssetInformation(AssetInformation assetInformation); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") Reference getDerivedFrom(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") void setDerivedFrom(Reference derivedFrom); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") List getSubmodels(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") void setSubmodels(List submodels); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java index 08a7e1715..60040db6a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java @@ -28,33 +28,33 @@ @JsonTypeName("aas:AssetInformation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AssetInformationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") AssetKind getAssetKind(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") void setAssetKind(AssetKind assetKind); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") Reference getGlobalAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") void setGlobalAssetId(Reference globalAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") List getSpecificAssetIds(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") void setSpecificAssetIds(List specificAssetIds); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") List getBillOfMaterials(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") void setBillOfMaterials(List billOfMaterials); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") File getDefaultThumbnail(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") void setDefaultThumbnail(File defaultThumbnail); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java index 803e6c037..6526e3db3 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java @@ -28,52 +28,52 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface BasicEventElementMixin extends EventElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") Direction getDirection(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") void setDirection(Direction direction); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") String getLastUpdate(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") void setLastUpdate(String lastUpdate); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") String getMaxInterval(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") void setMaxInterval(String maxInterval); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") Reference getMessageBroker(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") void setMessageBroker(Reference messageBroker); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") String getMessageTopic(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") void setMessageTopic(String messageTopic); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") String getMinInterval(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") void setMinInterval(String minInterval); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") Reference getObserved(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") void setObserved(Reference observed); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") StateOfEvent getState(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") void setState(StateOfEvent state); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java index 267158c70..b5763be43 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:Blob") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface BlobMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") void setConentType(String mimeType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") byte[] getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") void setValue(byte[] value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java index 7cc22006c..3f17da8fa 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:ConceptDescription") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") List getIsCaseOf(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") void setIsCaseOf(List isCaseOf); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java index e9d69f2d1..823206ff2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java @@ -15,18 +15,15 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import org.eclipse.digitaltwin.aas4j.v3.model.*; -import java.util.List; - @JsonTypeName("aas:DataSpecificationContent") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") @JsonSubTypes({ - @JsonSubTypes.Type(value = DataSpecificationIEC61360.class) + @JsonSubTypes.Type(value = DataSpecificationIec61360.class) }) public interface DataSpecificationContentMixin { diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java deleted file mode 100644 index 672645918..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - -@JsonTypeName("aas:DataSpecificationIEC61360") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationIEC61360Mixin extends DataSpecificationContentMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") - public DataTypeIEC61360 getDataType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") - public void setDataType(DataTypeIEC61360 dataType); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") - public List getDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") - public void setDefinitions(List definition); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") - public LevelType getLevelType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") - public void setLevelType(LevelType levelType); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") - public List getPreferredName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") - public void setPreferredName(List preferredName); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") - public List getShortName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") - public void setShortName(List shortName); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") - public String getSourceOfDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") - public void setSourceOfDefinition(String sourceOfDefinition); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") - public String getSymbol(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") - public void setSymbol(String symbol); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") - public String getUnit(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") - public void setUnit(String unit); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") - public Reference getUnitId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") - public void setUnitId(Reference unitId); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") - public String getValueFormat(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") - public void setValueFormat(String valueFormat); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") - public String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") - public void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") - public ValueList getValueList(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") - public void setValueList(ValueList valueList); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") - public Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") - public void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java new file mode 100644 index 000000000..4993c0353 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java @@ -0,0 +1,106 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationIec61360") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationIec61360Mixin extends DataSpecificationContentMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") + public DataTypeIec61360 getDataType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") + public void setDataType(DataTypeIec61360 dataType); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") + public List getDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") + public void setDefinitions(List definition); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") + public LevelType getLevelType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") + public void setLevelType(LevelType levelType); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") + public List getPreferredName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") + public void setPreferredName(List preferredName); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") + public List getShortName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") + public void setShortName(List shortName); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") + public String getSourceOfDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") + public void setSourceOfDefinition(String sourceOfDefinition); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") + public String getSymbol(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") + public void setSymbol(String symbol); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") + public String getUnit(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") + public void setUnit(String unit); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") + public Reference getUnitId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") + public void setUnitId(Reference unitId); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") + public String getValueFormat(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") + public void setValueFormat(String valueFormat); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") + public String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") + public void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") + public ValueList getValueList(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") + public void setValueList(ValueList valueList); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") + public Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") + public void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java deleted file mode 100644 index d299d0399..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; - -import java.util.List; - -@JsonTypeName("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationPhysicalUnitMixin { - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") - String getConversionFactor(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") - void setConversionFactor(String conversionFactor); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") - List getDefinitions(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") - void setDefinitions(List definitions); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") - String getDinNotation(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") - void setDinNotation(String dinNotation); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") - String getEceCode(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") - void setEceCode(String eceCode); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") - String getEceName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") - void setEceName(String eceName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") - String getNistName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") - void setNistName(String nistName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") - String getSiName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") - void setSiName(String siName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") - String getSiNotation(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") - void setSiNotation(String siNotation); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") - String getRegistrationAuthorityId(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") - void setRegistrationAuthorityId(String registrationAuthorityId); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") - String getSupplier(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") - void setSupplier(String supplier); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") - String getUnitName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") - void setUnitName(String unitName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") - String getUnitSymbol(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") - void setUnitSymbol(String unitSymbol); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java index b1fe7ac33..e8f87e544 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java @@ -19,9 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIEC61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; @@ -29,16 +27,16 @@ @JsonTypeName("aas:EmbeddedDataSpecification") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EmbeddedDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") - public DataSpecificationIEC61360 getDataSpecificationContent(); + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") + public DataSpecificationIec61360 getDataSpecificationContent(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") - public void setDataSpecificationContent(DataSpecificationIEC61360 dataSpecificationContent); + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") + public void setDataSpecificationContent(DataSpecificationIec61360 dataSpecificationContent); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") public Reference getDataSpecification(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") public void setDataSpecification(Reference dataSpecification); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java index 6a2636737..35f7da75d 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java @@ -28,27 +28,27 @@ @JsonTypeName("aas:Entity") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EntityMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") Reference getGlobalAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") void setGlobalAssetId(Reference globalAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") SpecificAssetId getSpecificAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") void setSpecificAssetId(SpecificAssetId specificAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") EntityType getEntityType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") void setEntityType(EntityType entityType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") List getStatements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") void setStatements(List statements); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java index 97a7028be..fb74f5287 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java @@ -27,21 +27,21 @@ @JsonTypeName("aas:Environment") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EnvironmentMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") List getAssetAdministrationShells(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") void setAssetAdministrationShells(List assetAdministrationShells); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") List getConceptDescriptions(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") void setConceptDescriptions(List conceptDescriptions); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") List getSubmodels(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") void setSubmodels(List submodels); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java index 62322c3b1..f46030240 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java @@ -24,27 +24,27 @@ @JsonTypeName("aas:Extension") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ExtensionMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") String getName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") void setName(String name); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") Reference getRefersTo(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") void setRefersTo(Reference refersTo); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java index c4c234413..59fa087ff 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:File") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface FileMixin extends DataElementMixin, SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") void setContentType(String contentType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + @JsonProperty("https://admin-shell.io/aas/3/0/File/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + @JsonProperty("https://admin-shell.io/aas/3/0/File/value") void setValue(String value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java index cc5a8707e..cc32cace1 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:Formula") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface FormulaMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") List getDependsOns(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") void setDependsOns(List dependsOns); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java index b0693d8d6..cd7f1b9c2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java @@ -35,15 +35,15 @@ }) public interface HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") List getDataSpecifications(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") void setDataSpecifications(List dataSpecifications); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") List getEmbeddedDataSpecifications(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") void setEmbeddedDataSpecifications(List embeddedDataSpecifications); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java index 772a10c3e..c7a16a663 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:HasExtensions") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface HasExtensionsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") List getExtensions(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") void setExtensions(List extensions); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java index d3f87470a..c8299f52f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ModelingKind; +import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; @@ -31,9 +31,9 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface HasKindMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") - ModelingKind getKind(); + @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") + ModellingKind getKind(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") - void setKind(ModelingKind kind); + @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") + void setKind(ModellingKind kind); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java index a194d33dd..c624b21d7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java @@ -35,15 +35,15 @@ @JsonSubTypes.Type(value = Extension.class) }) public interface HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") Reference getSemanticId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") void setSemanticId(Reference semanticId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") List getSupplementalSemanticIds(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") void setSupplementalSemanticIds(List references); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java index c9590fd02..80bdfe960 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java @@ -33,15 +33,15 @@ @JsonSubTypes.Type(value = ConceptDescription.class) }) public interface IdentifiableMixin extends ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") AdministrativeInformation getAdministration(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") void setAdministration(AdministrativeInformation administration); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") String getId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") void setId(String id); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java index 7594d6bd0..2298936a8 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:IdentifierKeyValuePair") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") String getKey(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") void setKey(String key); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") Reference getExternalSubjectId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") void setExternalSubjectId(Reference externalSubjectId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java index 5c30d2b41..25b4258af 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java @@ -23,9 +23,9 @@ @JsonTypeName("aas:Identifier") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface IdentifierMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") String getIdentifier(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") void setIdentifier(String identifier); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java index 972dca9a1..66cab3fbc 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java @@ -25,15 +25,15 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface KeyMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") KeyTypes getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") void setType(KeyTypes type); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") void setValue(String value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java index 71b17e055..1e290609f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; @@ -26,15 +26,15 @@ @JsonTypeName("aas:MultiLanguageProperty") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface MultiLanguagePropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") - List getValues(); + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") + List getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") - void setValues(List values); + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") + void setValue(List values); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java index a91d8f9aa..095bbc8c9 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:ObjectAttributes") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ObjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") List getObjectAttributes(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") void setObjectAttributes(List objectAttributes); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java index c37547418..e60eb42fc 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java @@ -25,21 +25,21 @@ @JsonTypeName("aas:Operation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface OperationMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") List getInputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") void setInputVariables(List inputVariables); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") List getInoutputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") void setInoutputVariables(List inoutputVariables); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") List getOutputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") void setOutputVariables(List outputVariables); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java index 3e21e6918..a099ae7db 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:OperationVariable") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface OperationVariableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") SubmodelElement getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") void setValue(SubmodelElement value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java index f6a0023c8..8e63a86f8 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:PolicyDecisionPoint") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyDecisionPointMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") boolean getExternalPolicyDecisionPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java index 7eb2bd1a8..d1aaa0eef 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:PolicyEnforcementPoints") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyEnforcementPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") boolean getExternalPolicyEnforcementPoint(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java index db74d7242..935f0b5f0 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java @@ -25,15 +25,15 @@ @JsonTypeName("aas:PolicyInformationPoints") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyInformationPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") boolean getExternalInformationPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") void setExternalInformationPoints(boolean externalInformationPoints); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") List getInternalInformationPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") void setInternalInformationPoints(List internalInformationPoints); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java index 162cda7a2..1466c78e0 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:Property") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java index be2e8c0c9..e4619f351 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java @@ -32,9 +32,9 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface QualifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") List getQualifiers(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") void setQualifiers(List qualifiers); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java index 941567e52..d3c5ef093 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java @@ -24,27 +24,27 @@ @JsonTypeName("aas:Qualifier") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface QualifierMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") String getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") void setType(String type); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java index b46e6de2c..1bef8f17a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:Range") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface RangeMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") String getMax(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") void setMax(String max); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") String getMin(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") void setMin(String min); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java index 349c27b6e..de65fa1eb 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java @@ -20,7 +20,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import java.util.List; @@ -32,27 +33,27 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") String getCategory(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") void setCategory(String category); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") - List getDescription(); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") + List getDescription(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") - void setDescription(List description); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") + void setDescription(List description); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") - List getDisplayName(); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") + List getDisplayName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") - void setDisplayName(List displayName); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") + void setDisplayName(List displayName); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") String getIdShort(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") void setIdShort(String idShort); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java index 6df2a7be1..bbffdaaae 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:ReferenceElement") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ReferenceElementMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") Reference getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") void setValue(Reference value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java index 0af5ae449..55e5b8c98 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java @@ -27,15 +27,15 @@ @JsonTypeName("aas:Reference") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ReferenceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") List getKeys(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") void setKeys(List keys); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") ReferenceTypes getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") void setType(ReferenceTypes type); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java index 31fefc0c7..3b1fba521 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java @@ -29,15 +29,15 @@ @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) }) public interface RelationshipElementMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") Reference getFirst(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") void setFirst(Reference first); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") Reference getSecond(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") void setSecond(Reference second); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java index 4d25d1637..88a6dfff2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java @@ -26,15 +26,15 @@ @JsonTypeName("aas:Resource") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ResourceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") void setContentType(String contentType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") String getPath(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") void setPath(String path); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java index 0380783e6..ec328856e 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java @@ -26,22 +26,22 @@ @JsonTypeName("aas:SpecificAssetId") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SpecificAssetIdMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") String getName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") void setName(String name); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") Reference getExternalSubjectId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") void setExternalSubjectId(Reference reference); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java index f0451e1f4..54401344b 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:SubjectAttributes") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") List getSubjectAttributes(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") void setSubjectAttributes(List subjectAttributes); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java index 722fc32ab..99fe43314 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java @@ -25,21 +25,21 @@ @JsonTypeName("aas:SubmodelElementCollection") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") boolean getAllowDuplicates(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") void setAllowDuplicates(boolean allowDuplicates); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") boolean getOrdered(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") void setOrdered(boolean ordered); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") Collection getValues(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") void setValues(Collection values); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java index 9387f7570..a00265d97 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java @@ -29,33 +29,33 @@ @JsonTypeName("aas:SubmodelElementList") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelElementListMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") boolean getOrderRelevant(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") void setOrderRelevant(boolean orderRelevant); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") Reference getSemanticIdListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") void setSemanticIdListElement(Reference semanticIdListElement); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") AasSubmodelElements getTypeValueListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") void setTypeValueListElement(AasSubmodelElements typeValueListElement); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") List getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") void setValue(List value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") DataTypeDefXsd getValueTypeListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java index df693d6a2..ccb2cbcf7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:Submodel") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") List getSubmodelElements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") void setSubmodelElements(List submodelElements); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java index 2cb4a878c..005eec10a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java @@ -28,9 +28,9 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ValueListMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") List getValueReferencePairs(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") void setValueReferencePairs(List valueReferencePairs); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java index d9502ad58..f57950e61 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:ValueReferencePair") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ValueReferencePairMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java index fd1aa933c..b10f8626e 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:View") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") List getContainedElements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") void setContainedElements(List containedElements); } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 58da78d90..fbd95bf51 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -17,13 +17,8 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIEC61360; import org.junit.Assert; import org.junit.Test; @@ -46,18 +41,18 @@ public void serializeEnvironment() throws IOException, DeserializationException .assetInformation(new DefaultAssetInformation.Builder() .assetKind(AssetKind.INSTANCE) .build()) - .description(Arrays.asList(new DefaultLangString.Builder().text("This is a test AAS").language("en-us").build())) + .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())) .displayName(Arrays.asList( - new DefaultLangString.Builder().text("Anzeigename 2").language("de").build(), - new DefaultLangString.Builder().text("Display Name 1").language("en").build() + 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() - .description(Arrays.asList(new DefaultLangString.Builder().text("My Submodel").language("en-us").build())) + .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())) .displayName(Arrays.asList( - new DefaultLangString.Builder().text("First Submodel Element name").language("en").build(), - new DefaultLangString.Builder().text("Second Submodel Element name").language("en").build() + 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(); @@ -69,8 +64,8 @@ public void serializeEnvironment() throws IOException, DeserializationException .value("https://example.org") .build()) .build()) - .dataSpecificationContent(new DefaultDataSpecificationIEC61360.Builder() - .dataType(DataTypeIEC61360.RATIONAL) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.RATIONAL) .build()) .build()) .build(); @@ -83,7 +78,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .build(); String output = new Serializer().serialize(aasEnv, RDFLanguages.JSONLD); - //System.out.println(output); + System.out.println(output); Assert.assertTrue(output.contains("@context")); // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? From 058582584d1e3284f8e55a29f5e7e91d407f2fdc Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 20:09:36 +0100 Subject: [PATCH 004/160] Separate internals and establish main interfaces --- .../rdf/{Parser.java => ParserHelper.java} | 265 ++++++--------- .../aas4j/v3/dataformat/rdf/RdfParser.java | 318 ++++++++++++++++++ .../v3/dataformat/rdf/RdfSerializer.java | 192 +++++++++++ ...{Serializer.java => SerializerHelper.java} | 76 +---- .../aas4j/v3/dataformat/rdf/ParserTest.java | 198 +++++------ .../v3/dataformat/rdf/SerializerTest.java | 20 +- 6 files changed, 729 insertions(+), 340 deletions(-) rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{Parser.java => ParserHelper.java} (91%) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{Serializer.java => SerializerHelper.java} (75%) diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java similarity index 91% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java index cc6434777..2edd2bd10 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java @@ -51,22 +51,38 @@ /** * Internal class to handle the parsing of JSON-LD into java objects + * * @author maboeckmann */ -class Parser { - - private final Logger logger = LoggerFactory.getLogger(Parser.class); +class ParserHelper { private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); - static Map knownNamespaces = new HashMap<>(); + private final Logger logger = LoggerFactory.getLogger(ParserHelper.class); + /** + * This list contains all primitive Java types + */ + private final Map> builtInMap = new HashMap<>(); + + { + builtInMap.put("int", Integer.TYPE); + builtInMap.put("long", Long.TYPE); + builtInMap.put("double", Double.TYPE); + builtInMap.put("float", Float.TYPE); + builtInMap.put("bool", Boolean.TYPE); + builtInMap.put("char", Character.TYPE); + builtInMap.put("byte", Byte.TYPE); + builtInMap.put("void", Void.TYPE); + builtInMap.put("short", Short.TYPE); + } /** * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle - * @param inputModel Model on which queries are to be evaluated from which information can be retrieved - * @param objectUri URI of the object to be handled + * + * @param inputModel Model on which queries are to be evaluated from which information can be retrieved + * @param objectUri URI of the object to be handled * @param targetClass Variable containing the class which should be returned - * @param Class which should be returned + * @param Class which should be returned * @return Object of desired class, filled with the values extracted from inputModel * @throws IOException thrown if the parsing fails */ @@ -85,18 +101,13 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax try { new URL(objectUri); - } - catch (MalformedURLException e) - { + } catch (MalformedURLException e) { currentObjectIsBlankNode = true; } - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { //Object is a blank node, so the subject URI cannot be used queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; - } - else - { + } else { //Not a blank node, so we can work with the subject URI queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; } @@ -128,7 +139,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Is this class instantiable? if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { //candidateClass = currentClass; - if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { targetClass = (Class) currentClass; break; } @@ -147,8 +158,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } //Enums have no constructors - if(targetClass.isEnum()) - { + if (targetClass.isEnum()) { return handleEnum(targetClass, objectUri); } @@ -196,8 +206,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl */ //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal - if(methodMap.isEmpty()) - { + if (methodMap.isEmpty()) { return returnObject; } @@ -207,11 +216,9 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl StringBuilder queryStringBuilder = new StringBuilder(); - for(Map.Entry entry : knownNamespaces.entrySet()) - { + for (Map.Entry entry : knownNamespaces.entrySet()) { queryStringBuilder.append("PREFIX ").append(entry.getKey()); - if(!entry.getKey().endsWith(":")) - { + if (!entry.getKey().endsWith(":")) { queryStringBuilder.append(":"); } queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); @@ -251,12 +258,9 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl queryStringBuilder.append(" { "); //In case of blank nodes, we can't work with the subject URI - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); - } - else - { + } else { queryStringBuilder.append(" <").append(objectUri).append(">"); } @@ -274,23 +278,20 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //In AAS, every field is optional, as there are no validation annotations in the model queryStringBuilder.append(" OPTIONAL {"); - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { queryStringBuilder.append(" ?s "); - } - else { + } else { queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function } //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) //Find the annotation value containing a colon and interpret this as "prefix:predicate" boolean foundAnnotation = false; - if(field.getAnnotation(IRI.class) != null) { + if (field.getAnnotation(IRI.class) != null) { Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); currentAnnotation.ifPresent(queryStringBuilder::append); foundAnnotation = true; } - if(!foundAnnotation) - { + if (!foundAnnotation) { logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); queryStringBuilder.append("aas:").append(entry.getKey()); } @@ -321,7 +322,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Query for all unknown properties and their values //Select properties and values only - if(!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step + if (!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } for (Map.Entry entry : knownNamespaces.entrySet()) { @@ -420,21 +421,16 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } } externalPropertiesQueryExecution.close(); - } - catch (NoSuchMethodException ignored) - { + } catch (NoSuchMethodException ignored) { //Method does not exist, skip } } - Query query; try { query = QueryFactory.create(queryString); - } - catch (QueryParseException e) - { + } catch (QueryParseException e) { logger.error(queryString); throw e; } @@ -459,13 +455,10 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl String value1 = "", value2 = "", parameterName = ""; QuerySolution querySolution2 = resultSet.next(); Iterator varNamesIt = querySolution2.varNames(); - while(varNamesIt.hasNext()) - { + while (varNamesIt.hasNext()) { String varName = varNamesIt.next(); - if(querySolution.contains(varName)) - { - if(!querySolution.get(varName).equals(querySolution2.get(varName))) - { + if (querySolution.contains(varName)) { + if (!querySolution.get(varName).equals(querySolution2.get(varName))) { parameterName = varName; value1 = querySolution.get(varName).toString(); value2 = querySolution2.get(varName).toString(); @@ -473,8 +466,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } } } - if(!value1.isEmpty()) - { + if (!value1.isEmpty()) { throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); } throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); @@ -491,8 +483,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl if (Collection.class.isAssignableFrom(currentType)) { sparqlParameterName += "s"; //plural form for the concatenated values } - if(!querySolution.contains(sparqlParameterName)) - { + if (!querySolution.contains(sparqlParameterName)) { sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead //TODO: Note: This would not yield full results yet in case some of the values are encapsulated // in blank nodes and some are not, for the same property @@ -504,7 +495,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl String blankNodeId = ""; //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject //For that case, we add some artificial identifiers here - if(objectIsBlankNode) { + if (objectIsBlankNode) { blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); } if (currentType.isEnum()) { @@ -512,8 +503,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //1: The URI of the enum value is given directly e.g. ?s ?p //2: The URI of the enum value is encapsulated in a blank node, e.g. // ?s ?p [ a demo:myEnum, demo:enumValue ] - if(objectIsBlankNode) - { + if (objectIsBlankNode) { Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); @@ -522,24 +512,22 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Only throw this if there is no successful execution IOException anyIOException = null; boolean oneSuccessfulEnumFound = false; - while(innerEnumQueryExecutionResultSet.hasNext()) - { + while (innerEnumQueryExecutionResultSet.hasNext()) { try { entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); oneSuccessfulEnumFound = true; break; //Stop after the first successful execution - } - catch (IOException e) //There might be errors, if multiple types are present, see example above + } catch ( + IOException e) //There might be errors, if multiple types are present, see example above { anyIOException = e; } } //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception - if(anyIOException != null && !oneSuccessfulEnumFound) + if (anyIOException != null && !oneSuccessfulEnumFound) throw new IOException("Could not parse Enum. ", anyIOException); innerEnumQueryExecution.close(); - } - else { + } else { entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); } continue; @@ -635,23 +623,23 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl queryExecution.close(); return returnObject; - } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchFieldException | URISyntaxException | DatatypeConfigurationException | ClassNotFoundException e) { + } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | + InvocationTargetException | NoSuchFieldException | URISyntaxException | + DatatypeConfigurationException | ClassNotFoundException e) { throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); } } /** * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" + * * @param input Input URI, possibly a prefixed value * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" */ - private String wrapIfUri(String input) - { - if(input.startsWith("http://") || input.startsWith("https://")) - { + private String wrapIfUri(String input) { + if (input.startsWith("http://") || input.startsWith("https://")) { return "<" + input + ">"; - } - else { + } else { return input; } } @@ -681,8 +669,7 @@ private Object handleForeignLiteral(Literal literal) throws URISyntaxException { private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map //Literals must be handled "one recursion step above" - if(node.isLiteral()) - { + if (node.isLiteral()) { throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); } @@ -693,15 +680,13 @@ private HashMap handleForeignNode(RDFNode node, HashMap newList = new ArrayList<>(); @@ -711,36 +696,28 @@ private HashMap handleForeignNode(RDFNode node, HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); subMap.put("@id", querySolution.getResource("o").getURI()); - if(map.containsKey(propertyUri)) - { - map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(subMap)); - } - else { + if (map.containsKey(propertyUri)) { + map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(subMap)); + } else { map.put(querySolution.get("p").toString(), subMap); } } @@ -749,11 +726,11 @@ private HashMap handleForeignNode(RDFNode node, HashMap targetClass, String fieldName) throws NoSu } catch (NoSuchFieldException e2) { try { return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); - } - catch (NoSuchFieldException e3) - { + } catch (NoSuchFieldException e3) { throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); } } @@ -777,9 +752,10 @@ private Field getFieldByName(Class targetClass, String fieldName) throws NoSu /** * Internal function to create a single enum object from a given desired class and a URL + * * @param enumClass The enum class - * @param url The URL of the enum value - * @param Enum class + * @param url The URL of the enum value + * @param Enum class * @return Value of enumClass matching the input URL * @throws IOException thrown if no matching enum value could be found */ @@ -788,8 +764,7 @@ private T handleEnum(Class enumClass, String url) throws IOException { throw new RuntimeException("Non-Enum class passed to handleEnum function."); } T[] constants = enumClass.getEnumConstants(); - if(url.contains("/")) - { + if (url.contains("/")) { url = url.substring(url.lastIndexOf("/") + 1); } for (T constant : constants) { @@ -803,13 +778,14 @@ private T handleEnum(Class enumClass, String url) throws IOException { /** * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) - * @param currentType Input Class (or primitive) - * @param literal Value as literal (can be null in some cases) + * + * @param currentType Input Class (or primitive) + * @param literal Value as literal (can be null in some cases) * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) * @return Object of type currentType - * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI + * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails - * @throws IOException thrown, if no matching "simple class" could be found + * @throws IOException thrown, if no matching "simple class" could be found */ private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { //Java way of checking for primitives, i.e. int, char, float, double, ... @@ -853,18 +829,14 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown try { return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); - } - catch (DatatypeFormatException | DateTimeParseException ignored) - { + } catch (DatatypeFormatException | DateTimeParseException ignored) { //Not a valid dateTimeStamp. Try parsing just to Date try { Date date = new SimpleDateFormat().parse(literal.getValue().toString()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); - } - catch (ParseException | DateTimeParseException | DatatypeFormatException e2) - { + } catch (ParseException | DateTimeParseException | DatatypeFormatException e2) { //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); } @@ -906,22 +878,6 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur throw new IOException("Unrecognized primitive type: " + currentType.getName()); } - /** - * This list contains all primitive Java types - */ - private final Map> builtInMap = new HashMap<>(); - { - builtInMap.put("int", Integer.TYPE); - builtInMap.put("long", Long.TYPE); - builtInMap.put("double", Double.TYPE); - builtInMap.put("float", Float.TYPE); - builtInMap.put("bool", Boolean.TYPE); - builtInMap.put("char", Character.TYPE); - builtInMap.put("byte", Byte.TYPE); - builtInMap.put("void", Void.TYPE); - builtInMap.put("short", Short.TYPE); - } - private boolean isArrayListTypePrimitive(Type t) throws IOException { String typeName = extractTypeNameFromCollection(t); @@ -940,14 +896,12 @@ private String extractTypeNameFromCollection(Type t) throws IOException { throw new IOException("Illegal argument encountered while interpreting type parameter"); } //"" or super instead of extends - if(typeName.contains("?")) - { + if (typeName.contains("?")) { //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); } //No extends - else - { + else { return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); } } @@ -974,9 +928,10 @@ private boolean isPrimitive(Class input) throws IOException { /** * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) - * @param rdfModel RDF input to be parsed + * + * @param rdfModel RDF input to be parsed * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1004,7 +959,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { String className = fullName.substring(fullName.lastIndexOf('/') + 1); //In case of hash-namespaces - if(className.contains("#")) { + if (className.contains("#")) { className = className.substring(className.lastIndexOf("#")); } @@ -1014,7 +969,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { } for (Class currentClass : implementingClasses) { - if (currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { returnCandidates.put(solution.get("id").toString(), currentClass); } } @@ -1028,13 +983,11 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { //At this point, we parsed the model and know to which implementing class we want to parse //Check if there are several options available - if(returnCandidates.size() > 1) - { + if (returnCandidates.size() > 1) { String bestCandidateId = null; Class bestCandidateClass = null; long bestNumRelations = -1L; - for(Map.Entry> entry : returnCandidates.entrySet()) - { + for (Map.Entry> entry : returnCandidates.entrySet()) { String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + " WHERE {" + " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + @@ -1042,8 +995,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); - if(graphSize > bestNumRelations) - { + if (graphSize > bestNumRelations) { bestNumRelations = graphSize; bestCandidateId = entry.getKey(); bestCandidateClass = entry.getValue(); @@ -1065,9 +1017,10 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { /** * Entry point to this class. Takes a message and a desired target class (can be an interface) - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1078,10 +1031,11 @@ T parseMessage(String message, Class targetClass) throws IOException { /** * Entry point to this class. Takes a message and a desired target class (can be an interface) - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) * @param serializationFormat Input RDF format - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1119,7 +1073,7 @@ private Model readMessage(String message) throws IOException { * Reads a message into an Apache Jena model, guessing the input language. * Note: Guessing the language may cause some error messages during parsing attempts * - * @param message Message to be read + * @param message Message to be read * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML * @return The model of the message */ @@ -1129,9 +1083,7 @@ private Model readMessage(String message, Lang language) throws IOException { try { RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); - } - catch (RiotException e) - { + } catch (RiotException e) { throw new IOException("Failed to parse input as " + language, e); } return targetModel; @@ -1139,6 +1091,7 @@ private Model readMessage(String message, Lang language) throws IOException { /** * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated + * * @param someClass Input class of which implementable subclasses need to be found * @return ArrayList of instantiable subclasses */ @@ -1152,20 +1105,18 @@ ArrayList> getImplementingClasses(Class someClass) { } } if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { - result.add(Serializer.customImplementationMap.getOrDefault(someClass, someClass)); + result.add(SerializerHelper.customImplementationMap.getOrDefault(someClass, someClass)); } return result; } - private void addArtificialBlankNodeLabels(Model m) - { + private void addArtificialBlankNodeLabels(Model m) { //Get all blank nodes Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); QueryExecution qe = QueryExecutionFactory.create(q, m); ResultSet rs = qe.execSelect(); List statementsToAdd = new ArrayList<>(); - while(rs.hasNext()) - { + while (rs.hasNext()) { QuerySolution qs = rs.next(); statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), 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..bba8cc423 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java @@ -0,0 +1,318 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.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/RdfSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java new file mode 100644 index 000000000..3fc0fe1be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java @@ -0,0 +1,192 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +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.Collection; +import java.util.List; + +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 { + throw new RuntimeException("Not Implemented"); + } 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 { + throw new RuntimeException("Not Implemented"); + } 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 JSON node. + * + * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize + * @return the Jena Model + */ + public Model toModel(Environment aasEnvironment) { + throw new RuntimeException("Not Implemented"); + } + + /** + * Converts a given instance of a Referable to a JSON node. + * + * @param referable the referable to serialize + * @return the Jena Model + */ + public Model toModel(Referable referable) { + throw new RuntimeException("Not Implemented"); + } + + + /** + * 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/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java similarity index 75% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java index 375e4b82f..50237734f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java @@ -22,7 +22,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; @@ -39,7 +38,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; -public class Serializer { +class SerializerHelper { private static final ObjectMapper mapper = new ObjectMapper(); public static String implementingClassesNamePrefix = "Default"; @@ -47,9 +46,9 @@ public class Serializer { static Map, Class> customImplementationMap = new HashMap<>(); private static boolean charsetWarningPrinted = false; private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(Serializer.class); + private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); - public Serializer() { + public SerializerHelper() { mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); mapper.setMixInResolver(new ReflectiveMixInResolver()); @@ -79,7 +78,7 @@ public Serializer() { * @param namespaceUrl URL of the prefix */ public static void addKnownNamespace(String prefix, String namespaceUrl) { - Parser.knownNamespaces.put(prefix, namespaceUrl); + ParserHelper.knownNamespaces.put(prefix, namespaceUrl); JsonLDSerializer.contextItems.put(prefix, namespaceUrl); } @@ -157,58 +156,6 @@ public String serializePlainJson(Object instance) throws JsonProcessingException return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); } - /** - * Inverse method of "serialize" - * - * @param serialization JSON(-LD) string - * @param valueType class of top level type - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(String serialization, Class valueType) throws DeserializationException { - try { - return new Parser().parseMessage(serialization, valueType); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } - - /** - * Inverse method of "serialize" - * - * @param serialization JSON(-LD) string - * @param valueType class of top level type - * @param serializationFormat RDF input format - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(String serialization, Class valueType, Lang serializationFormat) throws DeserializationException { - try { - - return new Parser().parseMessage(serialization, valueType, serializationFormat); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } - - /** - * Inverse method of "serialize" - * - * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes - * @param valueType class of top level type - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { - try { - return new Parser().parseMessage(rdfModel, valueType); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } /** * Method to add a preprocessor for deserialization. @@ -264,21 +211,6 @@ public String write(Environment aasEnvironment, Lang format, Map } } - public Environment read(String value) throws DeserializationException { - try { - return new Parser().parseMessage(value, Environment.class); - } catch (IOException e) { - throw new DeserializationException("Could not deserialize to environment.", e); - } - } - - public Environment read(String value, Lang serializationFormat) throws DeserializationException { - try { - return new Parser().parseMessage(value, Environment.class, serializationFormat); - } catch (IOException e) { - throw new DeserializationException("Could not deserialize to environment.", e); - } - } public void useImplementation(Class aasInterface, Class implementation) { diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java index 9a3e79235..7acbacdba 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -41,7 +41,7 @@ public class ParserTest { @Test public void parseAasEnvironmentTest() throws IOException, DeserializationException { String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); - Environment aasEnv = new Serializer().read(aasEnvAsString); + Environment aasEnv = new RdfParser().read(aasEnvAsString); Assert.assertEquals(1, aasEnv.getSubmodels().size()); Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); @@ -51,103 +51,103 @@ public void parseAasEnvironmentTest() throws IOException, DeserializationExcepti Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); } - - @Test - @Ignore - public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { - String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); - Environment environment = new Serializer().read(aasEnvAsString); - - // TODO continue providing a correct AASFull Turtle representation - // TODO test for LangStrings - Assert.assertEquals(AASFull.ENVIRONMENT, environment); - } - - - @Test - @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", - "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) - public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - - AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); - } - - @Test - @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) - public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - - AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); - } - - @Test - @Parameters({"Submodel_SubmodelElement_Example.ttl"}) - public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - //These work - - Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); - - - //The following examples do not work yet, as they are semantically problematic - //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); - //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); - } - - - - - @Test - public void deserializeConceptDescription() throws IOException, DeserializationException { - String conceptDescription = "{\n" + - " \"@context\" : {\n" + - " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + - " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + - " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + - " },\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + - " \"@type\" : \"aas:ConceptDescription\",\n" + - " \"isCaseOf\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + - " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + - " \"@type\" : \"aas:Reference\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + - " \"@type\" : \"aas:Key\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + - " } ]\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + - " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + - " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + - " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + - " } ]\n" + - "}"; - - Serializer serializer = new Serializer(); - ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); - - Assert.assertNotNull(c); - } - +// +// @Test +// @Ignore +// public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { +// String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); +// Environment environment = new RdfParser().read(aasEnvAsString); +// +// // TODO continue providing a correct AASFull Turtle representation +// // TODO test for LangStrings +// Assert.assertEquals(AASFull.ENVIRONMENT, environment); +// } +// +// +// @Test +// @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", +// "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) +// public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// +// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); +// } +// +// @Test +// @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) +// public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// +// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); +// } +// +// @Test +// @Parameters({"Submodel_SubmodelElement_Example.ttl"}) +// public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// //These work +// +// Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); +// +// +// //The following examples do not work yet, as they are semantically problematic +// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); +// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); +// } +// +// +// +// +// @Test +// public void deserializeConceptDescription() throws IOException, DeserializationException { +// String conceptDescription = "{\n" + +// " \"@context\" : {\n" + +// " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + +// " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + +// " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + +// " },\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + +// " \"@type\" : \"aas:ConceptDescription\",\n" + +// " \"isCaseOf\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + +// " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + +// " \"@type\" : \"aas:Reference\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + +// " \"@type\" : \"aas:Key\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + +// " } ]\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + +// " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + +// " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + +// " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + +// " } ]\n" + +// "}"; +// +// Serializer serializer = new Serializer(); +// ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); +// +// Assert.assertNotNull(c); +// } +// } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index fbd95bf51..ba7b28eab 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -17,6 +17,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; @@ -77,19 +78,14 @@ public void serializeEnvironment() throws IOException, DeserializationException .conceptDescriptions(conceptDescription) .build(); - String output = new Serializer().serialize(aasEnv, RDFLanguages.JSONLD); - System.out.println(output); + String output = null; + try { + output = new RdfSerializer().write(aasEnv); + System.out.println(output); + } catch (SerializationException e) { + throw new RuntimeException(e); + } - Assert.assertTrue(output.contains("@context")); - // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? - Assert.assertTrue(output.contains("\"@type\" : \"aas:Environment\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:AssetAdministrationShell\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:Submodel\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:ConceptDescription\"")); - Environment environment = new Serializer().deserialize(output, Environment.class); - Assert.assertNotNull(environment); - - // Assert.assertTrue(aasEnv.equals(environment)); // TODO: Serialising and parsing to/from RDF looses the sequence of e.g. LangStrings, therefore this test fails also for semantically equal objects } } From c1bc9ec76bee5a2342269440910f0c4e7d182578 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 20:13:07 +0100 Subject: [PATCH 005/160] Make the initial test running again --- .../v3/dataformat/rdf/RdfSerializer.java | 4 +++- .../v3/dataformat/rdf/SerializerTest.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) 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 index 3fc0fe1be..ed26ec3fe 100644 --- 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 @@ -3,6 +3,7 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; +import org.apache.jena.riot.system.Serializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -16,6 +17,7 @@ public class RdfSerializer { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + SerializerHelper serializerHelper = new SerializerHelper(); /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * @@ -26,7 +28,7 @@ public class RdfSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + return serializerHelper.write(aasEnvironment, serializationFormat); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index ba7b28eab..54b26a6bf 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -46,7 +46,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .displayName(Arrays.asList( 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() @@ -54,21 +54,21 @@ public void serializeEnvironment() throws IOException, DeserializationException .displayName(Arrays.asList( 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() .embeddedDataSpecifications(new DefaultEmbeddedDataSpecification.Builder() - .dataSpecification(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.org") - .build()) + .dataSpecification(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.org") + .build()) + .build()) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.RATIONAL) + .build()) .build()) - .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() - .dataType(DataTypeIec61360.RATIONAL) - .build()) - .build()) .build(); List aasList = new ArrayList<>(Collections.singletonList(aas)); From 5763c228c018e5e879501881b5a3f946f90cce29 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 4 Jan 2024 11:57:27 +0100 Subject: [PATCH 006/160] Add complex test for ConceptDescription --- .../aas4j/v3/dataformat/rdf/ParserHelper.java | 30 ++-- .../v3/dataformat/rdf/RdfSerializer.java | 2 +- .../v3/dataformat/rdf/SerializerHelper.java | 36 +++- .../v3/dataformat/rdf/SerializerTest.java | 163 ++++++++++++++++-- .../aas4j/v3/model/Identifiable.java | 4 +- 5 files changed, 200 insertions(+), 35 deletions(-) diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java index 2edd2bd10..a9d0d7540 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java @@ -135,16 +135,16 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl className = className.substring(className.lastIndexOf("#") + 1); } - for (Class currentClass : implementingClasses) { - //Is this class instantiable? - if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { - //candidateClass = currentClass; - if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { - targetClass = (Class) currentClass; - break; - } - } - } +// for (Class currentClass : implementingClasses) { +// //Is this class instantiable? +// if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { +// //candidateClass = currentClass; +// if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(this.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { +// targetClass = (Class) currentClass; +// break; +// } +// } +// } } queryExecution.close(); //Did we find "the" class, i.e. instantiable and name matches? @@ -968,11 +968,11 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { className = className.substring(4); } - for (Class currentClass : implementingClasses) { - if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { - returnCandidates.put(solution.get("id").toString(), currentClass); - } - } +// for (Class currentClass : implementingClasses) { +// if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { +// returnCandidates.put(solution.get("id").toString(), currentClass); +// } +// } //if (returnCandidates.size() > 0) break; } queryExecution.close(); 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 index ed26ec3fe..e24460f47 100644 --- 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 @@ -55,7 +55,7 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + return serializerHelper.write(referable, serializationFormat); } 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/SerializerHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java index 50237734f..0009a96e9 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java @@ -30,6 +30,7 @@ import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,11 +41,11 @@ class SerializerHelper { - private static final ObjectMapper mapper = new ObjectMapper(); - public static String implementingClassesNamePrefix = "Default"; - public static String implementingClassesNameSuffix = ""; + private final ObjectMapper mapper = new ObjectMapper(); + public String implementingClassesNamePrefix = "Default"; + public String implementingClassesNameSuffix = ""; static Map, Class> customImplementationMap = new HashMap<>(); - private static boolean charsetWarningPrinted = false; + private boolean charsetWarningPrinted = false; private final List preprocessors; private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); @@ -77,7 +78,7 @@ public SerializerHelper() { * @param prefix Prefix to be added * @param namespaceUrl URL of the prefix */ - public static void addKnownNamespace(String prefix, String namespaceUrl) { + public void addKnownNamespace(String prefix, String namespaceUrl) { ParserHelper.knownNamespaces.put(prefix, namespaceUrl); JsonLDSerializer.contextItems.put(prefix, namespaceUrl); } @@ -103,12 +104,13 @@ public String serialize(Object instance) throws IOException { * @return RDF serialization of the provided object graph * @throws IOException if the serialization fails */ - public synchronized String serialize(Object instance, Lang format) throws IOException { + public String serialize(Object instance, Lang format) throws IOException { return serialize(instance, format, new HashMap<>()); } //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function - public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { + //HoRi: No, bad design + public String serialize(Object instance, Lang format, Map idMap) throws IOException { if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); } @@ -211,6 +213,26 @@ public String write(Environment aasEnvironment, Lang format, Map } } + public String write(Referable referable) throws SerializationException { + try { + return serialize(referable); + } catch (IOException e) { + throw new SerializationException("Failed to serialize environment.", e); + } + } + + public String write(Referable referable, Lang format) throws SerializationException { + return write(referable, format, new HashMap<>()); + } + + public String write(Referable referable, Lang format, Map idMap) throws SerializationException { + try { + return serialize(referable, format, idMap); + } catch (IOException e) { + throw new SerializationException("Failed to serialize environment.", e); + } + } + public void useImplementation(Class aasInterface, Class implementation) { diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 54b26a6bf..6431a764b 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -15,28 +15,178 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; +import org.apache.jena.rdf.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.DeserializationException; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; import org.junit.Assert; import org.junit.Test; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; + public class SerializerTest { //TODO: Optional: Prefixes instead of full URIs //TODO: Optional: Do not serialize empty collections + @Test + public void simpleConceptDescription() throws IOException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("simple") + .build(); + + String output = null; + try { + output = new RdfSerializer().write(conceptDescription); + System.out.println(output); + + Model model = ModelFactory.createDefaultModel(); + InputStream inputStream = new ByteArrayInputStream(output.getBytes()); + model.read(inputStream, null, "TTL"); +// ResourceFactory.createResource(Identifiable.id); +// ResourceFactory.createProperty(propertyUriString); + // Get all subject nodes that are of type ConceptDescription + ResIterator resIterator = model.listResourcesWithProperty(RDF.type, + ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); + Resource createdConceptDescriptionResource = resIterator.nextResource(); + Statement idStatement = model.getProperty(createdConceptDescriptionResource, + ResourceFactory.createProperty(Identifiable.id)); + assert idStatement.getString().equals(conceptDescription.getId()); + } catch (SerializationException e) { + throw new RuntimeException(e); + } + + } + + @Test + public void complexConceptDescription() throws IOException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("complex") + .extensions(Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build())) + .category("myCategory") + .idShort("exampleIdShort") + .displayName(Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build() + )) + .description(Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build() + )) + .administration(new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .creator(new DefaultReference.Builder() + .keys(Arrays.asList( + 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()) + .build() + ).isCaseOf(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.com/outside") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build() + )) + .embeddedDataSpecifications(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()) + .build()) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .levelType(new DefaultLevelType.Builder() + .max(true) + .min(true) + .nom(false) + .typ(false) + .build()) + .unit("gram") + .symbol("g") +// .definition() +// .shortName() +// .preferredName() +// .valueFormat() +// .valueList() + .dataType(DataTypeIec61360.INTEGER_MEASURE) + .build()) + .build()) + .build(); + + String output = null; + try { + String outputJsonLd = new RdfSerializer().write(conceptDescription, Lang.JSONLD); + System.out.println(outputJsonLd); + output = new RdfSerializer().write(conceptDescription); + System.out.println(output); + + Model model = ModelFactory.createDefaultModel(); + InputStream inputStream = new ByteArrayInputStream(output.getBytes()); + model.read(inputStream, null, "TTL"); +// ResourceFactory.createResource(Identifiable.id); +// ResourceFactory.createProperty(propertyUriString); + // Get all subject nodes that are of type ConceptDescription + ResIterator resIterator = model.listResourcesWithProperty(RDF.type, + ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); + Resource createdConceptDescriptionResource = resIterator.nextResource(); + Statement idStatement = model.getProperty(createdConceptDescriptionResource, + ResourceFactory.createProperty(Identifiable.id)); + assert idStatement.getString().equals(conceptDescription.getId()); + } catch (SerializationException e) { + throw new RuntimeException(e); + } + + } @Test - public void serializeEnvironment() throws IOException, DeserializationException { + public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() .assetInformation(new DefaultAssetInformation.Builder() @@ -78,14 +228,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .conceptDescriptions(conceptDescription) .build(); - String output = null; - try { - output = new RdfSerializer().write(aasEnv); - System.out.println(output); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - - + String output = new RdfSerializer().write(aasEnv); + System.out.println(output); } } 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..41afc0483 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,7 @@ @KnownSubtypes.Type(value = Submodel.class) }) public interface Identifiable extends Referable { - + String id = "https://admin-shell.io/aas/3/0/Identifiable/id"; /** * Administrative information of an identifiable element. * @@ -56,7 +56,7 @@ public interface Identifiable extends Referable { * * @return Returns the String for the property id. */ - @IRI("https://admin-shell.io/aas/3/0/Identifiable/id") + @IRI(id) String getId(); /** From 804ffcf577c42871e9e8fe195c70daf8d6156428 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 25 Jan 2024 15:00:13 +0100 Subject: [PATCH 007/160] Fix base structure and simple test cases --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 239 ++++ .../rdf/DefaultRDFHandlerResult.java | 31 + .../v3/dataformat/rdf/FallbackSerializer.java | 42 - .../v3/dataformat/rdf/IgnoreTypeMixIn.java | 22 - .../rdf/IncompatibleTypeException.java | 7 + .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 52 - .../v3/dataformat/rdf/JsonLDSerializer.java | 196 --- .../rdf/JsonLDSerializerModifier.java | 44 - .../dataformat/rdf/JsonLdEnumSerializer.java | 88 -- .../dataformat/rdf/LangStringSerializer.java | 53 - .../aas4j/v3/dataformat/rdf/ParserHelper.java | 1129 ----------------- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 27 + .../rdf/{RdfParser.java => RDFParser.java} | 6 +- .../v3/dataformat/rdf/RDFPartialHandler.java | 10 + .../rdf/RDFSerializationResult.java | 10 + ...{RdfSerializer.java => RDFSerializer.java} | 19 +- .../v3/dataformat/rdf/SerializerHelper.java | 242 ---- .../v3/dataformat/rdf/UriSerializer.java | 53 - .../rdf/custom/BigDecimalSerializer.java | 42 - .../rdf/custom/JsonLdEnumMixin.java | 23 - .../rdf/custom/LangStringMixin.java | 35 - .../rdf/custom/ReflectiveMixInResolver.java | 41 - .../XMLGregorianCalendarDeserializer.java | 49 - .../XMLGregorianCalendarSerializer.java | 47 - .../aas4j/v3/dataformat/rdf/doc.md | 9 + ...ltAdministrativeInformationRDFHandler.java | 19 + ...nnotatedRelationshipElementRDFHandler.java | 20 + ...ultAssetAdministrationShellRDFHandler.java | 26 + .../DefaultAssetInformationRDFHandler.java | 20 + .../DefaultBasicEventElementRDFHandler.java | 20 + .../rdf/handlers/DefaultBlobRDFHandler.java | 20 + .../handlers/DefaultCapabilityRDFHandler.java | 20 + .../DefaultConceptDescriptionRDFHandler.java | 52 + ...ltDataSpecificationIEC61360RDFHandler.java | 20 + ...ltEmbeddedDataSpecificationRDFHandler.java | 20 + .../rdf/handlers/DefaultEntityRDFHandler.java | 20 + .../handlers/DefaultExtensionRDFHandler.java | 20 + .../rdf/handlers/DefaultFileRDFHandler.java | 20 + .../rdf/handlers/DefaultKeyRDFHandler.java | 42 + .../DefaultLangStringNameTypeRDFHandler.java | 20 + .../DefaultLangStringTextTypeRDFHandler.java | 19 + ...efaultMultiLanguagePropertyRDFHandler.java | 20 + .../handlers/DefaultOperationRDFHandler.java | 20 + .../handlers/DefaultPropertyRDFHandler.java | 20 + .../handlers/DefaultQualifierRDFHandler.java | 20 + .../rdf/handlers/DefaultRangeRDFHandler.java | 20 + .../DefaultReferenceElementRDFHandler.java | 20 + .../handlers/DefaultReferenceRDFHandler.java | 60 + .../DefaultRelationshipElementRDFHandler.java | 20 + .../handlers/DefaultResrouceRDFHandler.java | 19 + .../DefaultSpecificAssetIdRDFHandler.java | 20 + ...ltSubmodelElementCollectionRDFHandler.java | 20 + .../DefaultSubmodelElementListRDFHandler.java | 22 + .../DefaultHasSemanticsRDFHandler.java | 21 + .../DefaultIdentifiableRDFHandler.java | 49 + .../partial/DefaultReferableRDFHandler.java | 46 + .../AdministrativeInformationMixin.java | 38 - .../AnnotatedRelationshipElementMixin.java | 33 - .../mixins/AssetAdministrationShellMixin.java | 47 - .../rdf/mixins/AssetInformationMixin.java | 60 - .../rdf/mixins/BasicEventElementMixin.java | 79 -- .../v3/dataformat/rdf/mixins/BlobMixin.java | 38 - .../rdf/mixins/CapabilityMixin.java | 27 - .../rdf/mixins/ConceptDescriptionMixin.java | 33 - .../rdf/mixins/DataElementMixin.java | 37 - .../mixins/DataSpecificationContentMixin.java | 30 - .../DataSpecificationIec61360Mixin.java | 106 -- .../EmbeddedDataSpecificationMixin.java | 42 - .../v3/dataformat/rdf/mixins/EntityMixin.java | 54 - .../rdf/mixins/EnvironmentMixin.java | 47 - .../rdf/mixins/EventElementMixin.java | 33 - .../rdf/mixins/EventMessageMixin.java | 27 - .../dataformat/rdf/mixins/ExtensionMixin.java | 50 - .../v3/dataformat/rdf/mixins/FileMixin.java | 38 - .../dataformat/rdf/mixins/FormulaMixin.java | 33 - .../rdf/mixins/HasDataSpecificationMixin.java | 49 - .../rdf/mixins/HasExtensionsMixin.java | 33 - .../dataformat/rdf/mixins/HasKindMixin.java | 39 - .../rdf/mixins/HasSemanticsMixin.java | 49 - .../rdf/mixins/IdentifiableMixin.java | 47 - .../mixins/IdentifierKeyValuePairMixin.java | 44 - .../rdf/mixins/IdentifierMixin.java | 31 - .../v3/dataformat/rdf/mixins/KeyMixin.java | 39 - .../mixins/MultiLanguagePropertyMixin.java | 40 - .../rdf/mixins/ObjectAttributesMixin.java | 33 - .../dataformat/rdf/mixins/OperationMixin.java | 45 - .../rdf/mixins/OperationVariableMixin.java | 32 - .../rdf/mixins/PolicyDecisionPointMixin.java | 32 - .../mixins/PolicyEnforcementPointsMixin.java | 32 - .../mixins/PolicyInformationPointsMixin.java | 39 - .../dataformat/rdf/mixins/PropertyMixin.java | 44 - .../rdf/mixins/QualifiableMixin.java | 40 - .../dataformat/rdf/mixins/QualifierMixin.java | 50 - .../v3/dataformat/rdf/mixins/RangeMixin.java | 44 - .../dataformat/rdf/mixins/ReferableMixin.java | 59 - .../rdf/mixins/ReferenceElementMixin.java | 32 - .../dataformat/rdf/mixins/ReferenceMixin.java | 41 - .../rdf/mixins/RelationshipElementMixin.java | 43 - .../dataformat/rdf/mixins/ResourceMixin.java | 40 - .../rdf/mixins/SpecificAssetIdMixin.java | 47 - .../rdf/mixins/SubjectAttributesMixin.java | 33 - .../SubmodelElementCollectionMixin.java | 45 - .../rdf/mixins/SubmodelElementListMixin.java | 61 - .../rdf/mixins/SubmodelElementMixin.java | 40 - .../dataformat/rdf/mixins/SubmodelMixin.java | 33 - .../dataformat/rdf/mixins/ValueListMixin.java | 36 - .../rdf/mixins/ValueReferencePairMixin.java | 38 - .../v3/dataformat/rdf/mixins/ViewMixin.java | 33 - .../rdf/preprocessing/BasePreprocessor.java | 53 - .../rdf/preprocessing/JsonPreprocessor.java | 42 - .../preprocessing/TypeNamePreprocessor.java | 194 --- .../aas4j/v3/dataformat/rdf/ParserTest.java | 120 -- .../v3/dataformat/rdf/SerializerTest.java | 225 +--- dataformat-rdf/src/test/resources/AASFull.ttl | 354 ------ .../resources/AAS_Reference_shortExample.nt | 16 - .../resources/AAS_Reference_shortExample.ttl | 27 - .../AssetAdministrationShell_Example.ttl | 56 - .../src/test/resources/Complete_Example.ttl | 347 ----- .../src/test/resources/Overall-Example.nt | 253 ---- .../src/test/resources/ReferenceExample.ttl | 18 - .../Submodel_SubmodelElement_Example.ttl | 137 -- .../Submodel_SubmodelElement_shortExample.nt | 25 - .../Submodel_SubmodelElement_shortExample.ttl | 42 - .../resources/example-from-serializer.jsonld | 88 -- .../aas4j/v3/model/Identifiable.java | 3 +- 125 files changed, 1169 insertions(+), 6317 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{RdfParser.java => RDFParser.java} (98%) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{RdfSerializer.java => RDFSerializer.java} (93%) delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/doc.md create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java delete mode 100644 dataformat-rdf/src/test/resources/AASFull.ttl delete mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt delete mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Complete_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Overall-Example.nt delete mode 100644 dataformat-rdf/src/test/resources/ReferenceExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/example-from-serializer.jsonld 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..d75755bad --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java @@ -0,0 +1,239 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Property; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; + +/** + * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. + */ +public class AASNamespace { + public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; + + public static final 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 class Key { + /** + * The key value, for example an IRDI or an URI + */ + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/value"); + /** + * Denotes which kind of entity is referenced. + */ + public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); + } + + public static class Reference { + public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); + public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); + } + + public static class Referable { + public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); + public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); + public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); + public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); + } + + public static class Identifiable { + public static final Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); + public static final 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 Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); + } + + /** + * Enumeration of different key value types within a key. + * + * @see AASNamespace.Key + */ + public static class KeyTypes { + public static final Resource AnnotatedRelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); + public static final Resource AssetAdministrationShell = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AssetAdministrationShell"); + public static final Resource BasicEventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/BasicEventElement"); + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Blob"); + public static final Resource Capability = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Capability"); + public static final Resource ConceptDescription = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ConceptDescription"); + public static final Resource DataElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/DataElement"); + public static final Resource Entity = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Entity"); + public static final Resource EventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/EventElement"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/File"); + public static final Resource FragmentReference = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/FragmentReference"); + public static final Resource GlobalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/GlobalReference"); + public static final Resource Identifiable = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Identifiable"); + public static final Resource MultiLanguageProperty = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/MultiLanguageProperty"); + public static final Resource Operation = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Operation"); + public static final Resource Property = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Property"); + public static final Resource Range = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Range"); + public static final Resource ReferenceElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ReferenceElement"); + public static final Resource RelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/RelationshipElement"); + public static final Resource Submodel = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Submodel"); + public static final Resource SubmodelElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElement"); + public static final Resource SubmodelElementCollection = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); + public static final Resource SubmodelElementList = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementList"); + public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI){ + 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; + } + throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); + } + public static 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; + } + + throw new IllegalArgumentException("Invalid ReferenceType provided."); + } + } + + public static class ReferenceTypes { + 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 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 Resource ExternalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); + public static final Resource ModelReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ModelReference"); + } + + public static class Types { + + public static final Resource AdministrativeInformation = + ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); + public static final Resource AnnotatedRelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "AnnotatedRelationshipElement"); + public static final Resource AssetAdministrationShell = + ResourceFactory.createResource(AAS_NAMESPACE + "AssetAdministrationShell"); + public static final Resource AssetInformation = + ResourceFactory.createResource(AAS_NAMESPACE + "AssetInformation"); + public static final Resource BasicEventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "BasicEventElement"); + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "Blob"); + public static final Resource Capability = + ResourceFactory.createResource(AAS_NAMESPACE + "Capability"); + public static final Resource ConceptDescription = + ResourceFactory.createResource(AAS_NAMESPACE + "ConceptDescription"); + public static final Resource DataSpecificationIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "DataSpecificationIec61360"); + public static final Resource EmbeddedDataSpecification = + ResourceFactory.createResource(AAS_NAMESPACE + "EmbeddedDataSpecification"); + public static final Resource Entity = + ResourceFactory.createResource(AAS_NAMESPACE + "Entity"); + public static final Resource Extension = + ResourceFactory.createResource(AAS_NAMESPACE + "Extension"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "File"); + + public static final Resource Key = + ResourceFactory.createResource(AAS_NAMESPACE + "Key"); + public static final Resource LangStringDefinitionTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringDefinitionTypeIec61360"); + public static final Resource LangStringNameType = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringNameType"); + public static final Resource LangStringPreferredNameTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringPreferredNameTypeIec61360"); + public static final Resource LangStringShortNameTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringShortNameTypeIec61360"); + public static final Resource LangStringTextType = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringTextType"); + public static final Resource LevelType = + ResourceFactory.createResource(AAS_NAMESPACE + "LevelType"); + public static final Resource MultiLanguageProperty = + ResourceFactory.createResource(AAS_NAMESPACE + "MultiLanguageProperty"); + public static final Resource Operation = + ResourceFactory.createResource(AAS_NAMESPACE + "Operation"); + public static final Resource OperationVariable = + ResourceFactory.createResource(AAS_NAMESPACE + "OperationVariable"); + public static final Resource Property = + ResourceFactory.createResource(AAS_NAMESPACE + "Property"); + public static final Resource Qualifier = + ResourceFactory.createResource(AAS_NAMESPACE + "Qualifier"); + public static final Resource Range = + ResourceFactory.createResource(AAS_NAMESPACE + "Range"); + public static final Resource Reference = + ResourceFactory.createResource(AAS_NAMESPACE + "Reference"); + public static final Resource ReferenceElement = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceElement"); + public static final Resource RelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "RelationshipElement"); + public static final Resource Resource = + ResourceFactory.createResource(AAS_NAMESPACE + "Resource"); + public static final Resource SpecificAssetId = + ResourceFactory.createResource(AAS_NAMESPACE + "SpecificAssetId"); + public static final Resource Submodel = + ResourceFactory.createResource(AAS_NAMESPACE + "Submodel"); + public static final Resource SubmodelElementCollection = + ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementCollection"); + public static final Resource SubmodelElementList = + ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementList"); + public static final Resource ValueList = + ResourceFactory.createResource(AAS_NAMESPACE + "ValueList"); + public static final Resource ValueReferencePair = + ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); + + } +} 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..57daf095d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java @@ -0,0 +1,31 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; + +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/FallbackSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java deleted file mode 100644 index 1522e476d..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; -import java.util.Map; - -public class FallbackSerializer extends StdSerializer> { - - - public FallbackSerializer() { - this(null); - } - - public FallbackSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(Map value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeString(value.toString()); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java deleted file mode 100644 index 816c77d39..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonIgnoreType; - -@JsonIgnoreType -public class IgnoreTypeMixIn { -} 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..1b7cb3c4e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java @@ -0,0 +1,7 @@ +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"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java deleted file mode 100644 index 0f403a1d7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.databind.module.SimpleModule; - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; - -import java.math.BigDecimal; -import java.net.URI; -import java.util.Map; - - -import javax.xml.datatype.XMLGregorianCalendar; - - -/** - * Jackson module which provides support for JSON-LD serialization - */ -public class JsonLDModule extends SimpleModule { - - - public JsonLDModule(Map idMap) { - super(); - - setSerializerModifier(new JsonLDSerializerModifier(idMap)); - - addSerializer(XMLGregorianCalendar.class, new XMLGregorianCalendarSerializer()); - addDeserializer(XMLGregorianCalendar.class, new XMLGregorianCalendarDeserializer()); - addSerializer(BigDecimal.class, new BigDecimalSerializer()); - - addSerializer(URI.class, new UriSerializer()); - addSerializer(AbstractLangString.class, new LangStringSerializer()); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java deleted file mode 100644 index 5c28c71c3..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.type.WritableTypeId; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; -import com.fasterxml.jackson.databind.ser.BeanSerializer; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.math.BigInteger; -import java.util.*; -import java.util.stream.Stream; - - -public class JsonLDSerializer extends BeanSerializer { - - private final Logger logger = LoggerFactory.getLogger(JsonLDSerializer.class); - - private static int currentRecursionDepth = 0; - - static final Map contextItems = new HashMap<>(); - - private final Map idMap; - - JsonLDSerializer(BeanSerializerBase src, Map idMap) { - super(src); - this.idMap = Objects.requireNonNullElseGet(idMap, HashMap::new); - } - - - - @Override - public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { - gen.setCurrentValue(bean); - - currentRecursionDepth++; - gen.writeStartObject(); - - if (currentRecursionDepth == 1) { - Map filteredContext = new HashMap<>(); - filterContextWrtBean(bean, filteredContext); - gen.writeObjectField("@context", filteredContext); - //gen.writeStringField("@context", "https://jira.iais.fraunhofer.de/stash/projects/ICTSL/repos/ids-infomodel-commons/raw/jsonld-context/3.0.0/context.jsonld"); // only add @context on top level - - } - - if(idMap.containsKey(bean)) - { - gen.writeStringField("@id", idMap.get(bean)); - } - else - { - String randomUri = "https://admin-shell.io/autogen/" + bean.getClass().getSimpleName() + "/" + UUID.randomUUID(); - idMap.put(bean, randomUri); - gen.writeStringField("@id", randomUri); - } - - WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_OBJECT); - String resolvedTypeId = typeIdDef.id != null ? typeIdDef.id.toString() : typeSer.getTypeIdResolver().idFromValue(bean); - if (resolvedTypeId != null) { - gen.writeStringField(typeIdDef.asProperty, resolvedTypeId); - } - if (_propertyFilterId != null) { - serializeFieldsFiltered(bean, gen, provider); - } else { - serializeFields(bean, gen, provider); - } - gen.writeEndObject(); - currentRecursionDepth--; - } - - - private void filterContextWrtBean(Object bean, Map filteredContext) { - //Some default entries for AAS - filteredContext.put("aas", "https://admin-shell.io/aas/3/0/"); - //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); - //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); - - if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion - - //Check if RdfResource or TypedLiteral is used. They contain a field called "type" which can reference to any namespace - //Therefore it is vital to also check the value of the type field for prefixes that need to be included in the context - if(bean.getClass().getSimpleName().equals("LangString")) - { - //LangString is of type rdf:langString, so this must be present - filteredContext.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - } - contextItems.forEach((p, u) -> { - JsonTypeName typeNameAnnotation = bean.getClass().getAnnotation(JsonTypeName.class); - if(typeNameAnnotation != null && typeNameAnnotation.value().contains(p)) { - filteredContext.put(p, u); - } - Stream.of(bean.getClass().getMethods()).forEach(m -> { - JsonProperty propertyAnnotation = m.getAnnotation(JsonProperty.class); - if(propertyAnnotation != null && propertyAnnotation.value().contains(p)) { - filteredContext.put(p, u); - } - }); - }); - Stream.of(bean.getClass().getMethods()).forEach(m -> { - // run though all properties and check annotations. These annotations should contain the prefixes - JsonProperty prop = m.getAnnotation(JsonProperty.class); - if(prop != null) - { - for(Map.Entry entry : contextItems.entrySet()) - { - if(prop.value().startsWith(entry.getKey())) - { - filteredContext.put(entry.getKey(), entry.getValue()); - break; - } - } - } - }); - // run through fields recursively - for(Field f : getAllFields(new HashSet<>(), bean.getClass())) { - - if(Collection.class.isAssignableFrom(f.getType())) - { - try { - if(f.getType().getName().startsWith("java.") && !f.getType().getName().startsWith("java.util")) continue; - boolean accessible = f.isAccessible(); - f.setAccessible(true); - Collection c = (Collection) f.get(bean); - if(c == null) { - continue; - } - for(Object o : c) - { - filterContextWrtBean(o, filteredContext); - } - f.setAccessible(accessible); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - if (f.getType().isPrimitive() || f.getType().isEnum() || f.getType().isArray() - || f.getType().getName().contains("java.") - || f.getType().getName().contains("javax.")) continue; - - try { - boolean wasAccessible = f.isAccessible(); - f.setAccessible(true); - filterContextWrtBean(f.get(bean), filteredContext); - f.setAccessible(wasAccessible); - } catch (IllegalAccessException ignored) { - //logger.error("setting accessible failed"); //We can catch that here, as IllegalReflectiveAccess cannot occur on our own packages - } - - //f.trySetAccessible(wasAccessible); - - } - - } - - /** - * This function retrieves a set of all available fields of a class, including inherited fields - * @param fields Set to which discovered fields will be added. An empty HashSet should do the trick - * @param type The class for which fields should be discovered - * @return set of all available fields - */ - private static Set getAllFields(Set fields, Class type) { - fields.addAll(Arrays.asList(type.getDeclaredFields())); - - if (type.getSuperclass() != null) { - getAllFields(fields, type.getSuperclass()); - } - - return fields; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java deleted file mode 100644 index d1bff7f5c..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf; - - -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; - -import java.util.Map; - - -public class JsonLDSerializerModifier extends BeanSerializerModifier { - - private final Map idMap; - - public JsonLDSerializerModifier(Map idMap) { - this.idMap = idMap; - } - - @Override - public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer serializer) { - if (serializer instanceof BeanSerializerBase) { - return new JsonLDSerializer((BeanSerializerBase) serializer, idMap); - } else { - return serializer; - } - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java deleted file mode 100644 index 8d544ab14..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.io.IOException; - -public class JsonLdEnumSerializer extends JsonSerializer> { - - - @Override - public void serialize(Enum value, JsonGenerator gen, SerializerProvider provider) throws IOException { - //Generated Enum classes of the admin shell have @IRI annotations, which need to be used to provide proper RDF - if(value.getClass().isEnum() && value.getClass().getName().startsWith("org.eclipse.digitaltwin.aas4j.")) - { - //Try to get annotation value to get the IRI used in the ontology - if(value.getClass().getAnnotation(IRI.class) != null && value.getClass().getAnnotation(IRI.class).value().length > 0) - { - gen.writeStartObject(); - gen.writeStringField("@type", value.getClass().getAnnotation(IRI.class).value()[0]); - - //Try to extract exact IRI of the enum value, if present - try { - var annotation = value.getClass().getField(value.name()).getAnnotation(IRI.class); - if(annotation != null && annotation.value().length > 0) - { - gen.writeStringField("@id", annotation.value()[0]); - } - else - { - //Didn't find an @IRI annotation - fall back to using class annotation + field name - gen.writeStringField("@id", translate(value.getClass(), value.name())); - } - } - //Should be impossible - catch (NoSuchFieldException e) - { - //Didn't find an @IRI annotation - fall back to using class annotation + field name - gen.writeStringField("@id", translate(value.getClass(), value.name())); - } - gen.writeEndObject(); - } - else - { - gen.writeString(translate(value.getClass(), value.name())); - } - - - } else { - provider.findValueSerializer(Enum.class).serialize(value, gen, provider); - } - } - - - - public static String translate(Class enumClass, String input) { - String[] iriValues = enumClass.getAnnotation(IRI.class).value(); - String result = ""; - if(iriValues.length > 0) - { - result = iriValues[0]; - if(!result.endsWith("/")) - { - result += "/"; - } - } - result += input; - return result; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java deleted file mode 100644 index cdd3409db..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf; - -import java.io.IOException; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; - -public class LangStringSerializer extends StdSerializer { - - - public LangStringSerializer() { - this(null); - } - - public LangStringSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(AbstractLangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeStartObject(); - if(value.getLanguage() != null && !value.getLanguage().isEmpty()) - { - gen.writeStringField("@language", value.getLanguage()); - } - else - { - gen.writeStringField("@type", "rdf:langString"); - } - gen.writeStringField("@value", value.getText()); - gen.writeEndObject(); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java deleted file mode 100644 index a9d0d7540..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java +++ /dev/null @@ -1,1129 +0,0 @@ -/* - * 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.rdf; - -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; -import org.apache.jena.datatypes.DatatypeFormatException; -import org.apache.jena.query.*; -import org.apache.jena.rdf.model.*; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.RiotException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.lang.reflect.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.ZonedDateTime; -import java.time.format.DateTimeParseException; -import java.util.*; -import java.util.stream.Collectors; - - -/** - * Internal class to handle the parsing of JSON-LD into java objects - * - * @author maboeckmann - */ -class ParserHelper { - - private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); - static Map knownNamespaces = new HashMap<>(); - private final Logger logger = LoggerFactory.getLogger(ParserHelper.class); - /** - * This list contains all primitive Java types - */ - private final Map> builtInMap = new HashMap<>(); - - { - builtInMap.put("int", Integer.TYPE); - builtInMap.put("long", Long.TYPE); - builtInMap.put("double", Double.TYPE); - builtInMap.put("float", Float.TYPE); - builtInMap.put("bool", Boolean.TYPE); - builtInMap.put("char", Character.TYPE); - builtInMap.put("byte", Byte.TYPE); - builtInMap.put("void", Void.TYPE); - builtInMap.put("short", Short.TYPE); - } - - /** - * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle - * - * @param inputModel Model on which queries are to be evaluated from which information can be retrieved - * @param objectUri URI of the object to be handled - * @param targetClass Variable containing the class which should be returned - * @param Class which should be returned - * @return Object of desired class, filled with the values extracted from inputModel - * @throws IOException thrown if the parsing fails - */ - private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { - - try { - - //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on - //Check whether we are dealing with an instantiable class (i.e. no interface and no abstract class) - boolean currentObjectIsBlankNode = false; - if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { - //We don't know the desired class yet (current targetClass is not instantiable). This is only known for the root object - ArrayList> implementingClasses = getImplementingClasses(targetClass); - String queryString; - //Get a list of all "rdf:type" statements in our model - //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax - try { - new URL(objectUri); - } catch (MalformedURLException e) { - currentObjectIsBlankNode = true; - } - if (currentObjectIsBlankNode) { - //Object is a blank node, so the subject URI cannot be used - queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; - } else { - //Not a blank node, so we can work with the subject URI - queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; - } - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); - ResultSet resultSet = queryExecution.execSelect(); - - if (!resultSet.hasNext()) { - queryExecution.close(); - throw new IOException("Could not extract class of child object. ID: " + objectUri); - } - - //Class candidateClass = null; - - String fullName = "No triple present indicating type."; - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - fullName = solution.get("type").toString(); - - //Expected URI is something like https://w3id.org/idsa/core/ClassName (and we want ClassName) - String className = fullName.substring(fullName.lastIndexOf('/') + 1); - - //Some namespaces use "#" instead of "/" - if (className.contains("#")) { - className = className.substring(className.lastIndexOf("#") + 1); - } - -// for (Class currentClass : implementingClasses) { -// //Is this class instantiable? -// if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { -// //candidateClass = currentClass; -// if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(this.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { -// targetClass = (Class) currentClass; -// break; -// } -// } -// } - } - queryExecution.close(); - //Did we find "the" class, i.e. instantiable and name matches? - if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { - //No, the current targetClass cannot be instantiated. Do we have a candidate class? - //if (candidateClass != null) { - throw new IOException("Did not find an instantiable class for " + objectUri + " matching expected class name (" + targetClass.getSimpleName() + "). Object has type: " + fullName); - //targetClass = (Class) candidateClass; - //} - } - } - - //Enums have no constructors - if (targetClass.isEnum()) { - return handleEnum(targetClass, objectUri); - } - - //Get constructor (which is package private for our classes) and make it accessible - Constructor constructor = targetClass.getDeclaredConstructor(); - constructor.setAccessible(true); - - //Instantiate new object, which will be returned at the end - T returnObject = constructor.newInstance(); - - //Get methods - Method[] methods = returnObject.getClass().getDeclaredMethods(); - - //Store methods in map. Key is the name of the RDF property without ids prefix - Map methodMap = new HashMap<>(); - - //Get all relevant methods (setters, but not for label, comment or external properties) - Arrays.stream(methods).filter(method -> { - String name = method.getName(); - //Filter out irrelevant methods - return name.startsWith("set") && !name.equals("setProperty") && !name.equals("setComment") && !name.equals("setLabel"); // && !name.equals("setId"); - }).forEach(method -> { - //Remove "set" part - String reducedName = method.getName().substring(3); - - //Turn first character to lower case - char[] c = reducedName.toCharArray(); - c[0] = Character.toLowerCase(c[0]); - String finalName = new String(c); - methodMap.put(finalName, method); - - }); - - //There is no "setId" method in our CodeGen generated classes, so we get the field - /* TODO: No "id" field yet - Field idField = returnObject.getClass().getDeclaredField("id"); - - //Store whether or not it was accessible, so that we can undo making it accessible - boolean wasAccessible = idField.isAccessible(); - idField.setAccessible(true); - - //Set the ID of the object to be identical with the objectUri parameter - idField.set(returnObject, new URI(objectUri)); - idField.setAccessible(wasAccessible); - */ - - //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal - if (methodMap.isEmpty()) { - return returnObject; - } - - - //A list which stores all those parameter names which may occur only once (i.e. those occurring in the GROUP BY clause) - List groupByKeys = new ArrayList<>(); - - StringBuilder queryStringBuilder = new StringBuilder(); - - for (Map.Entry entry : knownNamespaces.entrySet()) { - queryStringBuilder.append("PREFIX ").append(entry.getKey()); - if (!entry.getKey().endsWith(":")) { - queryStringBuilder.append(":"); - } - queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); - } - queryStringBuilder.append("SELECT"); - methodMap.forEach((key1, value) -> { - //Is the return type some sort of List? - if (Collection.class.isAssignableFrom(value.getParameterTypes()[0])) { - boolean isTypedLiteral = false; - //Yes, it is assignable multiple times. Concatenate multiple values together using some delimiter - try { - //ArrayLists are generics. We need to extract the name of the generic parameter as string and interpret that - String typeName = extractTypeNameFromCollection(value.getGenericParameterTypes()[0]); - - if (typeName.endsWith("LangString")) - isTypedLiteral = true; - } catch (IOException e) { - e.printStackTrace(); - } - if (isTypedLiteral) { - queryStringBuilder.append(" (GROUP_CONCAT(CONCAT('\"',?").append(key1).append(",'\"@', lang(?").append(key1).append("));separator=\"||\") AS ?").append(key1).append("sLang) "); - } - queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append(";separator=\"||\") AS ?").append(key1).append("s) "); - - //Additional case for blank nodes - queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append("Blank;separator=\"||\") AS ?").append(key1).append("sBlank) "); - - - } else { - //No, it's not a list. No need to aggregate - queryStringBuilder.append(" ?").append(key1); - //We will have to GROUP BY this variable though... - groupByKeys.add(key1); - } - }); - //Start the "WHERE" part - Fuseki does not expect the "WHERE" keyword, but just an "{" - queryStringBuilder.append(" { "); - - //In case of blank nodes, we can't work with the subject URI - if (currentObjectIsBlankNode) { - queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); - } else { - queryStringBuilder.append(" <").append(objectUri).append(">"); - } - - //Make sure that the object is of the correct type - //This is particularly relevant in case of all fields being optional -- then one could simply parse a random object - queryStringBuilder.append(" a ").append(wrapIfUri(targetClass.getAnnotation(IRI.class).value()[0])).append(". "); - - for (Map.Entry entry : methodMap.entrySet()) { - //Is this a field which is annotated by NOT NULL? - //Attempt to find a field matching the setter method name - //E.g. for "setSomething", we search for a field with name "_something" (IDS way) and "something" - Field field = getFieldByName(targetClass, entry.getKey()); - - - //In AAS, every field is optional, as there are no validation annotations in the model - queryStringBuilder.append(" OPTIONAL {"); - - if (currentObjectIsBlankNode) { - queryStringBuilder.append(" ?s "); - } else { - queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function - } - //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) - //Find the annotation value containing a colon and interpret this as "prefix:predicate" - boolean foundAnnotation = false; - if (field.getAnnotation(IRI.class) != null) { - Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); - currentAnnotation.ifPresent(queryStringBuilder::append); - foundAnnotation = true; - } - if (!foundAnnotation) { - logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); - queryStringBuilder.append("aas:").append(entry.getKey()); - } - //if(isBlank(?entry.getKey(), use value of artificial, use original value) - queryStringBuilder.append(" ?").append(entry.getKey()).append(" ."); //object - - //In case of the object being a blank node, we construct a second result variable with the blank node id - queryStringBuilder.append("OPTIONAL { ?").append(entry.getKey()).append(" <").append(blankNodeIdPropertyUri).append("> ?").append(entry.getKey()).append("Blank . } "); - - queryStringBuilder.append("} "); - } - - - queryStringBuilder.append(" } "); - - //Do we need to group? We do, if there is at least one property which can occur multiple times - //We added all those properties, which may only occur once, to the groupByKeys list - if (!groupByKeys.isEmpty()) { - queryStringBuilder.append("GROUP BY"); - for (String key : groupByKeys) { - queryStringBuilder.append(" ?").append(key); - } - } - - String queryString = queryStringBuilder.toString(); - - StringBuilder queryForOtherProperties = new StringBuilder(); - //Query for all unknown properties and their values - //Select properties and values only - - if (!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step - - //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } - for (Map.Entry entry : knownNamespaces.entrySet()) { - queryForOtherProperties.append("PREFIX ").append(entry.getKey()); - if (!entry.getKey().endsWith(":")) { - queryForOtherProperties.append(":"); - } - queryForOtherProperties.append(" <").append(entry.getValue()).append(">\n"); - } - - - //Respect ALL properties and values - queryForOtherProperties.append(" SELECT ?p ?o { <").append(objectUri).append("> ?p ?o .\n"); - - //Exclude known properties - queryForOtherProperties.append("FILTER (?p NOT IN (rdf:type"); - - //Predicates usually look like: .append("ids:").append(entry.getKey()) - for (Map.Entry entry : methodMap.entrySet()) { - queryForOtherProperties.append(", "); - - Field field = getFieldByName(targetClass, entry.getKey()); - Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).filter(annotation -> annotation.contains(":")).filter(s -> s.length() > 1).findFirst(); - if (currentAnnotation.isPresent()) { - queryForOtherProperties.append(wrapIfUri(currentAnnotation.get())); - } else { - logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); - queryForOtherProperties.append("aas:").append(entry.getKey()); - } - } - - queryForOtherProperties.append(")). } "); - - - //Now that we searched for all "known properties", let's search for all unrecognized content and append it to a generic properties map - - Query externalPropertiesQuery = QueryFactory.create(queryForOtherProperties.toString()); - QueryExecution externalPropertiesQueryExecution = QueryExecutionFactory.create(externalPropertiesQuery, inputModel); - ResultSet externalPropertiesResultSet = externalPropertiesQueryExecution.execSelect(); - - // now as all declared instances and classes are treated, which are also represented in the respective java - // dependency, take care about the ones within foreign namespaces and add those to the 'properties' field - // note that not all models (e.g. AAS) have such methods. In case they do not exist, skip adding external properties - - try { - Method setProperty = returnObject.getClass().getDeclaredMethod("setProperty", String.class, Object.class); - Method getProperties = returnObject.getClass().getDeclaredMethod("getProperties"); - - while (externalPropertiesResultSet.hasNext()) { - QuerySolution externalPropertySolution = externalPropertiesResultSet.next(); - - HashMap currentProperties = (HashMap) getProperties.invoke(returnObject); - - //Avoid NullPointerException - if (currentProperties == null) { - currentProperties = new HashMap<>(); - } - - String propertyUri = externalPropertySolution.get("p").toString(); - - //Does this key already exist? If yes, we need to store the value as array to not override them - if (currentProperties.containsKey(propertyUri)) { - //If it is not an array list yet, turn it into one - if (!(currentProperties.get(propertyUri) instanceof ArrayList)) { - ArrayList newList = new ArrayList<>(); - newList.add(currentProperties.get(propertyUri)); - currentProperties.put(propertyUri, newList); - } - } - - //Literals and complex objects need to be handled differently - //Literals can be treated as flat values, whereas complex objects require recursive calls - if (externalPropertySolution.get("o").isLiteral()) { - Object o = handleForeignLiteral(externalPropertySolution.getLiteral("o")); - //If it is already an ArrayList, add new value to it - if (currentProperties.containsKey(propertyUri)) { - ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); - currentPropertyArray.add(o); - setProperty.invoke(returnObject, propertyUri, currentPropertyArray); - } - //Otherwise save as new plain value - else { - setProperty.invoke(returnObject, propertyUri, o); - } - } else { - //It is a complex object. Distinguish whether or not we need to store as array - HashMap subMap = handleForeignNode(externalPropertySolution.getResource("o"), new HashMap<>(), inputModel); - subMap.put("@id", externalPropertySolution.getResource("o").getURI()); - if (currentProperties.containsKey(propertyUri)) { - ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); - currentPropertyArray.add(subMap); - setProperty.invoke(returnObject, propertyUri, currentPropertyArray); - } else { - setProperty.invoke(returnObject, propertyUri, subMap); - } - } - } - externalPropertiesQueryExecution.close(); - } catch (NoSuchMethodException ignored) { - //Method does not exist, skip - } - } - - - Query query; - try { - query = QueryFactory.create(queryString); - } catch (QueryParseException e) { - logger.error(queryString); - throw e; - } - - //Evaluate query - QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); - ResultSet resultSet = queryExecution.execSelect(); - - - if (!resultSet.hasNext()) { - queryExecution.close(); - //no content... - return returnObject; - } - - //SPARQL binding present, iterate over result and construct return object - while (resultSet.hasNext()) { - QuerySolution querySolution = resultSet.next(); - - //Check if there are fields which have more values than allowed - if (resultSet.hasNext()) { - String value1 = "", value2 = "", parameterName = ""; - QuerySolution querySolution2 = resultSet.next(); - Iterator varNamesIt = querySolution2.varNames(); - while (varNamesIt.hasNext()) { - String varName = varNamesIt.next(); - if (querySolution.contains(varName)) { - if (!querySolution.get(varName).equals(querySolution2.get(varName))) { - parameterName = varName; - value1 = querySolution.get(varName).toString(); - value2 = querySolution2.get(varName).toString(); - break; - } - } - } - if (!value1.isEmpty()) { - throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); - } - throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); - } - - //No value occurs more often than allowed - for (Map.Entry entry : methodMap.entrySet()) { - - //What is this method setting? Get the expected parameter type and check whether it is some complex sub-object and whether this is a list - Class currentType = entry.getValue().getParameterTypes()[0]; - - String sparqlParameterName = entry.getKey(); - - if (Collection.class.isAssignableFrom(currentType)) { - sparqlParameterName += "s"; //plural form for the concatenated values - } - if (!querySolution.contains(sparqlParameterName)) { - sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead - //TODO: Note: This would not yield full results yet in case some of the values are encapsulated - // in blank nodes and some are not, for the same property - } - if (querySolution.contains(sparqlParameterName)) { - String currentSparqlBinding = querySolution.get(sparqlParameterName).toString(); - - boolean objectIsBlankNode = querySolution.get(sparqlParameterName).isResource() && querySolution.get(sparqlParameterName).asNode().isBlank(); - String blankNodeId = ""; - //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject - //For that case, we add some artificial identifiers here - if (objectIsBlankNode) { - blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); - } - if (currentType.isEnum()) { - //Two possibilities: - //1: The URI of the enum value is given directly e.g. ?s ?p - //2: The URI of the enum value is encapsulated in a blank node, e.g. - // ?s ?p [ a demo:myEnum, demo:enumValue ] - if (objectIsBlankNode) { - - Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); - QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); - ResultSet innerEnumQueryExecutionResultSet = innerEnumQueryExecution.execSelect(); - - //Only throw this if there is no successful execution - IOException anyIOException = null; - boolean oneSuccessfulEnumFound = false; - while (innerEnumQueryExecutionResultSet.hasNext()) { - try { - entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); - oneSuccessfulEnumFound = true; - break; //Stop after the first successful execution - } catch ( - IOException e) //There might be errors, if multiple types are present, see example above - { - anyIOException = e; - } - } - //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception - if (anyIOException != null && !oneSuccessfulEnumFound) - throw new IOException("Could not parse Enum. ", anyIOException); - innerEnumQueryExecution.close(); - } else { - entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); - } - continue; - } - - - //There is a binding. If it is a complex sub-object, we need to recursively call this function - if (Collection.class.isAssignableFrom(currentType)) { - //We are working with ArrayLists. - //Here, we need to work with the GenericParameterTypes instead to find out what kind of ArrayList we are dealing with - String typeName = extractTypeNameFromCollection(entry.getValue().getGenericParameterTypes()[0]); - if (isArrayListTypePrimitive(entry.getValue().getGenericParameterTypes()[0])) { - if (typeName.endsWith("LangString")) { - try { - currentSparqlBinding = querySolution.get(sparqlParameterName + "Lang").toString(); - } catch (NullPointerException e) { - //logger.warn("Failed to retrieve localized/typed values of " + currentSparqlBinding + ". Make sure that namespaces used in this property are known and valid. Proceeding without localized values and interpreting as string."); - //logger.warn("Query was: " + queryString); - //logger.warn("Attempted to fetch: " + sparqlParameterName + "Lang"); - } - } - ArrayList list = new ArrayList<>(); - //Two pipes were used as delimiter above - //Introduce set to deduplicate - Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); - for (String s : allElements) { - Literal literal; - //querySolution.get(sparqlParameterName). - if (s.endsWith("@")) { - s = s.substring(2, s.length() - 3); - literal = ResourceFactory.createStringLiteral(s); - } else if (s.startsWith("\\")) { - //turn something like \"my Desc 1\"@en to "my Desc 1"@en - s = s.substring(1).replace("\\\"@", "\"@"); - literal = ResourceFactory.createLangLiteral(s.substring(1, s.lastIndexOf("@") - 1), s.substring(s.lastIndexOf("@") + 1)); - } else { - literal = ResourceFactory.createPlainLiteral(s); - } - - //Is the type of the ArrayList some built in Java primitive? - - if (builtInMap.containsKey(typeName)) { - //Yes, it is. We MUST NOT call Class.forName(name)! - list.add(handlePrimitive(builtInMap.get(typeName), literal, null)); - } else { - //Not a Java primitive, we may call Class.forName(name) - list.add(handlePrimitive(Class.forName(typeName), literal, s)); - } - } - entry.getValue().invoke(returnObject, list); - } else { - //List of complex sub-objects, such as a list of Resources in a ResourceCatalog - ArrayList list = new ArrayList<>(); - Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); - for (String s : allElements) { - if (Class.forName(typeName).isEnum()) { - list.add(handleEnum(Class.forName(typeName), s)); - } else { - list.add(handleObject(inputModel, s, Class.forName(typeName))); - } - } - entry.getValue().invoke(returnObject, list); - } - } - - //Not an ArrayList of objects expected, but rather one object - else { - //Our implementation of checking for primitives (i.e. also includes URLs, Strings, XMLGregorianCalendars, ...) - if (isPrimitive(currentType)) { - - Literal literal = null; - try { - literal = querySolution.getLiteral(sparqlParameterName); - } catch (Exception ignored) { - } - - entry.getValue().invoke(returnObject, handlePrimitive(currentType, literal, currentSparqlBinding)); - - } else { - //Not a primitive object, but a complex sub-object. Recursively call this function to handle it - if (objectIsBlankNode) { - entry.getValue().invoke(returnObject, handleObject(inputModel, blankNodeId, entry.getValue().getParameterTypes()[0])); - } else { - - entry.getValue().invoke(returnObject, handleObject(inputModel, currentSparqlBinding, entry.getValue().getParameterTypes()[0])); - } - } - } - } - - } - } - queryExecution.close(); - - return returnObject; - } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | - InvocationTargetException | NoSuchFieldException | URISyntaxException | - DatatypeConfigurationException | ClassNotFoundException e) { - throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); - } - } - - /** - * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" - * - * @param input Input URI, possibly a prefixed value - * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" - */ - private String wrapIfUri(String input) { - if (input.startsWith("http://") || input.startsWith("https://")) { - return "<" + input + ">"; - } else { - return input; - } - } - - private Object handleForeignLiteral(Literal literal) throws URISyntaxException { -// // TODO: LangTag is not native -// START -// if(literal.getLanguage() != null && !literal.getLanguage().equals("")) -// { -// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); -// } -// -// else -// { -// return literal.getString(); -// } -// END - //If not, does it have some datatype URI? - //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) - //{ - // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); - //} - //If both is not true, add it as normal string - return literal.getString(); - } - - private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { - //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map - //Literals must be handled "one recursion step above" - if (node.isLiteral()) { - throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); - } - - //Run SPARQL query retrieving all information (only one hop!) about this node - String queryString = "SELECT ?s ?p ?o { BIND(<" + node.asNode().getURI() + "> AS ?s) . ?s ?p ?o . } "; - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, model); - ResultSet resultSet = queryExecution.execSelect(); - - - //Handle outgoing properties of this foreign node - while (resultSet.hasNext()) { - QuerySolution querySolution = resultSet.next(); - - String propertyUri = querySolution.get("p").toString(); - - if (map.containsKey(propertyUri)) { - //If it is not an array list yet, turn it into one - if (!(map.get(propertyUri) instanceof ArrayList)) { - ArrayList newList = new ArrayList<>(); - newList.add(map.get(propertyUri)); - map.put(propertyUri, newList); - } - } - - //Check the type of object we have. If it is a literal, just add it as "flat value" to the map - if (querySolution.get("o").isLiteral()) { - //Handle some small literal. This function will turn this into a TypedLiteral if appropriate - Object o = handleForeignLiteral(querySolution.getLiteral("o")); - if (map.containsKey(propertyUri)) { - map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(o)); - } else { - map.put(querySolution.get("p").toString(), o); - } - } - - //If it is not a literal, we need to call this function recursively. Create new map for sub object - else { - //logger.info("Calling handleForeignNode for " + querySolution.getResource("o").toString()); - if (querySolution.getResource("s").toString().equals(querySolution.getResource("o").toString())) { - logger.warn("Found self-reference on " + querySolution.getResource("s").toString() + " via predicate " + querySolution.getResource("p").toString() + " ."); - continue; - } - HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); - subMap.put("@id", querySolution.getResource("o").getURI()); - if (map.containsKey(propertyUri)) { - map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(subMap)); - } else { - map.put(querySolution.get("p").toString(), subMap); - } - } - } - queryExecution.close(); - return map; - } - - /** - * Utility function, used to obtain the field corresponding to a setter function - * - * @param targetClass Class object in which we search for a field - * @param fieldName Guessed name of the field to search for - * @return Field object matching the name (possibly with leading underscore) - * @throws NoSuchFieldException thrown, if no such field exists - */ - private Field getFieldByName(Class targetClass, String fieldName) throws NoSuchFieldException { - try { - return targetClass.getDeclaredField("_" + fieldName); - } catch (NoSuchFieldException e) { - try { - return targetClass.getDeclaredField(fieldName); - } catch (NoSuchFieldException e2) { - try { - return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); - } catch (NoSuchFieldException e3) { - throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); - } - } - } - } - - /** - * Internal function to create a single enum object from a given desired class and a URL - * - * @param enumClass The enum class - * @param url The URL of the enum value - * @param Enum class - * @return Value of enumClass matching the input URL - * @throws IOException thrown if no matching enum value could be found - */ - private T handleEnum(Class enumClass, String url) throws IOException { - if (!enumClass.isEnum()) { - throw new RuntimeException("Non-Enum class passed to handleEnum function."); - } - T[] constants = enumClass.getEnumConstants(); - if (url.contains("/")) { - url = url.substring(url.lastIndexOf("/") + 1); - } - for (T constant : constants) { - //We artificially added some underscores in the AAS ontology. TODO: This might be a bit dangerous for other ontologies, which really contain underscores in enum names - if (url.equalsIgnoreCase(constant.toString()) || url.equalsIgnoreCase(constant.toString().replace("_", ""))) { - return constant; - } - } - throw new IOException("Failed to find matching enum value for " + url + " . Available enums are: " + Arrays.stream(constants).map(Object::toString).collect(Collectors.joining(", "))); - } - - /** - * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) - * - * @param currentType Input Class (or primitive) - * @param literal Value as literal (can be null in some cases) - * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) - * @return Object of type currentType - * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI - * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails - * @throws IOException thrown, if no matching "simple class" could be found - */ - private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { - //Java way of checking for primitives, i.e. int, char, float, double, ... - if (currentType.isPrimitive()) { - if (literal == null) { - throw new IOException("Trying to handle Java primitive, but got no literal value"); - } - //If it is an actual primitive, there is no need to instantiate anything. Just give it to the function - switch (currentType.getSimpleName()) { - case "int": - return literal.getInt(); - case "boolean": - return literal.getBoolean(); - case "long": - return literal.getLong(); - case "short": - return literal.getShort(); - case "float": - return literal.getFloat(); - case "double": - return literal.getDouble(); - case "byte": - return literal.getByte(); - } - } - - //Check for the more complex literals - - //URI - if (URI.class.isAssignableFrom(currentType)) { - return new URI(currentSparqlBinding); - } - - //String - if (String.class.isAssignableFrom(currentType)) { - return currentSparqlBinding; - } - - //XMLGregorianCalendar - if (XMLGregorianCalendar.class.isAssignableFrom(currentType)) { - //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown - try { - return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); - } catch (DatatypeFormatException | DateTimeParseException ignored) { - //Not a valid dateTimeStamp. Try parsing just to Date - try { - Date date = new SimpleDateFormat().parse(literal.getValue().toString()); - GregorianCalendar calendar = new GregorianCalendar(); - calendar.setTime(date); - return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); - } catch (ParseException | DateTimeParseException | DatatypeFormatException e2) { - //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException - throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); - } - } - } - -// // TODO: Abstract lan is no longer native type -// START -// //TypedLiteral -// if (LangString.class.isAssignableFrom(currentType)) { -// //Either a language tagged string OR literal with type. Only one allowed -// if (!literal.getLanguage().equals("")) { -// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); -// } -// return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag -// } -// END - - //BigInteger - if (BigInteger.class.isAssignableFrom(currentType)) { - return new BigInteger(literal.getString()); - } - - //BigDecimal - if (BigDecimal.class.isAssignableFrom(currentType)) { - return new BigDecimal(literal.getString()); - } - - //byte[] - if (byte[].class.isAssignableFrom(currentType)) { - return currentSparqlBinding.getBytes(); - } - - //Duration - if (Duration.class.isAssignableFrom(currentType)) { - return DatatypeFactory.newInstance().newDuration(currentSparqlBinding); - } - - throw new IOException("Unrecognized primitive type: " + currentType.getName()); - } - - private boolean isArrayListTypePrimitive(Type t) throws IOException { - String typeName = extractTypeNameFromCollection(t); - - try { - //Do not try to call Class.forName(primitive) -- that would throw an exception - if (builtInMap.containsKey(typeName)) return true; - return isPrimitive(Class.forName(typeName)); - } catch (ClassNotFoundException e) { - throw new IOException("Unable to retrieve class from generic", e); - } - } - - private String extractTypeNameFromCollection(Type t) throws IOException { - String typeName = t.getTypeName(); - if (!typeName.startsWith("java.util.ArrayList<") && !typeName.startsWith("java.util.List<") && !typeName.startsWith("java.util.Collection<")) { - throw new IOException("Illegal argument encountered while interpreting type parameter"); - } - //"" or super instead of extends - if (typeName.contains("?")) { - //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces - return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); - } - //No extends - else { - return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); - } - } - - private boolean isPrimitive(Class input) throws IOException { - //Collections are not simple - if (Collection.class.isAssignableFrom(input)) { - throw new IOException("Encountered collection in isPrimitive. Use isArrayListTypePrimitive instead"); - } - - //check for: plain/typed literal, XMLGregorianCalendar, byte[], RdfResource - //covers int, long, short, float, double, boolean, byte - if (input.isPrimitive()) return true; - - return (URI.class.isAssignableFrom(input) || - String.class.isAssignableFrom(input) || - XMLGregorianCalendar.class.isAssignableFrom(input) || - AbstractLangString.class.isAssignableFrom(input) || - BigInteger.class.isAssignableFrom(input) || - BigDecimal.class.isAssignableFrom(input) || - byte[].class.isAssignableFrom(input) || - Duration.class.isAssignableFrom(input)); - } - - /** - * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) - * - * @param rdfModel RDF input to be parsed - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(Model rdfModel, Class targetClass) throws IOException { - addArtificialBlankNodeLabels(rdfModel); - ArrayList> implementingClasses = getImplementingClasses(targetClass); - - // Query to retrieve all instances in the input graph that have a class assignment - // Assumption: if the class name (?type) is equal to the target class, this should be the - // instance we actually want to parse - String queryString = "SELECT ?id ?type { ?id a ?type . }"; - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, rdfModel); - ResultSet resultSet = queryExecution.execSelect(); - - if (!resultSet.hasNext()) { - throw new IOException("Could not extract class from input message"); - } - - Map> returnCandidates = new HashMap<>(); - - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - String fullName = solution.get("type").toString(); - String className = fullName.substring(fullName.lastIndexOf('/') + 1); - - //In case of hash-namespaces - if (className.contains("#")) { - className = className.substring(className.lastIndexOf("#")); - } - - //For legacy purposes... - if (className.startsWith("ids:") || className.startsWith("aas:")) { - className = className.substring(4); - } - -// for (Class currentClass : implementingClasses) { -// if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { -// returnCandidates.put(solution.get("id").toString(), currentClass); -// } -// } - //if (returnCandidates.size() > 0) break; - } - queryExecution.close(); - - if (returnCandidates.size() == 0) { - throw new IOException("Could not transform input to an appropriate implementing class for " + targetClass.getName()); - } - - //At this point, we parsed the model and know to which implementing class we want to parse - //Check if there are several options available - if (returnCandidates.size() > 1) { - String bestCandidateId = null; - Class bestCandidateClass = null; - long bestNumRelations = -1L; - for (Map.Entry> entry : returnCandidates.entrySet()) { - String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + - " WHERE {" + - " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + - " OPTIONAL {?o ?p2 ?o2 . OPTIONAL {?o2 ?p3 ?o3 . OPTIONAL {?o3 ?p4 ?o4 . OPTIONAL {?o4 ?p5 ?o5 . } } } } }"; - Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); - QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); - long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); - if (graphSize > bestNumRelations) { - bestNumRelations = graphSize; - bestCandidateId = entry.getKey(); - bestCandidateClass = entry.getValue(); - } - - determineBestCandidateQueryExecution.close(); - - } - logger.debug("The RDF graph contains multiple objects which can be parsed to " + targetClass.getSimpleName() + ". Determined " + bestCandidateId + " as best candidate."); - return (T) handleObject(rdfModel, bestCandidateId, bestCandidateClass); - } - - //We only reach this spot, if there is exactly one return candidate. Let's return it - Map.Entry> singularEntry = returnCandidates.entrySet().iterator().next(); - return (T) handleObject(rdfModel, singularEntry.getKey(), singularEntry.getValue()); - - } - - - /** - * Entry point to this class. Takes a message and a desired target class (can be an interface) - * - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(String message, Class targetClass) throws IOException { - Model model = readMessage(message); - return parseMessage(model, targetClass); - } - - /** - * Entry point to this class. Takes a message and a desired target class (can be an interface) - * - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param serializationFormat Input RDF format - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(String message, Class targetClass, Lang serializationFormat) throws IOException { - Model model = readMessage(message, serializationFormat); - return parseMessage(model, targetClass); - } - - /** - * Reads a message into an Apache Jena model, guessing the input language. - * Note: Guessing the language may cause some error messages during parsing attempts - * - * @param message Message to be read - * @return The model of the message - */ - private Model readMessage(String message) throws IOException { - - List supportedLanguages = new ArrayList<>( - Arrays.asList( - RDFLanguages.JSONLD, //JSON-LD first - RDFLanguages.TURTLE, //N-TRIPLE is a subset of Turtle - RDFLanguages.RDFXML - )); - - for (Lang lang : supportedLanguages) { - try { - return readMessage(message, lang); - } catch (IOException ignored) { - } - } - throw new IOException("Could not parse string as any supported RDF format (JSON-LD, Turtle/N-Triple, RDF-XML)."); - } - - /** - * Reads a message into an Apache Jena model, guessing the input language. - * Note: Guessing the language may cause some error messages during parsing attempts - * - * @param message Message to be read - * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML - * @return The model of the message - */ - private Model readMessage(String message, Lang language) throws IOException { - - Model targetModel = ModelFactory.createDefaultModel(); - - try { - RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); - } catch (RiotException e) { - throw new IOException("Failed to parse input as " + language, e); - } - return targetModel; - } - - /** - * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated - * - * @param someClass Input class of which implementable subclasses need to be found - * @return ArrayList of instantiable subclasses - */ - ArrayList> getImplementingClasses(Class someClass) { - ArrayList> result = new ArrayList<>(); - KnownSubtypes subTypeAnnotation = someClass.getAnnotation(KnownSubtypes.class); - if (subTypeAnnotation != null) { - KnownSubtypes.Type[] types = subTypeAnnotation.value(); - for (KnownSubtypes.Type type : types) { - result.addAll(getImplementingClasses(type.value())); - } - } - if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { - result.add(SerializerHelper.customImplementationMap.getOrDefault(someClass, someClass)); - } - return result; - } - - private void addArtificialBlankNodeLabels(Model m) { - //Get all blank nodes - Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); - QueryExecution qe = QueryExecutionFactory.create(q, m); - ResultSet rs = qe.execSelect(); - List statementsToAdd = new ArrayList<>(); - while (rs.hasNext()) { - QuerySolution qs = rs.next(); - statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), - ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), - ResourceFactory.createStringLiteral(qs.get("?s").toString()))); - } - qe.close(); - m.add(statementsToAdd); - } - -} 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..4e56f9bd6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java @@ -0,0 +1,27 @@ +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 is side effect free and idempotent. + * @param element 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. + */ + public RDFSerializationResult toModel(T object); + + /** + * This method is side effect free and idempotent. + * @param model The graph model that holds information. + * @param subjectToParse Root elements that correspond to the object. + * @return instance of the object + */ + public 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 similarity index 98% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java index bba8cc423..b6fad5601 100644 --- 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 @@ -1,11 +1,7 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; -import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; -import org.apache.jena.riot.Lang; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -16,7 +12,7 @@ import java.util.List; import java.util.stream.Collectors; -public class RdfParser { +public class RDFParser { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /** * Deserializes a given string into an instance of AssetAdministrationShellEnvironment 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..4f8750612 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java @@ -0,0 +1,10 @@ +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 { + + public void partialToModel(T object, Model model, Resource parentNode); + public T partialFromModel(T object, Model model, Resource subjectToParse); +} 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..89523965d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java @@ -0,0 +1,10 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; + +public interface RDFSerializationResult { + Model getModel(); + + 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 similarity index 93% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java index e24460f47..7b314ccea 100644 --- 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 @@ -3,7 +3,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.system.Serializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -11,13 +10,11 @@ import java.io.*; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.List; -public class RdfSerializer { +public class RDFSerializer { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - SerializerHelper serializerHelper = new SerializerHelper(); + /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * @@ -28,7 +25,7 @@ public class RdfSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - return serializerHelper.write(aasEnvironment, serializationFormat); + throw new RuntimeException("Not Implemented"); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } @@ -55,7 +52,7 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - return serializerHelper.write(referable, serializationFormat); + throw new RuntimeException("Not Implemented"); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } @@ -73,7 +70,7 @@ public String write(Referable referable) throws SerializationException { } /** - * Converts a given instance of AssetAdministrationShellEnvironment as JSON node. + * Converts a given instance of AssetAdministrationShellEnvironment as RDF Model. * * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize * @return the Jena Model @@ -86,10 +83,10 @@ public Model toModel(Environment aasEnvironment) { * Converts a given instance of a Referable to a JSON node. * * @param referable the referable to serialize - * @return the Jena Model + * @return the RDFSerializationResult contains the Apache Jena model as well as the corresponding created resource */ - public Model toModel(Referable referable) { - throw new RuntimeException("Not Implemented"); + public RDFSerializationResult toModel(Referable referable) { + return null; } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java deleted file mode 100644 index 0009a96e9..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -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.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.*; - -class SerializerHelper { - - private final ObjectMapper mapper = new ObjectMapper(); - public String implementingClassesNamePrefix = "Default"; - public String implementingClassesNameSuffix = ""; - static Map, Class> customImplementationMap = new HashMap<>(); - private boolean charsetWarningPrinted = false; - private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); - - public SerializerHelper() { - mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); - mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - mapper.setMixInResolver(new ReflectiveMixInResolver()); - - preprocessors = new ArrayList<>(); - this.addPreprocessor(new TypeNamePreprocessor()); - - if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) { - charsetWarningPrinted = true; - logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); - } - - //Default namespaces for AAS - addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); - addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); - addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/"); - //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); - //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); - - } - - /** - * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". - * - * @param prefix Prefix to be added - * @param namespaceUrl URL of the prefix - */ - public void addKnownNamespace(String prefix, String namespaceUrl) { - ParserHelper.knownNamespaces.put(prefix, namespaceUrl); - JsonLDSerializer.contextItems.put(prefix, namespaceUrl); - } - - /** - * Serializes an object to an RDF representation. In order to support RDF, the input instance must be - * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). - * - * @param instance the instance to be serialized - * @return RDF serialization of the provided object graph - * @throws IOException if the serialization fails - */ - public String serialize(Object instance) throws IOException { - return serialize(instance, RDFLanguages.TTL, new HashMap<>()); - } - - /** - * Serializes an object to an RDF representation of a given RDF serialization format. In order to support RDF, the - * input instance must be annotated using AAS Metamodel annotations. - * - * @param instance the instance to be serialized - * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) - * @return RDF serialization of the provided object graph - * @throws IOException if the serialization fails - */ - public String serialize(Object instance, Lang format) throws IOException { - return serialize(instance, format, new HashMap<>()); - } - - //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function - //HoRi: No, bad design - public String serialize(Object instance, Lang format, Map idMap) throws IOException { - if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { - throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); - } - mapper.registerModule(new JsonLDModule(idMap)); - String jsonLD = (instance instanceof Collection) - ? serializeCollection((Collection) instance) - : mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); - if (format == RDFLanguages.JSONLD) return jsonLD; - else return convertJsonLdToOtherRdfFormat(jsonLD, format); - } - - private String serializeCollection(Collection collection) throws IOException { - String lineSep = System.lineSeparator(); - StringBuilder jsonLDBuilder = new StringBuilder(); - - if (collection.isEmpty()) { - jsonLDBuilder.append("[]"); - } else { - jsonLDBuilder.append("["); - jsonLDBuilder.append(lineSep); - for (Object item : collection) { - jsonLDBuilder.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(item)); - jsonLDBuilder.append(","); - jsonLDBuilder.append(lineSep); - } - int lastComma = jsonLDBuilder.lastIndexOf(","); - jsonLDBuilder.replace(lastComma, lastComma + 1, ""); - jsonLDBuilder.append("]"); - } - jsonLDBuilder.append(lineSep); - - return jsonLDBuilder.toString(); - } - - public String convertJsonLdToOtherRdfFormat(String jsonLd, Lang format) { - Model model = ModelFactory.createDefaultModel(); - RDFDataMgr.read(model, new ByteArrayInputStream(jsonLd.getBytes()), RDFLanguages.JSONLD); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - RDFDataMgr.write(os, model, format); - return os.toString(); - } - - public String serializePlainJson(Object instance) throws JsonProcessingException { - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); - } - - - /** - * Method to add a preprocessor for deserialization. - *

- * Important note: The preprocessors are executed in the same order they were added. - * - * @param preprocessor the preprocessor to add - */ - public void addPreprocessor(JsonPreprocessor preprocessor) { - preprocessors.add(preprocessor); - } - - /** - * Method to add a preprocessor for deserialization. - *

- * Important note: The preprocessors are executed in the same order they were added. - * - * @param preprocessor the preprocessor to add - * @param validate set whether the preprocessors output should be checked by RDF4j - */ - public void addPreprocessor(JsonPreprocessor preprocessor, boolean validate) { - preprocessor.enableRDFValidation(validate); - addPreprocessor(preprocessor); - } - - /** - * remove a preprocessor if no longer needed - * - * @param preprocessor the preprocessor to remove - */ - public void removePreprocessor(JsonPreprocessor preprocessor) { - preprocessors.remove(preprocessor); - } - - - public String write(Environment aasEnvironment) throws SerializationException { - try { - return serialize(aasEnvironment); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Environment aasEnvironment, Lang format) throws SerializationException { - return write(aasEnvironment, format, new HashMap<>()); - } - - public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { - try { - return serialize(aasEnvironment, format, idMap); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Referable referable) throws SerializationException { - try { - return serialize(referable); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Referable referable, Lang format) throws SerializationException { - return write(referable, format, new HashMap<>()); - } - - public String write(Referable referable, Lang format, Map idMap) throws SerializationException { - try { - return serialize(referable, format, idMap); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - - - public void useImplementation(Class aasInterface, Class implementation) { - customImplementationMap.put(aasInterface, implementation); - //throw new NotImplementedException("Custom implementation support not yet implemented"); - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java deleted file mode 100644 index a889ae103..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf; - -import java.io.IOException; -import java.net.URI; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonStreamContext; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -public class UriSerializer extends StdSerializer { - - - public UriSerializer() { - this(null); - } - - public UriSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(URI value, JsonGenerator gen, SerializerProvider provider) throws IOException { - String serializedUri = value.toString(); - // String idPattern = "{\"@id\": \"" + serializedUri + "\"}"; - JsonStreamContext context = gen.getOutputContext(); - if (context.getCurrentName() != null && context.getCurrentName().contains("@id")) { - gen.writeString(serializedUri); - } else { - gen.writeStartObject(); - gen.writeStringField("@id", serializedUri); - gen.writeEndObject(); - } - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java deleted file mode 100644 index a05f77d44..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; -import java.math.BigDecimal; - -public class BigDecimalSerializer extends StdSerializer { - - public BigDecimalSerializer() { - this(null); - } - - public BigDecimalSerializer(Class clazz) { - super(clazz); - } - - @Override - public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeStartObject(); - gen.writeStringField("@value", value.toString()); - gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#decimal"); - gen.writeEndObject(); - } -} \ No newline at end of file diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java deleted file mode 100644 index ff1374e20..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.JsonLdEnumSerializer; - -@JsonSerialize(using = JsonLdEnumSerializer.class) -public class JsonLdEnumMixin { -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java deleted file mode 100644 index a1f0ec779..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.rdf.custom; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - - -import java.util.List; - -@JsonTypeName("rdf:langString") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface LangStringMixin { - @JsonProperty("@value") - public String getValue(); - - @JsonProperty("@language") - public String getLanguage(); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java deleted file mode 100644 index 54692477e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.databind.introspect.ClassIntrospector; - -public class ReflectiveMixInResolver implements ClassIntrospector.MixInResolver { - - @Override - public Class findMixInClassFor(Class cls) { - if (cls.isEnum()) - { - return JsonLdEnumMixin.class; - } - try { - return Class.forName("org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins." + cls.getSimpleName() + "Mixin"); - } - catch (ClassNotFoundException ignored) - { - return null; - } - } - - @Override - public ClassIntrospector.MixInResolver copy() { - return new ReflectiveMixInResolver(); - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java deleted file mode 100644 index 28006cbb8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.IOException; -import java.time.ZonedDateTime; -import java.util.GregorianCalendar; - -public class XMLGregorianCalendarDeserializer extends StdDeserializer { - - public XMLGregorianCalendarDeserializer() { - this(XMLGregorianCalendar.class); - } - - public XMLGregorianCalendarDeserializer(Class clazz) { - super(clazz); - } - - @Override - public XMLGregorianCalendar deserialize(JsonParser p, DeserializationContext context) throws IOException { - XMLGregorianCalendar xgc = null; - try { - xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(p.getValueAsString()))); - } catch (DatatypeConfigurationException e) { - e.printStackTrace(); - } - return xgc; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java deleted file mode 100644 index b80718d93..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.IOException; -import java.text.SimpleDateFormat; - -public class XMLGregorianCalendarSerializer extends StdSerializer { - - public XMLGregorianCalendarSerializer() { - this(null); - } - - public XMLGregorianCalendarSerializer(Class clazz) { - super(clazz); - } - - @Override - public void serialize(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider) throws IOException { - SimpleDateFormat xsdDateTimeStampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - xsdDateTimeStampFormat.setCalendar(value.toGregorianCalendar()); - String xsdDateTimeStampFormatted = xsdDateTimeStampFormat.format(value.toGregorianCalendar().getTime()); - gen.writeStartObject(); - gen.writeStringField("@value", xsdDateTimeStampFormatted); - gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#dateTimeStamp"); - gen.writeEndObject(); - - } -} 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..2a3b2f74a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java @@ -0,0 +1,19 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; + +public class DefaultAdministrativeInformationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AdministrativeInformation key) { + return null; + } + + @Override + public AdministrativeInformation fromModel(Model model, Resource subjectToParse) { + return null; + } +} 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..aa9c77a42 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.AnnotatedRelationshipElement; + +public class DefaultAnnotatedRelationshipElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { + return null; + } + + @Override + public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..37e15e48d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java @@ -0,0 +1,26 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; + +public class DefaultAssetAdministrationShellRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AssetAdministrationShell key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + return null; + } + + @Override + public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) { + return null; + } +} 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..e808db27c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.AssetInformation; + +public class DefaultAssetInformationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AssetInformation object) { + return null; + } + + @Override + public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..cf56a05cf --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.BasicEventElement; + +public class DefaultBasicEventElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(BasicEventElement object) { + return null; + } + + @Override + public BasicEventElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..5df58123d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Blob; + +public class DefaultBlobRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Blob object) { + return null; + } + + @Override + public Blob fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d4db934ee --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Capability; + +public class DefaultCapabilityRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Capability object) { + return null; + } + + @Override + public Capability fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..c70b60406 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java @@ -0,0 +1,52 @@ +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.DefaultIdentifiableRDFHandler; +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; + +public class DefaultConceptDescriptionRDFHandler implements RDFHandler { + + @Override + public RDFSerializationResult toModel(ConceptDescription key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource conceptDescriptionResource = model.createResource(key.getId()); + model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); + //HasDataSpecification + if (key.getEmbeddedDataSpecifications() != null && key.getEmbeddedDataSpecifications().isEmpty() == false) { + + } + + //Identifiable + new DefaultIdentifiableRDFHandler().partialToModel(key, model, conceptDescriptionResource); + + for (Reference reference : key.getIsCaseOf()) { + // TODO: Optional ordering + RDFSerializationResult result = new DefaultReferenceRDFHandler().toModel(reference); + model.add(result.getModel()); + conceptDescriptionResource.addProperty(AASNamespace.ConceptDescription.isCaseOf, result.getResource()); + } + + return new DefaultRDFHandlerResult(model, conceptDescriptionResource); + } + + @Override + public ConceptDescription fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { + throw new IncompatibleTypeException(); + } + ConceptDescription build = new DefaultConceptDescription.Builder() + .build(); + new DefaultIdentifiableRDFHandler().partialFromModel(build, model, subjectToParse); + return build; + } +} 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..88093bff2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java @@ -0,0 +1,20 @@ +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.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.DataSpecificationIec61360; + +public class DefaultDataSpecificationIEC61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationIec61360 object) { + return null; + } + + @Override + public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..65db7671c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.EmbeddedDataSpecification; + +public class DefaultEmbeddedDataSpecificationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(EmbeddedDataSpecification object) { + return null; + } + + @Override + public EmbeddedDataSpecification fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..b77a3ea74 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Entity; + +public class DefaultEntityRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Entity object) { + return null; + } + + @Override + public Entity fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d9a1f76b2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Extension; + +public class DefaultExtensionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Extension object) { + return null; + } + + @Override + public Extension fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..e3d88eecb --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java @@ -0,0 +1,20 @@ +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.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.File; + +public class DefaultFileRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(File object) { + return null; + } + + @Override + public File fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..2b05fbdc4 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java @@ -0,0 +1,42 @@ +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.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +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.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.builder.KeyBuilder; +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); + subject.addProperty(AASNamespace.Key.value, key.getValue()); + subject.addProperty(AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(key.getType().name())); + return new DefaultRDFHandlerResult(model, subject); + } + + public Key fromModel(Model model, Resource subjectToParse){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + throw new IllegalArgumentException("Provided Resource is not a Key"); + } + String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); + KeyTypes type = AASNamespace.KeyTypes.fromIRI(model.getProperty(subjectToParse, AASNamespace.Key.type).getResource().getURI()); + KeyBuilder builder = new DefaultKey.Builder(); + //Todo: in future instead of specific builder we can use a generic builder instantiator + return builder.type(type) + .value(value) + .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..e27ac069b --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java @@ -0,0 +1,20 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +public class DefaultLangStringNameTypeRDFHandler implements RDFHandler{ + + @Override + public RDFSerializationResult toModel(LangStringNameType object) { + return null; + } + + @Override + public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..2d2c34397 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java @@ -0,0 +1,19 @@ +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.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.LangStringTextType; + +public class DefaultLangStringTextTypeRDFHandler implements RDFHandler{ + @Override + public RDFSerializationResult toModel(LangStringTextType object) { + return null; + } + + @Override + public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..9f3d55f79 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java @@ -0,0 +1,20 @@ +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.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.MultiLanguageProperty; + +public class DefaultMultiLanguagePropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(MultiLanguageProperty object) { + return null; + } + + @Override + public MultiLanguageProperty fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..36b71d462 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Operation; + +public class DefaultOperationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Operation object) { + return null; + } + + @Override + public Operation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..478ef4406 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Property; + +public class DefaultPropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Property object) { + return null; + } + + @Override + public Property fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..5e4639a23 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Qualifier; + +public class DefaultQualifierRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Qualifier object) { + return null; + } + + @Override + public Qualifier fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..9a3395c14 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Range; + +public class DefaultRangeRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Range object) { + return null; + } + + @Override + public Range fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..4be19ea9a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.ReferenceElement; + +public class DefaultReferenceElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(ReferenceElement object) { + return null; + } + + @Override + public ReferenceElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..6a760557e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java @@ -0,0 +1,60 @@ +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); + 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) == false){ + throw new IncompatibleTypeException(); + } + String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); + Map keysMap = new HashMap<>(); + NodeIterator keysIterator = model.listObjectsOfProperty(AASNamespace.Reference.keys); + keysIterator.forEachRemaining(node->{ + Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index,key); + }); + List keys = new ArrayList<>(); + for(int index=0;index { + @Override + public RDFSerializationResult toModel(RelationshipElement object) { + return null; + } + + @Override + public RelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java new file mode 100644 index 000000000..e146db227 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java @@ -0,0 +1,19 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Model; +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.Resource; + +public class DefaultResrouceRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Resource object) { + return null; + } + + @Override + public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..af0b10809 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java @@ -0,0 +1,20 @@ +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.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.SpecificAssetId; + +public class DefaultSpecificAssetIdRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SpecificAssetId object) { + return null; + } + + @Override + public SpecificAssetId fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d43abc395 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java @@ -0,0 +1,20 @@ +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.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.SubmodelElementCollection; + +public class DefaultSubmodelElementCollectionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElementCollection object) { + return null; + } + + @Override + public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..0efd20430 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java @@ -0,0 +1,22 @@ +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.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.SubmodelElementList; + +public class DefaultSubmodelElementListRDFHandler implements RDFHandler { + + + @Override + public RDFSerializationResult toModel(SubmodelElementList object) { + return null; + } + + @Override + public SubmodelElementList fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java new file mode 100644 index 000000000..edbdcc3ba --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java @@ -0,0 +1,21 @@ +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.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; + +public class DefaultHasSemanticsRDFHandler implements RDFPartialHandler { + + @Override + public void partialToModel(HasSemantics object, Model model, Resource parentNode) { + + } + + @Override + public HasSemantics partialFromModel(HasSemantics object, Model model, Resource subjectToParse) { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java new file mode 100644 index 000000000..ca4c71697 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java @@ -0,0 +1,49 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +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.dataformat.rdf.DefaultRDFHandlerResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; + +import java.util.HashMap; +import java.util.Map; + +public class DefaultIdentifiableRDFHandler implements RDFPartialHandler { + + @Override + public void partialToModel(Identifiable object, Model model, Resource parentNode) { + //TODO: Side effect + parentNode.addProperty(AASNamespace.Identifiable.id, object.getId()); + + RDFSerializationResult administrativeResult = new DefaultAdministrativeInformationRDFHandler() + .toModel(object.getAdministration()); + if(object.getAdministration()!=null){ + parentNode.addProperty(AASNamespace.Identifiable.administration, administrativeResult.getResource()); + model.add(administrativeResult.getModel()); + } + + new DefaultReferableRDFHandler().partialToModel(object,model,parentNode); + } + + @Override + public Identifiable partialFromModel(Identifiable object, Model model, Resource subjectToParse) { + //TODO: Side effect + String id = model.getProperty(subjectToParse, AASNamespace.Identifiable.id).getString(); + object.setId(id); + + Statement administrationStatement = model.getProperty(subjectToParse, AASNamespace.Identifiable.administration); + if(administrationStatement!=null) { + Resource administrationToParse = administrationStatement.getResource(); + AdministrativeInformation administrativeInformation = new DefaultAdministrativeInformationRDFHandler().fromModel(model, administrationToParse); + object.setAdministration(administrativeInformation); + } + + //Referable + new DefaultReferableRDFHandler().partialFromModel(object,model,subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java new file mode 100644 index 000000000..23ae9b4c8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java @@ -0,0 +1,46 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +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.DefaultAdministrativeInformationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +public class DefaultReferableRDFHandler 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() == false){ + + } + if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ + + } + + } + + @Override + public Referable partialFromModel(Referable object, Model model, Resource subjectToParse) { + if (object.getIdShort() != null) { + + } + if (object.getCategory() != null) { + + } + if (object.getDescription() != null && object.getDescription().isEmpty() == false){ + + } + if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ + + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java deleted file mode 100644 index 6c692e3c5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:AdministrativeInformation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") - String getVersion(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") - void setVersion(String version); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") - String getRevision(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") - void setRevision(String revision); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java deleted file mode 100644 index 63e182fdf..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; - -import java.util.List; - -@JsonTypeName("aas:AnnotatedRelationshipElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") - List getAnnotations(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") - void setAnnotations(List annotations); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java deleted file mode 100644 index 31fb53258..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:AssetAdministrationShell") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") - AssetInformation getAssetInformation(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") - void setAssetInformation(AssetInformation assetInformation); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") - Reference getDerivedFrom(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") - void setDerivedFrom(Reference derivedFrom); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") - List getSubmodels(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") - void setSubmodels(List submodels); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java deleted file mode 100644 index 60040db6a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.File; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:AssetInformation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AssetInformationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") - AssetKind getAssetKind(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") - void setAssetKind(AssetKind assetKind); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") - Reference getGlobalAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") - void setGlobalAssetId(Reference globalAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") - List getSpecificAssetIds(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") - void setSpecificAssetIds(List specificAssetIds); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") - List getBillOfMaterials(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") - void setBillOfMaterials(List billOfMaterials); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") - File getDefaultThumbnail(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") - void setDefaultThumbnail(File defaultThumbnail); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java deleted file mode 100644 index 6526e3db3..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Direction; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -@JsonTypeName("aas:BasicEventElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface BasicEventElementMixin extends EventElementMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") - Direction getDirection(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") - void setDirection(Direction direction); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") - String getLastUpdate(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") - void setLastUpdate(String lastUpdate); - - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") - String getMaxInterval(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") - void setMaxInterval(String maxInterval); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") - Reference getMessageBroker(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") - void setMessageBroker(Reference messageBroker); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") - String getMessageTopic(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") - void setMessageTopic(String messageTopic); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") - String getMinInterval(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") - void setMinInterval(String minInterval); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") - Reference getObserved(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") - void setObserved(Reference observed); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") - StateOfEvent getState(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") - void setState(StateOfEvent state); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java deleted file mode 100644 index b5763be43..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Blob") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface BlobMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") - void setConentType(String mimeType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") - byte[] getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") - void setValue(byte[] value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java deleted file mode 100644 index d37450ab5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Capability") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface CapabilityMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java deleted file mode 100644 index 3f17da8fa..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:ConceptDescription") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") - List getIsCaseOf(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") - void setIsCaseOf(List isCaseOf); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java deleted file mode 100644 index dab2fb7be..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -@JsonTypeName("aas:DataElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = File.class), - @JsonSubTypes.Type(value = Blob.class), - @JsonSubTypes.Type(value = MultiLanguageProperty.class), - @JsonSubTypes.Type(value = Property.class), - @JsonSubTypes.Type(value = Range.class), - @JsonSubTypes.Type(value = ReferenceElement.class) -}) -public interface DataElementMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java deleted file mode 100644 index 823206ff2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -@JsonTypeName("aas:DataSpecificationContent") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = DataSpecificationIec61360.class) -}) -public interface DataSpecificationContentMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java deleted file mode 100644 index 4993c0353..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - -@JsonTypeName("aas:DataSpecificationIec61360") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationIec61360Mixin extends DataSpecificationContentMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") - public DataTypeIec61360 getDataType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") - public void setDataType(DataTypeIec61360 dataType); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") - public List getDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") - public void setDefinitions(List definition); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") - public LevelType getLevelType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") - public void setLevelType(LevelType levelType); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") - public List getPreferredName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") - public void setPreferredName(List preferredName); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") - public List getShortName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") - public void setShortName(List shortName); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") - public String getSourceOfDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") - public void setSourceOfDefinition(String sourceOfDefinition); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") - public String getSymbol(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") - public void setSymbol(String symbol); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") - public String getUnit(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") - public void setUnit(String unit); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") - public Reference getUnitId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") - public void setUnitId(Reference unitId); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") - public String getValueFormat(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") - public void setValueFormat(String valueFormat); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") - public String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") - public void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") - public ValueList getValueList(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") - public void setValueList(ValueList valueList); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") - public Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") - public void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java deleted file mode 100644 index e8f87e544..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:EmbeddedDataSpecification") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EmbeddedDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") - public DataSpecificationIec61360 getDataSpecificationContent(); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") - public void setDataSpecificationContent(DataSpecificationIec61360 dataSpecificationContent); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") - public Reference getDataSpecification(); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") - public void setDataSpecification(Reference dataSpecification); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java deleted file mode 100644 index 35f7da75d..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.EntityType; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Entity") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EntityMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") - Reference getGlobalAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") - void setGlobalAssetId(Reference globalAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") - SpecificAssetId getSpecificAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") - void setSpecificAssetId(SpecificAssetId specificAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") - EntityType getEntityType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") - void setEntityType(EntityType entityType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") - List getStatements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") - void setStatements(List statements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java deleted file mode 100644 index fb74f5287..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - -import java.util.List; - -@JsonTypeName("aas:Environment") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EnvironmentMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") - List getAssetAdministrationShells(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") - void setAssetAdministrationShells(List assetAdministrationShells); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") - List getConceptDescriptions(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") - void setConceptDescriptions(List conceptDescriptions); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") - List getSubmodels(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") - void setSubmodels(List submodels); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java deleted file mode 100644 index e3e7ed1c0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; - - -@JsonTypeName("aas:EventElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = BasicEventElement.class) -}) -public interface EventElementMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java deleted file mode 100644 index 26bc5c128..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:EventMessage") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EventMessageMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java deleted file mode 100644 index f46030240..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Extension") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ExtensionMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") - String getName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") - void setName(String name); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") - Reference getRefersTo(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") - void setRefersTo(Reference refersTo); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java deleted file mode 100644 index 59fa087ff..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:File") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface FileMixin extends DataElementMixin, SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") - void setContentType(String contentType); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/value") - void setValue(String value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java deleted file mode 100644 index cc32cace1..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:Formula") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface FormulaMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") - List getDependsOns(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") - void setDependsOns(List dependsOns); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java deleted file mode 100644 index cd7f1b9c2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -import java.util.List; - -@JsonTypeName("aas:HasDataSpecification") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = AdministrativeInformation.class), - @JsonSubTypes.Type(value = AssetAdministrationShell.class), - @JsonSubTypes.Type(value = ConceptDescription.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface HasDataSpecificationMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") - List getDataSpecifications(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") - void setDataSpecifications(List dataSpecifications); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") - List getEmbeddedDataSpecifications(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") - void setEmbeddedDataSpecifications(List embeddedDataSpecifications); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java deleted file mode 100644 index c7a16a663..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; - -import java.util.List; - -@JsonTypeName("aas:HasExtensions") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface HasExtensionsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") - List getExtensions(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") - void setExtensions(List extensions); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java deleted file mode 100644 index c8299f52f..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -@JsonTypeName("aas:HasKind") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface HasKindMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") - ModellingKind getKind(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") - void setKind(ModellingKind kind); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java deleted file mode 100644 index c624b21d7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - - -@JsonTypeName("aas:HasSemantics") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SpecificAssetId.class), - @JsonSubTypes.Type(value = SubmodelElement.class), - @JsonSubTypes.Type(value = Qualifier.class), - @JsonSubTypes.Type(value = Extension.class) -}) -public interface HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") - Reference getSemanticId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") - void setSemanticId(Reference semanticId); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") - List getSupplementalSemanticIds(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") - void setSupplementalSemanticIds(List references); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java deleted file mode 100644 index 80bdfe960..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - -@JsonTypeName("aas:Identifiable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = AssetAdministrationShell.class), - @JsonSubTypes.Type(value = ConceptDescription.class) -}) -public interface IdentifiableMixin extends ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") - AdministrativeInformation getAdministration(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") - void setAdministration(AdministrativeInformation administration); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") - String getId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") - void setId(String id); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java deleted file mode 100644 index 2298936a8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:IdentifierKeyValuePair") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") - String getKey(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") - void setKey(String key); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") - Reference getExternalSubjectId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") - void setExternalSubjectId(Reference externalSubjectId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java deleted file mode 100644 index 25b4258af..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Identifier") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface IdentifierMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") - String getIdentifier(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") - void setIdentifier(String identifier); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java deleted file mode 100644 index 66cab3fbc..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; - -@JsonTypeName("aas:Key") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface KeyMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") - KeyTypes getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") - void setType(KeyTypes type); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") - void setValue(String value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java deleted file mode 100644 index 1e290609f..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:MultiLanguageProperty") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface MultiLanguagePropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") - List getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") - void setValue(List values); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java deleted file mode 100644 index 095bbc8c9..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:ObjectAttributes") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ObjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") - List getObjectAttributes(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") - void setObjectAttributes(List objectAttributes); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java deleted file mode 100644 index e60eb42fc..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; - -import java.util.List; - -@JsonTypeName("aas:Operation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface OperationMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") - List getInputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") - void setInputVariables(List inputVariables); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") - List getInoutputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") - void setInoutputVariables(List inoutputVariables); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") - List getOutputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") - void setOutputVariables(List outputVariables); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java deleted file mode 100644 index a099ae7db..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -@JsonTypeName("aas:OperationVariable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface OperationVariableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") - SubmodelElement getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") - void setValue(SubmodelElement value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java deleted file mode 100644 index 8e63a86f8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:PolicyDecisionPoint") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyDecisionPointMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") - boolean getExternalPolicyDecisionPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") - void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java deleted file mode 100644 index d1aaa0eef..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:PolicyEnforcementPoints") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyEnforcementPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") - boolean getExternalPolicyEnforcementPoint(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") - void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java deleted file mode 100644 index 935f0b5f0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:PolicyInformationPoints") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyInformationPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") - boolean getExternalInformationPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") - void setExternalInformationPoints(boolean externalInformationPoints); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") - List getInternalInformationPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") - void setInternalInformationPoints(List internalInformationPoints); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java deleted file mode 100644 index 1466c78e0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Property") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java deleted file mode 100644 index e4619f351..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; - -import java.util.List; - -@JsonTypeName("aas:Qualifiable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface QualifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") - List getQualifiers(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") - void setQualifiers(List qualifiers); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java deleted file mode 100644 index d3c5ef093..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Qualifier") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface QualifierMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") - String getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") - void setType(String type); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java deleted file mode 100644 index 1bef8f17a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Range") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface RangeMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") - String getMax(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") - void setMax(String max); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") - String getMin(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") - void setMin(String min); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java deleted file mode 100644 index de65fa1eb..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Referable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Identifiable.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") - String getCategory(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") - void setCategory(String category); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") - List getDescription(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") - void setDescription(List description); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") - List getDisplayName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") - void setDisplayName(List displayName); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") - String getIdShort(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") - void setIdShort(String idShort); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java deleted file mode 100644 index bbffdaaae..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:ReferenceElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ReferenceElementMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") - Reference getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") - void setValue(Reference value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java deleted file mode 100644 index 55e5b8c98..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.util.List; - -@JsonTypeName("aas:Reference") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ReferenceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") - List getKeys(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") - void setKeys(List keys); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") - ReferenceTypes getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") - void setType(ReferenceTypes type); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java deleted file mode 100644 index 3b1fba521..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:RelationshipElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) -}) -public interface RelationshipElementMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") - Reference getFirst(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") - void setFirst(Reference first); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") - Reference getSecond(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") - void setSecond(Reference second); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java deleted file mode 100644 index 88a6dfff2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; - -import java.util.List; - -@JsonTypeName("aas:Resource") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ResourceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") - void setContentType(String contentType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") - String getPath(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") - void setPath(String path); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java deleted file mode 100644 index ec328856e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.File; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; - -@JsonTypeName("aas:SpecificAssetId") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SpecificAssetIdMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") - String getName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") - void setName(String name); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") - Reference getExternalSubjectId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") - void setExternalSubjectId(Reference reference); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java deleted file mode 100644 index 54401344b..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; - -import java.util.List; - -@JsonTypeName("aas:SubjectAttributes") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") - List getSubjectAttributes(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") - void setSubjectAttributes(List subjectAttributes); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java deleted file mode 100644 index 99fe43314..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.Collection; - -@JsonTypeName("aas:SubmodelElementCollection") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") - boolean getAllowDuplicates(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") - void setAllowDuplicates(boolean allowDuplicates); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") - boolean getOrdered(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") - void setOrdered(boolean ordered); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") - Collection getValues(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") - void setValues(Collection values); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java deleted file mode 100644 index a00265d97..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.util.List; - -@JsonTypeName("aas:SubmodelElementList") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelElementListMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") - boolean getOrderRelevant(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") - void setOrderRelevant(boolean orderRelevant); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") - Reference getSemanticIdListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") - void setSemanticIdListElement(Reference semanticIdListElement); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") - AasSubmodelElements getTypeValueListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") - void setTypeValueListElement(AasSubmodelElements typeValueListElement); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") - List getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") - void setValue(List value); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") - DataTypeDefXsd getValueTypeListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") - void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java deleted file mode 100644 index 1bb5e50b5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -@JsonTypeName("aas:SubmodelElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = RelationshipElement.class), - @JsonSubTypes.Type(value = DataElement.class), - @JsonSubTypes.Type(value = File.class), - @JsonSubTypes.Type(value = Capability.class), - @JsonSubTypes.Type(value = Entity.class), - @JsonSubTypes.Type(value = EventElement.class), - @JsonSubTypes.Type(value = EventPayload.class), - @JsonSubTypes.Type(value = Operation.class), - @JsonSubTypes.Type(value = SubmodelElementCollection.class) -}) -public interface SubmodelElementMixin extends ReferableMixin, QualifiableMixin, HasDataSpecificationMixin, HasKindMixin, HasSemanticsMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java deleted file mode 100644 index ccb2cbcf7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Submodel") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") - List getSubmodelElements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") - void setSubmodelElements(List submodelElements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java deleted file mode 100644 index 005eec10a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; - -import java.util.List; - - -@JsonTypeName("aas:ValueList") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ValueListMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") - List getValueReferencePairs(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") - void setValueReferencePairs(List valueReferencePairs); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java deleted file mode 100644 index f57950e61..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:ValueReferencePair") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ValueReferencePairMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java deleted file mode 100644 index b10f8626e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:View") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") - List getContainedElements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") - void setContainedElements(List containedElements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java deleted file mode 100644 index 2bf5c6603..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf.preprocessing; - - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; - - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -/** - * basic implementation of {@code JsonPreprocessor} that encapsulates validation. - * By default, validation is disabled for performance reasons (@context has to be downloaded each time). - */ -public abstract class BasePreprocessor implements JsonPreprocessor { - - private boolean validate = false; - - - @Override - public final String preprocess(String input) throws IOException { - String result = preprocess_impl(input); - if(validate) { - Model m = ModelFactory.createDefaultModel(); - RDFDataMgr.read(m, new ByteArrayInputStream(result.getBytes()), RDFLanguages.JSONLD); - } - return result; - } - - abstract String preprocess_impl(String input) throws IOException; - - @Override - public void enableRDFValidation(boolean validate) { - this.validate = validate; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java deleted file mode 100644 index a76739850..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.preprocessing; - -import java.io.IOException; - -/** - * Interface for JSON-LD preprocessors which should transform JSON-LD inputs - * before they are deserialized by Jackson. - * - * Implementations used at the same time must not interfere with each other. - */ -public interface JsonPreprocessor { - - /** - * preprocessing method - * @param input of the transformation, the original JSON-LD - * @return the transformation´s result - * @throws IOException if preprocessing fails, e.g. because the input is not valid RDF - */ - public String preprocess(String input) throws IOException; - - /** - * specify wheter the transformation's result should be validated to - * be parsable by RDF4j - * @param validate enable/disable switch - */ - public void enableRDFValidation(boolean validate); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java deleted file mode 100644 index 9de954912..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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.rdf.preprocessing; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -public class TypeNamePreprocessor extends BasePreprocessor { - - private static final Map prefixes; - - static { - prefixes = new HashMap<>(); - prefixes.put("ids:", "https://w3id.org/idsa/core/"); - prefixes.put("idsc:", "https://w3id.org/idsa/code/"); - prefixes.put("info:", "http://www.fraunhofer.de/fraunhofer-digital/infomodell#"); - prefixes.put("kdsf:", "http://kerndatensatz-forschung.de/version1/technisches_datenmodell/owl/Basis#"); - } - - @Override - String preprocess_impl(String input) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - Map inMap = mapper.readValue(input, Map.class); - Map outMap = unifyTypeURIPrefix(inMap); - return mapper.writeValueAsString(outMap); - } - - - private Map unifyTypeURIPrefix(Map in) { - Map out = new LinkedHashMap<>(); - in.forEach((k,v) -> { - if(v instanceof String && k instanceof String && k.equals("@type")) { - - - // if key is @type and value is a string: add 'ids:' if no other namespace at the value - AtomicReference modifiableValue = new AtomicReference<>((String) v); - prefixes.forEach((p, u) -> modifiableValue.set(modifiableValue.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableValue.get().startsWith("ids:") - || modifiableValue.get().startsWith("idsc:") - || modifiableValue.get().startsWith("info:") - || modifiableValue.get().startsWith("kdsf:") - || modifiableValue.get().startsWith("xsd:") - || modifiableValue.get().startsWith("http://") - || modifiableValue.get().startsWith("https://"))) { - modifiableValue.set("ids:".concat(modifiableValue.get())); // default to ids prefix for backwards compatibility - } - out.put(k, modifiableValue.get()); - - - } else if(v instanceof Map) { - AtomicReference modifiableKey = new AtomicReference<>((String) k); - - prefixes.forEach((prefix, uri) -> modifiableKey.set(modifiableKey.get().replace(uri, prefix))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://") - || modifiableKey.get().startsWith("@context"))) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - - - // shorten an @id Map - if (((Map) v).containsKey("@id") && ((Map) v).keySet().size() == 1) { - Map idMap = new LinkedHashMap<>(); - idMap.put(k, ((Map) v).get("@id")); - - out.putAll(unifyTypeURIPrefix(idMap)); - - } else if (((Map) v).containsKey("@value") && - ((Map) v).containsKey("@type")) - { - if( ((Map) v).get("@type").toString().contains("dateTime") ) - { - - // shorten an @value Map with xsd:dateTimes - Object date = ((Map) v).get("@value"); - out.put(modifiableKey, date); - } - else if(((Map) v).get("@type").toString().equals("xsd:integer")) - { - int value = Integer.parseInt(((Map) v).get("@value").toString()); - out.put(modifiableKey, value); - } - else { //Do the same as below - out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); - } - - } else { - - out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); - - - } - - } else if(v instanceof ArrayList) { - - - AtomicReference modifiableKey = new AtomicReference<>((String) k); - prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://"))) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - - Iterator iter = new ArrayList((ArrayList) v).iterator(); //making a copy of the old array so the iterator does not get confused by the element deletions - while (iter.hasNext()) { - Object child = iter.next(); - if (child instanceof Map && ((Map) child).containsKey("@id") && ((Map) child).keySet().size() == 1) { - ((ArrayList) v).remove(child); - ((ArrayList) v).add(((Map) child).get("@id")); - } - } - - out.put(modifiableKey, unifyTypeURIPrefix((ArrayList) v)); // TODO: What happens with an Array inside the Array? - - - } else { - - - AtomicReference modifiableKey = new AtomicReference<>((String) k); - prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://") - || modifiableKey.get().startsWith("@"))) { - //in the context definition, a pair might look like this: "ids" : "http://www.someURL.com" - //Here, we start with "ids", not "ids:". So we also need to check that the key is not contained in our prefixes - if(!prefixes.containsKey(modifiableKey.get() + ":")) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - } - - out.put(modifiableKey, v); // modify nothing if not @type or a map - } - }); - return out; - } - - - private ArrayList unifyTypeURIPrefix(ArrayList in) { - ArrayList out = new ArrayList<>(); - - Iterator iter = in.iterator(); - - while (iter.hasNext()) { - Object v = iter.next(); - if(v instanceof Map) { - - - if (!((Map) v).isEmpty()) - out.add( unifyTypeURIPrefix((Map) v)); - - - } else if (v instanceof String) { - - out.add(v); // modify nothing if not @type or a map - } else { - out.add(v); - } - } - return out; - } - - - - -} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java index 7acbacdba..3fbb9bc0b 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -17,137 +17,17 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; - -import org.apache.jena.riot.RDFLanguages; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import java.io.IOException; @RunWith(JUnitParamsRunner.class) public class ParserTest { - @Test - public void parseAasEnvironmentTest() throws IOException, DeserializationException { - String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); - Environment aasEnv = new RdfParser().read(aasEnvAsString); - Assert.assertEquals(1, aasEnv.getSubmodels().size()); - Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); - Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); - - Assert.assertEquals("de", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(0).getLanguage()); - Assert.assertEquals("en", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(1).getLanguage()); - Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); - - } -// -// @Test -// @Ignore -// public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { -// String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); -// Environment environment = new RdfParser().read(aasEnvAsString); -// -// // TODO continue providing a correct AASFull Turtle representation -// // TODO test for LangStrings -// Assert.assertEquals(AASFull.ENVIRONMENT, environment); -// } -// -// -// @Test -// @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", -// "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) -// public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// -// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); -// } -// -// @Test -// @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) -// public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// -// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); -// } -// -// @Test -// @Parameters({"Submodel_SubmodelElement_Example.ttl"}) -// public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// //These work -// -// Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); -// -// -// //The following examples do not work yet, as they are semantically problematic -// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); -// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); -// } -// -// -// -// -// @Test -// public void deserializeConceptDescription() throws IOException, DeserializationException { -// String conceptDescription = "{\n" + -// " \"@context\" : {\n" + -// " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + -// " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + -// " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + -// " },\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + -// " \"@type\" : \"aas:ConceptDescription\",\n" + -// " \"isCaseOf\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + -// " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + -// " \"@type\" : \"aas:Reference\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + -// " \"@type\" : \"aas:Key\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + -// " } ]\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + -// " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + -// " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + -// " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + -// " } ]\n" + -// "}"; -// -// Serializer serializer = new Serializer(); -// ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); -// -// Assert.assertNotNull(c); -// } -// - } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 6431a764b..e659e3f6e 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -20,20 +20,17 @@ import org.apache.jena.riot.Lang; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.*; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import org.junit.Assert; import org.junit.Test; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -42,193 +39,73 @@ public class SerializerTest { - //TODO: Optional: Prefixes instead of full URIs - //TODO: Optional: Do not serialize empty collections @Test - public void simpleConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("simple") - .build(); - - String output = null; - try { - output = new RdfSerializer().write(conceptDescription); - System.out.println(output); - - Model model = ModelFactory.createDefaultModel(); - InputStream inputStream = new ByteArrayInputStream(output.getBytes()); - model.read(inputStream, null, "TTL"); -// ResourceFactory.createResource(Identifiable.id); -// ResourceFactory.createProperty(propertyUriString); - // Get all subject nodes that are of type ConceptDescription - ResIterator resIterator = model.listResourcesWithProperty(RDF.type, - ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); - Resource createdConceptDescriptionResource = resIterator.nextResource(); - Statement idStatement = model.getProperty(createdConceptDescriptionResource, - ResourceFactory.createProperty(Identifiable.id)); - assert idStatement.getString().equals(conceptDescription.getId()); - } catch (SerializationException e) { - throw new RuntimeException(e); - } + public void testKey() throws IOException { + 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 testReference() throws IncompatibleTypeException { + Reference reference = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).keys(Arrays.asList(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 simpleConceptDescription() throws IOException, IncompatibleTypeException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("simple").build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(conceptDescription); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.ConceptDescription); + assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + ConceptDescription recreatedConceptDescription = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert conceptDescription.equals(recreatedConceptDescription); } @Test public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("complex") - .extensions(Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build())) - .category("myCategory") - .idShort("exampleIdShort") - .displayName(Arrays.asList( - new DefaultLangStringNameType.Builder() - .text("text in English") - .language("en") - .build(), - new DefaultLangStringNameType.Builder() - .text("متن به فارسی") - .language("fa") - .build() - )) - .description(Arrays.asList( - new DefaultLangStringTextType.Builder() - .text("A long text in English") - .language("en") - .build(), - new DefaultLangStringTextType.Builder() - .text("영어로 된 긴 텍스트") - .language("ko") - .build() - )) - .administration(new DefaultAdministrativeInformation.Builder() - .version("1") - .revision("0") - .creator(new DefaultReference.Builder() - .keys(Arrays.asList( - 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()) - .build() - ).isCaseOf(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.com/outside") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .build() - )) - .embeddedDataSpecifications(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()) - .build()) - .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() - .levelType(new DefaultLevelType.Builder() - .max(true) - .min(true) - .nom(false) - .typ(false) - .build()) - .unit("gram") - .symbol("g") + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("complex").extensions(Arrays.asList(new DefaultExtension.Builder().name("extension1").value("extension1Value").build(), new DefaultExtension.Builder().name("extension2").value("extension2Value").build())).category("myCategory").idShort("exampleIdShort").displayName(Arrays.asList(new DefaultLangStringNameType.Builder().text("text in English").language("en").build(), new DefaultLangStringNameType.Builder().text("متن به فارسی").language("fa").build())).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("A long text in English").language("en").build(), new DefaultLangStringTextType.Builder().text("영어로 된 긴 텍스트").language("ko").build())).administration(new DefaultAdministrativeInformation.Builder().version("1").revision("0").creator(new DefaultReference.Builder().keys(Arrays.asList(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()).build()).isCaseOf(Arrays.asList(new DefaultReference.Builder().keys(new DefaultKey.Builder().value("https://example.com/outside").type(KeyTypes.GLOBAL_REFERENCE).build()).type(ReferenceTypes.EXTERNAL_REFERENCE).build())).embeddedDataSpecifications(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()).build()).dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder().levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()).unit("gram").symbol("g") // .definition() // .shortName() // .preferredName() // .valueFormat() // .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE) - .build()) - .build()) - .build(); - - String output = null; - try { - String outputJsonLd = new RdfSerializer().write(conceptDescription, Lang.JSONLD); - System.out.println(outputJsonLd); - output = new RdfSerializer().write(conceptDescription); - System.out.println(output); - - Model model = ModelFactory.createDefaultModel(); - InputStream inputStream = new ByteArrayInputStream(output.getBytes()); - model.read(inputStream, null, "TTL"); -// ResourceFactory.createResource(Identifiable.id); -// ResourceFactory.createProperty(propertyUriString); - // Get all subject nodes that are of type ConceptDescription - ResIterator resIterator = model.listResourcesWithProperty(RDF.type, - ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); - Resource createdConceptDescriptionResource = resIterator.nextResource(); - Statement idStatement = model.getProperty(createdConceptDescriptionResource, - ResourceFactory.createProperty(Identifiable.id)); - assert idStatement.getString().equals(conceptDescription.getId()); - } catch (SerializationException e) { - throw new RuntimeException(e); - } + .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); + } @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { - AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) - .build()) - .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())) - .displayName(Arrays.asList( - 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() - .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())) - .displayName(Arrays.asList( - 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() - .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(); + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder().assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())).displayName(Arrays.asList(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().description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())).displayName(Arrays.asList(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().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(); + Environment aasEnv = new DefaultEnvironment.Builder().assetAdministrationShells(aasList).submodels(submodel).conceptDescriptions(conceptDescription).build(); - String output = new RdfSerializer().write(aasEnv); + String output = new RDFSerializer().write(aasEnv); System.out.println(output); } } diff --git a/dataformat-rdf/src/test/resources/AASFull.ttl b/dataformat-rdf/src/test/resources/AASFull.ttl deleted file mode 100644 index 8c11c4546..000000000 --- a/dataformat-rdf/src/test/resources/AASFull.ttl +++ /dev/null @@ -1,354 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - -# AAS Environment - rdf:type aas:Environment ; - ; - ; - ; -. - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "MaxRotationSpeed"^^xs:string ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "PARAMETER"^^xs:string ; - "0173-1#02-BAA120#008"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Max. rotation speed"@en, "max. Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; - . - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "RotationSpeed"^^xs:string ; - rdfs:label "RotationSpeed"^^xs:string ; - "PROPERTY"^^xs:string ; - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] . - - rdf:type aas:DataSpecificationIEC61360 ; - "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Document"^^xs:string ; - rdfs:label "Document"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Document"@en, "Dokument"@de ; - "Document"@en ; - "[ISO 15519-1:2010]"^^xs:string ; - ; - "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Title"^^xs:string ; - rdfs:label "Title"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; - . - - rdf:type aas:DataSpecificationIEC61360 ; - "Titel"@en, "Titel"@de ; - "Titel"@en ; - ; - "Sprachabhängiger Titel des Dokuments."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "DigitalFile"^^xs:string ; - rdfs:label "DigitalFile"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - - rdf:type aas:DataSpecificationIEC61360 ; - "Digital File"@en ; - "DigitalFile"@en ; - ; - "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt deleted file mode 100644 index 65b752bdc..000000000 --- a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt +++ /dev/null @@ -1,16 +0,0 @@ - . - "ExampleMotor"^^ . - "ExampleMotor"^^ . - "A very short description of the AAS instance"@en . - "A very short description of the AAS instance."^^ . - "https://customer.com/aas/9175_7013_7091_9168"^^ . - _:AssetInformation . -_:AssetInformation . -_:AssetInformation _:GlobalAssetId . -_:AssetInformation . -_:GlobalAssetId . -_:GlobalAssetId . -_:GlobalAssetId _:Key . -_:Key . -_:Key . -_:Key "https://customer.com/assets/KHBVZJSQKIY"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl deleted file mode 100644 index e22b250fd..000000000 --- a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl +++ /dev/null @@ -1,27 +0,0 @@ -@prefix : . -@prefix aas: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; -. diff --git a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl deleted file mode 100644 index e5f25bfe6..000000000 --- a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl +++ /dev/null @@ -1,56 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Complete_Example.ttl b/dataformat-rdf/src/test/resources/Complete_Example.ttl deleted file mode 100644 index 0c800f8d1..000000000 --- a/dataformat-rdf/src/test/resources/Complete_Example.ttl +++ /dev/null @@ -1,347 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "MaxRotationSpeed"^^xs:string ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "PARAMETER"^^xs:string ; - "0173-1#02-BAA120#008"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Max. rotation speed"@en, "max. Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; - . - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "RotationSpeed"^^xs:string ; - rdfs:label "RotationSpeed"^^xs:string ; - "PROPERTY"^^xs:string ; - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] . - - rdf:type aas:DataSpecificationIEC61360 ; - "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Document"^^xs:string ; - rdfs:label "Document"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Document"@en, "Dokument"@de ; - "Document"@en ; - "[ISO 15519-1:2010]"^^xs:string ; - ; - "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Title"^^xs:string ; - rdfs:label "Title"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; - . - - rdf:type aas:DataSpecificationIEC61360 ; - "Titel"@en, "Titel"@de ; - "Titel"@en ; - ; - "Sprachabhängiger Titel des Dokuments."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "DigitalFile"^^xs:string ; - rdfs:label "DigitalFile"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - - rdf:type aas:DataSpecificationIEC61360 ; - "Digital File"@en ; - "DigitalFile"@en ; - ; - "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Overall-Example.nt b/dataformat-rdf/src/test/resources/Overall-Example.nt deleted file mode 100644 index 3921c9aff..000000000 --- a/dataformat-rdf/src/test/resources/Overall-Example.nt +++ /dev/null @@ -1,253 +0,0 @@ - . - "ExampleMotor"^^ . - "ExampleMotor"^^ . - "A very short description of the AAS instance"@en . - "A very short description of the AAS instance."^^ . - "https://customer.com/aas/9175_7013_7091_9168"^^ . - _:AssetInformation . - _:Submodel1 . - _:Submodel2 . - _:Submodel3 . -_:AssetInformation . -_:AssetInformation _:GlobalAssetId1 . -_:AssetInformation . -_:GlobalAssetId1 . -_:GlobalAssetId1 . -_:GlobalAssetId1 _:Key1 . -_:Key1 . -_:Key1 . -_:Key1 "https://customer.com/assets/KHBVZJSQKIY"^^ . -_:Submodel1 . -_:Submodel1 . -_:Submodel1 _:Key2 . -_:Key2 . -_:Key2 . -_:Key2 "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . -_:Submodel2 . -_:Submodel2 . -_:Submodel2 _:Key3 . -_:Key3 . -_:Key3 . -_:Key3 "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . -_:Submodel3 . -_:Submodel3 . -_:Submodel3 _:Key4 . -_:Key4 . -_:Key4 . -_:Key4 "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^ . - . - "TechnicalData"^^ . - "TechnicalData"^^ . - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . - . - _:SemanticId1 . - _:SubmodelElement1 . -_:SemanticId1 . -_:SemanticId1 . -_:SemanticId1 _:Key5 . -_:Key5 . -_:Key5 . -_:Key5 "0173-1#01-AFZ615#016"^^ . -_:SubmodelElement1 . -_:SubmodelElement1 "MaxRotationSpeed"^^ . -_:SubmodelElement1 "MaxRotationSpeed"^^ . -_:SubmodelElement1 . -_:SubmodelElement1 _:ValueId1 . -_:SubmodelElement1 "5000"^^ . -_:ValueId1 . -_:ValueId1 . -_:ValueId1 _:Key6 . -_:Key6 . -_:Key6 . -_:Key6 "0173-1#02-BAA120#008"^^ . - . - "OperationalData"^^ . - "OperationalData"^^ . - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . - . - _:SubmodelElement2 . -_:SubmodelElement2 . -_:SubmodelElement2 "RotationSpeed"^^ . -_:SubmodelElement2 "RotationSpeed"^^ . -_:SubmodelElement2 . -_:SubmodelElement2 . -_:SubmodelElement2 _:ValueId2 . -_:SubmodelElement2 "4370"^^ . -_:ValueId2 . -_:ValueId2 . -_:ValueId2 _:Key7 . -_:Key7 . -_:Key7 . -_:Key7 "http://customer.com/cd/1/1/18EBD56F6B43D895"^^ . - . - "Documentation"^^ . - "Documentation"^^ . - " . - . - _:SubmodelElement3 . -_:SubmodelElement3 . -_:SubmodelElement3 "OperatingManual"^^ . -_:SubmodelElement3 "OperatingManual"^^ . -_:SubmodelElement3 _:SemanticIdListElement1 . -_:SubmodelElement3 . -_:SubmodelElement3 _:Value1 . -_:SubmodelElement3 _:Value3 . -_:SubmodelElement3 . -_:SemanticIdListElement1 . -_:SemanticIdListElement1 . -_:SemanticIdListElement1 _:Key8 . -_:Key8 . -_:Key8 . -_:Key8 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . -_:Value1 . -_:Value1 _:Value2 . -_:Value2 . -_:Value2 . -_:Value2 "Title"^^ . -_:Value2 "application/pdf" . -_:Value2 "file:///aas/OperatingManual.pdf"^^ . -_:Value2 "Title"^^ . -_:Value2 "CONSTANT"^^ . -_:Value2 _:SemanticId2 . -_:Value2 . -_:SemanticId2 . -_:SemanticId2 . -_:SemanticId2 _:Key9 . -_:Key9 . -_:Key9 . -_:Key9 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . -_:Value3 . -_:Value3 _:Value4 . -_:Value4 . -_:Value4 . -_:Value4 "DigitalFile_PDF"^^ . -_:Value4 "application/pdf" . -_:Value4 "file:///aasx/OperatingManual.pdf"^^ . -_:Value4 "DigitalFile_PDF"^^ . -_:Value4 "CONSTANT"^^ . -_:Value4 _:SemanticId3. -_:Value4 . -_:SemanticId3 . -_:SemanticId3 . -_:SemanticId3 _:Key10 . -_:Key10 . -_:Key10 . -_:Key10 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^ . - . - "MaxRotationSpeed"^^ . - "MaxRotationSpeed"^^ . - "PARAMETER"^^ . - "0173-1#02-BAA120#008"^^ . - _:EmbeddedDataSpecification1 . -_:EmbeddedDataSpecification1 . -_:EmbeddedDataSpecification1 _:DataSpecification1 . -_:EmbeddedDataSpecification1 . -_:DataSpecification1 . -_:DataSpecification1 . -_:DataSpecification1 _:Key11 . -_:Key11 . -_:Key11 . -_:Key11 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Max. rotation speed"@en . - "max. Drehzahl"@de . - "1/min"^^ . - _:UnitId1 . - . - "H\u00F6chste zul\u00E4ssige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de . - "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en . -_:UnitId1 . -_:UnitId1 . -_:UnitId1 _:Key12 . -_:Key12 . -_:Key12 . -_:Key12 "0173-1#05-AAA650#002"^^ . - . - "RotationSpeed"^^ . - "RotationSpeed"^^ . - "PROPERTY"^^ . - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^ . - _:EmbeddedDataSpecification2 . -_:EmbeddedDataSpecification2 . -_:EmbeddedDataSpecification2 _:DataSpecification2 . -_:EmbeddedDataSpecification2 . -_:DataSpecification2 . -_:DataSpecification2 . -_:DataSpecification2 _:Key13 . -_:Key13 . -_:Key13 . -_:Key13 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Actual rotation speed"@en . - "Aktuelle Drehzahl"@de . - "1/min"^^ . - _:UnitId2 . - . - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de . - "Actual rotation speed with which the motor or feeding unit is operated."@en . -_:UnitId2 . -_:UnitId2 . -_:UnitId2 _:Key14 . -_:Key14 . -_:Key14 . -_:Key14 "0173-1#05-AAA650#002"^^ . - . - "Document"^^ . - "Document"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . - _:EmbeddedDataSpecification3 . -_:EmbeddedDataSpecification3 . -_:EmbeddedDataSpecification3 _:DataSpecification3 . -_:EmbeddedDataSpecification3 . -_:DataSpecification3 . -_:DataSpecification3 . -_:DataSpecification3 _:Key15 . -_:Key15 . -_:Key15 . -_:Key15 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Document"@en . - "Dokument"@de . - "Document"@en . - "[ISO 15519-1:2010]"^^ . - . - "Feste und geordnete Menge von f\u00FCr die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de . - . - "Title"^^ . - "Title"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . - _:EmbeddedDataSpecification4 . -_:EmbeddedDataSpecification4 . -_:EmbeddedDataSpecification4 _:DataSpecification4 . -_:EmbeddedDataSpecification4 . -_:DataSpecification4 . -_:DataSpecification4 . -_:DataSpecification4 _:Key16 . -_:Key16 . -_:Key16 . -_:Key16 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Titel"@en . - "Titel"@de . - "Titel"@en . - . - "Sprachabh\u00E4ngiger Titel des Dokuments."@de . - . - "DigitalFile"^^ . - "DigitalFile"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^ . - _:EmbeddedDataSpecification5 . -_:EmbeddedDataSpecification5 . -_:EmbeddedDataSpecification5 _:DataSpecification5 . -_:EmbeddedDataSpecification5 . -_:DataSpecification5 . -_:DataSpecification5 . -_:DataSpecification5 _:Key17 . -_:Key17 . -_:Key17 . -_:Key17 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Digital File"@en . - "DigitalFile"@en . - . - "Eine Datei, die die DocumentVersion repr\u00E4sentiert. Neben der obligatorischen PDF/A Datei k\u00F6nnen weitere Dateien angegeben werden."@de . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/ReferenceExample.ttl b/dataformat-rdf/src/test/resources/ReferenceExample.ttl deleted file mode 100644 index a18db83e5..000000000 --- a/dataformat-rdf/src/test/resources/ReferenceExample.ttl +++ /dev/null @@ -1,18 +0,0 @@ -@prefix xs: . - -# 1) Reference with KeyElements - a ; - [ - a ; - ; - [ - a ; - ; - [ - a ; - ; - "http://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] - ] - ] ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl deleted file mode 100644 index 3e50807d6..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl +++ /dev/null @@ -1,137 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt deleted file mode 100644 index 2733f1131..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt +++ /dev/null @@ -1,25 +0,0 @@ - . - "TechnicalData"^^ . - "TechnicalData"^^ . - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . - . - _:SemanticId . - _:SubmodelElements . -_:SemanticId . -_:SemanticId . -_:SemanticId _:Key1 . -_:Key1 . -_:Key1 . -_:Key1 "0173-1#01-AFZ615#016"^^ . -_:SubmodelElements . -_:SubmodelElements "MaxRotationSpeed"^^ . -_:SubmodelElements "MaxRotationSpeed"^^ . -_:SubmodelElements . -_:SubmodelElements _:ValueId . -_:SubmodelElements "5000"^^ . -_:ValueId . -_:ValueId . -_:ValueId _:Key2 . -_:Key2 . -_:Key2 . -_:Key2 "0173-1#02-BAA120#008"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl deleted file mode 100644 index 9c1d7f8c4..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl +++ /dev/null @@ -1,42 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. diff --git a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld deleted file mode 100644 index 7eac7fa6c..000000000 --- a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld +++ /dev/null @@ -1,88 +0,0 @@ -{ - "@context" : { - "aas" : "https://admin-shell.io/aas/3/0/RC02/" - }, - "@id" : "https://admin-shell.io/autogen/DefaultEnvironment/7e646a58-7419-41e2-99e8-163a7abb7b46", - "@type" : "aas:Environment", - "https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultAssetAdministrationShell/b869a629-8d69-4754-9c50-804b0e9eb35a", - "@type" : "aas:AssetAdministrationShell", - "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation" : { - "@id" : "https://admin-shell.io/autogen/DefaultAssetInformation/6882a093-6831-445d-a884-f2ebc37aaa29", - "@type" : "aas:AssetInformation", - "https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind" : { - "@type" : "aas:AssetKind", - "@id" : "https://admin-shell.io/aas/3/0/RC02/AssetKind/Instance" - }, - "https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds" : [ ] - }, - "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { - "@language" : "en-us", - "@value" : "This is a test AAS" - } ], - "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { - "@language" : "de", - "@value" : "Anzeigename 2" - }, { - "@language" : "en", - "@value" : "Display Name 1" - } ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] - } ], - "https://admin-shell.io/aas/3/0/RC02/Environment/conceptdescriptions" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultConceptDescription/14b4a819-7ca0-4cb2-b2c7-33a1c443c899", - "@type" : "aas:ConceptDescription", - "https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultDataSpecification/66cf9a6c-e656-4c95-91be-2ddc1779ec71", - "@type" : "aas:EmbeddedDataSpecification", - "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation" : { - "@id" : "https://admin-shell.io/autogen/DefaultReference/251d9f19-b36b-4c39-b517-3d7e93bd8c96", - "@type" : "aas:Reference", - "https://admin-shell.io/aas/3/0/RC02/Reference/key" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultKey/ad4e8527-e002-4776-87ca-7049e7be440f", - "@type" : "aas:Key", - "https://admin-shell.io/aas/3/0/RC02/Key/value" : "https://example.org" - } ] - } , - "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent" : { - "@id" : "https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/5319d62e-7ca1-4954-addf-76db6bf1e241", - "@type" : "aas:DataSpecificationIEC61360", - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType" : { - "@type" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/DataTypeIEC61360", - "@id" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/RATIONAL" - }, - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition" : [ ], - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName" : [ ], - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName" : [ ] - }, - "https://admin-shell.io/aas/3/0/RC02/DataSpecification/id" : "http://example.org/DataSpecification1" - } ] - } ], - "https://admin-shell.io/aas/3/0/RC02/Environment/submodels" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultSubmodel/18810336-c309-42f8-9986-438f7068f0d6", - "@type" : "aas:Submodel", - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Referable/category" : "Example category", - "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { - "@language" : "en-us", - "@value" : "My Submodel" - } ], - "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { - "@language" : "en", - "@value" : "First Submodel Element name" - }, { - "@language" : "en", - "@value" : "Second Submodel Element name" - } ], - "https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] - } ] -} \ No newline at end of file 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 41afc0483..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 { - String id = "https://admin-shell.io/aas/3/0/Identifiable/id"; /** * Administrative information of an identifiable element. * @@ -56,7 +55,7 @@ public interface Identifiable extends Referable { * * @return Returns the String for the property id. */ - @IRI(id) + @IRI("https://admin-shell.io/aas/3/0/Identifiable/id") String getId(); /** From 9fd7db6ea3a58719c256d7e91fe30db5903b1099 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Mon, 29 Jan 2024 00:43:01 +0100 Subject: [PATCH 008/160] Add DataSpecificationIec61360 --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 256 ++++++++++++++++-- .../rdf/IncompatibleTypeException.java | 3 + ...ltAdministrativeInformationRDFHandler.java | 16 +- ...ltDataSpecificationIEC61360RDFHandler.java | 129 ++++++++- .../DefaultLangStringNameTypeRDFHandler.java | 30 +- .../DefaultLangStringTextTypeRDFHandler.java | 30 +- .../handlers/DefaultReferenceRDFHandler.java | 2 +- .../DefaultSubmodelElementRDFHandler.java | 120 ++++++++ ...tringDefinitionTypeIec61360RDFHandler.java | 37 +++ ...ngPreferredNameTypeIec61360RDFHandler.java | 37 +++ ...StringShortNameTypeIec61360RDFHandler.java | 37 +++ .../DefaultLevelTypeRDFHandler.java | 40 +++ .../DefaultValueListRDFHandler.java | 60 ++++ .../DefaultValueReferencePairRDFHandler.java | 42 +++ .../rdf/DataSpecificationIec61360Test.java | 118 ++++++++ .../v3/dataformat/rdf/SerializerTest.java | 100 ++++++- 16 files changed, 1009 insertions(+), 48 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java 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 index d75755bad..4646cebce 100644 --- 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 @@ -3,13 +3,14 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; /** * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. */ -public class AASNamespace { +public final class AASNamespace { public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; public static final Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); @@ -23,7 +24,7 @@ private AASNamespace() { * * @see AASNamespace.KeyTypes */ - public static class Key { + public static final class Key { /** * The key value, for example an IRDI or an URI */ @@ -34,19 +35,19 @@ public static class Key { public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); } - public static class Reference { + public static final class Reference { public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); } - public static class Referable { + public static final class Referable { public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); } - public static class Identifiable { + public static final class Identifiable { public static final Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); public static final Property administration = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/administration"); } @@ -63,7 +64,7 @@ public static class ConceptDescription { * * @see AASNamespace.Key */ - public static class KeyTypes { + public static final class KeyTypes { public static final Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); public static final Resource AssetAdministrationShell = @@ -110,23 +111,25 @@ public static class KeyTypes { ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); public static final Resource SubmodelElementList = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementList"); - public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI){ - if(stringIRI.equals(FragmentReference.getURI())){ + + public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI) { + if (stringIRI.equals(FragmentReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE; } - if(stringIRI.equals(GlobalReference.getURI())){ + if (stringIRI.equals(GlobalReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.GLOBAL_REFERENCE; } throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type){ - if(type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT.name())){ + + public static 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())){ + 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())){ + if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE.name())) { return FragmentReference; } @@ -134,32 +137,34 @@ public static Resource valueOf(String type){ } } - public static class ReferenceTypes { - public static org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes fromIRI(String stringIRI){ - if(stringIRI.equals(ModelReference.getURI())){ + public static final class ReferenceTypes { + public static final Resource ExternalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); + public static final 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())){ + if (stringIRI.equals(ExternalReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE; } throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type){ - if(type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE.name())){ + + public static 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())){ + if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.MODEL_REFERENCE.name())) { return ModelReference; } throw new IllegalArgumentException("Invalid ReferenceType provided."); } - public static final Resource ExternalReference = - ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); - public static final Resource ModelReference = - ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ModelReference"); } - public static class Types { + public static final class Types { public static final Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); @@ -236,4 +241,205 @@ public static class Types { ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); } + + public static final class LevelType { + public static final Property min = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/min"); + public static final Property nom = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/nom"); + public static final Property typ = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/typ"); + public static final Property max = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/max"); + } + + public static final class AbstractLangString { + public static final Property language = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/language"); + public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); + } + + public static final class ValueReferencePair { + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); + public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); + } + + public static final class ValueList { + public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); + } + + public static final class DataSpecificationIec61360 { + public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/value"); + public static final Property valueFormat = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueFormat"); + public static final Property definition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/definition"); + public static final Property dataType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/dataType"); + public static final Property symbol = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/symbol"); + public static final Property sourceOfDefinition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/sourceOfDefinition"); + public static final Property unitId = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unitId"); + public static final Property unit = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unit"); + public static final Property shortName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/shortName"); + public static final Property preferredName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/preferredName"); + public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); + } + + public static final class DataTypeIec61360 { + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Blob"); + public static final Resource Boolean = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Boolean"); + public static final Resource Date = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Date"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/File"); + public static final Resource Html = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Html"); + public static final Resource IntegerCount = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCount"); + public static final Resource IntegerCurrency = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCurrency"); + public static final Resource IntegerMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerMeasure"); + public static final Resource Irdi = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Irdi"); + public static final Resource Iri = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Iri"); + public static final Resource Rational = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Rational"); + public static final Resource RationalMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RationalMeasure"); + public static final Resource RealCount = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCount"); + public static final Resource RealCurrency = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCurrency"); + public static final Resource RealMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealMeasure"); + public static final Resource String = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/String"); + public static final Resource StringTranslatable = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/StringTranslatable"); + public static final Resource Time = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Time"); + public static final 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 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."); + } + } } 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 index 1b7cb3c4e..7c4da8781 100644 --- 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 @@ -4,4 +4,7 @@ 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/handlers/DefaultAdministrativeInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java index 2a3b2f74a..946b2d804 100644 --- 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 @@ -1,7 +1,12 @@ 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.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; 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.AdministrativeInformation; @@ -9,11 +14,20 @@ public class DefaultAdministrativeInformationRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(AdministrativeInformation key) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public AdministrativeInformation fromModel(Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + throw new IllegalArgumentException("Provided Resource is not a _"); + } + return null; } } 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 index 88093bff2..ae8985d0f 100644 --- 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 @@ -1,20 +1,137 @@ 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.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.DataSpecificationIec61360; +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.dataspecificationiec61360.*; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.builder.DataSpecificationIec61360Builder; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; public class DefaultDataSpecificationIEC61360RDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(DataSpecificationIec61360 object) { - return null; + 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() == false){ + 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() == false){ + 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() == false){ + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false){ + throw new IncompatibleTypeException("DataSpecificationIec61360"); + } + DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); + + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.preferredName)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.shortName)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.definition)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unit)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unitId)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.sourceOfDefinition)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.symbol)){ + + } + 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)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.valueList)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.levelType)){ + + } + + + 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 index e27ac069b..024be783d 100644 --- 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 @@ -1,20 +1,38 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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.dataformat.rdf.RDFHandler; -public class DefaultLangStringNameTypeRDFHandler implements RDFHandler{ +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; + +public class DefaultLangStringNameTypeRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(LangStringNameType object) { - return null; + 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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + return new DefaultRDFHandlerResult(model, subject); } @Override public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); + } + + return new DefaultLangStringNameType.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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 index 2d2c34397..04e55de72 100644 --- 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 @@ -1,19 +1,37 @@ 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.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.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{ +public class DefaultLangStringTextTypeRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(LangStringTextType object) { - return null; + 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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + return new DefaultRDFHandlerResult(model, subject); } @Override public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); + } + + return new DefaultLangStringTextType.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .build(); } } 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 index 6a760557e..5c8c93aab 100644 --- 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 @@ -42,7 +42,7 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); Map keysMap = new HashMap<>(); - NodeIterator keysIterator = model.listObjectsOfProperty(AASNamespace.Reference.keys); + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse,AASNamespace.Reference.keys); keysIterator.forEachRemaining(node->{ Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); 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..5a6c5e173 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java @@ -0,0 +1,120 @@ +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.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; + +public class DefaultSubmodelElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElement object) { + // it should be bottom up in hierarchy + if (object.getClass().isInstance(AnnotatedRelationshipElement.class)) { + return new DefaultAnnotatedRelationshipElementRDFHandler().toModel((AnnotatedRelationshipElement) object); + } + if (object.getClass().isInstance(RelationshipElement.class)) { + return new DefaultRelationshipElementRDFHandler().toModel((RelationshipElement) object); + } + if (object.getClass().isInstance(BasicEventElement.class)) { + return new DefaultBasicEventElementRDFHandler().toModel((BasicEventElement) object); + } + if (object.getClass().isInstance(Blob.class)) { + return new DefaultBlobRDFHandler().toModel((Blob) object); + } + if (object.getClass().isInstance(File.class)) { + return new DefaultFileRDFHandler().toModel((File) object); + } + if (object.getClass().isInstance(MultiLanguageProperty.class)) { + return new DefaultMultiLanguagePropertyRDFHandler().toModel((MultiLanguageProperty) object); + } + if (object.getClass().isInstance(Property.class)) { + return new DefaultPropertyRDFHandler().toModel((Property) object); + } + if (object.getClass().isInstance(Range.class)) { + return new DefaultRangeRDFHandler().toModel((Range) object); + } + if (object.getClass().isInstance(ReferenceElement.class)) { + return new DefaultReferenceElementRDFHandler().toModel((ReferenceElement) object); + } + if (object.getClass().isInstance(SubmodelElementCollection.class)) { + return new DefaultSubmodelElementCollectionRDFHandler().toModel((SubmodelElementCollection) object); + } + if (object.getClass().isInstance(SubmodelElementList.class)) { + return new DefaultSubmodelElementListRDFHandler().toModel((SubmodelElementList) object); + } + if (object.getClass().isInstance(Entity.class)) { + return new DefaultEntityRDFHandler().toModel((Entity) object); + } + if (object.getClass().isInstance(Capability.class)) { + return new DefaultCapabilityRDFHandler().toModel((Capability) object); + } + if (object.getClass().isInstance(Operation.class)) { + return new DefaultOperationRDFHandler().toModel((Operation) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known type"); + } + + @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/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..99018a3e6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringDefinitionTypeIec61360"); + } + + return new DefaultLangStringDefinitionTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..556783bf3 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringPreferredNameTypeIec61360"); + } + + return new DefaultLangStringPreferredNameTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..c77865651 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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.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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringShortNameTypeIec61360"); + } + + return new DefaultLangStringShortNameTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..a9a359ce3 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java @@ -0,0 +1,40 @@ +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) == false){ + throw new IllegalArgumentException("Provided Resource is not a LevelType"); + } + return new DefaultLevelType.Builder() + .min(model.getProperty(subjectToParse,AASNamespace.LevelType.min).getBoolean()) + .max(model.getProperty(subjectToParse,AASNamespace.LevelType.max).getBoolean()) + .nom(model.getProperty(subjectToParse,AASNamespace.LevelType.nom).getBoolean()) + .typ(model.getProperty(subjectToParse,AASNamespace.LevelType.typ).getBoolean()) + .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..e9c2657f2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java @@ -0,0 +1,60 @@ +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); + 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) == false) { + throw new IncompatibleTypeException("ValueList"); + } + 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); + }); + List valueReferencePairList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + valueReferencePairList.add(keysMap.get(index)); + } + return new DefaultValueList.Builder() + .valueReferencePairs(valueReferencePairList) + .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..56b152a94 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java @@ -0,0 +1,42 @@ +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); + model.add(subject, AASNamespace.ValueReferencePair.value, object.getValue()); + RDFSerializationResult referenceSerializationResult = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(referenceSerializationResult.getModel()); + model.add(subject,AASNamespace.ValueReferencePair.valueId,referenceSerializationResult.getResource()); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public ValueReferencePair fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false){ + throw new IncompatibleTypeException("ValueReferencePair"); + } + + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.valueId).getResource()); + return new DefaultValueReferencePair.Builder() + .value(model.getProperty(subjectToParse,AASNamespace.ValueReferencePair.value).getString()) + .valueId(reference) + .build(); + } +} 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..ea30c6c41 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java @@ -0,0 +1,118 @@ +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.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; + +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 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); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index e659e3f6e..649d76305 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -22,6 +22,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultDataSpecificationIEC61360RDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; @@ -55,7 +56,18 @@ public void testKey() throws IOException { @Test public void testReference() throws IncompatibleTypeException { - Reference reference = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).keys(Arrays.asList(new DefaultKey.Builder().value("https://example.com").type(KeyTypes.GLOBAL_REFERENCE).build(), new DefaultKey.Builder().value("fragment").type(KeyTypes.FRAGMENT_REFERENCE).build())).build(); + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(Arrays.asList( + 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(); @@ -82,13 +94,75 @@ public void simpleConceptDescription() throws IOException, IncompatibleTypeExcep @Test public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("complex").extensions(Arrays.asList(new DefaultExtension.Builder().name("extension1").value("extension1Value").build(), new DefaultExtension.Builder().name("extension2").value("extension2Value").build())).category("myCategory").idShort("exampleIdShort").displayName(Arrays.asList(new DefaultLangStringNameType.Builder().text("text in English").language("en").build(), new DefaultLangStringNameType.Builder().text("متن به فارسی").language("fa").build())).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("A long text in English").language("en").build(), new DefaultLangStringTextType.Builder().text("영어로 된 긴 텍스트").language("ko").build())).administration(new DefaultAdministrativeInformation.Builder().version("1").revision("0").creator(new DefaultReference.Builder().keys(Arrays.asList(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()).build()).isCaseOf(Arrays.asList(new DefaultReference.Builder().keys(new DefaultKey.Builder().value("https://example.com/outside").type(KeyTypes.GLOBAL_REFERENCE).build()).type(ReferenceTypes.EXTERNAL_REFERENCE).build())).embeddedDataSpecifications(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()).build()).dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder().levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()).unit("gram").symbol("g") + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("complex") + .extensions(Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build())) + .category("myCategory") + .idShort("exampleIdShort") + .displayName(Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build())) + .description(Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build())) + .administration(new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .creator(new DefaultReference.Builder().keys( + Arrays.asList(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()) + .build()) + .isCaseOf(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.com/outside") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .embeddedDataSpecifications(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()).build()) + .dataSpecificationContent( + new DefaultDataSpecificationIec61360.Builder() + .levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()) + .unit("gram") + .symbol("g") // .definition() // .shortName() // .preferredName() // .valueFormat() // .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); + .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); } @@ -108,4 +182,24 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE String output = new RDFSerializer().write(aasEnv); System.out.println(output); } + + @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); +// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert dataSpecificationIec61360.equals(recreatedDataSpecification); + } + } From 2bf6e8eca069193adae35a46ecad8717cdaaba3c Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 30 Jan 2024 17:39:10 +0100 Subject: [PATCH 009/160] Add ConceptDescription --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 291 ++++++++++++++++++ .../v3/dataformat/rdf/RDFPartialHandler.java | 2 +- ...ltAdministrativeInformationRDFHandler.java | 60 +++- ...ultAssetAdministrationShellRDFHandler.java | 19 +- .../DefaultConceptDescriptionRDFHandler.java | 77 +++-- ...ultDataSpecificationContentRDFHandler.java | 41 +++ ...ltDataSpecificationIEC61360RDFHandler.java | 159 +++++++--- ...ltEmbeddedDataSpecificationRDFHandler.java | 50 ++- .../handlers/DefaultExtensionRDFHandler.java | 87 +++++- .../handlers/DefaultReferenceRDFHandler.java | 6 +- .../DefaultSubmodelElementRDFHandler.java | 28 +- ...HasDataSpecificationRDFPartialHandler.java | 65 ++++ .../DefaultHasSemanticsRDFHandler.java | 21 -- .../DefaultHasSemanticsRDFPartialHandler.java | 68 ++++ .../DefaultIdentifiableRDFHandler.java | 49 --- .../DefaultIdentifiableRDFPartialHandler.java | 54 ++++ .../partial/DefaultReferableRDFHandler.java | 46 --- .../DefaultReferableRDFPartialHandler.java | 134 ++++++++ .../rdf/ConceptDescriptionTest.java | 55 ++++ .../rdf/DataSpecificationIec61360Test.java | 41 +++ .../v3/dataformat/rdf/SerializerTest.java | 152 ++++----- .../v3/dataformat/rdf/SerializerUtil.java | 171 ++++++++++ 22 files changed, 1344 insertions(+), 332 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasDataSpecificationRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java 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 index 4646cebce..d17d9713a 100644 --- 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 @@ -3,6 +3,7 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; @@ -40,6 +41,10 @@ public static final class Reference { public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); } + public static final class HasExtensions { + public static final Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); + } + public static final class Referable { public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); @@ -254,6 +259,14 @@ public static final class AbstractLangString { public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); } + public static final class Extension { + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/value"); + public static final Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/valueType"); + public static final Property refersTo = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/refersTo"); + public static final Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/name"); + + } + public static final class ValueReferencePair { public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); @@ -262,6 +275,35 @@ public static final class ValueReferencePair { public static final class ValueList { public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } + public static final class EmbeddedDataSpecification { + public static final Property dataSpecification = + ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); + public static final Property dataSpecificationContent = + ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); + } + public static final class HasDataSpecification { + public static final Property embeddedDataSpecifications = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); + } + public static final class HasSemantics { + public static final Property semanticId = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); + public static final Property supplementalSemanticIds = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); + + } + public static final class AdministrativeInformation { + public static final Property version = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); + public static final Property revision = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/revision"); + public static final Property creator = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); + public static final Property templateId = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); + public static final Property valueReferencePairs = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/valueReferencePairs"); + } public static final class DataSpecificationIec61360 { public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); @@ -439,6 +481,255 @@ public static Resource valueOf(String type) { return Timestamp; } + throw new IllegalArgumentException("Invalid DataTypeIec61360 provided."); + } + } + + public static final class DataTypeDefXsd { + public static final Resource AnyUri = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/AnyUri"); + public static final Resource Base64Binary = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Base64Binary"); + public static final Resource Boolean = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Boolean"); + public static final Resource Byte = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Byte"); + public static final Resource Date = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Date"); + public static final Resource DateTime = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/DateTime"); + public static final Resource Decimal = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Decimal"); + public static final Resource Double = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Double"); + public static final Resource Duration = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Duration"); + public static final Resource Float = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Float"); + public static final Resource GDay = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GDay"); + public static final Resource GMonth = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonth"); + public static final Resource GMonthDay = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonthDay"); + public static final Resource GYear = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYear"); + public static final Resource GYearMonth = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYearMonth"); + public static final Resource HexBinary = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/HexBinary"); + public static final Resource Int = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Int"); + public static final Resource Integer = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Integer"); + public static final Resource Long = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Long"); + public static final Resource NegativeInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NegativeInteger"); + public static final Resource NonNegativeInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonNegativeInteger"); + public static final Resource NonPositiveInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonPositiveInteger"); + public static final Resource PositiveInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/PositiveInteger"); + public static final Resource Short = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Short"); + public static final Resource String = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/String"); + public static final Resource Time = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Time"); + public static final Resource UnsignedByte = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedByte"); + public static final Resource UnsignedInt = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedInt"); + public static final Resource UnsignedLong = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedLong"); + public static final 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 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."); } } 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 index 4f8750612..aa7b3dac3 100644 --- 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 @@ -6,5 +6,5 @@ public interface RDFPartialHandler { public void partialToModel(T object, Model model, Resource parentNode); - public T partialFromModel(T object, Model model, Resource subjectToParse); + public 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/handlers/DefaultAdministrativeInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java index 946b2d804..6fcdd5eca 100644 --- 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 @@ -5,29 +5,67 @@ 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.AASNamespace; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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 key) { + public RDFSerializationResult toModel(AdministrativeInformation object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + 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,object.getVersion()); + } + if(object.getRevision()!=null){ + model.addLiteral(subject,AASNamespace.AdministrativeInformation.revision,object.getRevision()); + } + if(object.getTemplateId()!=null){ + model.addLiteral(subject,AASNamespace.AdministrativeInformation.templateId,object.getTemplateId()); + } + if(object.getCreator()!=null){ + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); + model.addLiteral(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) { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ - throw new IllegalArgumentException("Provided Resource is not a _"); + public AdministrativeInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AdministrativeInformation"); } - - return null; + 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/DefaultAssetAdministrationShellRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java index 37e15e48d..c4dbd2074 100644 --- 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 @@ -4,23 +4,28 @@ import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; public class DefaultAssetAdministrationShellRDFHandler implements RDFHandler { @Override - public RDFSerializationResult toModel(AssetAdministrationShell key) { + public RDFSerializationResult toModel(AssetAdministrationShell object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - return null; + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override - public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) { + public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AssetAdministrationShell"); + } + return null; } + } 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 index c70b60406..1796d4087 100644 --- 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 @@ -1,41 +1,49 @@ 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.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.DefaultIdentifiableRDFHandler; +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.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; 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 key) { + public RDFSerializationResult toModel(ConceptDescription object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - Resource conceptDescriptionResource = model.createResource(key.getId()); + Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - //HasDataSpecification - if (key.getEmbeddedDataSpecifications() != null && key.getEmbeddedDataSpecifications().isEmpty() == false) { + if(object.getIsCaseOf()!=null && object.getIsCaseOf().isEmpty() == false) { + 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 DefaultIdentifiableRDFHandler().partialToModel(key, model, conceptDescriptionResource); - - for (Reference reference : key.getIsCaseOf()) { - // TODO: Optional ordering - RDFSerializationResult result = new DefaultReferenceRDFHandler().toModel(reference); - model.add(result.getModel()); - conceptDescriptionResource.addProperty(AASNamespace.ConceptDescription.isCaseOf, result.getResource()); - } + //Identifiable + new DefaultIdentifiableRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource); + //HasDataSpecification + new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource); return new DefaultRDFHandlerResult(model, conceptDescriptionResource); } @@ -44,9 +52,32 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { throw new IncompatibleTypeException(); } - ConceptDescription build = new DefaultConceptDescription.Builder() - .build(); - new DefaultIdentifiableRDFHandler().partialFromModel(build, model, subjectToParse); - return build; + 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); + }); + 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..4ecda069d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java @@ -0,0 +1,41 @@ +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.dataformat.rdf.handlers.DefaultAnnotatedRelationshipElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultRelationshipElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; + +public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationContent object) { + if (DataSpecificationIec61360.class.isInstance(object)) { + return new DefaultDataSpecificationIEC61360RDFHandler().toModel((DataSpecificationIec61360) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known type"); + } + + @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 SubmodelElement"); + } +} 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 index ae8985d0f..1ce328b78 100644 --- 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 @@ -1,9 +1,7 @@ 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.*; 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.dataspecificationiec61360.*; @@ -11,6 +9,11 @@ import org.eclipse.digitaltwin.aas4j.v3.model.builder.DataSpecificationIec61360Builder; 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) { @@ -20,7 +23,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.DataSpecificationIec61360); - if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false){ + if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false) { int index = 0; for (LangStringPreferredNameTypeIec61360 langString : object.getPreferredName()) { RDFSerializationResult res = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().toModel(langString); @@ -30,7 +33,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getShortName() != null && object.getShortName().isEmpty() == false){ + if (object.getShortName() != null && object.getShortName().isEmpty() == false) { int index = 0; for (LangStringShortNameTypeIec61360 langString : object.getShortName()) { RDFSerializationResult res = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(langString); @@ -40,7 +43,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getDefinition() != null && object.getDefinition().isEmpty() == false){ + if (object.getDefinition() != null && object.getDefinition().isEmpty() == false) { int index = 0; for (LangStringDefinitionTypeIec61360 langString : object.getDefinition()) { RDFSerializationResult res = new DefaultLangStringDefinitionTypeIec61360RDFHandler().toModel(langString); @@ -50,37 +53,37 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getUnit() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.unit,object.getUnit()); + if (object.getUnit() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.unit, object.getUnit()); } - if (object.getUnitId() != null ){ + if (object.getUnitId() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getUnitId()); - model.add(subject,AASNamespace.DataSpecificationIec61360.unitId,res.getResource()); + 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.getSourceOfDefinition() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.sourceOfDefinition, object.getSourceOfDefinition()); } - if (object.getSymbol() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.symbol,object.getSymbol()); + if (object.getSymbol() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.symbol, object.getSymbol()); } - if (object.getDataType() != null ){ + 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.getValueFormat() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.valueFormat, object.getValueFormat()); } - if (object.getValue() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.value,object.getValue()); + if (object.getValue() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.value, object.getValue()); } - if (object.getValueList() != null ){ + if (object.getValueList() != null) { RDFSerializationResult res = new DefaultValueListRDFHandler().toModel(object.getValueList()); - model.add(subject,AASNamespace.DataSpecificationIec61360.valueList,res.getResource()); + model.add(subject, AASNamespace.DataSpecificationIec61360.valueList, res.getResource()); model.add(res.getModel()); } - if (object.getLevelType() != null ){ + if (object.getLevelType() != null) { RDFSerializationResult res = new DefaultLevelTypeRDFHandler().toModel(object.getLevelType()); - model.add(subject,AASNamespace.DataSpecificationIec61360.levelType,res.getResource()); + model.add(subject, AASNamespace.DataSpecificationIec61360.levelType, res.getResource()); model.add(res.getModel()); } return new DefaultRDFHandlerResult(model, subject); @@ -88,47 +91,105 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { @Override public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false) { throw new IncompatibleTypeException("DataSpecificationIec61360"); } DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.preferredName)){ - - } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.shortName)){ - - } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.definition)){ - + 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()); + } 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.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); + }); + 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); + }); + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unit)) { + builder.unit(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unit).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unitId)){ - + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition)) { + builder.sourceOfDefinition(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.symbol)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol)) { + builder.symbol(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.dataType)){ + 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.valueFormat)) { + builder.valueFormat(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.valueFormat).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.value)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.value).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.valueList)){ - + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType)) { + LevelType levelType = new DefaultLevelTypeRDFHandler() + .fromModel(model, model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType).getResource()); + builder.levelType(levelType); } 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 index 65db7671c..22a115a98 100644 --- 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 @@ -1,20 +1,60 @@ 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.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.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.DataSpecificationIec61360; 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) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification) == false) { + 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/DefaultExtensionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java index d9a1f76b2..6d94b8f3c 100644 --- 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 @@ -1,20 +1,93 @@ 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.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.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.DefaultLangStringDefinitionTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; +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) { - return null; + 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, object.getName()); + } + if (object.getValue() != null) { + model.addLiteral(subject, AASNamespace.Extension.value, 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() != false) { + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension) == false) { + 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); + }); + 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/DefaultReferenceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java index 5c8c93aab..802b1b4f7 100644 --- 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 @@ -21,7 +21,9 @@ public RDFSerializationResult toModel(Reference key) { } Resource subject = model.createResource(); subject.addProperty(RDF.type,AASNamespace.Types.Reference); - subject.addProperty(AASNamespace.Reference.type,AASNamespace.ReferenceTypes.valueOf(key.getType().name())); + 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); @@ -38,7 +40,7 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false){ - throw new IncompatibleTypeException(); + throw new IncompatibleTypeException("Reference"); } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); Map keysMap = new HashMap<>(); 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 index 5a6c5e173..101435189 100644 --- 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 @@ -18,46 +18,46 @@ public class DefaultSubmodelElementRDFHandler implements RDFHandler { + @Override + public void partialToModel(HasDataSpecification object, Model model, Resource parentNode) { + if (object.getEmbeddedDataSpecifications() != null && object.getEmbeddedDataSpecifications().isEmpty() == false) { + 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); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index,key); + }); + List keys = new ArrayList<>(); + for(int index=0;index { - - @Override - public void partialToModel(HasSemantics object, Model model, Resource parentNode) { - - } - - @Override - public HasSemantics partialFromModel(HasSemantics object, Model model, Resource subjectToParse) { - return null; - } -} 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..e4387aadd --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java @@ -0,0 +1,68 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultExtensionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringTextTypeRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +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()==false){ + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setSupplementalSemanticIds(langStringList); + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java deleted file mode 100644 index ca4c71697..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; - -import org.apache.jena.rdf.model.*; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; -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.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; - -import java.util.HashMap; -import java.util.Map; - -public class DefaultIdentifiableRDFHandler implements RDFPartialHandler { - - @Override - public void partialToModel(Identifiable object, Model model, Resource parentNode) { - //TODO: Side effect - parentNode.addProperty(AASNamespace.Identifiable.id, object.getId()); - - RDFSerializationResult administrativeResult = new DefaultAdministrativeInformationRDFHandler() - .toModel(object.getAdministration()); - if(object.getAdministration()!=null){ - parentNode.addProperty(AASNamespace.Identifiable.administration, administrativeResult.getResource()); - model.add(administrativeResult.getModel()); - } - - new DefaultReferableRDFHandler().partialToModel(object,model,parentNode); - } - - @Override - public Identifiable partialFromModel(Identifiable object, Model model, Resource subjectToParse) { - //TODO: Side effect - String id = model.getProperty(subjectToParse, AASNamespace.Identifiable.id).getString(); - object.setId(id); - - Statement administrationStatement = model.getProperty(subjectToParse, AASNamespace.Identifiable.administration); - if(administrationStatement!=null) { - Resource administrationToParse = administrationStatement.getResource(); - AdministrativeInformation administrativeInformation = new DefaultAdministrativeInformationRDFHandler().fromModel(model, administrationToParse); - object.setAdministration(administrativeInformation); - } - - //Referable - new DefaultReferableRDFHandler().partialFromModel(object,model,subjectToParse); - 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..d53da392a --- /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.*; +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; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +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/DefaultReferableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java deleted file mode 100644 index 23ae9b4c8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; - -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.DefaultAdministrativeInformationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; - -public class DefaultReferableRDFHandler 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() == false){ - - } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ - - } - - } - - @Override - public Referable partialFromModel(Referable object, Model model, Resource subjectToParse) { - if (object.getIdShort() != null) { - - } - if (object.getCategory() != null) { - - } - if (object.getDescription() != null && object.getDescription().isEmpty() == false){ - - } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ - - } - 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..8c00a9f19 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java @@ -0,0 +1,134 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultExtensionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; +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.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +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() == false) { + 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() == false) { + 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() == false) { + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setDescription(langStringList); + } + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setDisplayName(langStringList); + } + + //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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setExtensions(langStringList); + } + return object; + } +} 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..a5bf3cbce --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java @@ -0,0 +1,55 @@ +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.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; +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.Arrays; + +public class ConceptDescriptionTest { + + @Test + public void simpleConceptDescription() throws IOException, IncompatibleTypeException { + ConceptDescription object = new DefaultConceptDescription.Builder() + .id("simple") + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + + + @Test + public void complexConceptDescription() throws IncompatibleTypeException { + ConceptDescription object = 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.getEmbeddedDataSpecifications()) + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert object.equals(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 index ea30c6c41..e5b89f53a 100644 --- 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 @@ -5,6 +5,7 @@ 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; @@ -14,6 +15,8 @@ import java.util.List; +import static org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.SerializerUtil.getDataSpecificationIec61360; + public class DataSpecificationIec61360Test { @Test @@ -40,6 +43,29 @@ public void testLevelType() throws IncompatibleTypeException { 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 testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() @@ -115,4 +141,19 @@ public void testMinimalDataSpecificationIec61360() throws IncompatibleTypeExcept 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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 649d76305..ca538d270 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -21,11 +21,7 @@ import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultDataSpecificationIEC61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.*; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; @@ -42,7 +38,10 @@ public class SerializerTest { @Test public void testKey() throws IOException { - Key simpleKey = new DefaultKey.Builder().value("simple").type(KeyTypes.GLOBAL_REFERENCE).build(); + 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(); @@ -54,6 +53,54 @@ public void testKey() throws IOException { assert simpleKey.equals(recreatedKey); } + @Test + public void testAdministrativeInformationSimple() 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 testAdministrativeInformationComplex() 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() @@ -77,95 +124,6 @@ public void testReference() throws IncompatibleTypeException { assert reference.equals(recreatedKey); } - @Test - public void simpleConceptDescription() throws IOException, IncompatibleTypeException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("simple").build(); - - RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(conceptDescription); - Model model = rdfSerializationResult.getModel(); - model.write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert model.contains(createdResource, RDF.type, AASNamespace.Types.ConceptDescription); - assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); - - ConceptDescription recreatedConceptDescription = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); - assert conceptDescription.equals(recreatedConceptDescription); - } - - @Test - public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("complex") - .extensions(Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build())) - .category("myCategory") - .idShort("exampleIdShort") - .displayName(Arrays.asList( - new DefaultLangStringNameType.Builder() - .text("text in English") - .language("en") - .build(), - new DefaultLangStringNameType.Builder() - .text("متن به فارسی") - .language("fa") - .build())) - .description(Arrays.asList( - new DefaultLangStringTextType.Builder() - .text("A long text in English") - .language("en") - .build(), - new DefaultLangStringTextType.Builder() - .text("영어로 된 긴 텍스트") - .language("ko") - .build())) - .administration(new DefaultAdministrativeInformation.Builder() - .version("1") - .revision("0") - .creator(new DefaultReference.Builder().keys( - Arrays.asList(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()) - .build()) - .isCaseOf(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.com/outside") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) - .embeddedDataSpecifications(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()).build()) - .dataSpecificationContent( - new DefaultDataSpecificationIec61360.Builder() - .levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()) - .unit("gram") - .symbol("g") -// .definition() -// .shortName() -// .preferredName() -// .valueFormat() -// .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); - - - } @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -187,8 +145,8 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 dataSpecificationIec61360 = new DefaultDataSpecificationIec61360.Builder() .preferredName(List.of(new DefaultLangStringPreferredNameTypeIec61360.Builder() - .language("en") - .text("preferred name") + .language("en") + .text("preferred name") .build())) .build(); RDFSerializationResult rdfSerializationResult = new DefaultDataSpecificationIEC61360RDFHandler().toModel(dataSpecificationIec61360); 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 index e970d8e9f..74ea03f38 100644 --- 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 @@ -19,8 +19,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; import org.apache.commons.io.IOUtils; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; /** * Helper class for Serializer Tests @@ -42,4 +46,171 @@ public static String stripWhitespaces(String input) { return input.replaceAll("\\s+", ""); } + public static DefaultDataSpecificationIec61360 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 Arrays.asList( + 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(new DefaultReference.Builder().keys( + Arrays.asList(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()) + .build(); + } + + static List getDescriptions() { + return Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build()); + } + + static List getDisplayNames() { + return Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build()); + } + + static List getExtensionList() { + return Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build()); + } } From beefb83d1fb8cb0cd55da1e03021515e5eac27e4 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 15:50:19 +0100 Subject: [PATCH 010/160] Add AssetAdministrationShell --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 381 ++++++++++++------ ...nnotatedRelationshipElementRDFHandler.java | 18 +- ...ultAssetAdministrationShellRDFHandler.java | 80 +++- .../DefaultAssetInformationRDFHandler.java | 97 ++++- .../handlers/DefaultExtensionRDFHandler.java | 2 +- .../handlers/DefaultQualifierRDFHandler.java | 71 +++- .../handlers/DefaultResourceRDFHandler.java | 43 ++ .../handlers/DefaultResrouceRDFHandler.java | 19 - .../DefaultSpecificAssetIdRDFHandler.java | 55 ++- .../rdf/DataSpecificationIec61360Test.java | 18 + .../v3/dataformat/rdf/SerializerTest.java | 135 ++++++- .../v3/dataformat/rdf/SerializerUtil.java | 146 ++++++- 12 files changed, 866 insertions(+), 199 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java 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 index d17d9713a..93c63ddf4 100644 --- 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 @@ -1,15 +1,12 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; /** - * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. + * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. */ public final class AASNamespace { public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; @@ -70,51 +67,51 @@ public static class ConceptDescription { * @see AASNamespace.Key */ public static final class KeyTypes { - public static final Resource AnnotatedRelationshipElement = + public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); - public static final Resource AssetAdministrationShell = + public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AssetAdministrationShell"); - public static final Resource BasicEventElement = + public static final org.apache.jena.rdf.model.Resource BasicEventElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/BasicEventElement"); - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Blob"); - public static final Resource Capability = + public static final org.apache.jena.rdf.model.Resource Capability = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Capability"); - public static final Resource ConceptDescription = + public static final org.apache.jena.rdf.model.Resource ConceptDescription = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ConceptDescription"); - public static final Resource DataElement = + public static final org.apache.jena.rdf.model.Resource DataElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/DataElement"); - public static final Resource Entity = + public static final org.apache.jena.rdf.model.Resource Entity = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Entity"); - public static final Resource EventElement = + public static final org.apache.jena.rdf.model.Resource EventElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/EventElement"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/File"); - public static final Resource FragmentReference = + public static final org.apache.jena.rdf.model.Resource FragmentReference = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/FragmentReference"); - public static final Resource GlobalReference = + public static final org.apache.jena.rdf.model.Resource GlobalReference = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/GlobalReference"); - public static final Resource Identifiable = + public static final org.apache.jena.rdf.model.Resource Identifiable = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Identifiable"); - public static final Resource MultiLanguageProperty = + public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/MultiLanguageProperty"); - public static final Resource Operation = + public static final org.apache.jena.rdf.model.Resource Operation = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Operation"); - public static final Resource Property = + public static final org.apache.jena.rdf.model.Resource Property = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Property"); - public static final Resource Range = + public static final org.apache.jena.rdf.model.Resource Range = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Range"); - public static final Resource ReferenceElement = + public static final org.apache.jena.rdf.model.Resource ReferenceElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ReferenceElement"); - public static final Resource RelationshipElement = + public static final org.apache.jena.rdf.model.Resource RelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/RelationshipElement"); - public static final Resource Submodel = + public static final org.apache.jena.rdf.model.Resource Submodel = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Submodel"); - public static final Resource SubmodelElement = + public static final org.apache.jena.rdf.model.Resource SubmodelElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElement"); - public static final Resource SubmodelElementCollection = + public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); - public static final Resource SubmodelElementList = + 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) { @@ -127,7 +124,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String str throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -143,9 +140,9 @@ public static Resource valueOf(String type) { } public static final class ReferenceTypes { - public static final Resource ExternalReference = + public static final org.apache.jena.rdf.model.Resource ExternalReference = ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); - public static final Resource ModelReference = + 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) { @@ -158,7 +155,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes fromIRI(Stri throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -171,78 +168,78 @@ public static Resource valueOf(String type) { public static final class Types { - public static final Resource AdministrativeInformation = + public static final org.apache.jena.rdf.model.Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); - public static final Resource AnnotatedRelationshipElement = + public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "AnnotatedRelationshipElement"); - public static final Resource AssetAdministrationShell = + public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell = ResourceFactory.createResource(AAS_NAMESPACE + "AssetAdministrationShell"); - public static final Resource AssetInformation = + public static final org.apache.jena.rdf.model.Resource AssetInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AssetInformation"); - public static final Resource BasicEventElement = + public static final org.apache.jena.rdf.model.Resource BasicEventElement = ResourceFactory.createResource(AAS_NAMESPACE + "BasicEventElement"); - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "Blob"); - public static final Resource Capability = + public static final org.apache.jena.rdf.model.Resource Capability = ResourceFactory.createResource(AAS_NAMESPACE + "Capability"); - public static final Resource ConceptDescription = + public static final org.apache.jena.rdf.model.Resource ConceptDescription = ResourceFactory.createResource(AAS_NAMESPACE + "ConceptDescription"); - public static final Resource DataSpecificationIec61360 = + public static final org.apache.jena.rdf.model.Resource DataSpecificationIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "DataSpecificationIec61360"); - public static final Resource EmbeddedDataSpecification = + public static final org.apache.jena.rdf.model.Resource EmbeddedDataSpecification = ResourceFactory.createResource(AAS_NAMESPACE + "EmbeddedDataSpecification"); - public static final Resource Entity = + public static final org.apache.jena.rdf.model.Resource Entity = ResourceFactory.createResource(AAS_NAMESPACE + "Entity"); - public static final Resource Extension = + public static final org.apache.jena.rdf.model.Resource Extension = ResourceFactory.createResource(AAS_NAMESPACE + "Extension"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "File"); - public static final Resource Key = + public static final org.apache.jena.rdf.model.Resource Key = ResourceFactory.createResource(AAS_NAMESPACE + "Key"); - public static final Resource LangStringDefinitionTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringDefinitionTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringDefinitionTypeIec61360"); - public static final Resource LangStringNameType = + public static final org.apache.jena.rdf.model.Resource LangStringNameType = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringNameType"); - public static final Resource LangStringPreferredNameTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringPreferredNameTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringPreferredNameTypeIec61360"); - public static final Resource LangStringShortNameTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringShortNameTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringShortNameTypeIec61360"); - public static final Resource LangStringTextType = + public static final org.apache.jena.rdf.model.Resource LangStringTextType = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringTextType"); - public static final Resource LevelType = + public static final org.apache.jena.rdf.model.Resource LevelType = ResourceFactory.createResource(AAS_NAMESPACE + "LevelType"); - public static final Resource MultiLanguageProperty = + public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty = ResourceFactory.createResource(AAS_NAMESPACE + "MultiLanguageProperty"); - public static final Resource Operation = + public static final org.apache.jena.rdf.model.Resource Operation = ResourceFactory.createResource(AAS_NAMESPACE + "Operation"); - public static final Resource OperationVariable = + public static final org.apache.jena.rdf.model.Resource OperationVariable = ResourceFactory.createResource(AAS_NAMESPACE + "OperationVariable"); - public static final Resource Property = + public static final org.apache.jena.rdf.model.Resource Property = ResourceFactory.createResource(AAS_NAMESPACE + "Property"); - public static final Resource Qualifier = + public static final org.apache.jena.rdf.model.Resource Qualifier = ResourceFactory.createResource(AAS_NAMESPACE + "Qualifier"); - public static final Resource Range = + public static final org.apache.jena.rdf.model.Resource Range = ResourceFactory.createResource(AAS_NAMESPACE + "Range"); - public static final Resource Reference = + public static final org.apache.jena.rdf.model.Resource Reference = ResourceFactory.createResource(AAS_NAMESPACE + "Reference"); - public static final Resource ReferenceElement = + public static final org.apache.jena.rdf.model.Resource ReferenceElement = ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceElement"); - public static final Resource RelationshipElement = + public static final org.apache.jena.rdf.model.Resource RelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "RelationshipElement"); - public static final Resource Resource = + public static final org.apache.jena.rdf.model.Resource Resource = ResourceFactory.createResource(AAS_NAMESPACE + "Resource"); - public static final Resource SpecificAssetId = + public static final org.apache.jena.rdf.model.Resource SpecificAssetId = ResourceFactory.createResource(AAS_NAMESPACE + "SpecificAssetId"); - public static final Resource Submodel = + public static final org.apache.jena.rdf.model.Resource Submodel = ResourceFactory.createResource(AAS_NAMESPACE + "Submodel"); - public static final Resource SubmodelElementCollection = + public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection = ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementCollection"); - public static final Resource SubmodelElementList = + public static final org.apache.jena.rdf.model.Resource SubmodelElementList = ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementList"); - public static final Resource ValueList = + public static final org.apache.jena.rdf.model.Resource ValueList = ResourceFactory.createResource(AAS_NAMESPACE + "ValueList"); - public static final Resource ValueReferencePair = + public static final org.apache.jena.rdf.model.Resource ValueReferencePair = ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); } @@ -275,16 +272,19 @@ public static final class ValueReferencePair { public static final class ValueList { public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } + public static final class EmbeddedDataSpecification { public static final Property dataSpecification = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); public static final Property dataSpecificationContent = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); } + public static final class HasDataSpecification { public static final Property embeddedDataSpecifications = ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); } + public static final class HasSemantics { public static final Property semanticId = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); @@ -292,6 +292,28 @@ public static final class HasSemantics { ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); } + + public static final class Qualifiable { + public static final Property qualifiers = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifiable/qualifiers"); + + } + + public static final class Qualifier { + public static final Property kind = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/kind"); + public static final Property type = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/type"); + public static final Property value = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/value"); + public static final Property valueId = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueId"); + public static final Property valueType = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueType"); + + + } + public static final class AdministrativeInformation { public static final Property version = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); @@ -301,8 +323,46 @@ public static final class AdministrativeInformation { ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); public static final Property templateId = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); - public static final Property valueReferencePairs = - ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/valueReferencePairs"); + } + + public static final class SpecificAssetId { + public static final Property externalSubjectId = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/externalSubjectId"); + public static final Property name = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/name"); + public static final Property value = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/value"); + } + + public static final class AssetAdministrationShell { + public static final Property assetInformation = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); + public static final Property derivedFrom = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/derivedFrom"); + public static final Property submodels = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/submodels"); + } + + public static final class AssetInformation { + public static final Property assetType = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetType"); + public static final Property defaultThumbnail = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/defaultThumbnail"); + public static final Property globalAssetId = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/globalAssetId"); + public static final Property specificAssetIds = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/specificAssetIds"); + + public static final Property assetKind = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetKind"); + + } + + public static final class Resource { + public static final Property contentType = + ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/contentType"); + public static final Property path = + ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/path"); } public static final class DataSpecificationIec61360 { @@ -320,44 +380,80 @@ public static final class DataSpecificationIec61360 { public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); } + 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 DataTypeIec61360 { - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Blob"); - public static final Resource Boolean = + public static final org.apache.jena.rdf.model.Resource Boolean = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Boolean"); - public static final Resource Date = + public static final org.apache.jena.rdf.model.Resource Date = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Date"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/File"); - public static final Resource Html = + public static final org.apache.jena.rdf.model.Resource Html = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Html"); - public static final Resource IntegerCount = + public static final org.apache.jena.rdf.model.Resource IntegerCount = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCount"); - public static final Resource IntegerCurrency = + public static final org.apache.jena.rdf.model.Resource IntegerCurrency = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCurrency"); - public static final Resource IntegerMeasure = + public static final org.apache.jena.rdf.model.Resource IntegerMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerMeasure"); - public static final Resource Irdi = + public static final org.apache.jena.rdf.model.Resource Irdi = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Irdi"); - public static final Resource Iri = + public static final org.apache.jena.rdf.model.Resource Iri = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Iri"); - public static final Resource Rational = + public static final org.apache.jena.rdf.model.Resource Rational = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Rational"); - public static final Resource RationalMeasure = + public static final org.apache.jena.rdf.model.Resource RationalMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RationalMeasure"); - public static final Resource RealCount = + public static final org.apache.jena.rdf.model.Resource RealCount = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCount"); - public static final Resource RealCurrency = + public static final org.apache.jena.rdf.model.Resource RealCurrency = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCurrency"); - public static final Resource RealMeasure = + public static final org.apache.jena.rdf.model.Resource RealMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealMeasure"); - public static final Resource String = + public static final org.apache.jena.rdf.model.Resource String = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/String"); - public static final Resource StringTranslatable = + public static final org.apache.jena.rdf.model.Resource StringTranslatable = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/StringTranslatable"); - public static final Resource Time = + public static final org.apache.jena.rdf.model.Resource Time = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Time"); - public static final Resource Timestamp = + 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) { @@ -422,7 +518,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360 fromIRI(St throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -486,65 +582,65 @@ public static Resource valueOf(String type) { } public static final class DataTypeDefXsd { - public static final Resource AnyUri = + public static final org.apache.jena.rdf.model.Resource AnyUri = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/AnyUri"); - public static final Resource Base64Binary = + public static final org.apache.jena.rdf.model.Resource Base64Binary = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Base64Binary"); - public static final Resource Boolean = + public static final org.apache.jena.rdf.model.Resource Boolean = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Boolean"); - public static final Resource Byte = + public static final org.apache.jena.rdf.model.Resource Byte = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Byte"); - public static final Resource Date = + public static final org.apache.jena.rdf.model.Resource Date = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Date"); - public static final Resource DateTime = + public static final org.apache.jena.rdf.model.Resource DateTime = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/DateTime"); - public static final Resource Decimal = + public static final org.apache.jena.rdf.model.Resource Decimal = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Decimal"); - public static final Resource Double = + public static final org.apache.jena.rdf.model.Resource Double = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Double"); - public static final Resource Duration = + public static final org.apache.jena.rdf.model.Resource Duration = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Duration"); - public static final Resource Float = + public static final org.apache.jena.rdf.model.Resource Float = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Float"); - public static final Resource GDay = + public static final org.apache.jena.rdf.model.Resource GDay = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GDay"); - public static final Resource GMonth = + public static final org.apache.jena.rdf.model.Resource GMonth = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonth"); - public static final Resource GMonthDay = + public static final org.apache.jena.rdf.model.Resource GMonthDay = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonthDay"); - public static final Resource GYear = + public static final org.apache.jena.rdf.model.Resource GYear = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYear"); - public static final Resource GYearMonth = + public static final org.apache.jena.rdf.model.Resource GYearMonth = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYearMonth"); - public static final Resource HexBinary = + public static final org.apache.jena.rdf.model.Resource HexBinary = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/HexBinary"); - public static final Resource Int = + public static final org.apache.jena.rdf.model.Resource Int = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Int"); - public static final Resource Integer = + public static final org.apache.jena.rdf.model.Resource Integer = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Integer"); - public static final Resource Long = + public static final org.apache.jena.rdf.model.Resource Long = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Long"); - public static final Resource NegativeInteger = + public static final org.apache.jena.rdf.model.Resource NegativeInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NegativeInteger"); - public static final Resource NonNegativeInteger = + public static final org.apache.jena.rdf.model.Resource NonNegativeInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonNegativeInteger"); - public static final Resource NonPositiveInteger = + public static final org.apache.jena.rdf.model.Resource NonPositiveInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonPositiveInteger"); - public static final Resource PositiveInteger = + public static final org.apache.jena.rdf.model.Resource PositiveInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/PositiveInteger"); - public static final Resource Short = + public static final org.apache.jena.rdf.model.Resource Short = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Short"); - public static final Resource String = + public static final org.apache.jena.rdf.model.Resource String = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/String"); - public static final Resource Time = + public static final org.apache.jena.rdf.model.Resource Time = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Time"); - public static final Resource UnsignedByte = + public static final org.apache.jena.rdf.model.Resource UnsignedByte = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedByte"); - public static final Resource UnsignedInt = + public static final org.apache.jena.rdf.model.Resource UnsignedInt = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedInt"); - public static final Resource UnsignedLong = + public static final org.apache.jena.rdf.model.Resource UnsignedLong = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedLong"); - public static final Resource UnsignedShort = + public static final org.apache.jena.rdf.model.Resource UnsignedShort = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedShort"); @@ -643,7 +739,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd fromIRI(Stri throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -732,5 +828,48 @@ public static Resource valueOf(String type) { 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/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java index aa9c77a42..d33586fe7 100644 --- 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 @@ -1,20 +1,30 @@ 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.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.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.AnnotatedRelationshipElement; public class DefaultAnnotatedRelationshipElementRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AssetAdministrationShell"); + } + return null; } } 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 index c4dbd2074..92676c503 100644 --- 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 @@ -1,12 +1,18 @@ 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.*; 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.AssetAdministrationShell; +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.*; +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 @@ -16,16 +22,76 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); + 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() == false){ + 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.AdministrativeInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false){ throw new IncompatibleTypeException("AssetAdministrationShell"); } - - return null; + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.submodels(langStringList); + } + 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 index e808db27c..e3ce43a99 100644 --- 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 @@ -1,20 +1,103 @@ 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.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.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.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +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) { - return null; + 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() == 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.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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false){ + 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); + }); + 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/DefaultExtensionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java index 6d94b8f3c..873defd48 100644 --- 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 @@ -35,7 +35,7 @@ public RDFSerializationResult toModel(Extension object) { model.add(subject, AASNamespace.Extension.valueType, AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); } - if (object.getRefersTo() != null && object.getRefersTo().isEmpty() != false) { + if (object.getRefersTo() != null && object.getRefersTo().isEmpty() == false) { int index = 0; for (Reference reference : object.getRefersTo()) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(reference); 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 index 5e4639a23..b08979b7d 100644 --- 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 @@ -1,20 +1,77 @@ 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.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.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.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) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier) == false) { + 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/DefaultResourceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java new file mode 100644 index 000000000..f4622e7fb --- /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) == false){ + 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/DefaultResrouceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java deleted file mode 100644 index e146db227..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; - -import org.apache.jena.rdf.model.Model; -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.Resource; - -public class DefaultResrouceRDFHandler implements RDFHandler { - @Override - public RDFSerializationResult toModel(Resource object) { - return null; - } - - @Override - public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { - return null; - } -} 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 index af0b10809..7b75be0fd 100644 --- 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 @@ -1,20 +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.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.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.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId; public class DefaultSpecificAssetIdRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(SpecificAssetId object) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId) == false){ + 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/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 index e5b89f53a..4a6bce649 100644 --- 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 @@ -67,6 +67,24 @@ public void testMaximalEmbeddedDataSpecification() throws IncompatibleTypeExcept } @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); +// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert dataSpecificationIec61360.equals(recreatedDataSpecification); + } + @Test public void testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() .text("test") diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index ca538d270..2600cc7b6 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -54,7 +54,7 @@ public void testKey() throws IOException { } @Test - public void testAdministrativeInformationSimple() throws IncompatibleTypeException { + public void testMinimalAdministrativeInformation() throws IncompatibleTypeException { AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() .version("1") .revision("0") @@ -72,7 +72,7 @@ public void testAdministrativeInformationSimple() throws IncompatibleTypeExcepti } @Test - public void testAdministrativeInformationComplex() throws IncompatibleTypeException { + public void testMaximalAdministrativeInformation() throws IncompatibleTypeException { AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() .version("1") .revision("1") @@ -124,6 +124,120 @@ public void testReference() throws IncompatibleTypeException { assert reference.equals(recreatedKey); } + @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 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); + } + + @Test + public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -141,23 +255,6 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE System.out.println(output); } - @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); -// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); - DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); - assert dataSpecificationIec61360.equals(recreatedDataSpecification); - } } 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 index 74ea03f38..ec41dc0d8 100644 --- 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 @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.sql.Ref; import java.util.Arrays; import java.util.List; @@ -30,7 +31,6 @@ * Helper class for Serializer Tests * * @author sbader - * */ public class SerializerUtil { @@ -42,6 +42,8 @@ public static String readResourceToString(String resourceName) throws IOExceptio return writer.toString(); } + + public static String stripWhitespaces(String input) { return input.replaceAll("\\s+", ""); } @@ -118,6 +120,7 @@ public static DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { .build()) .build(); } + public static EmbeddedDataSpecification getEmbeddedDataSpecifications() { return new DefaultEmbeddedDataSpecification.Builder() .dataSpecification( @@ -137,6 +140,7 @@ public static EmbeddedDataSpecification getEmbeddedDataSpecifications() { .dataType(DataTypeIec61360.INTEGER_MEASURE).build()) .build(); } + public static EmbeddedDataSpecification getMaximalEmbeddedDataSpecifications() { return new DefaultEmbeddedDataSpecification.Builder() .dataSpecification( @@ -202,15 +206,139 @@ static List getDisplayNames() { .build()); } + static Extension getMaximalExtension(){ + return new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .valueType(DataTypeDefXsd.ANY_URI) + .refersTo(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("refersTo") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .semanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("semanticId") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build()) + .supplementalSemanticIds(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("supplementalSemanticIds") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .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 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() + .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("id1") + .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 Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build()); + getMaximalExtension(), + getMiniamlExtension()); } } From fd6dd5a3e4f5887a7a264d254b6af97967ba106a Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 16:24:45 +0100 Subject: [PATCH 011/160] Rearrange code and cleanups --- dataformat-rdf/pom.xml | 4 +- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 2 - .../rdf/DefaultRDFHandlerResult.java | 1 - .../rdf/IncompatibleTypeException.java | 3 +- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 5 +- .../aas4j/v3/dataformat/rdf/RDFParser.java | 77 +++++++-------- .../v3/dataformat/rdf/RDFPartialHandler.java | 1 + .../v3/dataformat/rdf/RDFSerializer.java | 35 +++---- ...ltAdministrativeInformationRDFHandler.java | 32 +++---- ...nnotatedRelationshipElementRDFHandler.java | 2 +- ...ultAssetAdministrationShellRDFHandler.java | 27 +++--- .../DefaultAssetInformationRDFHandler.java | 34 ++++--- .../rdf/handlers/DefaultBlobRDFHandler.java | 10 +- .../DefaultConceptDescriptionRDFHandler.java | 10 +- ...ultDataSpecificationContentRDFHandler.java | 4 - ...ltDataSpecificationIEC61360RDFHandler.java | 3 +- ...ltEmbeddedDataSpecificationRDFHandler.java | 1 - .../handlers/DefaultExtensionRDFHandler.java | 15 ++- .../rdf/handlers/DefaultKeyRDFHandler.java | 4 +- .../handlers/DefaultPropertyRDFHandler.java | 21 +++- .../handlers/DefaultQualifierRDFHandler.java | 16 ++-- .../handlers/DefaultReferenceRDFHandler.java | 20 ++-- .../handlers/DefaultResourceRDFHandler.java | 20 ++-- .../DefaultSpecificAssetIdRDFHandler.java | 23 +++-- .../DefaultSubmodelElementRDFHandler.java | 4 - .../DefaultLevelTypeRDFHandler.java | 18 ++-- .../DefaultValueListRDFHandler.java | 2 +- .../DefaultValueReferencePairRDFHandler.java | 8 +- ...HasDataSpecificationRDFPartialHandler.java | 14 +-- .../DefaultHasSemanticsRDFPartialHandler.java | 19 ++-- .../DefaultIdentifiableRDFPartialHandler.java | 4 +- .../DefaultReferableRDFPartialHandler.java | 29 +++--- .../rdf/AssetAdministrationShellTest.java | 94 ++++++++++++++++++ .../rdf/ConceptDescriptionTest.java | 8 +- .../rdf/DataSpecificationIec61360Test.java | 2 + .../aas4j/v3/dataformat/rdf/ParserTest.java | 33 ------- .../v3/dataformat/rdf/SerializerTest.java | 96 +------------------ .../v3/dataformat/rdf/SerializerUtil.java | 77 +++++---------- .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 25 +++++ 39 files changed, 384 insertions(+), 419 deletions(-) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java delete mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index bd72cb847..93a8d4061 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 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 index 93c63ddf4..d84cf27ff 100644 --- 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 @@ -2,8 +2,6 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; /** * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. 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 index 57daf095d..3319a5dfc 100644 --- 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 @@ -2,7 +2,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; public class DefaultRDFHandlerResult implements RDFSerializationResult { private final Model model; 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 index 7c4da8781..972cf9e14 100644 --- 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 @@ -4,7 +4,8 @@ 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); + 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/RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java index 4e56f9bd6..736559469 100644 --- 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 @@ -6,11 +6,13 @@ /** * 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 is side effect free and idempotent. + * * @param element 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. @@ -19,7 +21,8 @@ public interface RDFHandler { /** * This method is side effect free and idempotent. - * @param model The graph model that holds information. + * + * @param model The graph model that holds information. * @param subjectToParse Root elements that correspond to the object. * @return instance of the object */ 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 index b6fad5601..46a0f2e14 100644 --- 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 @@ -14,6 +14,7 @@ public class RDFParser { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + /** * Deserializes a given string into an instance of AssetAdministrationShellEnvironment * @@ -68,7 +69,7 @@ public Environment read(InputStream src) throws DeserializationException { /** * 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 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 @@ -83,10 +84,10 @@ public Environment read(InputStream src, Charset charset) throws Deserialization /** * 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 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 FileNotFoundException if file is not present * @throws DeserializationException if deserialization fails */ public Environment read(java.io.File file, Charset charset) @@ -99,7 +100,7 @@ public Environment read(java.io.File file, Charset 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 FileNotFoundException if the file is not present * @throws DeserializationException if deserialization fails */ public Environment read(java.io.File file) throws FileNotFoundException, DeserializationException { @@ -115,8 +116,8 @@ public Environment read(java.io.File file) throws FileNotFoundException, Deseria * 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 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) { @@ -127,9 +128,9 @@ public void useImplementation(Class aasInterface, Class impl /** * Deserializes a given string into an instance of the given Referable * - * @param src a string representation of the Referable + * @param src a string representation of the Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -144,9 +145,9 @@ public T readReferable(String src, Class outputClass) t /** * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET * - * @param src a input stream representing a Referable + * @param src a input stream representing a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -157,9 +158,9 @@ public T readReferable(InputStream src, Class outputCla /** * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET * - * @param root Apache Jena Resource + * @param root Apache Jena Resource * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -174,10 +175,10 @@ public T readReferable(JsonNode root, Class outputClass /** * 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 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 + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -192,11 +193,11 @@ public T readReferable(InputStream src, Charset charset, C /** * 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 src a file containing string representation of a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @throws DeserializationException if deserialization fails * @throws java.io.FileNotFoundException if file is not found */ public T readReferable(File src, Class outputClass) throws DeserializationException, FileNotFoundException { @@ -206,12 +207,12 @@ public T readReferable(File src, Class outputClass) thr /** * 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 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 + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @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 { @@ -221,9 +222,9 @@ public T readReferable(File src, Charset charset, Class /** * 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 referables a string representation of an array of Referables * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of a list of the referables * @throws DeserializationException if deserialization of referable fails */ @@ -238,9 +239,9 @@ public List readReferables(String referables, Class /** * Deserializes a given string into an instance of a list of the given Referables * - * @param root Apache Jena Resource + * @param root Apache Jena Resource * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of a list of the referables * @throws DeserializationException if deserialization of referable fails */ @@ -255,9 +256,9 @@ public List readReferables(Resource root, Class outp /** * 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 src a input stream representing a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -268,10 +269,10 @@ public List readReferables(InputStream src, Class ou /** * 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 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 + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -286,11 +287,11 @@ public List readReferables(InputStream src, Charset cha /** * 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 src a file containing string representation of a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @throws DeserializationException if deserialization fails * @throws java.io.FileNotFoundException if file is not found */ public List readReferables(File src, Class outputClass) throws DeserializationException, FileNotFoundException { @@ -300,12 +301,12 @@ public List readReferables(File src, Class outputCla /** * 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 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 + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @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 { 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 index aa7b3dac3..efcf1d5b3 100644 --- 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 @@ -6,5 +6,6 @@ public interface RDFPartialHandler { public void partialToModel(T object, Model model, Resource parentNode); + public 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/RDFSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java index 7b314ccea..328b0d1ea 100644 --- 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 @@ -18,7 +18,7 @@ public class RDFSerializer { /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * - * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize + * @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 @@ -45,7 +45,7 @@ public String write(Environment aasEnvironment) throws SerializationException { /** * Serializes a given instance of a Referable to string * - * @param referable the referable to serialize + * @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 @@ -93,9 +93,9 @@ public RDFSerializationResult toModel(Referable referable) { /** * Serializes a given instance of Environment to an OutputStream using DEFAULT_CHARSET * - * @param out the Outputstream to serialize to + * @param out the Outputstream to serialize to * @param aasEnvironment the Environment to serialize - * @throws IOException if writing to the stream fails + * @throws IOException if writing to the stream fails * @throws SerializationException if serialization fails */ void write(OutputStream out, Environment aasEnvironment) throws IOException, SerializationException { @@ -105,10 +105,10 @@ void write(OutputStream out, Environment aasEnvironment) throws IOException, Ser /** * 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 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 IOException if writing to the stream fails * @throws SerializationException if serialization fails */ void write(OutputStream out, Charset charset, Environment aasEnvironment) @@ -119,14 +119,15 @@ void write(OutputStream out, Charset charset, Environment 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 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 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) @@ -139,10 +140,10 @@ void write(java.io.File file, Charset charset, Environment 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 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 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) @@ -151,11 +152,6 @@ void write(java.io.File file, Environment aasEnvironment) } - - - - - // /** // * // * @param referables the referables to serialize @@ -180,7 +176,6 @@ void write(java.io.File file, Environment aasEnvironment) // } - // public String writeReferables(List referables) throws SerializationException { // try { // throw new RuntimeException("Not Implemented"); 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 index 6fcdd5eca..629daf2f2 100644 --- 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 @@ -19,45 +19,45 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { 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,object.getVersion()); + model.add(subject, RDF.type, AASNamespace.Types.AdministrativeInformation); + if (object.getVersion() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, object.getVersion()); } - if(object.getRevision()!=null){ - model.addLiteral(subject,AASNamespace.AdministrativeInformation.revision,object.getRevision()); + if (object.getRevision() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, object.getRevision()); } - if(object.getTemplateId()!=null){ - model.addLiteral(subject,AASNamespace.AdministrativeInformation.templateId,object.getTemplateId()); + if (object.getTemplateId() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, object.getTemplateId()); } - if(object.getCreator()!=null){ + if (object.getCreator() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); - model.addLiteral(subject,AASNamespace.AdministrativeInformation.creator,res.getResource()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); model.add(res.getModel()); } //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object,model,subject); + 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) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { throw new IncompatibleTypeException("AdministrativeInformation"); } DefaultAdministrativeInformation.Builder builder = new DefaultAdministrativeInformation.Builder(); - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.version)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.version)) { builder.version(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.version).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.revision)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.revision)) { builder.revision(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.revision).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.templateId)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.templateId)) { builder.templateId(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.templateId).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.creator)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.creator)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.creator).getResource(); Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); @@ -65,7 +65,7 @@ public AdministrativeInformation fromModel(Model model, Resource subjectToParse) } DefaultAdministrativeInformation object = builder.build(); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index d33586fe7..1f1ae995e 100644 --- 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 @@ -21,7 +21,7 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { throw new IncompatibleTypeException("AssetAdministrationShell"); } 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 index 92676c503..96bf75060 100644 --- 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 @@ -1,12 +1,13 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; import org.apache.jena.rdf.model.*; -import org.apache.jena.rdf.model.Resource; 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.*; +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; @@ -22,13 +23,13 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.AssetAdministrationShell); - if(object.getAssetInformation()!=null){ + 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(subject, AASNamespace.AssetAdministrationShell.assetInformation, res.getResource()); model.add(res.getModel()); } - if(object.getSubmodels()!=null && object.getSubmodels().isEmpty() == false){ + if (object.getSubmodels() != null && object.getSubmodels().isEmpty() == false) { int index = 0; for (Reference item : object.getSubmodels()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -39,9 +40,9 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { index = index + 1; } } - if(object.getDerivedFrom()!=null){ + if (object.getDerivedFrom() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getDerivedFrom()); - model.add(subject,AASNamespace.AssetAdministrationShell.derivedFrom,res.getResource()); + model.add(subject, AASNamespace.AssetAdministrationShell.derivedFrom, res.getResource()); model.add(res.getModel()); } //Identifiable @@ -53,16 +54,16 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { @Override public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false) { throw new IncompatibleTypeException("AssetAdministrationShell"); } DefaultAssetAdministrationShell.Builder builder = new DefaultAssetAdministrationShell.Builder(); - if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.assetInformation)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.submodels)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetAdministrationShell.submodels); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -81,7 +82,7 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) } builder.submodels(langStringList); } - if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom)){ + 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); @@ -90,7 +91,7 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) //Identifiable new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index e3ce43a99..e49608846 100644 --- 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 @@ -4,8 +4,6 @@ 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.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; @@ -22,26 +20,26 @@ public RDFSerializationResult toModel(AssetInformation object) { 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, + 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, + if (object.getAssetType() != null) { + model.add(subject, AASNamespace.AssetInformation.assetType, object.getAssetType()); } - if(object.getDefaultThumbnail()!=null){ + if (object.getDefaultThumbnail() != null) { RDFSerializationResult res = new DefaultResourceRDFHandler().toModel(object.getDefaultThumbnail()); - model.add(subject,AASNamespace.AssetInformation.defaultThumbnail, + model.add(subject, AASNamespace.AssetInformation.defaultThumbnail, res.getResource()); model.add(res.getModel()); } - if(object.getGlobalAssetId()!=null){ - model.add(subject,AASNamespace.AssetInformation.globalAssetId, + if (object.getGlobalAssetId() != null) { + model.add(subject, AASNamespace.AssetInformation.globalAssetId, object.getGlobalAssetId()); } - if(object.getSpecificAssetIds()!=null && object.getSpecificAssetIds().isEmpty() == false){ + if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -57,29 +55,29 @@ public RDFSerializationResult toModel(AssetInformation object) { @Override public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false) { throw new IncompatibleTypeException("AssetInformation"); } DefaultAssetInformation.Builder builder = new DefaultAssetInformation.Builder(); - if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetKind)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetType)) { builder.assetType(model.getProperty(subjectToParse, AASNamespace.AssetInformation.assetType).getString()); } - if (model.contains(subjectToParse, AASNamespace.AssetInformation.defaultThumbnail)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.globalAssetId)) { builder.globalAssetId(model.getProperty(subjectToParse, AASNamespace.AssetInformation.globalAssetId).getString()); } - if (model.contains(subjectToParse, AASNamespace.AssetInformation.specificAssetIds)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.specificAssetIds)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetInformation.specificAssetIds); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 5df58123d..a5888e465 100644 --- 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 @@ -1,7 +1,10 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; 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; @@ -10,7 +13,12 @@ public class DefaultBlobRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(Blob object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override 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 index 1796d4087..5927dcfcb 100644 --- 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 @@ -6,8 +6,6 @@ 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.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; @@ -27,12 +25,12 @@ public RDFSerializationResult toModel(ConceptDescription object) { Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - if(object.getIsCaseOf()!=null && object.getIsCaseOf().isEmpty() == false) { + if (object.getIsCaseOf() != null && object.getIsCaseOf().isEmpty() == false) { 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()); + model.add(conceptDescriptionResource, AASNamespace.ConceptDescription.isCaseOf, resultItem.getResource()); // It is important where to put model.add model.add(resultItem.getModel()); index = index + 1; @@ -54,7 +52,7 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws } DefaultConceptDescription.Builder builder = new DefaultConceptDescription.Builder(); - if(model.contains(subjectToParse,AASNamespace.ConceptDescription.isCaseOf)){ + if (model.contains(subjectToParse, AASNamespace.ConceptDescription.isCaseOf)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -77,7 +75,7 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws //Identifiable new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index 4ecda069d..a9d2a3ca4 100644 --- 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 @@ -8,12 +8,8 @@ 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.dataformat.rdf.handlers.DefaultAnnotatedRelationshipElementRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultRelationshipElementRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { @Override 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 index 1ce328b78..ee46feca3 100644 --- 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 @@ -1,12 +1,11 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.*; 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.builder.DataSpecificationIec61360Builder; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; import java.util.ArrayList; 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 index 22a115a98..03417cfc8 100644 --- 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 @@ -7,7 +7,6 @@ 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.DataSpecificationIec61360; 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; 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 index 873defd48..11ca61e6b 100644 --- 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 @@ -3,11 +3,8 @@ 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.DefaultLangStringDefinitionTypeIec61360RDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; @@ -56,17 +53,17 @@ public Extension fromModel(Model model, Resource subjectToParse) throws Incompat 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.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.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.Extension.value).getString()); } - if(model.contains(subjectToParse,AASNamespace.Extension.valueType)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Extension.refersTo)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Extension.refersTo); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 2b05fbdc4..dbcf474b5 100644 --- 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 @@ -27,8 +27,8 @@ public RDFSerializationResult toModel(Key key) { return new DefaultRDFHandlerResult(model, subject); } - public Key fromModel(Model model, Resource subjectToParse){ - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + public Key fromModel(Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false) { throw new IllegalArgumentException("Provided Resource is not a Key"); } String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); 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 index 478ef4406..a6416001f 100644 --- 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 @@ -1,20 +1,33 @@ 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.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.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.Property; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; public class DefaultPropertyRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(Property object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public Property fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property) == false) { + throw new IncompatibleTypeException("Property"); + } + DefaultProperty.Builder builder = new DefaultProperty.Builder(); + + return null; } } 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 index b08979b7d..e4a67a77e 100644 --- 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 @@ -1,10 +1,12 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.*; +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.Extension; 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; @@ -50,22 +52,22 @@ public Qualifier fromModel(Model model, Resource subjectToParse) throws Incompat throw new IncompatibleTypeException("Qualifier"); } DefaultQualifier.Builder builder = new DefaultQualifier.Builder(); - if (model.contains(subjectToParse, AASNamespace.Qualifier.kind)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.type)) { builder.type(model.getProperty(subjectToParse, AASNamespace.Qualifier.type).getString()); } - if (model.contains(subjectToParse, AASNamespace.Qualifier.value)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.value)) { builder.value(model.getProperty(subjectToParse, AASNamespace.Qualifier.value).getString()); } - if (model.contains(subjectToParse, AASNamespace.Qualifier.valueId)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.valueType)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.Qualifier.valueType).getResource(); builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); } 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 index 802b1b4f7..946a8a2a7 100644 --- 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 @@ -20,15 +20,15 @@ public RDFSerializationResult toModel(Reference key) { 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())); + 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()); + 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; @@ -39,19 +39,19 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false) { 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->{ + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); + keysIterator.forEachRemaining(node -> { Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index,key); + keysMap.put(index, key); }); List keys = new ArrayList<>(); - for(int index=0;index { @Override 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 index a9a359ce3..a0622244d 100644 --- 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 @@ -18,23 +18,23 @@ public RDFSerializationResult toModel(LevelType object) { } 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()); + 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) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LevelType) == false) { throw new IllegalArgumentException("Provided Resource is not a LevelType"); } return new DefaultLevelType.Builder() - .min(model.getProperty(subjectToParse,AASNamespace.LevelType.min).getBoolean()) - .max(model.getProperty(subjectToParse,AASNamespace.LevelType.max).getBoolean()) - .nom(model.getProperty(subjectToParse,AASNamespace.LevelType.nom).getBoolean()) - .typ(model.getProperty(subjectToParse,AASNamespace.LevelType.typ).getBoolean()) + .min(model.getProperty(subjectToParse, AASNamespace.LevelType.min).getBoolean()) + .max(model.getProperty(subjectToParse, AASNamespace.LevelType.max).getBoolean()) + .nom(model.getProperty(subjectToParse, AASNamespace.LevelType.nom).getBoolean()) + .typ(model.getProperty(subjectToParse, AASNamespace.LevelType.typ).getBoolean()) .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 index e9c2657f2..6d2b870e1 100644 --- 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 @@ -20,7 +20,7 @@ public RDFSerializationResult toModel(ValueList object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.ValueList); + model.add(subject, RDF.type, AASNamespace.Types.ValueList); int index = 0; for (ValueReferencePair valueReferencePair : object.getValueReferencePairs()) { RDFSerializationResult valueReferencePairSerializationResult = new DefaultValueReferencePairRDFHandler().toModel(valueReferencePair); 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 index 56b152a94..6fdb367b9 100644 --- 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 @@ -19,23 +19,23 @@ public RDFSerializationResult toModel(ValueReferencePair object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.ValueReferencePair); + model.add(subject, RDF.type, AASNamespace.Types.ValueReferencePair); model.add(subject, AASNamespace.ValueReferencePair.value, object.getValue()); RDFSerializationResult referenceSerializationResult = new DefaultReferenceRDFHandler().toModel(object.getValueId()); model.add(referenceSerializationResult.getModel()); - model.add(subject,AASNamespace.ValueReferencePair.valueId,referenceSerializationResult.getResource()); + model.add(subject, AASNamespace.ValueReferencePair.valueId, referenceSerializationResult.getResource()); return new DefaultRDFHandlerResult(model, subject); } @Override public ValueReferencePair fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false) { throw new IncompatibleTypeException("ValueReferencePair"); } Reference reference = new DefaultReferenceRDFHandler().fromModel(model, model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.valueId).getResource()); return new DefaultValueReferencePair.Builder() - .value(model.getProperty(subjectToParse,AASNamespace.ValueReferencePair.value).getString()) + .value(model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.value).getString()) .valueId(reference) .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 index aff08f297..8803b691d 100644 --- 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 @@ -1,5 +1,3 @@ - - package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; import org.apache.jena.rdf.model.Model; @@ -10,12 +8,8 @@ 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.dataformat.rdf.handlers.DefaultKeyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringTextTypeRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import java.util.ArrayList; import java.util.HashMap; @@ -40,11 +34,11 @@ public void partialToModel(HasDataSpecification object, Model model, Resource pa @Override public HasDataSpecification partialFromModel(HasDataSpecification object, Model model, Resource subjectToParse) { - if(model.contains(subjectToParse,AASNamespace.HasDataSpecification.embeddedDataSpecifications)){ + if (model.contains(subjectToParse, AASNamespace.HasDataSpecification.embeddedDataSpecifications)) { Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasDataSpecification.embeddedDataSpecifications); - keysIterator.forEachRemaining(node->{ + keysIterator.forEachRemaining(node -> { EmbeddedDataSpecification key = null; try { key = new DefaultEmbeddedDataSpecificationRDFHandler().fromModel(model, (Resource) node); @@ -52,10 +46,10 @@ public HasDataSpecification partialFromModel(HasDataSpecification object, Model throw new RuntimeException(e); } int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index,key); + keysMap.put(index, key); }); List keys = new ArrayList<>(); - for(int index=0;index { 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 index 8c00a9f19..204ffaa14 100644 --- 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 @@ -1,14 +1,19 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; -import org.apache.jena.rdf.model.*; +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.*; +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.DefaultKeyRDFHandler; 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.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.*; +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; @@ -64,13 +69,13 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { @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.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.category)) { + object.setCategory(model.getProperty(subjectToParse, AASNamespace.Referable.category).getString()); } - if (model.contains(subjectToParse,AASNamespace.Referable.description)) { + if (model.contains(subjectToParse, AASNamespace.Referable.description)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.description); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -89,7 +94,7 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec } object.setDescription(langStringList); } - if (model.contains(subjectToParse,AASNamespace.Referable.displayName)) { + if (model.contains(subjectToParse, AASNamespace.Referable.displayName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.displayName); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -110,7 +115,7 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec } //HasExtension - if (model.contains(subjectToParse,AASNamespace.HasExtensions.extensions)) { + if (model.contains(subjectToParse, AASNamespace.HasExtensions.extensions)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasExtensions.extensions); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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..815a50b75 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java @@ -0,0 +1,94 @@ +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.rdf.handlers.DefaultAssetAdministrationShellRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultAssetInformationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultResourceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSpecificAssetIdRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.junit.Test; + +public class AssetAdministrationShellTest { + + @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); + } + + @Test + public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); + 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); + assert object.equals(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 index a5bf3cbce..308ee96ed 100644 --- 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 @@ -3,15 +3,12 @@ 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.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.*; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; import org.junit.Test; import java.io.IOException; -import java.util.Arrays; public class ConceptDescriptionTest { @@ -30,7 +27,6 @@ public void simpleConceptDescription() throws IOException, IncompatibleTypeExcep } - @Test public void complexConceptDescription() throws IncompatibleTypeException { ConceptDescription object = new DefaultConceptDescription.Builder() 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 index 4a6bce649..cf2849d93 100644 --- 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 @@ -66,6 +66,7 @@ public void testMaximalEmbeddedDataSpecification() throws IncompatibleTypeExcept assert object.equals(recreatedObject); } + @Test public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 dataSpecificationIec61360 = new DefaultDataSpecificationIec61360.Builder() @@ -84,6 +85,7 @@ public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); assert dataSpecificationIec61360.equals(recreatedDataSpecification); } + @Test public void testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java deleted file mode 100644 index 3fbb9bc0b..000000000 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf; - - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; - -import junitparams.JUnitParamsRunner; - -import java.io.IOException; - -@RunWith(JUnitParamsRunner.class) -public class ParserTest { - -} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 2600cc7b6..1f6cc12bb 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -1,21 +1,6 @@ -/* - * 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.rdf; -import org.apache.jena.rdf.model.*; +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; @@ -24,7 +9,6 @@ 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; @@ -161,83 +145,6 @@ public void testMaximalQualifier() throws IncompatibleTypeException { assert object.equals(recreatedObject); } - @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); - } - - @Test - public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); - 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); - assert object.equals(recreatedObject); - } - - @Test - public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); - 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); - assert object.equals(recreatedObject); - } - @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -256,5 +163,4 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE } - } 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 index ec41dc0d8..7aef2be01 100644 --- 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 @@ -1,52 +1,15 @@ -/* - * 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.rdf; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.sql.Ref; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.io.IOUtils; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -/** - * Helper class for Serializer Tests - * - * @author sbader - */ -public class SerializerUtil { - - public static String readResourceToString(String resourceName) throws IOException { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream(resourceName); - StringWriter writer = new StringWriter(); - IOUtils.copy(is, writer, "UTF-8"); - return writer.toString(); - } +import java.util.Arrays; +import java.util.List; +public class SerializerUtil { - public static String stripWhitespaces(String input) { - return input.replaceAll("\\s+", ""); - } public static DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { return new DefaultDataSpecificationIec61360.Builder() @@ -206,7 +169,7 @@ static List getDisplayNames() { .build()); } - static Extension getMaximalExtension(){ + static Extension getMaximalExtension() { return new DefaultExtension.Builder() .name("extension1") .value("extension1Value") @@ -234,7 +197,7 @@ static Extension getMaximalExtension(){ .build(); } - static Reference getMinimalReference(){ + static Reference getMinimalReference() { return new DefaultReference.Builder() .keys(new DefaultKey.Builder() .value("minimal") @@ -244,13 +207,14 @@ static Reference getMinimalReference(){ .build(); } - static Qualifier getMinimalQualifier(){ + static Qualifier getMinimalQualifier() { return new DefaultQualifier.Builder() .type("type1") .valueType(DataTypeDefXsd.STRING) .build(); } - static Qualifier getMaximalQualifier(){ + + static Qualifier getMaximalQualifier() { return new DefaultQualifier.Builder() .type("type1") .kind(QualifierKind.CONCEPT_QUALIFIER) @@ -262,7 +226,7 @@ static Qualifier getMaximalQualifier(){ .build(); } - static SpecificAssetId getMaximalSpecificAssetId(){ + static SpecificAssetId getMaximalSpecificAssetId() { return new DefaultSpecificAssetId.Builder() .semanticId(getMinimalReference()) .supplementalSemanticIds(getMinimalReference()) @@ -271,38 +235,43 @@ static SpecificAssetId getMaximalSpecificAssetId(){ .value("value1") .build(); } - static SpecificAssetId getMinimalSpecificAssetId(){ + + static SpecificAssetId getMinimalSpecificAssetId() { return new DefaultSpecificAssetId.Builder() .name("name1") .value("value1") .build(); } - static Property getMinimalProperty(){ + + static Property getMinimalProperty() { return new DefaultProperty.Builder() + .idShort("idShort1") + .valueType(DataTypeDefXsd.DECIMAL) .build(); } - static Extension getMiniamlExtension(){ + static Extension getMiniamlExtension() { return new DefaultExtension.Builder() .name("extension2") .value("extension2Value") .build(); } - static Resource getResource(){ + static Resource getResource() { return new DefaultResource.Builder() .path("path://") .contentType("content/type") .build(); } - static AssetInformation getMinimalAssetInformation(){ + static AssetInformation getMinimalAssetInformation() { return new DefaultAssetInformation.Builder() .assetKind(AssetKind.INSTANCE) .globalAssetId("global1") .build(); } - static AssetInformation getMaximalAssetInformation(){ + + static AssetInformation getMaximalAssetInformation() { return new DefaultAssetInformation.Builder() .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetId("global2") @@ -315,13 +284,14 @@ static AssetInformation getMaximalAssetInformation(){ .build(); } - static AssetAdministrationShell getMinimalAssetAdministrationShell(){ + static AssetAdministrationShell getMinimalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMinimalAssetInformation()) .id("id1") .build(); } - static AssetAdministrationShell getMaximalAssetAdministrationShell(){ + + static AssetAdministrationShell getMaximalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMaximalAssetInformation()) .administration(getAdministrativeInformation()) @@ -336,6 +306,7 @@ static AssetAdministrationShell getMaximalAssetAdministrationShell(){ .build(); } + static List getExtensionList() { return Arrays.asList( getMaximalExtension(), 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..ed15a4811 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java @@ -0,0 +1,25 @@ +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.rdf.handlers.DefaultPropertyRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Property; +import org.junit.Test; + +public class SubmodelTest { + + @Test + public void testMinimalProperty() throws IncompatibleTypeException { + Property object = SerializerUtil.getMinimalProperty(); + RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + +} From cece7dd7bdb0939a1974e9b46d4b5c7a23601ad8 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 23:07:26 +0100 Subject: [PATCH 012/160] Add Property --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 144 +++++++++--------- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 6 +- .../v3/dataformat/rdf/RDFPartialHandler.java | 4 +- .../rdf/RDFSerializationResult.java | 14 ++ ...ltAdministrativeInformationRDFHandler.java | 2 +- ...nnotatedRelationshipElementRDFHandler.java | 2 +- ...ultAssetAdministrationShellRDFHandler.java | 4 +- .../DefaultAssetInformationRDFHandler.java | 4 +- .../DefaultConceptDescriptionRDFHandler.java | 4 +- ...ultDataSpecificationContentRDFHandler.java | 2 +- ...ltDataSpecificationIEC61360RDFHandler.java | 8 +- ...ltEmbeddedDataSpecificationRDFHandler.java | 2 +- .../handlers/DefaultExtensionRDFHandler.java | 4 +- .../rdf/handlers/DefaultKeyRDFHandler.java | 27 ++-- .../DefaultLangStringNameTypeRDFHandler.java | 23 ++- .../DefaultLangStringTextTypeRDFHandler.java | 23 ++- .../handlers/DefaultPropertyRDFHandler.java | 52 ++++++- .../handlers/DefaultQualifierRDFHandler.java | 2 +- .../handlers/DefaultReferenceRDFHandler.java | 2 +- .../handlers/DefaultResourceRDFHandler.java | 2 +- .../DefaultSpecificAssetIdRDFHandler.java | 2 +- .../DefaultSubmodelElementRDFHandler.java | 28 ++-- ...tringDefinitionTypeIec61360RDFHandler.java | 23 ++- ...ngPreferredNameTypeIec61360RDFHandler.java | 25 +-- ...StringShortNameTypeIec61360RDFHandler.java | 10 +- .../DefaultLevelTypeRDFHandler.java | 2 +- .../DefaultValueListRDFHandler.java | 2 +- .../DefaultValueReferencePairRDFHandler.java | 30 ++-- ...HasDataSpecificationRDFPartialHandler.java | 2 +- .../DefaultHasSemanticsRDFPartialHandler.java | 2 +- .../DefaultQualifiableRDFPartialHandler.java | 58 +++++++ .../DefaultReferableRDFPartialHandler.java | 6 +- .../v3/dataformat/rdf/SerializerUtil.java | 17 +++ .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 12 ++ 34 files changed, 376 insertions(+), 174 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java 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 index d84cf27ff..3bf92b79a 100644 --- 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 @@ -1,15 +1,14 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; /** - * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. + * 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 Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); + public static final org.apache.jena.rdf.model.Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); private AASNamespace() { @@ -24,39 +23,39 @@ public static final class Key { /** * The key value, for example an IRDI or an URI */ - public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/value"); + 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 Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); + public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); } public static final class Reference { - public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); - public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); + 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 Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); + public static final org.apache.jena.rdf.model.Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); } public static final class Referable { - public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); - public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); - public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); - public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); + 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 Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); - public static final Property administration = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/administration"); + 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 Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); + public static final org.apache.jena.rdf.model.Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); } /** @@ -243,139 +242,148 @@ public static final class Types { } public static final class LevelType { - public static final Property min = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/min"); - public static final Property nom = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/nom"); - public static final Property typ = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/typ"); - public static final Property max = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/max"); + 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 Property language = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/language"); - public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); + 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 Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/value"); - public static final Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/valueType"); - public static final Property refersTo = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/refersTo"); - public static final Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/name"); + 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 Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); - public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); + 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 Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); + public static final org.apache.jena.rdf.model.Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } public static final class EmbeddedDataSpecification { - public static final Property dataSpecification = + public static final org.apache.jena.rdf.model.Property dataSpecification = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); - public static final Property dataSpecificationContent = + public static final org.apache.jena.rdf.model.Property dataSpecificationContent = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); } public static final class HasDataSpecification { - public static final Property embeddedDataSpecifications = + public static final org.apache.jena.rdf.model.Property embeddedDataSpecifications = ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); } public static final class HasSemantics { - public static final Property semanticId = + public static final org.apache.jena.rdf.model.Property semanticId = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); - public static final Property supplementalSemanticIds = + public static final org.apache.jena.rdf.model.Property supplementalSemanticIds = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); } public static final class Qualifiable { - public static final Property qualifiers = + public static final org.apache.jena.rdf.model.Property qualifiers = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifiable/qualifiers"); } public static final class Qualifier { - public static final Property kind = + public static final org.apache.jena.rdf.model.Property kind = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/kind"); - public static final Property type = + public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/type"); - public static final Property value = + public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/value"); - public static final Property valueId = + public static final org.apache.jena.rdf.model.Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueId"); - public static final Property valueType = + public static final org.apache.jena.rdf.model.Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueType"); } public static final class AdministrativeInformation { - public static final Property version = + public static final org.apache.jena.rdf.model.Property version = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); - public static final Property revision = + public static final org.apache.jena.rdf.model.Property revision = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/revision"); - public static final Property creator = + public static final org.apache.jena.rdf.model.Property creator = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); - public static final Property templateId = + public static final org.apache.jena.rdf.model.Property templateId = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); } public static final class SpecificAssetId { - public static final Property externalSubjectId = + public static final org.apache.jena.rdf.model.Property externalSubjectId = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/externalSubjectId"); - public static final Property name = + public static final org.apache.jena.rdf.model.Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/name"); - public static final Property value = + public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/value"); } + 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 AssetAdministrationShell { - public static final Property assetInformation = + public static final org.apache.jena.rdf.model.Property assetInformation = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); - public static final Property derivedFrom = + public static final org.apache.jena.rdf.model.Property derivedFrom = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/derivedFrom"); - public static final Property submodels = + public static final org.apache.jena.rdf.model.Property submodels = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/submodels"); } public static final class AssetInformation { - public static final Property assetType = + public static final org.apache.jena.rdf.model.Property assetType = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetType"); - public static final Property defaultThumbnail = + public static final org.apache.jena.rdf.model.Property defaultThumbnail = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/defaultThumbnail"); - public static final Property globalAssetId = + public static final org.apache.jena.rdf.model.Property globalAssetId = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/globalAssetId"); - public static final Property specificAssetIds = + public static final org.apache.jena.rdf.model.Property specificAssetIds = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/specificAssetIds"); - public static final Property assetKind = + public static final org.apache.jena.rdf.model.Property assetKind = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetKind"); } public static final class Resource { - public static final Property contentType = + public static final org.apache.jena.rdf.model.Property contentType = ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/contentType"); - public static final Property path = + public static final org.apache.jena.rdf.model.Property path = ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/path"); } public static final class DataSpecificationIec61360 { - public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); - public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/value"); - public static final Property valueFormat = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueFormat"); - public static final Property definition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/definition"); - public static final Property dataType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/dataType"); - public static final Property symbol = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/symbol"); - public static final Property sourceOfDefinition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/sourceOfDefinition"); - public static final Property unitId = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unitId"); - public static final Property unit = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unit"); - public static final Property shortName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/shortName"); - public static final Property preferredName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/preferredName"); - public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); + 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 AssetKind { 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 index 736559469..69c8f4450 100644 --- 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 @@ -13,11 +13,11 @@ public interface RDFHandler { /** * Convert to RDF model. This method is side effect free and idempotent. * - * @param element the object that should be converted to an RDF model + * @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. */ - public RDFSerializationResult toModel(T object); + RDFSerializationResult toModel(T object); /** * This method is side effect free and idempotent. @@ -26,5 +26,5 @@ public interface RDFHandler { * @param subjectToParse Root elements that correspond to the object. * @return instance of the object */ - public T fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException; + T fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException; } 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 index efcf1d5b3..981c59f85 100644 --- 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 @@ -5,7 +5,7 @@ public interface RDFPartialHandler { - public void partialToModel(T object, Model model, Resource parentNode); + void partialToModel(T object, Model model, Resource parentNode); - public T partialFromModel(T object, Model model, Resource subjectToParse) throws IncompatibleTypeException; + 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/RDFSerializationResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java index 89523965d..699177f14 100644 --- 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 @@ -3,8 +3,22 @@ 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 a Apache Jena's {@link org.apache.jena.rdf.model.Resource} + * + * @return a Resource in the graph + */ Resource getResource(); } 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 index 629daf2f2..ac7333c40 100644 --- 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 @@ -41,7 +41,7 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { @Override public AdministrativeInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation)) { throw new IncompatibleTypeException("AdministrativeInformation"); } DefaultAdministrativeInformation.Builder builder = new DefaultAdministrativeInformation.Builder(); 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 index 1f1ae995e..58c083ede 100644 --- 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 @@ -21,7 +21,7 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation)) { throw new IncompatibleTypeException("AssetAdministrationShell"); } 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 index 96bf75060..201304b3e 100644 --- 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 @@ -29,7 +29,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { model.add(subject, AASNamespace.AssetAdministrationShell.assetInformation, res.getResource()); model.add(res.getModel()); } - if (object.getSubmodels() != null && object.getSubmodels().isEmpty() == false) { + if (object.getSubmodels() != null && !object.getSubmodels().isEmpty()) { int index = 0; for (Reference item : object.getSubmodels()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -54,7 +54,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { @Override public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell)) { throw new IncompatibleTypeException("AssetAdministrationShell"); } DefaultAssetAdministrationShell.Builder builder = new DefaultAssetAdministrationShell.Builder(); 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 index e49608846..64fbbced4 100644 --- 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 @@ -39,7 +39,7 @@ public RDFSerializationResult toModel(AssetInformation object) { model.add(subject, AASNamespace.AssetInformation.globalAssetId, object.getGlobalAssetId()); } - if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { + if (object.getSpecificAssetIds() != null && !object.getSpecificAssetIds().isEmpty()) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -55,7 +55,7 @@ public RDFSerializationResult toModel(AssetInformation object) { @Override public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation)) { throw new IncompatibleTypeException("AssetInformation"); } DefaultAssetInformation.Builder builder = new DefaultAssetInformation.Builder(); 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 index 5927dcfcb..2bfd7c4b4 100644 --- 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 @@ -25,7 +25,7 @@ public RDFSerializationResult toModel(ConceptDescription object) { Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - if (object.getIsCaseOf() != null && object.getIsCaseOf().isEmpty() == false) { + if (object.getIsCaseOf() != null && !object.getIsCaseOf().isEmpty()) { int index = 0; for (Reference item : object.getIsCaseOf()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -47,7 +47,7 @@ public RDFSerializationResult toModel(ConceptDescription object) { @Override public ConceptDescription fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription)) { throw new IncompatibleTypeException(); } DefaultConceptDescription.Builder builder = new DefaultConceptDescription.Builder(); 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 index a9d2a3ca4..efa686c95 100644 --- 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 @@ -14,7 +14,7 @@ public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(DataSpecificationContent object) { - if (DataSpecificationIec61360.class.isInstance(object)) { + if (object instanceof DataSpecificationIec61360) { return new DefaultDataSpecificationIEC61360RDFHandler().toModel((DataSpecificationIec61360) object); } 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 index ee46feca3..44205388b 100644 --- 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 @@ -22,7 +22,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.DataSpecificationIec61360); - if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false) { + if (object.getPreferredName() != null && !object.getPreferredName().isEmpty()) { int index = 0; for (LangStringPreferredNameTypeIec61360 langString : object.getPreferredName()) { RDFSerializationResult res = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().toModel(langString); @@ -32,7 +32,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getShortName() != null && object.getShortName().isEmpty() == false) { + if (object.getShortName() != null && !object.getShortName().isEmpty()) { int index = 0; for (LangStringShortNameTypeIec61360 langString : object.getShortName()) { RDFSerializationResult res = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(langString); @@ -42,7 +42,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getDefinition() != null && object.getDefinition().isEmpty() == false) { + if (object.getDefinition() != null && !object.getDefinition().isEmpty()) { int index = 0; for (LangStringDefinitionTypeIec61360 langString : object.getDefinition()) { RDFSerializationResult res = new DefaultLangStringDefinitionTypeIec61360RDFHandler().toModel(langString); @@ -90,7 +90,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { @Override public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360)) { throw new IncompatibleTypeException("DataSpecificationIec61360"); } DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); 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 index 03417cfc8..010d71f1e 100644 --- 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 @@ -36,7 +36,7 @@ public RDFSerializationResult toModel(EmbeddedDataSpecification object) { @Override public EmbeddedDataSpecification fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification)) { throw new IncompatibleTypeException("EmbeddedDataSpecification"); } DefaultEmbeddedDataSpecification.Builder builder = new DefaultEmbeddedDataSpecification.Builder(); 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 index 11ca61e6b..a30613c46 100644 --- 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 @@ -32,7 +32,7 @@ public RDFSerializationResult toModel(Extension object) { model.add(subject, AASNamespace.Extension.valueType, AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); } - if (object.getRefersTo() != null && object.getRefersTo().isEmpty() == false) { + if (object.getRefersTo() != null && !object.getRefersTo().isEmpty()) { int index = 0; for (Reference reference : object.getRefersTo()) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(reference); @@ -49,7 +49,7 @@ public RDFSerializationResult toModel(Extension object) { @Override public Extension fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension)) { throw new IncompatibleTypeException("Extension"); } DefaultExtension.Builder builder = new DefaultExtension.Builder(); 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 index dbcf474b5..b4910e6d9 100644 --- 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 @@ -11,7 +11,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; import org.eclipse.digitaltwin.aas4j.v3.model.Key; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.builder.KeyBuilder; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; public class DefaultKeyRDFHandler implements RDFHandler { @@ -22,21 +21,29 @@ public RDFSerializationResult toModel(Key key) { } Resource subject = model.createResource(); subject.addProperty(RDF.type, AASNamespace.Types.Key); - subject.addProperty(AASNamespace.Key.value, key.getValue()); - subject.addProperty(AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(key.getType().name())); + 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) { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key)) { throw new IllegalArgumentException("Provided Resource is not a Key"); } - String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); - KeyTypes type = AASNamespace.KeyTypes.fromIRI(model.getProperty(subjectToParse, AASNamespace.Key.type).getResource().getURI()); - KeyBuilder builder = new DefaultKey.Builder(); + 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.type(type) - .value(value) - .build(); + 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 index 024be783d..b4f483b14 100644 --- 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 @@ -19,20 +19,27 @@ public RDFSerializationResult toModel(LangStringNameType object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringNameType); - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType)) { throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); } - - return new DefaultLangStringNameType.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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 index 04e55de72..7c745524d 100644 --- 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 @@ -18,20 +18,27 @@ public RDFSerializationResult toModel(LangStringTextType object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringTextType); - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType)) { throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); } - - return new DefaultLangStringTextType.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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/DefaultPropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java index a6416001f..b1fc18b48 100644 --- 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 @@ -6,7 +6,12 @@ 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 { @@ -17,17 +22,58 @@ public RDFSerializationResult toModel(Property object) { 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property)) { throw new IncompatibleTypeException("Property"); } DefaultProperty.Builder builder = new DefaultProperty.Builder(); - - return null; + if (model.contains(subjectToParse, AASNamespace.Property.value)) { + builder.value(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); + builder.valueId(reference); + } + if (model.contains(subjectToParse, AASNamespace.Property.valueType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueType).getResource(); + builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + Property 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/DefaultQualifierRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java index e4a67a77e..16e860a43 100644 --- 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 @@ -48,7 +48,7 @@ public RDFSerializationResult toModel(Qualifier object) { @Override public Qualifier fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier)) { throw new IncompatibleTypeException("Qualifier"); } DefaultQualifier.Builder builder = new DefaultQualifier.Builder(); 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 index 946a8a2a7..d2a152450 100644 --- 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 @@ -39,7 +39,7 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference)) { throw new IncompatibleTypeException("Reference"); } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); 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 index d6fe74f18..f4c0308df 100644 --- 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 @@ -28,7 +28,7 @@ public RDFSerializationResult toModel(Resource object) { @Override public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Resource) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Resource)) { throw new IncompatibleTypeException("Resource"); } DefaultResource.Builder builder = new DefaultResource.Builder(); 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 index 036ef08d8..835d0b3e5 100644 --- 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 @@ -38,7 +38,7 @@ public RDFSerializationResult toModel(SpecificAssetId object) { @Override public SpecificAssetId fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId)) { throw new IncompatibleTypeException("SpecificAssetId"); } DefaultSpecificAssetId.Builder builder = new DefaultSpecificAssetId.Builder(); 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 index ce839c9ea..1d6dce76f 100644 --- 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 @@ -14,46 +14,46 @@ public class DefaultSubmodelElementRDFHandler implements RDFHandler { @Override public void partialToModel(HasDataSpecification object, Model model, Resource parentNode) { - if (object.getEmbeddedDataSpecifications() != null && object.getEmbeddedDataSpecifications().isEmpty() == false) { + if (object.getEmbeddedDataSpecifications() != null && !object.getEmbeddedDataSpecifications().isEmpty()) { int index = 0; for (EmbeddedDataSpecification item : object.getEmbeddedDataSpecifications()) { RDFSerializationResult resultItem = new DefaultEmbeddedDataSpecificationRDFHandler().toModel(item); 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 index 793b1dd1b..8a0ee2a98 100644 --- 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 @@ -25,7 +25,7 @@ public void partialToModel(HasSemantics object, Model model, Resource parentNode model.add(parentNode, AASNamespace.HasSemantics.semanticId, res.getResource()); model.add(res.getModel()); } - if (object.getSupplementalSemanticIds() != null && object.getSupplementalSemanticIds().isEmpty() == false) { + if (object.getSupplementalSemanticIds() != null && !object.getSupplementalSemanticIds().isEmpty()) { int index = 0; for (Reference item : object.getSupplementalSemanticIds()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); 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..a4644169f --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java @@ -0,0 +1,58 @@ +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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setQualifiers(langStringList); + } + 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 index 204ffaa14..92809acc0 100644 --- 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 @@ -31,7 +31,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { if (object.getCategory() != null) { parentNode.addProperty(AASNamespace.Referable.category, object.getCategory()); } - if (object.getDescription() != null && object.getDescription().isEmpty() == false) { + if (object.getDescription() != null && !object.getDescription().isEmpty()) { int index = 0; for (LangStringTextType item : object.getDescription()) { RDFSerializationResult resultItem = new DefaultLangStringTextTypeRDFHandler().toModel(item); @@ -42,7 +42,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { index = index + 1; } } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false) { + if (object.getDisplayName() != null && !object.getDescription().isEmpty()) { int index = 0; for (LangStringNameType item : object.getDisplayName()) { RDFSerializationResult resultItem = new DefaultLangStringNameTypeRDFHandler().toModel(item); @@ -54,7 +54,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { } } //HasExtension - if (object.getExtensions() != null && object.getExtensions().isEmpty() == false) { + if (object.getExtensions() != null && !object.getExtensions().isEmpty()) { int index = 0; for (Extension item : object.getExtensions()) { RDFSerializationResult resultItem = new DefaultExtensionRDFHandler().toModel(item); 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 index 7aef2be01..6fa75238f 100644 --- 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 @@ -250,6 +250,23 @@ static Property getMinimalProperty() { .build(); } + 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 Extension getMiniamlExtension() { return new DefaultExtension.Builder() .name("extension2") 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 index ed15a4811..ba13ad251 100644 --- 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 @@ -21,5 +21,17 @@ public void testMinimalProperty() throws IncompatibleTypeException { assert object.equals(recreatedObject); } + @Test + public void testMaximalProperty() throws IncompatibleTypeException { + Property object = SerializerUtil.getMaximalProperty(); + RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + } From 39db76eb3d2068157c7de2c519a13ae2a56eb2f9 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 00:31:52 +0100 Subject: [PATCH 013/160] Add test cases for SubmodelElements --- .../v3/dataformat/rdf/SerializerUtil.java | 124 +++++++++++++++++- .../dataformat/rdf/SubmodelElementTest.java | 54 ++++++++ .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 37 ------ 3 files changed, 177 insertions(+), 38 deletions(-) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java delete mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java 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 index 6fa75238f..5a457ecb2 100644 --- 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 @@ -263,7 +263,129 @@ static Property getMaximalProperty() { .extensions(getMaximalExtension()) .supplementalSemanticIds(getIsCaseOfs()) .semanticId(getMinimalReference()) - .qualifiers(List.of(getMaximalQualifier(),getMinimalQualifier())) + .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 BasicEventElement getMinimalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .observed(getMinimalReference()) + .build(); + } + + static Blob getMinimalBlob() { + return new DefaultBlob.Builder() + .idShort("B1") + .contentType("image/png") + .build(); + } + + static Capability getMinimalCapability() { + return new DefaultCapability.Builder() + .idShort("C1") + .build(); + } + + static Entity getMinimalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .build(); + } + + static File getMinimalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + + static Range getMinimalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + + static ReferenceElement getMinimalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .build(); + } + + static RelationshipElement getMinimalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .build(); + } + + static SubmodelElementCollection getMinimalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("SEC1") + .build(); + } + + static SubmodelElementList getMinimalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .build(); + } + + static Operation getMinimalOperation() { + return new DefaultOperation.Builder() + .idShort("O1") + .build(); + } + + static MultiLanguageProperty getMinimalMultiLanguageProperty() { + return new DefaultMultiLanguageProperty.Builder() + .idShort("mlp1") .build(); } 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..e8e24b94a --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java @@ -0,0 +1,54 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +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.DefaultSubmodelElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Parameterized.class) +public class SubmodelElementTest { + @Parameter + public SubmodelElement submodelElement; + + @Parameters(name = "{index}: SME - {0}") + public static Object[] data() { + return new Object[]{ + 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.getMaximalMultiLanguageProperty() + }; + } + + @Test + public void testGeneric() throws IncompatibleTypeException { + SubmodelElement object = submodelElement; + RDFSerializationResult rdfSerializationResult = new DefaultSubmodelElementRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + SubmodelElement submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(submodelElement); + + } + + +} 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 deleted file mode 100644 index ba13ad251..000000000 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java +++ /dev/null @@ -1,37 +0,0 @@ -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.rdf.handlers.DefaultPropertyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.Property; -import org.junit.Test; - -public class SubmodelTest { - - @Test - public void testMinimalProperty() throws IncompatibleTypeException { - Property object = SerializerUtil.getMinimalProperty(); - RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); - rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - - Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); - } - - @Test - public void testMaximalProperty() throws IncompatibleTypeException { - Property object = SerializerUtil.getMaximalProperty(); - RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); - rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - - Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); - } - - -} From 253e62a221a0006d371a805f8d46d9a3196282fa Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 02:12:44 +0100 Subject: [PATCH 014/160] Add Blob --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 +++ .../rdf/handlers/DefaultBlobRDFHandler.java | 53 +++++++++++++++++-- .../v3/dataformat/rdf/SerializerTest.java | 6 +-- .../v3/dataformat/rdf/SerializerUtil.java | 4 +- .../dataformat/rdf/SubmodelElementTest.java | 10 ++-- 5 files changed, 62 insertions(+), 18 deletions(-) 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 index 3bf92b79a..ce58cd114 100644 --- 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 @@ -340,6 +340,13 @@ public static final class Property { ResourceFactory.createProperty(AAS_NAMESPACE + "Property/valueType"); } + 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 AssetAdministrationShell { public static final org.apache.jena.rdf.model.Property assetInformation = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); 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 index a5888e465..4dc157d6f 100644 --- 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 @@ -1,14 +1,20 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -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.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 @@ -18,11 +24,48 @@ public RDFSerializationResult toModel(Blob object) { 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 { - return null; + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 1f6cc12bb..7bf75e1d9 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -12,14 +12,10 @@ import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; public class SerializerTest { - @Test public void testKey() throws IOException { Key simpleKey = new DefaultKey.Builder() 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 index 5a457ecb2..42284d6aa 100644 --- 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 @@ -5,6 +5,7 @@ import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; import java.util.Arrays; +import java.util.Base64; import java.util.List; @@ -322,7 +323,8 @@ static BasicEventElement getMinimalBasicEventElement() { static Blob getMinimalBlob() { return new DefaultBlob.Builder() .idShort("B1") - .contentType("image/png") + .value(Base64.getDecoder().decode("aGVsbG8=")) // a `hello` in a text file + .contentType("plain/text") .build(); } 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 index e8e24b94a..1b124e9cf 100644 --- 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 @@ -1,15 +1,14 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; 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.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; @RunWith(Parameterized.class) public class SubmodelElementTest { @@ -43,11 +42,8 @@ public void testGeneric() throws IncompatibleTypeException { RDFSerializationResult rdfSerializationResult = new DefaultSubmodelElementRDFHandler().toModel(object); rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - SubmodelElement submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); assert object.equals(submodelElement); - } From 2124d3998c6aae2cd2c9063177343dc8b9150db6 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 10:08:55 +0100 Subject: [PATCH 015/160] Add MultiLanguageProperty --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 ++ ...efaultMultiLanguagePropertyRDFHandler.java | 93 +++++++++++++++++-- 2 files changed, 93 insertions(+), 7 deletions(-) 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 index ce58cd114..dcfadd6f6 100644 --- 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 @@ -340,6 +340,13 @@ public static final class Property { 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 9f3d55f79..3ccccb5eb 100644 --- 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 @@ -1,20 +1,99 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.*; import org.apache.jena.rdf.model.Resource; -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.MultiLanguageProperty; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringShortNameTypeIec61360RDFHandler; +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.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultMultiLanguageProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; + +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) { - return null; + 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 { - return null; + 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.Property.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; } } From 8c795206b76abaed61dd5067829b91f65f0a9c65 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:02:15 +0100 Subject: [PATCH 016/160] Add Range --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 9 +++ ...efaultMultiLanguagePropertyRDFHandler.java | 8 +-- .../rdf/handlers/DefaultRangeRDFHandler.java | 63 +++++++++++++++++-- .../v3/dataformat/rdf/SerializerTest.java | 5 +- 4 files changed, 74 insertions(+), 11 deletions(-) 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 index dcfadd6f6..d6d0cfa19 100644 --- 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 @@ -347,6 +347,15 @@ public static final class MultiLanguageProperty { ResourceFactory.createProperty(AAS_NAMESPACE + "MultiLanguageProperty/valueId"); } + 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 3ccccb5eb..62b20c348 100644 --- 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 @@ -1,18 +1,16 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; import org.apache.jena.rdf.model.*; -import org.apache.jena.rdf.model.Resource; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringShortNameTypeIec61360RDFHandler; 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.*; +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 org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; import java.util.ArrayList; import java.util.HashMap; 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 index 9a3395c14..e2c0ec2e0 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 7bf75e1d9..5f07d26fb 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -12,7 +12,10 @@ import org.junit.Test; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class SerializerTest { From 30ffd5477651210cb1bed32330d85bd4d538d884 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:17:49 +0100 Subject: [PATCH 017/160] Add ReferenceElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 5 ++ .../DefaultReferenceElementRDFHandler.java | 55 +++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) 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 index d6d0cfa19..4e228c0bb 100644 --- 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 @@ -356,6 +356,11 @@ public static final class Range { 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 4be19ea9a..4726edda2 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From 0854bab93d93d31b44f47c13b254651695da356a Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:31:47 +0100 Subject: [PATCH 018/160] Add Capability --- .../handlers/DefaultCapabilityRDFHandler.java | 44 ++++++++++++++++--- ...efaultMultiLanguagePropertyRDFHandler.java | 2 +- 2 files changed, 40 insertions(+), 6 deletions(-) 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 index d4db934ee..f9791b6ff 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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/DefaultMultiLanguagePropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java index 62b20c348..b9d8fe0e0 100644 --- 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 @@ -79,7 +79,7 @@ public MultiLanguageProperty fromModel(Model model, Resource subjectToParse) thr builder.value(langStringList); } if (model.contains(subjectToParse, AASNamespace.MultiLanguageProperty.valueId)) { - Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueId).getResource(); + Resource resource = model.getProperty(subjectToParse, AASNamespace.MultiLanguageProperty.valueId).getResource(); Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); builder.valueId(reference); } From 9b7dfb5184d3379a54f98632812b48d93fd1e60e Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:36:25 +0100 Subject: [PATCH 019/160] Add File --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 +++ .../rdf/handlers/DefaultFileRDFHandler.java | 56 +++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) 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 index 4e228c0bb..9b92e1b3b 100644 --- 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 @@ -361,6 +361,13 @@ public static final class ReferenceElement { ResourceFactory.createProperty(AAS_NAMESPACE + "ReferenceElement/value"); } + 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"); 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 index e3d88eecb..e1343dfaa 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From c33fbb416b8e873a487a82988e256942f04af790 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 16:29:36 +0100 Subject: [PATCH 020/160] Add AnnotatedRelationshipElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 220 +++++++++++++++++- ...nnotatedRelationshipElementRDFHandler.java | 96 +++++++- 2 files changed, 307 insertions(+), 9 deletions(-) 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 index 9b92e1b3b..b35b2e3fd 100644 --- 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 @@ -112,13 +112,76 @@ public static final class KeyTypes { 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; } - throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); + 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) { @@ -131,8 +194,77 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { 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 ReferenceType provided."); + throw new IllegalArgumentException("Invalid KeyTypes provided."); } } @@ -331,6 +463,18 @@ public static final class SpecificAssetId { 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"); @@ -361,6 +505,21 @@ public static final class ReferenceElement { ResourceFactory.createProperty(AAS_NAMESPACE + "ReferenceElement/value"); } + 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 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"); @@ -457,6 +616,63 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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"); 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 index 58c083ede..e6f29a0f4 100644 --- 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 @@ -1,12 +1,21 @@ 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.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 @@ -16,15 +25,88 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { 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.AdministrativeInformation)) { - throw new IncompatibleTypeException("AssetAdministrationShell"); + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AnnotatedRelationshipElement)) { + throw new IncompatibleTypeException("AnnotatedRelationshipElement"); } + DefaultAnnotatedRelationshipElement.Builder builder = new DefaultAnnotatedRelationshipElement.Builder(); - return null; + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.annotations(references); + } + //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; } } From dbf2dcf0e2c56c867de1fe995ee99d5e2d41b265 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 17:39:29 +0100 Subject: [PATCH 021/160] Add BasicEventElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 20 ++++ .../DefaultBasicEventElementRDFHandler.java | 104 +++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) 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 index b35b2e3fd..3d36d1b19 100644 --- 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 @@ -510,6 +510,26 @@ public static final class OperationVariable { ResourceFactory.createProperty(AAS_NAMESPACE + "OperationVariable/value"); } + 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 = 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 index cf56a05cf..39b1cc5da 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From db11ed4ad318314f3940e5cf64cbe8bd04ec611f Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:06:08 +0100 Subject: [PATCH 022/160] Add RelationshipElement --- .../DefaultRelationshipElementRDFHandler.java | 64 +++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) 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 index 4d5213f44..1876f1c48 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.RelationshipElement)) { + throw new IncompatibleTypeException("Capability"); + } + 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; } } From c98b51cc421c9ad104c27a9c774f0d72b1b5cd75 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:33:22 +0100 Subject: [PATCH 023/160] Add Entity --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 40 ++++++ .../rdf/handlers/DefaultEntityRDFHandler.java | 124 +++++++++++++++++- 2 files changed, 157 insertions(+), 7 deletions(-) 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 index 3d36d1b19..287147bef 100644 --- 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 @@ -505,6 +505,18 @@ public static final class ReferenceElement { 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"); @@ -636,6 +648,34 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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"); 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 index b77a3ea74..198e3b8a8 100644 --- 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 @@ -1,20 +1,130 @@ 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.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.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) { - return null; + 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()) { + 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 { - return null; + 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()); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + }); + 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()); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + }); + 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; } } From 5f00fe14d654b2d5215fae3fee868ee653b09bc6 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:52:01 +0100 Subject: [PATCH 024/160] Add Operation --- .../handlers/DefaultOperationRDFHandler.java | 140 +++++++++++++++++- .../DefaultOperationVariableRDFHandler.java | 43 ++++++ .../DefaultRelationshipElementRDFHandler.java | 2 +- 3 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationVariableRDFHandler.java 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 index 36b71d462..80b9d978e 100644 --- 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 @@ -1,20 +1,146 @@ 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.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.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) { - return null; + 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.getOutputVariables()) { + 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.getOutputVariables()) { + 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 { - return null; + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.inoutputVariables(references); + } + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.inputVariables(references); + } + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.outputVariables(references); + } + 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/DefaultRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java index 1876f1c48..d722f40e7 100644 --- 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 @@ -47,7 +47,7 @@ public RDFSerializationResult toModel(RelationshipElement object) { @Override public RelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.RelationshipElement)) { - throw new IncompatibleTypeException("Capability"); + throw new IncompatibleTypeException("RelationshipElement"); } DefaultRelationshipElement.Builder builder = new DefaultRelationshipElement.Builder(); if (model.contains(subjectToParse, AASNamespace.RelationshipElement.second)) { From 27d94ef874d05223e0b54f1a424e41cd485abd7c Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:58:10 +0100 Subject: [PATCH 025/160] Add SubmodelElementCollection --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 5 ++ ...ltSubmodelElementCollectionRDFHandler.java | 83 +++++++++++++++++-- 2 files changed, 81 insertions(+), 7 deletions(-) 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 index 287147bef..16707c022 100644 --- 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 @@ -565,6 +565,11 @@ public static final class Blob { 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 AssetAdministrationShell { public static final org.apache.jena.rdf.model.Property assetInformation = 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 index d43abc395..c6f15ac58 100644 --- 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 @@ -1,20 +1,89 @@ 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.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.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.Capability; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultCapability; +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) { - return null; + 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 { - return null; + 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.ConceptDescription.isCaseOf); + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.value(references); + } + 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; } } From 04926b140ccbc7f17adff2755c147bcd9d26c5b4 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 19:24:10 +0100 Subject: [PATCH 026/160] Add SubmodelElementList --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 165 ++++++++++++++++++ ...ltSubmodelElementCollectionRDFHandler.java | 7 +- .../DefaultSubmodelElementListRDFHandler.java | 120 ++++++++++++- 3 files changed, 280 insertions(+), 12 deletions(-) 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 index 16707c022..a8e82dbf8 100644 --- 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 @@ -268,6 +268,156 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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.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"); @@ -565,12 +715,27 @@ public static final class Blob { 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"); 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 index c6f15ac58..3f55115d1 100644 --- 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 @@ -7,11 +7,8 @@ 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.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultCapability; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection; import java.util.ArrayList; @@ -28,7 +25,7 @@ public RDFSerializationResult toModel(SubmodelElementCollection object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.SubmodelElementCollection); - if(object.getValue()!=null && object.getValue().isEmpty()==false){ + if (object.getValue() != null && object.getValue().isEmpty() == false) { int index = 0; for (SubmodelElement item : object.getValue()) { RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); @@ -56,7 +53,7 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) throw new IncompatibleTypeException("SubmodelElementCollection"); } DefaultSubmodelElementCollection.Builder builder = new DefaultSubmodelElementCollection.Builder(); - if(model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)){ + if (model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 0efd20430..8a15da7a5 100644 --- 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 @@ -1,22 +1,128 @@ 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.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.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) { - return null; + 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 { - return null; + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SubmodelElementList)) { + throw new IncompatibleTypeException("SubmodelElementList"); + } + DefaultSubmodelElementList.Builder builder = new DefaultSubmodelElementList.Builder(); + builder.orderRelevant(false); + 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.orderRelevant)) { + builder.orderRelevant(model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.value)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.value(references); + } + 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; } } From 7b61ee3bc2eba786f07909812dcfa55cb0ddb7b5 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 20:18:00 +0100 Subject: [PATCH 027/160] Add Submodel and Environment --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 48 +++++++++ .../v3/dataformat/rdf/RDFSerializer.java | 6 +- ...ultAssetAdministrationShellRDFHandler.java | 2 +- .../DefaultEnvironmentRDFHandler.java | 97 +++++++++++++++++++ .../handlers/DefaultSubmodelRDFHandler.java | 95 ++++++++++++++++++ .../v3/dataformat/rdf/SerializerTest.java | 48 ++++++++- 6 files changed, 289 insertions(+), 7 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEnvironmentRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java 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 index a8e82dbf8..c673bfde5 100644 --- 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 @@ -446,6 +446,7 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } 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"); @@ -641,6 +642,11 @@ public static final class MultiLanguageProperty { 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"); @@ -672,6 +678,15 @@ public static final class OperationVariable { 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"); @@ -767,6 +782,12 @@ public static final class Resource { 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"); @@ -782,6 +803,33 @@ public static final class DataSpecificationIec61360 { 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"); 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 index 328b0d1ea..55f4e4fb7 100644 --- 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 @@ -4,6 +4,7 @@ import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEnvironmentRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -25,7 +26,10 @@ public class RDFSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + 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); } 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 index 201304b3e..aeea4b0e7 100644 --- 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 @@ -22,7 +22,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - Resource subject = model.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()); 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/DefaultSubmodelRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java new file mode 100644 index 000000000..ab4b05448 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java @@ -0,0 +1,95 @@ +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); + }); + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 5f07d26fb..728876fab 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -148,11 +148,49 @@ public void testMaximalQualifier() throws IncompatibleTypeException { @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { - AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder().assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())).displayName(Arrays.asList(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().description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())).displayName(Arrays.asList(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().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(); + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() + .id("test") + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .build()) + .description( + Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("This is a test AAS") + .language("en-us").build())) + .displayName(Arrays.asList(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( + Arrays.asList(new DefaultLangStringTextType.Builder() + .text("My Submodel") + .language("en-us") + .build())) + .displayName(Arrays.asList(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(); From 681d3268eefcc0b2305e8b88d2c1cef4d631d25c Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 8 Feb 2024 13:35:06 +0100 Subject: [PATCH 028/160] Improve tests --- .../v3/dataformat/rdf/SerializerUtil.java | 140 +++++++++++++++++- .../dataformat/rdf/SubmodelElementTest.java | 24 +-- 2 files changed, 146 insertions(+), 18 deletions(-) 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 index 42284d6aa..14fcb24a7 100644 --- 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 @@ -251,6 +251,44 @@ static Property getMinimalProperty() { .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() + ); + } + static Property getMaximalProperty() { return new DefaultProperty.Builder() .idShort("idShort1") @@ -311,6 +349,32 @@ static AnnotatedRelationshipElement getMinimalAnnotatedRelationshipElement() { .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") @@ -320,6 +384,15 @@ static BasicEventElement getMinimalBasicEventElement() { .build(); } + static BasicEventElement getMaximalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .observed(getMinimalReference()) + .build(); + } + static Blob getMinimalBlob() { return new DefaultBlob.Builder() .idShort("B1") @@ -328,12 +401,26 @@ static Blob getMinimalBlob() { .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") @@ -341,6 +428,13 @@ static Entity getMinimalEntity() { .build(); } + static Entity getMaximalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .build(); + } + static File getMinimalFile() { return new DefaultFile.Builder() .idShort("F1") @@ -348,6 +442,13 @@ static File getMinimalFile() { .build(); } + static File getMaximalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + static Range getMinimalRange() { return new DefaultRange.Builder() .idShort("R1") @@ -355,36 +456,73 @@ static Range getMinimalRange() { .build(); } + static Range getMaximalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + static ReferenceElement getMinimalReferenceElement() { return new DefaultReferenceElement.Builder() .idShort("RE1") .build(); } + static ReferenceElement getMaximalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .build(); + } + static RelationshipElement getMinimalRelationshipElement() { return new DefaultRelationshipElement.Builder() .idShort("ReE1") .build(); } + static RelationshipElement getMaximalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .build(); + } + static SubmodelElementCollection getMinimalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() .idShort("SEC1") .build(); } + static SubmodelElementCollection getMaximalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("SEC1") + .build(); + } + static SubmodelElementList getMinimalSubmodelElementList() { return new DefaultSubmodelElementList.Builder() .idShort("SEL1") .build(); } + static SubmodelElementList getMaximalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .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") @@ -428,7 +566,7 @@ static AssetInformation getMaximalAssetInformation() { static AssetAdministrationShell getMinimalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMinimalAssetInformation()) - .id("id1") + .id("AssetAdministrationShell_minimal") .build(); } 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 index 1b124e9cf..559f5978a 100644 --- 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 @@ -10,6 +10,9 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import java.util.LinkedList; +import java.util.List; + @RunWith(Parameterized.class) public class SubmodelElementTest { @Parameter @@ -17,23 +20,10 @@ public class SubmodelElementTest { @Parameters(name = "{index}: SME - {0}") public static Object[] data() { - return new Object[]{ - 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.getMaximalMultiLanguageProperty() - }; + List list = new LinkedList<>(); + list.addAll(SerializerUtil.getMaximalSubmodelElementsList()); + list.addAll(SerializerUtil.getMinimalSubmodelElementsList()); + return list.toArray(); } @Test From 9ebb51275ad9f87cafe5744db2bf26ea66d25fcd Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 8 Feb 2024 13:46:18 +0100 Subject: [PATCH 029/160] Update maven --- dataformat-rdf/pom.xml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index 93a8d4061..aa42713c8 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -5,22 +5,20 @@ 4.0.0 org.eclipse.digitaltwin.aas4j - dataformat-parent + aas4j-dataformat-parent ${revision} - dataformat-rdf + aas4j-dataformat-rdf Asset Administration Shell RDF-Serializer - ${groupId} - dataformat-core - ${revision} + ${project.groupId} + aas4j-dataformat-core - ${groupId} - dataformat-core - ${revision} + ${project.groupId} + aas4j-dataformat-core tests test From 4c56bbe755f19ba9737fa278d0c4e0707bcc5476 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Fri, 9 Feb 2024 07:55:34 +0100 Subject: [PATCH 030/160] Refactors package structure to better reflect public API (#246) * Refactors package structure to better reflect public API * Fixes wrong names in ReflectionHelper --------- Signed-off-by: Frank Schnicke --- .../v3/dataformat/aasx/AASXDeserializer.java | 2 +- .../v3/dataformat/aasx/AASXSerializer.java | 2 +- .../deserialization/AASXDeserializerTest.java | 4 +-- .../aasx/deserialization/ValidationTest.java | 4 +-- .../serialization/AASXSerializerTest.java | 2 +- .../{ => core}/DeserializationException.java | 2 +- .../{ => core}/SchemaValidator.java | 2 +- .../{ => core}/SerializationException.java | 2 +- .../deserialization/EnumDeserializer.java | 2 +- .../serialization/EnumSerializer.java | 5 +-- .../{ => internal}/util/ReflectionHelper.java | 31 ++++++++++--------- .../v3/dataformat/core/util/AasUtils.java | 19 ++++++------ .../dataformat/core/EnumDeserializerTest.java | 3 +- .../dataformat/core/EnumSerializerTest.java | 3 +- .../v3/dataformat/json/JsonDeserializer.java | 2 +- .../v3/dataformat/json/JsonMapperFactory.java | 6 ++-- .../dataformat/json/JsonSchemaValidator.java | 3 +- .../v3/dataformat/json/JsonSerializer.java | 2 +- .../SimpleAbstractTypeResolverFactory.java | 2 +- .../ReflectionAnnotationIntrospector.java | 3 +- .../mixins/AssetAdministrationShellMixin.java | 2 +- .../mixins/AssetInformationMixin.java | 2 +- .../json/{ => internal}/mixins/BlobMixin.java | 2 +- .../DataSpecificationIec61360Mixin.java | 2 +- .../{ => internal}/mixins/EndpointMixin.java | 2 +- .../{ => internal}/mixins/EntityMixin.java | 2 +- .../mixins/EnvironmentMixin.java | 2 +- .../{ => internal}/mixins/ExtensionMixin.java | 2 +- .../json/{ => internal}/mixins/FileMixin.java | 2 +- .../mixins/IdentifiableMixin.java | 2 +- .../json/{ => internal}/mixins/KeyMixin.java | 2 +- .../mixins/OperationVariableMixin.java | 2 +- .../{ => internal}/mixins/QualifierMixin.java | 2 +- .../{ => internal}/mixins/RangeMixin.java | 2 +- .../{ => internal}/mixins/ReferenceMixin.java | 2 +- .../mixins/RelationshipElementMixin.java | 2 +- .../mixins/SubmodelElementListMixin.java | 2 +- .../dataformat/json/JsonDeserializerTest.java | 7 +++-- .../dataformat/json/JsonSerializerTest.java | 2 +- .../v3/dataformat/xml/XmlDeserializer.java | 9 +++--- .../v3/dataformat/xml/XmlSchemaValidator.java | 2 +- .../v3/dataformat/xml/XmlSerializer.java | 11 ++++--- .../XmlDataformatAnnotationIntrospector.java | 3 +- .../AbstractLangStringsDeserializer.java | 5 +-- .../CustomJsonNodeDeserializer.java | 2 +- .../DataElementsDeserializer.java | 2 +- .../DeserializationHelper.java | 2 +- ...mbeddedDataSpecificationsDeserializer.java | 5 +-- .../deserialization/KeyDeserializer.java | 2 +- .../deserialization/KeysDeserializer.java | 2 +- .../LangStringContentDeserializer.java | 5 +-- ...ngsDefinitionTypeIec61360Deserializer.java | 4 +-- .../LangStringsNameTypeDeserializer.java | 4 +-- ...PreferredNameTypeIec61360Deserializer.java | 4 +-- ...ingsShortNameTypeIec61360Deserializer.java | 4 +-- .../LangStringsTextTypeDeserializer.java | 4 +-- .../NoEntryWrapperListDeserializer.java | 2 +- .../OperationVariableDeserializer.java | 2 +- .../QualifierDeserializer.java | 2 +- .../ReferencesDeserializer.java | 2 +- .../SubmodelElementDeserializer.java | 2 +- .../SubmodelElementsDeserializer.java | 2 +- .../ValueReferencePairNodeDeserializer.java | 2 +- .../ValueReferencePairsDeserializer.java | 2 +- .../AdministrativeInformationMixin.java | 2 +- .../AnnotatedRelationshipElementMixin.java | 7 +++-- .../mixins/AssetAdministrationShellMixin.java | 2 +- .../mixins/AssetInformationMixin.java | 2 +- .../mixins/ConceptDescriptionMixin.java | 2 +- .../DataSpecificationIec61360Mixin.java | 17 +++++----- .../EmbeddedDataSpecificationMixin.java | 7 +++-- .../{ => internal}/mixins/EntityMixin.java | 7 +++-- .../mixins/EnvironmentMixin.java | 2 +- .../{ => internal}/mixins/ExtensionMixin.java | 5 +-- .../mixins/HasDataSpecificationMixin.java | 2 +- .../mixins/HasExtensionsMixin.java | 2 +- .../mixins/HasSemanticsMixin.java | 5 +-- .../xml/{ => internal}/mixins/KeyMixin.java | 2 +- .../{ => internal}/mixins/LevelTypeMixin.java | 2 +- .../mixins/MultiLanguagePropertyMixin.java | 5 +-- .../{ => internal}/mixins/OperationMixin.java | 5 +-- .../mixins/OperationVariableMixin.java | 7 +++-- .../{ => internal}/mixins/PropertyMixin.java | 2 +- .../mixins/QualifiableMixin.java | 5 +-- .../{ => internal}/mixins/QualifierMixin.java | 2 +- .../{ => internal}/mixins/ReferableMixin.java | 11 ++++--- .../{ => internal}/mixins/ReferenceMixin.java | 5 +-- .../{ => internal}/mixins/ResourceMixin.java | 2 +- .../mixins/SpecificAssetIdMixin.java | 2 +- .../SubmodelElementCollectionMixin.java | 7 +++-- .../mixins/SubmodelElementListMixin.java | 7 +++-- .../mixins/SubmodelElementMixin.java | 2 +- .../{ => internal}/mixins/SubmodelMixin.java | 7 +++-- .../{ => internal}/mixins/ValueListMixin.java | 5 +-- .../mixins/ValueReferencePairMixin.java | 2 +- .../AbstractLangStringSerializer.java | 2 +- .../AbstractLangStringsSerializer.java | 5 +-- ...inistrationShellEnvironmentSerializer.java | 5 +-- .../serialization/DataElementsSerializer.java | 2 +- .../EmbeddedDataSpecificationSerializer.java | 2 +- ...ringsDefinitionTypeIec61360Serializer.java | 2 +- .../LangStringsNameTypeSerializer.java | 5 +-- ...gsPreferredNameTypeIec61360Serializer.java | 2 +- ...tringsShortNameTypeIec61360Serializer.java | 2 +- .../LangStringsTextTypeSerializer.java | 2 +- .../NoEntryWrapperListSerializer.java | 2 +- .../OperationVariableSerializer.java | 2 +- .../serialization/RefersToSerializer.java | 5 +-- .../SubmodelElementSerializer.java | 2 +- .../SubmodelElementsSerializer.java | 5 +-- .../util}/LangStringContent.java | 2 +- .../dataformat/xml/XMLDeserializerTest.java | 4 +-- .../v3/dataformat/xml/XmlSerializerTest.java | 6 ++-- 113 files changed, 231 insertions(+), 198 deletions(-) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/{ => core}/DeserializationException.java (94%) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/{ => core}/SchemaValidator.java (95%) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/{ => core}/SerializationException.java (94%) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/{ => internal}/deserialization/EnumDeserializer.java (96%) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/{ => internal}/serialization/EnumSerializer.java (95%) rename dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/{ => internal}/util/ReflectionHelper.java (95%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/AssetAdministrationShellMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/AssetInformationMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/BlobMixin.java (91%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/DataSpecificationIec61360Mixin.java (90%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/EndpointMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/EntityMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/EnvironmentMixin.java (94%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/ExtensionMixin.java (91%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/FileMixin.java (91%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/IdentifiableMixin.java (89%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/KeyMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/OperationVariableMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/QualifierMixin.java (91%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/RangeMixin.java (91%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/ReferenceMixin.java (93%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/RelationshipElementMixin.java (92%) rename dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/{ => internal}/mixins/SubmodelElementListMixin.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/AbstractLangStringsDeserializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/CustomJsonNodeDeserializer.java (91%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/DataElementsDeserializer.java (97%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/DeserializationHelper.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/EmbeddedDataSpecificationsDeserializer.java (93%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/KeyDeserializer.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/KeysDeserializer.java (91%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringContentDeserializer.java (86%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringsDefinitionTypeIec61360Deserializer.java (88%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringsNameTypeDeserializer.java (87%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringsPreferredNameTypeIec61360Deserializer.java (89%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringsShortNameTypeIec61360Deserializer.java (88%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/LangStringsTextTypeDeserializer.java (87%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/NoEntryWrapperListDeserializer.java (97%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/OperationVariableDeserializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/QualifierDeserializer.java (97%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/ReferencesDeserializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/SubmodelElementDeserializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/SubmodelElementsDeserializer.java (98%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/ValueReferencePairNodeDeserializer.java (94%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/deserialization/ValueReferencePairsDeserializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/AdministrativeInformationMixin.java (93%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/AnnotatedRelationshipElementMixin.java (79%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/AssetAdministrationShellMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/AssetInformationMixin.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ConceptDescriptionMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/DataSpecificationIec61360Mixin.java (83%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/EmbeddedDataSpecificationMixin.java (85%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/EntityMixin.java (84%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/EnvironmentMixin.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ExtensionMixin.java (86%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/HasDataSpecificationMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/HasExtensionsMixin.java (94%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/HasSemanticsMixin.java (90%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/KeyMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/LevelTypeMixin.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/MultiLanguagePropertyMixin.java (89%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/OperationMixin.java (87%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/OperationVariableMixin.java (83%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/PropertyMixin.java (93%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/QualifiableMixin.java (90%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/QualifierMixin.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ReferableMixin.java (80%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ReferenceMixin.java (91%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ResourceMixin.java (94%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/SpecificAssetIdMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/SubmodelElementCollectionMixin.java (82%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/SubmodelElementListMixin.java (90%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/SubmodelElementMixin.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/SubmodelMixin.java (85%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ValueListMixin.java (90%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/mixins/ValueReferencePairMixin.java (94%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/AbstractLangStringSerializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/AbstractLangStringsSerializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/AssetAdministrationShellEnvironmentSerializer.java (97%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/DataElementsSerializer.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/EmbeddedDataSpecificationSerializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/LangStringsDefinitionTypeIec61360Serializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/LangStringsNameTypeSerializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/LangStringsPreferredNameTypeIec61360Serializer.java (93%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/LangStringsShortNameTypeIec61360Serializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/LangStringsTextTypeSerializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/NoEntryWrapperListSerializer.java (97%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/OperationVariableSerializer.java (95%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/RefersToSerializer.java (93%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/SubmodelElementSerializer.java (96%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{ => internal}/serialization/SubmodelElementsSerializer.java (92%) rename dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/{helper => internal/util}/LangStringContent.java (93%) 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..f6ab72a13 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 @@ -31,8 +31,8 @@ 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.xml.XmlDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.File; 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..8eb4a9090 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 @@ -31,8 +31,8 @@ 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.xml.XmlSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.File; 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..4cd02eeba 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,12 @@ 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.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; 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..a62341725 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; 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..aa23825ed 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,10 +16,10 @@ 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.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException; import org.junit.Before; import org.junit.Test; diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/DeserializationException.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/DeserializationException.java similarity index 94% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/DeserializationException.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/DeserializationException.java index 26e0f1868..ac0262486 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/DeserializationException.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/DeserializationException.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; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core; @SuppressWarnings("serial") public class DeserializationException extends Exception { diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SchemaValidator.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SchemaValidator.java similarity index 95% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SchemaValidator.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SchemaValidator.java index 3cff51469..c246a591e 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SchemaValidator.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SchemaValidator.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; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core; import java.util.Set; diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SerializationException.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SerializationException.java similarity index 94% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SerializationException.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SerializationException.java index 981d657cb..e4da3d766 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/SerializationException.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/SerializationException.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; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core; @SuppressWarnings("serial") public class SerializationException extends Exception { diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/deserialization/EnumDeserializer.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/deserialization/EnumDeserializer.java similarity index 96% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/deserialization/EnumDeserializer.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/deserialization/EnumDeserializer.java index ebd49fbff..74b46f252 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/deserialization/EnumDeserializer.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/deserialization/EnumDeserializer.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.core.deserialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/serialization/EnumSerializer.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/serialization/EnumSerializer.java similarity index 95% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/serialization/EnumSerializer.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/serialization/EnumSerializer.java index 56b88f1af..842482d90 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/serialization/EnumSerializer.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/serialization/EnumSerializer.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -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.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.Direction; diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java similarity index 95% rename from dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java rename to dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java index 41b64858a..b571972c7 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java @@ -13,19 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; - -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; -import org.apache.commons.lang3.ClassUtils; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.MostSpecificTypeTokenComparator; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util; import java.lang.reflect.Field; import java.util.ArrayList; @@ -37,6 +25,19 @@ 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. @@ -58,12 +59,12 @@ public class ReflectionHelper { * 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.mixins"; + 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.mixins"; + public static final String XML_MIXINS_PACKAGE_NAME = ROOT_PACKAGE_NAME + ".dataformat.xml.internal.mixins"; /** * Suffix that identifies a class as a mixin. */ 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..b1f210bdd 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 @@ -23,13 +23,18 @@ import java.util.Comparator; 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 java.util.stream.Stream; -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.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.MostSpecificTypeTokenComparator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.serialization.EnumSerializer; +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.Identifiable; import org.eclipse.digitaltwin.aas4j.v3.model.Key; @@ -37,16 +42,12 @@ 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; 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 @@ -55,8 +56,6 @@ 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"); 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-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..de24180aa 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 @@ -23,7 +23,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; 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..3ffa080b8 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 @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; 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 90% 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..f1766b2a8 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 @@ -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/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 89% 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..dcf651251 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 @@ -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/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-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlDeserializer.java index 38965664a..679760b05 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlDeserializer.java @@ -23,11 +23,12 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.dataformat.xml.XmlFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.deserialization.EnumDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.deserialization.SubmodelElementDeserializer; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.XmlDataformatAnnotationIntrospector; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.deserialization.SubmodelElementDeserializer; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSchemaValidator.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSchemaValidator.java index 35dd015bb..deef0614c 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSchemaValidator.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSchemaValidator.java @@ -15,7 +15,7 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SchemaValidator; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SchemaValidator; import org.xml.sax.SAXException; import javax.xml.XMLConstants; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializer.java index eda8f98f7..86990f7a7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializer.java @@ -24,12 +24,13 @@ import com.fasterxml.jackson.dataformat.xml.XmlFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; -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.SerializationException; +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.xml.internal.XmlDataformatAnnotationIntrospector; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.AssetAdministrationShellEnvironmentSerializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.OperationVariableSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.AssetAdministrationShellEnvironmentSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.serialization.OperationVariableSerializer; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/XmlDataformatAnnotationIntrospector.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/XmlDataformatAnnotationIntrospector.java index 2fc785819..e0ac3d224 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/XmlDataformatAnnotationIntrospector.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/XmlDataformatAnnotationIntrospector.java @@ -21,10 +21,11 @@ import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.dataformat.xml.JacksonXmlAnnotationIntrospector; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.ReflectionHelper; import java.util.Collection; +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. It will automatically add a default namespace diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/AbstractLangStringsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/AbstractLangStringsDeserializer.java similarity index 92% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/AbstractLangStringsDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/AbstractLangStringsDeserializer.java index dec133fca..04d215e8a 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/AbstractLangStringsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/AbstractLangStringsDeserializer.java @@ -14,14 +14,15 @@ * 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; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; -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.AbstractLangString; import java.io.IOException; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/CustomJsonNodeDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/CustomJsonNodeDeserializer.java similarity index 91% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/CustomJsonNodeDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/CustomJsonNodeDeserializer.java index 7d15fab24..20d96da24 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/CustomJsonNodeDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/CustomJsonNodeDeserializer.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/DataElementsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java similarity index 97% rename from dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/DataElementsDeserializer.java rename to dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java index cc3972177..c2fd58d42 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/deserialization/DataElementsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.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/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 97% 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..81cfb79ee 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,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 java.io.IOException; import java.util.ArrayList; 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 96% 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..d2c970aa0 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,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/QualifierDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java similarity index 97% 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..cb6d251ec 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,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/ReferencesDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java similarity index 96% 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..7c927e018 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,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/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 98% 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..0fd407cb8 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; 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 85% 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..949e03d1e 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 @@ -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.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.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; 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; From 79018a3922d4429c46b45965ff599667a8f3ec37 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Sat, 10 Feb 2024 12:16:06 +0100 Subject: [PATCH 031/160] Fix Operation --- .../v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java | 2 ++ 4 files changed, 8 insertions(+) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java 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..4a9274ef5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;public class DefaultReferableRDFHandler { +} 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..c79fa2be3 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class EnvironemntTest { +} 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..1f0cf68a5 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SubmodelTest { +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java new file mode 100644 index 000000000..7bf4c32e8 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class TestCustomClass { +} From 16895e90ab1191b8d0e4fddd9842c6ae341680d3 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Sat, 10 Feb 2024 14:36:30 +0100 Subject: [PATCH 032/160] Fix tests --- .../v3/dataformat/core/CustomProperty.java | 15 +- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 30 +++- ...nnotatedRelationshipElementRDFHandler.java | 10 +- ...ultAssetAdministrationShellRDFHandler.java | 10 +- .../DefaultAssetInformationRDFHandler.java | 10 +- .../DefaultConceptDescriptionRDFHandler.java | 10 +- ...ultDataSpecificationContentRDFHandler.java | 4 +- ...ltDataSpecificationIEC61360RDFHandler.java | 37 +++-- .../rdf/handlers/DefaultEntityRDFHandler.java | 30 ++-- .../handlers/DefaultExtensionRDFHandler.java | 10 +- .../rdf/handlers/DefaultKeyRDFHandler.java | 9 +- .../DefaultLangStringNameTypeRDFHandler.java | 2 +- .../DefaultLangStringTextTypeRDFHandler.java | 2 +- .../handlers/DefaultOperationRDFHandler.java | 34 +++-- .../handlers/DefaultPropertyRDFHandler.java | 10 +- .../handlers/DefaultReferableRDFHandler.java | 53 ++++++- .../handlers/DefaultReferenceRDFHandler.java | 7 +- ...ltSubmodelElementCollectionRDFHandler.java | 12 +- .../DefaultSubmodelElementListRDFHandler.java | 18 +-- .../DefaultSubmodelElementRDFHandler.java | 2 +- .../handlers/DefaultSubmodelRDFHandler.java | 10 +- ...tringDefinitionTypeIec61360RDFHandler.java | 2 +- ...StringShortNameTypeIec61360RDFHandler.java | 15 +- .../DefaultLevelTypeRDFHandler.java | 22 ++- .../DefaultValueListRDFHandler.java | 55 ++++--- ...HasDataSpecificationRDFPartialHandler.java | 15 +- .../DefaultHasSemanticsRDFPartialHandler.java | 10 +- .../DefaultQualifiableRDFPartialHandler.java | 10 +- .../DefaultReferableRDFPartialHandler.java | 30 ++-- .../rdf/AssetAdministrationShellTest.java | 95 ++++-------- .../rdf/ConceptDescriptionTest.java | 60 ++++---- .../rdf/DataSpecificationIec61360Test.java | 1 - .../v3/dataformat/rdf/EnvironmentTest.java | 52 ++++++- .../v3/dataformat/rdf/SerializerTest.java | 78 +++++++++- .../v3/dataformat/rdf/SerializerUtil.java | 143 +++++++++++++----- .../dataformat/rdf/SubmodelElementTest.java | 8 +- .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 68 ++++++++- .../v3/dataformat/rdf/TestCustomClass.java | 29 +++- 38 files changed, 695 insertions(+), 323 deletions(-) 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-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 index c673bfde5..8ebe2468d 100644 --- 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 @@ -2,6 +2,8 @@ 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. */ @@ -360,9 +362,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements fromIRI } 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.ANNOTATED_RELATIONSHIP_ELEMENT.name())) { return AnnotatedRelationshipElement; } @@ -416,6 +416,8 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } throw new IllegalArgumentException("Invalid AasSubmodelElements provided."); } + + } public static final class ReferenceTypes { @@ -446,7 +448,10 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } 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 Environment = + ResourceFactory.createResource(AAS_NAMESPACE + "Environment"); public static final org.apache.jena.rdf.model.Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); @@ -522,6 +527,23 @@ public static final class Types { 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 { 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 index e6f29a0f4..a4b854983 100644 --- 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 @@ -81,11 +81,13 @@ public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToPar int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.annotations(references); } //RelationshipElement if (model.contains(subjectToParse, AASNamespace.RelationshipElement.first)) { 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 index aeea4b0e7..425858d0f 100644 --- 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 @@ -76,11 +76,13 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.submodels(langStringList); } if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom).getResource(); 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 index 64fbbced4..e9ee94179 100644 --- 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 @@ -90,11 +90,13 @@ public AssetInformation fromModel(Model model, Resource subjectToParse) throws I int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List specificAssetIds = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - specificAssetIds.add(keysMap.get(index)); + 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); } - builder.specificAssetIds(specificAssetIds); } return builder.build(); } 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 index 2bfd7c4b4..feac5988b 100644 --- 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 @@ -65,11 +65,13 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.isCaseOf(references); } ConceptDescription object = builder.build(); //Identifiable 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 index efa686c95..8d3b497e8 100644 --- 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 @@ -20,7 +20,7 @@ public RDFSerializationResult toModel(DataSpecificationContent object) { throw new IllegalArgumentException("Provided object " + object.getClass() + - " is not a known type"); + " is not a known DataSpecificationContent"); } @Override @@ -32,6 +32,6 @@ public DataSpecificationContent fromModel(Model model, Resource subjectToParse) //Other data specification content should be discriminated here. throw new IllegalArgumentException("Provided Resource " + typeStatement.getResource().getURI() + - " is not a SubmodelElement"); + " 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 index 44205388b..5058e05e9 100644 --- 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 @@ -102,17 +102,20 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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); } - 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)); + 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); } - builder.preferredName(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName); @@ -127,11 +130,13 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.shortName(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.definition)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.definition); @@ -146,11 +151,13 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.definition(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unit)) { builder.unit(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unit).getString()); @@ -190,8 +197,6 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) .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/DefaultEntityRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java index 198e3b8a8..850426423 100644 --- 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 @@ -43,7 +43,7 @@ public RDFSerializationResult toModel(Entity object) { if (object.getGlobalAssetId() != null) { model.add(subject, AASNamespace.Entity.globalAssetId, object.getGlobalAssetId()); } - if (object.getSpecificAssetIds() != null && !object.getSpecificAssetIds().isEmpty()) { + if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -78,17 +78,19 @@ public Entity fromModel(Model model, Resource subjectToParse) throws Incompatibl 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); }); - List submodelElements = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - submodelElements.add(keysMap.get(index)); + 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); } - builder.statements(submodelElements); } if (model.contains(subjectToParse, AASNamespace.Entity.globalAssetId)) { builder.globalAssetId(model.getProperty(subjectToParse, AASNamespace.Entity.globalAssetId).getString()); @@ -104,17 +106,19 @@ public Entity fromModel(Model model, Resource subjectToParse) throws Incompatibl 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); }); - List specificAssetIds = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - specificAssetIds.add(keysMap.get(index)); + 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); } - builder.specificAssetIds(specificAssetIds); } Entity object = builder.build(); //HasDataSpecification 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 index a30613c46..4a8eab390 100644 --- 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 @@ -76,11 +76,13 @@ public Extension fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.refersTo(references); } //HasSemantics Extension object = builder.build(); 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 index b4910e6d9..d7c30d72c 100644 --- 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 @@ -5,10 +5,7 @@ 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.AASNamespace; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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; @@ -30,9 +27,9 @@ public RDFSerializationResult toModel(Key key) { return new DefaultRDFHandlerResult(model, subject); } - public Key fromModel(Model model, Resource subjectToParse) { + public Key fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key)) { - throw new IllegalArgumentException("Provided Resource is not a Key"); + throw new IncompatibleTypeException("Key"); } DefaultKey.Builder builder = new DefaultKey.Builder(); if (model.contains(subjectToParse, AASNamespace.Key.value)) { 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 index b4f483b14..d65cd543a 100644 --- 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 @@ -31,7 +31,7 @@ public RDFSerializationResult toModel(LangStringNameType object) { @Override public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); + throw new IncompatibleTypeException("LangStringNameType"); } DefaultLangStringNameType.Builder builder = new DefaultLangStringNameType.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 7c745524d..88e20bb35 100644 --- 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 @@ -30,7 +30,7 @@ public RDFSerializationResult toModel(LangStringTextType object) { @Override public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); + throw new IncompatibleTypeException("LangStringTextType"); } DefaultLangStringTextType.Builder builder = new DefaultLangStringTextType.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 80b9d978e..6422502dc 100644 --- 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 @@ -27,7 +27,7 @@ public RDFSerializationResult toModel(Operation object) { model.add(subject, RDF.type, AASNamespace.Types.Operation); if (object.getInoutputVariables() != null && object.getInoutputVariables().isEmpty() == false) { int index = 0; - for (OperationVariable item : object.getOutputVariables()) { + 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()); @@ -38,7 +38,7 @@ public RDFSerializationResult toModel(Operation object) { } if (object.getInputVariables() != null && object.getInputVariables().isEmpty() == false) { int index = 0; - for (OperationVariable item : object.getOutputVariables()) { + 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()); @@ -88,11 +88,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.inoutputVariables(references); } if (model.contains(subjectToParse, AASNamespace.Operation.inputVariables)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.inputVariables); @@ -107,11 +109,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.inputVariables(references); } if (model.contains(subjectToParse, AASNamespace.Operation.outputVariables)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.outputVariables); @@ -126,11 +130,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.outputVariables(references); } Operation object = builder.build(); //HasDataSpecification 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 index b1fc18b48..7f5b847eb 100644 --- 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 @@ -51,21 +51,21 @@ public Property fromModel(Model model, Resource subjectToParse) throws Incompati if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property)) { throw new IncompatibleTypeException("Property"); } - DefaultProperty.Builder builder = new DefaultProperty.Builder(); + //TODO: Get this from supplier + Property object = new DefaultProperty(); if (model.contains(subjectToParse, AASNamespace.Property.value)) { - builder.value(model.getProperty(subjectToParse, AASNamespace.Property.value).getString()); + 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); - builder.valueId(reference); + object.setValueId(reference); } if (model.contains(subjectToParse, AASNamespace.Property.valueType)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueType).getResource(); - builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + object.setValueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); } - Property object = builder.build(); //HasDataSpecification new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasSemantics 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 index 4a9274ef5..e234176d1 100644 --- 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 @@ -1,2 +1,53 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;public class DefaultReferableRDFHandler { +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/DefaultReferenceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java index d2a152450..b3cd5517d 100644 --- 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 @@ -46,7 +46,12 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); keysIterator.forEachRemaining(node -> { - Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + Key key = null; + try { + key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); keysMap.put(index, key); }); 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 index 3f55115d1..06f527d4b 100644 --- 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 @@ -54,7 +54,7 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) } DefaultSubmodelElementCollection.Builder builder = new DefaultSubmodelElementCollection.Builder(); if (model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)) { - NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementCollection.value); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { SubmodelElement key = null; @@ -66,11 +66,13 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.value(references); } SubmodelElementCollection object = builder.build(); //HasDataSpecification 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 index 8a15da7a5..60cf1f3a8 100644 --- 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 @@ -70,7 +70,7 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw throw new IncompatibleTypeException("SubmodelElementList"); } DefaultSubmodelElementList.Builder builder = new DefaultSubmodelElementList.Builder(); - builder.orderRelevant(false); + builder.orderRelevant(true); if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant)) { builder.orderRelevant(model.getProperty(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); @@ -91,12 +91,8 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw AASNamespace.SubmodelElementList.typeValueListElement).getResource(); builder.typeValueListElement(AASNamespace.AasSubmodelElements.fromIRI(resource.getURI())); } - if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant)) { - builder.orderRelevant(model.getProperty(subjectToParse, - AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); - } if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.value)) { - NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementList.value); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { SubmodelElement key = null; @@ -108,11 +104,13 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.value(references); } SubmodelElementList object = builder.build(); //HasDataSpecification 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 index 1d6dce76f..b8f0add58 100644 --- 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 @@ -59,7 +59,7 @@ public RDFSerializationResult toModel(SubmodelElement object) { throw new IllegalArgumentException("Provided object " + object.getClass() + - " is not a known type"); + " is not a known SubmodelElement"); } @Override 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 index ab4b05448..9bf6a0893 100644 --- 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 @@ -70,11 +70,13 @@ public Submodel fromModel(Model model, Resource subjectToParse) throws Incompati int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List submodelElements = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - submodelElements.add(keysMap.get(index)); + 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); } - builder.submodelElements(submodelElements); } //HasKind if (model.contains(subjectToParse, AASNamespace.HasKind.kind)) { 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 index c96bab8e9..10c1599e9 100644 --- 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 @@ -30,7 +30,7 @@ public RDFSerializationResult toModel(LangStringDefinitionTypeIec61360 object) { @Override public LangStringDefinitionTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringDefinitionTypeIec61360)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringDefinitionTypeIec61360"); + throw new IncompatibleTypeException("LangStringDefinitionTypeIec61360"); } DefaultLangStringDefinitionTypeIec61360.Builder builder = new DefaultLangStringDefinitionTypeIec61360.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 7db3cb95d..c70cbba54 100644 --- 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 @@ -30,12 +30,15 @@ public RDFSerializationResult toModel(LangStringShortNameTypeIec61360 object) { @Override public LangStringShortNameTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringShortNameTypeIec61360"); + throw new IncompatibleTypeException("LangStringShortNameTypeIec61360"); } - - return new DefaultLangStringShortNameTypeIec61360.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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 index 7fbb47d40..876203b4f 100644 --- 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 @@ -28,13 +28,21 @@ public RDFSerializationResult toModel(LevelType object) { @Override public LevelType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LevelType)) { - throw new IllegalArgumentException("Provided Resource is not a LevelType"); + throw new IncompatibleTypeException("LevelType"); } - return new DefaultLevelType.Builder() - .min(model.getProperty(subjectToParse, AASNamespace.LevelType.min).getBoolean()) - .max(model.getProperty(subjectToParse, AASNamespace.LevelType.max).getBoolean()) - .nom(model.getProperty(subjectToParse, AASNamespace.LevelType.nom).getBoolean()) - .typ(model.getProperty(subjectToParse, AASNamespace.LevelType.typ).getBoolean()) - .build(); + 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 index efdbdfe31..97c802a47 100644 --- 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 @@ -21,14 +21,17 @@ public RDFSerializationResult toModel(ValueList object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.ValueList); - 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++; + 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); } @@ -37,24 +40,28 @@ public ValueList fromModel(Model model, Resource subjectToParse) throws Incompat if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueList)) { throw new IncompatibleTypeException("ValueList"); } - 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); + 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); - }); - List valueReferencePairList = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - valueReferencePairList.add(keysMap.get(index)); } - return new DefaultValueList.Builder() - .valueReferencePairs(valueReferencePairList) - .build(); + 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 index f767d7005..a1e15f6a8 100644 --- 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 @@ -42,17 +42,20 @@ public HasDataSpecification partialFromModel(HasDataSpecification object, Model 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); } - int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index, key); + }); - List keys = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - keys.add(keysMap.get(index)); + 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); } - object.setEmbeddedDataSpecifications(keys); } 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 index 8a0ee2a98..c6f7e4404 100644 --- 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 @@ -58,11 +58,13 @@ public HasSemantics partialFromModel(HasSemantics object, Model model, Resource 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)); + 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); } - object.setSupplementalSemanticIds(langStringList); } 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 index a4644169f..31eb55b22 100644 --- 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 @@ -47,11 +47,13 @@ public Qualifiable partialFromModel(Qualifiable object, Model model, Resource su 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)); + 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); } - object.setQualifiers(langStringList); } 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 index 92809acc0..fd39940e6 100644 --- 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 @@ -88,11 +88,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setDescription(langStringList); } if (model.contains(subjectToParse, AASNamespace.Referable.displayName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.displayName); @@ -107,11 +109,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setDisplayName(langStringList); } //HasExtension @@ -128,11 +132,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setExtensions(langStringList); } return object; } 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 index 815a50b75..d97c1b92a 100644 --- 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 @@ -3,92 +3,49 @@ 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.dataformat.rdf.handlers.DefaultAssetInformationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultResourceRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSpecificAssetIdRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -public class AssetAdministrationShellTest { - - @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); +import java.util.LinkedList; +import java.util.List; +import static org.junit.Assert.assertEquals; - AssetInformation recreatedObject = new DefaultAssetInformationRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); +@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 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); - } @Test - public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); - assert object.equals(recreatedObject); + assertEquals(object, recreatedObject); } - @Test - public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); - 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); - assert object.equals(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 index 308ee96ed..4dfd9e272 100644 --- 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 @@ -3,49 +3,55 @@ 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.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) public class ConceptDescriptionTest { - @Test - public void simpleConceptDescription() throws IOException, IncompatibleTypeException { - ConceptDescription object = new DefaultConceptDescription.Builder() - .id("simple") - .build(); - RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); - Model model = rdfSerializationResult.getModel(); - model.write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); - assert object.equals(recreatedObject); + @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 complexConceptDescription() throws IncompatibleTypeException { - ConceptDescription object = 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.getEmbeddedDataSpecifications()) - .build(); + 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); - assert object.equals(recreatedObject); + 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 index cf2849d93..a14e9012e 100644 --- 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 @@ -80,7 +80,6 @@ public void testDataSpecificationIec61360() throws IncompatibleTypeException { model.write(System.out, Lang.TTL.getName()); Resource createdResource = rdfSerializationResult.getResource(); assert model.contains(createdResource, RDF.type, AASNamespace.Types.DataSpecificationIec61360); -// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); assert dataSpecificationIec61360.equals(recreatedDataSpecification); 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 index c79fa2be3..1d26e6026 100644 --- 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 @@ -1,2 +1,52 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class EnvironemntTest { +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 testConceptDescription() 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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 728876fab..080f3ece7 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -13,14 +13,13 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; public class SerializerTest { @Test - public void testKey() throws IOException { + public void testKey() throws IOException, IncompatibleTypeException { Key simpleKey = new DefaultKey.Builder() .value("simple") .type(KeyTypes.GLOBAL_REFERENCE) @@ -88,7 +87,7 @@ public void testMaximalAdministrativeInformation() throws IncompatibleTypeExcept public void testReference() throws IncompatibleTypeException { Reference reference = new DefaultReference.Builder() .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys(Arrays.asList( + .keys(List.of( new DefaultKey.Builder() .value("https://example.com") .type(KeyTypes.GLOBAL_REFERENCE) @@ -106,6 +105,20 @@ public void testReference() throws IncompatibleTypeException { 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 { @@ -154,11 +167,11 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE .assetKind(AssetKind.INSTANCE) .build()) .description( - Arrays.asList( + List.of( new DefaultLangStringTextType.Builder() .text("This is a test AAS") .language("en-us").build())) - .displayName(Arrays.asList(new DefaultLangStringNameType.Builder() + .displayName(List.of(new DefaultLangStringNameType.Builder() .text("Anzeigename 2").language("de").build(), new DefaultLangStringNameType.Builder().text("Display Name 1") .language("en").build())).build(); @@ -166,11 +179,11 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE Submodel submodel = new DefaultSubmodel.Builder() .id("example") .description( - Arrays.asList(new DefaultLangStringTextType.Builder() + List.of(new DefaultLangStringTextType.Builder() .text("My Submodel") .language("en-us") .build())) - .displayName(Arrays.asList(new DefaultLangStringNameType.Builder() + .displayName(List.of(new DefaultLangStringNameType.Builder() .text("First Submodel Element name") .language("en").build(), new DefaultLangStringNameType.Builder() @@ -199,5 +212,56 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE 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/SerializerUtil.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java index 14fcb24a7..d81be9685 100644 --- 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 @@ -4,15 +4,32 @@ import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import java.util.Arrays; 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 DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { + public static DataSpecificationIec61360 getDataSpecificationIec61360() { return new DefaultDataSpecificationIec61360.Builder() .dataType(DataTypeIec61360.STRING) .value("exampleValue") @@ -119,7 +136,7 @@ public static EmbeddedDataSpecification getMaximalEmbeddedDataSpecifications() { } static List getIsCaseOfs() { - return Arrays.asList( + return List.of( new DefaultReference.Builder() .keys(new DefaultKey.Builder() .value("https://example.com/outside") @@ -132,22 +149,12 @@ static AdministrativeInformation getAdministrativeInformation() { return new DefaultAdministrativeInformation.Builder() .version("1") .revision("0") - .creator(new DefaultReference.Builder().keys( - Arrays.asList(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()) + .creator(getMaximalReference()) .build(); } static List getDescriptions() { - return Arrays.asList( + return List.of( new DefaultLangStringTextType.Builder() .text("A long text in English") .language("en") @@ -159,7 +166,7 @@ static List getDescriptions() { } static List getDisplayNames() { - return Arrays.asList( + return List.of( new DefaultLangStringNameType.Builder() .text("text in English") .language("en") @@ -175,26 +182,9 @@ static Extension getMaximalExtension() { .name("extension1") .value("extension1Value") .valueType(DataTypeDefXsd.ANY_URI) - .refersTo(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("refersTo") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) - .semanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("semanticId") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build()) - .supplementalSemanticIds(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("supplementalSemanticIds") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .refersTo(getMaximalReference()) + .semanticId(getMaximalReference()) + .supplementalSemanticIds(getMaximalReferenceList()) .build(); } @@ -208,6 +198,78 @@ static Reference getMinimalReference() { .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") @@ -432,6 +494,13 @@ static Entity getMaximalEntity() { return new DefaultEntity.Builder() .idShort("E1") .entityType(EntityType.SELF_MANAGED_ENTITY) + .statements(List.of(getMinimalProperty(), getMinimalAnnotatedRelationshipElement())) + .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) + .globalAssetId("global") + .description(getDescriptions()) + .displayName(getDisplayNames()) + .qualifiers(getMaximalQualifier()) + .supplementalSemanticIds(getMaximalReferenceList()) .build(); } @@ -587,7 +656,7 @@ static AssetAdministrationShell getMaximalAssetAdministrationShell() { static List getExtensionList() { - return Arrays.asList( + 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 index 559f5978a..5b80674fc 100644 --- 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 @@ -13,6 +13,8 @@ import java.util.LinkedList; import java.util.List; +import static org.junit.Assert.assertEquals; + @RunWith(Parameterized.class) public class SubmodelElementTest { @Parameter @@ -27,13 +29,13 @@ public static Object[] data() { } @Test - public void testGeneric() throws IncompatibleTypeException { + 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 submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(submodelElement); + 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 index 1f0cf68a5..d98d197db 100644 --- 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 @@ -1,2 +1,68 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SubmodelTest { +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 Date: Mon, 12 Feb 2024 11:00:18 +0100 Subject: [PATCH 033/160] Enhance tests and java docs --- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 8 ++- .../rdf/RDFSerializationResult.java | 6 +- .../v3/dataformat/rdf/RDFSerializer.java | 15 +++-- .../handlers/DefaultReferenceRDFHandler.java | 7 +- .../v3/dataformat/rdf/SerializerUtil.java | 66 ++++++++++++++++++- 5 files changed, 85 insertions(+), 17 deletions(-) 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 index 69c8f4450..0f6078a8b 100644 --- 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 @@ -11,7 +11,7 @@ */ public interface RDFHandler { /** - * Convert to RDF model. This method is side effect free and idempotent. + * 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 @@ -20,11 +20,13 @@ public interface RDFHandler { RDFSerializationResult toModel(T object); /** - * This method is side effect free and idempotent. + * 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 elements that correspond to the object. + * @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/RDFSerializationResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java index 699177f14..e2bb09145 100644 --- 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 @@ -15,10 +15,10 @@ public interface RDFSerializationResult { Model getModel(); /** - * corresponding node created in the graph as a starting point - * note that this is a Apache Jena's {@link org.apache.jena.rdf.model.Resource} + * 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 a Resource in the graph + * @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 index 55f4e4fb7..81b5af576 100644 --- 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 @@ -1,10 +1,10 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.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; @@ -56,7 +56,10 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + 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); } @@ -79,8 +82,9 @@ public String write(Referable referable) throws SerializationException { * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize * @return the Jena Model */ - public Model toModel(Environment aasEnvironment) { - throw new RuntimeException("Not Implemented"); + public RDFSerializationResult toModel(Environment aasEnvironment) { + RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(aasEnvironment); + return rdfSerializationResult; } /** @@ -90,7 +94,8 @@ public Model toModel(Environment aasEnvironment) { * @return the RDFSerializationResult contains the Apache Jena model as well as the corresponding created resource */ public RDFSerializationResult toModel(Referable referable) { - return null; + RDFSerializationResult rdfSerializationResult = new DefaultReferableRDFHandler().toModel(referable); + return rdfSerializationResult; } 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 index b3cd5517d..20ec5c2ab 100644 --- 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 @@ -46,14 +46,13 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); keysIterator.forEachRemaining(node -> { - Key key = null; try { - key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + 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); } - int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index, key); }); List keys = new ArrayList<>(); for (int index = 0; index < keysMap.keySet().size(); index++) { 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 index d81be9685..fe48499c7 100644 --- 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 @@ -334,6 +334,20 @@ static List getMinimalSubmodelElementsList() { 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(), @@ -451,6 +465,12 @@ static BasicEventElement getMaximalBasicEventElement() { .idShort("BEE1") .direction(Direction.OUTPUT) .state(StateOfEvent.OFF) + .messageBroker(getMaximalReference()) + .messageTopic("topic") + .minInterval("1s") + .maxInterval("2s") + .lastUpdate("3s") + .semanticId(getMinimalReference()) .observed(getMinimalReference()) .build(); } @@ -497,6 +517,7 @@ static Entity getMaximalEntity() { .statements(List.of(getMinimalProperty(), getMinimalAnnotatedRelationshipElement())) .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) .globalAssetId("global") + .specificAssetIds(getMaximalSpecificAssetId()) .description(getDescriptions()) .displayName(getDisplayNames()) .qualifiers(getMaximalQualifier()) @@ -529,6 +550,9 @@ static Range getMaximalRange() { return new DefaultRange.Builder() .idShort("R1") .valueType(DataTypeDefXsd.DECIMAL) + .max("19") + .min("10") + .build(); } @@ -541,6 +565,7 @@ static ReferenceElement getMinimalReferenceElement() { static ReferenceElement getMaximalReferenceElement() { return new DefaultReferenceElement.Builder() .idShort("RE1") + .value(getMaximalReference()) .build(); } @@ -553,18 +578,53 @@ static RelationshipElement getMinimalRelationshipElement() { static RelationshipElement getMaximalRelationshipElement() { return new DefaultRelationshipElement.Builder() .idShort("ReE1") + .first(getMaximalReference()) + .second(getMinimalReference()) .build(); } static SubmodelElementCollection getMinimalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() - .idShort("SEC1") + .idShort("MinimalSubmodelElementCollection") .build(); } static SubmodelElementCollection getMaximalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() - .idShort("SEC1") + .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(); } @@ -577,6 +637,8 @@ static SubmodelElementList getMinimalSubmodelElementList() { static SubmodelElementList getMaximalSubmodelElementList() { return new DefaultSubmodelElementList.Builder() .idShort("SEL1") + .semanticIdListElement(getMaximalReference()) + .valueTypeListElement(DataTypeDefXsd.STRING) .build(); } From cd5973725528a319c01abe87c5f7f779f2f2dcaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:01:47 +0000 Subject: [PATCH 034/160] Bump com.networknt:json-schema-validator from 1.3.1 to 1.3.2 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.3.1...1.3.2) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a3d86ed8..1a674ff63 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ 2.1.0 4.1.0 1.5.1 - 1.3.1 + 1.3.2 4.13.2 1.1.1 2.7.8 From 4dc82ffb6694aaf0db55aba9675bf333be07e287 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:21:39 +0000 Subject: [PATCH 035/160] Bump actions/delete-package-versions from 4 to 5 Bumps [actions/delete-package-versions](https://github.com/actions/delete-package-versions) from 4 to 5. - [Release notes](https://github.com/actions/delete-package-versions/releases) - [Commits](https://github.com/actions/delete-package-versions/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/delete-package-versions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven-publish-snapshots.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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' From 09629e49fddd80aa9a96c237f0f932c7bf20cddb Mon Sep 17 00:00:00 2001 From: Thiago Weber Martins <68608396+twebermartins@users.noreply.github.com> Date: Tue, 13 Feb 2024 18:46:03 +0100 Subject: [PATCH 036/160] Prepares POM for release in Maven Central --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1a674ff63..e6914ce25 100644 --- a/pom.xml +++ b/pom.xml @@ -40,9 +40,8 @@ 1 0 0 - -RC1 - ${revision.major}.${revision.minor}.${revision.patch}${revision.suffix} - 1.0.0-RC1 + ${revision.major}.${revision.minor}.${revision.patch} + 1.0.0 UTF-8 UTF-8 From e6035e16d4c18c790ca7074a35c59168b7553a10 Mon Sep 17 00:00:00 2001 From: Thiago Weber Martins <68608396+twebermartins@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:23:10 +0100 Subject: [PATCH 037/160] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ff8ea555..ddb2a347e 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.0`_ 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`. From 6636cd209687341df0ceea0996ae4d26217344c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:52:02 +0000 Subject: [PATCH 038/160] Bump org.apache.commons:commons-compress from 1.25.0 to 1.26.0 Bumps org.apache.commons:commons-compress from 1.25.0 to 1.26.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6914ce25..36244e099 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 4.8.165 1.15 2.15.1 - 1.25.0 + 1.26.0 3.14.0 33.0.0-jre 5.0.1 From c3fdd778d77afae390554b8729de03a69aaf7821 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:06:38 +0000 Subject: [PATCH 039/160] Bump com.networknt:json-schema-validator from 1.3.2 to 1.3.3 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.3.2 to 1.3.3. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.3.2...1.3.3) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6914ce25..7465d5107 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.1 - 1.3.2 + 1.3.3 4.13.2 1.1.1 2.7.8 From 6c2b04e4ee0e2413a38922828ec55093354aa7ec Mon Sep 17 00:00:00 2001 From: fvolz Date: Tue, 27 Feb 2024 15:22:57 +0100 Subject: [PATCH 040/160] [Bugfix] Files in SubmodelElementLists and NullPointerException when serializing/deserializing empty files (#250) * visit all elements (also list) and add null check * skip empty files when serializing AASX * add tests for empty files and files in submodelElementList * fix null test * change serializer test to AASFull provokes java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "path" is null * fix serializer test, add thumbnail to AASFull * fix missing import * revert AASFull change, change AASXSerializerTest * revert unused import * remove unused imports --- .../v3/dataformat/aasx/AASXDeserializer.java | 31 ++++---------- .../v3/dataformat/aasx/AASXSerializer.java | 40 ++++++++----------- .../deserialization/AASXDeserializerTest.java | 32 +++++++++++++++ .../serialization/AASXSerializerTest.java | 27 +++++++++---- 4 files changed, 76 insertions(+), 54 deletions(-) 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 f6ab72a13..234fe9ccb 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; @@ -33,11 +32,10 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper; 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.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; @@ -207,27 +205,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 8eb4a9090..4d2d9e400 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 @@ -33,12 +33,10 @@ import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; 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.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; @@ -94,7 +92,7 @@ public AASXSerializer(XmlSerializer xmlSerializer) { */ public void write(Environment environment, Collection files, OutputStream os) throws SerializationException, IOException { - prepareFilePaths(environment.getSubmodels()); + prepareFilePaths(environment); OPCPackage rootPackage = OPCPackage.create(os); @@ -129,9 +127,8 @@ private void storeFilesInAASX(Environment environment, Collection .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())); } /** @@ -226,35 +223,32 @@ 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) { + private Collection findFileElements(Environment environment) { 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())); + 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 + * @param environment the Environment */ - private void prepareFilePaths(Collection submodels) { - submodels.stream() - .forEach(sm -> findFileElements(sm.getSubmodelElements()).stream().forEach(f -> f.setValue(preparePath(f.getValue())))); + private void prepareFilePaths(Environment environment) { + findFileElements(environment).forEach(f -> f.setValue(preparePath(f.getValue()))); } /** 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 4cd02eeba..1b01f8772 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 @@ -44,6 +44,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; @@ -92,6 +93,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/serialization/AASXSerializerTest.java b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/serialization/AASXSerializerTest.java index aa23825ed..ebbe0c649 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 @@ -18,9 +18,9 @@ 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.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException; -import org.junit.Before; import org.junit.Test; import javax.xml.parsers.ParserConfigurationException; @@ -43,19 +43,30 @@ public class AASXSerializerTest { 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(); + + new AASXSerializer().write(AASFull.createEnvironment(), fileList, out); + + validateAASX(out); + } + + @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"); From a37bef701777daf861062e2ed84b858c0e253241 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:43:16 +0100 Subject: [PATCH 041/160] Prepare 1.0.1 release (#254) * Prepare 1.0.1 release * Update README.md --- README.md | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddb2a347e..058b00311 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Eclipse AAS4J -> :newspaper: The _`Eclipse AAS4J 1.0.0`_ release is available on [Maven Central Repository](https://oss.sonatype.org/#nexus-search;quick~org.eclipse.digitaltwin.aas4j) and includes the +> :newspaper: The _`Eclipse AAS4J 1.0.1`_ 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`. diff --git a/pom.xml b/pom.xml index b224c08d4..6d1076629 100644 --- a/pom.xml +++ b/pom.xml @@ -39,9 +39,9 @@ 1 0 - 0 + 1 ${revision.major}.${revision.minor}.${revision.patch} - 1.0.0 + 1.0.1 UTF-8 UTF-8 From 24b4ba16b118a67fd1348af339eeea7819d193cf Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:50:09 +0100 Subject: [PATCH 042/160] Update pom.xml --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6d1076629..7899a1d7b 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 0 - 1 + 1 + 0-SNAPSHOT ${revision.major}.${revision.minor}.${revision.patch} - 1.0.1 + 1.1.0-SNAPSHOT UTF-8 UTF-8 From 54718dcae25352252b617477bb7907adb1663a5c Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Fri, 8 Mar 2024 19:30:28 +0100 Subject: [PATCH 043/160] Include Jena Shacl module --- dataformat-rdf/pom.xml | 5 + .../v3/dataformat/rdf/RDFDeserializer.java | 2 + .../v3/dataformat/rdf/RDFSchemaValidator.java | 2 + .../src/main/resources/rdf-ontology.ttl | 2058 +++++++++++++++++ .../main/resources/shacl-schema-original.ttl | 0 .../src/main/resources/shacl-schema.ttl | 1325 +++++++++++ ...tCustomClass.java => CustomClassTest.java} | 0 .../dataformat/rdf/RDFDeserializerTest.java | 2 + ...rializerTest.java => RDFHandlersTest.java} | 0 .../v3/dataformat/rdf/RDFSerializerTest.java | 2 + .../dataformat/rdf/SchemaValidatorTest.java | 2 + 11 files changed, 3398 insertions(+) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java create mode 100644 dataformat-rdf/src/main/resources/rdf-ontology.ttl create mode 100644 dataformat-rdf/src/main/resources/shacl-schema-original.ttl create mode 100644 dataformat-rdf/src/main/resources/shacl-schema.ttl rename dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{TestCustomClass.java => CustomClassTest.java} (100%) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java rename dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{SerializerTest.java => RDFHandlersTest.java} (100%) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index aa42713c8..4017ce587 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -27,6 +27,11 @@ jena-arq ${jena.version} + + org.apache.jena + jena-shacl + ${jena.version} + org.slf4j slf4j-api 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..b11c5fd66 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java @@ -0,0 +1,2 @@ +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/RDFSchemaValidator.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java new file mode 100644 index 000000000..f79e602ac --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class RDFSchemaValidator { +} 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..e69de29bb 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..03ec931db --- /dev/null +++ b/dataformat-rdf/src/main/resources/shacl-schema.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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java similarity index 100% rename from dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java rename to dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java 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..7330b292a --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java @@ -0,0 +1,2 @@ +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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java similarity index 100% rename from dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java rename to dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java 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..96c7e13e4 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java @@ -0,0 +1,2 @@ +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..9dd3ee8ef --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SchemaValidatorTest { +} From a59bc29b7aaa87e21be38ccada76ee935730cdab Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Fri, 8 Mar 2024 19:30:51 +0100 Subject: [PATCH 044/160] Add initial SHACL validator --- .../v3/dataformat/rdf/RDFDeserializer.java | 4 +- .../v3/dataformat/rdf/RDFSchemaValidator.java | 54 +- .../main/resources/shacl-schema-original.ttl | 1325 +++++++++++++++++ .../src/main/resources/shacl-schema.ttl | 74 +- .../v3/dataformat/rdf/CustomClassTest.java | 12 +- .../v3/dataformat/rdf/EnvironmentTest.java | 2 +- .../dataformat/rdf/RDFDeserializerTest.java | 4 +- .../v3/dataformat/rdf/RDFHandlersTest.java | 2 +- .../v3/dataformat/rdf/RDFSerializerTest.java | 4 +- .../dataformat/rdf/SchemaValidatorTest.java | 70 +- 10 files changed, 1512 insertions(+), 39 deletions(-) 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 index b11c5fd66..3316efdb3 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFDeserializer { +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/RDFSchemaValidator.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java index f79e602ac..d33a2bbbe 100644 --- 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 @@ -1,2 +1,54 @@ -package PACKAGE_NAME;public class RDFSchemaValidator { +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.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/resources/shacl-schema-original.ttl b/dataformat-rdf/src/main/resources/shacl-schema-original.ttl index e69de29bb..03ec931db 100644 --- a/dataformat-rdf/src/main/resources/shacl-schema-original.ttl +++ 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 index 03ec931db..145069e23 100644 --- a/dataformat-rdf/src/main/resources/shacl-schema.ttl +++ b/dataformat-rdf/src/main/resources/shacl-schema.ttl @@ -23,6 +23,7 @@ aas:AbstractLangStringShape a sh:NodeShape ; 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 . @@ -45,7 +46,7 @@ aas:AbstractLangStringShape a sh:NodeShape ; sh:minCount 1 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -60,7 +61,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 4 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -71,7 +72,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 4 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -89,7 +90,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -147,7 +148,7 @@ aas:AssetInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -163,7 +164,7 @@ aas:AssetInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -206,7 +207,7 @@ aas:BasicEventElementShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 255 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -259,7 +260,7 @@ aas:BlobShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -289,6 +290,7 @@ aas:DataElementShape a sh:NodeShape ; 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 . @@ -305,6 +307,7 @@ aas:DataSpecificationContentShape a sh:NodeShape ; 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 . @@ -336,7 +339,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -352,7 +355,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -361,7 +364,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -383,7 +386,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -400,7 +403,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -453,7 +456,7 @@ aas:EntityShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -493,6 +496,7 @@ aas:EventElementShape a sh:NodeShape ; 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 . @@ -540,7 +544,7 @@ aas:EventPayloadShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 255 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -577,7 +581,7 @@ aas:ExtensionShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -612,7 +616,7 @@ aas:FileShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -623,7 +627,7 @@ aas:FileShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -635,6 +639,7 @@ aas:HasDataSpecificationShape a sh:NodeShape ; 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 . @@ -657,6 +662,7 @@ aas:HasExtensionsShape a sh:NodeShape ; 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 . @@ -679,6 +685,7 @@ aas:HasKindShape a sh:NodeShape ; 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 . @@ -702,6 +709,7 @@ aas:HasSemanticsShape a sh:NodeShape ; 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 . @@ -732,6 +740,7 @@ aas:IdentifiableShape a sh:NodeShape ; 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 . @@ -754,7 +763,7 @@ aas:IdentifiableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -775,7 +784,7 @@ aas:KeyShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -797,7 +806,7 @@ aas:LangStringNameTypeShape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -810,7 +819,7 @@ aas:LangStringPreferredNameTypeIec61360Shape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -823,7 +832,7 @@ aas:LangStringShortNameTypeIec61360Shape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -961,6 +970,7 @@ aas:QualifiableShape a sh:NodeShape ; 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 . @@ -994,7 +1004,7 @@ aas:QualifierShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1053,6 +1063,7 @@ aas:ReferableShape a sh:NodeShape ; 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 . @@ -1068,7 +1079,7 @@ aas:ReferableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1078,7 +1089,7 @@ aas:ReferableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -1160,7 +1171,7 @@ aas:ResourceShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -1171,7 +1182,7 @@ aas:ResourceShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -1187,7 +1198,7 @@ aas:SpecificAssetIdShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 64 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1197,7 +1208,7 @@ aas:SpecificAssetIdShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1234,6 +1245,7 @@ aas:SubmodelElementShape a sh:NodeShape ; 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 . @@ -1313,7 +1325,7 @@ aas:ValueReferencePairShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; 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 index 855d6e5c1..50bd9aeec 100644 --- 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 @@ -8,12 +8,22 @@ 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 TestCustomClass { +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"); 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 index 1d26e6026..4437b4868 100644 --- 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 @@ -33,7 +33,7 @@ public static Object[] data() { } @Test - public void testConceptDescription() throws IncompatibleTypeException { + public void testEnvironment() throws IncompatibleTypeException { Environment object = environment; RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(object); Model model = rdfSerializationResult.getModel(); 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 index 7330b292a..bfc09cd47 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFDeserializerTest { +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 index 080f3ece7..503d1812e 100644 --- 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 @@ -17,7 +17,7 @@ import java.util.List; -public class SerializerTest { +public class RDFHandlersTest { @Test public void testKey() throws IOException, IncompatibleTypeException { Key simpleKey = new DefaultKey.Builder() 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 index 96c7e13e4..b24805f08 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFSerializerTest { +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 index 9dd3ee8ef..99d8e9749 100644 --- 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 @@ -1,2 +1,70 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SchemaValidatorTest { +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; + + } } From 429da9515a5bd4a5422f62031d09b0976959c116 Mon Sep 17 00:00:00 2001 From: Andreas Schilling Date: Thu, 14 Mar 2024 08:40:27 +0100 Subject: [PATCH 045/160] Use correct reference when adding thumbnail images (#263) * Use correct reference when adding thumbnail images fix #256 * Fix formatting * Apply further formatting fixes --- .../v3/dataformat/aasx/AASXSerializer.java | 44 +++++++------- .../serialization/AASXSerializerTest.java | 60 ++++++++++++++----- 2 files changed, 69 insertions(+), 35 deletions(-) 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 4d2d9e400..c38dd3228 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 @@ -50,6 +50,7 @@ public class AASXSerializer { private static final String MIME_PLAINTXT = "text/plain"; private static final String MIME_XML = "application/xml"; + 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"; @@ -61,6 +62,8 @@ public class AASXSerializer { 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; @@ -74,7 +77,7 @@ public AASXSerializer() { /** * Constructor with a custom serializer for serializing the aas environment - * + * * @param xmlSerializer a custom serializer used for serializing the aas environment */ public AASXSerializer(XmlSerializer xmlSerializer) { @@ -83,7 +86,7 @@ public AASXSerializer(XmlSerializer xmlSerializer) { /** * 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 @@ -106,6 +109,12 @@ public void write(Environment environment, Collection files, Outpu // Save the XML to aasx/xml/content.xml PackagePart xmlPart = createAASXPart(rootPackage, origin, XML_PATH, MIME_XML, AASSPEC_RELTYPE, xml.getBytes(DEFAULT_CHARSET)); + 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, xmlPart); saveAASX(os, rootPackage); @@ -113,7 +122,7 @@ public void write(Environment environment, Collection files, Outpu /** * 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 @@ -121,14 +130,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())); findFileElements(environment).forEach(file -> createParts(files, - AASXUtils.removeFilePartOfURI(file.getValue()), rootPackage, xmlPart, file.getContentType())); + AASXUtils.removeFilePartOfURI(file.getValue()), rootPackage, xmlPart, file.getContentType(), AASSUPPL_RELTYPE)); } /** @@ -139,13 +142,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); @@ -154,7 +158,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 @@ -167,7 +171,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() { @@ -177,7 +181,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 @@ -209,7 +213,7 @@ private PackagePart createAASXPart(OPCPackage root, RelationshipSource relateTo, /** * 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 */ @@ -225,7 +229,7 @@ private void writeDataToPart(PackagePart part, byte[] content) { /** * Gets the File elements from an environment * searches in SubmodelElementCollections - * + * * @param environment the Environment * @return the found Files */ @@ -244,7 +248,7 @@ public void visit(File file) { /** * Replaces the path in all File Elements with the result of preparePath - * + * * @param environment the Environment */ private void prepareFilePaths(Environment environment) { @@ -253,7 +257,7 @@ private void prepareFilePaths(Environment environment) { /** * 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 @@ -269,7 +273,7 @@ private InMemoryFile findFileByPath(Collection files, String path) /** * Removes the serverpart from a path and ensures it starts with "file://" - * + * * @param path the path to be prepared * @return the prepared path */ 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 ebbe0c649..2e258efdf 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 @@ -28,8 +28,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,6 +40,7 @@ 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 ORIGIN_PATH_URI = "file:///aasx/aasx-origin"; @@ -56,7 +59,7 @@ public void testBuildAASXFull() throws IOException, TransformerException, Parser new AASXSerializer().write(AASFull.createEnvironment(), fileList, out); - validateAASX(out); + validateAASX(out, List.of(AASXSerializerTest::assertRootXml)); } @Test @@ -75,28 +78,26 @@ public void testBuildAASXSimple() throws IOException, TransformerException, Pars new AASXSerializer().write(AASSimple.createEnvironment(), fileList, out); - validateAASX(out); + validateAASX(out, List.of(AASXSerializerTest::assertRootXml, AASXSerializerTest::assertThumbnailReference)); } - private void validateAASX(ByteArrayOutputStream byteStream) throws IOException { + private void validateAASX(ByteArrayOutputStream byteStream, 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)); @@ -110,4 +111,33 @@ 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(" Date: Thu, 14 Mar 2024 13:22:27 +0100 Subject: [PATCH 046/160] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.1.0 to 3.2.0 (#262) Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.1.0...maven-gpg-plugin-3.2.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 33773f8bb..d8a2f867c 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.0 ${gpg.keyname} ${gpg.keyname} diff --git a/pom.xml b/pom.xml index 7899a1d7b..b06b0767a 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.0 sign-artifacts From 4196a6e37fa03641fae1d24c1cd6902cd158fbce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:33 +0100 Subject: [PATCH 047/160] Bump jackson.version from 2.16.1 to 2.16.2 (#261) Bumps `jackson.version` from 2.16.1 to 2.16.2. Updates `com.fasterxml.jackson.core:jackson-databind` from 2.16.1 to 2.16.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-core` from 2.16.1 to 2.16.2 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.16.1...jackson-core-2.16.2) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.16.1 to 2.16.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.16.1 to 2.16.2 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.16.1...jackson-dataformat-xml-2.16.2) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b06b0767a..f8d07c271 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 33.0.0-jre 5.0.1 2.2 - 2.16.1 + 2.16.2 2.0.1.Final 2.3.1 2.1.0 From 097189fd6a9e6173c07f574ddea66d7e655816ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:40 +0100 Subject: [PATCH 048/160] Bump org.apache.commons:commons-compress from 1.26.0 to 1.26.1 (#260) Bumps org.apache.commons:commons-compress from 1.26.0 to 1.26.1. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f8d07c271..0659b14db 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 4.8.165 1.15 2.15.1 - 1.26.0 + 1.26.1 3.14.0 33.0.0-jre 5.0.1 From 5433e96a1c77b16c8381ba6924e4a19315010e2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:51 +0100 Subject: [PATCH 049/160] Bump io.github.classgraph:classgraph from 4.8.165 to 4.8.168 (#259) Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.165 to 4.8.168. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.165...classgraph-4.8.168) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0659b14db..8b25dde44 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.5.0 3.3.0 0.8.11 - 4.8.165 + 4.8.168 1.15 2.15.1 1.26.1 From 2c508b666d07d1ad24ed44c241797bae87074945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:56 +0100 Subject: [PATCH 050/160] Bump org.mockito:mockito-core from 5.10.0 to 5.11.0 (#255) Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.10.0 to 5.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.10.0...v5.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b25dde44..3032085a6 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 4.4.1 2.12.1 2.9.1 - 5.10.0 + 5.11.0 0.0.20131108.vaadin1 From 1017e1d3592778d9fe4e9cf5760caac1d0165a43 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:11:58 +0100 Subject: [PATCH 051/160] Bugfix/aasx files (#265) * Ensures sames files are only tried to be added once Signed-off-by: Frank Schnicke * Removes changing of file value to start with file:// on AASX serialization Signed-off-by: Frank Schnicke --------- Signed-off-by: Frank Schnicke --- .../v3/dataformat/aasx/AASXSerializer.java | 27 ++----------------- .../aasx/deserialization/ValidationTest.java | 3 +++ 2 files changed, 5 insertions(+), 25 deletions(-) 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 c38dd3228..9414df8a9 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; @@ -95,7 +95,6 @@ public AASXSerializer(XmlSerializer xmlSerializer) { */ public void write(Environment environment, Collection files, OutputStream os) throws SerializationException, IOException { - prepareFilePaths(environment); OPCPackage rootPackage = OPCPackage.create(os); @@ -234,7 +233,7 @@ private void writeDataToPart(PackagePart part, byte[] content) { * @return the found Files */ private Collection findFileElements(Environment environment) { - Collection files = new ArrayList<>(); + Collection files = new HashSet<>(); new AssetAdministrationShellElementWalkerVisitor() { @Override public void visit(File file) { @@ -246,15 +245,6 @@ public void visit(File file) { return files; } - /** - * Replaces the path in all File Elements with the result of preparePath - * - * @param environment the Environment - */ - private void prepareFilePaths(Environment environment) { - findFileElements(environment).forEach(f -> f.setValue(preparePath(f.getValue()))); - } - /** * Finds an InMemoryFile by its path * @@ -271,17 +261,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/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 a62341725..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 @@ -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"); From 53003287091c5672587c053077208e91d9a4c95c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:50:31 +0000 Subject: [PATCH 052/160] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.0 to 3.2.2 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.0 to 3.2.2. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.0...maven-gpg-plugin-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index d8a2f867c..21a0520b6 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.0 + 3.2.2 ${gpg.keyname} ${gpg.keyname} diff --git a/pom.xml b/pom.xml index 3032085a6..3c85926bf 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.0 + 3.2.2 sign-artifacts From 0c53877d9845cefe9a14b08b2b7192c184cf4a9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:50:58 +0000 Subject: [PATCH 053/160] Bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c85926bf..ef975ad1b 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ UTF-8 UTF-8 - 3.12.1 + 3.13.0 3.3.1 1.6.0 3.0.1 From 2a802b0d8efc90de3e0968f1542f2063e10cad31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 11:01:04 +0000 Subject: [PATCH 054/160] Bump com.google.guava:guava from 33.0.0-jre to 33.1.0-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.0.0-jre to 33.1.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef975ad1b..8d0c1c925 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 2.15.1 1.26.1 3.14.0 - 33.0.0-jre + 33.1.0-jre 5.0.1 2.2 2.16.2 From 0477f3ee0290eccfb8a2fb05b5aad746d20f370c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:00:00 +0000 Subject: [PATCH 055/160] Bump com.networknt:json-schema-validator from 1.3.3 to 1.4.0 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.3.3 to 1.4.0. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.3.3...1.4.0) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d0c1c925..ba48c03a5 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.1 - 1.3.3 + 1.4.0 4.13.2 1.1.1 2.7.8 From 91eb2f7581836ccea39ee1ee9687e7177ef61839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:57:03 +0000 Subject: [PATCH 056/160] Bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1 Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.3.0 to 3.3.1. - [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.3.0...maven-source-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-source-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 21a0520b6..c713af6c7 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -76,7 +76,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources diff --git a/pom.xml b/pom.xml index ba48c03a5..ff3cc04fd 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ 3.3.0 3.6.3 3.5.0 - 3.3.0 + 3.3.1 0.8.11 4.8.168 1.15 From 420f5aba0a3aa8b1f3f1100b13ff9183b65671ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:22:02 +0000 Subject: [PATCH 057/160] Bump io.github.classgraph:classgraph from 4.8.168 to 4.8.170 Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.168 to 4.8.170. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.168...classgraph-4.8.170) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ff3cc04fd..b76e6e486 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.5.0 3.3.1 0.8.11 - 4.8.168 + 4.8.170 1.15 2.15.1 1.26.1 From 8e2259b98d6b99911486c4e72cf790bfb385af4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 05:35:59 +0000 Subject: [PATCH 058/160] Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12 Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.11 to 0.8.12. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.11...v0.8.12) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b76e6e486..3e44a4323 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 3.6.3 3.5.0 3.3.1 - 0.8.11 + 0.8.12 4.8.170 1.15 2.15.1 From 727b897097442364cf0137370d0160972918c3cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:45:36 +0000 Subject: [PATCH 059/160] Bump commons-io:commons-io from 2.15.1 to 2.16.0 Bumps commons-io:commons-io from 2.15.1 to 2.16.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e44a4323..5679eae39 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 0.8.12 4.8.170 1.15 - 2.15.1 + 2.16.0 1.26.1 3.14.0 33.1.0-jre From b7e467ed27deb6b251280739bc89c466ed8ef4af Mon Sep 17 00:00:00 2001 From: Rene Fischer <33397768+FischerRene@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:30:12 +0200 Subject: [PATCH 060/160] Fixes example for dependency inclusion (#277) Adds missing forward slash, changes example to model itself, and adds existing latest version. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 058b00311..69ca63153 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,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.1 + ``` ## AAS4J Project Structure From ecf4dc3c6f7598bf3bd43baf82a12e6cebd14fec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:31:32 +0000 Subject: [PATCH 061/160] Bump commons-io:commons-io from 2.16.0 to 2.16.1 Bumps commons-io:commons-io from 2.16.0 to 2.16.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5679eae39..5ff3b4e02 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 0.8.12 4.8.170 1.15 - 2.16.0 + 2.16.1 1.26.1 3.14.0 33.1.0-jre From 95172c5303e5a72782b652aee8868bf632a0f9f8 Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Tue, 9 Apr 2024 16:11:19 +0200 Subject: [PATCH 062/160] Update README.md Remove link to outdated documentation --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 69ca63153..1d58f6f4b 100644 --- a/README.md +++ b/README.md @@ -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: From e240ddc0ca924ade781bb3c31a48de88e129a24c Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:40:06 +0200 Subject: [PATCH 063/160] Adds further compatibility with AASX Package Explorer & fine-tunes warning messages (#278) * Adds further compatibility with AASX Package Explorer & fine-tunes warning messages Signed-off-by: Frank Schnicke * Adresses review remarks Signed-off-by: Frank Schnicke --------- Signed-off-by: Frank Schnicke --- .../DataElementsDeserializer.java | 3 +- .../NoEntryWrapperListDeserializer.java | 6 +-- .../OperationVariableDeserializer.java | 41 +++++++++++------- .../QualifierDeserializer.java | 43 ++++++++++++------- .../ReferencesDeserializer.java | 17 ++++---- .../SubmodelElementsDeserializer.java | 7 ++- 6 files changed, 68 insertions(+), 49 deletions(-) diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java index c2fd58d42..4c259b453 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/DataElementsDeserializer.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -47,7 +46,7 @@ public DataElementsDeserializer() { 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<>(); } ObjectNode node = (ObjectNode) treeNode; diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java index 81cfb79ee..550a2fe3c 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/NoEntryWrapperListDeserializer.java @@ -17,7 +17,6 @@ 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/internal/deserialization/OperationVariableDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java index d2c970aa0..a67fbd3f7 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/OperationVariableDeserializer.java @@ -16,6 +16,14 @@ */ 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; import com.fasterxml.jackson.databind.DeserializationContext; @@ -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/internal/deserialization/QualifierDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java index cb6d251ec..5f9cffa9d 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/QualifierDeserializer.java @@ -41,6 +41,14 @@ */ 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; import com.fasterxml.jackson.databind.DeserializationContext; @@ -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/internal/deserialization/ReferencesDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java index 7c927e018..df02b914b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/ReferencesDeserializer.java @@ -15,6 +15,12 @@ */ 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; import com.fasterxml.jackson.core.TreeNode; @@ -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/internal/deserialization/SubmodelElementsDeserializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.java index 0fd407cb8..e77e85e9b 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/deserialization/SubmodelElementsDeserializer.java @@ -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); } } From 79ff39c880bd0917abd0fae88a6610c338abd28c Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Wed, 10 Apr 2024 09:51:00 +0200 Subject: [PATCH 064/160] Prepares 1.0.2 release Signed-off-by: Frank Schnicke --- README.md | 2 +- pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1d58f6f4b..787dea56f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Eclipse AAS4J -> :newspaper: The _`Eclipse AAS4J 1.0.1`_ release is available on [Maven Central Repository](https://oss.sonatype.org/#nexus-search;quick~org.eclipse.digitaltwin.aas4j) and includes the +> :newspaper: The _`Eclipse AAS4J 1.0.2`_ 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`. diff --git a/pom.xml b/pom.xml index 5ff3b4e02..1745f03a3 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 1 - 0-SNAPSHOT + 0 + 2 ${revision.major}.${revision.minor}.${revision.patch} - 1.1.0-SNAPSHOT + 1.0.2 UTF-8 UTF-8 From 535de9068f10982401bdb8ee31d77a6c3c9872a9 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:38:07 +0200 Subject: [PATCH 065/160] Update pom.xml --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1745f03a3..5ff3b4e02 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 0 - 2 + 1 + 0-SNAPSHOT ${revision.major}.${revision.minor}.${revision.patch} - 1.0.2 + 1.1.0-SNAPSHOT UTF-8 UTF-8 From c30483c303dea04793be3120302b21282fbba7d4 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:46:38 +0200 Subject: [PATCH 066/160] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 787dea56f..fd11e3b66 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ or by integrating the respective modules as dependencies from [Maven Central](ht org.eclipse.digitaltwin.aas4j aas4j-model - 1.0.1 + 1.0.2 ``` From b84ffe3b95d633150832c5d4d84006dbd0a1df3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:36:57 +0000 Subject: [PATCH 067/160] Bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.0 Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.3.0...maven-jar-plugin-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ff3b4e02..cd28a88af 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 3.3.1 1.6.0 3.0.1 - 3.3.0 + 3.4.0 3.6.3 3.5.0 3.3.1 From 9fccc12e1b6ada03e29320befef2dc030092eb1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:37:00 +0000 Subject: [PATCH 068/160] Bump slf4j.version from 2.0.12 to 2.0.13 Bumps `slf4j.version` from 2.0.12 to 2.0.13. Updates `org.slf4j:slf4j-api` from 2.0.12 to 2.0.13 Updates `org.slf4j:slf4j-simple` from 2.0.12 to 2.0.13 --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ff3b4e02..acf7cfc45 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ 1.1.1 2.7.8 5.2.5 - 2.0.12 + 2.0.13 1.3.2 4.4.1 2.12.1 From 336e9467ec43756c5432ed901e34a328ad61daa2 Mon Sep 17 00:00:00 2001 From: Stamatis Karnouskos Date: Tue, 16 Apr 2024 09:57:25 +0200 Subject: [PATCH 069/160] consistent formatting of github files via gitattributes --- .gitattributes | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .gitattributes 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 + + From 64e6ae4c3aa275f818aad6bcc06e873488bcc361 Mon Sep 17 00:00:00 2001 From: Tobias Kraft Date: Wed, 17 Apr 2024 07:03:17 +0200 Subject: [PATCH 070/160] GH-287: Add JSON support for serializing and deserializing AASX files (#288) * GH-287: Add JSON support for serializing and deserializing AASX files * GH-287: rework after code review --- dataformat-aasx/pom.xml | 4 + .../v3/dataformat/aasx/AASXDeserializer.java | 94 ++++++++++++++++--- .../v3/dataformat/aasx/AASXSerializer.java | 73 +++++++++++--- .../v3/dataformat/aasx/AASXValidator.java | 15 ++- .../dataformat/aasx/MetamodelContentType.java | 24 +++++ .../deserialization/AASXDeserializerTest.java | 16 +++- .../serialization/AASXSerializerTest.java | 41 ++++++-- pom.xml | 5 + 8 files changed, 231 insertions(+), 41 deletions(-) create mode 100644 dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/MetamodelContentType.java 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 234fe9ccb..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 @@ -33,6 +33,7 @@ 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; @@ -52,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; @@ -66,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; } /** @@ -96,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); } /** @@ -134,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); } 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 9414df8a9..6f3727e02 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 @@ -34,6 +34,7 @@ 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; @@ -49,6 +50,7 @@ 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"; @@ -59,6 +61,7 @@ public class AASXSerializer { 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"; @@ -67,25 +70,39 @@ public class AASXSerializer { 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 + * Constructor with a custom XML serializer for serializing the aas environment * - * @param xmlSerializer a custom serializer used 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 @@ -96,25 +113,53 @@ public AASXSerializer(XmlSerializer xmlSerializer) { public void write(Environment environment, Collection files, OutputStream os) throws SerializationException, IOException { + 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); // Create the empty aasx-origin file 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); + } 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, xmlPart); + && 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); } 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 1b01f8772..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 @@ -34,6 +34,7 @@ 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; @@ -65,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); @@ -74,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(); 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 2e258efdf..b5f86d6ce 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 @@ -18,6 +18,7 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.core.SerializationException; @@ -42,6 +43,7 @@ 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<>(); @@ -56,10 +58,14 @@ public void testBuildAASXFull() throws IOException, TransformerException, Parser // This stream keeps the output of the AASXFactory only in memory ByteArrayOutputStream out = new ByteArrayOutputStream(); - - new AASXSerializer().write(AASFull.createEnvironment(), fileList, out); - - validateAASX(out, List.of(AASXSerializerTest::assertRootXml)); + // 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 @@ -75,13 +81,17 @@ public void testBuildAASXSimple() throws IOException, TransformerException, Pars // 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, List.of(AASXSerializerTest::assertRootXml, AASXSerializerTest::assertThumbnailReference)); + 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, List> fileValidators) { + private void validateAASX(ByteArrayOutputStream byteStream, String contentFilePath, List> fileValidators) { ZipInputStream in = new ZipInputStream(new ByteArrayInputStream(byteStream.toByteArray())); ZipEntry zipEntry; @@ -100,7 +110,7 @@ private void validateAASX(ByteArrayOutputStream byteStream, Listaas4j-dataformat-xml ${revision} + + ${project.groupId} + aas4j-dataformat-json + ${revision} + ${project.groupId} aas4j-model From 7037adc61d076e9ba616a12f48b209ee938449f1 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Mon, 26 Aug 2024 15:24:18 +0200 Subject: [PATCH 071/160] Adds setting of refferedSemanticId Signed-off-by: Frank Schnicke --- .../v3/dataformat/core/util/AasUtils.java | 70 +++---------------- .../v3/dataformat/core/util/AasUtilsTest.java | 48 +++++++++++-- 2 files changed, 51 insertions(+), 67 deletions(-) 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 b1f210bdd..070140ebc 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 @@ -15,27 +15,20 @@ */ 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.Map; import java.util.Objects; -import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; 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.MostSpecificTypeTokenComparator; 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; @@ -44,18 +37,11 @@ import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.reflect.TypeToken; /** * Provides utility functions related to AAS */ public class AasUtils { - - private static final Logger log = LoggerFactory.getLogger(AasUtils.class); - private static final Map REFERENCE_TYPE_REPRESENTATION = Map.of( ReferenceTypes.EXTERNAL_REFERENCE, "ExternalRef", ReferenceTypes.MODEL_REFERENCE, "ModelRef"); @@ -123,6 +109,9 @@ public static Reference toReference(Identifiable identifiable, 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 @@ -194,6 +169,7 @@ public static Reference toReference(Reference parent, Referable element, Class T resolve(Reference reference, Environment e 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)); + private static void setReferredSemanticIdIfHasSemantics(Object obj, Reference reference) { + if (obj instanceof HasSemantics) { + reference.setReferredSemanticId(((HasSemantics) obj).getSemanticId()); } - 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()); } } 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..eec846fa6 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 @@ -16,11 +16,16 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; -import junitparams.JUnitParamsRunner; +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; @@ -39,10 +44,7 @@ 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; +import junitparams.JUnitParamsRunner; @RunWith(JUnitParamsRunner.class) public class AasUtilsTest { @@ -505,4 +507,40 @@ public void whenAsString_withReferredSemanticId_success() { String actual = AasUtils.asString(reference); Assert.assertEquals(expected, actual); } + + @Test + public void whenAsReference_IdentifiableWithSemanticId_success() { + Submodel submodel = AASFull.SUBMODEL_3; + Reference ref = AasUtils.toReference(submodel); + assertEquals(submodel.getSemanticId(), ref.getReferredSemanticId()); + } + + @Test + public void whenAsReference_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); + assertEquals(prop.getSemanticId(), 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(); + } } From c15a02869c61efcb0e956007544768e3d0d9b6e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:35:57 +0200 Subject: [PATCH 072/160] Bump io.github.classgraph:classgraph from 4.8.170 to 4.8.174 (#303) Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.170 to 4.8.174. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.170...classgraph-4.8.174) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 01c5d7e4a..729b3b413 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.5.0 3.3.1 0.8.12 - 4.8.170 + 4.8.174 1.15 2.16.1 1.26.1 From 87b768f0546e05befa69ce3aa8e93744f13d325f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:36:11 +0200 Subject: [PATCH 073/160] Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.0 to 3.4.2 (#304) Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.0 to 3.4.2. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.0...maven-jar-plugin-3.4.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 729b3b413..6414709bb 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 3.3.1 1.6.0 3.0.1 - 3.4.0 + 3.4.2 3.6.3 3.5.0 3.3.1 From f9ab04c71dd1636458f80c3e2337341ab7079c53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:36:22 +0200 Subject: [PATCH 074/160] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.2 to 3.2.4 (#294) Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.2 to 3.2.4. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.2...maven-gpg-plugin-3.2.4) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index c713af6c7..4eefd8531 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.2 + 3.2.4 ${gpg.keyname} ${gpg.keyname} diff --git a/pom.xml b/pom.xml index 6414709bb..5fef6d930 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.2 + 3.2.4 sign-artifacts From 099433928baded0fe579cba1b8651fc70dc075ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:37:20 +0200 Subject: [PATCH 075/160] Bump xmlunit.version from 2.9.1 to 2.10.0 (#298) Bumps `xmlunit.version` from 2.9.1 to 2.10.0. Updates `org.xmlunit:xmlunit-core` from 2.9.1 to 2.10.0 - [Release notes](https://github.com/xmlunit/xmlunit/releases) - [Changelog](https://github.com/xmlunit/xmlunit/blob/main/RELEASE_NOTES.md) - [Commits](https://github.com/xmlunit/xmlunit/compare/v2.9.1...v2.10.0) Updates `org.xmlunit:xmlunit-matchers` from 2.9.1 to 2.10.0 - [Release notes](https://github.com/xmlunit/xmlunit/releases) - [Changelog](https://github.com/xmlunit/xmlunit/blob/main/RELEASE_NOTES.md) - [Commits](https://github.com/xmlunit/xmlunit/compare/v2.9.1...v2.10.0) --- updated-dependencies: - dependency-name: org.xmlunit:xmlunit-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.xmlunit:xmlunit-matchers dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5fef6d930..216428380 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ 1.3.2 4.4.1 2.12.1 - 2.9.1 + 2.10.0 5.11.0 0.0.20131108.vaadin1 From 7f16c4fb50283f228833975d5cfc8c76a5bc518d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:47:28 +0000 Subject: [PATCH 076/160] Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0 Bumps org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 216428380..4e653f658 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 1.15 2.16.1 1.26.1 - 3.14.0 + 3.17.0 33.1.0-jre 5.0.1 2.2 From 1121a7848f0c5cd6def3eb25323e27b14db3daf1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:47:31 +0000 Subject: [PATCH 077/160] Bump org.mockito:mockito-core from 5.11.0 to 5.13.0 Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.11.0 to 5.13.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.11.0...v5.13.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 216428380..1ccbf2062 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 4.4.1 2.12.1 2.10.0 - 5.11.0 + 5.13.0 0.0.20131108.vaadin1 From 13e452081d8eeafd2c564c5b8963c4e1bc5e26be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:47:36 +0000 Subject: [PATCH 078/160] Bump slf4j.version from 2.0.13 to 2.0.16 Bumps `slf4j.version` from 2.0.13 to 2.0.16. Updates `org.slf4j:slf4j-api` from 2.0.13 to 2.0.16 Updates `org.slf4j:slf4j-simple` from 2.0.13 to 2.0.16 --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 216428380..6dcc0c6cc 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ 1.1.1 2.7.8 5.2.5 - 2.0.13 + 2.0.16 1.3.2 4.4.1 2.12.1 From 51b74eb8fa0a40cef387f788168b6308a7a39f7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:16:55 +0200 Subject: [PATCH 079/160] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.10.0 (#313) Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.3 to 3.10.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.10.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 4eefd8531..33943428f 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -21,7 +21,7 @@ 1.8 1.8 1.6.0 - 3.6.3 + 3.10.0 3.5.0 diff --git a/pom.xml b/pom.xml index 216428380..0452cf48a 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 1.6.0 3.0.1 3.4.2 - 3.6.3 + 3.10.0 3.5.0 3.3.1 0.8.12 From 2cb5533c4bef36b035b6532500c3884f197ff94e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:06:39 +0000 Subject: [PATCH 080/160] Bump org.skyscreamer:jsonassert from 1.5.1 to 1.5.3 Bumps [org.skyscreamer:jsonassert](https://github.com/skyscreamer/JSONassert) from 1.5.1 to 1.5.3. - [Release notes](https://github.com/skyscreamer/JSONassert/releases) - [Changelog](https://github.com/skyscreamer/JSONassert/blob/master/CHANGELOG.md) - [Commits](https://github.com/skyscreamer/JSONassert/compare/jsonassert-1.5.1...jsonassert-1.5.3) --- updated-dependencies: - dependency-name: org.skyscreamer:jsonassert dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ba620ccb..d14471e4d 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 2.3.1 2.1.0 4.1.0 - 1.5.1 + 1.5.3 1.4.0 4.13.2 1.1.1 From 47d4c7e8b4e126f377f51190d60ec7cca9c0c9fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:06:42 +0000 Subject: [PATCH 081/160] Bump hamcrest.version from 2.2 to 3.0 Bumps `hamcrest.version` from 2.2 to 3.0. Updates `org.hamcrest:hamcrest` from 2.2 to 3.0 - [Release notes](https://github.com/hamcrest/JavaHamcrest/releases) - [Changelog](https://github.com/hamcrest/JavaHamcrest/blob/master/CHANGES.md) - [Commits](https://github.com/hamcrest/JavaHamcrest/compare/v2.2...v3.0) Updates `org.hamcrest:hamcrest-core` from 2.2 to 3.0 - [Release notes](https://github.com/hamcrest/JavaHamcrest/releases) - [Changelog](https://github.com/hamcrest/JavaHamcrest/blob/master/CHANGES.md) - [Commits](https://github.com/hamcrest/JavaHamcrest/compare/v2.2...v3.0) --- updated-dependencies: - dependency-name: org.hamcrest:hamcrest dependency-type: direct:development update-type: version-update:semver-major - dependency-name: org.hamcrest:hamcrest-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ba620ccb..36a665b5e 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ 3.17.0 33.1.0-jre 5.0.1 - 2.2 + 3.0 2.16.2 2.0.1.Final 2.3.1 From a64921a1a6b20f1f9483e4dfa262174268e24f90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:06:45 +0000 Subject: [PATCH 082/160] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.4 to 3.2.5 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.4 to 3.2.5. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.4...maven-gpg-plugin-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 33943428f..f8471b667 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.5 ${gpg.keyname} ${gpg.keyname} diff --git a/pom.xml b/pom.xml index 3ba620ccb..9a45db245 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.5 sign-artifacts From fd3f885f121541ef5bf9ad68b7c67cb932cb484e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:06:46 +0000 Subject: [PATCH 083/160] Bump com.google.guava:guava from 33.1.0-jre to 33.3.0-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.1.0-jre to 33.3.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ba620ccb..c44e5ed20 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 2.16.1 1.26.1 3.17.0 - 33.1.0-jre + 33.3.0-jre 5.0.1 2.2 2.16.2 From fd856d52f068a7f71ae1bb8c2ce377ed613ba903 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 06:32:58 +0000 Subject: [PATCH 084/160] Bump jackson.version from 2.16.2 to 2.17.2 Bumps `jackson.version` from 2.16.2 to 2.17.2. Updates `com.fasterxml.jackson.core:jackson-databind` from 2.16.2 to 2.17.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-core` from 2.16.2 to 2.17.2 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.16.2...jackson-core-2.17.2) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.16.2 to 2.17.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.16.2 to 2.17.2 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.16.2...jackson-dataformat-xml-2.17.2) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6763089b2..75fb5f610 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 33.3.0-jre 5.0.1 3.0 - 2.16.2 + 2.17.2 2.0.1.Final 2.3.1 2.1.0 From 0a278c376b21f1253a9bbba5526bd5849021e906 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:21:09 +0000 Subject: [PATCH 085/160] Bump org.apache.maven.plugins:maven-project-info-reports-plugin Bumps [org.apache.maven.plugins:maven-project-info-reports-plugin](https://github.com/apache/maven-project-info-reports-plugin) from 3.5.0 to 3.7.0. - [Commits](https://github.com/apache/maven-project-info-reports-plugin/compare/maven-project-info-reports-plugin-3.5.0...maven-project-info-reports-plugin-3.7.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-project-info-reports-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index f8471b667..bdccf3195 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -22,7 +22,7 @@ 1.8 1.6.0 3.10.0 - 3.5.0 + 3.7.0 diff --git a/pom.xml b/pom.xml index 75fb5f610..e08a9d63b 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ 3.0.1 3.4.2 3.10.0 - 3.5.0 + 3.7.0 3.3.1 0.8.12 4.8.174 From d2998c92312b91d594a078aa0f630a4041cc6d47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:21:12 +0000 Subject: [PATCH 086/160] Bump io.github.classgraph:classgraph from 4.8.174 to 4.8.175 Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.174 to 4.8.175. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.174...classgraph-4.8.175) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75fb5f610..157cd17af 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.5.0 3.3.1 0.8.12 - 4.8.174 + 4.8.175 1.15 2.16.1 1.26.1 From 07fdafed6c41aa5d98bebf4ca24288592d0d1b84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:21:14 +0000 Subject: [PATCH 087/160] Bump org.sonatype.plugins:nexus-staging-maven-plugin Bumps org.sonatype.plugins:nexus-staging-maven-plugin from 1.6.13 to 1.7.0. --- updated-dependencies: - dependency-name: org.sonatype.plugins:nexus-staging-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75fb5f610..459799464 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true ossrh From fd615cd88f9a9aafc794d596ed4548431327a24c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:21:16 +0000 Subject: [PATCH 088/160] Bump org.apache.poi:poi-ooxml from 5.2.5 to 5.3.0 Bumps org.apache.poi:poi-ooxml from 5.2.5 to 5.3.0. --- updated-dependencies: - dependency-name: org.apache.poi:poi-ooxml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75fb5f610..aa37bf298 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 4.13.2 1.1.1 2.7.8 - 5.2.5 + 5.3.0 2.0.16 1.3.2 4.4.1 From 1735dfc3a96b685f6b1581e485cea49d585c577b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:21:18 +0000 Subject: [PATCH 089/160] Bump org.apache.commons:commons-compress from 1.26.1 to 1.27.1 Bumps org.apache.commons:commons-compress from 1.26.1 to 1.27.1. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75fb5f610..95c0b6e53 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 4.8.174 1.15 2.16.1 - 1.26.1 + 1.27.1 3.17.0 33.3.0-jre 5.0.1 From b92237cba7a5d7063cf51aa53ab6d1f2211c4fdd Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Fri, 13 Sep 2024 15:51:24 +0200 Subject: [PATCH 090/160] Introduces overloaded variants Signed-off-by: Frank Schnicke --- .../v3/dataformat/core/util/AasUtils.java | 104 +++++++++++++++--- .../v3/dataformat/core/util/AasUtilsTest.java | 29 ++++- 2 files changed, 114 insertions(+), 19 deletions(-) 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 070140ebc..22ffd8272 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 @@ -110,7 +110,6 @@ 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 * @@ -133,18 +149,16 @@ public static Reference toReference(Identifiable identifiable) { } /** - * Gets the KeyElements type matching the provided Referable + * Creates a reference for an Identifiable instance * - * @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 + * @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 KeyTypes referableToKeyType(Referable referable) { - Class aasInterface = ReflectionHelper.getAasInterface(referable.getClass()); - if (aasInterface != null) { - return KeyTypes.valueOf(EnumDeserializer.deserializeEnumName(aasInterface.getSimpleName())); - } - return null; + public static Reference toReference(Identifiable identifiable, boolean setReferredSemanticIdIfHasSemantics) { + Reference reference = toReference(identifiable); + + return handleReferredSemanticId(identifiable, setReferredSemanticIdIfHasSemantics, reference); } /** @@ -169,7 +183,6 @@ 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 * @@ -200,6 +234,42 @@ public static Reference toReference(Reference parent, Referable element) { 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. * @@ -356,9 +426,13 @@ public static T resolve(Reference reference, Environment e return type.cast(current); } - private static void setReferredSemanticIdIfHasSemantics(Object obj, Reference reference) { - if (obj instanceof HasSemantics) { - reference.setReferredSemanticId(((HasSemantics) obj).getSemanticId()); + 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/util/AasUtilsTest.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java index eec846fa6..6ea6e25cc 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 @@ -509,14 +509,21 @@ public void whenAsString_withReferredSemanticId_success() { } @Test - public void whenAsReference_IdentifiableWithSemanticId_success() { + public void whenAsReferenceWithReferredSemanticId_IdentifiableWithSemanticId_success() { Submodel submodel = AASFull.SUBMODEL_3; - Reference ref = AasUtils.toReference(submodel); + Reference ref = AasUtils.toReference(submodel, true); assertEquals(submodel.getSemanticId(), ref.getReferredSemanticId()); } @Test - public void whenAsReference_PropertyWithSemanticId_success() { + 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) @@ -525,9 +532,23 @@ public void whenAsReference_PropertyWithSemanticId_success() { .value("bar") .build()) .build(); - Reference ref = AasUtils.toReference(reference, prop); + 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() From c46a0ec56fc0c2ed02a296080bbe1f4f7a1e9816 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:33:23 +0000 Subject: [PATCH 091/160] Bump org.apache.maven.plugins:maven-dependency-plugin Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.6.1 to 3.8.0. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.6.1...maven-dependency-plugin-3.8.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5746cd1fb..6b9e937f8 100644 --- a/pom.xml +++ b/pom.xml @@ -190,7 +190,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.6.1 + 3.8.0 From 47df4415c47c83ff54e60a1332fc081752d4cbe9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:18:57 +0000 Subject: [PATCH 092/160] Bump io.github.classgraph:classgraph from 4.8.175 to 4.8.176 Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.175 to 4.8.176. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.175...classgraph-4.8.176) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5746cd1fb..61ba1544d 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.7.0 3.3.1 0.8.12 - 4.8.175 + 4.8.176 1.15 2.16.1 1.27.1 From 5b17587e9ceb8c38d22f8b1581cf0c9cb12c3f35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:56:24 +0000 Subject: [PATCH 093/160] Bump commons-io:commons-io from 2.16.1 to 2.17.0 Bumps commons-io:commons-io from 2.16.1 to 2.17.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5746cd1fb..80aa6138a 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 0.8.12 4.8.175 1.15 - 2.16.1 + 2.17.0 1.27.1 3.17.0 33.3.0-jre From 8be0beef7dc41d180263c61a0cc0e342a12dbbaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:32:53 +0000 Subject: [PATCH 094/160] Bump com.networknt:json-schema-validator from 1.4.0 to 1.5.2 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.4.0 to 1.5.2. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.4.0...1.5.2) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5746cd1fb..39c3ed864 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.3 - 1.4.0 + 1.5.2 4.13.2 1.1.1 2.7.8 From 63c330ec9555d2916b91954e61b06c4de9f188c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:57:34 +0000 Subject: [PATCH 095/160] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.5 to 3.2.7 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.5 to 3.2.7. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.5...maven-gpg-plugin-3.2.7) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index bdccf3195..7f099f069 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.5 + 3.2.7 ${gpg.keyname} ${gpg.keyname} diff --git a/pom.xml b/pom.xml index 5746cd1fb..3a9cda673 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.5 + 3.2.7 sign-artifacts From 074f87ae847265f46e5d8d9dce5dc4fa88893deb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:12:10 +0000 Subject: [PATCH 096/160] Bump com.google.guava:guava from 33.3.0-jre to 33.3.1-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.3.0-jre to 33.3.1-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95e6a1f8f..d99511ae8 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 2.17.0 1.27.1 3.17.0 - 33.3.0-jre + 33.3.1-jre 5.0.1 3.0 2.17.2 From bbb51303dcfb3e3f791e8bc6901207af653448af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:12:13 +0000 Subject: [PATCH 097/160] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.0 to 3.10.1 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.0 to 3.10.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.0...maven-javadoc-plugin-3.10.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 7f099f069..81922ca8d 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -21,7 +21,7 @@ 1.8 1.8 1.6.0 - 3.10.0 + 3.10.1 3.7.0 diff --git a/pom.xml b/pom.xml index 95e6a1f8f..e89bfa319 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 1.6.0 3.0.1 3.4.2 - 3.10.0 + 3.10.1 3.7.0 3.3.1 0.8.12 From a3b9dfcad2ab7c3241d51cafed3226faf81c5e1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:12:20 +0000 Subject: [PATCH 098/160] Bump jackson.version from 2.17.2 to 2.18.0 Bumps `jackson.version` from 2.17.2 to 2.18.0. Updates `com.fasterxml.jackson.core:jackson-databind` from 2.17.2 to 2.18.0 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-core` from 2.17.2 to 2.18.0 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.17.2...jackson-core-2.18.0) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.17.2 to 2.18.0 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.17.2 to 2.18.0 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.17.2...jackson-dataformat-xml-2.18.0) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95e6a1f8f..fc66bcb1f 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 33.3.0-jre 5.0.1 3.0 - 2.17.2 + 2.18.0 2.0.1.Final 2.3.1 2.1.0 From 3d23699663499a2705415e61a6f50f6e7236fd3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:12:24 +0000 Subject: [PATCH 099/160] Bump org.mockito:mockito-core from 5.13.0 to 5.14.1 Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.13.0 to 5.14.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.13.0...v5.14.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95e6a1f8f..f7ac2aad0 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 4.4.1 2.12.1 2.10.0 - 5.13.0 + 5.14.1 0.0.20131108.vaadin1 From 3e7dd5f940563f52739bf72f95ebb3a60e8c4c09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:42:03 +0000 Subject: [PATCH 100/160] Bump io.github.classgraph:classgraph from 4.8.176 to 4.8.177 Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.176 to 4.8.177. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.176...classgraph-4.8.177) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5140cafdd..77307fe54 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.7.0 3.3.1 0.8.12 - 4.8.176 + 4.8.177 1.15 2.17.0 1.27.1 From c286a1f49a046da5b8464a585ac648b3ccb8b78e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:28:19 +0000 Subject: [PATCH 101/160] Bump org.mockito:mockito-core from 5.14.1 to 5.14.2 Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.14.1 to 5.14.2. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.14.1...v5.14.2) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5140cafdd..bdfaba252 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 4.4.1 2.12.1 2.10.0 - 5.14.1 + 5.14.2 0.0.20131108.vaadin1 From 52fa9a8beb3d2d782af6064d72ed696e097730e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:09:43 +0000 Subject: [PATCH 102/160] Bump org.apache.maven.plugins:maven-project-info-reports-plugin Bumps [org.apache.maven.plugins:maven-project-info-reports-plugin](https://github.com/apache/maven-project-info-reports-plugin) from 3.7.0 to 3.8.0. - [Commits](https://github.com/apache/maven-project-info-reports-plugin/compare/maven-project-info-reports-plugin-3.7.0...maven-project-info-reports-plugin-3.8.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-project-info-reports-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 81922ca8d..6bb1f07a9 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -22,7 +22,7 @@ 1.8 1.6.0 3.10.1 - 3.7.0 + 3.8.0 diff --git a/pom.xml b/pom.xml index 5140cafdd..a1cc7cf9c 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ 3.0.1 3.4.2 3.10.1 - 3.7.0 + 3.8.0 3.3.1 0.8.12 4.8.176 From 3d28ba2b61fd32599680ad39f73e531af05221e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:33:46 +0000 Subject: [PATCH 103/160] Bump org.apache.maven.plugins:maven-dependency-plugin Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.8.0 to 3.8.1. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.8.0...maven-dependency-plugin-3.8.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d57a40977..619cda605 100644 --- a/pom.xml +++ b/pom.xml @@ -190,7 +190,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.8.0 + 3.8.1 From 16bf37a7a0c21260a6ade3510a0d78aef78500bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:54:34 +0000 Subject: [PATCH 104/160] Bump jackson.version from 2.18.0 to 2.18.1 Bumps `jackson.version` from 2.18.0 to 2.18.1. Updates `com.fasterxml.jackson.core:jackson-databind` from 2.18.0 to 2.18.1 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-core` from 2.18.0 to 2.18.1 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.18.0...jackson-core-2.18.1) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.18.0 to 2.18.1 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.18.0 to 2.18.1 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.18.0...jackson-dataformat-xml-2.18.1) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 619cda605..483f81fee 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 33.3.1-jre 5.0.1 3.0 - 2.18.0 + 2.18.1 2.0.1.Final 2.3.1 2.1.0 From 2cf6e7a30e7d17ae42269279cdaae513b890233b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:26:08 +0000 Subject: [PATCH 105/160] Bump com.networknt:json-schema-validator from 1.5.2 to 1.5.3 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.5.2 to 1.5.3. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.5.2...1.5.3) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 619cda605..01a688772 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.3 - 1.5.2 + 1.5.3 4.13.2 1.1.1 2.7.8 From 1a3716786e16fbc8f75b1d5ad7f5756eb2457407 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:57:14 +0000 Subject: [PATCH 106/160] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.1 to 3.11.1 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.1 to 3.11.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.1...maven-javadoc-plugin-3.11.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 6bb1f07a9..19b95c826 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -21,7 +21,7 @@ 1.8 1.8 1.6.0 - 3.10.1 + 3.11.1 3.8.0 diff --git a/pom.xml b/pom.xml index 619cda605..d29eb9083 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 1.6.0 3.0.1 3.4.2 - 3.10.1 + 3.11.1 3.8.0 3.3.1 0.8.12 From 256e055f24f5578d78de634df2012917b65fac0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:29:49 +0000 Subject: [PATCH 107/160] Bump io.github.classgraph:classgraph from 4.8.177 to 4.8.179 Bumps [io.github.classgraph:classgraph](https://github.com/classgraph/classgraph) from 4.8.177 to 4.8.179. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.177...classgraph-4.8.179) --- updated-dependencies: - dependency-name: io.github.classgraph:classgraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 619cda605..7dba3477b 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 3.8.0 3.3.1 0.8.12 - 4.8.177 + 4.8.179 1.15 2.17.0 1.27.1 From 0b73774db491b38b3e1a883aa1452e3a7846af73 Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Tue, 19 Nov 2024 15:48:11 +0100 Subject: [PATCH 108/160] fix OperationResult to correctly inherit from BaseOperationResult (#343) --- .../aas4j/v3/model/OperationResult.java | 2 +- .../model/builder/OperationResultBuilder.java | 67 ++++++++++++++-- .../impl/DefaultBaseOperationResult.java | 19 +++-- .../v3/model/impl/DefaultOperationResult.java | 78 +++++++++++++++++-- 4 files changed, 143 insertions(+), 23 deletions(-) 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(); From c7540aaf30a91541d1c31117942015e04b8ee814 Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Tue, 19 Nov 2024 16:06:43 +0100 Subject: [PATCH 109/160] remove github pages & docs --- .github/workflows/docfx-build-publish.yml | 29 - docs/.gitignore | 9 - docs/articles/building.md | 28 - docs/articles/development_workflow.md | 37 - docs/articles/intro.md | 16 - docs/articles/releasing.md | 5 - docs/articles/toc.yml | 10 - docs/articles/usage.md | 85 --- docs/{adr => }/branching_strategy.png | Bin docs/{adr => }/decision_records.md | 0 docs/{adr => }/development_process.md | 0 docs/docfx.json | 39 - docs/images/adminshellio-48x48.jpg | Bin 2228 -> 0 bytes docs/images/favicon-16x16.png | Bin 1504 -> 0 bytes docs/images/favicon-32x32.png | Bin 2483 -> 0 bytes docs/images/favicon-96x96.png | Bin 11434 -> 0 bytes docs/images/favicon.ico | Bin 1150 -> 0 bytes docs/index.md | 6 - docs/toc.yml | 2 - pom.xml | 836 +++++++++++----------- 20 files changed, 418 insertions(+), 684 deletions(-) delete mode 100644 .github/workflows/docfx-build-publish.yml delete mode 100644 docs/.gitignore delete mode 100644 docs/articles/building.md delete mode 100644 docs/articles/development_workflow.md delete mode 100644 docs/articles/intro.md delete mode 100644 docs/articles/releasing.md delete mode 100644 docs/articles/toc.yml delete mode 100644 docs/articles/usage.md rename docs/{adr => }/branching_strategy.png (100%) rename docs/{adr => }/decision_records.md (100%) rename docs/{adr => }/development_process.md (100%) delete mode 100644 docs/docfx.json delete mode 100644 docs/images/adminshellio-48x48.jpg delete mode 100644 docs/images/favicon-16x16.png delete mode 100644 docs/images/favicon-32x32.png delete mode 100644 docs/images/favicon-96x96.png delete mode 100644 docs/images/favicon.ico delete mode 100644 docs/index.md delete mode 100644 docs/toc.yml 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/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 820c4136d498a5a5fc9fbd203760c84278d8d0cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2228 zcmbW1do)-83bJ43Z-N+}YlwuyEmw2@ZHCbM(8=j>m*`+cAHocBG?^StN#Iq!L2@vN8y zsQP$%djcR32;fTwAZ7yy4@z_-0QmX>mH+_2Bsp~eELnjh<4=j_0e3(K1d_&I0?UG> zl7m3NvQRlFR61eu3i2=*90rBLmEdp%MTwyD$|_2V%F?y;5NW%#OA?AOC`?-Mze)TM zP=f*cf&E|*0+3Myfz?3b0l-M&RaQbIh5Ab%88AdvPGSkJASq~3mDmS^Wh7>0ArMJ* ziX;y})MV974!Fu`1Q4N!_+7SX1ywLpx29grz)8NDUHI8_dAOFgj;YCc0>2<%{xp%+0rM0b{@u07NU~p)7Wc2r`>8H$RGqca<*vp)kE3aO^;qnCQ z8}B~|H$@*mNx47(_+MCG$o_*%O~NH3xdRAP$_0{1l1#7~MAqbhoVsfOlo+ppuuX&Q zax186>XkRO3*>8tpPhtjnc1_E0x8;`Wd9vl`u|1t1?=BkbATckB)L4W8h`<|Pi)uq zkh>CCmj@LVwEgc-ruNh4++C&@d#!8ia~_Qbt6Dr{85E``%u-^T#DMH2L2T=d#>{ZO zIm0%VRFmJw3qv~3r5;PmE6?Ay8WRJo`X&7}7t<}AsI5QRrD-iGHAz!Z@?ldg^)Edw? z8_gnKZGg<@kRI8WF+Ot!7R|%!qBO?NFs-W(diqCcRnYL$p*GKj^ntkRi#DQZR%Ujf z;O4btq+^vW;X9}7MAUC3y4tT!M?|TU^R#*ieli=YBsS_Dba`Lqq21T=2+o4*SJC}v zXAqnLy=sC#IxKZm*G&x_6o0P?`OPAqLWElu>2nGBy<*R+d3b*n~~2eGmgl z2Csj%dU82ZW!|44niLRbT$$GAPQQ!WOQ-E2?_Hs03~659XPTwsY+HC_3+~ ztG?wmDo61J2W1vj&Oz-ajXrYr+qJ*g%EFAJ^**Ke@lPYkfmu$rRhhzj+b=o0O7AB{ zlh%9K>n|~^YQ6T{9R&<~J|au0PIN}ow9ede`+I&{M%lo5JU)*$?B0#y3@F6`i3a9Tr)m#vqrj#0AN+Y>s~ z=d9(2px?-nF}Wx{s<%gjgcD{TDf3E+`Sevl`3rlzwvC3d#)c;N@BUw__8b(*QFOV#u2+0cH9;p;sX19<^r z06t+iENl@2JK$h3AjtU`$G$m?$v0}nhJ?Ji#ufuIZyYb?3A>RG%6y9* zXXW$zsO5>|9AqTkAm6_($agy7IM<2vwq*0tUWc}b)`L4*0YMx$!e}$2p|gVKgVDgB zkCpsfgxhYSnLZ_UsLj;+61F4i(A^4f{oM0+l$TxUPS`81E4#B?AyLK|=@=Wyqb%1O zu8_Rmp9Gri#+E#^Y0z;{p8b#D^+x9H9Cep&rKV`@h>8erYsSR%b`^OjrM_Ggw`GvL zPvkE+v^CUi!1tuqh#CX!^eg;yE>9utoGfN!&?$h-T#Xz)5Zl$s4>#YN;NtK#Yi4E9+(!2LB z)kZ(2M?2}=6rLk0$74G4qd~Pg@F52^b(a89np;z^`h#v1v2cPa8D z&BdLi+_)TyXUBGJH^p=G*Occ)OTM{%GnH0Nm%a{P_1DHhnkPpJ#+r}oQ?J!}6ja0g zD5y80?v*p$E`rwFWnaUgvG1AIi3$vd6i1J&xx`YpUsAvwL~rLHT=+#m{w@#GLGVM+ nF^fEnGrAoiq&@75j)e4qmm6-lD4)|R8mD*6|0WfLngLCWr3a zhH?4S1pt7d1P6tq-rZq~KSbBH-fj`7`-rnSWHSK8sjf3LCp2Cp3f~q83R^xKMFTHJ zaCis+N52B#coG11^ys(_fOtFrV^jdhIRLB_fLmW@cwiu+3mW#x3xh zNlV+XzCxwt7uG{X^%AwVXT)HzBGa>TLq_v8S?48b`vqy+p_1pklIO`1)sd3sV7)rQVtlcjysaJEKG$$Pfua#d)7j9J)ptg4k?tcWXa<`pTRvX&DPWkPwY zsI=wO6Lsg9Q8BEimnhcf*0`pZet)ZW*PVv_Me>k4vh4*jN`Au+1@%AvDGR&T7<#vn zR?^%uVt70_w)%#2S?*)^E7jQB(sj3_U*CI%&6lpbE%nTO;+$FTlwP*{N{wf3&FY)d zr$gfv13FB0<-W=nS*pHlRo`WGU$(k0L)mxnMNfvJJ5$-Ww@QJ@E|+M>Dtm`9DMhLB z4wKb_OxY2;-DbBNEU>t#eQ8Req+eIjHMHbJp159VwjuNL^D}dE$n^9iGL>AX#{8Zq z=^gIZPyAXTuj(E!*$~)nAD*<7^=NOjcEI-OC%r@GYg-3RX4pPugsl^Z?R;bF(Wmn3 zsxH~9H@s?jX^(bpZq8t}nQb;B3|ptBlImLWHQjm`)>+`3)~=4XhN+oZ69NxST2h)c zXBt$g&o!qTlxG{&1?~M0I{Qb>)|;B%6nXn^buH%`RY@|XSgtAU8N8+G(oI?ou=S1E z`ciM|)SCv36W!wzU3!zrHZ^XwA=CC(`f;6UQv24}i&QHdpNhVHTTo1MtmO+da25pb z6`?-(oo$sL+JtV*l%UO#t27KMl}TsQSd0p?c1{+gy89$M+{x$I+)70a{J($X^N zX<6x)F76494Bs6V74cHpMpt&I+BN?8jYL0!uTMo$DZQw?xa?7)01_tr5-&nb7P<+Z zu$mFq#TGZ0rOp`FRO(srxeLioCo3x}ZAtaFnWr<`N-bisSh2w?{p!UljcEr%qcg+y zhyTR za}f07~^PY}zE<9M@a42UlT#KXi5 zgu?`fQSAApD7)3ciui0OktSpT3XjHNh0r)$#vw01tUoruo8(2r6E=F|eZ2`puP}n2 zR}2IR$T(bLVj`C7pix6jR1$e4H@olFkmGvaxyIEYLRMNttT6wFuS z-ecbNB$H!UTuuxG2qdB#5S~Jrl?!zKX7+HIP>ci7++VX8MLt=8gm8H*=!k#?-c5xQ z#BshW*}d~UosdYB0t8Ms7D3;H`v1tih20u=O`}c)$Y$lCFWN&2q1qAr9hzzDr0NsZ{^r!nW{ryOE bA37GTz@qc5K3IpK9ROv^&Y;3T>dC(VWys;& diff --git a/docs/images/favicon-32x32.png b/docs/images/favicon-32x32.png deleted file mode 100644 index bc1d21954348f993ffb1198e1112d0338151c938..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2483 zcmZ{l2{e>@AIG1Oge0Ug(rqY2m<7Wu35}T)W663GX2#4I+srj%t7I4rMVrWSxk8o_ zH*JXS6&l&EkTqG#cB9OYl=410?|I+ed(L~F^Lu{h|Nnk|-`{^Z&w0)}l1W?S)#U*I z*kXHx;0$KiddSLvZ|3bbHtMi<|E&O z*c@m9QmF6U!ogTAGI4H|sh;eFSz`MSYn6NmP;={N zQPF($)MB4cL`-yf#%&0!wq6>cKq=@de07W?)w-+Gb8b;7_SuYndcd}fr*9&!4%|Y8 zHeO}K$xBzCbNT``1$Q0)=4<9YZrq}?(cB^z&_OuTnhq#i8yn9* z807T|WSRL=x~n>%5A9McK<^ICR~w7%VY&p;2X8H$!4W@70z-Dz@wDH3Zr0B&wZy1sBxH1?QbBcDq|Y*7M*4- zL?+TVJm2Tb>RqzLW0Ng5?KSC6CE~^=+I0%+kna1%K{bM_5icY}Vb;RelYo@r@AwX9 zf*4PHtI~C4;1SeaN3?Qppx`$-v&-jrCKIjUEtQO>nc|iw3_JdYWMcMT>WzS^ATd@g zwm-yFU8u&ZO;+QVySrUe{YA0CQBp&H+w;q_)L_Y-#+E2S@O#gsFWG&GJq_Sjkg@@0 ztGR?QnD13nlbQ7T)(2e-4+IV$^q6%@NBS6vb1I9V-0JI5x~YxaS}$$Wy!}KW=b>96 zOh(^;Y_Ek*Mo2u+3U#rnT6P+@^kZK8f4Di+&=WiR(}ohNtvuBrCu6ko^+_$VigWH< z5j{6`ZZ>`{rYa_QA2up#T>9uUsY73_i?S%Osss<+K23T=zhg05eMpG?;r7J7hJM870bXsk8TylL*67}6D!mS`n zGM;g^`~dXPSiX8nQHFX4^R!9UZlt!)YvSy*^SK_HVo*9nT4L+H0T`KDO!OUBTw*g| zLiL-T7CYxWOk7I{t9l)ZGv5LH(_wS4-H4 zN}LxK{j~k~{S~#e^kvzViQ|RHkz1;nB?N<)`YT!P53MFwIvIj_U(1JHetBr}{oD$K zC-kFPr0cjzLpA@)iJ>!M|BE^M=%u+8=B{I;^w*3cm*L$O3Teutl84yMy;9MFeNOU} zx_6P86?K{n#%a%%vRuWIWtlbyJE~TrclDEdqNAk=DGTWdouA&#?D+HS`;#GUZ5%c? zDJICoHm5*k|DTV~#;TfG`k0WJD z3v=ftdbFB0B^6gA51DB^y>xWHSH>NFUBc@#362^8!ek>eQvU(q`5!UXWgg?77xc?K zs?hFZVfOw@r8TjTkB; zh_7~j{%qE~bSe0cN<=F>y<=f4t^3Y{@K4iS-D7%eSxbJ7`P=2SQ_oK`r#!PV$D7{& zHg)!ijh=#DJPkah?6OqZ`YTD@*SvCm9T$0BTxnK$#RIDLLNuJ>qqd9;3^Sq%$W+c+ z)UQ4GwUH2U6Z|Kov6WTNYjCL&*9)uj9UB_s329d7(S)Qa0EcSHQ`C6iwTU`eEMhI9 z{s?%`>>@c(12r$XX!Bq^Rbk+`@-C!q_CdGFvKDi#dhyRW#@+PWZ?&lNVS}7TLBY@Z zocm{15l)k7VHPQm`uqilA^nbLHxA*R1uZABey@?RMGXN{VcC0{`I!_(RhKRNd<%v9 zzV1ceh8yykp`*kvIy(H4Ju+hP*Ks9)_(tQl=xcA-Vte#^a-(&gr5=8ju@tjCRN%Ps zmUbTe<7xA3Ja~Q-9vw>yrGp7TAy5cI1jZ1Fa6y=1kr*t}_y7WdMIffT`w#w4K``5o z#fbX<1(}z8W5ELD^$r0XIulD{2eCuB910EWVi4w<3yQG+h+IlACx{ioG-Oa{Ja#C6 zibNS8Ba!Q2`?=@=$P(9CE}OxNpoG!^+h7WlZckydXn`=ak(rUXAqIv*AWaMrriMrq z%n6Bx`SW-jEF2yY5n;qyr@;VeBX%frSU3k70&44yF8*P`R4kUjriBI5LwH!MBZzVV zWbs-J{2$Eso>;6uoyGL$0Z0sLD-e1PWOn}G^KZtT<;U}1N4oE5%7O^=2gIHgOy@;$ z=)m_?!8sw!L-*Xs|M0PQ0Vx1!iouwnP{yXlS$SopAhPubpX01kbO2#(otkg)4wT$} zkX)T@0R}6G4sIVF9Ks7?GvN$MIE%&(;llrW!*GTl1%qOkFwo}aXgZ4KXKYS2rlHKJ hrhaB<4Aq!w1XdV<>)Yc~zYKN&Y;DMda%j>9L(o^FWsH{Q$d-F$cq2~^>K)A zhR~mF2xk>ZQ9#WM(dlP{%vefA9suy70Ra4i0f4`sUH&HkfGZFHI5PkMc+&v@T!*X< zW&TeCjFGG)81V6*E3dmW>9YskK}ys4Q%n7qNQ_$x0s!<&(qIu)kF~>Y%V^W_lBo3Bli5Eu2Th>_F=S%|F%tgd!hz(!x8H_IZTo;ozv~S9 z{0#{)$Ykr9QJ^)&rbV6UI9D(1oPJN&oE3YO`;M=%er40|akn4hc}H{H_WqfoHeFL} zJ{BRWZrXjg74EE%b@)Re>#JEz04!$oEgC>sxP9NSryIk7EY$ENG7yll?e5=rdpRZj zo(z#dhYr~Vj}dYrK!F|>hz-6?4=@f-4?K_UnO@T@`XGcu7@E(F6hnWrP#f6g~5_IiQ*^z z&Vnq{D3oyHpH99UxlXK1w4nLiM{3z2eSA(Ik4M(1uVPF56eO<5TLir7Xg66pSNHb% z-q|mCOAGxv5op3+l!-(|xS&YZdqQgc9^qStAZCQA61b|F(9O-vB4Hmd4NA0C(s!h? zoG3G@f5GJ1;7M(XB&Juuf%Mm_UtJ7OANN@*1KFk$Cme)cvh8!EdM-UccAJlK7@o$K zA<<-LUpj)Wz9i|0kt@aNK`dzZS6HP zzr-aiZMCI+RL-0&{cv-;qKgB=1=l+FSL2o$zftt{DfZsHbQ!RtfA`e_va+fFK5BzbyhjQ-qDDWlrs(b zXm|blgek?;rrPD``ZISLt~8F@y4X#WiN$x(*@lww$N?n*bjU*xnO!QQa1<7rluK|B zm~rK!8WQFs%9HV0&}qfq(?B$$v{b8t&VWWK@<9CbvG0g+CwJq^*48~%a;^+!r6nhS zn~pMjjLeo<`_KaWeu)fvJ8%9Y0U>dH&FBoIPBxwTtv*P__jBT z)Qv~<^2)L;Qb3|mBUKbPMfaPt+tl<^j=kwVe&t9P`^tn8nny~%6Gqhd-zaZ=oQF074 zS-}oASx!~0Ya02bhHX>Uc4X*6GcuWNYO|D#nt3c4tbS`Ve>@P31;JdX1Vt#2RTrj& z-U^Nm)LSBK44D3{U@B%x(MpCYEX)|aN|D6JU7~b=g1y)HHQ6>^ISGI#yK!d%8 zIsx1uTB?B`8VdyhM7|kdveP^mvv%Zm98{-kA0L?ps7dpcC@FCiNDv%b=p=ec8re)e zJy86FkX}%e;@dZ7d}sPO*W(!V8(2=M*=9By+Vml>3%j z>}CpK+m_7f%TAfDWS!VYC(X}qt7Hg;J;l?7;Ae7uKXE5e02kvC%0mRijd*!Ab&(F? z4#!cJ-I50i6U}3Rw2k3RMdjhR_yFf84(sT&7ArDcxcKeS=e_o3;Zg`^HbfaMcOYpE z2rD)MMjnESC6v&TA!Hi$s<GOpLKMgibU#dco8&zi+LAGLp3T{SXOeHDqxlg zq0ViU+fo;2DGO^3j`H}%$WW00aN!kT9H_HIJC+!-I`-u1G{9OusJ1UjhTCi~a&=AF zfqr1hNTKGdtz?ir>nMo;=}#_~iPfT0v;L|y@cew~VG2UEF96WDc2Fb{)aA5P1^iwf zEZVKMM!OQZ`?NE4DtuPg_!-7{jQPb1oT_6oMG$}UON=9bar9GL?=#w3Kfu2r(alp( zPXxg}I$2yZ&*-(y)PKXplR$IyXoj+mU`5~AHrn_r01_d_lL=9ALCoRv@LyeJM#QbX zF*l#BkEY#G<_8;>FmgAU!}7IE-M&j6r|W+Qchk1ORZ^GskB&LVU6|XQ6HVgQ-j2X( z;Nj#1v^eYW>F{ZaNGQ0>g^%>v*hh+Wwg7*eiMiQd)!DYBwIqugOR&rDEtMd%cI8+m z#}q5`8PmxGp@S&q;MghHVPdFj4a3nRsu-DB_oIIz6mTrzHN(fi_ctW46@t2l;||a5 z-Y~I3=gZW}#SG4uNnno=m~;5YF=1QkJv%0WOG{=*Ox4Yn1b?~g=3JHF(J08ZGCFBc zYhouhF0j10TzMY0;2-UN<}YR&S%}&;kV8g3u#^$RFf<2VyF|bsMonHIplhUn%fIF2 z2V^N54yMyuQ#W6PYJnLGG6Gr0Z^Fz5H_Z?N;qNtYHHncxQ5IFoX@aCq!6u~VRY}Dn zoLOmN;S}NUAO_vz2=cmyIxxKwjxOUe8ND`{6?^^B#Gx9>4Ig0Ce}{f!wjhU*MNn=;C)xXs$Bu-?o5?An)-ZRyh>9$BT~>|1 zdrs+9rEPx~%Pwo{#Kd9Go8}%a-Pn{ocTKyhueIg&F7>+uj2m8Gv`dJ+lNiSdX@R_k9D;Is4@FVS63 zuSqFBM+`12gQtni*U>BI@%HV@4Pt{^U}op2968wRD6ldCeMoZ3i8V}ejiUzK&2kRVlaHfhykS3Y9)HSa@w>vK z8_s`$yyu3lmB50-FOp5ToAzjoX_(%Rw_T{U2QPL~fRD>H2;aAjuN!|64T?-VDO2}u zV>JuYOIQ$W@pwl(&FE1eETLN^uG`H6)0SJ%qCc)`-C&m9V4^Kt-$Ec^sxR)qeW>j zuJZUq6|o&?OWs}hAvDRLO91gIIv%Wg(tuqOA6etDzfw`Sj@oxu(Xc?%;1I3(f}yTm zm-xkG2?(sSlUhy>*k&lSI3C9R$A`!+|))%|D==y0PO6fO%3Zpnr zU6CAG5Xz@}> zM^4YR8E-57+?4;rX{5o36}vhkhID9cN&4>`ihjYD(Np~lwHv|nys=njU` zcRWSGwv@D-jY&RQ!M*I4B%M=iRRR#U6&w3TL7qgO@}zUFzYQyi~AlPTw(}M?M2>pASS5>Qvik?G!$E;i@{V^?f-(V z=v4CMt9)(;$&MHm5~MtB9Twr4#S%^g^H!FcWhtq#kwj&Z4Uw2ss_mph*oYUF#cHT( zTLfeoBDXWo2~zMJa367iY4^lcLsiz5KjUkso$F}KeT}hnB%RoC-3idu#_1bBe``qh zCP|n%r?cIQ#9bkq2bRDTsx>nb1q=T>W2Uz@x9=&1=y=^to@gm&$=?A=ZMOz6}6Nx(T>$J6zBE%tXjyI(n3AK0~*T(HFBZQlA^a4ojTW*Kl#F<#gO7 zdW}#>zmEs5myMk6uDj*1HxEPfrXkO`$OVr=6_JvXmn7%oawHQo0(V>Jdr>U3X4NLX zpBK|h($Feym|H?QJ=FGbEq9c$D_oj)jtzy74j--a{F}N9``6?xXnnc35{w8 z!|4Y|I4GE5VyEonhbS}-_bm(s9O`-;zuv?1LmVw#BYwEPec7U@^yBO2-_vgO4JT)x zxxGpu%;N7IbE>715yyuvr`$twop8$U^17uEYHJFN3r(vAYsB98l0sgUbnS5i7t0Fa z{4SbS31rfTqiNn9Z1uF@GO1QZI4HR+(y-r|PfALsWCqiqgJOz694y zBjTb*oQ|k_z;Se*g`N)J$z-9$9u!#C^g6?Ruh5}E0t}{T-&2^zII_oRB75lYK!$)a z&t&5%Vx4AEyU86<>Zi+#zWBq4R#IeSE)A41PD>$(a4wv1GLS=swPFRErDOQ-V2E`P z;6KA81&Tmwzzx|sS?jXPB~Gxjv;owAU#cV;vrB3j)IiTJ2~&Wjhqa*?te?;B<8Bu6 zbzRt@`DY|tm*H!mLuZ^)(l@poHjQW%{VcO-L|iVhZ3|h4T=nI4Dh!k{gMpxxh+YY| zS)Tq*6IAVB`p6yhl7a>uJYS8QJ8z9=$sdm>h|2M0>A^%_xyb@?T9>rMW0`17451Db z4=xtmFrv^XQku{$0=q#6k*FP@*OwL&b?bk{$eTwTiT zTcEs<(zZUCP;iC8COtXQg-8%ww<`>XyqvdjLve}o=FL;BHM^*GQu_#^4B=UKB+OX- z(o-mqQGicHIvokMj8?z|rKvdEdg_1G9L`vHQUu!gx>>(O zi0Vja!|;akmBWZrW|Dk{;E8AoPHxc#G3LY~u43z~1hlD`4JAvpxuL*mt;%esR$1nh z3P@>S{h}_|vR|-TN2qR(pjSY6%D8tE2Ey+ZP(r!TipS(haAisoJUrg6P6o zp-J}G*f5zGqcSY!@^hsY1WtS6U+a~5^P3IithO<#@8f^_80pK);H`-e(lsbh=%dX^ z1g9t^N%9N|%FYxDj(P6$o21xh}Bs4u7-YeJI zKysoCX??9Su9Ie@z)^WCMzO>gqGCuN(&^4>P*JwZQrn;-UQ}?PO9=n&2-`EemQo9$ zzVhv#!ujZr0`FRA{URpz$!i|h@NY)s;9wX^svj^(Fr~IPN5U%EN@Q~2ocuWt~6G4

2wkWmf!U;pq05xPc46cqz*1bL6=vB7TK0tTVms3)_rYJI08I&FUiZ)`K*8A40Ofk zHZJ~lo5>@+TZ*WMv)*G8y;>6RtPnKX5F2|s!h8sp@@2q1U0#r-CoZ*EmJTot6ESJs zvVgdMEXlRddh4Yw&es~_(Zc-8sl_j!Rg!$j z-i}^zn0dPtOL4wUEB2kUVtfS)oQ2YJVFjlr(O_WGrFCtFAKW+ZH@P@QMQ$oK%s9fa zR|sSSeof`MQE~C~VscQRbYyr*?)2$I(Z|Gf$2zVn3aj7HmzVM%rP}X8AF>KsS3=0$VyMi*Jdi3TQz(wK?zNNIe;eH7g~zX$yhC5#LzCTLE*K0%1Nw~7iAG~h z1Gbk4fqjR-b*Nh4p#U?CoahKB(M8*>aV@C-yt=QOWFe;rQyRtJ8r7pT2nAwPCc2B~ zN5Vd08vXF?)J*rqwaqYJzalt$pWv#~9W{~hfB}B(AV2z|xIFI&Lh%yYu`-XNu_!5# z3)DyD`2Z~(oZZ-XvCckSju@4WS>WMtS``i@V(EYp&g1RYn{L2N+qyE)RKyA~x@WbM z+x?f|nuQtIYEAfX7XR`52;cK}>6_2Pd{|$pO26v!d190=s$3rx;kq-j0;M=x5o9=W z9Yr9gra0=YW6CIrhrjN6%f^&H`blnWm$h5Q_UnT_+57ERABQ^xS-5RKTmn*hxl@nbc}mHb zb$yT6OEub24b1OKe1*#=uHw&Un3A3@PYMctE;%p11jTAq5!94m@KoS(`CR-Psw>+U zIW~?u1-T>fK*tOHR!J^0Y*3+l+-{aRVX;JeqsJ_FaXn86nY_C1leKTG-3r6yl^Q%< z#wcNmf*n-?;~r^vyU+3PGL{_rUT;8H5+6Vt!wMV|o4xkS;_}tyTF??BP z$Y1EzI{3DPp@ezKySWZvu!J9jzXvE$;ZTlj?O zYPa0nOQN!>VZFWQ_6+p;9wXVq{h5pu^t|ZOcuSC5tb}yZD*Z+|%>3(&1_lCUH z?i1oGiF(WO;|9mI`fW3>>v_&Eqhz=HJ}q7U%(&-Zo|uoj!!kCOivX7%&f@`(I_7>q zc;WI1LM9@zG%tU^A0c0kbR734xyjp3XGw6}f1Msh^C_yzdzSNUIiohF0cn*|`d=VX z8pnmm`ZC*(~#V zcrZ4KZT4ZYBz_-abO}?S0bTH{16smfoSXT+c{M`|cp; z90h@$`Yo*9yTfCT(*(*3280$;!9F%r;vqsgt~z_`xbr*c_whKvz29%HTR!JVG5E=u zHw$D?TROVC-PgSnDIwzTnffo(CG_P{E^8%8ak9Qz;d}p#{Q(%aMO9k7;&|vGgz^Vr zqe6T4ae@I;HoLw5P`7uRUp&nSXEji+4&8h2JoP%A5=eXQNm#CgCP=FvPt%ZDF4o7l zKZeacy|&F-#KnF4(2g>&;D%Mwzw*6R&+_+Am0Z5LZ$C3%S0T)J9>IvkPPwgaeQigF zEXA$8zq@t!yzHlZOOYg%`{kyY7S|XgG>znM62Bh5S**jh*VeRTZpd*X`}%bAqx;s} z=X#A_{+Dqv#{0jJMSgE578WAkK+>+iVkDk#AU)o$pSFBYce#QO?0jYnB{tY`rH+ED zBE`0+A(;7LPIbq0--mTXBxCdi8j?QVLXLm4ZJKgNclp`n*mpmOF+bS@u};Xaj%YR` zav@;In$(t=9Kt+PGs#t8pMSG!8s(GJ-Jx@gRfLjK01G!zU^rn5t2Uc|bS1|#ve(muMX^mh zr=IYQR*}T?xTgB;q?+`8C${=eB(rX1AN?TfL-wF6#(ZN1iFj+fW0c1JP76=YMl14m z)dFg)eJ=MXc90qu6>FY=ty*LumWVj~mc_xMY2RjfUc%QkGb7I5oj(<*1Cf68Ftmk^BljgP$4CmiSj?UaWhoRo>^=lqEkYTS$oA$&)x#G3AKbDpSUIif6t@ko= z^;UuI#sW6qMxumfx%6H@*V%u`CEYH}h9$Rhgr-{*#;<)JGc_75RE%XcMybPGXq}g{(j(<&i9{sq|zIb1Y;_v<8Eul6VKa?@itT>OdVNTf< z`)u2Yg6_q+Q!CIDRO;S4Mo6k_Y{;?TI zSjP&*F7_eYZ*f;Z9%=SI`E@EkGL@q%CK zV?=F+nT72Sv{ho|m=jo_Vo%>4wXb||sc|owEP-CF#JR8xo3_epT2r`8HJwS;?ZN9J zH`}b`k7pXe43Da-ym3#i6-;y}zAVk#d8^{>J|Ses!tM$R>0Y4T9$(tbU07-D{c4hi zX8G~U_QxL~r%hL7hOUwV{}Zg*R?n&Mlyv!dZgDD=VJZBi2wQNtV2LQCvnm89pP>dh zf3rKG{_CFk^G0m73&)oG=?50xTnY68n(T`Xhllk$tG>`XGkd^jsrfT33(=v|#%P#+ z@7T{>{~sUbqc42D&s3ceGH;=kK&>P>fH2Z95wPoU@u=AIJ? zO=Ys&2^7)!=XnC*nz>S4Qj#7JYIAvqNp*QYeS9Dt zW~$z>uuFoq${aYoC2)c#3$YArNtw8fnLpqjci@L?%KTbXSaU1mHY4PMol1>kYbn7w1pn}@&eNMKi0aWn4LZ$_x$qJMf-b|w^ z+{a*&0vFlej>KMHvS$TE(n5)8-nwZ?kEc4#J)MgW&h4`gR!Drpk5TRWH6c|N%8uX8 z{OvzZ!n)kg_+QOA?=xqGruV&%9H3y<4u37;K5yOb|IvVbyDN;l(;)E`#uAU0PWbM*lok z!IIuPf1KNW2UEHqAI7k2?|Ve=rubxGBdkW4o4Y<_&+nUTy#3GL9T)NawBFs*;g#)T z0YYRaY+4w!_eeaYBFNxoVgT zmO~7rFxy;q8NNQ4h5qtOtt8IMy#BTvtM_f;bDn1$gA?6D<=s=Lyjh)XU~K;E@8ntq zSY;`A*kY#`#bMSm9cpQ29it6kb+PP;#3{-ni4Y5~xTn6)HN$gZcUMI(TnbD|OMC9! z_6md6a42FMw&!;acB&xjkP?Bk17v5ww#wbM=JJdQs<*Y(4XkXx`CBjdw?|Hg?5_$m zUNFL{4xYPY67o0wfc=&-xE_DmxX54EJo@L1Bk~>FZJLLKw+oSpqS+n~2bm&)f`F$_ z0sJuHgf|x_>jM7C6cu6a7chI+4$byL`g`+)T=g&=0mxl@IR`cxEjR%xtJDOzjns}=3VC&Wk zNH!|%cLla2=j?p*pYXO8!1-f$!+QZpn2~gqOP&5DY4P~wZ^So74Qyw%{y$Tn8(xp7 z14?N*BdY+ODE(5K7T)3G2L|BuTz!L;j zgeiUr-k5!ko$8UH#z@-KoA>6gJ|BO0BJ*!&d!Hb2N(B0OEl!Hv?uP+MFjGk+PQQ1m z@^FdtAiowjXkodWqo~2PKeJ=QFmrvKdP*xZjU4QJyzSKY3)Ed)Y{z1)E}Tw=|DoKS zr_8sJ3US(xyyXebJ4QUp5cK2NV;5j6ftNY6VRc**QF%2H71kX}0}?|vLJl?^Tnv~h z=<$yJI+b6lfzloeZ>!JYg=d+dzAp@9>@SZ&sDdgq4iLb8d!zJzuKrvj+!i~TcFt@1 zq1uFUZ(HcAAcPEXD?yfci|p|Azl}xy<{z|>;{x0dkInfEz(2qniSh|S{o9Lx?yStK zx{uZ#(RdX1GqEDEgYxzy@;_aU4t9}}Zr27Q@Wg6G4$--I^(2oy?s9FlO2Hj29@V(X z$DFfwOD*khe~NW5d@}d{Sd|Cu12L=2cdQO?AiX`_$4Dain3;*}mz2fOICPY{B&cBM zDqOkebaUO>4%>bNq{9V7iuOf_70iKTV;G$tHV(=&;O_tu=rITbzLLJU0Kc+sx>0-c_IA#>1=;L9rV+Q*YhCU#hE9%&9Q2*R+_+9Qs8 zbuvA4M8V1{5|KDxest&hZ;qtc2sOX>x14A=6<5Ny<2Duc6}z#w7Us7l;6hu!!WNg> zck;PQY5_PtniLhSFxiDnd3Lqqlo!Bw&3%7_6DXDLTX%(N{Io5Z7LJ0}2XU@qU!jWu zjOLW@53&yAEZLQd5`0#nVbW1FHYo38Ph zKaPd}j60^yh1x#%=I%P*J^8$u+IijK8f|buE_l}54tn}6j|%Xa{u~w9g!ln}GW&ev zPT)Qne2e#vcdEY;I8LqF2 zZUxs482%c8b(+wOIe)IWXfeoYZhfwajK|2-P_AU8oDa7p>emn|d5{$3=HBnm$sq4B z-b1|pJZSHmCZNsLX#a$QaBR8vPYnI~7!99`l8a5$j;6cKC&+kod%u5_L?UbS(72t( zw)%m1WAY-&%_E%%xk5%vI>zBG=v&wQ6}%Ci3RaGRxVG=dvHW7LN4oI-x}dOTa|RmI zUf2Ffe-OX(Gn)1UtH90-{h3P3@7?F3%$+Md1LP8!>e%mCNZ9IsD|I^S!$5hB|4#-h2UBxiV|yEWCuavkR~5$V4rO`oj9e^_UGGZ%M5CsTm5t)aQ8yrH?Ju{9YdGZ!;A6Au|H5X8;| zsur%cM!dXWdt+By zQ#%)4UZqde82~E%=w$gH%zx$N<+U)iG`Da8fOuF@0Zt*G4DNr6^S>DlOA{B1{~(K1 zjdE=H@hIH8x@6HexeoNw73GeM${ni Fe*sk#dI10c diff --git a/docs/images/favicon.ico b/docs/images/favicon.ico deleted file mode 100644 index e0dff0fd1be6f8a9b152be59f9d7e2d0f17ae045..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmbW1+iMh89LJAEC|E4g2cP;N1;K~fr zdZmd`)w!@JT|RZ;9SJ$>U@%@z90;*US2)QXWIk z5*s-~JkUaHw3+bG_ayvhcr@9`bmAX$O+5a`ziFD7W(~twLDSOq+l=-fVkXgH$2FHGFrFQ!DF6OGivLgO;*_s>$T7zDgOFmz`xlaY(078AIgJ9seFZD(rFm&IqH zp)x5J78&mTiigv^RI1j#Sbm@+Ys^k|G3GmqA^Fux$<~y`=lraj;J|S-@v=DQ!||nJ zY`BFgwYsNOU-B%esrAgdSCg8I$33TMKd4xq_mg_!r|X1bI(&(Wq}6IQft6>)0*kX@ z`7)^rHx+EB^G8KyAw>GAkDKRY{ee$;H1Qj=(KeFf4wA8p0_m+d+R9AW!E~_A&WX5o z(<7SPLV)z*2(Dk(Gw{ngdL0V)pPO<2{yv_L4;lRH0|x)tM8EJiTHfONDMg=S4gHti z#&vl;xupQvr8vPGdlvxMMpbS9cP;`8mETA93$W6C<5X__~C5HsN=Eg8$l1 z{N20AKbs;ehz&L~^!GMyx4nz6^J7M@?_=C`jPR|)gapB!1B~7IhM4OVW4DhIxpjo- zz%laaq`iOfyR9Vdwlm>v$LIV^*4aa}ubDv4*8(}eeLsoz9C7z~67CCvR^pzY(d1jQ zYFa7lluJd~=M_1J&&kR+IzQpTdv!lv=Rt|R;&skGTUK7#5QxUw*O&i+H|<{lN0@go 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/pom.xml b/pom.xml index ede4d099c..35b941718 100644 --- a/pom.xml +++ b/pom.xml @@ -1,418 +1,418 @@ - - - - - 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 - 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.1 - 3.8.0 - 3.3.1 - 0.8.12 - 4.8.179 - 1.15 - 2.17.0 - 1.27.1 - 3.17.0 - 33.3.1-jre - 5.0.1 - 3.0 - 2.18.1 - 2.0.1.Final - 2.3.1 - 2.1.0 - 4.1.0 - 1.5.3 - 1.5.3 - 4.13.2 - 1.1.1 - 2.7.8 - 5.3.0 - 2.0.16 - 1.3.2 - 4.4.1 - 2.12.1 - 2.10.0 - 5.14.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.8.1 - - - - - - - - MavenCentral - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.7 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.7.0 - 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-dataformat-json - ${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 + + + 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.1 + 3.8.0 + 3.3.1 + 0.8.12 + 4.8.179 + 1.15 + 2.17.0 + 1.27.1 + 3.17.0 + 33.3.1-jre + 5.0.1 + 3.0 + 2.18.1 + 2.0.1.Final + 2.3.1 + 2.1.0 + 4.1.0 + 1.5.3 + 1.5.3 + 4.13.2 + 1.1.1 + 2.7.8 + 5.3.0 + 2.0.16 + 1.3.2 + 4.4.1 + 2.12.1 + 2.10.0 + 5.14.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.8.1 + + + + + + + + MavenCentral + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.7 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.7.0 + 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-dataformat-json + ${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 + + + From 243395dd3f64575b1f4b52c49ed63ebf81a88a29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:42:45 +0000 Subject: [PATCH 110/160] Bump commons-io:commons-io from 2.17.0 to 2.18.0 Bumps commons-io:commons-io from 2.17.0 to 2.18.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 35b941718..28deb0a20 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 0.8.12 4.8.179 1.15 - 2.17.0 + 2.18.0 1.27.1 3.17.0 33.3.1-jre From 482c764a2c6103ff1e2ee19e839612b3b27e12d9 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Thu, 21 Nov 2024 10:31:40 +0100 Subject: [PATCH 111/160] Updates to 1.0.3 Signed-off-by: Frank Schnicke --- README.md | 2 +- pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fd11e3b66..cbf5ebae9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Eclipse AAS4J -> :newspaper: The _`Eclipse AAS4J 1.0.2`_ release is available on [Maven Central Repository](https://oss.sonatype.org/#nexus-search;quick~org.eclipse.digitaltwin.aas4j) and includes the +> :newspaper: The _`Eclipse AAS4J 1.0.3`_ 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`. diff --git a/pom.xml b/pom.xml index 35b941718..574c21aa8 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 1 - 0-SNAPSHOT + 0 + 3 ${revision.major}.${revision.minor}.${revision.patch} - 1.1.0-SNAPSHOT + 1.0.3 UTF-8 UTF-8 From 3f7fb6f6976109eaeb579a14745dfb8ed02aeade Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:45:35 +0100 Subject: [PATCH 112/160] Updates version to 1.0.0-SNAPSHOT --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 574c21aa8..35b941718 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 0 - 3 + 1 + 0-SNAPSHOT ${revision.major}.${revision.minor}.${revision.patch} - 1.0.3 + 1.1.0-SNAPSHOT UTF-8 UTF-8 From 7ddc321db59ead5245633767317437c2fc557b30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:49:04 +0000 Subject: [PATCH 113/160] Bump com.networknt:json-schema-validator from 1.5.3 to 1.5.4 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.5.3 to 1.5.4. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.5.3...1.5.4) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 35b941718..60880c11a 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.3 - 1.5.3 + 1.5.4 4.13.2 1.1.1 2.7.8 From c23b1f2878f092f314369af5933d2ccd82230b7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:22:42 +0000 Subject: [PATCH 114/160] Bump jackson.version from 2.18.1 to 2.18.2 Bumps `jackson.version` from 2.18.1 to 2.18.2. Updates `com.fasterxml.jackson.core:jackson-databind` from 2.18.1 to 2.18.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-core` from 2.18.1 to 2.18.2 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.18.1...jackson-core-2.18.2) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.18.1 to 2.18.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.18.1 to 2.18.2 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.18.1...jackson-dataformat-xml-2.18.2) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 60880c11a..f40131a57 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 33.3.1-jre 5.0.1 3.0 - 2.18.1 + 2.18.2 2.0.1.Final 2.3.1 2.1.0 From dd48aa7154b38864da90e7c63587fdca168cc1a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:31:46 +0000 Subject: [PATCH 115/160] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.1 to 3.11.2 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.1 to 3.11.2. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.1...maven-javadoc-plugin-3.11.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- model/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/pom.xml b/model/pom.xml index 19b95c826..37fd2e703 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -21,7 +21,7 @@ 1.8 1.8 1.6.0 - 3.11.1 + 3.11.2 3.8.0 diff --git a/pom.xml b/pom.xml index 60880c11a..e6c34913b 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 1.6.0 3.0.1 3.4.2 - 3.11.1 + 3.11.2 3.8.0 3.3.1 0.8.12 From 27f20c7cf4d3aad452c44092709a604f60b599d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:28:35 +0000 Subject: [PATCH 116/160] Bump com.google.guava:guava from 33.3.1-jre to 33.4.0-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.3.1-jre to 33.4.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6c34913b..8f07f849b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 2.17.0 1.27.1 3.17.0 - 33.3.1-jre + 33.4.0-jre 5.0.1 3.0 2.18.1 From 064d70bb26fed131adc444ef9fea51fea5d0c52f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 10:28:11 +0000 Subject: [PATCH 117/160] Bump org.mockito:mockito-core from 5.14.2 to 5.15.2 Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.14.2 to 5.15.2. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.14.2...v5.15.2) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6c34913b..ad5a86ec5 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 4.4.1 2.12.1 2.10.0 - 5.14.2 + 5.15.2 0.0.20131108.vaadin1 From 46e45a9c288fbee68e62d07a6a858bc3af4c82de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 10:09:41 +0000 Subject: [PATCH 118/160] Bump org.apache.poi:poi-ooxml from 5.3.0 to 5.4.0 Bumps org.apache.poi:poi-ooxml from 5.3.0 to 5.4.0. --- updated-dependencies: - dependency-name: org.apache.poi:poi-ooxml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b85e430c..44e5d5ce8 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 4.13.2 1.1.1 2.7.8 - 5.3.0 + 5.4.0 2.0.16 1.3.2 4.4.1 From bd1110c24408fc0a4df52afa72dbc3edaa7f7b73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:33:53 +0000 Subject: [PATCH 119/160] Bump com.networknt:json-schema-validator from 1.5.4 to 1.5.5 Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.5.4 to 1.5.5. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.5.4...1.5.5) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44e5d5ce8..477d46aa7 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.1.0 4.1.0 1.5.3 - 1.5.4 + 1.5.5 4.13.2 1.1.1 2.7.8 From d407900ea514c8fa720d204a4ece60990107f3cc Mon Sep 17 00:00:00 2001 From: Aaron Zielstorff Date: Thu, 16 Jan 2025 13:28:51 +0100 Subject: [PATCH 120/160] Fixes wrong "." at end of ORIGIN_CONTENT string --- .../digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6f3727e02..48f1d5658 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 @@ -57,7 +57,7 @@ public class AASXSerializer { 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"; From 0f441cbf17fff345c80fdef9bf07701d3601852e Mon Sep 17 00:00:00 2001 From: Aaron Zielstorff Date: Thu, 16 Jan 2025 13:31:54 +0100 Subject: [PATCH 121/160] Updates AASX serializations targetMode to EXTERNAL (#358) * Updates AASX serializations targetMode to EXTERNAL * Adds missing "/" to AASXSerializerTest --- .../digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java | 2 +- .../v3/dataformat/aasx/serialization/AASXSerializerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 6f3727e02..0bc9a6694 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 @@ -251,7 +251,7 @@ 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; } 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 b5f86d6ce..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 @@ -163,6 +163,6 @@ private static void assertThumbnailReference(ZipEntry zipEntry, ZipInputStream i throw new RuntimeException(e); } assertTrue(content.contains("Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail\"")); - assertTrue(content.contains("Target=\"master/verwaltungsschale-detail-part1.png\"")); + assertTrue(content.contains("Target=\"/master/verwaltungsschale-detail-part1.png\"")); } } From 000cf08e9902d6df05db0e3af9289713808430b7 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Tue, 21 Jan 2025 13:44:20 +0100 Subject: [PATCH 122/160] Updates to 1.0.4 Signed-off-by: Frank Schnicke --- README.md | 2 +- pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cbf5ebae9..7b3faf906 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Eclipse AAS4J -> :newspaper: The _`Eclipse AAS4J 1.0.3`_ release is available on [Maven Central Repository](https://oss.sonatype.org/#nexus-search;quick~org.eclipse.digitaltwin.aas4j) 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`. diff --git a/pom.xml b/pom.xml index 44e5d5ce8..d65b1f1c6 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 1 - 0-SNAPSHOT + 0 + 4 ${revision.major}.${revision.minor}.${revision.patch} - 1.1.0-SNAPSHOT + 1.0.4 UTF-8 UTF-8 From 6c6e7c5605a21934bc1edc4f5ef893aa292b25bd Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Tue, 21 Jan 2025 13:57:34 +0100 Subject: [PATCH 123/160] Updates version to 1.1.0-SNAPSHOT Signed-off-by: Frank Schnicke --- README.md | 2 +- pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7b3faf906..0bec109af 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ or by integrating the respective modules as dependencies from [Maven Central](ht org.eclipse.digitaltwin.aas4j aas4j-model - 1.0.2 + 1.0.4 ``` diff --git a/pom.xml b/pom.xml index d65b1f1c6..44e5d5ce8 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ 1 - 0 - 4 + 1 + 0-SNAPSHOT ${revision.major}.${revision.minor}.${revision.patch} - 1.0.4 + 1.1.0-SNAPSHOT UTF-8 UTF-8 From 53af58818d750420bffc4efe3b045f8d900ca581 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 30 Jan 2025 12:53:57 +0100 Subject: [PATCH 124/160] Migrate to Apache Jena 5.3.0 --- .../DefaultAdministrativeInformationRDFHandler.java | 8 ++++---- .../rdf/handlers/DefaultExtensionRDFHandler.java | 4 ++-- .../handlers/DefaultLangStringNameTypeRDFHandler.java | 4 ++-- .../handlers/DefaultLangStringTextTypeRDFHandler.java | 4 ++-- ...efaultLangStringDefinitionTypeIec61360RDFHandler.java | 4 ++-- ...ultLangStringPreferredNameTypeIec61360RDFHandler.java | 4 ++-- ...DefaultLangStringShortNameTypeIec61360RDFHandler.java | 9 +++------ pom.xml | 2 +- 8 files changed, 18 insertions(+), 21 deletions(-) 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 index ac7333c40..dc2a43b53 100644 --- 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 @@ -21,17 +21,17 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.AdministrativeInformation); if (object.getVersion() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, object.getVersion()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, model.createTypedLiteral(object.getVersion())); } if (object.getRevision() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, object.getRevision()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, model.createTypedLiteral(object.getRevision())); } if (object.getTemplateId() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, object.getTemplateId()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, model.createTypedLiteral(object.getTemplateId())); } if (object.getCreator() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); - model.addLiteral(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); + model.add(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); model.add(res.getModel()); } //HasDataSpecification 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 index 4a8eab390..c48f84a3d 100644 --- 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 @@ -23,10 +23,10 @@ public RDFSerializationResult toModel(Extension object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.Extension); if (object.getName() != null) { - model.addLiteral(subject, AASNamespace.Extension.name, object.getName()); + model.addLiteral(subject, AASNamespace.Extension.name, model.createTypedLiteral(object.getName())); } if (object.getValue() != null) { - model.addLiteral(subject, AASNamespace.Extension.value, object.getValue()); + model.addLiteral(subject, AASNamespace.Extension.value, model.createTypedLiteral(object.getValue())); } if (object.getValueType() != null) { model.add(subject, AASNamespace.Extension.valueType, 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 index d65cd543a..f1b841edc 100644 --- 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 @@ -20,10 +20,10 @@ public RDFSerializationResult toModel(LangStringNameType object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringNameType); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 88e20bb35..ea847cc72 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringTextType object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringTextType); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 10c1599e9..a9f9b91b2 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringDefinitionTypeIec61360 object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringDefinitionTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 449941f3f..8748566ba 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringPreferredNameTypeIec61360 object Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringPreferredNameTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index c70cbba54..17e6a8656 100644 --- 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 @@ -1,9 +1,6 @@ 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.rdf.model.*; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringShortNameTypeIec61360; @@ -19,10 +16,10 @@ public RDFSerializationResult toModel(LangStringShortNameTypeIec61360 object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } diff --git a/pom.xml b/pom.xml index bea45507e..c4f13ea8c 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 2.0.1.Final 2.3.1 2.1.0 - 4.10.0 + 5.3.0 1.5.1 1.3.1 4.13.2 From df5a6b71c95cefabc72c793aa01557dab2981416 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 16:59:13 +0100 Subject: [PATCH 125/160] Revert old rdf module --- dataformat-rdf/pom.xml | 45 + .../v3/dataformat/rdf/FallbackSerializer.java | 42 + .../v3/dataformat/rdf/IgnoreTypeMixIn.java | 22 + .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 52 + .../v3/dataformat/rdf/JsonLDSerializer.java | 196 +++ .../rdf/JsonLDSerializerModifier.java | 44 + .../dataformat/rdf/JsonLdEnumSerializer.java | 88 ++ .../dataformat/rdf/LangStringSerializer.java | 53 + .../aas4j/v3/dataformat/rdf/Parser.java | 1170 +++++++++++++++++ .../aas4j/v3/dataformat/rdf/Serializer.java | 308 +++++ .../v3/dataformat/rdf/UriSerializer.java | 53 + .../rdf/custom/BigDecimalSerializer.java | 42 + .../rdf/custom/JsonLdEnumMixin.java | 23 + .../rdf/custom/LangStringMixin.java | 35 + .../rdf/custom/ReflectiveMixInResolver.java | 41 + .../XMLGregorianCalendarDeserializer.java | 49 + .../XMLGregorianCalendarSerializer.java | 47 + .../AdministrativeInformationMixin.java | 38 + .../AnnotatedRelationshipElementMixin.java | 33 + .../mixins/AssetAdministrationShellMixin.java | 47 + .../rdf/mixins/AssetInformationMixin.java | 60 + .../rdf/mixins/BasicEventElementMixin.java | 79 ++ .../v3/dataformat/rdf/mixins/BlobMixin.java | 38 + .../rdf/mixins/CapabilityMixin.java | 27 + .../rdf/mixins/ConceptDescriptionMixin.java | 33 + .../rdf/mixins/DataElementMixin.java | 37 + .../mixins/DataSpecificationContentMixin.java | 33 + .../DataSpecificationIEC61360Mixin.java | 106 ++ .../DataSpecificationPhysicalUnitMixin.java | 99 ++ .../EmbeddedDataSpecificationMixin.java | 44 + .../v3/dataformat/rdf/mixins/EntityMixin.java | 54 + .../rdf/mixins/EnvironmentMixin.java | 47 + .../rdf/mixins/EventElementMixin.java | 33 + .../rdf/mixins/EventMessageMixin.java | 27 + .../dataformat/rdf/mixins/ExtensionMixin.java | 50 + .../v3/dataformat/rdf/mixins/FileMixin.java | 38 + .../dataformat/rdf/mixins/FormulaMixin.java | 33 + .../rdf/mixins/HasDataSpecificationMixin.java | 49 + .../rdf/mixins/HasExtensionsMixin.java | 33 + .../dataformat/rdf/mixins/HasKindMixin.java | 39 + .../rdf/mixins/HasSemanticsMixin.java | 49 + .../rdf/mixins/IdentifiableMixin.java | 47 + .../mixins/IdentifierKeyValuePairMixin.java | 44 + .../rdf/mixins/IdentifierMixin.java | 31 + .../v3/dataformat/rdf/mixins/KeyMixin.java | 39 + .../mixins/MultiLanguagePropertyMixin.java | 40 + .../rdf/mixins/ObjectAttributesMixin.java | 33 + .../dataformat/rdf/mixins/OperationMixin.java | 45 + .../rdf/mixins/OperationVariableMixin.java | 32 + .../rdf/mixins/PolicyDecisionPointMixin.java | 32 + .../mixins/PolicyEnforcementPointsMixin.java | 32 + .../mixins/PolicyInformationPointsMixin.java | 39 + .../dataformat/rdf/mixins/PropertyMixin.java | 44 + .../rdf/mixins/QualifiableMixin.java | 40 + .../dataformat/rdf/mixins/QualifierMixin.java | 50 + .../v3/dataformat/rdf/mixins/RangeMixin.java | 44 + .../dataformat/rdf/mixins/ReferableMixin.java | 58 + .../rdf/mixins/ReferenceElementMixin.java | 32 + .../dataformat/rdf/mixins/ReferenceMixin.java | 41 + .../rdf/mixins/RelationshipElementMixin.java | 43 + .../dataformat/rdf/mixins/ResourceMixin.java | 40 + .../rdf/mixins/SpecificAssetIdMixin.java | 47 + .../rdf/mixins/SubjectAttributesMixin.java | 33 + .../SubmodelElementCollectionMixin.java | 45 + .../rdf/mixins/SubmodelElementListMixin.java | 61 + .../rdf/mixins/SubmodelElementMixin.java | 40 + .../dataformat/rdf/mixins/SubmodelMixin.java | 33 + .../dataformat/rdf/mixins/ValueListMixin.java | 36 + .../rdf/mixins/ValueReferencePairMixin.java | 38 + .../v3/dataformat/rdf/mixins/ViewMixin.java | 33 + .../rdf/preprocessing/BasePreprocessor.java | 53 + .../rdf/preprocessing/JsonPreprocessor.java | 42 + .../preprocessing/TypeNamePreprocessor.java | 194 +++ .../aas4j/v3/dataformat/rdf/ParserTest.java | 153 +++ .../v3/dataformat/rdf/SerializerTest.java | 100 ++ .../v3/dataformat/rdf/SerializerUtil.java | 45 + dataformat-rdf/src/test/resources/AASFull.ttl | 354 +++++ .../resources/AAS_Reference_shortExample.nt | 16 + .../resources/AAS_Reference_shortExample.ttl | 27 + .../AssetAdministrationShell_Example.ttl | 56 + .../src/test/resources/Complete_Example.ttl | 347 +++++ .../src/test/resources/Overall-Example.nt | 253 ++++ .../src/test/resources/ReferenceExample.ttl | 18 + .../Submodel_SubmodelElement_Example.ttl | 137 ++ .../Submodel_SubmodelElement_shortExample.nt | 25 + .../Submodel_SubmodelElement_shortExample.ttl | 42 + .../resources/example-from-serializer.jsonld | 88 ++ 87 files changed, 6558 insertions(+) create mode 100644 dataformat-rdf/pom.xml create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java create mode 100644 dataformat-rdf/src/test/resources/AASFull.ttl create mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt create mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl create mode 100644 dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Complete_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Overall-Example.nt create mode 100644 dataformat-rdf/src/test/resources/ReferenceExample.ttl create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt create mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl create mode 100644 dataformat-rdf/src/test/resources/example-from-serializer.jsonld diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml new file mode 100644 index 000000000..8d65df6de --- /dev/null +++ b/dataformat-rdf/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + org.eclipse.digitaltwin.aas4j + dataformat-parent + ${revision} + + dataformat-rdf + Asset Administration Shell RDF-Serializer + + + + ${groupId} + dataformat-core + ${revision} + + + ${groupId} + dataformat-core + ${revision} + tests + test + + + org.apache.jena + jena-arq + ${jena.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + pl.pragmatists + JUnitParams + ${junit-params.version} + test + + + diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java new file mode 100644 index 000000000..1522e476d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java @@ -0,0 +1,42 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import java.io.IOException; +import java.util.Map; + +public class FallbackSerializer extends StdSerializer> { + + + public FallbackSerializer() { + this(null); + } + + public FallbackSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(Map value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeString(value.toString()); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java new file mode 100644 index 000000000..816c77d39 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java @@ -0,0 +1,22 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonIgnoreType; + +@JsonIgnoreType +public class IgnoreTypeMixIn { +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java new file mode 100644 index 000000000..b5a790d60 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java @@ -0,0 +1,52 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +import java.math.BigDecimal; +import java.net.URI; +import java.util.Map; + + +import javax.xml.datatype.XMLGregorianCalendar; + + +/** + * Jackson module which provides support for JSON-LD serialization + */ +public class JsonLDModule extends SimpleModule { + + + public JsonLDModule(Map idMap) { + super(); + + setSerializerModifier(new JsonLDSerializerModifier(idMap)); + + addSerializer(XMLGregorianCalendar.class, new XMLGregorianCalendarSerializer()); + addDeserializer(XMLGregorianCalendar.class, new XMLGregorianCalendarDeserializer()); + addSerializer(BigDecimal.class, new BigDecimalSerializer()); + + addSerializer(URI.class, new UriSerializer()); + addSerializer(LangString.class, new LangStringSerializer()); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java new file mode 100644 index 000000000..853fe1847 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java @@ -0,0 +1,196 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.WritableTypeId; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import com.fasterxml.jackson.databind.ser.BeanSerializer; +import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.math.BigInteger; +import java.util.*; +import java.util.stream.Stream; + + +public class JsonLDSerializer extends BeanSerializer { + + private final Logger logger = LoggerFactory.getLogger(JsonLDSerializer.class); + + private static int currentRecursionDepth = 0; + + static final Map contextItems = new HashMap<>(); + + private final Map idMap; + + JsonLDSerializer(BeanSerializerBase src, Map idMap) { + super(src); + this.idMap = Objects.requireNonNullElseGet(idMap, HashMap::new); + } + + + + @Override + public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { + gen.setCurrentValue(bean); + + currentRecursionDepth++; + gen.writeStartObject(); + + if (currentRecursionDepth == 1) { + Map filteredContext = new HashMap<>(); + filterContextWrtBean(bean, filteredContext); + gen.writeObjectField("@context", filteredContext); + //gen.writeStringField("@context", "https://jira.iais.fraunhofer.de/stash/projects/ICTSL/repos/ids-infomodel-commons/raw/jsonld-context/3.0.0/context.jsonld"); // only add @context on top level + + } + + if(idMap.containsKey(bean)) + { + gen.writeStringField("@id", idMap.get(bean)); + } + else + { + String randomUri = "https://admin-shell.io/autogen/" + bean.getClass().getSimpleName() + "/" + UUID.randomUUID(); + idMap.put(bean, randomUri); + gen.writeStringField("@id", randomUri); + } + + WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_OBJECT); + String resolvedTypeId = typeIdDef.id != null ? typeIdDef.id.toString() : typeSer.getTypeIdResolver().idFromValue(bean); + if (resolvedTypeId != null) { + gen.writeStringField(typeIdDef.asProperty, resolvedTypeId); + } + if (_propertyFilterId != null) { + serializeFieldsFiltered(bean, gen, provider); + } else { + serializeFields(bean, gen, provider); + } + gen.writeEndObject(); + currentRecursionDepth--; + } + + + private void filterContextWrtBean(Object bean, Map filteredContext) { + //Some default entries for AAS + filteredContext.put("aas", "https://admin-shell.io/aas/3/0/RC02/"); + //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); + + if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion + + //Check if RdfResource or TypedLiteral is used. They contain a field called "type" which can reference to any namespace + //Therefore it is vital to also check the value of the type field for prefixes that need to be included in the context + if(bean.getClass().getSimpleName().equals("LangString")) + { + //LangString is of type rdf:langString, so this must be present + filteredContext.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + } + contextItems.forEach((p, u) -> { + JsonTypeName typeNameAnnotation = bean.getClass().getAnnotation(JsonTypeName.class); + if(typeNameAnnotation != null && typeNameAnnotation.value().contains(p)) { + filteredContext.put(p, u); + } + Stream.of(bean.getClass().getMethods()).forEach(m -> { + JsonProperty propertyAnnotation = m.getAnnotation(JsonProperty.class); + if(propertyAnnotation != null && propertyAnnotation.value().contains(p)) { + filteredContext.put(p, u); + } + }); + }); + Stream.of(bean.getClass().getMethods()).forEach(m -> { + // run though all properties and check annotations. These annotations should contain the prefixes + JsonProperty prop = m.getAnnotation(JsonProperty.class); + if(prop != null) + { + for(Map.Entry entry : contextItems.entrySet()) + { + if(prop.value().startsWith(entry.getKey())) + { + filteredContext.put(entry.getKey(), entry.getValue()); + break; + } + } + } + }); + // run through fields recursively + for(Field f : getAllFields(new HashSet<>(), bean.getClass())) { + + if(Collection.class.isAssignableFrom(f.getType())) + { + try { + if(f.getType().getName().startsWith("java.") && !f.getType().getName().startsWith("java.util")) continue; + boolean accessible = f.isAccessible(); + f.setAccessible(true); + Collection c = (Collection) f.get(bean); + if(c == null) { + continue; + } + for(Object o : c) + { + filterContextWrtBean(o, filteredContext); + } + f.setAccessible(accessible); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (f.getType().isPrimitive() || f.getType().isEnum() || f.getType().isArray() + || f.getType().getName().contains("java.") + || f.getType().getName().contains("javax.")) continue; + + try { + boolean wasAccessible = f.isAccessible(); + f.setAccessible(true); + filterContextWrtBean(f.get(bean), filteredContext); + f.setAccessible(wasAccessible); + } catch (IllegalAccessException ignored) { + //logger.error("setting accessible failed"); //We can catch that here, as IllegalReflectiveAccess cannot occur on our own packages + } + + //f.trySetAccessible(wasAccessible); + + } + + } + + /** + * This function retrieves a set of all available fields of a class, including inherited fields + * @param fields Set to which discovered fields will be added. An empty HashSet should do the trick + * @param type The class for which fields should be discovered + * @return set of all available fields + */ + private static Set getAllFields(Set fields, Class type) { + fields.addAll(Arrays.asList(type.getDeclaredFields())); + + if (type.getSuperclass() != null) { + getAllFields(fields, type.getSuperclass()); + } + + return fields; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java new file mode 100644 index 000000000..d1bff7f5c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java @@ -0,0 +1,44 @@ +/* + * 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.rdf; + + +import com.fasterxml.jackson.databind.BeanDescription; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; +import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; + +import java.util.Map; + + +public class JsonLDSerializerModifier extends BeanSerializerModifier { + + private final Map idMap; + + public JsonLDSerializerModifier(Map idMap) { + this.idMap = idMap; + } + + @Override + public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer serializer) { + if (serializer instanceof BeanSerializerBase) { + return new JsonLDSerializer((BeanSerializerBase) serializer, idMap); + } else { + return serializer; + } + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java new file mode 100644 index 000000000..8d544ab14 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java @@ -0,0 +1,88 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.io.IOException; + +public class JsonLdEnumSerializer extends JsonSerializer> { + + + @Override + public void serialize(Enum value, JsonGenerator gen, SerializerProvider provider) throws IOException { + //Generated Enum classes of the admin shell have @IRI annotations, which need to be used to provide proper RDF + if(value.getClass().isEnum() && value.getClass().getName().startsWith("org.eclipse.digitaltwin.aas4j.")) + { + //Try to get annotation value to get the IRI used in the ontology + if(value.getClass().getAnnotation(IRI.class) != null && value.getClass().getAnnotation(IRI.class).value().length > 0) + { + gen.writeStartObject(); + gen.writeStringField("@type", value.getClass().getAnnotation(IRI.class).value()[0]); + + //Try to extract exact IRI of the enum value, if present + try { + var annotation = value.getClass().getField(value.name()).getAnnotation(IRI.class); + if(annotation != null && annotation.value().length > 0) + { + gen.writeStringField("@id", annotation.value()[0]); + } + else + { + //Didn't find an @IRI annotation - fall back to using class annotation + field name + gen.writeStringField("@id", translate(value.getClass(), value.name())); + } + } + //Should be impossible + catch (NoSuchFieldException e) + { + //Didn't find an @IRI annotation - fall back to using class annotation + field name + gen.writeStringField("@id", translate(value.getClass(), value.name())); + } + gen.writeEndObject(); + } + else + { + gen.writeString(translate(value.getClass(), value.name())); + } + + + } else { + provider.findValueSerializer(Enum.class).serialize(value, gen, provider); + } + } + + + + public static String translate(Class enumClass, String input) { + String[] iriValues = enumClass.getAnnotation(IRI.class).value(); + String result = ""; + if(iriValues.length > 0) + { + result = iriValues[0]; + if(!result.endsWith("/")) + { + result += "/"; + } + } + result += input; + return result; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java new file mode 100644 index 000000000..e90100562 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java @@ -0,0 +1,53 @@ +/* + * 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.rdf; + +import java.io.IOException; + + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +public class LangStringSerializer extends StdSerializer { + + + public LangStringSerializer() { + this(null); + } + + public LangStringSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(LangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeStartObject(); + if(value.getLanguage() != null && !value.getLanguage().isEmpty()) + { + gen.writeStringField("@language", value.getLanguage()); + } + else + { + gen.writeStringField("@type", "rdf:langString"); + } + gen.writeStringField("@value", value.getText()); + gen.writeEndObject(); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java new file mode 100644 index 000000000..c995160e5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java @@ -0,0 +1,1170 @@ +/* + * 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.rdf; + +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangString; +import org.apache.jena.datatypes.DatatypeFormatException; +import org.apache.jena.query.*; +import org.apache.jena.rdf.model.*; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; +import org.apache.jena.riot.RDFLanguages; +import org.apache.jena.riot.RiotException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.lang.reflect.*; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.ZonedDateTime; +import java.time.format.DateTimeParseException; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * Internal class to handle the parsing of JSON-LD into java objects + * @author maboeckmann + */ +class Parser { + + private final Logger logger = LoggerFactory.getLogger(Parser.class); + + private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); + + static Map knownNamespaces = new HashMap<>(); + + /** + * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle + * @param inputModel Model on which queries are to be evaluated from which information can be retrieved + * @param objectUri URI of the object to be handled + * @param targetClass Variable containing the class which should be returned + * @param Class which should be returned + * @return Object of desired class, filled with the values extracted from inputModel + * @throws IOException thrown if the parsing fails + */ + private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { + try { + + //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on + //Check whether we are dealing with an instantiable class (i.e. no interface and no abstract class) + boolean currentObjectIsBlankNode = false; + if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { + //We don't know the desired class yet (current targetClass is not instantiable). This is only known for the root object + ArrayList> implementingClasses = getImplementingClasses(targetClass); + String queryString; + //Get a list of all "rdf:type" statements in our model + //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax + try { + new URL(objectUri); + } + catch (MalformedURLException e) + { + currentObjectIsBlankNode = true; + } + if(currentObjectIsBlankNode) + { + //Object is a blank node, so the subject URI cannot be used + queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; + } + else + { + //Not a blank node, so we can work with the subject URI + queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; + } + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); + ResultSet resultSet = queryExecution.execSelect(); + + if (!resultSet.hasNext()) { + queryExecution.close(); + throw new IOException("Could not extract class of child object. ID: " + objectUri); + } + + //Class candidateClass = null; + + String fullName = "No triple present indicating type."; + while (resultSet.hasNext()) { + QuerySolution solution = resultSet.nextSolution(); + fullName = solution.get("type").toString(); + + //Expected URI is something like https://w3id.org/idsa/core/ClassName (and we want ClassName) + String className = fullName.substring(fullName.lastIndexOf('/') + 1); + + //Some namespaces use "#" instead of "/" + if (className.contains("#")) { + className = className.substring(className.lastIndexOf("#") + 1); + } + + for (Class currentClass : implementingClasses) { + //Is this class instantiable? + if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { + //candidateClass = currentClass; + if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + targetClass = (Class) currentClass; + break; + } + } + } + } + queryExecution.close(); + //Did we find "the" class, i.e. instantiable and name matches? + if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { + //No, the current targetClass cannot be instantiated. Do we have a candidate class? + //if (candidateClass != null) { + throw new IOException("Did not find an instantiable class for " + objectUri + " matching expected class name (" + targetClass.getSimpleName() + "). Object has type: " + fullName); + //targetClass = (Class) candidateClass; + //} + } + } + + //Enums have no constructors + if(targetClass.isEnum()) + { + return handleEnum(targetClass, objectUri); + } + + //Get constructor (which is package private for our classes) and make it accessible + Constructor constructor = targetClass.getDeclaredConstructor(); + constructor.setAccessible(true); + + //Instantiate new object, which will be returned at the end + T returnObject = constructor.newInstance(); + + //Get methods + Method[] methods = returnObject.getClass().getDeclaredMethods(); + + //Store methods in map. Key is the name of the RDF property without ids prefix + Map methodMap = new HashMap<>(); + + //Get all relevant methods (setters, but not for label, comment or external properties) + Arrays.stream(methods).filter(method -> { + String name = method.getName(); + //Filter out irrelevant methods + return name.startsWith("set") && !name.equals("setProperty") && !name.equals("setComment") && !name.equals("setLabel"); // && !name.equals("setId"); + }).forEach(method -> { + //Remove "set" part + String reducedName = method.getName().substring(3); + + //Turn first character to lower case + char[] c = reducedName.toCharArray(); + c[0] = Character.toLowerCase(c[0]); + String finalName = new String(c); + methodMap.put(finalName, method); + + }); + + //There is no "setId" method in our CodeGen generated classes, so we get the field + /* TODO: No "id" field yet + Field idField = returnObject.getClass().getDeclaredField("id"); + + //Store whether or not it was accessible, so that we can undo making it accessible + boolean wasAccessible = idField.isAccessible(); + idField.setAccessible(true); + + //Set the ID of the object to be identical with the objectUri parameter + idField.set(returnObject, new URI(objectUri)); + idField.setAccessible(wasAccessible); + */ + + //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal + if(methodMap.isEmpty()) + { + return returnObject; + } + + + //A list which stores all those parameter names which may occur only once (i.e. those occurring in the GROUP BY clause) + List groupByKeys = new ArrayList<>(); + + StringBuilder queryStringBuilder = new StringBuilder(); + + for(Map.Entry entry : knownNamespaces.entrySet()) + { + queryStringBuilder.append("PREFIX ").append(entry.getKey()); + if(!entry.getKey().endsWith(":")) + { + queryStringBuilder.append(":"); + } + queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); + } + queryStringBuilder.append("SELECT"); + methodMap.forEach((key1, value) -> { + //Is the return type some sort of List? + if (Collection.class.isAssignableFrom(value.getParameterTypes()[0])) { + boolean isTypedLiteral = false; + //Yes, it is assignable multiple times. Concatenate multiple values together using some delimiter + try { + //ArrayLists are generics. We need to extract the name of the generic parameter as string and interpret that + String typeName = extractTypeNameFromCollection(value.getGenericParameterTypes()[0]); + + if (typeName.endsWith("LangString")) + isTypedLiteral = true; + } catch (IOException e) { + e.printStackTrace(); + } + if (isTypedLiteral) { + queryStringBuilder.append(" (GROUP_CONCAT(CONCAT('\"',?").append(key1).append(",'\"@', lang(?").append(key1).append("));separator=\"||\") AS ?").append(key1).append("sLang) "); + } + queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append(";separator=\"||\") AS ?").append(key1).append("s) "); + + //Additional case for blank nodes + queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append("Blank;separator=\"||\") AS ?").append(key1).append("sBlank) "); + + + } else { + //No, it's not a list. No need to aggregate + queryStringBuilder.append(" ?").append(key1); + //We will have to GROUP BY this variable though... + groupByKeys.add(key1); + } + }); + //Start the "WHERE" part - Fuseki does not expect the "WHERE" keyword, but just an "{" + queryStringBuilder.append(" { "); + + //In case of blank nodes, we can't work with the subject URI + if(currentObjectIsBlankNode) + { + queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); + } + else + { + queryStringBuilder.append(" <").append(objectUri).append(">"); + } + + //Make sure that the object is of the correct type + //This is particularly relevant in case of all fields being optional -- then one could simply parse a random object + queryStringBuilder.append(" a ").append(wrapIfUri(targetClass.getAnnotation(IRI.class).value()[0])).append(". "); + + for (Map.Entry entry : methodMap.entrySet()) { + //Is this a field which is annotated by NOT NULL? + //Attempt to find a field matching the setter method name + //E.g. for "setSomething", we search for a field with name "_something" (IDS way) and "something" + Field field = getFieldByName(targetClass, entry.getKey()); + + + //In AAS, every field is optional, as there are no validation annotations in the model + queryStringBuilder.append(" OPTIONAL {"); + + if(currentObjectIsBlankNode) + { + queryStringBuilder.append(" ?s "); + } + else { + queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function + } + //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) + //Find the annotation value containing a colon and interpret this as "prefix:predicate" + boolean foundAnnotation = false; + if(field.getAnnotation(IRI.class) != null) { + Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); + currentAnnotation.ifPresent(queryStringBuilder::append); + foundAnnotation = true; + } + if(!foundAnnotation) + { + logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); + queryStringBuilder.append("aas:").append(entry.getKey()); + } + //if(isBlank(?entry.getKey(), use value of artificial, use original value) + queryStringBuilder.append(" ?").append(entry.getKey()).append(" ."); //object + + //In case of the object being a blank node, we construct a second result variable with the blank node id + queryStringBuilder.append("OPTIONAL { ?").append(entry.getKey()).append(" <").append(blankNodeIdPropertyUri).append("> ?").append(entry.getKey()).append("Blank . } "); + + queryStringBuilder.append("} "); + } + + + queryStringBuilder.append(" } "); + + //Do we need to group? We do, if there is at least one property which can occur multiple times + //We added all those properties, which may only occur once, to the groupByKeys list + if (!groupByKeys.isEmpty()) { + queryStringBuilder.append("GROUP BY"); + for (String key : groupByKeys) { + queryStringBuilder.append(" ?").append(key); + } + } + + String queryString = queryStringBuilder.toString(); + + StringBuilder queryForOtherProperties = new StringBuilder(); + //Query for all unknown properties and their values + //Select properties and values only + + if(!targetClass.equals(LangString.class)) { //LangString has no additional properties map. Skip this step + + //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } + for (Map.Entry entry : knownNamespaces.entrySet()) { + queryForOtherProperties.append("PREFIX ").append(entry.getKey()); + if (!entry.getKey().endsWith(":")) { + queryForOtherProperties.append(":"); + } + queryForOtherProperties.append(" <").append(entry.getValue()).append(">\n"); + } + + + //Respect ALL properties and values + queryForOtherProperties.append(" SELECT ?p ?o { <").append(objectUri).append("> ?p ?o .\n"); + + //Exclude known properties + queryForOtherProperties.append("FILTER (?p NOT IN (rdf:type"); + + //Predicates usually look like: .append("ids:").append(entry.getKey()) + for (Map.Entry entry : methodMap.entrySet()) { + queryForOtherProperties.append(", "); + + Field field = getFieldByName(targetClass, entry.getKey()); + Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).filter(annotation -> annotation.contains(":")).filter(s -> s.length() > 1).findFirst(); + if (currentAnnotation.isPresent()) { + queryForOtherProperties.append(wrapIfUri(currentAnnotation.get())); + } else { + logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); + queryForOtherProperties.append("aas:").append(entry.getKey()); + } + } + + queryForOtherProperties.append(")). } "); + + + //Now that we searched for all "known properties", let's search for all unrecognized content and append it to a generic properties map + + Query externalPropertiesQuery = QueryFactory.create(queryForOtherProperties.toString()); + QueryExecution externalPropertiesQueryExecution = QueryExecutionFactory.create(externalPropertiesQuery, inputModel); + ResultSet externalPropertiesResultSet = externalPropertiesQueryExecution.execSelect(); + + // now as all declared instances and classes are treated, which are also represented in the respective java + // dependency, take care about the ones within foreign namespaces and add those to the 'properties' field + // note that not all models (e.g. AAS) have such methods. In case they do not exist, skip adding external properties + + try { + Method setProperty = returnObject.getClass().getDeclaredMethod("setProperty", String.class, Object.class); + Method getProperties = returnObject.getClass().getDeclaredMethod("getProperties"); + + while (externalPropertiesResultSet.hasNext()) { + QuerySolution externalPropertySolution = externalPropertiesResultSet.next(); + + HashMap currentProperties = (HashMap) getProperties.invoke(returnObject); + + //Avoid NullPointerException + if (currentProperties == null) { + currentProperties = new HashMap<>(); + } + + String propertyUri = externalPropertySolution.get("p").toString(); + + //Does this key already exist? If yes, we need to store the value as array to not override them + if (currentProperties.containsKey(propertyUri)) { + //If it is not an array list yet, turn it into one + if (!(currentProperties.get(propertyUri) instanceof ArrayList)) { + ArrayList newList = new ArrayList<>(); + newList.add(currentProperties.get(propertyUri)); + currentProperties.put(propertyUri, newList); + } + } + + //Literals and complex objects need to be handled differently + //Literals can be treated as flat values, whereas complex objects require recursive calls + if (externalPropertySolution.get("o").isLiteral()) { + Object o = handleForeignLiteral(externalPropertySolution.getLiteral("o")); + //If it is already an ArrayList, add new value to it + if (currentProperties.containsKey(propertyUri)) { + ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); + currentPropertyArray.add(o); + setProperty.invoke(returnObject, propertyUri, currentPropertyArray); + } + //Otherwise save as new plain value + else { + setProperty.invoke(returnObject, propertyUri, o); + } + } else { + //It is a complex object. Distinguish whether or not we need to store as array + HashMap subMap = handleForeignNode(externalPropertySolution.getResource("o"), new HashMap<>(), inputModel); + subMap.put("@id", externalPropertySolution.getResource("o").getURI()); + if (currentProperties.containsKey(propertyUri)) { + ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); + currentPropertyArray.add(subMap); + setProperty.invoke(returnObject, propertyUri, currentPropertyArray); + } else { + setProperty.invoke(returnObject, propertyUri, subMap); + } + } + } + externalPropertiesQueryExecution.close(); + } + catch (NoSuchMethodException ignored) + { + //Method does not exist, skip + } + } + + + + Query query; + try { + query = QueryFactory.create(queryString); + } + catch (QueryParseException e) + { + logger.error(queryString); + throw e; + } + + //Evaluate query + QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); + ResultSet resultSet = queryExecution.execSelect(); + + + if (!resultSet.hasNext()) { + queryExecution.close(); + //no content... + return returnObject; + } + + //SPARQL binding present, iterate over result and construct return object + while (resultSet.hasNext()) { + QuerySolution querySolution = resultSet.next(); + + //Check if there are fields which have more values than allowed + if (resultSet.hasNext()) { + String value1 = "", value2 = "", parameterName = ""; + QuerySolution querySolution2 = resultSet.next(); + Iterator varNamesIt = querySolution2.varNames(); + while(varNamesIt.hasNext()) + { + String varName = varNamesIt.next(); + if(querySolution.contains(varName)) + { + if(!querySolution.get(varName).equals(querySolution2.get(varName))) + { + parameterName = varName; + value1 = querySolution.get(varName).toString(); + value2 = querySolution2.get(varName).toString(); + break; + } + } + } + if(!value1.isEmpty()) + { + throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); + } + throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); + } + + //No value occurs more often than allowed + for (Map.Entry entry : methodMap.entrySet()) { + + //What is this method setting? Get the expected parameter type and check whether it is some complex sub-object and whether this is a list + Class currentType = entry.getValue().getParameterTypes()[0]; + + String sparqlParameterName = entry.getKey(); + + if (Collection.class.isAssignableFrom(currentType)) { + sparqlParameterName += "s"; //plural form for the concatenated values + } + if(!querySolution.contains(sparqlParameterName)) + { + sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead + //TODO: Note: This would not yield full results yet in case some of the values are encapsulated + // in blank nodes and some are not, for the same property + } + if (querySolution.contains(sparqlParameterName)) { + String currentSparqlBinding = querySolution.get(sparqlParameterName).toString(); + + boolean objectIsBlankNode = querySolution.get(sparqlParameterName).isResource() && querySolution.get(sparqlParameterName).asNode().isBlank(); + String blankNodeId = ""; + //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject + //For that case, we add some artificial identifiers here + if(objectIsBlankNode) { + blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); + } + if (currentType.isEnum()) { + //Two possibilities: + //1: The URI of the enum value is given directly e.g. ?s ?p + //2: The URI of the enum value is encapsulated in a blank node, e.g. + // ?s ?p [ a demo:myEnum, demo:enumValue ] + if(objectIsBlankNode) + { + + Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); + QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); + ResultSet innerEnumQueryExecutionResultSet = innerEnumQueryExecution.execSelect(); + + //Only throw this if there is no successful execution + IOException anyIOException = null; + boolean oneSuccessfulEnumFound = false; + while(innerEnumQueryExecutionResultSet.hasNext()) + { + try { + entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); + oneSuccessfulEnumFound = true; + break; //Stop after the first successful execution + } + catch (IOException e) //There might be errors, if multiple types are present, see example above + { + anyIOException = e; + } + } + //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception + if(anyIOException != null && !oneSuccessfulEnumFound) + throw new IOException("Could not parse Enum. ", anyIOException); + innerEnumQueryExecution.close(); + } + else { + entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); + } + continue; + } + + + //There is a binding. If it is a complex sub-object, we need to recursively call this function + if (Collection.class.isAssignableFrom(currentType)) { + //We are working with ArrayLists. + //Here, we need to work with the GenericParameterTypes instead to find out what kind of ArrayList we are dealing with + String typeName = extractTypeNameFromCollection(entry.getValue().getGenericParameterTypes()[0]); + if (isArrayListTypePrimitive(entry.getValue().getGenericParameterTypes()[0])) { + if (typeName.endsWith("LangString")) { + try { + currentSparqlBinding = querySolution.get(sparqlParameterName + "Lang").toString(); + } catch (NullPointerException e) { + //logger.warn("Failed to retrieve localized/typed values of " + currentSparqlBinding + ". Make sure that namespaces used in this property are known and valid. Proceeding without localized values and interpreting as string."); + //logger.warn("Query was: " + queryString); + //logger.warn("Attempted to fetch: " + sparqlParameterName + "Lang"); + } + } + ArrayList list = new ArrayList<>(); + //Two pipes were used as delimiter above + //Introduce set to deduplicate + Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); + for (String s : allElements) { + Literal literal; + //querySolution.get(sparqlParameterName). + if (s.endsWith("@")) { + s = s.substring(2, s.length() - 3); + literal = ResourceFactory.createStringLiteral(s); + } else if (s.startsWith("\\")) { + //turn something like \"my Desc 1\"@en to "my Desc 1"@en + s = s.substring(1).replace("\\\"@", "\"@"); + literal = ResourceFactory.createLangLiteral(s.substring(1, s.lastIndexOf("@") - 1), s.substring(s.lastIndexOf("@") + 1)); + } else { + literal = ResourceFactory.createPlainLiteral(s); + } + + //Is the type of the ArrayList some built in Java primitive? + + if (builtInMap.containsKey(typeName)) { + //Yes, it is. We MUST NOT call Class.forName(name)! + list.add(handlePrimitive(builtInMap.get(typeName), literal, null)); + } else { + //Not a Java primitive, we may call Class.forName(name) + list.add(handlePrimitive(Class.forName(typeName), literal, s)); + } + } + entry.getValue().invoke(returnObject, list); + } else { + //List of complex sub-objects, such as a list of Resources in a ResourceCatalog + ArrayList list = new ArrayList<>(); + Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); + for (String s : allElements) { + if (Class.forName(typeName).isEnum()) { + list.add(handleEnum(Class.forName(typeName), s)); + } else { + list.add(handleObject(inputModel, s, Class.forName(typeName))); + } + } + entry.getValue().invoke(returnObject, list); + } + } + + //Not an ArrayList of objects expected, but rather one object + else { + //Our implementation of checking for primitives (i.e. also includes URLs, Strings, XMLGregorianCalendars, ...) + if (isPrimitive(currentType)) { + + Literal literal = null; + try { + literal = querySolution.getLiteral(sparqlParameterName); + } catch (Exception ignored) { + } + + entry.getValue().invoke(returnObject, handlePrimitive(currentType, literal, currentSparqlBinding)); + + } else { + //Not a primitive object, but a complex sub-object. Recursively call this function to handle it + if (objectIsBlankNode) { + entry.getValue().invoke(returnObject, handleObject(inputModel, blankNodeId, entry.getValue().getParameterTypes()[0])); + } else { + + entry.getValue().invoke(returnObject, handleObject(inputModel, currentSparqlBinding, entry.getValue().getParameterTypes()[0])); + } + } + } + } + + } + } + queryExecution.close(); + + return returnObject; + } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchFieldException | URISyntaxException | DatatypeConfigurationException | ClassNotFoundException e) { + throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); + } + } + + /** + * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" + * @param input Input URI, possibly a prefixed value + * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" + */ + private String wrapIfUri(String input) + { + if(input.startsWith("http://") || input.startsWith("https://")) + { + return "<" + input + ">"; + } + else { + return input; + } + } + + private Object handleForeignLiteral(Literal literal) throws URISyntaxException { + if(literal.getLanguage() != null && !literal.getLanguage().equals("")) + { + return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); + } + //If not, does it have some datatype URI? + //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) + //{ + // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); + //} + //If both is not true, add it as normal string + else + { + return literal.getString(); + } + } + + private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { + //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map + //Literals must be handled "one recursion step above" + if(node.isLiteral()) + { + throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); + } + + //Run SPARQL query retrieving all information (only one hop!) about this node + String queryString = "SELECT ?s ?p ?o { BIND(<" + node.asNode().getURI() + "> AS ?s) . ?s ?p ?o . } "; + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, model); + ResultSet resultSet = queryExecution.execSelect(); + + + + //Handle outgoing properties of this foreign node + while(resultSet.hasNext()) + { + QuerySolution querySolution = resultSet.next(); + + String propertyUri = querySolution.get("p").toString(); + + if(map.containsKey(propertyUri)) { + //If it is not an array list yet, turn it into one + if (!(map.get(propertyUri) instanceof ArrayList)) { + ArrayList newList = new ArrayList<>(); + newList.add(map.get(propertyUri)); + map.put(propertyUri, newList); + } + } + + //Check the type of object we have. If it is a literal, just add it as "flat value" to the map + if(querySolution.get("o").isLiteral()) + { + //Handle some small literal. This function will turn this into a TypedLiteral if appropriate + Object o = handleForeignLiteral(querySolution.getLiteral("o")); + if(map.containsKey(propertyUri)) + { + map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(o)); + } + else + { + map.put(querySolution.get("p").toString(), o); + } + } + + //If it is not a literal, we need to call this function recursively. Create new map for sub object + else + { + //logger.info("Calling handleForeignNode for " + querySolution.getResource("o").toString()); + if(querySolution.getResource("s").toString().equals(querySolution.getResource("o").toString())) + { + logger.warn("Found self-reference on " + querySolution.getResource("s").toString() + " via predicate " + querySolution.getResource("p").toString() + " ."); + continue; + } + HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); + subMap.put("@id", querySolution.getResource("o").getURI()); + if(map.containsKey(propertyUri)) + { + map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(subMap)); + } + else { + map.put(querySolution.get("p").toString(), subMap); + } + } + } + queryExecution.close(); + return map; + } + + + /** + * Utility function, used to obtain the field corresponding to a setter function + * @param targetClass Class object in which we search for a field + * @param fieldName Guessed name of the field to search for + * @return Field object matching the name (possibly with leading underscore) + * @throws NoSuchFieldException thrown, if no such field exists + */ + private Field getFieldByName(Class targetClass, String fieldName) throws NoSuchFieldException { + try { + return targetClass.getDeclaredField("_" + fieldName); + } catch (NoSuchFieldException e) { + try { + return targetClass.getDeclaredField(fieldName); + } catch (NoSuchFieldException e2) { + try { + return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); + } + catch (NoSuchFieldException e3) + { + throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); + } + } + } + } + + /** + * Internal function to create a single enum object from a given desired class and a URL + * @param enumClass The enum class + * @param url The URL of the enum value + * @param Enum class + * @return Value of enumClass matching the input URL + * @throws IOException thrown if no matching enum value could be found + */ + private T handleEnum(Class enumClass, String url) throws IOException { + if (!enumClass.isEnum()) { + throw new RuntimeException("Non-Enum class passed to handleEnum function."); + } + T[] constants = enumClass.getEnumConstants(); + if(url.contains("/")) + { + url = url.substring(url.lastIndexOf("/") + 1); + } + for (T constant : constants) { + //We artificially added some underscores in the AAS ontology. TODO: This might be a bit dangerous for other ontologies, which really contain underscores in enum names + if (url.equalsIgnoreCase(constant.toString()) || url.equalsIgnoreCase(constant.toString().replace("_", ""))) { + return constant; + } + } + throw new IOException("Failed to find matching enum value for " + url + " . Available enums are: " + Arrays.stream(constants).map(Object::toString).collect(Collectors.joining(", "))); + } + + /** + * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) + * @param currentType Input Class (or primitive) + * @param literal Value as literal (can be null in some cases) + * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) + * @return Object of type currentType + * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI + * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails + * @throws IOException thrown, if no matching "simple class" could be found + */ + private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { + //Java way of checking for primitives, i.e. int, char, float, double, ... + if (currentType.isPrimitive()) { + if (literal == null) { + throw new IOException("Trying to handle Java primitive, but got no literal value"); + } + //If it is an actual primitive, there is no need to instantiate anything. Just give it to the function + switch (currentType.getSimpleName()) { + case "int": + return literal.getInt(); + case "boolean": + return literal.getBoolean(); + case "long": + return literal.getLong(); + case "short": + return literal.getShort(); + case "float": + return literal.getFloat(); + case "double": + return literal.getDouble(); + case "byte": + return literal.getByte(); + } + } + + //Check for the more complex literals + + //URI + if (URI.class.isAssignableFrom(currentType)) { + return new URI(currentSparqlBinding); + } + + //String + if (String.class.isAssignableFrom(currentType)) { + return currentSparqlBinding; + } + + //XMLGregorianCalendar + if (XMLGregorianCalendar.class.isAssignableFrom(currentType)) { + //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown + try { + return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); + } + catch (DatatypeFormatException | DateTimeParseException ignored) + { + //Not a valid dateTimeStamp. Try parsing just to Date + try { + Date date = new SimpleDateFormat().parse(literal.getValue().toString()); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(date); + return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); + } + catch (ParseException | DateTimeParseException | DatatypeFormatException e2) + { + //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException + throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); + } + } + } + + //TypedLiteral + if (LangString.class.isAssignableFrom(currentType)) { + //Either a language tagged string OR literal with type. Only one allowed + if (!literal.getLanguage().equals("")) { + return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); + } + return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag + } + + //BigInteger + if (BigInteger.class.isAssignableFrom(currentType)) { + return new BigInteger(literal.getString()); + } + + //BigDecimal + if (BigDecimal.class.isAssignableFrom(currentType)) { + return new BigDecimal(literal.getString()); + } + + //byte[] + if (byte[].class.isAssignableFrom(currentType)) { + return currentSparqlBinding.getBytes(); + } + + //Duration + if (Duration.class.isAssignableFrom(currentType)) { + return DatatypeFactory.newInstance().newDuration(currentSparqlBinding); + } + + throw new IOException("Unrecognized primitive type: " + currentType.getName()); + } + + /** + * This list contains all primitive Java types + */ + private final Map> builtInMap = new HashMap<>(); + { + builtInMap.put("int", Integer.TYPE); + builtInMap.put("long", Long.TYPE); + builtInMap.put("double", Double.TYPE); + builtInMap.put("float", Float.TYPE); + builtInMap.put("bool", Boolean.TYPE); + builtInMap.put("char", Character.TYPE); + builtInMap.put("byte", Byte.TYPE); + builtInMap.put("void", Void.TYPE); + builtInMap.put("short", Short.TYPE); + } + + private boolean isArrayListTypePrimitive(Type t) throws IOException { + String typeName = extractTypeNameFromCollection(t); + + try { + //Do not try to call Class.forName(primitive) -- that would throw an exception + if (builtInMap.containsKey(typeName)) return true; + return isPrimitive(Class.forName(typeName)); + } catch (ClassNotFoundException e) { + throw new IOException("Unable to retrieve class from generic", e); + } + } + + private String extractTypeNameFromCollection(Type t) throws IOException { + String typeName = t.getTypeName(); + if (!typeName.startsWith("java.util.ArrayList<") && !typeName.startsWith("java.util.List<") && !typeName.startsWith("java.util.Collection<")) { + throw new IOException("Illegal argument encountered while interpreting type parameter"); + } + //"" or super instead of extends + if(typeName.contains("?")) + { + //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces + return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); + } + //No extends + else + { + return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); + } + } + + private boolean isPrimitive(Class input) throws IOException { + //Collections are not simple + if (Collection.class.isAssignableFrom(input)) { + throw new IOException("Encountered collection in isPrimitive. Use isArrayListTypePrimitive instead"); + } + + //check for: plain/typed literal, XMLGregorianCalendar, byte[], RdfResource + //covers int, long, short, float, double, boolean, byte + if (input.isPrimitive()) return true; + + return (URI.class.isAssignableFrom(input) || + String.class.isAssignableFrom(input) || + XMLGregorianCalendar.class.isAssignableFrom(input) || + LangString.class.isAssignableFrom(input) || + BigInteger.class.isAssignableFrom(input) || + BigDecimal.class.isAssignableFrom(input) || + byte[].class.isAssignableFrom(input) || + Duration.class.isAssignableFrom(input)); + } + + /** + * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) + * @param rdfModel RDF input to be parsed + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(Model rdfModel, Class targetClass) throws IOException { + addArtificialBlankNodeLabels(rdfModel); + ArrayList> implementingClasses = getImplementingClasses(targetClass); + + // Query to retrieve all instances in the input graph that have a class assignment + // Assumption: if the class name (?type) is equal to the target class, this should be the + // instance we actually want to parse + String queryString = "SELECT ?id ?type { ?id a ?type . }"; + Query query = QueryFactory.create(queryString); + QueryExecution queryExecution = QueryExecutionFactory.create(query, rdfModel); + ResultSet resultSet = queryExecution.execSelect(); + + if (!resultSet.hasNext()) { + throw new IOException("Could not extract class from input message"); + } + + Map> returnCandidates = new HashMap<>(); + + while (resultSet.hasNext()) { + QuerySolution solution = resultSet.nextSolution(); + String fullName = solution.get("type").toString(); + String className = fullName.substring(fullName.lastIndexOf('/') + 1); + + //In case of hash-namespaces + if(className.contains("#")) { + className = className.substring(className.lastIndexOf("#")); + } + + //For legacy purposes... + if (className.startsWith("ids:") || className.startsWith("aas:")) { + className = className.substring(4); + } + + for (Class currentClass : implementingClasses) { + if (currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + returnCandidates.put(solution.get("id").toString(), currentClass); + } + } + //if (returnCandidates.size() > 0) break; + } + queryExecution.close(); + + if (returnCandidates.size() == 0) { + throw new IOException("Could not transform input to an appropriate implementing class for " + targetClass.getName()); + } + + //At this point, we parsed the model and know to which implementing class we want to parse + //Check if there are several options available + if(returnCandidates.size() > 1) + { + String bestCandidateId = null; + Class bestCandidateClass = null; + long bestNumRelations = -1L; + for(Map.Entry> entry : returnCandidates.entrySet()) + { + String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + + " WHERE {" + + " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + + " OPTIONAL {?o ?p2 ?o2 . OPTIONAL {?o2 ?p3 ?o3 . OPTIONAL {?o3 ?p4 ?o4 . OPTIONAL {?o4 ?p5 ?o5 . } } } } }"; + Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); + QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); + long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); + if(graphSize > bestNumRelations) + { + bestNumRelations = graphSize; + bestCandidateId = entry.getKey(); + bestCandidateClass = entry.getValue(); + } + + determineBestCandidateQueryExecution.close(); + + } + logger.debug("The RDF graph contains multiple objects which can be parsed to " + targetClass.getSimpleName() + ". Determined " + bestCandidateId + " as best candidate."); + return (T) handleObject(rdfModel, bestCandidateId, bestCandidateClass); + } + + //We only reach this spot, if there is exactly one return candidate. Let's return it + Map.Entry> singularEntry = returnCandidates.entrySet().iterator().next(); + return (T) handleObject(rdfModel, singularEntry.getKey(), singularEntry.getValue()); + + } + + + /** + * Entry point to this class. Takes a message and a desired target class (can be an interface) + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(String message, Class targetClass) throws IOException { + Model model = readMessage(message); + return parseMessage(model, targetClass); + } + + /** + * Entry point to this class. Takes a message and a desired target class (can be an interface) + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * @param serializationFormat Input RDF format + * @param Desired target class + * @return Object of desired target class, representing the values contained in input message + * @throws IOException if the parsing of the message fails + */ + T parseMessage(String message, Class targetClass, Lang serializationFormat) throws IOException { + Model model = readMessage(message, serializationFormat); + return parseMessage(model, targetClass); + } + + /** + * Reads a message into an Apache Jena model, guessing the input language. + * Note: Guessing the language may cause some error messages during parsing attempts + * + * @param message Message to be read + * @return The model of the message + */ + private Model readMessage(String message) throws IOException { + + List supportedLanguages = new ArrayList<>( + Arrays.asList( + RDFLanguages.JSONLD, //JSON-LD first + RDFLanguages.TURTLE, //N-TRIPLE is a subset of Turtle + RDFLanguages.RDFXML + )); + + for (Lang lang : supportedLanguages) { + try { + return readMessage(message, lang); + } catch (IOException ignored) { + } + } + throw new IOException("Could not parse string as any supported RDF format (JSON-LD, Turtle/N-Triple, RDF-XML)."); + } + + /** + * Reads a message into an Apache Jena model, guessing the input language. + * Note: Guessing the language may cause some error messages during parsing attempts + * + * @param message Message to be read + * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML + * @return The model of the message + */ + private Model readMessage(String message, Lang language) throws IOException { + + Model targetModel = ModelFactory.createDefaultModel(); + + try { + RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); + } + catch (RiotException e) + { + throw new IOException("Failed to parse input as " + language, e); + } + return targetModel; + } + + /** + * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated + * @param someClass Input class of which implementable subclasses need to be found + * @return ArrayList of instantiable subclasses + */ + ArrayList> getImplementingClasses(Class someClass) { + ArrayList> result = new ArrayList<>(); + KnownSubtypes subTypeAnnotation = someClass.getAnnotation(KnownSubtypes.class); + if (subTypeAnnotation != null) { + KnownSubtypes.Type[] types = subTypeAnnotation.value(); + for (KnownSubtypes.Type type : types) { + result.addAll(getImplementingClasses(type.value())); + } + } + if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { + result.add(Serializer.customImplementationMap.getOrDefault(someClass, someClass)); + } + return result; + } + + private void addArtificialBlankNodeLabels(Model m) + { + //Get all blank nodes + Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); + QueryExecution qe = QueryExecutionFactory.create(q, m); + ResultSet rs = qe.execSelect(); + List statementsToAdd = new ArrayList<>(); + while(rs.hasNext()) + { + QuerySolution qs = rs.next(); + statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), + ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), + ResourceFactory.createStringLiteral(qs.get("?s").toString()))); + } + qe.close(); + m.add(statementsToAdd); + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java new file mode 100644 index 000000000..b18f0567d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java @@ -0,0 +1,308 @@ +/* + * 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.rdf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.Deserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class Serializer implements org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer, Deserializer { + + private static final ObjectMapper mapper = new ObjectMapper(); + private final List preprocessors; + private final Logger logger = LoggerFactory.getLogger(Serializer.class); + + public static String implementingClassesNamePrefix = "Default"; + public static String implementingClassesNameSuffix = ""; + + static Map, Class> customImplementationMap = new HashMap<>(); + + private static boolean charsetWarningPrinted = false; + + public Serializer() { + mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); + mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + mapper.setMixInResolver(new ReflectiveMixInResolver()); + + preprocessors = new ArrayList<>(); + this.addPreprocessor(new TypeNamePreprocessor()); + + if(!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) + { + charsetWarningPrinted = true; + logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); + } + + //Default namespaces for AAS + addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); + addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); + addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/RC02/"); + //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); + + } + + /** + * Serializes an object to an RDF representation. In order to support RDF, the input instance must be + * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). + * + * @param instance the instance to be serialized + * @return RDF serialization of the provided object graph + * @throws IOException if the serialization fails + */ + public String serialize(Object instance) throws IOException { + return serialize(instance, RDFLanguages.TTL, new HashMap<>()); + } + + /** + * Serializes an object to an RDF representation of a given RDF serialization format. In order to support RDF, the + * input instance must be annotated using AAS Metamodel annotations. + * + * @param instance the instance to be serialized + * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) + * @return RDF serialization of the provided object graph + * @throws IOException if the serialization fails + */ + public synchronized String serialize(Object instance, Lang format) throws IOException { + return serialize(instance, format, new HashMap<>() ); + } + + + //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function + public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { + if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { + throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); + } + mapper.registerModule(new JsonLDModule(idMap)); + String jsonLD = (instance instanceof Collection) + ? serializeCollection((Collection) instance) + : mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); + if (format == RDFLanguages.JSONLD) return jsonLD; + else return convertJsonLdToOtherRdfFormat(jsonLD, format); + } + + private String serializeCollection(Collection collection) throws IOException { + String lineSep = System.lineSeparator(); + StringBuilder jsonLDBuilder = new StringBuilder(); + + if (collection.isEmpty()) { + jsonLDBuilder.append("[]"); + } else { + jsonLDBuilder.append("["); + jsonLDBuilder.append(lineSep); + for (Object item : collection) { + jsonLDBuilder.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(item)); + jsonLDBuilder.append(","); + jsonLDBuilder.append(lineSep); + } + int lastComma = jsonLDBuilder.lastIndexOf(","); + jsonLDBuilder.replace(lastComma, lastComma + 1, ""); + jsonLDBuilder.append("]"); + } + jsonLDBuilder.append(lineSep); + + return jsonLDBuilder.toString(); + } + + public String convertJsonLdToOtherRdfFormat(String jsonLd, Lang format) { + Model model = ModelFactory.createDefaultModel(); + RDFDataMgr.read(model, new ByteArrayInputStream(jsonLd.getBytes()), RDFLanguages.JSONLD); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + RDFDataMgr.write(os, model, format); + return os.toString(); + } + + public String serializePlainJson(Object instance) throws JsonProcessingException { + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); + } + + /** + * Inverse method of "serialize" + * + * @param serialization JSON(-LD) string + * @param valueType class of top level type + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(String serialization, Class valueType) throws DeserializationException { + try { + return new Parser().parseMessage(serialization, valueType); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Inverse method of "serialize" + * + * @param serialization JSON(-LD) string + * @param valueType class of top level type + * @param serializationFormat RDF input format + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(String serialization, Class valueType, Lang serializationFormat) throws DeserializationException { + try { + + return new Parser().parseMessage(serialization, valueType, serializationFormat); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Inverse method of "serialize" + * + * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes + * @param valueType class of top level type + * @param deserialized type + * @return an object representing the provided JSON(-LD) structure + * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF + */ + public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { + try { + return new Parser().parseMessage(rdfModel, valueType); + } + catch (IOException e) + { + throw new DeserializationException("Failed to deserialize input.", e); + } + } + + /** + * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". + * @param prefix Prefix to be added + * @param namespaceUrl URL of the prefix + */ + public static void addKnownNamespace(String prefix, String namespaceUrl) + { + Parser.knownNamespaces.put(prefix, namespaceUrl); + JsonLDSerializer.contextItems.put(prefix, namespaceUrl); + } + + /** + * Method to add a preprocessor for deserialization. + *

+ * Important note: The preprocessors are executed in the same order they were added. + * + * @param preprocessor the preprocessor to add + */ + public void addPreprocessor(JsonPreprocessor preprocessor) { + preprocessors.add(preprocessor); + } + + /** + * Method to add a preprocessor for deserialization. + *

+ * Important note: The preprocessors are executed in the same order they were added. + * + * @param preprocessor the preprocessor to add + * @param validate set whether the preprocessors output should be checked by RDF4j + */ + public void addPreprocessor(JsonPreprocessor preprocessor, boolean validate) { + preprocessor.enableRDFValidation(validate); + addPreprocessor(preprocessor); + } + + /** + * remove a preprocessor if no longer needed + * + * @param preprocessor the preprocessor to remove + */ + public void removePreprocessor(JsonPreprocessor preprocessor) { + preprocessors.remove(preprocessor); + } + + @Override + public String write(Environment aasEnvironment) throws SerializationException { + try { + return serialize(aasEnvironment); + } + catch (IOException e) + { + throw new SerializationException("Failed to serialize environment.", e); + } + } + + public String write(Environment aasEnvironment, Lang format) throws SerializationException { + return write(aasEnvironment, format, new HashMap<>()); + } + + public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { + try { + return serialize(aasEnvironment, format, idMap); + } + catch (IOException e) + { + throw new SerializationException("Failed to serialize environment.", e); + } + } + @Override + public Environment read(String value) throws DeserializationException { + try { + return new Parser().parseMessage(value, Environment.class); + } + catch (IOException e) + { + throw new DeserializationException("Could not deserialize to environment.", e); + } + } + + public Environment read(String value, Lang serializationFormat) throws DeserializationException { + try { + return new Parser().parseMessage(value, Environment.class, serializationFormat); + } + catch (IOException e) + { + throw new DeserializationException("Could not deserialize to environment.", e); + } + } + + @Override + public void useImplementation(Class aasInterface, Class implementation) { + customImplementationMap.put(aasInterface, implementation); + //throw new NotImplementedException("Custom implementation support not yet implemented"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java new file mode 100644 index 000000000..a889ae103 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java @@ -0,0 +1,53 @@ +/* + * 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.rdf; + +import java.io.IOException; +import java.net.URI; + + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonStreamContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class UriSerializer extends StdSerializer { + + + public UriSerializer() { + this(null); + } + + public UriSerializer(Class clazz) { + super(clazz); + } + + + @Override + public void serialize(URI value, JsonGenerator gen, SerializerProvider provider) throws IOException { + String serializedUri = value.toString(); + // String idPattern = "{\"@id\": \"" + serializedUri + "\"}"; + JsonStreamContext context = gen.getOutputContext(); + if (context.getCurrentName() != null && context.getCurrentName().contains("@id")) { + gen.writeString(serializedUri); + } else { + gen.writeStartObject(); + gen.writeStringField("@id", serializedUri); + gen.writeEndObject(); + } + } + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java new file mode 100644 index 000000000..a05f77d44 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java @@ -0,0 +1,42 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import java.io.IOException; +import java.math.BigDecimal; + +public class BigDecimalSerializer extends StdSerializer { + + public BigDecimalSerializer() { + this(null); + } + + public BigDecimalSerializer(Class clazz) { + super(clazz); + } + + @Override + public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeStartObject(); + gen.writeStringField("@value", value.toString()); + gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#decimal"); + gen.writeEndObject(); + } +} \ No newline at end of file diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java new file mode 100644 index 000000000..ff1374e20 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java @@ -0,0 +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.rdf.custom; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.JsonLdEnumSerializer; + +@JsonSerialize(using = JsonLdEnumSerializer.class) +public class JsonLdEnumMixin { +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java new file mode 100644 index 000000000..a1f0ec779 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java @@ -0,0 +1,35 @@ +/* + * 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.rdf.custom; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + + +import java.util.List; + +@JsonTypeName("rdf:langString") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface LangStringMixin { + @JsonProperty("@value") + public String getValue(); + + @JsonProperty("@language") + public String getLanguage(); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java new file mode 100644 index 000000000..54692477e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java @@ -0,0 +1,41 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.databind.introspect.ClassIntrospector; + +public class ReflectiveMixInResolver implements ClassIntrospector.MixInResolver { + + @Override + public Class findMixInClassFor(Class cls) { + if (cls.isEnum()) + { + return JsonLdEnumMixin.class; + } + try { + return Class.forName("org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins." + cls.getSimpleName() + "Mixin"); + } + catch (ClassNotFoundException ignored) + { + return null; + } + } + + @Override + public ClassIntrospector.MixInResolver copy() { + return new ReflectiveMixInResolver(); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java new file mode 100644 index 000000000..28006cbb8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.IOException; +import java.time.ZonedDateTime; +import java.util.GregorianCalendar; + +public class XMLGregorianCalendarDeserializer extends StdDeserializer { + + public XMLGregorianCalendarDeserializer() { + this(XMLGregorianCalendar.class); + } + + public XMLGregorianCalendarDeserializer(Class clazz) { + super(clazz); + } + + @Override + public XMLGregorianCalendar deserialize(JsonParser p, DeserializationContext context) throws IOException { + XMLGregorianCalendar xgc = null; + try { + xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(p.getValueAsString()))); + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + return xgc; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java new file mode 100644 index 000000000..b80718d93 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.custom; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import javax.xml.datatype.XMLGregorianCalendar; +import java.io.IOException; +import java.text.SimpleDateFormat; + +public class XMLGregorianCalendarSerializer extends StdSerializer { + + public XMLGregorianCalendarSerializer() { + this(null); + } + + public XMLGregorianCalendarSerializer(Class clazz) { + super(clazz); + } + + @Override + public void serialize(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider) throws IOException { + SimpleDateFormat xsdDateTimeStampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + xsdDateTimeStampFormat.setCalendar(value.toGregorianCalendar()); + String xsdDateTimeStampFormatted = xsdDateTimeStampFormat.format(value.toGregorianCalendar().getTime()); + gen.writeStartObject(); + gen.writeStringField("@value", xsdDateTimeStampFormatted); + gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#dateTimeStamp"); + gen.writeEndObject(); + + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java new file mode 100644 index 000000000..e967dd795 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:AdministrativeInformation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + String getVersion(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + void setVersion(String version); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + String getRevision(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + void setRevision(String revision); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java new file mode 100644 index 000000000..2b8c30171 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; + +import java.util.List; + +@JsonTypeName("aas:AnnotatedRelationshipElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + List getAnnotations(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + void setAnnotations(List annotations); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java new file mode 100644 index 000000000..9a49ca42c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:AssetAdministrationShell") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + AssetInformation getAssetInformation(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + void setAssetInformation(AssetInformation assetInformation); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + Reference getDerivedFrom(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + void setDerivedFrom(Reference derivedFrom); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + List getSubmodels(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + void setSubmodels(List submodels); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java new file mode 100644 index 000000000..08a7e1715 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java @@ -0,0 +1,60 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.File; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:AssetInformation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface AssetInformationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + AssetKind getAssetKind(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + void setAssetKind(AssetKind assetKind); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + Reference getGlobalAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + void setGlobalAssetId(Reference globalAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + List getSpecificAssetIds(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + void setSpecificAssetIds(List specificAssetIds); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + List getBillOfMaterials(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + void setBillOfMaterials(List billOfMaterials); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + File getDefaultThumbnail(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + void setDefaultThumbnail(File defaultThumbnail); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java new file mode 100644 index 000000000..803e6c037 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java @@ -0,0 +1,79 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Direction; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +@JsonTypeName("aas:BasicEventElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface BasicEventElementMixin extends EventElementMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + Direction getDirection(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + void setDirection(Direction direction); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + String getLastUpdate(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + void setLastUpdate(String lastUpdate); + + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + String getMaxInterval(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + void setMaxInterval(String maxInterval); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + Reference getMessageBroker(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + void setMessageBroker(Reference messageBroker); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + String getMessageTopic(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + void setMessageTopic(String messageTopic); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + String getMinInterval(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + void setMinInterval(String minInterval); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + Reference getObserved(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + void setObserved(Reference observed); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + StateOfEvent getState(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + void setState(StateOfEvent state); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java new file mode 100644 index 000000000..267158c70 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Blob") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface BlobMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + void setConentType(String mimeType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + byte[] getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + void setValue(byte[] value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java new file mode 100644 index 000000000..d37450ab5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java @@ -0,0 +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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Capability") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface CapabilityMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java new file mode 100644 index 000000000..7cc22006c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:ConceptDescription") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + List getIsCaseOf(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + void setIsCaseOf(List isCaseOf); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java new file mode 100644 index 000000000..dab2fb7be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java @@ -0,0 +1,37 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +@JsonTypeName("aas:DataElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = File.class), + @JsonSubTypes.Type(value = Blob.class), + @JsonSubTypes.Type(value = MultiLanguageProperty.class), + @JsonSubTypes.Type(value = Property.class), + @JsonSubTypes.Type(value = Range.class), + @JsonSubTypes.Type(value = ReferenceElement.class) +}) +public interface DataElementMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java new file mode 100644 index 000000000..e9d69f2d1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationContent") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = DataSpecificationIEC61360.class) +}) +public interface DataSpecificationContentMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java new file mode 100644 index 000000000..672645918 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java @@ -0,0 +1,106 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationIEC61360") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationIEC61360Mixin extends DataSpecificationContentMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") + public DataTypeIEC61360 getDataType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") + public void setDataType(DataTypeIEC61360 dataType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") + public List getDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") + public void setDefinitions(List definition); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") + public LevelType getLevelType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") + public void setLevelType(LevelType levelType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") + public List getPreferredName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") + public void setPreferredName(List preferredName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") + public List getShortName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") + public void setShortName(List shortName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") + public String getSourceOfDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") + public void setSourceOfDefinition(String sourceOfDefinition); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") + public String getSymbol(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") + public void setSymbol(String symbol); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") + public String getUnit(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") + public void setUnit(String unit); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") + public Reference getUnitId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") + public void setUnitId(Reference unitId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") + public String getValueFormat(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") + public void setValueFormat(String valueFormat); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") + public String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") + public void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") + public ValueList getValueList(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") + public void setValueList(ValueList valueList); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") + public Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") + public void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java new file mode 100644 index 000000000..d299d0399 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java @@ -0,0 +1,99 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; + +import java.util.List; + +@JsonTypeName("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationPhysicalUnitMixin { + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") + String getConversionFactor(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") + void setConversionFactor(String conversionFactor); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") + List getDefinitions(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") + void setDefinitions(List definitions); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") + String getDinNotation(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") + void setDinNotation(String dinNotation); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") + String getEceCode(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") + void setEceCode(String eceCode); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") + String getEceName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") + void setEceName(String eceName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") + String getNistName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") + void setNistName(String nistName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") + String getSiName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") + void setSiName(String siName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") + String getSiNotation(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") + void setSiNotation(String siNotation); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") + String getRegistrationAuthorityId(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") + void setRegistrationAuthorityId(String registrationAuthorityId); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") + String getSupplier(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") + void setSupplier(String supplier); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") + String getUnitName(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") + void setUnitName(String unitName); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") + String getUnitSymbol(); + + @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") + void setUnitSymbol(String unitSymbol); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java new file mode 100644 index 000000000..b1fe7ac33 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIEC61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:EmbeddedDataSpecification") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EmbeddedDataSpecificationMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") + public DataSpecificationIEC61360 getDataSpecificationContent(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") + public void setDataSpecificationContent(DataSpecificationIEC61360 dataSpecificationContent); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + public Reference getDataSpecification(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + public void setDataSpecification(Reference dataSpecification); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java new file mode 100644 index 000000000..6a2636737 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java @@ -0,0 +1,54 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.EntityType; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Entity") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EntityMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + Reference getGlobalAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + void setGlobalAssetId(Reference globalAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + SpecificAssetId getSpecificAssetId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + void setSpecificAssetId(SpecificAssetId specificAssetId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + EntityType getEntityType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + void setEntityType(EntityType entityType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + List getStatements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + void setStatements(List statements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java new file mode 100644 index 000000000..97a7028be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; + +import java.util.List; + +@JsonTypeName("aas:Environment") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EnvironmentMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + List getAssetAdministrationShells(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + void setAssetAdministrationShells(List assetAdministrationShells); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + List getConceptDescriptions(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + void setConceptDescriptions(List conceptDescriptions); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + List getSubmodels(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + void setSubmodels(List submodels); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java new file mode 100644 index 000000000..e3e7ed1c0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; + + +@JsonTypeName("aas:EventElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = BasicEventElement.class) +}) +public interface EventElementMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java new file mode 100644 index 000000000..26bc5c128 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java @@ -0,0 +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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:EventMessage") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface EventMessageMixin extends SubmodelElementMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java new file mode 100644 index 000000000..62322c3b1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java @@ -0,0 +1,50 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Extension") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ExtensionMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + String getName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + void setName(String name); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + Reference getRefersTo(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + void setRefersTo(Reference refersTo); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java new file mode 100644 index 000000000..c4c234413 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:File") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface FileMixin extends DataElementMixin, SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + void setContentType(String contentType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + void setValue(String value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java new file mode 100644 index 000000000..cc5a8707e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:Formula") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface FormulaMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + List getDependsOns(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + void setDependsOns(List dependsOns); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java new file mode 100644 index 000000000..b0693d8d6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +import java.util.List; + +@JsonTypeName("aas:HasDataSpecification") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = AdministrativeInformation.class), + @JsonSubTypes.Type(value = AssetAdministrationShell.class), + @JsonSubTypes.Type(value = ConceptDescription.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface HasDataSpecificationMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + List getDataSpecifications(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + void setDataSpecifications(List dataSpecifications); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + List getEmbeddedDataSpecifications(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + void setEmbeddedDataSpecifications(List embeddedDataSpecifications); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java new file mode 100644 index 000000000..772a10c3e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; + +import java.util.List; + +@JsonTypeName("aas:HasExtensions") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface HasExtensionsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + List getExtensions(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + void setExtensions(List extensions); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java new file mode 100644 index 000000000..d3f87470a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.ModelingKind; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +@JsonTypeName("aas:HasKind") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface HasKindMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") + ModelingKind getKind(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") + void setKind(ModelingKind kind); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java new file mode 100644 index 000000000..a194d33dd --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java @@ -0,0 +1,49 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + + +@JsonTypeName("aas:HasSemantics") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SpecificAssetId.class), + @JsonSubTypes.Type(value = SubmodelElement.class), + @JsonSubTypes.Type(value = Qualifier.class), + @JsonSubTypes.Type(value = Extension.class) +}) +public interface HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + Reference getSemanticId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + void setSemanticId(Reference semanticId); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + List getSupplementalSemanticIds(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + void setSupplementalSemanticIds(List references); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java new file mode 100644 index 000000000..c9590fd02 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; + +@JsonTypeName("aas:Identifiable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = AssetAdministrationShell.class), + @JsonSubTypes.Type(value = ConceptDescription.class) +}) +public interface IdentifiableMixin extends ReferableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + AdministrativeInformation getAdministration(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + void setAdministration(AdministrativeInformation administration); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + String getId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + void setId(String id); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java new file mode 100644 index 000000000..7594d6bd0 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:IdentifierKeyValuePair") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + String getKey(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + void setKey(String key); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + Reference getExternalSubjectId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + void setExternalSubjectId(Reference externalSubjectId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java new file mode 100644 index 000000000..5c30d2b41 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java @@ -0,0 +1,31 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Identifier") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface IdentifierMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + String getIdentifier(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + void setIdentifier(String identifier); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java new file mode 100644 index 000000000..972dca9a1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; + +@JsonTypeName("aas:Key") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface KeyMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + KeyTypes getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + void setType(KeyTypes type); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + void setValue(String value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java new file mode 100644 index 000000000..71b17e055 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:MultiLanguageProperty") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface MultiLanguagePropertyMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") + List getValues(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") + void setValues(List values); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java new file mode 100644 index 000000000..a91d8f9aa --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:ObjectAttributes") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ObjectAttributesMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + List getObjectAttributes(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + void setObjectAttributes(List objectAttributes); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java new file mode 100644 index 000000000..c37547418 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java @@ -0,0 +1,45 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; + +import java.util.List; + +@JsonTypeName("aas:Operation") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface OperationMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + List getInputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + void setInputVariables(List inputVariables); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + List getInoutputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + void setInoutputVariables(List inoutputVariables); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + List getOutputVariables(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + void setOutputVariables(List outputVariables); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java new file mode 100644 index 000000000..3e21e6918 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +@JsonTypeName("aas:OperationVariable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface OperationVariableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + SubmodelElement getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + void setValue(SubmodelElement value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java new file mode 100644 index 000000000..f6a0023c8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:PolicyDecisionPoint") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyDecisionPointMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + boolean getExternalPolicyDecisionPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java new file mode 100644 index 000000000..7eb2bd1a8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:PolicyEnforcementPoints") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyEnforcementPointsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + boolean getExternalPolicyEnforcementPoint(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java new file mode 100644 index 000000000..db74d7242 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java @@ -0,0 +1,39 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:PolicyInformationPoints") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PolicyInformationPointsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + boolean getExternalInformationPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + void setExternalInformationPoints(boolean externalInformationPoints); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + List getInternalInformationPoints(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + void setInternalInformationPoints(List internalInformationPoints); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java new file mode 100644 index 000000000..162cda7a2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Property") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface PropertyMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java new file mode 100644 index 000000000..be2e8c0c9 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; + +import java.util.List; + +@JsonTypeName("aas:Qualifiable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Submodel.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface QualifiableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + List getQualifiers(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + void setQualifiers(List qualifiers); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java new file mode 100644 index 000000000..941567e52 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java @@ -0,0 +1,50 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:Qualifier") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface QualifierMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + String getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + void setType(String type); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java new file mode 100644 index 000000000..b46e6de2c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java @@ -0,0 +1,44 @@ +/* + * 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.rdf.mixins; + + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("aas:Range") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface RangeMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + String getValueType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + void setValueType(String valueType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + String getMax(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + void setMax(String max); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + String getMin(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + void setMin(String min); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java new file mode 100644 index 000000000..349c27b6e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java @@ -0,0 +1,58 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Referable") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Identifiable.class), + @JsonSubTypes.Type(value = SubmodelElement.class) +}) +public interface ReferableMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + String getCategory(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + void setCategory(String category); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") + List getDescription(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") + void setDescription(List description); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") + List getDisplayName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") + void setDisplayName(List displayName); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + String getIdShort(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + void setIdShort(String idShort); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java new file mode 100644 index 000000000..6df2a7be1 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java @@ -0,0 +1,32 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:ReferenceElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ReferenceElementMixin extends DataElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + Reference getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + void setValue(Reference value); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java new file mode 100644 index 000000000..0af5ae449 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java @@ -0,0 +1,41 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.util.List; + +@JsonTypeName("aas:Reference") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ReferenceMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + List getKeys(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + void setKeys(List keys); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + ReferenceTypes getType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + void setType(ReferenceTypes type); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java new file mode 100644 index 000000000..31fefc0c7 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java @@ -0,0 +1,43 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:RelationshipElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) +}) +public interface RelationshipElementMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + Reference getFirst(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + void setFirst(Reference first); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + Reference getSecond(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + void setSecond(Reference second); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java new file mode 100644 index 000000000..4d25d1637 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; + +import java.util.List; + +@JsonTypeName("aas:Resource") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ResourceMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + String getContentType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + void setContentType(String contentType); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + String getPath(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + void setPath(String path); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java new file mode 100644 index 000000000..0380783e6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java @@ -0,0 +1,47 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.File; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; + +@JsonTypeName("aas:SpecificAssetId") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SpecificAssetIdMixin extends HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + String getName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + void setName(String name); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + Reference getExternalSubjectId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + void setExternalSubjectId(Reference reference); + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java new file mode 100644 index 000000000..f0451e1f4 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; + +import java.util.List; + +@JsonTypeName("aas:SubjectAttributes") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubjectAttributesMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + List getSubjectAttributes(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + void setSubjectAttributes(List subjectAttributes); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java new file mode 100644 index 000000000..722fc32ab --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java @@ -0,0 +1,45 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.Collection; + +@JsonTypeName("aas:SubmodelElementCollection") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + boolean getAllowDuplicates(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + void setAllowDuplicates(boolean allowDuplicates); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + boolean getOrdered(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + void setOrdered(boolean ordered); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + Collection getValues(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + void setValues(Collection values); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java new file mode 100644 index 000000000..9387f7570 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java @@ -0,0 +1,61 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; + +import java.util.List; + +@JsonTypeName("aas:SubmodelElementList") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelElementListMixin extends SubmodelElementMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + boolean getOrderRelevant(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + void setOrderRelevant(boolean orderRelevant); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + Reference getSemanticIdListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + void setSemanticIdListElement(Reference semanticIdListElement); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + AasSubmodelElements getTypeValueListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + void setTypeValueListElement(AasSubmodelElements typeValueListElement); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + List getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + void setValue(List value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + DataTypeDefXsd getValueTypeListElement(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java new file mode 100644 index 000000000..1bb5e50b5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java @@ -0,0 +1,40 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + + +@JsonTypeName("aas:SubmodelElement") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = RelationshipElement.class), + @JsonSubTypes.Type(value = DataElement.class), + @JsonSubTypes.Type(value = File.class), + @JsonSubTypes.Type(value = Capability.class), + @JsonSubTypes.Type(value = Entity.class), + @JsonSubTypes.Type(value = EventElement.class), + @JsonSubTypes.Type(value = EventPayload.class), + @JsonSubTypes.Type(value = Operation.class), + @JsonSubTypes.Type(value = SubmodelElementCollection.class) +}) +public interface SubmodelElementMixin extends ReferableMixin, QualifiableMixin, HasDataSpecificationMixin, HasKindMixin, HasSemanticsMixin { + +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java new file mode 100644 index 000000000..df693d6a2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; + +import java.util.List; + +@JsonTypeName("aas:Submodel") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + List getSubmodelElements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + void setSubmodelElements(List submodelElements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java new file mode 100644 index 000000000..2cb4a878c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java @@ -0,0 +1,36 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; + +import java.util.List; + + +@JsonTypeName("aas:ValueList") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ValueListMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + List getValueReferencePairs(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + void setValueReferencePairs(List valueReferencePairs); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java new file mode 100644 index 000000000..d9502ad58 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java @@ -0,0 +1,38 @@ +/* + * 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.rdf.mixins; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +@JsonTypeName("aas:ValueReferencePair") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ValueReferencePairMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java new file mode 100644 index 000000000..fd1aa933c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java @@ -0,0 +1,33 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import java.util.List; + +@JsonTypeName("aas:View") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + List getContainedElements(); + + @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + void setContainedElements(List containedElements); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java new file mode 100644 index 000000000..2bf5c6603 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java @@ -0,0 +1,53 @@ +/* + * 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.rdf.preprocessing; + + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.riot.RDFDataMgr; +import org.apache.jena.riot.RDFLanguages; + + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/** + * basic implementation of {@code JsonPreprocessor} that encapsulates validation. + * By default, validation is disabled for performance reasons (@context has to be downloaded each time). + */ +public abstract class BasePreprocessor implements JsonPreprocessor { + + private boolean validate = false; + + + @Override + public final String preprocess(String input) throws IOException { + String result = preprocess_impl(input); + if(validate) { + Model m = ModelFactory.createDefaultModel(); + RDFDataMgr.read(m, new ByteArrayInputStream(result.getBytes()), RDFLanguages.JSONLD); + } + return result; + } + + abstract String preprocess_impl(String input) throws IOException; + + @Override + public void enableRDFValidation(boolean validate) { + this.validate = validate; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java new file mode 100644 index 000000000..a76739850 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java @@ -0,0 +1,42 @@ +/* + * 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.rdf.preprocessing; + +import java.io.IOException; + +/** + * Interface for JSON-LD preprocessors which should transform JSON-LD inputs + * before they are deserialized by Jackson. + * + * Implementations used at the same time must not interfere with each other. + */ +public interface JsonPreprocessor { + + /** + * preprocessing method + * @param input of the transformation, the original JSON-LD + * @return the transformation´s result + * @throws IOException if preprocessing fails, e.g. because the input is not valid RDF + */ + public String preprocess(String input) throws IOException; + + /** + * specify wheter the transformation's result should be validated to + * be parsable by RDF4j + * @param validate enable/disable switch + */ + public void enableRDFValidation(boolean validate); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java new file mode 100644 index 000000000..9de954912 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java @@ -0,0 +1,194 @@ +/* + * 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.rdf.preprocessing; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +public class TypeNamePreprocessor extends BasePreprocessor { + + private static final Map prefixes; + + static { + prefixes = new HashMap<>(); + prefixes.put("ids:", "https://w3id.org/idsa/core/"); + prefixes.put("idsc:", "https://w3id.org/idsa/code/"); + prefixes.put("info:", "http://www.fraunhofer.de/fraunhofer-digital/infomodell#"); + prefixes.put("kdsf:", "http://kerndatensatz-forschung.de/version1/technisches_datenmodell/owl/Basis#"); + } + + @Override + String preprocess_impl(String input) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + Map inMap = mapper.readValue(input, Map.class); + Map outMap = unifyTypeURIPrefix(inMap); + return mapper.writeValueAsString(outMap); + } + + + private Map unifyTypeURIPrefix(Map in) { + Map out = new LinkedHashMap<>(); + in.forEach((k,v) -> { + if(v instanceof String && k instanceof String && k.equals("@type")) { + + + // if key is @type and value is a string: add 'ids:' if no other namespace at the value + AtomicReference modifiableValue = new AtomicReference<>((String) v); + prefixes.forEach((p, u) -> modifiableValue.set(modifiableValue.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableValue.get().startsWith("ids:") + || modifiableValue.get().startsWith("idsc:") + || modifiableValue.get().startsWith("info:") + || modifiableValue.get().startsWith("kdsf:") + || modifiableValue.get().startsWith("xsd:") + || modifiableValue.get().startsWith("http://") + || modifiableValue.get().startsWith("https://"))) { + modifiableValue.set("ids:".concat(modifiableValue.get())); // default to ids prefix for backwards compatibility + } + out.put(k, modifiableValue.get()); + + + } else if(v instanceof Map) { + AtomicReference modifiableKey = new AtomicReference<>((String) k); + + prefixes.forEach((prefix, uri) -> modifiableKey.set(modifiableKey.get().replace(uri, prefix))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://") + || modifiableKey.get().startsWith("@context"))) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + + + // shorten an @id Map + if (((Map) v).containsKey("@id") && ((Map) v).keySet().size() == 1) { + Map idMap = new LinkedHashMap<>(); + idMap.put(k, ((Map) v).get("@id")); + + out.putAll(unifyTypeURIPrefix(idMap)); + + } else if (((Map) v).containsKey("@value") && + ((Map) v).containsKey("@type")) + { + if( ((Map) v).get("@type").toString().contains("dateTime") ) + { + + // shorten an @value Map with xsd:dateTimes + Object date = ((Map) v).get("@value"); + out.put(modifiableKey, date); + } + else if(((Map) v).get("@type").toString().equals("xsd:integer")) + { + int value = Integer.parseInt(((Map) v).get("@value").toString()); + out.put(modifiableKey, value); + } + else { //Do the same as below + out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); + } + + } else { + + out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); + + + } + + } else if(v instanceof ArrayList) { + + + AtomicReference modifiableKey = new AtomicReference<>((String) k); + prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://"))) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + + Iterator iter = new ArrayList((ArrayList) v).iterator(); //making a copy of the old array so the iterator does not get confused by the element deletions + while (iter.hasNext()) { + Object child = iter.next(); + if (child instanceof Map && ((Map) child).containsKey("@id") && ((Map) child).keySet().size() == 1) { + ((ArrayList) v).remove(child); + ((ArrayList) v).add(((Map) child).get("@id")); + } + } + + out.put(modifiableKey, unifyTypeURIPrefix((ArrayList) v)); // TODO: What happens with an Array inside the Array? + + + } else { + + + AtomicReference modifiableKey = new AtomicReference<>((String) k); + prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix + if(! (modifiableKey.get().startsWith("ids:") + || modifiableKey.get().startsWith("info:") + || modifiableKey.get().startsWith("kdsf:") + || modifiableKey.get().startsWith("http://") + || modifiableKey.get().startsWith("https://") + || modifiableKey.get().startsWith("@"))) { + //in the context definition, a pair might look like this: "ids" : "http://www.someURL.com" + //Here, we start with "ids", not "ids:". So we also need to check that the key is not contained in our prefixes + if(!prefixes.containsKey(modifiableKey.get() + ":")) { + modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility + } + } + + out.put(modifiableKey, v); // modify nothing if not @type or a map + } + }); + return out; + } + + + private ArrayList unifyTypeURIPrefix(ArrayList in) { + ArrayList out = new ArrayList<>(); + + Iterator iter = in.iterator(); + + while (iter.hasNext()) { + Object v = iter.next(); + if(v instanceof Map) { + + + if (!((Map) v).isEmpty()) + out.add( unifyTypeURIPrefix((Map) v)); + + + } else if (v instanceof String) { + + out.add(v); // modify nothing if not @type or a map + } else { + out.add(v); + } + } + return out; + } + + + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java new file mode 100644 index 000000000..9a3e79235 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -0,0 +1,153 @@ +/* + * 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.rdf; + + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; + +import org.apache.jena.riot.RDFLanguages; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import java.io.IOException; + +@RunWith(JUnitParamsRunner.class) +public class ParserTest { + + @Test + public void parseAasEnvironmentTest() throws IOException, DeserializationException { + String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); + Environment aasEnv = new Serializer().read(aasEnvAsString); + Assert.assertEquals(1, aasEnv.getSubmodels().size()); + Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); + Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); + + Assert.assertEquals("de", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(0).getLanguage()); + Assert.assertEquals("en", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(1).getLanguage()); + Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); + + } + + @Test + @Ignore + public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { + String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); + Environment environment = new Serializer().read(aasEnvAsString); + + // TODO continue providing a correct AASFull Turtle representation + // TODO test for LangStrings + Assert.assertEquals(AASFull.ENVIRONMENT, environment); + } + + + @Test + @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", + "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) + public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + + AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); + } + + @Test + @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) + public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + + AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); + } + + @Test + @Parameters({"Submodel_SubmodelElement_Example.ttl"}) + public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { + Serializer serializer = new Serializer(); + //These work + + Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); + + Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); + + + //The following examples do not work yet, as they are semantically problematic + //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); + //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); + } + + + + + @Test + public void deserializeConceptDescription() throws IOException, DeserializationException { + String conceptDescription = "{\n" + + " \"@context\" : {\n" + + " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + + " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + + " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + + " },\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + + " \"@type\" : \"aas:ConceptDescription\",\n" + + " \"isCaseOf\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + + " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + + " \"@type\" : \"aas:Reference\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + + " \"@type\" : \"aas:Key\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + + " } ]\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + + " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + + " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + + " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + + " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + + " },\n" + + " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + + " } ]\n" + + "}"; + + Serializer serializer = new Serializer(); + ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); + + Assert.assertNotNull(c); + } + + +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java new file mode 100644 index 000000000..58da78d90 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -0,0 +1,100 @@ +/* + * 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.rdf; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIEC61360; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class SerializerTest { + + //TODO: Optional: Prefixes instead of full URIs + //TODO: Optional: Do not serialize empty collections + + @Test + public void serializeEnvironment() throws IOException, DeserializationException { + + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .build()) + .description(Arrays.asList(new DefaultLangString.Builder().text("This is a test AAS").language("en-us").build())) + .displayName(Arrays.asList( + new DefaultLangString.Builder().text("Anzeigename 2").language("de").build(), + new DefaultLangString.Builder().text("Display Name 1").language("en").build() + )) + .build(); + + Submodel submodel = new DefaultSubmodel.Builder() + .description(Arrays.asList(new DefaultLangString.Builder().text("My Submodel").language("en-us").build())) + .displayName(Arrays.asList( + new DefaultLangString.Builder().text("First Submodel Element name").language("en").build(), + new DefaultLangString.Builder().text("Second Submodel Element name").language("en").build() + )) + .category("Example category") + .build(); + + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .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 Serializer().serialize(aasEnv, RDFLanguages.JSONLD); + //System.out.println(output); + + Assert.assertTrue(output.contains("@context")); + // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? + Assert.assertTrue(output.contains("\"@type\" : \"aas:Environment\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:AssetAdministrationShell\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:Submodel\"")); + Assert.assertTrue(output.contains("\"@type\" : \"aas:ConceptDescription\"")); + + Environment environment = new Serializer().deserialize(output, Environment.class); + Assert.assertNotNull(environment); + + // Assert.assertTrue(aasEnv.equals(environment)); // TODO: Serialising and parsing to/from RDF looses the sequence of e.g. LangStrings, therefore this test fails also for semantically equal objects + } +} 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..e970d8e9f --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java @@ -0,0 +1,45 @@ +/* + * 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.rdf; + + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; + +import org.apache.commons.io.IOUtils; + +/** + * Helper class for Serializer Tests + * + * @author sbader + * + */ +public class SerializerUtil { + + public static String readResourceToString(String resourceName) throws IOException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream is = classloader.getResourceAsStream(resourceName); + StringWriter writer = new StringWriter(); + IOUtils.copy(is, writer, "UTF-8"); + return writer.toString(); + } + + public static String stripWhitespaces(String input) { + return input.replaceAll("\\s+", ""); + } + +} diff --git a/dataformat-rdf/src/test/resources/AASFull.ttl b/dataformat-rdf/src/test/resources/AASFull.ttl new file mode 100644 index 000000000..8c11c4546 --- /dev/null +++ b/dataformat-rdf/src/test/resources/AASFull.ttl @@ -0,0 +1,354 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + +# AAS Environment + rdf:type aas:Environment ; + ; + ; + ; +. + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "MaxRotationSpeed"^^xs:string ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "PARAMETER"^^xs:string ; + "0173-1#02-BAA120#008"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Max. rotation speed"@en, "max. Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; + . + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "RotationSpeed"^^xs:string ; + rdfs:label "RotationSpeed"^^xs:string ; + "PROPERTY"^^xs:string ; + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] . + + rdf:type aas:DataSpecificationIEC61360 ; + "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Document"^^xs:string ; + rdfs:label "Document"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Document"@en, "Dokument"@de ; + "Document"@en ; + "[ISO 15519-1:2010]"^^xs:string ; + ; + "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Title"^^xs:string ; + rdfs:label "Title"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; + . + + rdf:type aas:DataSpecificationIEC61360 ; + "Titel"@en, "Titel"@de ; + "Titel"@en ; + ; + "Sprachabhängiger Titel des Dokuments."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "DigitalFile"^^xs:string ; + rdfs:label "DigitalFile"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + + rdf:type aas:DataSpecificationIEC61360 ; + "Digital File"@en ; + "DigitalFile"@en ; + ; + "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt new file mode 100644 index 000000000..65b752bdc --- /dev/null +++ b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt @@ -0,0 +1,16 @@ + . + "ExampleMotor"^^ . + "ExampleMotor"^^ . + "A very short description of the AAS instance"@en . + "A very short description of the AAS instance."^^ . + "https://customer.com/aas/9175_7013_7091_9168"^^ . + _:AssetInformation . +_:AssetInformation . +_:AssetInformation _:GlobalAssetId . +_:AssetInformation . +_:GlobalAssetId . +_:GlobalAssetId . +_:GlobalAssetId _:Key . +_:Key . +_:Key . +_:Key "https://customer.com/assets/KHBVZJSQKIY"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl new file mode 100644 index 000000000..e22b250fd --- /dev/null +++ b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl @@ -0,0 +1,27 @@ +@prefix : . +@prefix aas: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; +. diff --git a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl new file mode 100644 index 000000000..e5f25bfe6 --- /dev/null +++ b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl @@ -0,0 +1,56 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Complete_Example.ttl b/dataformat-rdf/src/test/resources/Complete_Example.ttl new file mode 100644 index 000000000..0c800f8d1 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Complete_Example.ttl @@ -0,0 +1,347 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + +# Asset Administration Shell + rdf:type aas:AssetAdministrationShell ; + "ExampleMotor"^^xs:string ; + rdfs:label "ExampleMotor"^^xs:string ; + "A very short description of the AAS instance"@en ; + rdfs:comment "A very short description of the AAS instance."^^xs:string ; + "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; + [ + rdf:type ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] ; + ] ; + ; + ]; + + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ] + ]; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; + ] + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "MaxRotationSpeed"^^xs:string ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "PARAMETER"^^xs:string ; + "0173-1#02-BAA120#008"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Max. rotation speed"@en, "max. Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; + . + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "RotationSpeed"^^xs:string ; + rdfs:label "RotationSpeed"^^xs:string ; + "PROPERTY"^^xs:string ; + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] . + + rdf:type aas:DataSpecificationIEC61360 ; + "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; + "1/min"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#05-AAA650#002"^^xs:string ; + ] ; + ] ; + ; + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; +. + + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Document"^^xs:string ; + rdfs:label "Document"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + rdf:type aas:DataSpecificationIEC61360 ; + "Document"@en, "Dokument"@de ; + "Document"@en ; + "[ISO 15519-1:2010]"^^xs:string ; + ; + "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "Title"^^xs:string ; + rdfs:label "Title"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; + . + + rdf:type aas:DataSpecificationIEC61360 ; + "Titel"@en, "Titel"@de ; + "Titel"@en ; + ; + "Sprachabhängiger Titel des Dokuments."@de ; +. + +# ConceptDescription + rdf:type aas:ConceptDescription ; + "DigitalFile"^^xs:string ; + rdfs:label "DigitalFile"^^xs:string ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; + [ + rdf:type aas:EmbeddedDataSpecification ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; + ] ; + ] ; + ; + ] ; +. + + + rdf:type aas:DataSpecificationIEC61360 ; + "Digital File"@en ; + "DigitalFile"@en ; + ; + "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Overall-Example.nt b/dataformat-rdf/src/test/resources/Overall-Example.nt new file mode 100644 index 000000000..3921c9aff --- /dev/null +++ b/dataformat-rdf/src/test/resources/Overall-Example.nt @@ -0,0 +1,253 @@ + . + "ExampleMotor"^^ . + "ExampleMotor"^^ . + "A very short description of the AAS instance"@en . + "A very short description of the AAS instance."^^ . + "https://customer.com/aas/9175_7013_7091_9168"^^ . + _:AssetInformation . + _:Submodel1 . + _:Submodel2 . + _:Submodel3 . +_:AssetInformation . +_:AssetInformation _:GlobalAssetId1 . +_:AssetInformation . +_:GlobalAssetId1 . +_:GlobalAssetId1 . +_:GlobalAssetId1 _:Key1 . +_:Key1 . +_:Key1 . +_:Key1 "https://customer.com/assets/KHBVZJSQKIY"^^ . +_:Submodel1 . +_:Submodel1 . +_:Submodel1 _:Key2 . +_:Key2 . +_:Key2 . +_:Key2 "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . +_:Submodel2 . +_:Submodel2 . +_:Submodel2 _:Key3 . +_:Key3 . +_:Key3 . +_:Key3 "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . +_:Submodel3 . +_:Submodel3 . +_:Submodel3 _:Key4 . +_:Key4 . +_:Key4 . +_:Key4 "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^ . + . + "TechnicalData"^^ . + "TechnicalData"^^ . + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . + . + _:SemanticId1 . + _:SubmodelElement1 . +_:SemanticId1 . +_:SemanticId1 . +_:SemanticId1 _:Key5 . +_:Key5 . +_:Key5 . +_:Key5 "0173-1#01-AFZ615#016"^^ . +_:SubmodelElement1 . +_:SubmodelElement1 "MaxRotationSpeed"^^ . +_:SubmodelElement1 "MaxRotationSpeed"^^ . +_:SubmodelElement1 . +_:SubmodelElement1 _:ValueId1 . +_:SubmodelElement1 "5000"^^ . +_:ValueId1 . +_:ValueId1 . +_:ValueId1 _:Key6 . +_:Key6 . +_:Key6 . +_:Key6 "0173-1#02-BAA120#008"^^ . + . + "OperationalData"^^ . + "OperationalData"^^ . + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . + . + _:SubmodelElement2 . +_:SubmodelElement2 . +_:SubmodelElement2 "RotationSpeed"^^ . +_:SubmodelElement2 "RotationSpeed"^^ . +_:SubmodelElement2 . +_:SubmodelElement2 . +_:SubmodelElement2 _:ValueId2 . +_:SubmodelElement2 "4370"^^ . +_:ValueId2 . +_:ValueId2 . +_:ValueId2 _:Key7 . +_:Key7 . +_:Key7 . +_:Key7 "http://customer.com/cd/1/1/18EBD56F6B43D895"^^ . + . + "Documentation"^^ . + "Documentation"^^ . + " . + . + _:SubmodelElement3 . +_:SubmodelElement3 . +_:SubmodelElement3 "OperatingManual"^^ . +_:SubmodelElement3 "OperatingManual"^^ . +_:SubmodelElement3 _:SemanticIdListElement1 . +_:SubmodelElement3 . +_:SubmodelElement3 _:Value1 . +_:SubmodelElement3 _:Value3 . +_:SubmodelElement3 . +_:SemanticIdListElement1 . +_:SemanticIdListElement1 . +_:SemanticIdListElement1 _:Key8 . +_:Key8 . +_:Key8 . +_:Key8 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . +_:Value1 . +_:Value1 _:Value2 . +_:Value2 . +_:Value2 . +_:Value2 "Title"^^ . +_:Value2 "application/pdf" . +_:Value2 "file:///aas/OperatingManual.pdf"^^ . +_:Value2 "Title"^^ . +_:Value2 "CONSTANT"^^ . +_:Value2 _:SemanticId2 . +_:Value2 . +_:SemanticId2 . +_:SemanticId2 . +_:SemanticId2 _:Key9 . +_:Key9 . +_:Key9 . +_:Key9 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . +_:Value3 . +_:Value3 _:Value4 . +_:Value4 . +_:Value4 . +_:Value4 "DigitalFile_PDF"^^ . +_:Value4 "application/pdf" . +_:Value4 "file:///aasx/OperatingManual.pdf"^^ . +_:Value4 "DigitalFile_PDF"^^ . +_:Value4 "CONSTANT"^^ . +_:Value4 _:SemanticId3. +_:Value4 . +_:SemanticId3 . +_:SemanticId3 . +_:SemanticId3 _:Key10 . +_:Key10 . +_:Key10 . +_:Key10 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^ . + . + "MaxRotationSpeed"^^ . + "MaxRotationSpeed"^^ . + "PARAMETER"^^ . + "0173-1#02-BAA120#008"^^ . + _:EmbeddedDataSpecification1 . +_:EmbeddedDataSpecification1 . +_:EmbeddedDataSpecification1 _:DataSpecification1 . +_:EmbeddedDataSpecification1 . +_:DataSpecification1 . +_:DataSpecification1 . +_:DataSpecification1 _:Key11 . +_:Key11 . +_:Key11 . +_:Key11 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Max. rotation speed"@en . + "max. Drehzahl"@de . + "1/min"^^ . + _:UnitId1 . + . + "H\u00F6chste zul\u00E4ssige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de . + "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en . +_:UnitId1 . +_:UnitId1 . +_:UnitId1 _:Key12 . +_:Key12 . +_:Key12 . +_:Key12 "0173-1#05-AAA650#002"^^ . + . + "RotationSpeed"^^ . + "RotationSpeed"^^ . + "PROPERTY"^^ . + "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^ . + _:EmbeddedDataSpecification2 . +_:EmbeddedDataSpecification2 . +_:EmbeddedDataSpecification2 _:DataSpecification2 . +_:EmbeddedDataSpecification2 . +_:DataSpecification2 . +_:DataSpecification2 . +_:DataSpecification2 _:Key13 . +_:Key13 . +_:Key13 . +_:Key13 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Actual rotation speed"@en . + "Aktuelle Drehzahl"@de . + "1/min"^^ . + _:UnitId2 . + . + "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de . + "Actual rotation speed with which the motor or feeding unit is operated."@en . +_:UnitId2 . +_:UnitId2 . +_:UnitId2 _:Key14 . +_:Key14 . +_:Key14 . +_:Key14 "0173-1#05-AAA650#002"^^ . + . + "Document"^^ . + "Document"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . + _:EmbeddedDataSpecification3 . +_:EmbeddedDataSpecification3 . +_:EmbeddedDataSpecification3 _:DataSpecification3 . +_:EmbeddedDataSpecification3 . +_:DataSpecification3 . +_:DataSpecification3 . +_:DataSpecification3 _:Key15 . +_:Key15 . +_:Key15 . +_:Key15 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Document"@en . + "Dokument"@de . + "Document"@en . + "[ISO 15519-1:2010]"^^ . + . + "Feste und geordnete Menge von f\u00FCr die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de . + . + "Title"^^ . + "Title"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . + _:EmbeddedDataSpecification4 . +_:EmbeddedDataSpecification4 . +_:EmbeddedDataSpecification4 _:DataSpecification4 . +_:EmbeddedDataSpecification4 . +_:DataSpecification4 . +_:DataSpecification4 . +_:DataSpecification4 _:Key16 . +_:Key16 . +_:Key16 . +_:Key16 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Titel"@en . + "Titel"@de . + "Titel"@en . + . + "Sprachabh\u00E4ngiger Titel des Dokuments."@de . + . + "DigitalFile"^^ . + "DigitalFile"^^ . + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^ . + _:EmbeddedDataSpecification5 . +_:EmbeddedDataSpecification5 . +_:EmbeddedDataSpecification5 _:DataSpecification5 . +_:EmbeddedDataSpecification5 . +_:DataSpecification5 . +_:DataSpecification5 . +_:DataSpecification5 _:Key17 . +_:Key17 . +_:Key17 . +_:Key17 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . + . + "Digital File"@en . + "DigitalFile"@en . + . + "Eine Datei, die die DocumentVersion repr\u00E4sentiert. Neben der obligatorischen PDF/A Datei k\u00F6nnen weitere Dateien angegeben werden."@de . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/ReferenceExample.ttl b/dataformat-rdf/src/test/resources/ReferenceExample.ttl new file mode 100644 index 000000000..a18db83e5 --- /dev/null +++ b/dataformat-rdf/src/test/resources/ReferenceExample.ttl @@ -0,0 +1,18 @@ +@prefix xs: . + +# 1) Reference with KeyElements + a ; + [ + a ; + ; + [ + a ; + ; + [ + a ; + ; + "http://customer.com/assets/KHBVZJSQKIY"^^xs:string ; + ] + ] + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl new file mode 100644 index 000000000..3e50807d6 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl @@ -0,0 +1,137 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "OperationalData"^^xs:string ; + rdfs:label "OperationalData"^^xs:string ; + "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; + ; + + [ + rdf:type aas:Property ; + rdfs:label "RotationSpeed"^^xs:string ; + "RotationSpeed"^^xs:string ; + ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; + ] + + ]; + "4370"^^xs:string ; + ]; +. + +# Submodel + rdf:type aas:Submodel ; + "Documentation"^^xs:string ; + rdfs:label "Documentation"^^xs:string ; + " ; + [ + rdf:type aas:SubmodelElementList ; + "OperatingManual"^^xs:string ; + rdfs:label "OperatingManual"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; + ] + ] ; + ; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type ; + rdf:subject ; + rdfs:label "Title"^^xs:string ; + "application/pdf" ; + "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO + "Title"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; + ] + ] ; + ; + ] + ]; + [ + rdf:type aas:SubmodelElementCollection ; + [ + rdf:type aas:File; + rdf:subject ; + rdfs:label "DigitalFile_PDF"^^xs:string ; + "application/pdf" ; + "file:///aasx/OperatingManual.pdf"^^xs:string ; + "DigitalFile_PDF"^^xs:string ; + "CONSTANT"^^xs:string ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; + ] + ] ; + ; + ]; + ] ; + ; + ] ; +. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt new file mode 100644 index 000000000..2733f1131 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt @@ -0,0 +1,25 @@ + . + "TechnicalData"^^ . + "TechnicalData"^^ . + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . + . + _:SemanticId . + _:SubmodelElements . +_:SemanticId . +_:SemanticId . +_:SemanticId _:Key1 . +_:Key1 . +_:Key1 . +_:Key1 "0173-1#01-AFZ615#016"^^ . +_:SubmodelElements . +_:SubmodelElements "MaxRotationSpeed"^^ . +_:SubmodelElements "MaxRotationSpeed"^^ . +_:SubmodelElements . +_:SubmodelElements _:ValueId . +_:SubmodelElements "5000"^^ . +_:ValueId . +_:ValueId . +_:ValueId _:Key2 . +_:Key2 . +_:Key2 . +_:Key2 "0173-1#02-BAA120#008"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl new file mode 100644 index 000000000..9c1d7f8c4 --- /dev/null +++ b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl @@ -0,0 +1,42 @@ +@prefix aas: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix xs: . + + + +# Submodel + rdf:type aas:Submodel ; + "TechnicalData"^^xs:string ; + rdfs:label "TechnicalData"^^xs:string ; + "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#01-AFZ615#016"^^xs:string ; + ] ; + ] ; + + + [ + rdf:type aas:Property ; + rdfs:label "MaxRotationSpeed"^^xs:string ; + "MaxRotationSpeed"^^xs:string ; + ; + [ + rdf:type aas:Reference ; + ; + [ + rdf:type aas:Key ; + ; + "0173-1#02-BAA120#008"^^xs:string ; + ] ; + ]; + "5000"^^xs:string ; + ]; +. diff --git a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld new file mode 100644 index 000000000..7eac7fa6c --- /dev/null +++ b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld @@ -0,0 +1,88 @@ +{ + "@context" : { + "aas" : "https://admin-shell.io/aas/3/0/RC02/" + }, + "@id" : "https://admin-shell.io/autogen/DefaultEnvironment/7e646a58-7419-41e2-99e8-163a7abb7b46", + "@type" : "aas:Environment", + "https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultAssetAdministrationShell/b869a629-8d69-4754-9c50-804b0e9eb35a", + "@type" : "aas:AssetAdministrationShell", + "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation" : { + "@id" : "https://admin-shell.io/autogen/DefaultAssetInformation/6882a093-6831-445d-a884-f2ebc37aaa29", + "@type" : "aas:AssetInformation", + "https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind" : { + "@type" : "aas:AssetKind", + "@id" : "https://admin-shell.io/aas/3/0/RC02/AssetKind/Instance" + }, + "https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds" : [ ] + }, + "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { + "@language" : "en-us", + "@value" : "This is a test AAS" + } ], + "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { + "@language" : "de", + "@value" : "Anzeigename 2" + }, { + "@language" : "en", + "@value" : "Display Name 1" + } ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] + } ], + "https://admin-shell.io/aas/3/0/RC02/Environment/conceptdescriptions" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultConceptDescription/14b4a819-7ca0-4cb2-b2c7-33a1c443c899", + "@type" : "aas:ConceptDescription", + "https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultDataSpecification/66cf9a6c-e656-4c95-91be-2ddc1779ec71", + "@type" : "aas:EmbeddedDataSpecification", + "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation" : { + "@id" : "https://admin-shell.io/autogen/DefaultReference/251d9f19-b36b-4c39-b517-3d7e93bd8c96", + "@type" : "aas:Reference", + "https://admin-shell.io/aas/3/0/RC02/Reference/key" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultKey/ad4e8527-e002-4776-87ca-7049e7be440f", + "@type" : "aas:Key", + "https://admin-shell.io/aas/3/0/RC02/Key/value" : "https://example.org" + } ] + } , + "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent" : { + "@id" : "https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/5319d62e-7ca1-4954-addf-76db6bf1e241", + "@type" : "aas:DataSpecificationIEC61360", + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType" : { + "@type" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/DataTypeIEC61360", + "@id" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/RATIONAL" + }, + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition" : [ ], + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName" : [ ], + "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName" : [ ] + }, + "https://admin-shell.io/aas/3/0/RC02/DataSpecification/id" : "http://example.org/DataSpecification1" + } ] + } ], + "https://admin-shell.io/aas/3/0/RC02/Environment/submodels" : [ { + "@id" : "https://admin-shell.io/autogen/DefaultSubmodel/18810336-c309-42f8-9986-438f7068f0d6", + "@type" : "aas:Submodel", + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier" : [ ], + "https://admin-shell.io/aas/3/0/RC02/Referable/category" : "Example category", + "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { + "@language" : "en-us", + "@value" : "My Submodel" + } ], + "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { + "@language" : "en", + "@value" : "First Submodel Element name" + }, { + "@language" : "en", + "@value" : "Second Submodel Element name" + } ], + "https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement" : [ ], + "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] + } ] +} \ No newline at end of file From 2f242ec9f03204fb6c12b22d0226fc2b446448b5 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 17:08:41 +0100 Subject: [PATCH 126/160] Add rdf module to pom.xml and bump jena version --- .../core/internal/util/ReflectionHelper.java | 914 ++++++------- .../v3/dataformat/core/util/AasUtils.java | 876 ++++++------- .../v3/dataformat/core/util/AasUtilsTest.java | 1134 ++++++++--------- .../v3/dataformat/json/JsonDeserializer.java | 388 +++--- .../v3/dataformat/json/JsonSerializer.java | 336 ++--- .../DataSpecificationIec61360Mixin.java | 54 +- .../internal/mixins/IdentifiableMixin.java | 46 +- dataformat-rdf/pom.xml | 9 +- .../EmbeddedDataSpecificationMixin.java | 90 +- pom.xml | 1 + 10 files changed, 1926 insertions(+), 1922 deletions(-) diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java index b571972c7..a05faff9e 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/ReflectionHelper.java @@ -1,457 +1,457 @@ -/* - * 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; - } -} +/* + * 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 22ffd8272..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,438 +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.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; - } - -} +/* + * 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/util/AasUtilsTest.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java index 6ea6e25cc..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,567 +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 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(); - } -} +/* + * 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 de24180aa..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.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); - } - } +/* + * 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/JsonSerializer.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializer.java index 3ffa080b8..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.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); - } +/* + * 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/internal/mixins/DataSpecificationIec61360Mixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/DataSpecificationIec61360Mixin.java index f1766b2a8..02f044946 100644 --- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/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.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(); -} +/* + * 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/internal/mixins/IdentifiableMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/mixins/IdentifiableMixin.java index dcf651251..298648d59 100644 --- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/internal/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.internal.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-rdf/pom.xml b/dataformat-rdf/pom.xml index 8d65df6de..0de21eabc 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -31,14 +31,17 @@ org.slf4j - slf4j-simple - ${slf4j.version} + slf4j-api test pl.pragmatists JUnitParams - ${junit-params.version} + test + + + junit + junit test diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java index 949e03d1e..971d0d7ce 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/internal/mixins/EmbeddedDataSpecificationMixin.java @@ -1,46 +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.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); - +/* + * 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/pom.xml b/pom.xml index 477d46aa7..b4106a45f 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ dataformat-core dataformat-json dataformat-xml + dataformat-rdf 1 From 33abeac8821eb618b2c7a664f4c1899e20e3b9b3 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 19:00:41 +0100 Subject: [PATCH 127/160] Fix compile issues Serializer produce output. Deserializer can't handle LangStrings --- dataformat-rdf/pom.xml | 1 - .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 4 +- .../v3/dataformat/rdf/JsonLDSerializer.java | 4 +- .../dataformat/rdf/LangStringSerializer.java | 6 +- .../aas4j/v3/dataformat/rdf/Parser.java | 48 ++++---- .../aas4j/v3/dataformat/rdf/Serializer.java | 90 ++++++--------- .../AdministrativeInformationMixin.java | 8 +- .../AnnotatedRelationshipElementMixin.java | 4 +- .../mixins/AssetAdministrationShellMixin.java | 12 +- .../rdf/mixins/AssetInformationMixin.java | 20 ++-- .../rdf/mixins/BasicEventElementMixin.java | 32 +++--- .../v3/dataformat/rdf/mixins/BlobMixin.java | 8 +- .../rdf/mixins/ConceptDescriptionMixin.java | 4 +- .../mixins/DataSpecificationContentMixin.java | 5 +- .../DataSpecificationIEC61360Mixin.java | 106 ------------------ .../DataSpecificationIec61360Mixin.java | 106 ++++++++++++++++++ .../DataSpecificationPhysicalUnitMixin.java | 99 ---------------- .../EmbeddedDataSpecificationMixin.java | 16 ++- .../v3/dataformat/rdf/mixins/EntityMixin.java | 16 +-- .../rdf/mixins/EnvironmentMixin.java | 12 +- .../dataformat/rdf/mixins/ExtensionMixin.java | 16 +-- .../v3/dataformat/rdf/mixins/FileMixin.java | 8 +- .../dataformat/rdf/mixins/FormulaMixin.java | 4 +- .../rdf/mixins/HasDataSpecificationMixin.java | 8 +- .../rdf/mixins/HasExtensionsMixin.java | 4 +- .../dataformat/rdf/mixins/HasKindMixin.java | 10 +- .../rdf/mixins/HasSemanticsMixin.java | 8 +- .../rdf/mixins/IdentifiableMixin.java | 8 +- .../mixins/IdentifierKeyValuePairMixin.java | 12 +- .../rdf/mixins/IdentifierMixin.java | 4 +- .../v3/dataformat/rdf/mixins/KeyMixin.java | 8 +- .../mixins/MultiLanguagePropertyMixin.java | 14 +-- .../rdf/mixins/ObjectAttributesMixin.java | 4 +- .../dataformat/rdf/mixins/OperationMixin.java | 12 +- .../rdf/mixins/OperationVariableMixin.java | 4 +- .../rdf/mixins/PolicyDecisionPointMixin.java | 4 +- .../mixins/PolicyEnforcementPointsMixin.java | 4 +- .../mixins/PolicyInformationPointsMixin.java | 8 +- .../dataformat/rdf/mixins/PropertyMixin.java | 12 +- .../rdf/mixins/QualifiableMixin.java | 4 +- .../dataformat/rdf/mixins/QualifierMixin.java | 16 +-- .../v3/dataformat/rdf/mixins/RangeMixin.java | 12 +- .../dataformat/rdf/mixins/ReferableMixin.java | 27 ++--- .../rdf/mixins/ReferenceElementMixin.java | 4 +- .../dataformat/rdf/mixins/ReferenceMixin.java | 8 +- .../rdf/mixins/RelationshipElementMixin.java | 8 +- .../dataformat/rdf/mixins/ResourceMixin.java | 8 +- .../rdf/mixins/SpecificAssetIdMixin.java | 12 +- .../rdf/mixins/SubjectAttributesMixin.java | 4 +- .../SubmodelElementCollectionMixin.java | 12 +- .../rdf/mixins/SubmodelElementListMixin.java | 20 ++-- .../dataformat/rdf/mixins/SubmodelMixin.java | 4 +- .../dataformat/rdf/mixins/ValueListMixin.java | 4 +- .../rdf/mixins/ValueReferencePairMixin.java | 8 +- .../v3/dataformat/rdf/mixins/ViewMixin.java | 4 +- .../v3/dataformat/rdf/SerializerTest.java | 25 ++--- 56 files changed, 406 insertions(+), 527 deletions(-) delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index 0de21eabc..bd72cb847 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -32,7 +32,6 @@ org.slf4j slf4j-api - test pl.pragmatists diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java index b5a790d60..0f403a1d7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java @@ -20,7 +20,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; import java.math.BigDecimal; import java.net.URI; @@ -46,7 +46,7 @@ public JsonLDModule(Map idMap) { addSerializer(BigDecimal.class, new BigDecimalSerializer()); addSerializer(URI.class, new UriSerializer()); - addSerializer(LangString.class, new LangStringSerializer()); + addSerializer(AbstractLangString.class, new LangStringSerializer()); } } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java index 853fe1847..5c28c71c3 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java @@ -95,8 +95,8 @@ public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider private void filterContextWrtBean(Object bean, Map filteredContext) { //Some default entries for AAS - filteredContext.put("aas", "https://admin-shell.io/aas/3/0/RC02/"); - //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + filteredContext.put("aas", "https://admin-shell.io/aas/3/0/"); + //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java index e90100562..cdd3409db 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; -public class LangStringSerializer extends StdSerializer { +public class LangStringSerializer extends StdSerializer { public LangStringSerializer() { @@ -36,7 +36,7 @@ public LangStringSerializer(Class clazz) { @Override - public void serialize(LangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AbstractLangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeStartObject(); if(value.getLanguage() != null && !value.getLanguage().isEmpty()) { diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java index c995160e5..cc6434777 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java @@ -15,10 +15,9 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangString; import org.apache.jena.datatypes.DatatypeFormatException; import org.apache.jena.query.*; import org.apache.jena.rdf.model.*; @@ -72,6 +71,7 @@ class Parser { * @throws IOException thrown if the parsing fails */ private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { + try { //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on @@ -321,7 +321,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Query for all unknown properties and their values //Select properties and values only - if(!targetClass.equals(LangString.class)) { //LangString has no additional properties map. Skip this step + if(!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } for (Map.Entry entry : knownNamespaces.entrySet()) { @@ -657,20 +657,25 @@ private String wrapIfUri(String input) } private Object handleForeignLiteral(Literal literal) throws URISyntaxException { - if(literal.getLanguage() != null && !literal.getLanguage().equals("")) - { - return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); - } +// // TODO: LangTag is not native +// START +// if(literal.getLanguage() != null && !literal.getLanguage().equals("")) +// { +// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); +// } +// +// else +// { +// return literal.getString(); +// } +// END //If not, does it have some datatype URI? //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) //{ // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); //} //If both is not true, add it as normal string - else - { - return literal.getString(); - } + return literal.getString(); } private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { @@ -866,14 +871,17 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur } } - //TypedLiteral - if (LangString.class.isAssignableFrom(currentType)) { - //Either a language tagged string OR literal with type. Only one allowed - if (!literal.getLanguage().equals("")) { - return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); - } - return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag - } +// // TODO: Abstract lan is no longer native type +// START +// //TypedLiteral +// if (LangString.class.isAssignableFrom(currentType)) { +// //Either a language tagged string OR literal with type. Only one allowed +// if (!literal.getLanguage().equals("")) { +// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); +// } +// return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag +// } +// END //BigInteger if (BigInteger.class.isAssignableFrom(currentType)) { @@ -957,7 +965,7 @@ private boolean isPrimitive(Class input) throws IOException { return (URI.class.isAssignableFrom(input) || String.class.isAssignableFrom(input) || XMLGregorianCalendar.class.isAssignableFrom(input) || - LangString.class.isAssignableFrom(input) || + AbstractLangString.class.isAssignableFrom(input) || BigInteger.class.isAssignableFrom(input) || BigDecimal.class.isAssignableFrom(input) || byte[].class.isAssignableFrom(input) || diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java index b18f0567d..375e4b82f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java @@ -23,7 +23,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.Deserializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; @@ -40,18 +39,15 @@ import java.nio.charset.StandardCharsets; import java.util.*; -public class Serializer implements org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer, Deserializer { +public class Serializer { private static final ObjectMapper mapper = new ObjectMapper(); - private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(Serializer.class); - public static String implementingClassesNamePrefix = "Default"; public static String implementingClassesNameSuffix = ""; - static Map, Class> customImplementationMap = new HashMap<>(); - private static boolean charsetWarningPrinted = false; + private final List preprocessors; + private final Logger logger = LoggerFactory.getLogger(Serializer.class); public Serializer() { mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); @@ -61,8 +57,7 @@ public Serializer() { preprocessors = new ArrayList<>(); this.addPreprocessor(new TypeNamePreprocessor()); - if(!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) - { + if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) { charsetWarningPrinted = true; logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); } @@ -71,12 +66,23 @@ public Serializer() { addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/RC02/"); - //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/"); + addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/"); + //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); } + /** + * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". + * + * @param prefix Prefix to be added + * @param namespaceUrl URL of the prefix + */ + public static void addKnownNamespace(String prefix, String namespaceUrl) { + Parser.knownNamespaces.put(prefix, namespaceUrl); + JsonLDSerializer.contextItems.put(prefix, namespaceUrl); + } + /** * Serializes an object to an RDF representation. In order to support RDF, the input instance must be * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). @@ -94,15 +100,14 @@ public String serialize(Object instance) throws IOException { * input instance must be annotated using AAS Metamodel annotations. * * @param instance the instance to be serialized - * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) + * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) * @return RDF serialization of the provided object graph * @throws IOException if the serialization fails */ public synchronized String serialize(Object instance, Lang format) throws IOException { - return serialize(instance, format, new HashMap<>() ); + return serialize(instance, format, new HashMap<>()); } - //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { @@ -164,9 +169,7 @@ public String serializePlainJson(Object instance) throws JsonProcessingException public T deserialize(String serialization, Class valueType) throws DeserializationException { try { return new Parser().parseMessage(serialization, valueType); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } @@ -174,10 +177,10 @@ public T deserialize(String serialization, Class valueType) throws Deseri /** * Inverse method of "serialize" * - * @param serialization JSON(-LD) string - * @param valueType class of top level type + * @param serialization JSON(-LD) string + * @param valueType class of top level type * @param serializationFormat RDF input format - * @param deserialized type + * @param deserialized type * @return an object representing the provided JSON(-LD) structure * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF */ @@ -185,9 +188,7 @@ public T deserialize(String serialization, Class valueType, Lang serializ try { return new Parser().parseMessage(serialization, valueType, serializationFormat); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } @@ -195,33 +196,20 @@ public T deserialize(String serialization, Class valueType, Lang serializ /** * Inverse method of "serialize" * - * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes - * @param valueType class of top level type - * @param deserialized type + * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes + * @param valueType class of top level type + * @param deserialized type * @return an object representing the provided JSON(-LD) structure * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF */ public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { try { return new Parser().parseMessage(rdfModel, valueType); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Failed to deserialize input.", e); } } - /** - * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". - * @param prefix Prefix to be added - * @param namespaceUrl URL of the prefix - */ - public static void addKnownNamespace(String prefix, String namespaceUrl) - { - Parser.knownNamespaces.put(prefix, namespaceUrl); - JsonLDSerializer.contextItems.put(prefix, namespaceUrl); - } - /** * Method to add a preprocessor for deserialization. *

@@ -255,13 +243,11 @@ public void removePreprocessor(JsonPreprocessor preprocessor) { preprocessors.remove(preprocessor); } - @Override + public String write(Environment aasEnvironment) throws SerializationException { try { return serialize(aasEnvironment); - } - catch (IOException e) - { + } catch (IOException e) { throw new SerializationException("Failed to serialize environment.", e); } } @@ -273,19 +259,15 @@ public String write(Environment aasEnvironment, Lang format) throws Serializatio public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { try { return serialize(aasEnvironment, format, idMap); - } - catch (IOException e) - { + } catch (IOException e) { throw new SerializationException("Failed to serialize environment.", e); } } - @Override + public Environment read(String value) throws DeserializationException { try { return new Parser().parseMessage(value, Environment.class); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Could not deserialize to environment.", e); } } @@ -293,14 +275,12 @@ public Environment read(String value) throws DeserializationException { public Environment read(String value, Lang serializationFormat) throws DeserializationException { try { return new Parser().parseMessage(value, Environment.class, serializationFormat); - } - catch (IOException e) - { + } catch (IOException e) { throw new DeserializationException("Could not deserialize to environment.", e); } } - @Override + public void useImplementation(Class aasInterface, Class implementation) { customImplementationMap.put(aasInterface, implementation); //throw new NotImplementedException("Custom implementation support not yet implemented"); diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java index e967dd795..6c692e3c5 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:AdministrativeInformation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") String getVersion(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/version") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") void setVersion(String version); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") String getRevision(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AdministrativeInformation/revision") + @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") void setRevision(String revision); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java index 2b8c30171..63e182fdf 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:AnnotatedRelationshipElement") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") List getAnnotations(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AnnotatedRelationshipElement/annotation") + @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") void setAnnotations(List annotations); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java index 9a49ca42c..31fb53258 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java @@ -26,22 +26,22 @@ @JsonTypeName("aas:AssetAdministrationShell") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") AssetInformation getAssetInformation(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") void setAssetInformation(AssetInformation assetInformation); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") Reference getDerivedFrom(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/derivedFrom") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") void setDerivedFrom(Reference derivedFrom); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") List getSubmodels(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") void setSubmodels(List submodels); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java index 08a7e1715..60040db6a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java @@ -28,33 +28,33 @@ @JsonTypeName("aas:AssetInformation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface AssetInformationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") AssetKind getAssetKind(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") void setAssetKind(AssetKind assetKind); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") Reference getGlobalAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") void setGlobalAssetId(Reference globalAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") List getSpecificAssetIds(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") void setSpecificAssetIds(List specificAssetIds); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") List getBillOfMaterials(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/billOfMaterial") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") void setBillOfMaterials(List billOfMaterials); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") File getDefaultThumbnail(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/AssetInformation/defaultThumbnail") + @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") void setDefaultThumbnail(File defaultThumbnail); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java index 803e6c037..6526e3db3 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java @@ -28,52 +28,52 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface BasicEventElementMixin extends EventElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") Direction getDirection(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/direction") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") void setDirection(Direction direction); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") String getLastUpdate(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/lastUpdate") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") void setLastUpdate(String lastUpdate); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") String getMaxInterval(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/maxInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") void setMaxInterval(String maxInterval); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") Reference getMessageBroker(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageBroker") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") void setMessageBroker(Reference messageBroker); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") String getMessageTopic(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/messageTopic") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") void setMessageTopic(String messageTopic); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") String getMinInterval(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/minInterval") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") void setMinInterval(String minInterval); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") Reference getObserved(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/observed") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") void setObserved(Reference observed); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") StateOfEvent getState(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/BasicEventElement/state") + @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") void setState(StateOfEvent state); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java index 267158c70..b5763be43 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:Blob") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface BlobMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") void setConentType(String mimeType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") byte[] getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Blob/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") void setValue(byte[] value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java index 7cc22006c..3f17da8fa 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:ConceptDescription") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") List getIsCaseOf(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf") + @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") void setIsCaseOf(List isCaseOf); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java index e9d69f2d1..823206ff2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java @@ -15,18 +15,15 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import org.eclipse.digitaltwin.aas4j.v3.model.*; -import java.util.List; - @JsonTypeName("aas:DataSpecificationContent") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") @JsonSubTypes({ - @JsonSubTypes.Type(value = DataSpecificationIEC61360.class) + @JsonSubTypes.Type(value = DataSpecificationIec61360.class) }) public interface DataSpecificationContentMixin { diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java deleted file mode 100644 index 672645918..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIEC61360Mixin.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - -@JsonTypeName("aas:DataSpecificationIEC61360") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationIEC61360Mixin extends DataSpecificationContentMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") - public DataTypeIEC61360 getDataType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType") - public void setDataType(DataTypeIEC61360 dataType); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") - public List getDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition") - public void setDefinitions(List definition); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") - public LevelType getLevelType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/levelType") - public void setLevelType(LevelType levelType); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") - public List getPreferredName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName") - public void setPreferredName(List preferredName); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") - public List getShortName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName") - public void setShortName(List shortName); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") - public String getSourceOfDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/sourceOfDefinition") - public void setSourceOfDefinition(String sourceOfDefinition); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") - public String getSymbol(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/symbol") - public void setSymbol(String symbol); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") - public String getUnit(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unit") - public void setUnit(String unit); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") - public Reference getUnitId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/unitId") - public void setUnitId(Reference unitId); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") - public String getValueFormat(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueFormat") - public void setValueFormat(String valueFormat); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") - public String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/value") - public void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") - public ValueList getValueList(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueList") - public void setValueList(ValueList valueList); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") - public Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/valueId") - public void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java new file mode 100644 index 000000000..4993c0353 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java @@ -0,0 +1,106 @@ +/* + * 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.rdf.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +import java.util.List; + +@JsonTypeName("aas:DataSpecificationIec61360") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") +public interface DataSpecificationIec61360Mixin extends DataSpecificationContentMixin { + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") + public DataTypeIec61360 getDataType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") + public void setDataType(DataTypeIec61360 dataType); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") + public List getDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") + public void setDefinitions(List definition); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") + public LevelType getLevelType(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") + public void setLevelType(LevelType levelType); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") + public List getPreferredName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") + public void setPreferredName(List preferredName); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") + public List getShortName(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") + public void setShortName(List shortName); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") + public String getSourceOfDefinition(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") + public void setSourceOfDefinition(String sourceOfDefinition); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") + public String getSymbol(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") + public void setSymbol(String symbol); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") + public String getUnit(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") + public void setUnit(String unit); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") + public Reference getUnitId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") + public void setUnitId(Reference unitId); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") + public String getValueFormat(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") + public void setValueFormat(String valueFormat); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") + public String getValue(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") + public void setValue(String value); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") + public ValueList getValueList(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") + public void setValueList(ValueList valueList); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") + public Reference getValueId(); + + @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") + public void setValueId(Reference valueId); +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java deleted file mode 100644 index d299d0399..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationPhysicalUnitMixin.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; - -import java.util.List; - -@JsonTypeName("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationPhysicalUnitMixin { - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") - String getConversionFactor(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/conversionFactor") - void setConversionFactor(String conversionFactor); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") - List getDefinitions(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/definition") - void setDefinitions(List definitions); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") - String getDinNotation(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/dinNotation") - void setDinNotation(String dinNotation); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") - String getEceCode(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceCode") - void setEceCode(String eceCode); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") - String getEceName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/eceName") - void setEceName(String eceName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") - String getNistName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/nistName") - void setNistName(String nistName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") - String getSiName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siName") - void setSiName(String siName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") - String getSiNotation(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/siNotation") - void setSiNotation(String siNotation); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") - String getRegistrationAuthorityId(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/registrationAuthorityId") - void setRegistrationAuthorityId(String registrationAuthorityId); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") - String getSupplier(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/supplier") - void setSupplier(String supplier); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") - String getUnitName(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitName") - void setUnitName(String unitName); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") - String getUnitSymbol(); - - @JsonProperty("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/DataSpecificationPhysicalUnit/unitSymbol") - void setUnitSymbol(String unitSymbol); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java index b1fe7ac33..e8f87e544 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java @@ -19,9 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIEC61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; @@ -29,16 +27,16 @@ @JsonTypeName("aas:EmbeddedDataSpecification") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EmbeddedDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") - public DataSpecificationIEC61360 getDataSpecificationContent(); + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") + public DataSpecificationIec61360 getDataSpecificationContent(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent") - public void setDataSpecificationContent(DataSpecificationIEC61360 dataSpecificationContent); + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") + public void setDataSpecificationContent(DataSpecificationIec61360 dataSpecificationContent); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") public Reference getDataSpecification(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecification") + @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") public void setDataSpecification(Reference dataSpecification); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java index 6a2636737..35f7da75d 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java @@ -28,27 +28,27 @@ @JsonTypeName("aas:Entity") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EntityMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") Reference getGlobalAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/globalAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") void setGlobalAssetId(Reference globalAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") SpecificAssetId getSpecificAssetId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/specificAssetId") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") void setSpecificAssetId(SpecificAssetId specificAssetId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") EntityType getEntityType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/entityType") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") void setEntityType(EntityType entityType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") List getStatements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Entity/statement") + @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") void setStatements(List statements); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java index 97a7028be..fb74f5287 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java @@ -27,21 +27,21 @@ @JsonTypeName("aas:Environment") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface EnvironmentMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") List getAssetAdministrationShells(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") void setAssetAdministrationShells(List assetAdministrationShells); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") List getConceptDescriptions(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/conceptDescriptions") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") void setConceptDescriptions(List conceptDescriptions); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") List getSubmodels(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Environment/submodels") + @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") void setSubmodels(List submodels); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java index 62322c3b1..f46030240 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java @@ -24,27 +24,27 @@ @JsonTypeName("aas:Extension") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ExtensionMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") String getName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/name") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") void setName(String name); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") Reference getRefersTo(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Extension/refersTo") + @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") void setRefersTo(Reference refersTo); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java index c4c234413..59fa087ff 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:File") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface FileMixin extends DataElementMixin, SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") void setContentType(String contentType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + @JsonProperty("https://admin-shell.io/aas/3/0/File/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/File/value") + @JsonProperty("https://admin-shell.io/aas/3/0/File/value") void setValue(String value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java index cc5a8707e..cc32cace1 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:Formula") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface FormulaMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") List getDependsOns(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Formula/dependsOn") + @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") void setDependsOns(List dependsOns); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java index b0693d8d6..cd7f1b9c2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java @@ -35,15 +35,15 @@ }) public interface HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") List getDataSpecifications(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiations") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") void setDataSpecifications(List dataSpecifications); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") List getEmbeddedDataSpecifications(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications") + @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") void setEmbeddedDataSpecifications(List embeddedDataSpecifications); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java index 772a10c3e..c7a16a663 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:HasExtensions") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface HasExtensionsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") List getExtensions(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension") + @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") void setExtensions(List extensions); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java index d3f87470a..c8299f52f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ModelingKind; +import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; @@ -31,9 +31,9 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface HasKindMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") - ModelingKind getKind(); + @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") + ModellingKind getKind(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasKind/kind") - void setKind(ModelingKind kind); + @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") + void setKind(ModellingKind kind); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java index a194d33dd..c624b21d7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java @@ -35,15 +35,15 @@ @JsonSubTypes.Type(value = Extension.class) }) public interface HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") Reference getSemanticId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/semanticId") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") void setSemanticId(Reference semanticId); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") List getSupplementalSemanticIds(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds") + @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") void setSupplementalSemanticIds(List references); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java index c9590fd02..80bdfe960 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java @@ -33,15 +33,15 @@ @JsonSubTypes.Type(value = ConceptDescription.class) }) public interface IdentifiableMixin extends ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") AdministrativeInformation getAdministration(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/administration") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") void setAdministration(AdministrativeInformation administration); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") String getId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifiable/id") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") void setId(String id); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java index 7594d6bd0..2298936a8 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:IdentifierKeyValuePair") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") String getKey(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/key") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") void setKey(String key); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") Reference getExternalSubjectId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/IdentifierKeyValuePair/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") void setExternalSubjectId(Reference externalSubjectId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java index 5c30d2b41..25b4258af 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java @@ -23,9 +23,9 @@ @JsonTypeName("aas:Identifier") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface IdentifierMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") String getIdentifier(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Identifier/identifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") void setIdentifier(String identifier); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java index 972dca9a1..66cab3fbc 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java @@ -25,15 +25,15 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface KeyMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") KeyTypes getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") void setType(KeyTypes type); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Key/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") void setValue(String value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java index 71b17e055..1e290609f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import java.util.List; @@ -26,15 +26,15 @@ @JsonTypeName("aas:MultiLanguageProperty") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface MultiLanguagePropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") - List getValues(); + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") + List getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/value") - void setValues(List values); + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") + void setValue(List values); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/MultiLanguageProperty/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java index a91d8f9aa..095bbc8c9 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:ObjectAttributes") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ObjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") List getObjectAttributes(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ObjectAttributes/objectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") void setObjectAttributes(List objectAttributes); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java index c37547418..e60eb42fc 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java @@ -25,21 +25,21 @@ @JsonTypeName("aas:Operation") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface OperationMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") List getInputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") void setInputVariables(List inputVariables); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") List getInoutputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/inoutputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") void setInoutputVariables(List inoutputVariables); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") List getOutputVariables(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Operation/outputVariable") + @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") void setOutputVariables(List outputVariables); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java index 3e21e6918..a099ae7db 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:OperationVariable") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface OperationVariableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") SubmodelElement getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/OperationVariable/value") + @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") void setValue(SubmodelElement value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java index f6a0023c8..8e63a86f8 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:PolicyDecisionPoint") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyDecisionPointMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") boolean getExternalPolicyDecisionPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyDecisionPoint/externalPolicyDecisionPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java index 7eb2bd1a8..d1aaa0eef 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:PolicyEnforcementPoints") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyEnforcementPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") boolean getExternalPolicyEnforcementPoint(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyEnforcementPoints/externalPolicyEnforcementPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java index db74d7242..935f0b5f0 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java @@ -25,15 +25,15 @@ @JsonTypeName("aas:PolicyInformationPoints") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PolicyInformationPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") boolean getExternalInformationPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/externalInformationPoints") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") void setExternalInformationPoints(boolean externalInformationPoints); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") List getInternalInformationPoints(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/PolicyInformationPoints/internalInformationPoint") + @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") void setInternalInformationPoints(List internalInformationPoints); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java index 162cda7a2..1466c78e0 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:Property") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface PropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Property/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java index be2e8c0c9..e4619f351 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java @@ -32,9 +32,9 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface QualifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") List getQualifiers(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") void setQualifiers(List qualifiers); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java index 941567e52..d3c5ef093 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java @@ -24,27 +24,27 @@ @JsonTypeName("aas:Qualifier") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface QualifierMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") String getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") void setType(String type); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/value") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Qualifier/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java index b46e6de2c..1bef8f17a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java @@ -24,21 +24,21 @@ @JsonTypeName("aas:Range") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface RangeMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") String getValueType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/valueType") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") void setValueType(String valueType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") String getMax(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/max") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") void setMax(String max); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") String getMin(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Range/min") + @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") void setMin(String min); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java index 349c27b6e..de65fa1eb 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java @@ -20,7 +20,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.LangString; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import java.util.List; @@ -32,27 +33,27 @@ @JsonSubTypes.Type(value = SubmodelElement.class) }) public interface ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") String getCategory(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/category") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") void setCategory(String category); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") - List getDescription(); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") + List getDescription(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/description") - void setDescription(List description); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") + void setDescription(List description); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") - List getDisplayName(); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") + List getDisplayName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/displayName") - void setDisplayName(List displayName); + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") + void setDisplayName(List displayName); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") String getIdShort(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Referable/idShort") + @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") void setIdShort(String idShort); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java index 6df2a7be1..bbffdaaae 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java @@ -24,9 +24,9 @@ @JsonTypeName("aas:ReferenceElement") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ReferenceElementMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") Reference getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ReferenceElement/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") void setValue(Reference value); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java index 0af5ae449..55e5b8c98 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java @@ -27,15 +27,15 @@ @JsonTypeName("aas:Reference") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ReferenceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") List getKeys(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/keys") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") void setKeys(List keys); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") ReferenceTypes getType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Reference/type") + @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") void setType(ReferenceTypes type); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java index 31fefc0c7..3b1fba521 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java @@ -29,15 +29,15 @@ @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) }) public interface RelationshipElementMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") Reference getFirst(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/first") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") void setFirst(Reference first); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") Reference getSecond(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/RelationshipElement/second") + @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") void setSecond(Reference second); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java index 4d25d1637..88a6dfff2 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java @@ -26,15 +26,15 @@ @JsonTypeName("aas:Resource") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ResourceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") String getContentType(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/contentType") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") void setContentType(String contentType); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") String getPath(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Resource/path") + @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") void setPath(String path); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java index 0380783e6..ec328856e 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java @@ -26,22 +26,22 @@ @JsonTypeName("aas:SpecificAssetId") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SpecificAssetIdMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") String getName(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/name") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") void setName(String name); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") Reference getExternalSubjectId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SpecificAssetId/externalSubjectId") + @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") void setExternalSubjectId(Reference reference); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java index f0451e1f4..54401344b 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:SubjectAttributes") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") List getSubjectAttributes(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubjectAttributes/subjectAttribute") + @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") void setSubjectAttributes(List subjectAttributes); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java index 722fc32ab..99fe43314 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java @@ -25,21 +25,21 @@ @JsonTypeName("aas:SubmodelElementCollection") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") boolean getAllowDuplicates(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/allowDuplicates") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") void setAllowDuplicates(boolean allowDuplicates); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") boolean getOrdered(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/ordered") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") void setOrdered(boolean ordered); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") Collection getValues(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementCollection/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") void setValues(Collection values); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java index 9387f7570..a00265d97 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java @@ -29,33 +29,33 @@ @JsonTypeName("aas:SubmodelElementList") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelElementListMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") boolean getOrderRelevant(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/orderRelevant") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") void setOrderRelevant(boolean orderRelevant); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") Reference getSemanticIdListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/semanticIdListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") void setSemanticIdListElement(Reference semanticIdListElement); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") AasSubmodelElements getTypeValueListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/typeValueListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") void setTypeValueListElement(AasSubmodelElements typeValueListElement); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") List getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/value") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") void setValue(List value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") DataTypeDefXsd getValueTypeListElement(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/SubmodelElementList/valueTypeListElement") + @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java index df693d6a2..ccb2cbcf7 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:Submodel") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") List getSubmodelElements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement") + @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") void setSubmodelElements(List submodelElements); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java index 2cb4a878c..005eec10a 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java @@ -28,9 +28,9 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ValueListMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") List getValueReferencePairs(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueList/valueReferencePairs") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") void setValueReferencePairs(List valueReferencePairs); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java index d9502ad58..f57950e61 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java @@ -24,15 +24,15 @@ @JsonTypeName("aas:ValueReferencePair") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ValueReferencePairMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") String getValue(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/value") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") void setValue(String value); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") Reference getValueId(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/ValueReferencePair/valueId") + @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") void setValueId(Reference valueId); } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java index fd1aa933c..b10f8626e 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java @@ -25,9 +25,9 @@ @JsonTypeName("aas:View") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") List getContainedElements(); - @JsonProperty("https://admin-shell.io/aas/3/0/RC02/View/containedElement") + @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") void setContainedElements(List containedElements); } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 58da78d90..fbd95bf51 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -17,13 +17,8 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIEC61360; import org.junit.Assert; import org.junit.Test; @@ -46,18 +41,18 @@ public void serializeEnvironment() throws IOException, DeserializationException .assetInformation(new DefaultAssetInformation.Builder() .assetKind(AssetKind.INSTANCE) .build()) - .description(Arrays.asList(new DefaultLangString.Builder().text("This is a test AAS").language("en-us").build())) + .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())) .displayName(Arrays.asList( - new DefaultLangString.Builder().text("Anzeigename 2").language("de").build(), - new DefaultLangString.Builder().text("Display Name 1").language("en").build() + 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() - .description(Arrays.asList(new DefaultLangString.Builder().text("My Submodel").language("en-us").build())) + .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())) .displayName(Arrays.asList( - new DefaultLangString.Builder().text("First Submodel Element name").language("en").build(), - new DefaultLangString.Builder().text("Second Submodel Element name").language("en").build() + 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(); @@ -69,8 +64,8 @@ public void serializeEnvironment() throws IOException, DeserializationException .value("https://example.org") .build()) .build()) - .dataSpecificationContent(new DefaultDataSpecificationIEC61360.Builder() - .dataType(DataTypeIEC61360.RATIONAL) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.RATIONAL) .build()) .build()) .build(); @@ -83,7 +78,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .build(); String output = new Serializer().serialize(aasEnv, RDFLanguages.JSONLD); - //System.out.println(output); + System.out.println(output); Assert.assertTrue(output.contains("@context")); // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? From bb618d3e0d47a422e672e6ac6fa161c07b04b517 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 20:09:36 +0100 Subject: [PATCH 128/160] Separate internals and establish main interfaces --- .../rdf/{Parser.java => ParserHelper.java} | 265 ++++++--------- .../aas4j/v3/dataformat/rdf/RdfParser.java | 318 ++++++++++++++++++ .../v3/dataformat/rdf/RdfSerializer.java | 192 +++++++++++ ...{Serializer.java => SerializerHelper.java} | 76 +---- .../aas4j/v3/dataformat/rdf/ParserTest.java | 198 +++++------ .../v3/dataformat/rdf/SerializerTest.java | 20 +- 6 files changed, 729 insertions(+), 340 deletions(-) rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{Parser.java => ParserHelper.java} (91%) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{Serializer.java => SerializerHelper.java} (75%) diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java similarity index 91% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java index cc6434777..2edd2bd10 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Parser.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java @@ -51,22 +51,38 @@ /** * Internal class to handle the parsing of JSON-LD into java objects + * * @author maboeckmann */ -class Parser { - - private final Logger logger = LoggerFactory.getLogger(Parser.class); +class ParserHelper { private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); - static Map knownNamespaces = new HashMap<>(); + private final Logger logger = LoggerFactory.getLogger(ParserHelper.class); + /** + * This list contains all primitive Java types + */ + private final Map> builtInMap = new HashMap<>(); + + { + builtInMap.put("int", Integer.TYPE); + builtInMap.put("long", Long.TYPE); + builtInMap.put("double", Double.TYPE); + builtInMap.put("float", Float.TYPE); + builtInMap.put("bool", Boolean.TYPE); + builtInMap.put("char", Character.TYPE); + builtInMap.put("byte", Byte.TYPE); + builtInMap.put("void", Void.TYPE); + builtInMap.put("short", Short.TYPE); + } /** * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle - * @param inputModel Model on which queries are to be evaluated from which information can be retrieved - * @param objectUri URI of the object to be handled + * + * @param inputModel Model on which queries are to be evaluated from which information can be retrieved + * @param objectUri URI of the object to be handled * @param targetClass Variable containing the class which should be returned - * @param Class which should be returned + * @param Class which should be returned * @return Object of desired class, filled with the values extracted from inputModel * @throws IOException thrown if the parsing fails */ @@ -85,18 +101,13 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax try { new URL(objectUri); - } - catch (MalformedURLException e) - { + } catch (MalformedURLException e) { currentObjectIsBlankNode = true; } - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { //Object is a blank node, so the subject URI cannot be used queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; - } - else - { + } else { //Not a blank node, so we can work with the subject URI queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; } @@ -128,7 +139,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Is this class instantiable? if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { //candidateClass = currentClass; - if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { targetClass = (Class) currentClass; break; } @@ -147,8 +158,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } //Enums have no constructors - if(targetClass.isEnum()) - { + if (targetClass.isEnum()) { return handleEnum(targetClass, objectUri); } @@ -196,8 +206,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl */ //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal - if(methodMap.isEmpty()) - { + if (methodMap.isEmpty()) { return returnObject; } @@ -207,11 +216,9 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl StringBuilder queryStringBuilder = new StringBuilder(); - for(Map.Entry entry : knownNamespaces.entrySet()) - { + for (Map.Entry entry : knownNamespaces.entrySet()) { queryStringBuilder.append("PREFIX ").append(entry.getKey()); - if(!entry.getKey().endsWith(":")) - { + if (!entry.getKey().endsWith(":")) { queryStringBuilder.append(":"); } queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); @@ -251,12 +258,9 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl queryStringBuilder.append(" { "); //In case of blank nodes, we can't work with the subject URI - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); - } - else - { + } else { queryStringBuilder.append(" <").append(objectUri).append(">"); } @@ -274,23 +278,20 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //In AAS, every field is optional, as there are no validation annotations in the model queryStringBuilder.append(" OPTIONAL {"); - if(currentObjectIsBlankNode) - { + if (currentObjectIsBlankNode) { queryStringBuilder.append(" ?s "); - } - else { + } else { queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function } //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) //Find the annotation value containing a colon and interpret this as "prefix:predicate" boolean foundAnnotation = false; - if(field.getAnnotation(IRI.class) != null) { + if (field.getAnnotation(IRI.class) != null) { Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); currentAnnotation.ifPresent(queryStringBuilder::append); foundAnnotation = true; } - if(!foundAnnotation) - { + if (!foundAnnotation) { logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); queryStringBuilder.append("aas:").append(entry.getKey()); } @@ -321,7 +322,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Query for all unknown properties and their values //Select properties and values only - if(!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step + if (!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } for (Map.Entry entry : knownNamespaces.entrySet()) { @@ -420,21 +421,16 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } } externalPropertiesQueryExecution.close(); - } - catch (NoSuchMethodException ignored) - { + } catch (NoSuchMethodException ignored) { //Method does not exist, skip } } - Query query; try { query = QueryFactory.create(queryString); - } - catch (QueryParseException e) - { + } catch (QueryParseException e) { logger.error(queryString); throw e; } @@ -459,13 +455,10 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl String value1 = "", value2 = "", parameterName = ""; QuerySolution querySolution2 = resultSet.next(); Iterator varNamesIt = querySolution2.varNames(); - while(varNamesIt.hasNext()) - { + while (varNamesIt.hasNext()) { String varName = varNamesIt.next(); - if(querySolution.contains(varName)) - { - if(!querySolution.get(varName).equals(querySolution2.get(varName))) - { + if (querySolution.contains(varName)) { + if (!querySolution.get(varName).equals(querySolution2.get(varName))) { parameterName = varName; value1 = querySolution.get(varName).toString(); value2 = querySolution2.get(varName).toString(); @@ -473,8 +466,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl } } } - if(!value1.isEmpty()) - { + if (!value1.isEmpty()) { throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); } throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); @@ -491,8 +483,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl if (Collection.class.isAssignableFrom(currentType)) { sparqlParameterName += "s"; //plural form for the concatenated values } - if(!querySolution.contains(sparqlParameterName)) - { + if (!querySolution.contains(sparqlParameterName)) { sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead //TODO: Note: This would not yield full results yet in case some of the values are encapsulated // in blank nodes and some are not, for the same property @@ -504,7 +495,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl String blankNodeId = ""; //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject //For that case, we add some artificial identifiers here - if(objectIsBlankNode) { + if (objectIsBlankNode) { blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); } if (currentType.isEnum()) { @@ -512,8 +503,7 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //1: The URI of the enum value is given directly e.g. ?s ?p //2: The URI of the enum value is encapsulated in a blank node, e.g. // ?s ?p [ a demo:myEnum, demo:enumValue ] - if(objectIsBlankNode) - { + if (objectIsBlankNode) { Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); @@ -522,24 +512,22 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl //Only throw this if there is no successful execution IOException anyIOException = null; boolean oneSuccessfulEnumFound = false; - while(innerEnumQueryExecutionResultSet.hasNext()) - { + while (innerEnumQueryExecutionResultSet.hasNext()) { try { entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); oneSuccessfulEnumFound = true; break; //Stop after the first successful execution - } - catch (IOException e) //There might be errors, if multiple types are present, see example above + } catch ( + IOException e) //There might be errors, if multiple types are present, see example above { anyIOException = e; } } //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception - if(anyIOException != null && !oneSuccessfulEnumFound) + if (anyIOException != null && !oneSuccessfulEnumFound) throw new IOException("Could not parse Enum. ", anyIOException); innerEnumQueryExecution.close(); - } - else { + } else { entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); } continue; @@ -635,23 +623,23 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl queryExecution.close(); return returnObject; - } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchFieldException | URISyntaxException | DatatypeConfigurationException | ClassNotFoundException e) { + } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | + InvocationTargetException | NoSuchFieldException | URISyntaxException | + DatatypeConfigurationException | ClassNotFoundException e) { throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); } } /** * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" + * * @param input Input URI, possibly a prefixed value * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" */ - private String wrapIfUri(String input) - { - if(input.startsWith("http://") || input.startsWith("https://")) - { + private String wrapIfUri(String input) { + if (input.startsWith("http://") || input.startsWith("https://")) { return "<" + input + ">"; - } - else { + } else { return input; } } @@ -681,8 +669,7 @@ private Object handleForeignLiteral(Literal literal) throws URISyntaxException { private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map //Literals must be handled "one recursion step above" - if(node.isLiteral()) - { + if (node.isLiteral()) { throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); } @@ -693,15 +680,13 @@ private HashMap handleForeignNode(RDFNode node, HashMap newList = new ArrayList<>(); @@ -711,36 +696,28 @@ private HashMap handleForeignNode(RDFNode node, HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); subMap.put("@id", querySolution.getResource("o").getURI()); - if(map.containsKey(propertyUri)) - { - map.put(querySolution.get("p").toString(), ((ArrayList)map.get(propertyUri)).add(subMap)); - } - else { + if (map.containsKey(propertyUri)) { + map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(subMap)); + } else { map.put(querySolution.get("p").toString(), subMap); } } @@ -749,11 +726,11 @@ private HashMap handleForeignNode(RDFNode node, HashMap targetClass, String fieldName) throws NoSu } catch (NoSuchFieldException e2) { try { return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); - } - catch (NoSuchFieldException e3) - { + } catch (NoSuchFieldException e3) { throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); } } @@ -777,9 +752,10 @@ private Field getFieldByName(Class targetClass, String fieldName) throws NoSu /** * Internal function to create a single enum object from a given desired class and a URL + * * @param enumClass The enum class - * @param url The URL of the enum value - * @param Enum class + * @param url The URL of the enum value + * @param Enum class * @return Value of enumClass matching the input URL * @throws IOException thrown if no matching enum value could be found */ @@ -788,8 +764,7 @@ private T handleEnum(Class enumClass, String url) throws IOException { throw new RuntimeException("Non-Enum class passed to handleEnum function."); } T[] constants = enumClass.getEnumConstants(); - if(url.contains("/")) - { + if (url.contains("/")) { url = url.substring(url.lastIndexOf("/") + 1); } for (T constant : constants) { @@ -803,13 +778,14 @@ private T handleEnum(Class enumClass, String url) throws IOException { /** * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) - * @param currentType Input Class (or primitive) - * @param literal Value as literal (can be null in some cases) + * + * @param currentType Input Class (or primitive) + * @param literal Value as literal (can be null in some cases) * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) * @return Object of type currentType - * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI + * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails - * @throws IOException thrown, if no matching "simple class" could be found + * @throws IOException thrown, if no matching "simple class" could be found */ private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { //Java way of checking for primitives, i.e. int, char, float, double, ... @@ -853,18 +829,14 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown try { return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); - } - catch (DatatypeFormatException | DateTimeParseException ignored) - { + } catch (DatatypeFormatException | DateTimeParseException ignored) { //Not a valid dateTimeStamp. Try parsing just to Date try { Date date = new SimpleDateFormat().parse(literal.getValue().toString()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); - } - catch (ParseException | DateTimeParseException | DatatypeFormatException e2) - { + } catch (ParseException | DateTimeParseException | DatatypeFormatException e2) { //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); } @@ -906,22 +878,6 @@ private Object handlePrimitive(Class currentType, Literal literal, String cur throw new IOException("Unrecognized primitive type: " + currentType.getName()); } - /** - * This list contains all primitive Java types - */ - private final Map> builtInMap = new HashMap<>(); - { - builtInMap.put("int", Integer.TYPE); - builtInMap.put("long", Long.TYPE); - builtInMap.put("double", Double.TYPE); - builtInMap.put("float", Float.TYPE); - builtInMap.put("bool", Boolean.TYPE); - builtInMap.put("char", Character.TYPE); - builtInMap.put("byte", Byte.TYPE); - builtInMap.put("void", Void.TYPE); - builtInMap.put("short", Short.TYPE); - } - private boolean isArrayListTypePrimitive(Type t) throws IOException { String typeName = extractTypeNameFromCollection(t); @@ -940,14 +896,12 @@ private String extractTypeNameFromCollection(Type t) throws IOException { throw new IOException("Illegal argument encountered while interpreting type parameter"); } //"" or super instead of extends - if(typeName.contains("?")) - { + if (typeName.contains("?")) { //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); } //No extends - else - { + else { return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); } } @@ -974,9 +928,10 @@ private boolean isPrimitive(Class input) throws IOException { /** * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) - * @param rdfModel RDF input to be parsed + * + * @param rdfModel RDF input to be parsed * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1004,7 +959,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { String className = fullName.substring(fullName.lastIndexOf('/') + 1); //In case of hash-namespaces - if(className.contains("#")) { + if (className.contains("#")) { className = className.substring(className.lastIndexOf("#")); } @@ -1014,7 +969,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { } for (Class currentClass : implementingClasses) { - if (currentClass.getSimpleName().equals(Serializer.implementingClassesNamePrefix + className + Serializer.implementingClassesNameSuffix)) { + if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { returnCandidates.put(solution.get("id").toString(), currentClass); } } @@ -1028,13 +983,11 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { //At this point, we parsed the model and know to which implementing class we want to parse //Check if there are several options available - if(returnCandidates.size() > 1) - { + if (returnCandidates.size() > 1) { String bestCandidateId = null; Class bestCandidateClass = null; long bestNumRelations = -1L; - for(Map.Entry> entry : returnCandidates.entrySet()) - { + for (Map.Entry> entry : returnCandidates.entrySet()) { String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + " WHERE {" + " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + @@ -1042,8 +995,7 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); - if(graphSize > bestNumRelations) - { + if (graphSize > bestNumRelations) { bestNumRelations = graphSize; bestCandidateId = entry.getKey(); bestCandidateClass = entry.getValue(); @@ -1065,9 +1017,10 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { /** * Entry point to this class. Takes a message and a desired target class (can be an interface) - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1078,10 +1031,11 @@ T parseMessage(String message, Class targetClass) throws IOException { /** * Entry point to this class. Takes a message and a desired target class (can be an interface) - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) + * + * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function + * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) * @param serializationFormat Input RDF format - * @param Desired target class + * @param Desired target class * @return Object of desired target class, representing the values contained in input message * @throws IOException if the parsing of the message fails */ @@ -1119,7 +1073,7 @@ private Model readMessage(String message) throws IOException { * Reads a message into an Apache Jena model, guessing the input language. * Note: Guessing the language may cause some error messages during parsing attempts * - * @param message Message to be read + * @param message Message to be read * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML * @return The model of the message */ @@ -1129,9 +1083,7 @@ private Model readMessage(String message, Lang language) throws IOException { try { RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); - } - catch (RiotException e) - { + } catch (RiotException e) { throw new IOException("Failed to parse input as " + language, e); } return targetModel; @@ -1139,6 +1091,7 @@ private Model readMessage(String message, Lang language) throws IOException { /** * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated + * * @param someClass Input class of which implementable subclasses need to be found * @return ArrayList of instantiable subclasses */ @@ -1152,20 +1105,18 @@ ArrayList> getImplementingClasses(Class someClass) { } } if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { - result.add(Serializer.customImplementationMap.getOrDefault(someClass, someClass)); + result.add(SerializerHelper.customImplementationMap.getOrDefault(someClass, someClass)); } return result; } - private void addArtificialBlankNodeLabels(Model m) - { + private void addArtificialBlankNodeLabels(Model m) { //Get all blank nodes Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); QueryExecution qe = QueryExecutionFactory.create(q, m); ResultSet rs = qe.execSelect(); List statementsToAdd = new ArrayList<>(); - while(rs.hasNext()) - { + while (rs.hasNext()) { QuerySolution qs = rs.next(); statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), 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..bba8cc423 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java @@ -0,0 +1,318 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.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/RdfSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java new file mode 100644 index 000000000..3fc0fe1be --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java @@ -0,0 +1,192 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +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.Collection; +import java.util.List; + +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 { + throw new RuntimeException("Not Implemented"); + } 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 { + throw new RuntimeException("Not Implemented"); + } 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 JSON node. + * + * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize + * @return the Jena Model + */ + public Model toModel(Environment aasEnvironment) { + throw new RuntimeException("Not Implemented"); + } + + /** + * Converts a given instance of a Referable to a JSON node. + * + * @param referable the referable to serialize + * @return the Jena Model + */ + public Model toModel(Referable referable) { + throw new RuntimeException("Not Implemented"); + } + + + /** + * 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/Serializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java similarity index 75% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java index 375e4b82f..50237734f 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/Serializer.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java @@ -22,7 +22,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; @@ -39,7 +38,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; -public class Serializer { +class SerializerHelper { private static final ObjectMapper mapper = new ObjectMapper(); public static String implementingClassesNamePrefix = "Default"; @@ -47,9 +46,9 @@ public class Serializer { static Map, Class> customImplementationMap = new HashMap<>(); private static boolean charsetWarningPrinted = false; private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(Serializer.class); + private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); - public Serializer() { + public SerializerHelper() { mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); mapper.setMixInResolver(new ReflectiveMixInResolver()); @@ -79,7 +78,7 @@ public Serializer() { * @param namespaceUrl URL of the prefix */ public static void addKnownNamespace(String prefix, String namespaceUrl) { - Parser.knownNamespaces.put(prefix, namespaceUrl); + ParserHelper.knownNamespaces.put(prefix, namespaceUrl); JsonLDSerializer.contextItems.put(prefix, namespaceUrl); } @@ -157,58 +156,6 @@ public String serializePlainJson(Object instance) throws JsonProcessingException return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); } - /** - * Inverse method of "serialize" - * - * @param serialization JSON(-LD) string - * @param valueType class of top level type - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(String serialization, Class valueType) throws DeserializationException { - try { - return new Parser().parseMessage(serialization, valueType); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } - - /** - * Inverse method of "serialize" - * - * @param serialization JSON(-LD) string - * @param valueType class of top level type - * @param serializationFormat RDF input format - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(String serialization, Class valueType, Lang serializationFormat) throws DeserializationException { - try { - - return new Parser().parseMessage(serialization, valueType, serializationFormat); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } - - /** - * Inverse method of "serialize" - * - * @param rdfModel Input RDF Model to be turned into an Instance of the IDS Java classes - * @param valueType class of top level type - * @param deserialized type - * @return an object representing the provided JSON(-LD) structure - * @throws DeserializationException thrown, if deserialization fails, e.g. because the input is not valid RDF - */ - public T deserialize(Model rdfModel, Class valueType) throws DeserializationException { - try { - return new Parser().parseMessage(rdfModel, valueType); - } catch (IOException e) { - throw new DeserializationException("Failed to deserialize input.", e); - } - } /** * Method to add a preprocessor for deserialization. @@ -264,21 +211,6 @@ public String write(Environment aasEnvironment, Lang format, Map } } - public Environment read(String value) throws DeserializationException { - try { - return new Parser().parseMessage(value, Environment.class); - } catch (IOException e) { - throw new DeserializationException("Could not deserialize to environment.", e); - } - } - - public Environment read(String value, Lang serializationFormat) throws DeserializationException { - try { - return new Parser().parseMessage(value, Environment.class, serializationFormat); - } catch (IOException e) { - throw new DeserializationException("Could not deserialize to environment.", e); - } - } public void useImplementation(Class aasInterface, Class implementation) { diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java index 9a3e79235..7acbacdba 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -41,7 +41,7 @@ public class ParserTest { @Test public void parseAasEnvironmentTest() throws IOException, DeserializationException { String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); - Environment aasEnv = new Serializer().read(aasEnvAsString); + Environment aasEnv = new RdfParser().read(aasEnvAsString); Assert.assertEquals(1, aasEnv.getSubmodels().size()); Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); @@ -51,103 +51,103 @@ public void parseAasEnvironmentTest() throws IOException, DeserializationExcepti Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); } - - @Test - @Ignore - public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { - String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); - Environment environment = new Serializer().read(aasEnvAsString); - - // TODO continue providing a correct AASFull Turtle representation - // TODO test for LangStrings - Assert.assertEquals(AASFull.ENVIRONMENT, environment); - } - - - @Test - @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", - "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) - public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - - AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); - } - - @Test - @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) - public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - - AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); - } - - @Test - @Parameters({"Submodel_SubmodelElement_Example.ttl"}) - public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { - Serializer serializer = new Serializer(); - //These work - - Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); - - Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); - - - //The following examples do not work yet, as they are semantically problematic - //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); - //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); - } - - - - - @Test - public void deserializeConceptDescription() throws IOException, DeserializationException { - String conceptDescription = "{\n" + - " \"@context\" : {\n" + - " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + - " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + - " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + - " },\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + - " \"@type\" : \"aas:ConceptDescription\",\n" + - " \"isCaseOf\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + - " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + - " \"@type\" : \"aas:Reference\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + - " \"@type\" : \"aas:Key\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + - " } ]\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + - " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + - " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + - " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + - " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + - " },\n" + - " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + - " } ]\n" + - "}"; - - Serializer serializer = new Serializer(); - ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); - - Assert.assertNotNull(c); - } - +// +// @Test +// @Ignore +// public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { +// String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); +// Environment environment = new RdfParser().read(aasEnvAsString); +// +// // TODO continue providing a correct AASFull Turtle representation +// // TODO test for LangStrings +// Assert.assertEquals(AASFull.ENVIRONMENT, environment); +// } +// +// +// @Test +// @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", +// "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) +// public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// +// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); +// } +// +// @Test +// @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) +// public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// +// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); +// } +// +// @Test +// @Parameters({"Submodel_SubmodelElement_Example.ttl"}) +// public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { +// Serializer serializer = new Serializer(); +// //These work +// +// Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); +// +// Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); +// +// +// //The following examples do not work yet, as they are semantically problematic +// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); +// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); +// } +// +// +// +// +// @Test +// public void deserializeConceptDescription() throws IOException, DeserializationException { +// String conceptDescription = "{\n" + +// " \"@context\" : {\n" + +// " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + +// " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + +// " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + +// " },\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + +// " \"@type\" : \"aas:ConceptDescription\",\n" + +// " \"isCaseOf\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + +// " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + +// " \"@type\" : \"aas:Reference\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + +// " \"@type\" : \"aas:Key\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + +// " } ]\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + +// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + +// " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + +// " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + +// " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + +// " },\n" + +// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + +// " } ]\n" + +// "}"; +// +// Serializer serializer = new Serializer(); +// ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); +// +// Assert.assertNotNull(c); +// } +// } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index fbd95bf51..ba7b28eab 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -17,6 +17,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; @@ -77,19 +78,14 @@ public void serializeEnvironment() throws IOException, DeserializationException .conceptDescriptions(conceptDescription) .build(); - String output = new Serializer().serialize(aasEnv, RDFLanguages.JSONLD); - System.out.println(output); + String output = null; + try { + output = new RdfSerializer().write(aasEnv); + System.out.println(output); + } catch (SerializationException e) { + throw new RuntimeException(e); + } - Assert.assertTrue(output.contains("@context")); - // Assert.assertTrue(output.contains("rdf:")); // TODO: why should the output contain the 'rdf' prefix? - Assert.assertTrue(output.contains("\"@type\" : \"aas:Environment\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:AssetAdministrationShell\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:Submodel\"")); - Assert.assertTrue(output.contains("\"@type\" : \"aas:ConceptDescription\"")); - Environment environment = new Serializer().deserialize(output, Environment.class); - Assert.assertNotNull(environment); - - // Assert.assertTrue(aasEnv.equals(environment)); // TODO: Serialising and parsing to/from RDF looses the sequence of e.g. LangStrings, therefore this test fails also for semantically equal objects } } From d360414cbeca5299a0bbb285fd15980f1a6c8f03 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 3 Jan 2024 20:13:07 +0100 Subject: [PATCH 129/160] Make the initial test running again --- .../v3/dataformat/rdf/RdfSerializer.java | 4 +++- .../v3/dataformat/rdf/SerializerTest.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) 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 index 3fc0fe1be..ed26ec3fe 100644 --- 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 @@ -3,6 +3,7 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; +import org.apache.jena.riot.system.Serializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -16,6 +17,7 @@ public class RdfSerializer { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + SerializerHelper serializerHelper = new SerializerHelper(); /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * @@ -26,7 +28,7 @@ public class RdfSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + return serializerHelper.write(aasEnvironment, serializationFormat); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index ba7b28eab..54b26a6bf 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -46,7 +46,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .displayName(Arrays.asList( 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() @@ -54,21 +54,21 @@ public void serializeEnvironment() throws IOException, DeserializationException .displayName(Arrays.asList( 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() .embeddedDataSpecifications(new DefaultEmbeddedDataSpecification.Builder() - .dataSpecification(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.org") - .build()) + .dataSpecification(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.org") + .build()) + .build()) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.RATIONAL) + .build()) .build()) - .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() - .dataType(DataTypeIec61360.RATIONAL) - .build()) - .build()) .build(); List aasList = new ArrayList<>(Collections.singletonList(aas)); From c1bb7b215b0439e463602d4594590d8d14fc8c1a Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 4 Jan 2024 11:57:27 +0100 Subject: [PATCH 130/160] Add complex test for ConceptDescription --- .../aas4j/v3/dataformat/rdf/ParserHelper.java | 30 ++-- .../v3/dataformat/rdf/RdfSerializer.java | 2 +- .../v3/dataformat/rdf/SerializerHelper.java | 36 +++- .../v3/dataformat/rdf/SerializerTest.java | 163 ++++++++++++++++-- .../aas4j/v3/model/Identifiable.java | 4 +- 5 files changed, 200 insertions(+), 35 deletions(-) diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java index 2edd2bd10..a9d0d7540 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java @@ -135,16 +135,16 @@ private T handleObject(Model inputModel, String objectUri, Class targetCl className = className.substring(className.lastIndexOf("#") + 1); } - for (Class currentClass : implementingClasses) { - //Is this class instantiable? - if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { - //candidateClass = currentClass; - if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { - targetClass = (Class) currentClass; - break; - } - } - } +// for (Class currentClass : implementingClasses) { +// //Is this class instantiable? +// if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { +// //candidateClass = currentClass; +// if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(this.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { +// targetClass = (Class) currentClass; +// break; +// } +// } +// } } queryExecution.close(); //Did we find "the" class, i.e. instantiable and name matches? @@ -968,11 +968,11 @@ T parseMessage(Model rdfModel, Class targetClass) throws IOException { className = className.substring(4); } - for (Class currentClass : implementingClasses) { - if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { - returnCandidates.put(solution.get("id").toString(), currentClass); - } - } +// for (Class currentClass : implementingClasses) { +// if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { +// returnCandidates.put(solution.get("id").toString(), currentClass); +// } +// } //if (returnCandidates.size() > 0) break; } queryExecution.close(); 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 index ed26ec3fe..e24460f47 100644 --- 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 @@ -55,7 +55,7 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + return serializerHelper.write(referable, serializationFormat); } 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/SerializerHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java index 50237734f..0009a96e9 100644 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java @@ -30,6 +30,7 @@ import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.riot.RDFLanguages; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,11 +41,11 @@ class SerializerHelper { - private static final ObjectMapper mapper = new ObjectMapper(); - public static String implementingClassesNamePrefix = "Default"; - public static String implementingClassesNameSuffix = ""; + private final ObjectMapper mapper = new ObjectMapper(); + public String implementingClassesNamePrefix = "Default"; + public String implementingClassesNameSuffix = ""; static Map, Class> customImplementationMap = new HashMap<>(); - private static boolean charsetWarningPrinted = false; + private boolean charsetWarningPrinted = false; private final List preprocessors; private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); @@ -77,7 +78,7 @@ public SerializerHelper() { * @param prefix Prefix to be added * @param namespaceUrl URL of the prefix */ - public static void addKnownNamespace(String prefix, String namespaceUrl) { + public void addKnownNamespace(String prefix, String namespaceUrl) { ParserHelper.knownNamespaces.put(prefix, namespaceUrl); JsonLDSerializer.contextItems.put(prefix, namespaceUrl); } @@ -103,12 +104,13 @@ public String serialize(Object instance) throws IOException { * @return RDF serialization of the provided object graph * @throws IOException if the serialization fails */ - public synchronized String serialize(Object instance, Lang format) throws IOException { + public String serialize(Object instance, Lang format) throws IOException { return serialize(instance, format, new HashMap<>()); } //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function - public synchronized String serialize(Object instance, Lang format, Map idMap) throws IOException { + //HoRi: No, bad design + public String serialize(Object instance, Lang format, Map idMap) throws IOException { if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); } @@ -211,6 +213,26 @@ public String write(Environment aasEnvironment, Lang format, Map } } + public String write(Referable referable) throws SerializationException { + try { + return serialize(referable); + } catch (IOException e) { + throw new SerializationException("Failed to serialize environment.", e); + } + } + + public String write(Referable referable, Lang format) throws SerializationException { + return write(referable, format, new HashMap<>()); + } + + public String write(Referable referable, Lang format, Map idMap) throws SerializationException { + try { + return serialize(referable, format, idMap); + } catch (IOException e) { + throw new SerializationException("Failed to serialize environment.", e); + } + } + public void useImplementation(Class aasInterface, Class implementation) { diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 54b26a6bf..6431a764b 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -15,28 +15,178 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; +import org.apache.jena.rdf.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.DeserializationException; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; import org.junit.Assert; import org.junit.Test; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; + public class SerializerTest { //TODO: Optional: Prefixes instead of full URIs //TODO: Optional: Do not serialize empty collections + @Test + public void simpleConceptDescription() throws IOException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("simple") + .build(); + + String output = null; + try { + output = new RdfSerializer().write(conceptDescription); + System.out.println(output); + + Model model = ModelFactory.createDefaultModel(); + InputStream inputStream = new ByteArrayInputStream(output.getBytes()); + model.read(inputStream, null, "TTL"); +// ResourceFactory.createResource(Identifiable.id); +// ResourceFactory.createProperty(propertyUriString); + // Get all subject nodes that are of type ConceptDescription + ResIterator resIterator = model.listResourcesWithProperty(RDF.type, + ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); + Resource createdConceptDescriptionResource = resIterator.nextResource(); + Statement idStatement = model.getProperty(createdConceptDescriptionResource, + ResourceFactory.createProperty(Identifiable.id)); + assert idStatement.getString().equals(conceptDescription.getId()); + } catch (SerializationException e) { + throw new RuntimeException(e); + } + + } + + @Test + public void complexConceptDescription() throws IOException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("complex") + .extensions(Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build())) + .category("myCategory") + .idShort("exampleIdShort") + .displayName(Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build() + )) + .description(Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build() + )) + .administration(new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .creator(new DefaultReference.Builder() + .keys(Arrays.asList( + 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()) + .build() + ).isCaseOf(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.com/outside") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build() + )) + .embeddedDataSpecifications(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()) + .build()) + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .levelType(new DefaultLevelType.Builder() + .max(true) + .min(true) + .nom(false) + .typ(false) + .build()) + .unit("gram") + .symbol("g") +// .definition() +// .shortName() +// .preferredName() +// .valueFormat() +// .valueList() + .dataType(DataTypeIec61360.INTEGER_MEASURE) + .build()) + .build()) + .build(); + + String output = null; + try { + String outputJsonLd = new RdfSerializer().write(conceptDescription, Lang.JSONLD); + System.out.println(outputJsonLd); + output = new RdfSerializer().write(conceptDescription); + System.out.println(output); + + Model model = ModelFactory.createDefaultModel(); + InputStream inputStream = new ByteArrayInputStream(output.getBytes()); + model.read(inputStream, null, "TTL"); +// ResourceFactory.createResource(Identifiable.id); +// ResourceFactory.createProperty(propertyUriString); + // Get all subject nodes that are of type ConceptDescription + ResIterator resIterator = model.listResourcesWithProperty(RDF.type, + ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); + Resource createdConceptDescriptionResource = resIterator.nextResource(); + Statement idStatement = model.getProperty(createdConceptDescriptionResource, + ResourceFactory.createProperty(Identifiable.id)); + assert idStatement.getString().equals(conceptDescription.getId()); + } catch (SerializationException e) { + throw new RuntimeException(e); + } + + } @Test - public void serializeEnvironment() throws IOException, DeserializationException { + public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() .assetInformation(new DefaultAssetInformation.Builder() @@ -78,14 +228,7 @@ public void serializeEnvironment() throws IOException, DeserializationException .conceptDescriptions(conceptDescription) .build(); - String output = null; - try { - output = new RdfSerializer().write(aasEnv); - System.out.println(output); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - - + String output = new RdfSerializer().write(aasEnv); + System.out.println(output); } } 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..41afc0483 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,7 @@ @KnownSubtypes.Type(value = Submodel.class) }) public interface Identifiable extends Referable { - + String id = "https://admin-shell.io/aas/3/0/Identifiable/id"; /** * Administrative information of an identifiable element. * @@ -56,7 +56,7 @@ public interface Identifiable extends Referable { * * @return Returns the String for the property id. */ - @IRI("https://admin-shell.io/aas/3/0/Identifiable/id") + @IRI(id) String getId(); /** From 4d52e92fac783b2ee175adeec83ee4263d69edb0 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 25 Jan 2024 15:00:13 +0100 Subject: [PATCH 131/160] Fix base structure and simple test cases --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 239 ++++ .../rdf/DefaultRDFHandlerResult.java | 31 + .../v3/dataformat/rdf/FallbackSerializer.java | 42 - .../v3/dataformat/rdf/IgnoreTypeMixIn.java | 22 - .../rdf/IncompatibleTypeException.java | 7 + .../aas4j/v3/dataformat/rdf/JsonLDModule.java | 52 - .../v3/dataformat/rdf/JsonLDSerializer.java | 196 --- .../rdf/JsonLDSerializerModifier.java | 44 - .../dataformat/rdf/JsonLdEnumSerializer.java | 88 -- .../dataformat/rdf/LangStringSerializer.java | 53 - .../aas4j/v3/dataformat/rdf/ParserHelper.java | 1129 ----------------- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 27 + .../rdf/{RdfParser.java => RDFParser.java} | 6 +- .../v3/dataformat/rdf/RDFPartialHandler.java | 10 + .../rdf/RDFSerializationResult.java | 10 + ...{RdfSerializer.java => RDFSerializer.java} | 19 +- .../v3/dataformat/rdf/SerializerHelper.java | 242 ---- .../v3/dataformat/rdf/UriSerializer.java | 53 - .../rdf/custom/BigDecimalSerializer.java | 42 - .../rdf/custom/JsonLdEnumMixin.java | 23 - .../rdf/custom/LangStringMixin.java | 35 - .../rdf/custom/ReflectiveMixInResolver.java | 41 - .../XMLGregorianCalendarDeserializer.java | 49 - .../XMLGregorianCalendarSerializer.java | 47 - .../aas4j/v3/dataformat/rdf/doc.md | 9 + ...ltAdministrativeInformationRDFHandler.java | 19 + ...nnotatedRelationshipElementRDFHandler.java | 20 + ...ultAssetAdministrationShellRDFHandler.java | 26 + .../DefaultAssetInformationRDFHandler.java | 20 + .../DefaultBasicEventElementRDFHandler.java | 20 + .../rdf/handlers/DefaultBlobRDFHandler.java | 20 + .../handlers/DefaultCapabilityRDFHandler.java | 20 + .../DefaultConceptDescriptionRDFHandler.java | 52 + ...ltDataSpecificationIEC61360RDFHandler.java | 20 + ...ltEmbeddedDataSpecificationRDFHandler.java | 20 + .../rdf/handlers/DefaultEntityRDFHandler.java | 20 + .../handlers/DefaultExtensionRDFHandler.java | 20 + .../rdf/handlers/DefaultFileRDFHandler.java | 20 + .../rdf/handlers/DefaultKeyRDFHandler.java | 42 + .../DefaultLangStringNameTypeRDFHandler.java | 20 + .../DefaultLangStringTextTypeRDFHandler.java | 19 + ...efaultMultiLanguagePropertyRDFHandler.java | 20 + .../handlers/DefaultOperationRDFHandler.java | 20 + .../handlers/DefaultPropertyRDFHandler.java | 20 + .../handlers/DefaultQualifierRDFHandler.java | 20 + .../rdf/handlers/DefaultRangeRDFHandler.java | 20 + .../DefaultReferenceElementRDFHandler.java | 20 + .../handlers/DefaultReferenceRDFHandler.java | 60 + .../DefaultRelationshipElementRDFHandler.java | 20 + .../handlers/DefaultResrouceRDFHandler.java | 19 + .../DefaultSpecificAssetIdRDFHandler.java | 20 + ...ltSubmodelElementCollectionRDFHandler.java | 20 + .../DefaultSubmodelElementListRDFHandler.java | 22 + .../DefaultHasSemanticsRDFHandler.java | 21 + .../DefaultIdentifiableRDFHandler.java | 49 + .../partial/DefaultReferableRDFHandler.java | 46 + .../AdministrativeInformationMixin.java | 38 - .../AnnotatedRelationshipElementMixin.java | 33 - .../mixins/AssetAdministrationShellMixin.java | 47 - .../rdf/mixins/AssetInformationMixin.java | 60 - .../rdf/mixins/BasicEventElementMixin.java | 79 -- .../v3/dataformat/rdf/mixins/BlobMixin.java | 38 - .../rdf/mixins/CapabilityMixin.java | 27 - .../rdf/mixins/ConceptDescriptionMixin.java | 33 - .../rdf/mixins/DataElementMixin.java | 37 - .../mixins/DataSpecificationContentMixin.java | 30 - .../DataSpecificationIec61360Mixin.java | 106 -- .../EmbeddedDataSpecificationMixin.java | 42 - .../v3/dataformat/rdf/mixins/EntityMixin.java | 54 - .../rdf/mixins/EnvironmentMixin.java | 47 - .../rdf/mixins/EventElementMixin.java | 33 - .../rdf/mixins/EventMessageMixin.java | 27 - .../dataformat/rdf/mixins/ExtensionMixin.java | 50 - .../v3/dataformat/rdf/mixins/FileMixin.java | 38 - .../dataformat/rdf/mixins/FormulaMixin.java | 33 - .../rdf/mixins/HasDataSpecificationMixin.java | 49 - .../rdf/mixins/HasExtensionsMixin.java | 33 - .../dataformat/rdf/mixins/HasKindMixin.java | 39 - .../rdf/mixins/HasSemanticsMixin.java | 49 - .../rdf/mixins/IdentifiableMixin.java | 47 - .../mixins/IdentifierKeyValuePairMixin.java | 44 - .../rdf/mixins/IdentifierMixin.java | 31 - .../v3/dataformat/rdf/mixins/KeyMixin.java | 39 - .../mixins/MultiLanguagePropertyMixin.java | 40 - .../rdf/mixins/ObjectAttributesMixin.java | 33 - .../dataformat/rdf/mixins/OperationMixin.java | 45 - .../rdf/mixins/OperationVariableMixin.java | 32 - .../rdf/mixins/PolicyDecisionPointMixin.java | 32 - .../mixins/PolicyEnforcementPointsMixin.java | 32 - .../mixins/PolicyInformationPointsMixin.java | 39 - .../dataformat/rdf/mixins/PropertyMixin.java | 44 - .../rdf/mixins/QualifiableMixin.java | 40 - .../dataformat/rdf/mixins/QualifierMixin.java | 50 - .../v3/dataformat/rdf/mixins/RangeMixin.java | 44 - .../dataformat/rdf/mixins/ReferableMixin.java | 59 - .../rdf/mixins/ReferenceElementMixin.java | 32 - .../dataformat/rdf/mixins/ReferenceMixin.java | 41 - .../rdf/mixins/RelationshipElementMixin.java | 43 - .../dataformat/rdf/mixins/ResourceMixin.java | 40 - .../rdf/mixins/SpecificAssetIdMixin.java | 47 - .../rdf/mixins/SubjectAttributesMixin.java | 33 - .../SubmodelElementCollectionMixin.java | 45 - .../rdf/mixins/SubmodelElementListMixin.java | 61 - .../rdf/mixins/SubmodelElementMixin.java | 40 - .../dataformat/rdf/mixins/SubmodelMixin.java | 33 - .../dataformat/rdf/mixins/ValueListMixin.java | 36 - .../rdf/mixins/ValueReferencePairMixin.java | 38 - .../v3/dataformat/rdf/mixins/ViewMixin.java | 33 - .../rdf/preprocessing/BasePreprocessor.java | 53 - .../rdf/preprocessing/JsonPreprocessor.java | 42 - .../preprocessing/TypeNamePreprocessor.java | 194 --- .../aas4j/v3/dataformat/rdf/ParserTest.java | 120 -- .../v3/dataformat/rdf/SerializerTest.java | 225 +--- dataformat-rdf/src/test/resources/AASFull.ttl | 354 ------ .../resources/AAS_Reference_shortExample.nt | 16 - .../resources/AAS_Reference_shortExample.ttl | 27 - .../AssetAdministrationShell_Example.ttl | 56 - .../src/test/resources/Complete_Example.ttl | 347 ----- .../src/test/resources/Overall-Example.nt | 253 ---- .../src/test/resources/ReferenceExample.ttl | 18 - .../Submodel_SubmodelElement_Example.ttl | 137 -- .../Submodel_SubmodelElement_shortExample.nt | 25 - .../Submodel_SubmodelElement_shortExample.ttl | 42 - .../resources/example-from-serializer.jsonld | 88 -- .../aas4j/v3/model/Identifiable.java | 3 +- 125 files changed, 1169 insertions(+), 6317 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{RdfParser.java => RDFParser.java} (98%) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java rename dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{RdfSerializer.java => RDFSerializer.java} (93%) delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/doc.md create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java delete mode 100644 dataformat-rdf/src/test/resources/AASFull.ttl delete mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt delete mode 100644 dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Complete_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Overall-Example.nt delete mode 100644 dataformat-rdf/src/test/resources/ReferenceExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt delete mode 100644 dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl delete mode 100644 dataformat-rdf/src/test/resources/example-from-serializer.jsonld 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..d75755bad --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AASNamespace.java @@ -0,0 +1,239 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Property; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; + +/** + * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. + */ +public class AASNamespace { + public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; + + public static final 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 class Key { + /** + * The key value, for example an IRDI or an URI + */ + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/value"); + /** + * Denotes which kind of entity is referenced. + */ + public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); + } + + public static class Reference { + public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); + public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); + } + + public static class Referable { + public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); + public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); + public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); + public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); + } + + public static class Identifiable { + public static final Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); + public static final 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 Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); + } + + /** + * Enumeration of different key value types within a key. + * + * @see AASNamespace.Key + */ + public static class KeyTypes { + public static final Resource AnnotatedRelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); + public static final Resource AssetAdministrationShell = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AssetAdministrationShell"); + public static final Resource BasicEventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/BasicEventElement"); + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Blob"); + public static final Resource Capability = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Capability"); + public static final Resource ConceptDescription = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ConceptDescription"); + public static final Resource DataElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/DataElement"); + public static final Resource Entity = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Entity"); + public static final Resource EventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/EventElement"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/File"); + public static final Resource FragmentReference = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/FragmentReference"); + public static final Resource GlobalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/GlobalReference"); + public static final Resource Identifiable = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Identifiable"); + public static final Resource MultiLanguageProperty = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/MultiLanguageProperty"); + public static final Resource Operation = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Operation"); + public static final Resource Property = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Property"); + public static final Resource Range = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Range"); + public static final Resource ReferenceElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ReferenceElement"); + public static final Resource RelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/RelationshipElement"); + public static final Resource Submodel = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Submodel"); + public static final Resource SubmodelElement = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElement"); + public static final Resource SubmodelElementCollection = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); + public static final Resource SubmodelElementList = + ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementList"); + public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI){ + 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; + } + throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); + } + public static 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; + } + + throw new IllegalArgumentException("Invalid ReferenceType provided."); + } + } + + public static class ReferenceTypes { + 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 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 Resource ExternalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); + public static final Resource ModelReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ModelReference"); + } + + public static class Types { + + public static final Resource AdministrativeInformation = + ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); + public static final Resource AnnotatedRelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "AnnotatedRelationshipElement"); + public static final Resource AssetAdministrationShell = + ResourceFactory.createResource(AAS_NAMESPACE + "AssetAdministrationShell"); + public static final Resource AssetInformation = + ResourceFactory.createResource(AAS_NAMESPACE + "AssetInformation"); + public static final Resource BasicEventElement = + ResourceFactory.createResource(AAS_NAMESPACE + "BasicEventElement"); + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "Blob"); + public static final Resource Capability = + ResourceFactory.createResource(AAS_NAMESPACE + "Capability"); + public static final Resource ConceptDescription = + ResourceFactory.createResource(AAS_NAMESPACE + "ConceptDescription"); + public static final Resource DataSpecificationIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "DataSpecificationIec61360"); + public static final Resource EmbeddedDataSpecification = + ResourceFactory.createResource(AAS_NAMESPACE + "EmbeddedDataSpecification"); + public static final Resource Entity = + ResourceFactory.createResource(AAS_NAMESPACE + "Entity"); + public static final Resource Extension = + ResourceFactory.createResource(AAS_NAMESPACE + "Extension"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "File"); + + public static final Resource Key = + ResourceFactory.createResource(AAS_NAMESPACE + "Key"); + public static final Resource LangStringDefinitionTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringDefinitionTypeIec61360"); + public static final Resource LangStringNameType = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringNameType"); + public static final Resource LangStringPreferredNameTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringPreferredNameTypeIec61360"); + public static final Resource LangStringShortNameTypeIec61360 = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringShortNameTypeIec61360"); + public static final Resource LangStringTextType = + ResourceFactory.createResource(AAS_NAMESPACE + "LangStringTextType"); + public static final Resource LevelType = + ResourceFactory.createResource(AAS_NAMESPACE + "LevelType"); + public static final Resource MultiLanguageProperty = + ResourceFactory.createResource(AAS_NAMESPACE + "MultiLanguageProperty"); + public static final Resource Operation = + ResourceFactory.createResource(AAS_NAMESPACE + "Operation"); + public static final Resource OperationVariable = + ResourceFactory.createResource(AAS_NAMESPACE + "OperationVariable"); + public static final Resource Property = + ResourceFactory.createResource(AAS_NAMESPACE + "Property"); + public static final Resource Qualifier = + ResourceFactory.createResource(AAS_NAMESPACE + "Qualifier"); + public static final Resource Range = + ResourceFactory.createResource(AAS_NAMESPACE + "Range"); + public static final Resource Reference = + ResourceFactory.createResource(AAS_NAMESPACE + "Reference"); + public static final Resource ReferenceElement = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceElement"); + public static final Resource RelationshipElement = + ResourceFactory.createResource(AAS_NAMESPACE + "RelationshipElement"); + public static final Resource Resource = + ResourceFactory.createResource(AAS_NAMESPACE + "Resource"); + public static final Resource SpecificAssetId = + ResourceFactory.createResource(AAS_NAMESPACE + "SpecificAssetId"); + public static final Resource Submodel = + ResourceFactory.createResource(AAS_NAMESPACE + "Submodel"); + public static final Resource SubmodelElementCollection = + ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementCollection"); + public static final Resource SubmodelElementList = + ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementList"); + public static final Resource ValueList = + ResourceFactory.createResource(AAS_NAMESPACE + "ValueList"); + public static final Resource ValueReferencePair = + ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); + + } +} 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..57daf095d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DefaultRDFHandlerResult.java @@ -0,0 +1,31 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; + +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/FallbackSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java deleted file mode 100644 index 1522e476d..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/FallbackSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; -import java.util.Map; - -public class FallbackSerializer extends StdSerializer> { - - - public FallbackSerializer() { - this(null); - } - - public FallbackSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(Map value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeString(value.toString()); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java deleted file mode 100644 index 816c77d39..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IgnoreTypeMixIn.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonIgnoreType; - -@JsonIgnoreType -public class IgnoreTypeMixIn { -} 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..1b7cb3c4e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/IncompatibleTypeException.java @@ -0,0 +1,7 @@ +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"); + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java deleted file mode 100644 index 0f403a1d7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDModule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.databind.module.SimpleModule; - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.BigDecimalSerializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarDeserializer; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.XMLGregorianCalendarSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; - -import java.math.BigDecimal; -import java.net.URI; -import java.util.Map; - - -import javax.xml.datatype.XMLGregorianCalendar; - - -/** - * Jackson module which provides support for JSON-LD serialization - */ -public class JsonLDModule extends SimpleModule { - - - public JsonLDModule(Map idMap) { - super(); - - setSerializerModifier(new JsonLDSerializerModifier(idMap)); - - addSerializer(XMLGregorianCalendar.class, new XMLGregorianCalendarSerializer()); - addDeserializer(XMLGregorianCalendar.class, new XMLGregorianCalendarDeserializer()); - addSerializer(BigDecimal.class, new BigDecimalSerializer()); - - addSerializer(URI.class, new UriSerializer()); - addSerializer(AbstractLangString.class, new LangStringSerializer()); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java deleted file mode 100644 index 5c28c71c3..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializer.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.type.WritableTypeId; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; -import com.fasterxml.jackson.databind.ser.BeanSerializer; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.math.BigInteger; -import java.util.*; -import java.util.stream.Stream; - - -public class JsonLDSerializer extends BeanSerializer { - - private final Logger logger = LoggerFactory.getLogger(JsonLDSerializer.class); - - private static int currentRecursionDepth = 0; - - static final Map contextItems = new HashMap<>(); - - private final Map idMap; - - JsonLDSerializer(BeanSerializerBase src, Map idMap) { - super(src); - this.idMap = Objects.requireNonNullElseGet(idMap, HashMap::new); - } - - - - @Override - public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { - gen.setCurrentValue(bean); - - currentRecursionDepth++; - gen.writeStartObject(); - - if (currentRecursionDepth == 1) { - Map filteredContext = new HashMap<>(); - filterContextWrtBean(bean, filteredContext); - gen.writeObjectField("@context", filteredContext); - //gen.writeStringField("@context", "https://jira.iais.fraunhofer.de/stash/projects/ICTSL/repos/ids-infomodel-commons/raw/jsonld-context/3.0.0/context.jsonld"); // only add @context on top level - - } - - if(idMap.containsKey(bean)) - { - gen.writeStringField("@id", idMap.get(bean)); - } - else - { - String randomUri = "https://admin-shell.io/autogen/" + bean.getClass().getSimpleName() + "/" + UUID.randomUUID(); - idMap.put(bean, randomUri); - gen.writeStringField("@id", randomUri); - } - - WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_OBJECT); - String resolvedTypeId = typeIdDef.id != null ? typeIdDef.id.toString() : typeSer.getTypeIdResolver().idFromValue(bean); - if (resolvedTypeId != null) { - gen.writeStringField(typeIdDef.asProperty, resolvedTypeId); - } - if (_propertyFilterId != null) { - serializeFieldsFiltered(bean, gen, provider); - } else { - serializeFields(bean, gen, provider); - } - gen.writeEndObject(); - currentRecursionDepth--; - } - - - private void filterContextWrtBean(Object bean, Map filteredContext) { - //Some default entries for AAS - filteredContext.put("aas", "https://admin-shell.io/aas/3/0/"); - //filteredContext.put("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); - //filteredContext.put("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); - - if(bean == null || bean.getClass().getName().equals("com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass().getName().equals("org.apache.jena.ext.xerces.jaxp.datatype.XMLGregorianCalendarImpl") || bean.getClass() == BigInteger.class) return; // XMLGregorianCalendarImpl causes infinite recursion - - //Check if RdfResource or TypedLiteral is used. They contain a field called "type" which can reference to any namespace - //Therefore it is vital to also check the value of the type field for prefixes that need to be included in the context - if(bean.getClass().getSimpleName().equals("LangString")) - { - //LangString is of type rdf:langString, so this must be present - filteredContext.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - } - contextItems.forEach((p, u) -> { - JsonTypeName typeNameAnnotation = bean.getClass().getAnnotation(JsonTypeName.class); - if(typeNameAnnotation != null && typeNameAnnotation.value().contains(p)) { - filteredContext.put(p, u); - } - Stream.of(bean.getClass().getMethods()).forEach(m -> { - JsonProperty propertyAnnotation = m.getAnnotation(JsonProperty.class); - if(propertyAnnotation != null && propertyAnnotation.value().contains(p)) { - filteredContext.put(p, u); - } - }); - }); - Stream.of(bean.getClass().getMethods()).forEach(m -> { - // run though all properties and check annotations. These annotations should contain the prefixes - JsonProperty prop = m.getAnnotation(JsonProperty.class); - if(prop != null) - { - for(Map.Entry entry : contextItems.entrySet()) - { - if(prop.value().startsWith(entry.getKey())) - { - filteredContext.put(entry.getKey(), entry.getValue()); - break; - } - } - } - }); - // run through fields recursively - for(Field f : getAllFields(new HashSet<>(), bean.getClass())) { - - if(Collection.class.isAssignableFrom(f.getType())) - { - try { - if(f.getType().getName().startsWith("java.") && !f.getType().getName().startsWith("java.util")) continue; - boolean accessible = f.isAccessible(); - f.setAccessible(true); - Collection c = (Collection) f.get(bean); - if(c == null) { - continue; - } - for(Object o : c) - { - filterContextWrtBean(o, filteredContext); - } - f.setAccessible(accessible); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - if (f.getType().isPrimitive() || f.getType().isEnum() || f.getType().isArray() - || f.getType().getName().contains("java.") - || f.getType().getName().contains("javax.")) continue; - - try { - boolean wasAccessible = f.isAccessible(); - f.setAccessible(true); - filterContextWrtBean(f.get(bean), filteredContext); - f.setAccessible(wasAccessible); - } catch (IllegalAccessException ignored) { - //logger.error("setting accessible failed"); //We can catch that here, as IllegalReflectiveAccess cannot occur on our own packages - } - - //f.trySetAccessible(wasAccessible); - - } - - } - - /** - * This function retrieves a set of all available fields of a class, including inherited fields - * @param fields Set to which discovered fields will be added. An empty HashSet should do the trick - * @param type The class for which fields should be discovered - * @return set of all available fields - */ - private static Set getAllFields(Set fields, Class type) { - fields.addAll(Arrays.asList(type.getDeclaredFields())); - - if (type.getSuperclass() != null) { - getAllFields(fields, type.getSuperclass()); - } - - return fields; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java deleted file mode 100644 index d1bff7f5c..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLDSerializerModifier.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf; - - -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; - -import java.util.Map; - - -public class JsonLDSerializerModifier extends BeanSerializerModifier { - - private final Map idMap; - - public JsonLDSerializerModifier(Map idMap) { - this.idMap = idMap; - } - - @Override - public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer serializer) { - if (serializer instanceof BeanSerializerBase) { - return new JsonLDSerializer((BeanSerializerBase) serializer, idMap); - } else { - return serializer; - } - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java deleted file mode 100644 index 8d544ab14..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/JsonLdEnumSerializer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.io.IOException; - -public class JsonLdEnumSerializer extends JsonSerializer> { - - - @Override - public void serialize(Enum value, JsonGenerator gen, SerializerProvider provider) throws IOException { - //Generated Enum classes of the admin shell have @IRI annotations, which need to be used to provide proper RDF - if(value.getClass().isEnum() && value.getClass().getName().startsWith("org.eclipse.digitaltwin.aas4j.")) - { - //Try to get annotation value to get the IRI used in the ontology - if(value.getClass().getAnnotation(IRI.class) != null && value.getClass().getAnnotation(IRI.class).value().length > 0) - { - gen.writeStartObject(); - gen.writeStringField("@type", value.getClass().getAnnotation(IRI.class).value()[0]); - - //Try to extract exact IRI of the enum value, if present - try { - var annotation = value.getClass().getField(value.name()).getAnnotation(IRI.class); - if(annotation != null && annotation.value().length > 0) - { - gen.writeStringField("@id", annotation.value()[0]); - } - else - { - //Didn't find an @IRI annotation - fall back to using class annotation + field name - gen.writeStringField("@id", translate(value.getClass(), value.name())); - } - } - //Should be impossible - catch (NoSuchFieldException e) - { - //Didn't find an @IRI annotation - fall back to using class annotation + field name - gen.writeStringField("@id", translate(value.getClass(), value.name())); - } - gen.writeEndObject(); - } - else - { - gen.writeString(translate(value.getClass(), value.name())); - } - - - } else { - provider.findValueSerializer(Enum.class).serialize(value, gen, provider); - } - } - - - - public static String translate(Class enumClass, String input) { - String[] iriValues = enumClass.getAnnotation(IRI.class).value(); - String result = ""; - if(iriValues.length > 0) - { - result = iriValues[0]; - if(!result.endsWith("/")) - { - result += "/"; - } - } - result += input; - return result; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java deleted file mode 100644 index cdd3409db..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/LangStringSerializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf; - -import java.io.IOException; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; - -public class LangStringSerializer extends StdSerializer { - - - public LangStringSerializer() { - this(null); - } - - public LangStringSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(AbstractLangString value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeStartObject(); - if(value.getLanguage() != null && !value.getLanguage().isEmpty()) - { - gen.writeStringField("@language", value.getLanguage()); - } - else - { - gen.writeStringField("@type", "rdf:langString"); - } - gen.writeStringField("@value", value.getText()); - gen.writeEndObject(); - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java deleted file mode 100644 index a9d0d7540..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserHelper.java +++ /dev/null @@ -1,1129 +0,0 @@ -/* - * 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.rdf; - -import org.eclipse.digitaltwin.aas4j.v3.model.AbstractLangString; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes; -import org.apache.jena.datatypes.DatatypeFormatException; -import org.apache.jena.query.*; -import org.apache.jena.rdf.model.*; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.RiotException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.lang.reflect.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.ZonedDateTime; -import java.time.format.DateTimeParseException; -import java.util.*; -import java.util.stream.Collectors; - - -/** - * Internal class to handle the parsing of JSON-LD into java objects - * - * @author maboeckmann - */ -class ParserHelper { - - private static final URI blankNodeIdPropertyUri = URI.create("https://admin-shell.io/aas/blankNodeId"); - static Map knownNamespaces = new HashMap<>(); - private final Logger logger = LoggerFactory.getLogger(ParserHelper.class); - /** - * This list contains all primitive Java types - */ - private final Map> builtInMap = new HashMap<>(); - - { - builtInMap.put("int", Integer.TYPE); - builtInMap.put("long", Long.TYPE); - builtInMap.put("double", Double.TYPE); - builtInMap.put("float", Float.TYPE); - builtInMap.put("bool", Boolean.TYPE); - builtInMap.put("char", Character.TYPE); - builtInMap.put("byte", Byte.TYPE); - builtInMap.put("void", Void.TYPE); - builtInMap.put("short", Short.TYPE); - } - - /** - * Main internal method for creating a java object from a given RDF graph and a URI of the object to handle - * - * @param inputModel Model on which queries are to be evaluated from which information can be retrieved - * @param objectUri URI of the object to be handled - * @param targetClass Variable containing the class which should be returned - * @param Class which should be returned - * @return Object of desired class, filled with the values extracted from inputModel - * @throws IOException thrown if the parsing fails - */ - private T handleObject(Model inputModel, String objectUri, Class targetClass) throws IOException { - - try { - - //if(!targetClass.getSimpleName().endsWith("Impl")) //This would not work for "TypedLiteral", "RdfResource" and so on - //Check whether we are dealing with an instantiable class (i.e. no interface and no abstract class) - boolean currentObjectIsBlankNode = false; - if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { - //We don't know the desired class yet (current targetClass is not instantiable). This is only known for the root object - ArrayList> implementingClasses = getImplementingClasses(targetClass); - String queryString; - //Get a list of all "rdf:type" statements in our model - //In case of a blank node, the "object URI" will just be a string and no valid URI. In that case, we need a different query syntax - try { - new URL(objectUri); - } catch (MalformedURLException e) { - currentObjectIsBlankNode = true; - } - if (currentObjectIsBlankNode) { - //Object is a blank node, so the subject URI cannot be used - queryString = "SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> \"" + objectUri + "\" ; a ?type . }"; - } else { - //Not a blank node, so we can work with the subject URI - queryString = "SELECT ?type { BIND(<" + objectUri + "> AS ?s). ?s a ?type . }"; - } - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); - ResultSet resultSet = queryExecution.execSelect(); - - if (!resultSet.hasNext()) { - queryExecution.close(); - throw new IOException("Could not extract class of child object. ID: " + objectUri); - } - - //Class candidateClass = null; - - String fullName = "No triple present indicating type."; - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - fullName = solution.get("type").toString(); - - //Expected URI is something like https://w3id.org/idsa/core/ClassName (and we want ClassName) - String className = fullName.substring(fullName.lastIndexOf('/') + 1); - - //Some namespaces use "#" instead of "/" - if (className.contains("#")) { - className = className.substring(className.lastIndexOf("#") + 1); - } - -// for (Class currentClass : implementingClasses) { -// //Is this class instantiable? -// if (!currentClass.isInterface() && !Modifier.isAbstract(currentClass.getModifiers())) { -// //candidateClass = currentClass; -// if (currentClass.getSimpleName().equals(className) || currentClass.getSimpleName().equals(this.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { -// targetClass = (Class) currentClass; -// break; -// } -// } -// } - } - queryExecution.close(); - //Did we find "the" class, i.e. instantiable and name matches? - if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { - //No, the current targetClass cannot be instantiated. Do we have a candidate class? - //if (candidateClass != null) { - throw new IOException("Did not find an instantiable class for " + objectUri + " matching expected class name (" + targetClass.getSimpleName() + "). Object has type: " + fullName); - //targetClass = (Class) candidateClass; - //} - } - } - - //Enums have no constructors - if (targetClass.isEnum()) { - return handleEnum(targetClass, objectUri); - } - - //Get constructor (which is package private for our classes) and make it accessible - Constructor constructor = targetClass.getDeclaredConstructor(); - constructor.setAccessible(true); - - //Instantiate new object, which will be returned at the end - T returnObject = constructor.newInstance(); - - //Get methods - Method[] methods = returnObject.getClass().getDeclaredMethods(); - - //Store methods in map. Key is the name of the RDF property without ids prefix - Map methodMap = new HashMap<>(); - - //Get all relevant methods (setters, but not for label, comment or external properties) - Arrays.stream(methods).filter(method -> { - String name = method.getName(); - //Filter out irrelevant methods - return name.startsWith("set") && !name.equals("setProperty") && !name.equals("setComment") && !name.equals("setLabel"); // && !name.equals("setId"); - }).forEach(method -> { - //Remove "set" part - String reducedName = method.getName().substring(3); - - //Turn first character to lower case - char[] c = reducedName.toCharArray(); - c[0] = Character.toLowerCase(c[0]); - String finalName = new String(c); - methodMap.put(finalName, method); - - }); - - //There is no "setId" method in our CodeGen generated classes, so we get the field - /* TODO: No "id" field yet - Field idField = returnObject.getClass().getDeclaredField("id"); - - //Store whether or not it was accessible, so that we can undo making it accessible - boolean wasAccessible = idField.isAccessible(); - idField.setAccessible(true); - - //Set the ID of the object to be identical with the objectUri parameter - idField.set(returnObject, new URI(objectUri)); - idField.setAccessible(wasAccessible); - */ - - //Is this a trivial class with 0 fields? If so, the generated query would be "SELECT { }", which is illegal - if (methodMap.isEmpty()) { - return returnObject; - } - - - //A list which stores all those parameter names which may occur only once (i.e. those occurring in the GROUP BY clause) - List groupByKeys = new ArrayList<>(); - - StringBuilder queryStringBuilder = new StringBuilder(); - - for (Map.Entry entry : knownNamespaces.entrySet()) { - queryStringBuilder.append("PREFIX ").append(entry.getKey()); - if (!entry.getKey().endsWith(":")) { - queryStringBuilder.append(":"); - } - queryStringBuilder.append(" <").append(entry.getValue()).append(">\n"); - } - queryStringBuilder.append("SELECT"); - methodMap.forEach((key1, value) -> { - //Is the return type some sort of List? - if (Collection.class.isAssignableFrom(value.getParameterTypes()[0])) { - boolean isTypedLiteral = false; - //Yes, it is assignable multiple times. Concatenate multiple values together using some delimiter - try { - //ArrayLists are generics. We need to extract the name of the generic parameter as string and interpret that - String typeName = extractTypeNameFromCollection(value.getGenericParameterTypes()[0]); - - if (typeName.endsWith("LangString")) - isTypedLiteral = true; - } catch (IOException e) { - e.printStackTrace(); - } - if (isTypedLiteral) { - queryStringBuilder.append(" (GROUP_CONCAT(CONCAT('\"',?").append(key1).append(",'\"@', lang(?").append(key1).append("));separator=\"||\") AS ?").append(key1).append("sLang) "); - } - queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append(";separator=\"||\") AS ?").append(key1).append("s) "); - - //Additional case for blank nodes - queryStringBuilder.append(" (GROUP_CONCAT(?").append(key1).append("Blank;separator=\"||\") AS ?").append(key1).append("sBlank) "); - - - } else { - //No, it's not a list. No need to aggregate - queryStringBuilder.append(" ?").append(key1); - //We will have to GROUP BY this variable though... - groupByKeys.add(key1); - } - }); - //Start the "WHERE" part - Fuseki does not expect the "WHERE" keyword, but just an "{" - queryStringBuilder.append(" { "); - - //In case of blank nodes, we can't work with the subject URI - if (currentObjectIsBlankNode) { - queryStringBuilder.append("?s <").append(blankNodeIdPropertyUri).append("> \"").append(objectUri).append("\" ;"); - } else { - queryStringBuilder.append(" <").append(objectUri).append(">"); - } - - //Make sure that the object is of the correct type - //This is particularly relevant in case of all fields being optional -- then one could simply parse a random object - queryStringBuilder.append(" a ").append(wrapIfUri(targetClass.getAnnotation(IRI.class).value()[0])).append(". "); - - for (Map.Entry entry : methodMap.entrySet()) { - //Is this a field which is annotated by NOT NULL? - //Attempt to find a field matching the setter method name - //E.g. for "setSomething", we search for a field with name "_something" (IDS way) and "something" - Field field = getFieldByName(targetClass, entry.getKey()); - - - //In AAS, every field is optional, as there are no validation annotations in the model - queryStringBuilder.append(" OPTIONAL {"); - - if (currentObjectIsBlankNode) { - queryStringBuilder.append(" ?s "); - } else { - queryStringBuilder.append(" <").append(objectUri).append("> "); //subject, as passed to the function - } - //For the field, get the JsonAlias annotation (present for all classes generated by the CodeGen tool) - //Find the annotation value containing a colon and interpret this as "prefix:predicate" - boolean foundAnnotation = false; - if (field.getAnnotation(IRI.class) != null) { - Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).map(this::wrapIfUri).filter(annotation -> annotation.contains(":")).findFirst(); - currentAnnotation.ifPresent(queryStringBuilder::append); - foundAnnotation = true; - } - if (!foundAnnotation) { - logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); - queryStringBuilder.append("aas:").append(entry.getKey()); - } - //if(isBlank(?entry.getKey(), use value of artificial, use original value) - queryStringBuilder.append(" ?").append(entry.getKey()).append(" ."); //object - - //In case of the object being a blank node, we construct a second result variable with the blank node id - queryStringBuilder.append("OPTIONAL { ?").append(entry.getKey()).append(" <").append(blankNodeIdPropertyUri).append("> ?").append(entry.getKey()).append("Blank . } "); - - queryStringBuilder.append("} "); - } - - - queryStringBuilder.append(" } "); - - //Do we need to group? We do, if there is at least one property which can occur multiple times - //We added all those properties, which may only occur once, to the groupByKeys list - if (!groupByKeys.isEmpty()) { - queryStringBuilder.append("GROUP BY"); - for (String key : groupByKeys) { - queryStringBuilder.append(" ?").append(key); - } - } - - String queryString = queryStringBuilder.toString(); - - StringBuilder queryForOtherProperties = new StringBuilder(); - //Query for all unknown properties and their values - //Select properties and values only - - if (!targetClass.equals(AbstractLangString.class)) { //LangString has no additional properties map. Skip this step - - //CONSTRUCT { ?s ?p ?o } { ?s ?p ?o. FILTER(?p NOT IN (list of ids properties)) } - for (Map.Entry entry : knownNamespaces.entrySet()) { - queryForOtherProperties.append("PREFIX ").append(entry.getKey()); - if (!entry.getKey().endsWith(":")) { - queryForOtherProperties.append(":"); - } - queryForOtherProperties.append(" <").append(entry.getValue()).append(">\n"); - } - - - //Respect ALL properties and values - queryForOtherProperties.append(" SELECT ?p ?o { <").append(objectUri).append("> ?p ?o .\n"); - - //Exclude known properties - queryForOtherProperties.append("FILTER (?p NOT IN (rdf:type"); - - //Predicates usually look like: .append("ids:").append(entry.getKey()) - for (Map.Entry entry : methodMap.entrySet()) { - queryForOtherProperties.append(", "); - - Field field = getFieldByName(targetClass, entry.getKey()); - Optional currentAnnotation = Arrays.stream(field.getAnnotation(IRI.class).value()).filter(annotation -> annotation.contains(":")).filter(s -> s.length() > 1).findFirst(); - if (currentAnnotation.isPresent()) { - queryForOtherProperties.append(wrapIfUri(currentAnnotation.get())); - } else { - logger.warn("Failed to retrieve JsonAlias for field " + field + ". Assuming aas:" + entry.getKey()); - queryForOtherProperties.append("aas:").append(entry.getKey()); - } - } - - queryForOtherProperties.append(")). } "); - - - //Now that we searched for all "known properties", let's search for all unrecognized content and append it to a generic properties map - - Query externalPropertiesQuery = QueryFactory.create(queryForOtherProperties.toString()); - QueryExecution externalPropertiesQueryExecution = QueryExecutionFactory.create(externalPropertiesQuery, inputModel); - ResultSet externalPropertiesResultSet = externalPropertiesQueryExecution.execSelect(); - - // now as all declared instances and classes are treated, which are also represented in the respective java - // dependency, take care about the ones within foreign namespaces and add those to the 'properties' field - // note that not all models (e.g. AAS) have such methods. In case they do not exist, skip adding external properties - - try { - Method setProperty = returnObject.getClass().getDeclaredMethod("setProperty", String.class, Object.class); - Method getProperties = returnObject.getClass().getDeclaredMethod("getProperties"); - - while (externalPropertiesResultSet.hasNext()) { - QuerySolution externalPropertySolution = externalPropertiesResultSet.next(); - - HashMap currentProperties = (HashMap) getProperties.invoke(returnObject); - - //Avoid NullPointerException - if (currentProperties == null) { - currentProperties = new HashMap<>(); - } - - String propertyUri = externalPropertySolution.get("p").toString(); - - //Does this key already exist? If yes, we need to store the value as array to not override them - if (currentProperties.containsKey(propertyUri)) { - //If it is not an array list yet, turn it into one - if (!(currentProperties.get(propertyUri) instanceof ArrayList)) { - ArrayList newList = new ArrayList<>(); - newList.add(currentProperties.get(propertyUri)); - currentProperties.put(propertyUri, newList); - } - } - - //Literals and complex objects need to be handled differently - //Literals can be treated as flat values, whereas complex objects require recursive calls - if (externalPropertySolution.get("o").isLiteral()) { - Object o = handleForeignLiteral(externalPropertySolution.getLiteral("o")); - //If it is already an ArrayList, add new value to it - if (currentProperties.containsKey(propertyUri)) { - ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); - currentPropertyArray.add(o); - setProperty.invoke(returnObject, propertyUri, currentPropertyArray); - } - //Otherwise save as new plain value - else { - setProperty.invoke(returnObject, propertyUri, o); - } - } else { - //It is a complex object. Distinguish whether or not we need to store as array - HashMap subMap = handleForeignNode(externalPropertySolution.getResource("o"), new HashMap<>(), inputModel); - subMap.put("@id", externalPropertySolution.getResource("o").getURI()); - if (currentProperties.containsKey(propertyUri)) { - ArrayList currentPropertyArray = ((ArrayList) currentProperties.get(propertyUri)); - currentPropertyArray.add(subMap); - setProperty.invoke(returnObject, propertyUri, currentPropertyArray); - } else { - setProperty.invoke(returnObject, propertyUri, subMap); - } - } - } - externalPropertiesQueryExecution.close(); - } catch (NoSuchMethodException ignored) { - //Method does not exist, skip - } - } - - - Query query; - try { - query = QueryFactory.create(queryString); - } catch (QueryParseException e) { - logger.error(queryString); - throw e; - } - - //Evaluate query - QueryExecution queryExecution = QueryExecutionFactory.create(query, inputModel); - ResultSet resultSet = queryExecution.execSelect(); - - - if (!resultSet.hasNext()) { - queryExecution.close(); - //no content... - return returnObject; - } - - //SPARQL binding present, iterate over result and construct return object - while (resultSet.hasNext()) { - QuerySolution querySolution = resultSet.next(); - - //Check if there are fields which have more values than allowed - if (resultSet.hasNext()) { - String value1 = "", value2 = "", parameterName = ""; - QuerySolution querySolution2 = resultSet.next(); - Iterator varNamesIt = querySolution2.varNames(); - while (varNamesIt.hasNext()) { - String varName = varNamesIt.next(); - if (querySolution.contains(varName)) { - if (!querySolution.get(varName).equals(querySolution2.get(varName))) { - parameterName = varName; - value1 = querySolution.get(varName).toString(); - value2 = querySolution2.get(varName).toString(); - break; - } - } - } - if (!value1.isEmpty()) { - throw new IOException(objectUri + " has multiple values for " + parameterName + ", which is not allowed. Values are: " + value1 + " and " + value2); - } - throw new IOException("Multiple bindings for SPARQL query which should only have one binding. Input contains multiple values for a field which may occur only once."); - } - - //No value occurs more often than allowed - for (Map.Entry entry : methodMap.entrySet()) { - - //What is this method setting? Get the expected parameter type and check whether it is some complex sub-object and whether this is a list - Class currentType = entry.getValue().getParameterTypes()[0]; - - String sparqlParameterName = entry.getKey(); - - if (Collection.class.isAssignableFrom(currentType)) { - sparqlParameterName += "s"; //plural form for the concatenated values - } - if (!querySolution.contains(sparqlParameterName)) { - sparqlParameterName += "Blank"; //If not present, try to go with the option for blank nodes instead - //TODO: Note: This would not yield full results yet in case some of the values are encapsulated - // in blank nodes and some are not, for the same property - } - if (querySolution.contains(sparqlParameterName)) { - String currentSparqlBinding = querySolution.get(sparqlParameterName).toString(); - - boolean objectIsBlankNode = querySolution.get(sparqlParameterName).isResource() && querySolution.get(sparqlParameterName).asNode().isBlank(); - String blankNodeId = ""; - //If the object is a blank node, we will struggle to make follow-up queries starting at the blank node as subject - //For that case, we add some artificial identifiers here - if (objectIsBlankNode) { - blankNodeId = querySolution.get(sparqlParameterName).asNode().getBlankNodeId().toString(); - } - if (currentType.isEnum()) { - //Two possibilities: - //1: The URI of the enum value is given directly e.g. ?s ?p - //2: The URI of the enum value is encapsulated in a blank node, e.g. - // ?s ?p [ a demo:myEnum, demo:enumValue ] - if (objectIsBlankNode) { - - Query innerEnumQuery = QueryFactory.create("SELECT ?type { ?s <" + blankNodeIdPropertyUri + "> + \"" + blankNodeId + "\" ; a ?type } "); - QueryExecution innerEnumQueryExecution = QueryExecutionFactory.create(innerEnumQuery, inputModel); - ResultSet innerEnumQueryExecutionResultSet = innerEnumQueryExecution.execSelect(); - - //Only throw this if there is no successful execution - IOException anyIOException = null; - boolean oneSuccessfulEnumFound = false; - while (innerEnumQueryExecutionResultSet.hasNext()) { - try { - entry.getValue().invoke(returnObject, handleEnum(currentType, innerEnumQueryExecutionResultSet.next().get("type").toString())); - oneSuccessfulEnumFound = true; - break; //Stop after the first successful execution - } catch ( - IOException e) //There might be errors, if multiple types are present, see example above - { - anyIOException = e; - } - } - //If nothing worked, but something failed (i.e. there exists a problematic element, but no proper element), we throw an exception - if (anyIOException != null && !oneSuccessfulEnumFound) - throw new IOException("Could not parse Enum. ", anyIOException); - innerEnumQueryExecution.close(); - } else { - entry.getValue().invoke(returnObject, handleEnum(currentType, currentSparqlBinding)); - } - continue; - } - - - //There is a binding. If it is a complex sub-object, we need to recursively call this function - if (Collection.class.isAssignableFrom(currentType)) { - //We are working with ArrayLists. - //Here, we need to work with the GenericParameterTypes instead to find out what kind of ArrayList we are dealing with - String typeName = extractTypeNameFromCollection(entry.getValue().getGenericParameterTypes()[0]); - if (isArrayListTypePrimitive(entry.getValue().getGenericParameterTypes()[0])) { - if (typeName.endsWith("LangString")) { - try { - currentSparqlBinding = querySolution.get(sparqlParameterName + "Lang").toString(); - } catch (NullPointerException e) { - //logger.warn("Failed to retrieve localized/typed values of " + currentSparqlBinding + ". Make sure that namespaces used in this property are known and valid. Proceeding without localized values and interpreting as string."); - //logger.warn("Query was: " + queryString); - //logger.warn("Attempted to fetch: " + sparqlParameterName + "Lang"); - } - } - ArrayList list = new ArrayList<>(); - //Two pipes were used as delimiter above - //Introduce set to deduplicate - Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); - for (String s : allElements) { - Literal literal; - //querySolution.get(sparqlParameterName). - if (s.endsWith("@")) { - s = s.substring(2, s.length() - 3); - literal = ResourceFactory.createStringLiteral(s); - } else if (s.startsWith("\\")) { - //turn something like \"my Desc 1\"@en to "my Desc 1"@en - s = s.substring(1).replace("\\\"@", "\"@"); - literal = ResourceFactory.createLangLiteral(s.substring(1, s.lastIndexOf("@") - 1), s.substring(s.lastIndexOf("@") + 1)); - } else { - literal = ResourceFactory.createPlainLiteral(s); - } - - //Is the type of the ArrayList some built in Java primitive? - - if (builtInMap.containsKey(typeName)) { - //Yes, it is. We MUST NOT call Class.forName(name)! - list.add(handlePrimitive(builtInMap.get(typeName), literal, null)); - } else { - //Not a Java primitive, we may call Class.forName(name) - list.add(handlePrimitive(Class.forName(typeName), literal, s)); - } - } - entry.getValue().invoke(returnObject, list); - } else { - //List of complex sub-objects, such as a list of Resources in a ResourceCatalog - ArrayList list = new ArrayList<>(); - Set allElements = new HashSet<>(Arrays.asList(currentSparqlBinding.split("\\|\\|"))); - for (String s : allElements) { - if (Class.forName(typeName).isEnum()) { - list.add(handleEnum(Class.forName(typeName), s)); - } else { - list.add(handleObject(inputModel, s, Class.forName(typeName))); - } - } - entry.getValue().invoke(returnObject, list); - } - } - - //Not an ArrayList of objects expected, but rather one object - else { - //Our implementation of checking for primitives (i.e. also includes URLs, Strings, XMLGregorianCalendars, ...) - if (isPrimitive(currentType)) { - - Literal literal = null; - try { - literal = querySolution.getLiteral(sparqlParameterName); - } catch (Exception ignored) { - } - - entry.getValue().invoke(returnObject, handlePrimitive(currentType, literal, currentSparqlBinding)); - - } else { - //Not a primitive object, but a complex sub-object. Recursively call this function to handle it - if (objectIsBlankNode) { - entry.getValue().invoke(returnObject, handleObject(inputModel, blankNodeId, entry.getValue().getParameterTypes()[0])); - } else { - - entry.getValue().invoke(returnObject, handleObject(inputModel, currentSparqlBinding, entry.getValue().getParameterTypes()[0])); - } - } - } - } - - } - } - queryExecution.close(); - - return returnObject; - } catch (NoSuchMethodException | NullPointerException | IllegalAccessException | InstantiationException | - InvocationTargetException | NoSuchFieldException | URISyntaxException | - DatatypeConfigurationException | ClassNotFoundException e) { - throw new IOException("Failed to instantiate desired class (" + targetClass.getName() + ")", e); - } - } - - /** - * This function wraps a URI with "<" ">", if needed, to avoid errors about "unknown namespace http(s):" - * - * @param input Input URI, possibly a prefixed value - * @return If this is a full URI, starting with http or https, the URI will be encapsulated in "<" ">" - */ - private String wrapIfUri(String input) { - if (input.startsWith("http://") || input.startsWith("https://")) { - return "<" + input + ">"; - } else { - return input; - } - } - - private Object handleForeignLiteral(Literal literal) throws URISyntaxException { -// // TODO: LangTag is not native -// START -// if(literal.getLanguage() != null && !literal.getLanguage().equals("")) -// { -// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); -// } -// -// else -// { -// return literal.getString(); -// } -// END - //If not, does it have some datatype URI? - //else if(literal.getDatatypeURI() != null && !literal.getDatatypeURI().equals("")) - //{ - // return new TypedLiteral(literal.getString(), new URI(literal.getDatatypeURI())); - //} - //If both is not true, add it as normal string - return literal.getString(); - } - - private HashMap handleForeignNode(RDFNode node, HashMap map, Model model) throws IOException, URISyntaxException { - //Make sure it is not a literal. If it were, we would not know the property name and could not add this to the map - //Literals must be handled "one recursion step above" - if (node.isLiteral()) { - throw new IOException("Literal passed to handleForeignNode. Must be non-literal RDF node"); - } - - //Run SPARQL query retrieving all information (only one hop!) about this node - String queryString = "SELECT ?s ?p ?o { BIND(<" + node.asNode().getURI() + "> AS ?s) . ?s ?p ?o . } "; - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, model); - ResultSet resultSet = queryExecution.execSelect(); - - - //Handle outgoing properties of this foreign node - while (resultSet.hasNext()) { - QuerySolution querySolution = resultSet.next(); - - String propertyUri = querySolution.get("p").toString(); - - if (map.containsKey(propertyUri)) { - //If it is not an array list yet, turn it into one - if (!(map.get(propertyUri) instanceof ArrayList)) { - ArrayList newList = new ArrayList<>(); - newList.add(map.get(propertyUri)); - map.put(propertyUri, newList); - } - } - - //Check the type of object we have. If it is a literal, just add it as "flat value" to the map - if (querySolution.get("o").isLiteral()) { - //Handle some small literal. This function will turn this into a TypedLiteral if appropriate - Object o = handleForeignLiteral(querySolution.getLiteral("o")); - if (map.containsKey(propertyUri)) { - map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(o)); - } else { - map.put(querySolution.get("p").toString(), o); - } - } - - //If it is not a literal, we need to call this function recursively. Create new map for sub object - else { - //logger.info("Calling handleForeignNode for " + querySolution.getResource("o").toString()); - if (querySolution.getResource("s").toString().equals(querySolution.getResource("o").toString())) { - logger.warn("Found self-reference on " + querySolution.getResource("s").toString() + " via predicate " + querySolution.getResource("p").toString() + " ."); - continue; - } - HashMap subMap = handleForeignNode(querySolution.getResource("o"), new HashMap<>(), model); - subMap.put("@id", querySolution.getResource("o").getURI()); - if (map.containsKey(propertyUri)) { - map.put(querySolution.get("p").toString(), ((ArrayList) map.get(propertyUri)).add(subMap)); - } else { - map.put(querySolution.get("p").toString(), subMap); - } - } - } - queryExecution.close(); - return map; - } - - /** - * Utility function, used to obtain the field corresponding to a setter function - * - * @param targetClass Class object in which we search for a field - * @param fieldName Guessed name of the field to search for - * @return Field object matching the name (possibly with leading underscore) - * @throws NoSuchFieldException thrown, if no such field exists - */ - private Field getFieldByName(Class targetClass, String fieldName) throws NoSuchFieldException { - try { - return targetClass.getDeclaredField("_" + fieldName); - } catch (NoSuchFieldException e) { - try { - return targetClass.getDeclaredField(fieldName); - } catch (NoSuchFieldException e2) { - try { - return targetClass.getDeclaredField("_" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1)); - } catch (NoSuchFieldException e3) { - throw new NoSuchFieldException("Failed to find field which is set by method " + fieldName); - } - } - } - } - - /** - * Internal function to create a single enum object from a given desired class and a URL - * - * @param enumClass The enum class - * @param url The URL of the enum value - * @param Enum class - * @return Value of enumClass matching the input URL - * @throws IOException thrown if no matching enum value could be found - */ - private T handleEnum(Class enumClass, String url) throws IOException { - if (!enumClass.isEnum()) { - throw new RuntimeException("Non-Enum class passed to handleEnum function."); - } - T[] constants = enumClass.getEnumConstants(); - if (url.contains("/")) { - url = url.substring(url.lastIndexOf("/") + 1); - } - for (T constant : constants) { - //We artificially added some underscores in the AAS ontology. TODO: This might be a bit dangerous for other ontologies, which really contain underscores in enum names - if (url.equalsIgnoreCase(constant.toString()) || url.equalsIgnoreCase(constant.toString().replace("_", ""))) { - return constant; - } - } - throw new IOException("Failed to find matching enum value for " + url + " . Available enums are: " + Arrays.stream(constants).map(Object::toString).collect(Collectors.joining(", "))); - } - - /** - * Function for handling a rather primitive object, i.e. not a complex sub-object (e.g. URI, TypedLiteral, GregorianCalendar values, ...) - * - * @param currentType Input Class (or primitive) - * @param literal Value as literal (can be null in some cases) - * @param currentSparqlBinding Value as SPARQL Binding (can be null in some cases) - * @return Object of type currentType - * @throws URISyntaxException thrown, if currentType is URI, but the value cannot be parsed to a URI - * @throws DatatypeConfigurationException thrown, if currentType is XMLGregorianCalendar or Duration, but parsing fails - * @throws IOException thrown, if no matching "simple class" could be found - */ - private Object handlePrimitive(Class currentType, Literal literal, String currentSparqlBinding) throws URISyntaxException, DatatypeConfigurationException, IOException { - //Java way of checking for primitives, i.e. int, char, float, double, ... - if (currentType.isPrimitive()) { - if (literal == null) { - throw new IOException("Trying to handle Java primitive, but got no literal value"); - } - //If it is an actual primitive, there is no need to instantiate anything. Just give it to the function - switch (currentType.getSimpleName()) { - case "int": - return literal.getInt(); - case "boolean": - return literal.getBoolean(); - case "long": - return literal.getLong(); - case "short": - return literal.getShort(); - case "float": - return literal.getFloat(); - case "double": - return literal.getDouble(); - case "byte": - return literal.getByte(); - } - } - - //Check for the more complex literals - - //URI - if (URI.class.isAssignableFrom(currentType)) { - return new URI(currentSparqlBinding); - } - - //String - if (String.class.isAssignableFrom(currentType)) { - return currentSparqlBinding; - } - - //XMLGregorianCalendar - if (XMLGregorianCalendar.class.isAssignableFrom(currentType)) { - //Try parsing this as dateTimeStamp (most specific). If seconds / timezone is missing, DatatypeFormatException will be thrown - try { - return DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(literal.getValue().toString()))); - } catch (DatatypeFormatException | DateTimeParseException ignored) { - //Not a valid dateTimeStamp. Try parsing just to Date - try { - Date date = new SimpleDateFormat().parse(literal.getValue().toString()); - GregorianCalendar calendar = new GregorianCalendar(); - calendar.setTime(date); - return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); - } catch (ParseException | DateTimeParseException | DatatypeFormatException e2) { - //Do NOT use literal.getValue(), as that can already cause yet another DatatypeFormatException - throw new IOException("Could not turn " + literal.getString() + " into " + literal.getDatatypeURI(), e2); - } - } - } - -// // TODO: Abstract lan is no longer native type -// START -// //TypedLiteral -// if (LangString.class.isAssignableFrom(currentType)) { -// //Either a language tagged string OR literal with type. Only one allowed -// if (!literal.getLanguage().equals("")) { -// return new DefaultLangString.Builder().text(literal.getValue().toString()).language(literal.getLanguage()).build(); -// } -// return new DefaultLangString.Builder().text(currentSparqlBinding).language("en-us").build(); // TODO: find a better language tag -// } -// END - - //BigInteger - if (BigInteger.class.isAssignableFrom(currentType)) { - return new BigInteger(literal.getString()); - } - - //BigDecimal - if (BigDecimal.class.isAssignableFrom(currentType)) { - return new BigDecimal(literal.getString()); - } - - //byte[] - if (byte[].class.isAssignableFrom(currentType)) { - return currentSparqlBinding.getBytes(); - } - - //Duration - if (Duration.class.isAssignableFrom(currentType)) { - return DatatypeFactory.newInstance().newDuration(currentSparqlBinding); - } - - throw new IOException("Unrecognized primitive type: " + currentType.getName()); - } - - private boolean isArrayListTypePrimitive(Type t) throws IOException { - String typeName = extractTypeNameFromCollection(t); - - try { - //Do not try to call Class.forName(primitive) -- that would throw an exception - if (builtInMap.containsKey(typeName)) return true; - return isPrimitive(Class.forName(typeName)); - } catch (ClassNotFoundException e) { - throw new IOException("Unable to retrieve class from generic", e); - } - } - - private String extractTypeNameFromCollection(Type t) throws IOException { - String typeName = t.getTypeName(); - if (!typeName.startsWith("java.util.ArrayList<") && !typeName.startsWith("java.util.List<") && !typeName.startsWith("java.util.Collection<")) { - throw new IOException("Illegal argument encountered while interpreting type parameter"); - } - //"" or super instead of extends - if (typeName.contains("?")) { - //last space is where we want to cut off (right after the "extends"), as well as removing the last closing braces - return typeName.substring(typeName.lastIndexOf(" ") + 1, typeName.length() - 1); - } - //No extends - else { - return typeName.substring(typeName.indexOf("<") + 1, typeName.indexOf(">")); - } - } - - private boolean isPrimitive(Class input) throws IOException { - //Collections are not simple - if (Collection.class.isAssignableFrom(input)) { - throw new IOException("Encountered collection in isPrimitive. Use isArrayListTypePrimitive instead"); - } - - //check for: plain/typed literal, XMLGregorianCalendar, byte[], RdfResource - //covers int, long, short, float, double, boolean, byte - if (input.isPrimitive()) return true; - - return (URI.class.isAssignableFrom(input) || - String.class.isAssignableFrom(input) || - XMLGregorianCalendar.class.isAssignableFrom(input) || - AbstractLangString.class.isAssignableFrom(input) || - BigInteger.class.isAssignableFrom(input) || - BigDecimal.class.isAssignableFrom(input) || - byte[].class.isAssignableFrom(input) || - Duration.class.isAssignableFrom(input)); - } - - /** - * Entry point to this class. Takes an RDF Model and a desired target class (can be an interface) - * - * @param rdfModel RDF input to be parsed - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(Model rdfModel, Class targetClass) throws IOException { - addArtificialBlankNodeLabels(rdfModel); - ArrayList> implementingClasses = getImplementingClasses(targetClass); - - // Query to retrieve all instances in the input graph that have a class assignment - // Assumption: if the class name (?type) is equal to the target class, this should be the - // instance we actually want to parse - String queryString = "SELECT ?id ?type { ?id a ?type . }"; - Query query = QueryFactory.create(queryString); - QueryExecution queryExecution = QueryExecutionFactory.create(query, rdfModel); - ResultSet resultSet = queryExecution.execSelect(); - - if (!resultSet.hasNext()) { - throw new IOException("Could not extract class from input message"); - } - - Map> returnCandidates = new HashMap<>(); - - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - String fullName = solution.get("type").toString(); - String className = fullName.substring(fullName.lastIndexOf('/') + 1); - - //In case of hash-namespaces - if (className.contains("#")) { - className = className.substring(className.lastIndexOf("#")); - } - - //For legacy purposes... - if (className.startsWith("ids:") || className.startsWith("aas:")) { - className = className.substring(4); - } - -// for (Class currentClass : implementingClasses) { -// if (currentClass.getSimpleName().equals(SerializerHelper.implementingClassesNamePrefix + className + SerializerHelper.implementingClassesNameSuffix)) { -// returnCandidates.put(solution.get("id").toString(), currentClass); -// } -// } - //if (returnCandidates.size() > 0) break; - } - queryExecution.close(); - - if (returnCandidates.size() == 0) { - throw new IOException("Could not transform input to an appropriate implementing class for " + targetClass.getName()); - } - - //At this point, we parsed the model and know to which implementing class we want to parse - //Check if there are several options available - if (returnCandidates.size() > 1) { - String bestCandidateId = null; - Class bestCandidateClass = null; - long bestNumRelations = -1L; - for (Map.Entry> entry : returnCandidates.entrySet()) { - String determineBestCandidateQueryString = "CONSTRUCT { ?s ?p ?o . ?o ?p2 ?o2 . ?o2 ?p3 ?o3 . ?o3 ?p4 ?o4 . ?o4 ?p5 ?o5 . }" + - " WHERE {" + - " BIND(<" + entry.getKey() + "> AS ?s). ?s ?p ?o ." + - " OPTIONAL {?o ?p2 ?o2 . OPTIONAL {?o2 ?p3 ?o3 . OPTIONAL {?o3 ?p4 ?o4 . OPTIONAL {?o4 ?p5 ?o5 . } } } } }"; - Query determineBestCandidateQuery = QueryFactory.create(determineBestCandidateQueryString); - QueryExecution determineBestCandidateQueryExecution = QueryExecutionFactory.create(determineBestCandidateQuery, rdfModel); - long graphSize = determineBestCandidateQueryExecution.execConstruct().size(); - if (graphSize > bestNumRelations) { - bestNumRelations = graphSize; - bestCandidateId = entry.getKey(); - bestCandidateClass = entry.getValue(); - } - - determineBestCandidateQueryExecution.close(); - - } - logger.debug("The RDF graph contains multiple objects which can be parsed to " + targetClass.getSimpleName() + ". Determined " + bestCandidateId + " as best candidate."); - return (T) handleObject(rdfModel, bestCandidateId, bestCandidateClass); - } - - //We only reach this spot, if there is exactly one return candidate. Let's return it - Map.Entry> singularEntry = returnCandidates.entrySet().iterator().next(); - return (T) handleObject(rdfModel, singularEntry.getKey(), singularEntry.getValue()); - - } - - - /** - * Entry point to this class. Takes a message and a desired target class (can be an interface) - * - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(String message, Class targetClass) throws IOException { - Model model = readMessage(message); - return parseMessage(model, targetClass); - } - - /** - * Entry point to this class. Takes a message and a desired target class (can be an interface) - * - * @param message Object to be parsed. Note that the name is misleading: One can also parse non-message IDS objects with this function - * @param targetClass Desired target class (something as abstract as "Message.class" is allowed) - * @param serializationFormat Input RDF format - * @param Desired target class - * @return Object of desired target class, representing the values contained in input message - * @throws IOException if the parsing of the message fails - */ - T parseMessage(String message, Class targetClass, Lang serializationFormat) throws IOException { - Model model = readMessage(message, serializationFormat); - return parseMessage(model, targetClass); - } - - /** - * Reads a message into an Apache Jena model, guessing the input language. - * Note: Guessing the language may cause some error messages during parsing attempts - * - * @param message Message to be read - * @return The model of the message - */ - private Model readMessage(String message) throws IOException { - - List supportedLanguages = new ArrayList<>( - Arrays.asList( - RDFLanguages.JSONLD, //JSON-LD first - RDFLanguages.TURTLE, //N-TRIPLE is a subset of Turtle - RDFLanguages.RDFXML - )); - - for (Lang lang : supportedLanguages) { - try { - return readMessage(message, lang); - } catch (IOException ignored) { - } - } - throw new IOException("Could not parse string as any supported RDF format (JSON-LD, Turtle/N-Triple, RDF-XML)."); - } - - /** - * Reads a message into an Apache Jena model, guessing the input language. - * Note: Guessing the language may cause some error messages during parsing attempts - * - * @param message Message to be read - * @param language The RDF serialization of the input. Supported formats are JSON-LD, N-Triple, Turtle, and RDF-XML - * @return The model of the message - */ - private Model readMessage(String message, Lang language) throws IOException { - - Model targetModel = ModelFactory.createDefaultModel(); - - try { - RDFDataMgr.read(targetModel, new ByteArrayInputStream(message.getBytes()), language); - } catch (RiotException e) { - throw new IOException("Failed to parse input as " + language, e); - } - return targetModel; - } - - /** - * Get a list of all subclasses (by JsonSubTypes annotation) which can be instantiated - * - * @param someClass Input class of which implementable subclasses need to be found - * @return ArrayList of instantiable subclasses - */ - ArrayList> getImplementingClasses(Class someClass) { - ArrayList> result = new ArrayList<>(); - KnownSubtypes subTypeAnnotation = someClass.getAnnotation(KnownSubtypes.class); - if (subTypeAnnotation != null) { - KnownSubtypes.Type[] types = subTypeAnnotation.value(); - for (KnownSubtypes.Type type : types) { - result.addAll(getImplementingClasses(type.value())); - } - } - if (!someClass.isInterface() && !Modifier.isAbstract(someClass.getModifiers())) { - result.add(SerializerHelper.customImplementationMap.getOrDefault(someClass, someClass)); - } - return result; - } - - private void addArtificialBlankNodeLabels(Model m) { - //Get all blank nodes - Query q = QueryFactory.create("SELECT DISTINCT ?s { ?s ?p ?o . FILTER(isBlank(?s)) } "); - QueryExecution qe = QueryExecutionFactory.create(q, m); - ResultSet rs = qe.execSelect(); - List statementsToAdd = new ArrayList<>(); - while (rs.hasNext()) { - QuerySolution qs = rs.next(); - statementsToAdd.add(ResourceFactory.createStatement(qs.get("?s").asResource(), - ResourceFactory.createProperty(blankNodeIdPropertyUri.toString()), - ResourceFactory.createStringLiteral(qs.get("?s").toString()))); - } - qe.close(); - m.add(statementsToAdd); - } - -} 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..4e56f9bd6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java @@ -0,0 +1,27 @@ +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 is side effect free and idempotent. + * @param element 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. + */ + public RDFSerializationResult toModel(T object); + + /** + * This method is side effect free and idempotent. + * @param model The graph model that holds information. + * @param subjectToParse Root elements that correspond to the object. + * @return instance of the object + */ + public 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 similarity index 98% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfParser.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java index bba8cc423..b6fad5601 100644 --- 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 @@ -1,11 +1,7 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; -import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; -import org.apache.jena.riot.Lang; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -16,7 +12,7 @@ import java.util.List; import java.util.stream.Collectors; -public class RdfParser { +public class RDFParser { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /** * Deserializes a given string into an instance of AssetAdministrationShellEnvironment 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..4f8750612 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFPartialHandler.java @@ -0,0 +1,10 @@ +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 { + + public void partialToModel(T object, Model model, Resource parentNode); + public T partialFromModel(T object, Model model, Resource subjectToParse); +} 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..89523965d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java @@ -0,0 +1,10 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; + +public interface RDFSerializationResult { + Model getModel(); + + 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 similarity index 93% rename from dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RdfSerializer.java rename to dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java index e24460f47..7b314ccea 100644 --- 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 @@ -3,7 +3,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.system.Serializer; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -11,13 +10,11 @@ import java.io.*; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.List; -public class RdfSerializer { +public class RDFSerializer { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - SerializerHelper serializerHelper = new SerializerHelper(); + /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * @@ -28,7 +25,7 @@ public class RdfSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - return serializerHelper.write(aasEnvironment, serializationFormat); + throw new RuntimeException("Not Implemented"); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } @@ -55,7 +52,7 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - return serializerHelper.write(referable, serializationFormat); + throw new RuntimeException("Not Implemented"); } catch (Exception ex) { throw new SerializationException("error serializing AssetAdministrationShellEnvironment", ex); } @@ -73,7 +70,7 @@ public String write(Referable referable) throws SerializationException { } /** - * Converts a given instance of AssetAdministrationShellEnvironment as JSON node. + * Converts a given instance of AssetAdministrationShellEnvironment as RDF Model. * * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize * @return the Jena Model @@ -86,10 +83,10 @@ public Model toModel(Environment aasEnvironment) { * Converts a given instance of a Referable to a JSON node. * * @param referable the referable to serialize - * @return the Jena Model + * @return the RDFSerializationResult contains the Apache Jena model as well as the corresponding created resource */ - public Model toModel(Referable referable) { - throw new RuntimeException("Not Implemented"); + public RDFSerializationResult toModel(Referable referable) { + return null; } diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java deleted file mode 100644 index 0009a96e9..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerHelper.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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.rdf; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.JsonPreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.preprocessing.TypeNamePreprocessor; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.custom.ReflectiveMixInResolver; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -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.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.*; - -class SerializerHelper { - - private final ObjectMapper mapper = new ObjectMapper(); - public String implementingClassesNamePrefix = "Default"; - public String implementingClassesNameSuffix = ""; - static Map, Class> customImplementationMap = new HashMap<>(); - private boolean charsetWarningPrinted = false; - private final List preprocessors; - private final Logger logger = LoggerFactory.getLogger(SerializerHelper.class); - - public SerializerHelper() { - mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); - mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - mapper.setMixInResolver(new ReflectiveMixInResolver()); - - preprocessors = new ArrayList<>(); - this.addPreprocessor(new TypeNamePreprocessor()); - - if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8) && !charsetWarningPrinted) { - charsetWarningPrinted = true; - logger.warn("Standard Charset is set to " + Charset.defaultCharset() + " - expecting " + StandardCharsets.UTF_8 + ". Some characters might not be displayed correctly.\nThis warning is only printed once"); - } - - //Default namespaces for AAS - addKnownNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); - addKnownNamespace("owl", "http://www.w3.org/2002/07/owl#"); - addKnownNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - addKnownNamespace("aas", "https://admin-shell.io/aas/3/0/"); - //addKnownNamespace("iec61360", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIec61360/3/0/RC02/"); - //addKnownNamespace("phys_unit", "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/"); - - } - - /** - * Allows to add further known namespaces to the message parser. Allows parsing to Java objects with JsonSubTypes annotations with other prefixes than "ids:". - * - * @param prefix Prefix to be added - * @param namespaceUrl URL of the prefix - */ - public void addKnownNamespace(String prefix, String namespaceUrl) { - ParserHelper.knownNamespaces.put(prefix, namespaceUrl); - JsonLDSerializer.contextItems.put(prefix, namespaceUrl); - } - - /** - * Serializes an object to an RDF representation. In order to support RDF, the input instance must be - * annotated using AAS Metamodel annotations. Default format is Turtle (TTL). - * - * @param instance the instance to be serialized - * @return RDF serialization of the provided object graph - * @throws IOException if the serialization fails - */ - public String serialize(Object instance) throws IOException { - return serialize(instance, RDFLanguages.TTL, new HashMap<>()); - } - - /** - * Serializes an object to an RDF representation of a given RDF serialization format. In order to support RDF, the - * input instance must be annotated using AAS Metamodel annotations. - * - * @param instance the instance to be serialized - * @param format the RDF format to be returned (only RDFLanguages.TTL, RDFLanguages.JSONLD, RDFLanguages.RDFXML) - * @return RDF serialization of the provided object graph - * @throws IOException if the serialization fails - */ - public String serialize(Object instance, Lang format) throws IOException { - return serialize(instance, format, new HashMap<>()); - } - - //Synchronized is required for thread safety. Without it, context elements might be missing in case of multiple simultaneous calls to this function - //HoRi: No, bad design - public String serialize(Object instance, Lang format, Map idMap) throws IOException { - if (format != RDFLanguages.JSONLD && format != RDFLanguages.TURTLE && format != RDFLanguages.RDFXML) { - throw new IOException("RDFFormat " + format + " is currently not supported by the serializer."); - } - mapper.registerModule(new JsonLDModule(idMap)); - String jsonLD = (instance instanceof Collection) - ? serializeCollection((Collection) instance) - : mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); - if (format == RDFLanguages.JSONLD) return jsonLD; - else return convertJsonLdToOtherRdfFormat(jsonLD, format); - } - - private String serializeCollection(Collection collection) throws IOException { - String lineSep = System.lineSeparator(); - StringBuilder jsonLDBuilder = new StringBuilder(); - - if (collection.isEmpty()) { - jsonLDBuilder.append("[]"); - } else { - jsonLDBuilder.append("["); - jsonLDBuilder.append(lineSep); - for (Object item : collection) { - jsonLDBuilder.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(item)); - jsonLDBuilder.append(","); - jsonLDBuilder.append(lineSep); - } - int lastComma = jsonLDBuilder.lastIndexOf(","); - jsonLDBuilder.replace(lastComma, lastComma + 1, ""); - jsonLDBuilder.append("]"); - } - jsonLDBuilder.append(lineSep); - - return jsonLDBuilder.toString(); - } - - public String convertJsonLdToOtherRdfFormat(String jsonLd, Lang format) { - Model model = ModelFactory.createDefaultModel(); - RDFDataMgr.read(model, new ByteArrayInputStream(jsonLd.getBytes()), RDFLanguages.JSONLD); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - RDFDataMgr.write(os, model, format); - return os.toString(); - } - - public String serializePlainJson(Object instance) throws JsonProcessingException { - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); - } - - - /** - * Method to add a preprocessor for deserialization. - *

- * Important note: The preprocessors are executed in the same order they were added. - * - * @param preprocessor the preprocessor to add - */ - public void addPreprocessor(JsonPreprocessor preprocessor) { - preprocessors.add(preprocessor); - } - - /** - * Method to add a preprocessor for deserialization. - *

- * Important note: The preprocessors are executed in the same order they were added. - * - * @param preprocessor the preprocessor to add - * @param validate set whether the preprocessors output should be checked by RDF4j - */ - public void addPreprocessor(JsonPreprocessor preprocessor, boolean validate) { - preprocessor.enableRDFValidation(validate); - addPreprocessor(preprocessor); - } - - /** - * remove a preprocessor if no longer needed - * - * @param preprocessor the preprocessor to remove - */ - public void removePreprocessor(JsonPreprocessor preprocessor) { - preprocessors.remove(preprocessor); - } - - - public String write(Environment aasEnvironment) throws SerializationException { - try { - return serialize(aasEnvironment); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Environment aasEnvironment, Lang format) throws SerializationException { - return write(aasEnvironment, format, new HashMap<>()); - } - - public String write(Environment aasEnvironment, Lang format, Map idMap) throws SerializationException { - try { - return serialize(aasEnvironment, format, idMap); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Referable referable) throws SerializationException { - try { - return serialize(referable); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - public String write(Referable referable, Lang format) throws SerializationException { - return write(referable, format, new HashMap<>()); - } - - public String write(Referable referable, Lang format, Map idMap) throws SerializationException { - try { - return serialize(referable, format, idMap); - } catch (IOException e) { - throw new SerializationException("Failed to serialize environment.", e); - } - } - - - - public void useImplementation(Class aasInterface, Class implementation) { - customImplementationMap.put(aasInterface, implementation); - //throw new NotImplementedException("Custom implementation support not yet implemented"); - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java deleted file mode 100644 index a889ae103..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/UriSerializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf; - -import java.io.IOException; -import java.net.URI; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonStreamContext; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -public class UriSerializer extends StdSerializer { - - - public UriSerializer() { - this(null); - } - - public UriSerializer(Class clazz) { - super(clazz); - } - - - @Override - public void serialize(URI value, JsonGenerator gen, SerializerProvider provider) throws IOException { - String serializedUri = value.toString(); - // String idPattern = "{\"@id\": \"" + serializedUri + "\"}"; - JsonStreamContext context = gen.getOutputContext(); - if (context.getCurrentName() != null && context.getCurrentName().contains("@id")) { - gen.writeString(serializedUri); - } else { - gen.writeStartObject(); - gen.writeStringField("@id", serializedUri); - gen.writeEndObject(); - } - } - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java deleted file mode 100644 index a05f77d44..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/BigDecimalSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; -import java.math.BigDecimal; - -public class BigDecimalSerializer extends StdSerializer { - - public BigDecimalSerializer() { - this(null); - } - - public BigDecimalSerializer(Class clazz) { - super(clazz); - } - - @Override - public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider provider) throws IOException { - gen.writeStartObject(); - gen.writeStringField("@value", value.toString()); - gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#decimal"); - gen.writeEndObject(); - } -} \ No newline at end of file diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java deleted file mode 100644 index ff1374e20..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/JsonLdEnumMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.JsonLdEnumSerializer; - -@JsonSerialize(using = JsonLdEnumSerializer.class) -public class JsonLdEnumMixin { -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java deleted file mode 100644 index a1f0ec779..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/LangStringMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.rdf.custom; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - - -import java.util.List; - -@JsonTypeName("rdf:langString") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface LangStringMixin { - @JsonProperty("@value") - public String getValue(); - - @JsonProperty("@language") - public String getLanguage(); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java deleted file mode 100644 index 54692477e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/ReflectiveMixInResolver.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.databind.introspect.ClassIntrospector; - -public class ReflectiveMixInResolver implements ClassIntrospector.MixInResolver { - - @Override - public Class findMixInClassFor(Class cls) { - if (cls.isEnum()) - { - return JsonLdEnumMixin.class; - } - try { - return Class.forName("org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.mixins." + cls.getSimpleName() + "Mixin"); - } - catch (ClassNotFoundException ignored) - { - return null; - } - } - - @Override - public ClassIntrospector.MixInResolver copy() { - return new ReflectiveMixInResolver(); - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java deleted file mode 100644 index 28006cbb8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarDeserializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.IOException; -import java.time.ZonedDateTime; -import java.util.GregorianCalendar; - -public class XMLGregorianCalendarDeserializer extends StdDeserializer { - - public XMLGregorianCalendarDeserializer() { - this(XMLGregorianCalendar.class); - } - - public XMLGregorianCalendarDeserializer(Class clazz) { - super(clazz); - } - - @Override - public XMLGregorianCalendar deserialize(JsonParser p, DeserializationContext context) throws IOException { - XMLGregorianCalendar xgc = null; - try { - xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.from(ZonedDateTime.parse(p.getValueAsString()))); - } catch (DatatypeConfigurationException e) { - e.printStackTrace(); - } - return xgc; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java deleted file mode 100644 index b80718d93..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/custom/XMLGregorianCalendarSerializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.custom; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.IOException; -import java.text.SimpleDateFormat; - -public class XMLGregorianCalendarSerializer extends StdSerializer { - - public XMLGregorianCalendarSerializer() { - this(null); - } - - public XMLGregorianCalendarSerializer(Class clazz) { - super(clazz); - } - - @Override - public void serialize(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider) throws IOException { - SimpleDateFormat xsdDateTimeStampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - xsdDateTimeStampFormat.setCalendar(value.toGregorianCalendar()); - String xsdDateTimeStampFormatted = xsdDateTimeStampFormat.format(value.toGregorianCalendar().getTime()); - gen.writeStartObject(); - gen.writeStringField("@value", xsdDateTimeStampFormatted); - gen.writeStringField("@type", "http://www.w3.org/2001/XMLSchema#dateTimeStamp"); - gen.writeEndObject(); - - } -} 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..2a3b2f74a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java @@ -0,0 +1,19 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; + +public class DefaultAdministrativeInformationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AdministrativeInformation key) { + return null; + } + + @Override + public AdministrativeInformation fromModel(Model model, Resource subjectToParse) { + return null; + } +} 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..aa9c77a42 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.AnnotatedRelationshipElement; + +public class DefaultAnnotatedRelationshipElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { + return null; + } + + @Override + public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..37e15e48d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java @@ -0,0 +1,26 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; + +public class DefaultAssetAdministrationShellRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AssetAdministrationShell key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + return null; + } + + @Override + public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) { + return null; + } +} 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..e808db27c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetInformationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.AssetInformation; + +public class DefaultAssetInformationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(AssetInformation object) { + return null; + } + + @Override + public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..cf56a05cf --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBasicEventElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.BasicEventElement; + +public class DefaultBasicEventElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(BasicEventElement object) { + return null; + } + + @Override + public BasicEventElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..5df58123d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultBlobRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Blob; + +public class DefaultBlobRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Blob object) { + return null; + } + + @Override + public Blob fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d4db934ee --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultCapabilityRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Capability; + +public class DefaultCapabilityRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Capability object) { + return null; + } + + @Override + public Capability fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..c70b60406 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultConceptDescriptionRDFHandler.java @@ -0,0 +1,52 @@ +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.DefaultIdentifiableRDFHandler; +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; + +public class DefaultConceptDescriptionRDFHandler implements RDFHandler { + + @Override + public RDFSerializationResult toModel(ConceptDescription key) { + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource conceptDescriptionResource = model.createResource(key.getId()); + model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); + //HasDataSpecification + if (key.getEmbeddedDataSpecifications() != null && key.getEmbeddedDataSpecifications().isEmpty() == false) { + + } + + //Identifiable + new DefaultIdentifiableRDFHandler().partialToModel(key, model, conceptDescriptionResource); + + for (Reference reference : key.getIsCaseOf()) { + // TODO: Optional ordering + RDFSerializationResult result = new DefaultReferenceRDFHandler().toModel(reference); + model.add(result.getModel()); + conceptDescriptionResource.addProperty(AASNamespace.ConceptDescription.isCaseOf, result.getResource()); + } + + return new DefaultRDFHandlerResult(model, conceptDescriptionResource); + } + + @Override + public ConceptDescription fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { + throw new IncompatibleTypeException(); + } + ConceptDescription build = new DefaultConceptDescription.Builder() + .build(); + new DefaultIdentifiableRDFHandler().partialFromModel(build, model, subjectToParse); + return build; + } +} 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..88093bff2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationIEC61360RDFHandler.java @@ -0,0 +1,20 @@ +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.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.DataSpecificationIec61360; + +public class DefaultDataSpecificationIEC61360RDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationIec61360 object) { + return null; + } + + @Override + public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..65db7671c --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEmbeddedDataSpecificationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.EmbeddedDataSpecification; + +public class DefaultEmbeddedDataSpecificationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(EmbeddedDataSpecification object) { + return null; + } + + @Override + public EmbeddedDataSpecification fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..b77a3ea74 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Entity; + +public class DefaultEntityRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Entity object) { + return null; + } + + @Override + public Entity fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d9a1f76b2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Extension; + +public class DefaultExtensionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Extension object) { + return null; + } + + @Override + public Extension fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..e3d88eecb --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultFileRDFHandler.java @@ -0,0 +1,20 @@ +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.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.File; + +public class DefaultFileRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(File object) { + return null; + } + + @Override + public File fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..2b05fbdc4 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultKeyRDFHandler.java @@ -0,0 +1,42 @@ +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.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +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.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.builder.KeyBuilder; +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); + subject.addProperty(AASNamespace.Key.value, key.getValue()); + subject.addProperty(AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(key.getType().name())); + return new DefaultRDFHandlerResult(model, subject); + } + + public Key fromModel(Model model, Resource subjectToParse){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + throw new IllegalArgumentException("Provided Resource is not a Key"); + } + String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); + KeyTypes type = AASNamespace.KeyTypes.fromIRI(model.getProperty(subjectToParse, AASNamespace.Key.type).getResource().getURI()); + KeyBuilder builder = new DefaultKey.Builder(); + //Todo: in future instead of specific builder we can use a generic builder instantiator + return builder.type(type) + .value(value) + .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..e27ac069b --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringNameTypeRDFHandler.java @@ -0,0 +1,20 @@ +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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; +public class DefaultLangStringNameTypeRDFHandler implements RDFHandler{ + + @Override + public RDFSerializationResult toModel(LangStringNameType object) { + return null; + } + + @Override + public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..2d2c34397 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultLangStringTextTypeRDFHandler.java @@ -0,0 +1,19 @@ +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.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.LangStringTextType; + +public class DefaultLangStringTextTypeRDFHandler implements RDFHandler{ + @Override + public RDFSerializationResult toModel(LangStringTextType object) { + return null; + } + + @Override + public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..9f3d55f79 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java @@ -0,0 +1,20 @@ +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.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.MultiLanguageProperty; + +public class DefaultMultiLanguagePropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(MultiLanguageProperty object) { + return null; + } + + @Override + public MultiLanguageProperty fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..36b71d462 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Operation; + +public class DefaultOperationRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Operation object) { + return null; + } + + @Override + public Operation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..478ef4406 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Property; + +public class DefaultPropertyRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Property object) { + return null; + } + + @Override + public Property fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..5e4639a23 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Qualifier; + +public class DefaultQualifierRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Qualifier object) { + return null; + } + + @Override + public Qualifier fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..9a3395c14 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRangeRDFHandler.java @@ -0,0 +1,20 @@ +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.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.Range; + +public class DefaultRangeRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Range object) { + return null; + } + + @Override + public Range fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..4be19ea9a --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceElementRDFHandler.java @@ -0,0 +1,20 @@ +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.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.ReferenceElement; + +public class DefaultReferenceElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(ReferenceElement object) { + return null; + } + + @Override + public ReferenceElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..6a760557e --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java @@ -0,0 +1,60 @@ +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); + 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) == false){ + throw new IncompatibleTypeException(); + } + String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); + Map keysMap = new HashMap<>(); + NodeIterator keysIterator = model.listObjectsOfProperty(AASNamespace.Reference.keys); + keysIterator.forEachRemaining(node->{ + Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index,key); + }); + List keys = new ArrayList<>(); + for(int index=0;index { + @Override + public RDFSerializationResult toModel(RelationshipElement object) { + return null; + } + + @Override + public RelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java new file mode 100644 index 000000000..e146db227 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java @@ -0,0 +1,19 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; + +import org.apache.jena.rdf.model.Model; +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.Resource; + +public class DefaultResrouceRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(Resource object) { + return null; + } + + @Override + public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..af0b10809 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSpecificAssetIdRDFHandler.java @@ -0,0 +1,20 @@ +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.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.SpecificAssetId; + +public class DefaultSpecificAssetIdRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SpecificAssetId object) { + return null; + } + + @Override + public SpecificAssetId fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..d43abc395 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementCollectionRDFHandler.java @@ -0,0 +1,20 @@ +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.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.SubmodelElementCollection; + +public class DefaultSubmodelElementCollectionRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElementCollection object) { + return null; + } + + @Override + public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} 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..0efd20430 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementListRDFHandler.java @@ -0,0 +1,22 @@ +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.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.SubmodelElementList; + +public class DefaultSubmodelElementListRDFHandler implements RDFHandler { + + + @Override + public RDFSerializationResult toModel(SubmodelElementList object) { + return null; + } + + @Override + public SubmodelElementList fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java new file mode 100644 index 000000000..edbdcc3ba --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java @@ -0,0 +1,21 @@ +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.RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; + +public class DefaultHasSemanticsRDFHandler implements RDFPartialHandler { + + @Override + public void partialToModel(HasSemantics object, Model model, Resource parentNode) { + + } + + @Override + public HasSemantics partialFromModel(HasSemantics object, Model model, Resource subjectToParse) { + return null; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java new file mode 100644 index 000000000..ca4c71697 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java @@ -0,0 +1,49 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; +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.dataformat.rdf.DefaultRDFHandlerResult; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; + +import java.util.HashMap; +import java.util.Map; + +public class DefaultIdentifiableRDFHandler implements RDFPartialHandler { + + @Override + public void partialToModel(Identifiable object, Model model, Resource parentNode) { + //TODO: Side effect + parentNode.addProperty(AASNamespace.Identifiable.id, object.getId()); + + RDFSerializationResult administrativeResult = new DefaultAdministrativeInformationRDFHandler() + .toModel(object.getAdministration()); + if(object.getAdministration()!=null){ + parentNode.addProperty(AASNamespace.Identifiable.administration, administrativeResult.getResource()); + model.add(administrativeResult.getModel()); + } + + new DefaultReferableRDFHandler().partialToModel(object,model,parentNode); + } + + @Override + public Identifiable partialFromModel(Identifiable object, Model model, Resource subjectToParse) { + //TODO: Side effect + String id = model.getProperty(subjectToParse, AASNamespace.Identifiable.id).getString(); + object.setId(id); + + Statement administrationStatement = model.getProperty(subjectToParse, AASNamespace.Identifiable.administration); + if(administrationStatement!=null) { + Resource administrationToParse = administrationStatement.getResource(); + AdministrativeInformation administrativeInformation = new DefaultAdministrativeInformationRDFHandler().fromModel(model, administrationToParse); + object.setAdministration(administrativeInformation); + } + + //Referable + new DefaultReferableRDFHandler().partialFromModel(object,model,subjectToParse); + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java new file mode 100644 index 000000000..23ae9b4c8 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java @@ -0,0 +1,46 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +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.DefaultAdministrativeInformationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +public class DefaultReferableRDFHandler 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() == false){ + + } + if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ + + } + + } + + @Override + public Referable partialFromModel(Referable object, Model model, Resource subjectToParse) { + if (object.getIdShort() != null) { + + } + if (object.getCategory() != null) { + + } + if (object.getDescription() != null && object.getDescription().isEmpty() == false){ + + } + if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ + + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java deleted file mode 100644 index 6c692e3c5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AdministrativeInformationMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:AdministrativeInformation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AdministrativeInformationMixin extends HasDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") - String getVersion(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/version") - void setVersion(String version); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") - String getRevision(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AdministrativeInformation/revision") - void setRevision(String revision); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java deleted file mode 100644 index 63e182fdf..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AnnotatedRelationshipElementMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; - -import java.util.List; - -@JsonTypeName("aas:AnnotatedRelationshipElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AnnotatedRelationshipElementMixin extends RelationshipElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") - List getAnnotations(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AnnotatedRelationshipElement/annotation") - void setAnnotations(List annotations); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java deleted file mode 100644 index 31fb53258..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetAdministrationShellMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:AssetAdministrationShell") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AssetAdministrationShellMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") - AssetInformation getAssetInformation(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/assetInformation") - void setAssetInformation(AssetInformation assetInformation); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") - Reference getDerivedFrom(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/derivedFrom") - void setDerivedFrom(Reference derivedFrom); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") - List getSubmodels(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetAdministrationShell/submodel") - void setSubmodels(List submodels); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java deleted file mode 100644 index 60040db6a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/AssetInformationMixin.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.File; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:AssetInformation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface AssetInformationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") - AssetKind getAssetKind(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/assetKind") - void setAssetKind(AssetKind assetKind); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") - Reference getGlobalAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/globalAssetId") - void setGlobalAssetId(Reference globalAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") - List getSpecificAssetIds(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/specificAssetIds") - void setSpecificAssetIds(List specificAssetIds); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") - List getBillOfMaterials(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/billOfMaterial") - void setBillOfMaterials(List billOfMaterials); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") - File getDefaultThumbnail(); - - @JsonProperty("https://admin-shell.io/aas/3/0/AssetInformation/defaultThumbnail") - void setDefaultThumbnail(File defaultThumbnail); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java deleted file mode 100644 index 6526e3db3..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BasicEventElementMixin.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Direction; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.StateOfEvent; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -@JsonTypeName("aas:BasicEventElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface BasicEventElementMixin extends EventElementMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") - Direction getDirection(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/direction") - void setDirection(Direction direction); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") - String getLastUpdate(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/lastUpdate") - void setLastUpdate(String lastUpdate); - - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") - String getMaxInterval(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/maxInterval") - void setMaxInterval(String maxInterval); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") - Reference getMessageBroker(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageBroker") - void setMessageBroker(Reference messageBroker); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") - String getMessageTopic(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/messageTopic") - void setMessageTopic(String messageTopic); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") - String getMinInterval(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/minInterval") - void setMinInterval(String minInterval); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") - Reference getObserved(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/observed") - void setObserved(Reference observed); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") - StateOfEvent getState(); - - @JsonProperty("https://admin-shell.io/aas/3/0/BasicEventElement/state") - void setState(StateOfEvent state); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java deleted file mode 100644 index b5763be43..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/BlobMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Blob") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface BlobMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/contentType") - void setConentType(String mimeType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") - byte[] getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Blob/value") - void setValue(byte[] value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java deleted file mode 100644 index d37450ab5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/CapabilityMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Capability") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface CapabilityMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java deleted file mode 100644 index 3f17da8fa..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ConceptDescriptionMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:ConceptDescription") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ConceptDescriptionMixin extends HasDataSpecificationMixin, IdentifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") - List getIsCaseOf(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ConceptDescription/isCaseOf") - void setIsCaseOf(List isCaseOf); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java deleted file mode 100644 index dab2fb7be..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataElementMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -@JsonTypeName("aas:DataElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = File.class), - @JsonSubTypes.Type(value = Blob.class), - @JsonSubTypes.Type(value = MultiLanguageProperty.class), - @JsonSubTypes.Type(value = Property.class), - @JsonSubTypes.Type(value = Range.class), - @JsonSubTypes.Type(value = ReferenceElement.class) -}) -public interface DataElementMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java deleted file mode 100644 index 823206ff2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationContentMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -@JsonTypeName("aas:DataSpecificationContent") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = DataSpecificationIec61360.class) -}) -public interface DataSpecificationContentMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java deleted file mode 100644 index 4993c0353..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/DataSpecificationIec61360Mixin.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - -@JsonTypeName("aas:DataSpecificationIec61360") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface DataSpecificationIec61360Mixin extends DataSpecificationContentMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") - public DataTypeIec61360 getDataType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/dataType") - public void setDataType(DataTypeIec61360 dataType); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") - public List getDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/definition") - public void setDefinitions(List definition); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") - public LevelType getLevelType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/levelType") - public void setLevelType(LevelType levelType); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") - public List getPreferredName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName") - public void setPreferredName(List preferredName); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") - public List getShortName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/shortName") - public void setShortName(List shortName); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") - public String getSourceOfDefinition(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/sourceOfDefinition") - public void setSourceOfDefinition(String sourceOfDefinition); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") - public String getSymbol(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/symbol") - public void setSymbol(String symbol); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") - public String getUnit(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unit") - public void setUnit(String unit); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") - public Reference getUnitId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/unitId") - public void setUnitId(Reference unitId); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") - public String getValueFormat(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueFormat") - public void setValueFormat(String valueFormat); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") - public String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/value") - public void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") - public ValueList getValueList(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueList") - public void setValueList(ValueList valueList); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") - public Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/DataSpecificationIec61360/valueId") - public void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java deleted file mode 100644 index e8f87e544..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EmbeddedDataSpecificationMixin.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:EmbeddedDataSpecification") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EmbeddedDataSpecificationMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") - public DataSpecificationIec61360 getDataSpecificationContent(); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecificationContent") - public void setDataSpecificationContent(DataSpecificationIec61360 dataSpecificationContent); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") - public Reference getDataSpecification(); - - @JsonProperty("https://admin-shell.io/aas/3/0/EmbeddedDataSpecification/dataSpecification") - public void setDataSpecification(Reference dataSpecification); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java deleted file mode 100644 index 35f7da75d..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EntityMixin.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.EntityType; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Entity") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EntityMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") - Reference getGlobalAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/globalAssetId") - void setGlobalAssetId(Reference globalAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") - SpecificAssetId getSpecificAssetId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/specificAssetId") - void setSpecificAssetId(SpecificAssetId specificAssetId); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") - EntityType getEntityType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/entityType") - void setEntityType(EntityType entityType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") - List getStatements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Entity/statement") - void setStatements(List statements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java deleted file mode 100644 index fb74f5287..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EnvironmentMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - -import java.util.List; - -@JsonTypeName("aas:Environment") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EnvironmentMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") - List getAssetAdministrationShells(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/assetAdministrationShells") - void setAssetAdministrationShells(List assetAdministrationShells); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") - List getConceptDescriptions(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/conceptDescriptions") - void setConceptDescriptions(List conceptDescriptions); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") - List getSubmodels(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Environment/submodels") - void setSubmodels(List submodels); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java deleted file mode 100644 index e3e7ed1c0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventElementMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; - - -@JsonTypeName("aas:EventElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = BasicEventElement.class) -}) -public interface EventElementMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java deleted file mode 100644 index 26bc5c128..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/EventMessageMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:EventMessage") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface EventMessageMixin extends SubmodelElementMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java deleted file mode 100644 index f46030240..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ExtensionMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Extension") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ExtensionMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") - String getName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/name") - void setName(String name); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") - Reference getRefersTo(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Extension/refersTo") - void setRefersTo(Reference refersTo); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java deleted file mode 100644 index 59fa087ff..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FileMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:File") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface FileMixin extends DataElementMixin, SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/contentType") - void setContentType(String contentType); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/File/value") - void setValue(String value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java deleted file mode 100644 index cc32cace1..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/FormulaMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:Formula") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface FormulaMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") - List getDependsOns(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Formula/dependsOn") - void setDependsOns(List dependsOns); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java deleted file mode 100644 index cd7f1b9c2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasDataSpecificationMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -import java.util.List; - -@JsonTypeName("aas:HasDataSpecification") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = AdministrativeInformation.class), - @JsonSubTypes.Type(value = AssetAdministrationShell.class), - @JsonSubTypes.Type(value = ConceptDescription.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface HasDataSpecificationMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") - List getDataSpecifications(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/dataSpecifiations") - void setDataSpecifications(List dataSpecifications); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") - List getEmbeddedDataSpecifications(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasDataSpecification/embeddedDataSpecifications") - void setEmbeddedDataSpecifications(List embeddedDataSpecifications); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java deleted file mode 100644 index c7a16a663..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasExtensionsMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; - -import java.util.List; - -@JsonTypeName("aas:HasExtensions") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface HasExtensionsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") - List getExtensions(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasExtensions/extension") - void setExtensions(List extensions); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java deleted file mode 100644 index c8299f52f..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasKindMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -@JsonTypeName("aas:HasKind") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface HasKindMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") - ModellingKind getKind(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasKind/kind") - void setKind(ModellingKind kind); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java deleted file mode 100644 index c624b21d7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/HasSemanticsMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - -import java.util.List; - - -@JsonTypeName("aas:HasSemantics") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SpecificAssetId.class), - @JsonSubTypes.Type(value = SubmodelElement.class), - @JsonSubTypes.Type(value = Qualifier.class), - @JsonSubTypes.Type(value = Extension.class) -}) -public interface HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") - Reference getSemanticId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/semanticId") - void setSemanticId(Reference semanticId); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") - List getSupplementalSemanticIds(); - - @JsonProperty("https://admin-shell.io/aas/3/0/HasSemantics/supplementalSemanticIds") - void setSupplementalSemanticIds(List references); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java deleted file mode 100644 index 80bdfe960..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifiableMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - -@JsonTypeName("aas:Identifiable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = AssetAdministrationShell.class), - @JsonSubTypes.Type(value = ConceptDescription.class) -}) -public interface IdentifiableMixin extends ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") - AdministrativeInformation getAdministration(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/administration") - void setAdministration(AdministrativeInformation administration); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") - String getId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifiable/id") - void setId(String id); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java deleted file mode 100644 index 2298936a8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierKeyValuePairMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:IdentifierKeyValuePair") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface IdentifierKeyValuePairMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") - String getKey(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/key") - void setKey(String key); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") - Reference getExternalSubjectId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/IdentifierKeyValuePair/externalSubjectId") - void setExternalSubjectId(Reference externalSubjectId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java deleted file mode 100644 index 25b4258af..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/IdentifierMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Identifier") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface IdentifierMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") - String getIdentifier(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Identifier/identifier") - void setIdentifier(String identifier); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java deleted file mode 100644 index 66cab3fbc..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/KeyMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; - -@JsonTypeName("aas:Key") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface KeyMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") - KeyTypes getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/type") - void setType(KeyTypes type); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Key/value") - void setValue(String value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java deleted file mode 100644 index 1e290609f..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/MultiLanguagePropertyMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:MultiLanguageProperty") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface MultiLanguagePropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") - List getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/value") - void setValue(List values); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/MultiLanguageProperty/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java deleted file mode 100644 index 095bbc8c9..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ObjectAttributesMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:ObjectAttributes") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ObjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") - List getObjectAttributes(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ObjectAttributes/objectAttribute") - void setObjectAttributes(List objectAttributes); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java deleted file mode 100644 index e60eb42fc..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationMixin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; - -import java.util.List; - -@JsonTypeName("aas:Operation") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface OperationMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") - List getInputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inputVariable") - void setInputVariables(List inputVariables); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") - List getInoutputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/inoutputVariable") - void setInoutputVariables(List inoutputVariables); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") - List getOutputVariables(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Operation/outputVariable") - void setOutputVariables(List outputVariables); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java deleted file mode 100644 index a099ae7db..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/OperationVariableMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -@JsonTypeName("aas:OperationVariable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface OperationVariableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") - SubmodelElement getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/OperationVariable/value") - void setValue(SubmodelElement value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java deleted file mode 100644 index 8e63a86f8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyDecisionPointMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:PolicyDecisionPoint") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyDecisionPointMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") - boolean getExternalPolicyDecisionPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyDecisionPoint/externalPolicyDecisionPoints") - void setExternalPolicyDecisionPoints(boolean externalPolicyDecisionPoints); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java deleted file mode 100644 index d1aaa0eef..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyEnforcementPointsMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:PolicyEnforcementPoints") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyEnforcementPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") - boolean getExternalPolicyEnforcementPoint(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyEnforcementPoints/externalPolicyEnforcementPoint") - void setExternalPolicyEnforcementPoint(boolean externalPolicyEnforcementPoint); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java deleted file mode 100644 index 935f0b5f0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PolicyInformationPointsMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:PolicyInformationPoints") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PolicyInformationPointsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") - boolean getExternalInformationPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/externalInformationPoints") - void setExternalInformationPoints(boolean externalInformationPoints); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") - List getInternalInformationPoints(); - - @JsonProperty("https://admin-shell.io/aas/3/0/PolicyInformationPoints/internalInformationPoint") - void setInternalInformationPoints(List internalInformationPoints); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java deleted file mode 100644 index 1466c78e0..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/PropertyMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Property") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface PropertyMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Property/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java deleted file mode 100644 index e4619f351..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifiableMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; - -import java.util.List; - -@JsonTypeName("aas:Qualifiable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Submodel.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface QualifiableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") - List getQualifiers(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifiable/qualifier") - void setQualifiers(List qualifiers); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java deleted file mode 100644 index d3c5ef093..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/QualifierMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:Qualifier") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface QualifierMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") - String getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/type") - void setType(String type); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Qualifier/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java deleted file mode 100644 index 1bef8f17a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RangeMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.rdf.mixins; - - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; - -@JsonTypeName("aas:Range") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface RangeMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") - String getValueType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/valueType") - void setValueType(String valueType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") - String getMax(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/max") - void setMax(String max); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") - String getMin(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Range/min") - void setMin(String min); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java deleted file mode 100644 index de65fa1eb..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferableMixin.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Referable") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = Identifiable.class), - @JsonSubTypes.Type(value = SubmodelElement.class) -}) -public interface ReferableMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") - String getCategory(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/category") - void setCategory(String category); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") - List getDescription(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/description") - void setDescription(List description); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") - List getDisplayName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/displayName") - void setDisplayName(List displayName); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") - String getIdShort(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Referable/idShort") - void setIdShort(String idShort); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java deleted file mode 100644 index bbffdaaae..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceElementMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:ReferenceElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ReferenceElementMixin extends DataElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") - Reference getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ReferenceElement/value") - void setValue(Reference value); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java deleted file mode 100644 index 55e5b8c98..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ReferenceMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.util.List; - -@JsonTypeName("aas:Reference") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ReferenceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") - List getKeys(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/keys") - void setKeys(List keys); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") - ReferenceTypes getType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Reference/type") - void setType(ReferenceTypes type); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java deleted file mode 100644 index 3b1fba521..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/RelationshipElementMixin.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:RelationshipElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = AnnotatedRelationshipElement.class) -}) -public interface RelationshipElementMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") - Reference getFirst(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/first") - void setFirst(Reference first); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") - Reference getSecond(); - - @JsonProperty("https://admin-shell.io/aas/3/0/RelationshipElement/second") - void setSecond(Reference second); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java deleted file mode 100644 index 88a6dfff2..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ResourceMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; - -import java.util.List; - -@JsonTypeName("aas:Resource") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ResourceMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") - String getContentType(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/contentType") - void setContentType(String contentType); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") - String getPath(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Resource/path") - void setPath(String path); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java deleted file mode 100644 index ec328856e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SpecificAssetIdMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.File; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; - -@JsonTypeName("aas:SpecificAssetId") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SpecificAssetIdMixin extends HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") - String getName(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/name") - void setName(String name); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") - Reference getExternalSubjectId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SpecificAssetId/externalSubjectId") - void setExternalSubjectId(Reference reference); - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java deleted file mode 100644 index 54401344b..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubjectAttributesMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; - -import java.util.List; - -@JsonTypeName("aas:SubjectAttributes") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubjectAttributesMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") - List getSubjectAttributes(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubjectAttributes/subjectAttribute") - void setSubjectAttributes(List subjectAttributes); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java deleted file mode 100644 index 99fe43314..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementCollectionMixin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.Collection; - -@JsonTypeName("aas:SubmodelElementCollection") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelElementCollectionMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") - boolean getAllowDuplicates(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/allowDuplicates") - void setAllowDuplicates(boolean allowDuplicates); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") - boolean getOrdered(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/ordered") - void setOrdered(boolean ordered); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") - Collection getValues(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementCollection/value") - void setValues(Collection values); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java deleted file mode 100644 index a00265d97..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementListMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; - -import java.util.List; - -@JsonTypeName("aas:SubmodelElementList") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelElementListMixin extends SubmodelElementMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") - boolean getOrderRelevant(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/orderRelevant") - void setOrderRelevant(boolean orderRelevant); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") - Reference getSemanticIdListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/semanticIdListElement") - void setSemanticIdListElement(Reference semanticIdListElement); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") - AasSubmodelElements getTypeValueListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/typeValueListElement") - void setTypeValueListElement(AasSubmodelElements typeValueListElement); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") - List getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/value") - void setValue(List value); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") - DataTypeDefXsd getValueTypeListElement(); - - @JsonProperty("https://admin-shell.io/aas/3/0/SubmodelElementList/valueTypeListElement") - void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java deleted file mode 100644 index 1bb5e50b5..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelElementMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.*; - - -@JsonTypeName("aas:SubmodelElement") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = RelationshipElement.class), - @JsonSubTypes.Type(value = DataElement.class), - @JsonSubTypes.Type(value = File.class), - @JsonSubTypes.Type(value = Capability.class), - @JsonSubTypes.Type(value = Entity.class), - @JsonSubTypes.Type(value = EventElement.class), - @JsonSubTypes.Type(value = EventPayload.class), - @JsonSubTypes.Type(value = Operation.class), - @JsonSubTypes.Type(value = SubmodelElementCollection.class) -}) -public interface SubmodelElementMixin extends ReferableMixin, QualifiableMixin, HasDataSpecificationMixin, HasKindMixin, HasSemanticsMixin { - -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java deleted file mode 100644 index ccb2cbcf7..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/SubmodelMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; - -import java.util.List; - -@JsonTypeName("aas:Submodel") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface SubmodelMixin extends QualifiableMixin, HasDataSpecificationMixin, IdentifiableMixin, HasKindMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") - List getSubmodelElements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/Submodel/submodelElement") - void setSubmodelElements(List submodelElements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java deleted file mode 100644 index 005eec10a..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueListMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.ValueReferencePair; - -import java.util.List; - - -@JsonTypeName("aas:ValueList") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ValueListMixin { - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") - List getValueReferencePairs(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueList/valueReferencePairs") - void setValueReferencePairs(List valueReferencePairs); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java deleted file mode 100644 index f57950e61..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ValueReferencePairMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.rdf.mixins; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -@JsonTypeName("aas:ValueReferencePair") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ValueReferencePairMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") - String getValue(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/value") - void setValue(String value); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") - Reference getValueId(); - - @JsonProperty("https://admin-shell.io/aas/3/0/ValueReferencePair/valueId") - void setValueId(Reference valueId); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java deleted file mode 100644 index b10f8626e..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/mixins/ViewMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf.mixins; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - -import java.util.List; - -@JsonTypeName("aas:View") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type") -public interface ViewMixin extends ReferableMixin, HasDataSpecificationMixin, HasSemanticsMixin { - @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") - List getContainedElements(); - - @JsonProperty("https://admin-shell.io/aas/3/0/View/containedElement") - void setContainedElements(List containedElements); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java deleted file mode 100644 index 2bf5c6603..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/BasePreprocessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.rdf.preprocessing; - - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; - - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -/** - * basic implementation of {@code JsonPreprocessor} that encapsulates validation. - * By default, validation is disabled for performance reasons (@context has to be downloaded each time). - */ -public abstract class BasePreprocessor implements JsonPreprocessor { - - private boolean validate = false; - - - @Override - public final String preprocess(String input) throws IOException { - String result = preprocess_impl(input); - if(validate) { - Model m = ModelFactory.createDefaultModel(); - RDFDataMgr.read(m, new ByteArrayInputStream(result.getBytes()), RDFLanguages.JSONLD); - } - return result; - } - - abstract String preprocess_impl(String input) throws IOException; - - @Override - public void enableRDFValidation(boolean validate) { - this.validate = validate; - } -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java deleted file mode 100644 index a76739850..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/JsonPreprocessor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.rdf.preprocessing; - -import java.io.IOException; - -/** - * Interface for JSON-LD preprocessors which should transform JSON-LD inputs - * before they are deserialized by Jackson. - * - * Implementations used at the same time must not interfere with each other. - */ -public interface JsonPreprocessor { - - /** - * preprocessing method - * @param input of the transformation, the original JSON-LD - * @return the transformation´s result - * @throws IOException if preprocessing fails, e.g. because the input is not valid RDF - */ - public String preprocess(String input) throws IOException; - - /** - * specify wheter the transformation's result should be validated to - * be parsable by RDF4j - * @param validate enable/disable switch - */ - public void enableRDFValidation(boolean validate); -} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java deleted file mode 100644 index 9de954912..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/preprocessing/TypeNamePreprocessor.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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.rdf.preprocessing; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -public class TypeNamePreprocessor extends BasePreprocessor { - - private static final Map prefixes; - - static { - prefixes = new HashMap<>(); - prefixes.put("ids:", "https://w3id.org/idsa/core/"); - prefixes.put("idsc:", "https://w3id.org/idsa/code/"); - prefixes.put("info:", "http://www.fraunhofer.de/fraunhofer-digital/infomodell#"); - prefixes.put("kdsf:", "http://kerndatensatz-forschung.de/version1/technisches_datenmodell/owl/Basis#"); - } - - @Override - String preprocess_impl(String input) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - Map inMap = mapper.readValue(input, Map.class); - Map outMap = unifyTypeURIPrefix(inMap); - return mapper.writeValueAsString(outMap); - } - - - private Map unifyTypeURIPrefix(Map in) { - Map out = new LinkedHashMap<>(); - in.forEach((k,v) -> { - if(v instanceof String && k instanceof String && k.equals("@type")) { - - - // if key is @type and value is a string: add 'ids:' if no other namespace at the value - AtomicReference modifiableValue = new AtomicReference<>((String) v); - prefixes.forEach((p, u) -> modifiableValue.set(modifiableValue.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableValue.get().startsWith("ids:") - || modifiableValue.get().startsWith("idsc:") - || modifiableValue.get().startsWith("info:") - || modifiableValue.get().startsWith("kdsf:") - || modifiableValue.get().startsWith("xsd:") - || modifiableValue.get().startsWith("http://") - || modifiableValue.get().startsWith("https://"))) { - modifiableValue.set("ids:".concat(modifiableValue.get())); // default to ids prefix for backwards compatibility - } - out.put(k, modifiableValue.get()); - - - } else if(v instanceof Map) { - AtomicReference modifiableKey = new AtomicReference<>((String) k); - - prefixes.forEach((prefix, uri) -> modifiableKey.set(modifiableKey.get().replace(uri, prefix))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://") - || modifiableKey.get().startsWith("@context"))) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - - - // shorten an @id Map - if (((Map) v).containsKey("@id") && ((Map) v).keySet().size() == 1) { - Map idMap = new LinkedHashMap<>(); - idMap.put(k, ((Map) v).get("@id")); - - out.putAll(unifyTypeURIPrefix(idMap)); - - } else if (((Map) v).containsKey("@value") && - ((Map) v).containsKey("@type")) - { - if( ((Map) v).get("@type").toString().contains("dateTime") ) - { - - // shorten an @value Map with xsd:dateTimes - Object date = ((Map) v).get("@value"); - out.put(modifiableKey, date); - } - else if(((Map) v).get("@type").toString().equals("xsd:integer")) - { - int value = Integer.parseInt(((Map) v).get("@value").toString()); - out.put(modifiableKey, value); - } - else { //Do the same as below - out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); - } - - } else { - - out.put(modifiableKey, unifyTypeURIPrefix((Map) v)); - - - } - - } else if(v instanceof ArrayList) { - - - AtomicReference modifiableKey = new AtomicReference<>((String) k); - prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://"))) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - - Iterator iter = new ArrayList((ArrayList) v).iterator(); //making a copy of the old array so the iterator does not get confused by the element deletions - while (iter.hasNext()) { - Object child = iter.next(); - if (child instanceof Map && ((Map) child).containsKey("@id") && ((Map) child).keySet().size() == 1) { - ((ArrayList) v).remove(child); - ((ArrayList) v).add(((Map) child).get("@id")); - } - } - - out.put(modifiableKey, unifyTypeURIPrefix((ArrayList) v)); // TODO: What happens with an Array inside the Array? - - - } else { - - - AtomicReference modifiableKey = new AtomicReference<>((String) k); - prefixes.forEach((p, u) -> modifiableKey.set(modifiableKey.get().replace(u, p))); // replace full URI with prefix - if(! (modifiableKey.get().startsWith("ids:") - || modifiableKey.get().startsWith("info:") - || modifiableKey.get().startsWith("kdsf:") - || modifiableKey.get().startsWith("http://") - || modifiableKey.get().startsWith("https://") - || modifiableKey.get().startsWith("@"))) { - //in the context definition, a pair might look like this: "ids" : "http://www.someURL.com" - //Here, we start with "ids", not "ids:". So we also need to check that the key is not contained in our prefixes - if(!prefixes.containsKey(modifiableKey.get() + ":")) { - modifiableKey.set("ids:".concat(modifiableKey.get())); // default to ids prefix for backwards compatibility - } - } - - out.put(modifiableKey, v); // modify nothing if not @type or a map - } - }); - return out; - } - - - private ArrayList unifyTypeURIPrefix(ArrayList in) { - ArrayList out = new ArrayList<>(); - - Iterator iter = in.iterator(); - - while (iter.hasNext()) { - Object v = iter.next(); - if(v instanceof Map) { - - - if (!((Map) v).isEmpty()) - out.add( unifyTypeURIPrefix((Map) v)); - - - } else if (v instanceof String) { - - out.add(v); // modify nothing if not @type or a map - } else { - out.add(v); - } - } - return out; - } - - - - -} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java index 7acbacdba..3fbb9bc0b 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java @@ -17,137 +17,17 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; - -import org.apache.jena.riot.RDFLanguages; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import java.io.IOException; @RunWith(JUnitParamsRunner.class) public class ParserTest { - @Test - public void parseAasEnvironmentTest() throws IOException, DeserializationException { - String aasEnvAsString = SerializerUtil.readResourceToString("example-from-serializer.jsonld"); - Environment aasEnv = new RdfParser().read(aasEnvAsString); - Assert.assertEquals(1, aasEnv.getSubmodels().size()); - Assert.assertEquals(1, aasEnv.getAssetAdministrationShells().get(0).getDescription().size()); - Assert.assertEquals(2, aasEnv.getAssetAdministrationShells().get(0).getDisplayName().size()); - - Assert.assertEquals("de", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(0).getLanguage()); - Assert.assertEquals("en", aasEnv.getAssetAdministrationShells().get(0).getDisplayName().get(1).getLanguage()); - Assert.assertNotNull(aasEnv.getAssetAdministrationShells().get(0).getDescription().get(0).getLanguage()); - - } -// -// @Test -// @Ignore -// public void parseFullTurtleEnvironmentTest() throws IOException, DeserializationException { -// String aasEnvAsString = SerializerUtil.readResourceToString("AASFull.ttl"); -// Environment environment = new RdfParser().read(aasEnvAsString); -// -// // TODO continue providing a correct AASFull Turtle representation -// // TODO test for LangStrings -// Assert.assertEquals(AASFull.ENVIRONMENT, environment); -// } -// -// -// @Test -// @Parameters({"AAS_Reference_shortExample.ttl", "AssetAdministrationShell_Example.ttl", -// "Complete_Example.ttl", "ReferenceExample.ttl" /*, "KapitalVerwaltungsschaleExample.ttl"*/}) -// public void parseAasTurtleSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// -// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file),AssetAdministrationShell.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); -// } -// -// @Test -// @Parameters({ "AAS_Reference_shortExample.nt", "Overall-Example.nt"}) -// public void parseAasNtriplesSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// -// AssetAdministrationShell aas = serializer.deserialize(SerializerUtil.readResourceToString(file), AssetAdministrationShell.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(aas.getAssetInformation().getAssetKind()); -// } -// -// @Test -// @Parameters({"Submodel_SubmodelElement_Example.ttl"}) -// public void parseSubmodelSchemaExamplesTest(String file) throws IOException, DeserializationException { -// Serializer serializer = new Serializer(); -// //These work -// -// Submodel submodel = serializer.deserialize(SerializerUtil.readResourceToString(file), Submodel.class, RDFLanguages.TURTLE); -// -// Assert.assertNotNull(submodel.getSubmodelElements().get(0).getIdShort()); -// -// -// //The following examples do not work yet, as they are semantically problematic -// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.ttl"), Reference.class, RDFLanguages.TURTLE); -// //serializer.deserialize(SerializerUtil.readResourceToString("Submodel_SubmodelElement_shortExample.nt"), Reference.class, RDFLanguages.NTRIPLES); -// } -// -// -// -// -// @Test -// public void deserializeConceptDescription() throws IOException, DeserializationException { -// String conceptDescription = "{\n" + -// " \"@context\" : {\n" + -// " \"aas\" : \"https://admin-shell.io/aas/3/0/RC02/\",\n" + -// " \"phys_unit\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02/\",\n" + -// " \"iec61360\" : \"https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/\"\n" + -// " },\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultConceptDescription/c6bd22b3-6487-49d2-a86d-e3834d22ceb9\",\n" + -// " \"@type\" : \"aas:ConceptDescription\",\n" + -// " \"isCaseOf\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications\" : [ {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecification/f461858c-8981-4141-bac3-6aee56977017\",\n" + -// " \"@type\" : \"aas:EmbeddedDataSpecification\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation\" : {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultReference/41ee5bcc-adde-4a5a-bfb5-ace237247d0c\",\n" + -// " \"@type\" : \"aas:Reference\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/Reference/key\" : [ {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultKey/234b457f-0e8f-46b3-8e73-f850a79269f1\",\n" + -// " \"@type\" : \"aas:Key\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/Key/value\" : \"https://example.org\"\n" + -// " } ]\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent\" : {\n" + -// " \"@id\" : \"https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/457288b3-77e1-474a-ab74-866bdcafd914\",\n" + -// " \"@type\" : \"iec61360:DataSpecificationIEC61360\",\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType\" : {\n" + -// " \"@type\" : \"https://admin-shell.io/aas/3/0/RC02/DataTypeIEC61360\",\n" + -// " \"@id\" : \"https://admin-shell.io/aas/3/0/RC02/RATIONAL\"\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName\" : [ ],\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName\" : [ ]\n" + -// " },\n" + -// " \"https://admin-shell.io/aas/3/0/RC02/DataSpecification/id\" : \"http://example.org/DataSpecification1\"\n" + -// " } ]\n" + -// "}"; -// -// Serializer serializer = new Serializer(); -// ConceptDescription c = serializer.deserialize(conceptDescription, ConceptDescription.class); -// -// Assert.assertNotNull(c); -// } -// - } diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 6431a764b..e659e3f6e 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -20,20 +20,17 @@ import org.apache.jena.riot.Lang; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.*; -import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import org.junit.Assert; import org.junit.Test; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -42,193 +39,73 @@ public class SerializerTest { - //TODO: Optional: Prefixes instead of full URIs - //TODO: Optional: Do not serialize empty collections @Test - public void simpleConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("simple") - .build(); - - String output = null; - try { - output = new RdfSerializer().write(conceptDescription); - System.out.println(output); - - Model model = ModelFactory.createDefaultModel(); - InputStream inputStream = new ByteArrayInputStream(output.getBytes()); - model.read(inputStream, null, "TTL"); -// ResourceFactory.createResource(Identifiable.id); -// ResourceFactory.createProperty(propertyUriString); - // Get all subject nodes that are of type ConceptDescription - ResIterator resIterator = model.listResourcesWithProperty(RDF.type, - ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); - Resource createdConceptDescriptionResource = resIterator.nextResource(); - Statement idStatement = model.getProperty(createdConceptDescriptionResource, - ResourceFactory.createProperty(Identifiable.id)); - assert idStatement.getString().equals(conceptDescription.getId()); - } catch (SerializationException e) { - throw new RuntimeException(e); - } + public void testKey() throws IOException { + 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 testReference() throws IncompatibleTypeException { + Reference reference = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).keys(Arrays.asList(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 simpleConceptDescription() throws IOException, IncompatibleTypeException { + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("simple").build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(conceptDescription); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert model.contains(createdResource, RDF.type, AASNamespace.Types.ConceptDescription); + assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + ConceptDescription recreatedConceptDescription = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert conceptDescription.equals(recreatedConceptDescription); } @Test public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("complex") - .extensions(Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build())) - .category("myCategory") - .idShort("exampleIdShort") - .displayName(Arrays.asList( - new DefaultLangStringNameType.Builder() - .text("text in English") - .language("en") - .build(), - new DefaultLangStringNameType.Builder() - .text("متن به فارسی") - .language("fa") - .build() - )) - .description(Arrays.asList( - new DefaultLangStringTextType.Builder() - .text("A long text in English") - .language("en") - .build(), - new DefaultLangStringTextType.Builder() - .text("영어로 된 긴 텍스트") - .language("ko") - .build() - )) - .administration(new DefaultAdministrativeInformation.Builder() - .version("1") - .revision("0") - .creator(new DefaultReference.Builder() - .keys(Arrays.asList( - 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()) - .build() - ).isCaseOf(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.com/outside") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .build() - )) - .embeddedDataSpecifications(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()) - .build()) - .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() - .levelType(new DefaultLevelType.Builder() - .max(true) - .min(true) - .nom(false) - .typ(false) - .build()) - .unit("gram") - .symbol("g") + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("complex").extensions(Arrays.asList(new DefaultExtension.Builder().name("extension1").value("extension1Value").build(), new DefaultExtension.Builder().name("extension2").value("extension2Value").build())).category("myCategory").idShort("exampleIdShort").displayName(Arrays.asList(new DefaultLangStringNameType.Builder().text("text in English").language("en").build(), new DefaultLangStringNameType.Builder().text("متن به فارسی").language("fa").build())).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("A long text in English").language("en").build(), new DefaultLangStringTextType.Builder().text("영어로 된 긴 텍스트").language("ko").build())).administration(new DefaultAdministrativeInformation.Builder().version("1").revision("0").creator(new DefaultReference.Builder().keys(Arrays.asList(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()).build()).isCaseOf(Arrays.asList(new DefaultReference.Builder().keys(new DefaultKey.Builder().value("https://example.com/outside").type(KeyTypes.GLOBAL_REFERENCE).build()).type(ReferenceTypes.EXTERNAL_REFERENCE).build())).embeddedDataSpecifications(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()).build()).dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder().levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()).unit("gram").symbol("g") // .definition() // .shortName() // .preferredName() // .valueFormat() // .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE) - .build()) - .build()) - .build(); - - String output = null; - try { - String outputJsonLd = new RdfSerializer().write(conceptDescription, Lang.JSONLD); - System.out.println(outputJsonLd); - output = new RdfSerializer().write(conceptDescription); - System.out.println(output); - - Model model = ModelFactory.createDefaultModel(); - InputStream inputStream = new ByteArrayInputStream(output.getBytes()); - model.read(inputStream, null, "TTL"); -// ResourceFactory.createResource(Identifiable.id); -// ResourceFactory.createProperty(propertyUriString); - // Get all subject nodes that are of type ConceptDescription - ResIterator resIterator = model.listResourcesWithProperty(RDF.type, - ResourceFactory.createResource("https://admin-shell.io/aas/3/0/ConceptDescription")); - Resource createdConceptDescriptionResource = resIterator.nextResource(); - Statement idStatement = model.getProperty(createdConceptDescriptionResource, - ResourceFactory.createProperty(Identifiable.id)); - assert idStatement.getString().equals(conceptDescription.getId()); - } catch (SerializationException e) { - throw new RuntimeException(e); - } + .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); + } @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { - AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) - .build()) - .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())) - .displayName(Arrays.asList( - 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() - .description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())) - .displayName(Arrays.asList( - 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() - .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(); + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder().assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())).displayName(Arrays.asList(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().description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())).displayName(Arrays.asList(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().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(); + Environment aasEnv = new DefaultEnvironment.Builder().assetAdministrationShells(aasList).submodels(submodel).conceptDescriptions(conceptDescription).build(); - String output = new RdfSerializer().write(aasEnv); + String output = new RDFSerializer().write(aasEnv); System.out.println(output); } } diff --git a/dataformat-rdf/src/test/resources/AASFull.ttl b/dataformat-rdf/src/test/resources/AASFull.ttl deleted file mode 100644 index 8c11c4546..000000000 --- a/dataformat-rdf/src/test/resources/AASFull.ttl +++ /dev/null @@ -1,354 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - -# AAS Environment - rdf:type aas:Environment ; - ; - ; - ; -. - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "MaxRotationSpeed"^^xs:string ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "PARAMETER"^^xs:string ; - "0173-1#02-BAA120#008"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Max. rotation speed"@en, "max. Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; - . - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "RotationSpeed"^^xs:string ; - rdfs:label "RotationSpeed"^^xs:string ; - "PROPERTY"^^xs:string ; - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] . - - rdf:type aas:DataSpecificationIEC61360 ; - "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Document"^^xs:string ; - rdfs:label "Document"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Document"@en, "Dokument"@de ; - "Document"@en ; - "[ISO 15519-1:2010]"^^xs:string ; - ; - "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Title"^^xs:string ; - rdfs:label "Title"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; - . - - rdf:type aas:DataSpecificationIEC61360 ; - "Titel"@en, "Titel"@de ; - "Titel"@en ; - ; - "Sprachabhängiger Titel des Dokuments."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "DigitalFile"^^xs:string ; - rdfs:label "DigitalFile"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - - rdf:type aas:DataSpecificationIEC61360 ; - "Digital File"@en ; - "DigitalFile"@en ; - ; - "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt deleted file mode 100644 index 65b752bdc..000000000 --- a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.nt +++ /dev/null @@ -1,16 +0,0 @@ - . - "ExampleMotor"^^ . - "ExampleMotor"^^ . - "A very short description of the AAS instance"@en . - "A very short description of the AAS instance."^^ . - "https://customer.com/aas/9175_7013_7091_9168"^^ . - _:AssetInformation . -_:AssetInformation . -_:AssetInformation _:GlobalAssetId . -_:AssetInformation . -_:GlobalAssetId . -_:GlobalAssetId . -_:GlobalAssetId _:Key . -_:Key . -_:Key . -_:Key "https://customer.com/assets/KHBVZJSQKIY"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl b/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl deleted file mode 100644 index e22b250fd..000000000 --- a/dataformat-rdf/src/test/resources/AAS_Reference_shortExample.ttl +++ /dev/null @@ -1,27 +0,0 @@ -@prefix : . -@prefix aas: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; -. diff --git a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl b/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl deleted file mode 100644 index e5f25bfe6..000000000 --- a/dataformat-rdf/src/test/resources/AssetAdministrationShell_Example.ttl +++ /dev/null @@ -1,56 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Complete_Example.ttl b/dataformat-rdf/src/test/resources/Complete_Example.ttl deleted file mode 100644 index 0c800f8d1..000000000 --- a/dataformat-rdf/src/test/resources/Complete_Example.ttl +++ /dev/null @@ -1,347 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - -# Asset Administration Shell - rdf:type aas:AssetAdministrationShell ; - "ExampleMotor"^^xs:string ; - rdfs:label "ExampleMotor"^^xs:string ; - "A very short description of the AAS instance"@en ; - rdfs:comment "A very short description of the AAS instance."^^xs:string ; - "https://customer.com/aas/9175_7013_7091_9168"^^xs:string ; - [ - rdf:type ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] ; - ] ; - ; - ]; - - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ] - ]; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^xs:string ; - ] - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "MaxRotationSpeed"^^xs:string ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "PARAMETER"^^xs:string ; - "0173-1#02-BAA120#008"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Max. rotation speed"@en, "max. Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Höchste zulässige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de, "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en ; - . - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "RotationSpeed"^^xs:string ; - rdfs:label "RotationSpeed"^^xs:string ; - "PROPERTY"^^xs:string ; - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] . - - rdf:type aas:DataSpecificationIEC61360 ; - "Actual rotation speed"@en, "Aktuelle Drehzahl"@de ; - "1/min"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#05-AAA650#002"^^xs:string ; - ] ; - ] ; - ; - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de, "Actual rotation speed with which the motor or feeding unit is operated."@en ; -. - - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Document"^^xs:string ; - rdfs:label "Document"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - rdf:type aas:DataSpecificationIEC61360 ; - "Document"@en, "Dokument"@de ; - "Document"@en ; - "[ISO 15519-1:2010]"^^xs:string ; - ; - "Feste und geordnete Menge von für die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "Title"^^xs:string ; - rdfs:label "Title"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; - . - - rdf:type aas:DataSpecificationIEC61360 ; - "Titel"@en, "Titel"@de ; - "Titel"@en ; - ; - "Sprachabhängiger Titel des Dokuments."@de ; -. - -# ConceptDescription - rdf:type aas:ConceptDescription ; - "DigitalFile"^^xs:string ; - rdfs:label "DigitalFile"^^xs:string ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^xs:string ; - [ - rdf:type aas:EmbeddedDataSpecification ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^xs:string ; - ] ; - ] ; - ; - ] ; -. - - - rdf:type aas:DataSpecificationIEC61360 ; - "Digital File"@en ; - "DigitalFile"@en ; - ; - "Eine Datei, die die DocumentVersion repräsentiert. Neben der obligatorischen PDF/A Datei können weitere Dateien angegeben werden."@de ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Overall-Example.nt b/dataformat-rdf/src/test/resources/Overall-Example.nt deleted file mode 100644 index 3921c9aff..000000000 --- a/dataformat-rdf/src/test/resources/Overall-Example.nt +++ /dev/null @@ -1,253 +0,0 @@ - . - "ExampleMotor"^^ . - "ExampleMotor"^^ . - "A very short description of the AAS instance"@en . - "A very short description of the AAS instance."^^ . - "https://customer.com/aas/9175_7013_7091_9168"^^ . - _:AssetInformation . - _:Submodel1 . - _:Submodel2 . - _:Submodel3 . -_:AssetInformation . -_:AssetInformation _:GlobalAssetId1 . -_:AssetInformation . -_:GlobalAssetId1 . -_:GlobalAssetId1 . -_:GlobalAssetId1 _:Key1 . -_:Key1 . -_:Key1 . -_:Key1 "https://customer.com/assets/KHBVZJSQKIY"^^ . -_:Submodel1 . -_:Submodel1 . -_:Submodel1 _:Key2 . -_:Key2 . -_:Key2 . -_:Key2 "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . -_:Submodel2 . -_:Submodel2 . -_:Submodel2 _:Key3 . -_:Key3 . -_:Key3 . -_:Key3 "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . -_:Submodel3 . -_:Submodel3 . -_:Submodel3 _:Key4 . -_:Key4 . -_:Key4 . -_:Key4 "http://i40.customer.com/type/1/1/1A7B62B529F19152"^^ . - . - "TechnicalData"^^ . - "TechnicalData"^^ . - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . - . - _:SemanticId1 . - _:SubmodelElement1 . -_:SemanticId1 . -_:SemanticId1 . -_:SemanticId1 _:Key5 . -_:Key5 . -_:Key5 . -_:Key5 "0173-1#01-AFZ615#016"^^ . -_:SubmodelElement1 . -_:SubmodelElement1 "MaxRotationSpeed"^^ . -_:SubmodelElement1 "MaxRotationSpeed"^^ . -_:SubmodelElement1 . -_:SubmodelElement1 _:ValueId1 . -_:SubmodelElement1 "5000"^^ . -_:ValueId1 . -_:ValueId1 . -_:ValueId1 _:Key6 . -_:Key6 . -_:Key6 . -_:Key6 "0173-1#02-BAA120#008"^^ . - . - "OperationalData"^^ . - "OperationalData"^^ . - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^ . - . - _:SubmodelElement2 . -_:SubmodelElement2 . -_:SubmodelElement2 "RotationSpeed"^^ . -_:SubmodelElement2 "RotationSpeed"^^ . -_:SubmodelElement2 . -_:SubmodelElement2 . -_:SubmodelElement2 _:ValueId2 . -_:SubmodelElement2 "4370"^^ . -_:ValueId2 . -_:ValueId2 . -_:ValueId2 _:Key7 . -_:Key7 . -_:Key7 . -_:Key7 "http://customer.com/cd/1/1/18EBD56F6B43D895"^^ . - . - "Documentation"^^ . - "Documentation"^^ . - " . - . - _:SubmodelElement3 . -_:SubmodelElement3 . -_:SubmodelElement3 "OperatingManual"^^ . -_:SubmodelElement3 "OperatingManual"^^ . -_:SubmodelElement3 _:SemanticIdListElement1 . -_:SubmodelElement3 . -_:SubmodelElement3 _:Value1 . -_:SubmodelElement3 _:Value3 . -_:SubmodelElement3 . -_:SemanticIdListElement1 . -_:SemanticIdListElement1 . -_:SemanticIdListElement1 _:Key8 . -_:Key8 . -_:Key8 . -_:Key8 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . -_:Value1 . -_:Value1 _:Value2 . -_:Value2 . -_:Value2 . -_:Value2 "Title"^^ . -_:Value2 "application/pdf" . -_:Value2 "file:///aas/OperatingManual.pdf"^^ . -_:Value2 "Title"^^ . -_:Value2 "CONSTANT"^^ . -_:Value2 _:SemanticId2 . -_:Value2 . -_:SemanticId2 . -_:SemanticId2 . -_:SemanticId2 _:Key9 . -_:Key9 . -_:Key9 . -_:Key9 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . -_:Value3 . -_:Value3 _:Value4 . -_:Value4 . -_:Value4 . -_:Value4 "DigitalFile_PDF"^^ . -_:Value4 "application/pdf" . -_:Value4 "file:///aasx/OperatingManual.pdf"^^ . -_:Value4 "DigitalFile_PDF"^^ . -_:Value4 "CONSTANT"^^ . -_:Value4 _:SemanticId3. -_:Value4 . -_:SemanticId3 . -_:SemanticId3 . -_:SemanticId3 _:Key10 . -_:Key10 . -_:Key10 . -_:Key10 "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^ . - . - "MaxRotationSpeed"^^ . - "MaxRotationSpeed"^^ . - "PARAMETER"^^ . - "0173-1#02-BAA120#008"^^ . - _:EmbeddedDataSpecification1 . -_:EmbeddedDataSpecification1 . -_:EmbeddedDataSpecification1 _:DataSpecification1 . -_:EmbeddedDataSpecification1 . -_:DataSpecification1 . -_:DataSpecification1 . -_:DataSpecification1 _:Key11 . -_:Key11 . -_:Key11 . -_:Key11 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Max. rotation speed"@en . - "max. Drehzahl"@de . - "1/min"^^ . - _:UnitId1 . - . - "H\u00F6chste zul\u00E4ssige Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben werden darf"@de . - "Greatest permissible rotation speed with which the motor or feeding unit may be operated"@en . -_:UnitId1 . -_:UnitId1 . -_:UnitId1 _:Key12 . -_:Key12 . -_:Key12 . -_:Key12 "0173-1#05-AAA650#002"^^ . - . - "RotationSpeed"^^ . - "RotationSpeed"^^ . - "PROPERTY"^^ . - "https://customer.com/cd/18EBD56F6B43D895/RotationSpeed"^^ . - _:EmbeddedDataSpecification2 . -_:EmbeddedDataSpecification2 . -_:EmbeddedDataSpecification2 _:DataSpecification2 . -_:EmbeddedDataSpecification2 . -_:DataSpecification2 . -_:DataSpecification2 . -_:DataSpecification2 _:Key13 . -_:Key13 . -_:Key13 . -_:Key13 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Actual rotation speed"@en . - "Aktuelle Drehzahl"@de . - "1/min"^^ . - _:UnitId2 . - . - "Aktuelle Drehzahl, mit welcher der Motor oder die Speiseinheit betrieben wird."@de . - "Actual rotation speed with which the motor or feeding unit is operated."@en . -_:UnitId2 . -_:UnitId2 . -_:UnitId2 _:Key14 . -_:Key14 . -_:Key14 . -_:Key14 "0173-1#05-AAA650#002"^^ . - . - "Document"^^ . - "Document"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^ . - _:EmbeddedDataSpecification3 . -_:EmbeddedDataSpecification3 . -_:EmbeddedDataSpecification3 _:DataSpecification3 . -_:EmbeddedDataSpecification3 . -_:DataSpecification3 . -_:DataSpecification3 . -_:DataSpecification3 _:Key15 . -_:Key15 . -_:Key15 . -_:Key15 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Document"@en . - "Dokument"@de . - "Document"@en . - "[ISO 15519-1:2010]"^^ . - . - "Feste und geordnete Menge von f\u00FCr die Verwendung durch Personen bestimmte Informationen, die verwaltet und als Einheit zwischen Benutzern und System ausgetauscht werden kann."@de . - . - "Title"^^ . - "Title"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^ . - _:EmbeddedDataSpecification4 . -_:EmbeddedDataSpecification4 . -_:EmbeddedDataSpecification4 _:DataSpecification4 . -_:EmbeddedDataSpecification4 . -_:DataSpecification4 . -_:DataSpecification4 . -_:DataSpecification4 _:Key16 . -_:Key16 . -_:Key16 . -_:Key16 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Titel"@en . - "Titel"@de . - "Titel"@en . - . - "Sprachabh\u00E4ngiger Titel des Dokuments."@de . - . - "DigitalFile"^^ . - "DigitalFile"^^ . - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/StoredDocumentRepresentation/DigitalFile"^^ . - _:EmbeddedDataSpecification5 . -_:EmbeddedDataSpecification5 . -_:EmbeddedDataSpecification5 _:DataSpecification5 . -_:EmbeddedDataSpecification5 . -_:DataSpecification5 . -_:DataSpecification5 . -_:DataSpecification5 _:Key17 . -_:Key17 . -_:Key17 . -_:Key17 "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360"^^ . - . - "Digital File"@en . - "DigitalFile"@en . - . - "Eine Datei, die die DocumentVersion repr\u00E4sentiert. Neben der obligatorischen PDF/A Datei k\u00F6nnen weitere Dateien angegeben werden."@de . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/ReferenceExample.ttl b/dataformat-rdf/src/test/resources/ReferenceExample.ttl deleted file mode 100644 index a18db83e5..000000000 --- a/dataformat-rdf/src/test/resources/ReferenceExample.ttl +++ /dev/null @@ -1,18 +0,0 @@ -@prefix xs: . - -# 1) Reference with KeyElements - a ; - [ - a ; - ; - [ - a ; - ; - [ - a ; - ; - "http://customer.com/assets/KHBVZJSQKIY"^^xs:string ; - ] - ] - ] ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl deleted file mode 100644 index 3e50807d6..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_Example.ttl +++ /dev/null @@ -1,137 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "OperationalData"^^xs:string ; - rdfs:label "OperationalData"^^xs:string ; - "http://i40.customer.com/instance/1/1/AC69B1CB44F07935"^^xs:string ; - ; - - [ - rdf:type aas:Property ; - rdfs:label "RotationSpeed"^^xs:string ; - "RotationSpeed"^^xs:string ; - ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "http://customer.com/cd/1/1/18EBD56F6B43D895"^^xs:string ; - ] - - ]; - "4370"^^xs:string ; - ]; -. - -# Submodel - rdf:type aas:Submodel ; - "Documentation"^^xs:string ; - rdfs:label "Documentation"^^xs:string ; - " ; - [ - rdf:type aas:SubmodelElementList ; - "OperatingManual"^^xs:string ; - rdfs:label "OperatingManual"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Document"^^xs:string ; - ] - ] ; - ; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type ; - rdf:subject ; - rdfs:label "Title"^^xs:string ; - "application/pdf" ; - "file:///aas/OperatingManual.pdf"^^xs:string ; # TODO - "Title"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title"^^xs:string ; - ] - ] ; - ; - ] - ]; - [ - rdf:type aas:SubmodelElementCollection ; - [ - rdf:type aas:File; - rdf:subject ; - rdfs:label "DigitalFile_PDF"^^xs:string ; - "application/pdf" ; - "file:///aasx/OperatingManual.pdf"^^xs:string ; - "DigitalFile_PDF"^^xs:string ; - "CONSTANT"^^xs:string ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "https://www.vdi2770.com/blatt1/Entwurf/Okt18/cd/escription/Title"^^xs:string ; - ] - ] ; - ; - ]; - ] ; - ; - ] ; -. \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt deleted file mode 100644 index 2733f1131..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.nt +++ /dev/null @@ -1,25 +0,0 @@ - . - "TechnicalData"^^ . - "TechnicalData"^^ . - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^ . - . - _:SemanticId . - _:SubmodelElements . -_:SemanticId . -_:SemanticId . -_:SemanticId _:Key1 . -_:Key1 . -_:Key1 . -_:Key1 "0173-1#01-AFZ615#016"^^ . -_:SubmodelElements . -_:SubmodelElements "MaxRotationSpeed"^^ . -_:SubmodelElements "MaxRotationSpeed"^^ . -_:SubmodelElements . -_:SubmodelElements _:ValueId . -_:SubmodelElements "5000"^^ . -_:ValueId . -_:ValueId . -_:ValueId _:Key2 . -_:Key2 . -_:Key2 . -_:Key2 "0173-1#02-BAA120#008"^^ . \ No newline at end of file diff --git a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl b/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl deleted file mode 100644 index 9c1d7f8c4..000000000 --- a/dataformat-rdf/src/test/resources/Submodel_SubmodelElement_shortExample.ttl +++ /dev/null @@ -1,42 +0,0 @@ -@prefix aas: . -@prefix owl: . -@prefix rdf: . -@prefix rdfs: . -@prefix xs: . - - - -# Submodel - rdf:type aas:Submodel ; - "TechnicalData"^^xs:string ; - rdfs:label "TechnicalData"^^xs:string ; - "http://i40.customer.com/type/1/1/7A7104BDAB57E184"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#01-AFZ615#016"^^xs:string ; - ] ; - ] ; - - - [ - rdf:type aas:Property ; - rdfs:label "MaxRotationSpeed"^^xs:string ; - "MaxRotationSpeed"^^xs:string ; - ; - [ - rdf:type aas:Reference ; - ; - [ - rdf:type aas:Key ; - ; - "0173-1#02-BAA120#008"^^xs:string ; - ] ; - ]; - "5000"^^xs:string ; - ]; -. diff --git a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld b/dataformat-rdf/src/test/resources/example-from-serializer.jsonld deleted file mode 100644 index 7eac7fa6c..000000000 --- a/dataformat-rdf/src/test/resources/example-from-serializer.jsonld +++ /dev/null @@ -1,88 +0,0 @@ -{ - "@context" : { - "aas" : "https://admin-shell.io/aas/3/0/RC02/" - }, - "@id" : "https://admin-shell.io/autogen/DefaultEnvironment/7e646a58-7419-41e2-99e8-163a7abb7b46", - "@type" : "aas:Environment", - "https://admin-shell.io/aas/3/0/RC02/Environment/assetAdministrationShells" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultAssetAdministrationShell/b869a629-8d69-4754-9c50-804b0e9eb35a", - "@type" : "aas:AssetAdministrationShell", - "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/assetInformation" : { - "@id" : "https://admin-shell.io/autogen/DefaultAssetInformation/6882a093-6831-445d-a884-f2ebc37aaa29", - "@type" : "aas:AssetInformation", - "https://admin-shell.io/aas/3/0/RC02/AssetInformation/assetKind" : { - "@type" : "aas:AssetKind", - "@id" : "https://admin-shell.io/aas/3/0/RC02/AssetKind/Instance" - }, - "https://admin-shell.io/aas/3/0/RC02/AssetInformation/specificAssetIds" : [ ] - }, - "https://admin-shell.io/aas/3/0/RC02/AssetAdministrationShell/submodel" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { - "@language" : "en-us", - "@value" : "This is a test AAS" - } ], - "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { - "@language" : "de", - "@value" : "Anzeigename 2" - }, { - "@language" : "en", - "@value" : "Display Name 1" - } ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] - } ], - "https://admin-shell.io/aas/3/0/RC02/Environment/conceptdescriptions" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultConceptDescription/14b4a819-7ca0-4cb2-b2c7-33a1c443c899", - "@type" : "aas:ConceptDescription", - "https://admin-shell.io/aas/3/0/RC02/ConceptDescription/isCaseOf" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultDataSpecification/66cf9a6c-e656-4c95-91be-2ddc1779ec71", - "@type" : "aas:EmbeddedDataSpecification", - "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecifiation" : { - "@id" : "https://admin-shell.io/autogen/DefaultReference/251d9f19-b36b-4c39-b517-3d7e93bd8c96", - "@type" : "aas:Reference", - "https://admin-shell.io/aas/3/0/RC02/Reference/key" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultKey/ad4e8527-e002-4776-87ca-7049e7be440f", - "@type" : "aas:Key", - "https://admin-shell.io/aas/3/0/RC02/Key/value" : "https://example.org" - } ] - } , - "https://admin-shell.io/aas/3/0/RC02/EmbeddedDataSpecification/dataSpecificationContent" : { - "@id" : "https://admin-shell.io/autogen/DefaultDataSpecificationIEC61360/5319d62e-7ca1-4954-addf-76db6bf1e241", - "@type" : "aas:DataSpecificationIEC61360", - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/dataType" : { - "@type" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/DataTypeIEC61360", - "@id" : "https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC02/RATIONAL" - }, - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/definition" : [ ], - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/preferredName" : [ ], - "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIEC61360/shortName" : [ ] - }, - "https://admin-shell.io/aas/3/0/RC02/DataSpecification/id" : "http://example.org/DataSpecification1" - } ] - } ], - "https://admin-shell.io/aas/3/0/RC02/Environment/submodels" : [ { - "@id" : "https://admin-shell.io/autogen/DefaultSubmodel/18810336-c309-42f8-9986-438f7068f0d6", - "@type" : "aas:Submodel", - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/dataSpecifiation" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasExtensions/extension" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasSemantics/supplementalSemanticIds" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Qualifiable/qualifier" : [ ], - "https://admin-shell.io/aas/3/0/RC02/Referable/category" : "Example category", - "https://admin-shell.io/aas/3/0/RC02/Referable/description" : [ { - "@language" : "en-us", - "@value" : "My Submodel" - } ], - "https://admin-shell.io/aas/3/0/RC02/Referable/displayName" : [ { - "@language" : "en", - "@value" : "First Submodel Element name" - }, { - "@language" : "en", - "@value" : "Second Submodel Element name" - } ], - "https://admin-shell.io/aas/3/0/RC02/Submodel/submodelElement" : [ ], - "https://admin-shell.io/aas/3/0/RC02/HasDataSpecification/embeddedDataSpecifications" : [ ] - } ] -} \ No newline at end of file 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 41afc0483..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 { - String id = "https://admin-shell.io/aas/3/0/Identifiable/id"; /** * Administrative information of an identifiable element. * @@ -56,7 +55,7 @@ public interface Identifiable extends Referable { * * @return Returns the String for the property id. */ - @IRI(id) + @IRI("https://admin-shell.io/aas/3/0/Identifiable/id") String getId(); /** From c48ab7501d79dbffdfabda300733c8ef51879dd7 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Mon, 29 Jan 2024 00:43:01 +0100 Subject: [PATCH 132/160] Add DataSpecificationIec61360 --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 256 ++++++++++++++++-- .../rdf/IncompatibleTypeException.java | 3 + ...ltAdministrativeInformationRDFHandler.java | 16 +- ...ltDataSpecificationIEC61360RDFHandler.java | 129 ++++++++- .../DefaultLangStringNameTypeRDFHandler.java | 30 +- .../DefaultLangStringTextTypeRDFHandler.java | 30 +- .../handlers/DefaultReferenceRDFHandler.java | 2 +- .../DefaultSubmodelElementRDFHandler.java | 120 ++++++++ ...tringDefinitionTypeIec61360RDFHandler.java | 37 +++ ...ngPreferredNameTypeIec61360RDFHandler.java | 37 +++ ...StringShortNameTypeIec61360RDFHandler.java | 37 +++ .../DefaultLevelTypeRDFHandler.java | 40 +++ .../DefaultValueListRDFHandler.java | 60 ++++ .../DefaultValueReferencePairRDFHandler.java | 42 +++ .../rdf/DataSpecificationIec61360Test.java | 118 ++++++++ .../v3/dataformat/rdf/SerializerTest.java | 100 ++++++- 16 files changed, 1009 insertions(+), 48 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java 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 index d75755bad..4646cebce 100644 --- 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 @@ -3,13 +3,14 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; /** * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. */ -public class AASNamespace { +public final class AASNamespace { public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; public static final Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); @@ -23,7 +24,7 @@ private AASNamespace() { * * @see AASNamespace.KeyTypes */ - public static class Key { + public static final class Key { /** * The key value, for example an IRDI or an URI */ @@ -34,19 +35,19 @@ public static class Key { public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); } - public static class Reference { + public static final class Reference { public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); } - public static class Referable { + public static final class Referable { public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); } - public static class Identifiable { + public static final class Identifiable { public static final Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); public static final Property administration = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/administration"); } @@ -63,7 +64,7 @@ public static class ConceptDescription { * * @see AASNamespace.Key */ - public static class KeyTypes { + public static final class KeyTypes { public static final Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); public static final Resource AssetAdministrationShell = @@ -110,23 +111,25 @@ public static class KeyTypes { ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); public static final Resource SubmodelElementList = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementList"); - public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI){ - if(stringIRI.equals(FragmentReference.getURI())){ + + public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String stringIRI) { + if (stringIRI.equals(FragmentReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE; } - if(stringIRI.equals(GlobalReference.getURI())){ + if (stringIRI.equals(GlobalReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.GLOBAL_REFERENCE; } throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type){ - if(type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT.name())){ + + public static 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())){ + 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())){ + if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes.FRAGMENT_REFERENCE.name())) { return FragmentReference; } @@ -134,32 +137,34 @@ public static Resource valueOf(String type){ } } - public static class ReferenceTypes { - public static org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes fromIRI(String stringIRI){ - if(stringIRI.equals(ModelReference.getURI())){ + public static final class ReferenceTypes { + public static final Resource ExternalReference = + ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); + public static final 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())){ + if (stringIRI.equals(ExternalReference.getURI())) { return org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE; } throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type){ - if(type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.EXTERNAL_REFERENCE.name())){ + + public static 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())){ + if (type.equalsIgnoreCase(org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes.MODEL_REFERENCE.name())) { return ModelReference; } throw new IllegalArgumentException("Invalid ReferenceType provided."); } - public static final Resource ExternalReference = - ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); - public static final Resource ModelReference = - ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ModelReference"); } - public static class Types { + public static final class Types { public static final Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); @@ -236,4 +241,205 @@ public static class Types { ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); } + + public static final class LevelType { + public static final Property min = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/min"); + public static final Property nom = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/nom"); + public static final Property typ = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/typ"); + public static final Property max = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/max"); + } + + public static final class AbstractLangString { + public static final Property language = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/language"); + public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); + } + + public static final class ValueReferencePair { + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); + public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); + } + + public static final class ValueList { + public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); + } + + public static final class DataSpecificationIec61360 { + public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/value"); + public static final Property valueFormat = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueFormat"); + public static final Property definition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/definition"); + public static final Property dataType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/dataType"); + public static final Property symbol = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/symbol"); + public static final Property sourceOfDefinition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/sourceOfDefinition"); + public static final Property unitId = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unitId"); + public static final Property unit = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unit"); + public static final Property shortName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/shortName"); + public static final Property preferredName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/preferredName"); + public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); + } + + public static final class DataTypeIec61360 { + public static final Resource Blob = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Blob"); + public static final Resource Boolean = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Boolean"); + public static final Resource Date = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Date"); + public static final Resource File = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/File"); + public static final Resource Html = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Html"); + public static final Resource IntegerCount = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCount"); + public static final Resource IntegerCurrency = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCurrency"); + public static final Resource IntegerMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerMeasure"); + public static final Resource Irdi = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Irdi"); + public static final Resource Iri = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Iri"); + public static final Resource Rational = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Rational"); + public static final Resource RationalMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RationalMeasure"); + public static final Resource RealCount = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCount"); + public static final Resource RealCurrency = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCurrency"); + public static final Resource RealMeasure = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealMeasure"); + public static final Resource String = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/String"); + public static final Resource StringTranslatable = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/StringTranslatable"); + public static final Resource Time = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Time"); + public static final 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 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."); + } + } } 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 index 1b7cb3c4e..7c4da8781 100644 --- 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 @@ -4,4 +4,7 @@ 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/handlers/DefaultAdministrativeInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java index 2a3b2f74a..946b2d804 100644 --- 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 @@ -1,7 +1,12 @@ 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.AASNamespace; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; 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.AdministrativeInformation; @@ -9,11 +14,20 @@ public class DefaultAdministrativeInformationRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(AdministrativeInformation key) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (key == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public AdministrativeInformation fromModel(Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + throw new IllegalArgumentException("Provided Resource is not a _"); + } + return null; } } 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 index 88093bff2..ae8985d0f 100644 --- 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 @@ -1,20 +1,137 @@ 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.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.DataSpecificationIec61360; +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.dataspecificationiec61360.*; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.builder.DataSpecificationIec61360Builder; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; public class DefaultDataSpecificationIEC61360RDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(DataSpecificationIec61360 object) { - return null; + 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() == false){ + 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() == false){ + 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() == false){ + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false){ + throw new IncompatibleTypeException("DataSpecificationIec61360"); + } + DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); + + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.preferredName)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.shortName)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.definition)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unit)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unitId)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.sourceOfDefinition)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.symbol)){ + + } + 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)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.valueList)){ + + } + if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.levelType)){ + + } + + + 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 index e27ac069b..024be783d 100644 --- 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 @@ -1,20 +1,38 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.IncompatibleTypeException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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.dataformat.rdf.RDFHandler; -public class DefaultLangStringNameTypeRDFHandler implements RDFHandler{ +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; + +public class DefaultLangStringNameTypeRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(LangStringNameType object) { - return null; + 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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + return new DefaultRDFHandlerResult(model, subject); } @Override public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); + } + + return new DefaultLangStringNameType.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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 index 2d2c34397..04e55de72 100644 --- 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 @@ -1,19 +1,37 @@ 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.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.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{ +public class DefaultLangStringTextTypeRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(LangStringTextType object) { - return null; + 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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + return new DefaultRDFHandlerResult(model, subject); } @Override public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); + } + + return new DefaultLangStringTextType.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .build(); } } 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 index 6a760557e..5c8c93aab 100644 --- 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 @@ -42,7 +42,7 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); Map keysMap = new HashMap<>(); - NodeIterator keysIterator = model.listObjectsOfProperty(AASNamespace.Reference.keys); + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse,AASNamespace.Reference.keys); keysIterator.forEachRemaining(node->{ Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); 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..5a6c5e173 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelElementRDFHandler.java @@ -0,0 +1,120 @@ +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.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; + +public class DefaultSubmodelElementRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(SubmodelElement object) { + // it should be bottom up in hierarchy + if (object.getClass().isInstance(AnnotatedRelationshipElement.class)) { + return new DefaultAnnotatedRelationshipElementRDFHandler().toModel((AnnotatedRelationshipElement) object); + } + if (object.getClass().isInstance(RelationshipElement.class)) { + return new DefaultRelationshipElementRDFHandler().toModel((RelationshipElement) object); + } + if (object.getClass().isInstance(BasicEventElement.class)) { + return new DefaultBasicEventElementRDFHandler().toModel((BasicEventElement) object); + } + if (object.getClass().isInstance(Blob.class)) { + return new DefaultBlobRDFHandler().toModel((Blob) object); + } + if (object.getClass().isInstance(File.class)) { + return new DefaultFileRDFHandler().toModel((File) object); + } + if (object.getClass().isInstance(MultiLanguageProperty.class)) { + return new DefaultMultiLanguagePropertyRDFHandler().toModel((MultiLanguageProperty) object); + } + if (object.getClass().isInstance(Property.class)) { + return new DefaultPropertyRDFHandler().toModel((Property) object); + } + if (object.getClass().isInstance(Range.class)) { + return new DefaultRangeRDFHandler().toModel((Range) object); + } + if (object.getClass().isInstance(ReferenceElement.class)) { + return new DefaultReferenceElementRDFHandler().toModel((ReferenceElement) object); + } + if (object.getClass().isInstance(SubmodelElementCollection.class)) { + return new DefaultSubmodelElementCollectionRDFHandler().toModel((SubmodelElementCollection) object); + } + if (object.getClass().isInstance(SubmodelElementList.class)) { + return new DefaultSubmodelElementListRDFHandler().toModel((SubmodelElementList) object); + } + if (object.getClass().isInstance(Entity.class)) { + return new DefaultEntityRDFHandler().toModel((Entity) object); + } + if (object.getClass().isInstance(Capability.class)) { + return new DefaultCapabilityRDFHandler().toModel((Capability) object); + } + if (object.getClass().isInstance(Operation.class)) { + return new DefaultOperationRDFHandler().toModel((Operation) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known type"); + } + + @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/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..99018a3e6 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringDefinitionTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringDefinitionTypeIec61360"); + } + + return new DefaultLangStringDefinitionTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..556783bf3 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringPreferredNameTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringPreferredNameTypeIec61360"); + } + + return new DefaultLangStringPreferredNameTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..c77865651 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLangStringShortNameTypeIec61360RDFHandler.java @@ -0,0 +1,37 @@ +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.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); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + throw new IllegalArgumentException("Provided Resource is not a LangStringShortNameTypeIec61360"); + } + + return new DefaultLangStringShortNameTypeIec61360.Builder() + .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) + .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) + .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..a9a359ce3 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultLevelTypeRDFHandler.java @@ -0,0 +1,40 @@ +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) == false){ + throw new IllegalArgumentException("Provided Resource is not a LevelType"); + } + return new DefaultLevelType.Builder() + .min(model.getProperty(subjectToParse,AASNamespace.LevelType.min).getBoolean()) + .max(model.getProperty(subjectToParse,AASNamespace.LevelType.max).getBoolean()) + .nom(model.getProperty(subjectToParse,AASNamespace.LevelType.nom).getBoolean()) + .typ(model.getProperty(subjectToParse,AASNamespace.LevelType.typ).getBoolean()) + .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..e9c2657f2 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueListRDFHandler.java @@ -0,0 +1,60 @@ +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); + 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) == false) { + throw new IncompatibleTypeException("ValueList"); + } + 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); + }); + List valueReferencePairList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + valueReferencePairList.add(keysMap.get(index)); + } + return new DefaultValueList.Builder() + .valueReferencePairs(valueReferencePairList) + .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..56b152a94 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/dataspecificationiec61360/DefaultValueReferencePairRDFHandler.java @@ -0,0 +1,42 @@ +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); + model.add(subject, AASNamespace.ValueReferencePair.value, object.getValue()); + RDFSerializationResult referenceSerializationResult = new DefaultReferenceRDFHandler().toModel(object.getValueId()); + model.add(referenceSerializationResult.getModel()); + model.add(subject,AASNamespace.ValueReferencePair.valueId,referenceSerializationResult.getResource()); + return new DefaultRDFHandlerResult(model, subject); + } + + @Override + public ValueReferencePair fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false){ + throw new IncompatibleTypeException("ValueReferencePair"); + } + + Reference reference = new DefaultReferenceRDFHandler().fromModel(model, model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.valueId).getResource()); + return new DefaultValueReferencePair.Builder() + .value(model.getProperty(subjectToParse,AASNamespace.ValueReferencePair.value).getString()) + .valueId(reference) + .build(); + } +} 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..ea30c6c41 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/DataSpecificationIec61360Test.java @@ -0,0 +1,118 @@ +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.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; + +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 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); + } +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index e659e3f6e..649d76305 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -22,6 +22,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultDataSpecificationIEC61360RDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; @@ -55,7 +56,18 @@ public void testKey() throws IOException { @Test public void testReference() throws IncompatibleTypeException { - Reference reference = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).keys(Arrays.asList(new DefaultKey.Builder().value("https://example.com").type(KeyTypes.GLOBAL_REFERENCE).build(), new DefaultKey.Builder().value("fragment").type(KeyTypes.FRAGMENT_REFERENCE).build())).build(); + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(Arrays.asList( + 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(); @@ -82,13 +94,75 @@ public void simpleConceptDescription() throws IOException, IncompatibleTypeExcep @Test public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("complex").extensions(Arrays.asList(new DefaultExtension.Builder().name("extension1").value("extension1Value").build(), new DefaultExtension.Builder().name("extension2").value("extension2Value").build())).category("myCategory").idShort("exampleIdShort").displayName(Arrays.asList(new DefaultLangStringNameType.Builder().text("text in English").language("en").build(), new DefaultLangStringNameType.Builder().text("متن به فارسی").language("fa").build())).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("A long text in English").language("en").build(), new DefaultLangStringTextType.Builder().text("영어로 된 긴 텍스트").language("ko").build())).administration(new DefaultAdministrativeInformation.Builder().version("1").revision("0").creator(new DefaultReference.Builder().keys(Arrays.asList(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()).build()).isCaseOf(Arrays.asList(new DefaultReference.Builder().keys(new DefaultKey.Builder().value("https://example.com/outside").type(KeyTypes.GLOBAL_REFERENCE).build()).type(ReferenceTypes.EXTERNAL_REFERENCE).build())).embeddedDataSpecifications(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()).build()).dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder().levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()).unit("gram").symbol("g") + ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() + .id("complex") + .extensions(Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build())) + .category("myCategory") + .idShort("exampleIdShort") + .displayName(Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build())) + .description(Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build())) + .administration(new DefaultAdministrativeInformation.Builder() + .version("1") + .revision("0") + .creator(new DefaultReference.Builder().keys( + Arrays.asList(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()) + .build()) + .isCaseOf(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("https://example.com/outside") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .embeddedDataSpecifications(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()).build()) + .dataSpecificationContent( + new DefaultDataSpecificationIec61360.Builder() + .levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()) + .unit("gram") + .symbol("g") // .definition() // .shortName() // .preferredName() // .valueFormat() // .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); + .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); } @@ -108,4 +182,24 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE String output = new RDFSerializer().write(aasEnv); System.out.println(output); } + + @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); +// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert dataSpecificationIec61360.equals(recreatedDataSpecification); + } + } From 5c3a85178ab04ecd3d7f952f4a826f627790e187 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 30 Jan 2024 17:39:10 +0100 Subject: [PATCH 133/160] Add ConceptDescription --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 291 ++++++++++++++++++ .../v3/dataformat/rdf/RDFPartialHandler.java | 2 +- ...ltAdministrativeInformationRDFHandler.java | 60 +++- ...ultAssetAdministrationShellRDFHandler.java | 19 +- .../DefaultConceptDescriptionRDFHandler.java | 77 +++-- ...ultDataSpecificationContentRDFHandler.java | 41 +++ ...ltDataSpecificationIEC61360RDFHandler.java | 159 +++++++--- ...ltEmbeddedDataSpecificationRDFHandler.java | 50 ++- .../handlers/DefaultExtensionRDFHandler.java | 87 +++++- .../handlers/DefaultReferenceRDFHandler.java | 6 +- .../DefaultSubmodelElementRDFHandler.java | 28 +- ...HasDataSpecificationRDFPartialHandler.java | 65 ++++ .../DefaultHasSemanticsRDFHandler.java | 21 -- .../DefaultHasSemanticsRDFPartialHandler.java | 68 ++++ .../DefaultIdentifiableRDFHandler.java | 49 --- .../DefaultIdentifiableRDFPartialHandler.java | 54 ++++ .../partial/DefaultReferableRDFHandler.java | 46 --- .../DefaultReferableRDFPartialHandler.java | 134 ++++++++ .../rdf/ConceptDescriptionTest.java | 55 ++++ .../rdf/DataSpecificationIec61360Test.java | 41 +++ .../v3/dataformat/rdf/SerializerTest.java | 152 ++++----- .../v3/dataformat/rdf/SerializerUtil.java | 171 ++++++++++ 22 files changed, 1344 insertions(+), 332 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasDataSpecificationRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFPartialHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java 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 index 4646cebce..d17d9713a 100644 --- 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 @@ -3,6 +3,7 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; @@ -40,6 +41,10 @@ public static final class Reference { public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); } + public static final class HasExtensions { + public static final Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); + } + public static final class Referable { public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); @@ -254,6 +259,14 @@ public static final class AbstractLangString { public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); } + public static final class Extension { + public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/value"); + public static final Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/valueType"); + public static final Property refersTo = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/refersTo"); + public static final Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/name"); + + } + public static final class ValueReferencePair { public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); @@ -262,6 +275,35 @@ public static final class ValueReferencePair { public static final class ValueList { public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } + public static final class EmbeddedDataSpecification { + public static final Property dataSpecification = + ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); + public static final Property dataSpecificationContent = + ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); + } + public static final class HasDataSpecification { + public static final Property embeddedDataSpecifications = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); + } + public static final class HasSemantics { + public static final Property semanticId = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); + public static final Property supplementalSemanticIds = + ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); + + } + public static final class AdministrativeInformation { + public static final Property version = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); + public static final Property revision = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/revision"); + public static final Property creator = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); + public static final Property templateId = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); + public static final Property valueReferencePairs = + ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/valueReferencePairs"); + } public static final class DataSpecificationIec61360 { public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); @@ -439,6 +481,255 @@ public static Resource valueOf(String type) { return Timestamp; } + throw new IllegalArgumentException("Invalid DataTypeIec61360 provided."); + } + } + + public static final class DataTypeDefXsd { + public static final Resource AnyUri = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/AnyUri"); + public static final Resource Base64Binary = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Base64Binary"); + public static final Resource Boolean = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Boolean"); + public static final Resource Byte = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Byte"); + public static final Resource Date = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Date"); + public static final Resource DateTime = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/DateTime"); + public static final Resource Decimal = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Decimal"); + public static final Resource Double = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Double"); + public static final Resource Duration = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Duration"); + public static final Resource Float = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Float"); + public static final Resource GDay = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GDay"); + public static final Resource GMonth = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonth"); + public static final Resource GMonthDay = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonthDay"); + public static final Resource GYear = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYear"); + public static final Resource GYearMonth = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYearMonth"); + public static final Resource HexBinary = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/HexBinary"); + public static final Resource Int = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Int"); + public static final Resource Integer = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Integer"); + public static final Resource Long = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Long"); + public static final Resource NegativeInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NegativeInteger"); + public static final Resource NonNegativeInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonNegativeInteger"); + public static final Resource NonPositiveInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonPositiveInteger"); + public static final Resource PositiveInteger = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/PositiveInteger"); + public static final Resource Short = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Short"); + public static final Resource String = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/String"); + public static final Resource Time = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Time"); + public static final Resource UnsignedByte = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedByte"); + public static final Resource UnsignedInt = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedInt"); + public static final Resource UnsignedLong = + ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedLong"); + public static final 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 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."); } } 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 index 4f8750612..aa7b3dac3 100644 --- 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 @@ -6,5 +6,5 @@ public interface RDFPartialHandler { public void partialToModel(T object, Model model, Resource parentNode); - public T partialFromModel(T object, Model model, Resource subjectToParse); + public 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/handlers/DefaultAdministrativeInformationRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAdministrativeInformationRDFHandler.java index 946b2d804..6fcdd5eca 100644 --- 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 @@ -5,29 +5,67 @@ 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.AASNamespace; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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 key) { + public RDFSerializationResult toModel(AdministrativeInformation object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + 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,object.getVersion()); + } + if(object.getRevision()!=null){ + model.addLiteral(subject,AASNamespace.AdministrativeInformation.revision,object.getRevision()); + } + if(object.getTemplateId()!=null){ + model.addLiteral(subject,AASNamespace.AdministrativeInformation.templateId,object.getTemplateId()); + } + if(object.getCreator()!=null){ + RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); + model.addLiteral(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) { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ - throw new IllegalArgumentException("Provided Resource is not a _"); + public AdministrativeInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AdministrativeInformation"); } - - return null; + 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/DefaultAssetAdministrationShellRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAssetAdministrationShellRDFHandler.java index 37e15e48d..c4dbd2074 100644 --- 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 @@ -4,23 +4,28 @@ import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; public class DefaultAssetAdministrationShellRDFHandler implements RDFHandler { @Override - public RDFSerializationResult toModel(AssetAdministrationShell key) { + public RDFSerializationResult toModel(AssetAdministrationShell object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - return null; + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override - public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) { + public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AssetAdministrationShell"); + } + return null; } + } 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 index c70b60406..1796d4087 100644 --- 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 @@ -1,41 +1,49 @@ 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.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.DefaultIdentifiableRDFHandler; +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.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; 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 key) { + public RDFSerializationResult toModel(ConceptDescription object) { Model model = ModelFactory.createDefaultModel(); - if (key == null) { + if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - Resource conceptDescriptionResource = model.createResource(key.getId()); + Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - //HasDataSpecification - if (key.getEmbeddedDataSpecifications() != null && key.getEmbeddedDataSpecifications().isEmpty() == false) { + if(object.getIsCaseOf()!=null && object.getIsCaseOf().isEmpty() == false) { + 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 DefaultIdentifiableRDFHandler().partialToModel(key, model, conceptDescriptionResource); - - for (Reference reference : key.getIsCaseOf()) { - // TODO: Optional ordering - RDFSerializationResult result = new DefaultReferenceRDFHandler().toModel(reference); - model.add(result.getModel()); - conceptDescriptionResource.addProperty(AASNamespace.ConceptDescription.isCaseOf, result.getResource()); - } + //Identifiable + new DefaultIdentifiableRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource); + //HasDataSpecification + new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object, model, conceptDescriptionResource); return new DefaultRDFHandlerResult(model, conceptDescriptionResource); } @@ -44,9 +52,32 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { throw new IncompatibleTypeException(); } - ConceptDescription build = new DefaultConceptDescription.Builder() - .build(); - new DefaultIdentifiableRDFHandler().partialFromModel(build, model, subjectToParse); - return build; + 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); + }); + 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..4ecda069d --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultDataSpecificationContentRDFHandler.java @@ -0,0 +1,41 @@ +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.dataformat.rdf.handlers.DefaultAnnotatedRelationshipElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultRelationshipElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; + +public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { + @Override + public RDFSerializationResult toModel(DataSpecificationContent object) { + if (DataSpecificationIec61360.class.isInstance(object)) { + return new DefaultDataSpecificationIEC61360RDFHandler().toModel((DataSpecificationIec61360) object); + } + + throw new IllegalArgumentException("Provided object " + + object.getClass() + + " is not a known type"); + } + + @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 SubmodelElement"); + } +} 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 index ae8985d0f..1ce328b78 100644 --- 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 @@ -1,9 +1,7 @@ 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.*; 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.dataspecificationiec61360.*; @@ -11,6 +9,11 @@ import org.eclipse.digitaltwin.aas4j.v3.model.builder.DataSpecificationIec61360Builder; 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) { @@ -20,7 +23,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.DataSpecificationIec61360); - if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false){ + if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false) { int index = 0; for (LangStringPreferredNameTypeIec61360 langString : object.getPreferredName()) { RDFSerializationResult res = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().toModel(langString); @@ -30,7 +33,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getShortName() != null && object.getShortName().isEmpty() == false){ + if (object.getShortName() != null && object.getShortName().isEmpty() == false) { int index = 0; for (LangStringShortNameTypeIec61360 langString : object.getShortName()) { RDFSerializationResult res = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(langString); @@ -40,7 +43,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getDefinition() != null && object.getDefinition().isEmpty() == false){ + if (object.getDefinition() != null && object.getDefinition().isEmpty() == false) { int index = 0; for (LangStringDefinitionTypeIec61360 langString : object.getDefinition()) { RDFSerializationResult res = new DefaultLangStringDefinitionTypeIec61360RDFHandler().toModel(langString); @@ -50,37 +53,37 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getUnit() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.unit,object.getUnit()); + if (object.getUnit() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.unit, object.getUnit()); } - if (object.getUnitId() != null ){ + if (object.getUnitId() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getUnitId()); - model.add(subject,AASNamespace.DataSpecificationIec61360.unitId,res.getResource()); + 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.getSourceOfDefinition() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.sourceOfDefinition, object.getSourceOfDefinition()); } - if (object.getSymbol() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.symbol,object.getSymbol()); + if (object.getSymbol() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.symbol, object.getSymbol()); } - if (object.getDataType() != null ){ + 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.getValueFormat() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.valueFormat, object.getValueFormat()); } - if (object.getValue() != null ){ - model.add(subject,AASNamespace.DataSpecificationIec61360.value,object.getValue()); + if (object.getValue() != null) { + model.add(subject, AASNamespace.DataSpecificationIec61360.value, object.getValue()); } - if (object.getValueList() != null ){ + if (object.getValueList() != null) { RDFSerializationResult res = new DefaultValueListRDFHandler().toModel(object.getValueList()); - model.add(subject,AASNamespace.DataSpecificationIec61360.valueList,res.getResource()); + model.add(subject, AASNamespace.DataSpecificationIec61360.valueList, res.getResource()); model.add(res.getModel()); } - if (object.getLevelType() != null ){ + if (object.getLevelType() != null) { RDFSerializationResult res = new DefaultLevelTypeRDFHandler().toModel(object.getLevelType()); - model.add(subject,AASNamespace.DataSpecificationIec61360.levelType,res.getResource()); + model.add(subject, AASNamespace.DataSpecificationIec61360.levelType, res.getResource()); model.add(res.getModel()); } return new DefaultRDFHandlerResult(model, subject); @@ -88,47 +91,105 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { @Override public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false) { throw new IncompatibleTypeException("DataSpecificationIec61360"); } DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.preferredName)){ - - } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.shortName)){ - - } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.definition)){ - + 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()); + } 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.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); + }); + 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); + }); + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unit)) { + builder.unit(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unit).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.unitId)){ - + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition)) { + builder.sourceOfDefinition(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.sourceOfDefinition).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.symbol)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol)) { + builder.symbol(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.symbol).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.dataType)){ + 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.valueFormat)) { + builder.valueFormat(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.valueFormat).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.value)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.value).getString()); } - if(model.contains(subjectToParse,AASNamespace.DataSpecificationIec61360.valueList)){ - + 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)){ - + if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType)) { + LevelType levelType = new DefaultLevelTypeRDFHandler() + .fromModel(model, model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.levelType).getResource()); + builder.levelType(levelType); } 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 index 65db7671c..22a115a98 100644 --- 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 @@ -1,20 +1,60 @@ 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.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.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.DataSpecificationIec61360; 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) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification) == false) { + 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/DefaultExtensionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java index d9a1f76b2..6d94b8f3c 100644 --- 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 @@ -1,20 +1,93 @@ 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.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.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.DefaultLangStringDefinitionTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; +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) { - return null; + 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, object.getName()); + } + if (object.getValue() != null) { + model.addLiteral(subject, AASNamespace.Extension.value, 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() != false) { + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension) == false) { + 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); + }); + 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/DefaultReferenceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java index 5c8c93aab..802b1b4f7 100644 --- 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 @@ -21,7 +21,9 @@ public RDFSerializationResult toModel(Reference key) { } Resource subject = model.createResource(); subject.addProperty(RDF.type,AASNamespace.Types.Reference); - subject.addProperty(AASNamespace.Reference.type,AASNamespace.ReferenceTypes.valueOf(key.getType().name())); + 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); @@ -38,7 +40,7 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false){ - throw new IncompatibleTypeException(); + throw new IncompatibleTypeException("Reference"); } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); Map keysMap = new HashMap<>(); 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 index 5a6c5e173..101435189 100644 --- 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 @@ -18,46 +18,46 @@ public class DefaultSubmodelElementRDFHandler implements RDFHandler { + @Override + public void partialToModel(HasDataSpecification object, Model model, Resource parentNode) { + if (object.getEmbeddedDataSpecifications() != null && object.getEmbeddedDataSpecifications().isEmpty() == false) { + 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); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); + keysMap.put(index,key); + }); + List keys = new ArrayList<>(); + for(int index=0;index { - - @Override - public void partialToModel(HasSemantics object, Model model, Resource parentNode) { - - } - - @Override - public HasSemantics partialFromModel(HasSemantics object, Model model, Resource subjectToParse) { - return null; - } -} 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..e4387aadd --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultHasSemanticsRDFPartialHandler.java @@ -0,0 +1,68 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultExtensionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringTextTypeRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +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()==false){ + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setSupplementalSemanticIds(langStringList); + } + return object; + } +} diff --git a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java deleted file mode 100644 index ca4c71697..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultIdentifiableRDFHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; - -import org.apache.jena.rdf.model.*; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.AASNamespace; -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.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; - -import java.util.HashMap; -import java.util.Map; - -public class DefaultIdentifiableRDFHandler implements RDFPartialHandler { - - @Override - public void partialToModel(Identifiable object, Model model, Resource parentNode) { - //TODO: Side effect - parentNode.addProperty(AASNamespace.Identifiable.id, object.getId()); - - RDFSerializationResult administrativeResult = new DefaultAdministrativeInformationRDFHandler() - .toModel(object.getAdministration()); - if(object.getAdministration()!=null){ - parentNode.addProperty(AASNamespace.Identifiable.administration, administrativeResult.getResource()); - model.add(administrativeResult.getModel()); - } - - new DefaultReferableRDFHandler().partialToModel(object,model,parentNode); - } - - @Override - public Identifiable partialFromModel(Identifiable object, Model model, Resource subjectToParse) { - //TODO: Side effect - String id = model.getProperty(subjectToParse, AASNamespace.Identifiable.id).getString(); - object.setId(id); - - Statement administrationStatement = model.getProperty(subjectToParse, AASNamespace.Identifiable.administration); - if(administrationStatement!=null) { - Resource administrationToParse = administrationStatement.getResource(); - AdministrativeInformation administrativeInformation = new DefaultAdministrativeInformationRDFHandler().fromModel(model, administrationToParse); - object.setAdministration(administrativeInformation); - } - - //Referable - new DefaultReferableRDFHandler().partialFromModel(object,model,subjectToParse); - 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..d53da392a --- /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.*; +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; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +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/DefaultReferableRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java deleted file mode 100644 index 23ae9b4c8..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; - -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.DefaultAdministrativeInformationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; - -public class DefaultReferableRDFHandler 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() == false){ - - } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ - - } - - } - - @Override - public Referable partialFromModel(Referable object, Model model, Resource subjectToParse) { - if (object.getIdShort() != null) { - - } - if (object.getCategory() != null) { - - } - if (object.getDescription() != null && object.getDescription().isEmpty() == false){ - - } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false){ - - } - 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..8c00a9f19 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultReferableRDFPartialHandler.java @@ -0,0 +1,134 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; + +import org.apache.jena.rdf.model.*; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultExtensionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; +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.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.*; + +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() == false) { + 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() == false) { + 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() == false) { + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setDescription(langStringList); + } + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setDisplayName(langStringList); + } + + //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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setExtensions(langStringList); + } + return object; + } +} 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..a5bf3cbce --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ConceptDescriptionTest.java @@ -0,0 +1,55 @@ +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.DefaultConceptDescriptionRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; +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.Arrays; + +public class ConceptDescriptionTest { + + @Test + public void simpleConceptDescription() throws IOException, IncompatibleTypeException { + ConceptDescription object = new DefaultConceptDescription.Builder() + .id("simple") + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert object.equals(recreatedObject); + } + + + + @Test + public void complexConceptDescription() throws IncompatibleTypeException { + ConceptDescription object = 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.getEmbeddedDataSpecifications()) + .build(); + + RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); + Model model = rdfSerializationResult.getModel(); + model.write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); + assert object.equals(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 index ea30c6c41..e5b89f53a 100644 --- 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 @@ -5,6 +5,7 @@ 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; @@ -14,6 +15,8 @@ import java.util.List; +import static org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.SerializerUtil.getDataSpecificationIec61360; + public class DataSpecificationIec61360Test { @Test @@ -40,6 +43,29 @@ public void testLevelType() throws IncompatibleTypeException { 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 testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() @@ -115,4 +141,19 @@ public void testMinimalDataSpecificationIec61360() throws IncompatibleTypeExcept 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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 649d76305..ca538d270 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -21,11 +21,7 @@ import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultDataSpecificationIEC61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultKeyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultReferableRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultReferenceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.*; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; @@ -42,7 +38,10 @@ public class SerializerTest { @Test public void testKey() throws IOException { - Key simpleKey = new DefaultKey.Builder().value("simple").type(KeyTypes.GLOBAL_REFERENCE).build(); + 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(); @@ -54,6 +53,54 @@ public void testKey() throws IOException { assert simpleKey.equals(recreatedKey); } + @Test + public void testAdministrativeInformationSimple() 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 testAdministrativeInformationComplex() 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() @@ -77,95 +124,6 @@ public void testReference() throws IncompatibleTypeException { assert reference.equals(recreatedKey); } - @Test - public void simpleConceptDescription() throws IOException, IncompatibleTypeException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder().id("simple").build(); - - RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(conceptDescription); - Model model = rdfSerializationResult.getModel(); - model.write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert model.contains(createdResource, RDF.type, AASNamespace.Types.ConceptDescription); - assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); - - ConceptDescription recreatedConceptDescription = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); - assert conceptDescription.equals(recreatedConceptDescription); - } - - @Test - public void complexConceptDescription() throws IOException { - ConceptDescription conceptDescription = new DefaultConceptDescription.Builder() - .id("complex") - .extensions(Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build())) - .category("myCategory") - .idShort("exampleIdShort") - .displayName(Arrays.asList( - new DefaultLangStringNameType.Builder() - .text("text in English") - .language("en") - .build(), - new DefaultLangStringNameType.Builder() - .text("متن به فارسی") - .language("fa") - .build())) - .description(Arrays.asList( - new DefaultLangStringTextType.Builder() - .text("A long text in English") - .language("en") - .build(), - new DefaultLangStringTextType.Builder() - .text("영어로 된 긴 텍스트") - .language("ko") - .build())) - .administration(new DefaultAdministrativeInformation.Builder() - .version("1") - .revision("0") - .creator(new DefaultReference.Builder().keys( - Arrays.asList(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()) - .build()) - .isCaseOf(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("https://example.com/outside") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) - .embeddedDataSpecifications(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()).build()) - .dataSpecificationContent( - new DefaultDataSpecificationIec61360.Builder() - .levelType(new DefaultLevelType.Builder().max(true).min(true).nom(false).typ(false).build()) - .unit("gram") - .symbol("g") -// .definition() -// .shortName() -// .preferredName() -// .valueFormat() -// .valueList() - .dataType(DataTypeIec61360.INTEGER_MEASURE).build()).build()).build(); - - - } @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -187,8 +145,8 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 dataSpecificationIec61360 = new DefaultDataSpecificationIec61360.Builder() .preferredName(List.of(new DefaultLangStringPreferredNameTypeIec61360.Builder() - .language("en") - .text("preferred name") + .language("en") + .text("preferred name") .build())) .build(); RDFSerializationResult rdfSerializationResult = new DefaultDataSpecificationIEC61360RDFHandler().toModel(dataSpecificationIec61360); 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 index e970d8e9f..74ea03f38 100644 --- 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 @@ -19,8 +19,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; import org.apache.commons.io.IOUtils; +import org.eclipse.digitaltwin.aas4j.v3.model.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; /** * Helper class for Serializer Tests @@ -42,4 +46,171 @@ public static String stripWhitespaces(String input) { return input.replaceAll("\\s+", ""); } + public static DefaultDataSpecificationIec61360 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 Arrays.asList( + 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(new DefaultReference.Builder().keys( + Arrays.asList(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()) + .build(); + } + + static List getDescriptions() { + return Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("A long text in English") + .language("en") + .build(), + new DefaultLangStringTextType.Builder() + .text("영어로 된 긴 텍스트") + .language("ko") + .build()); + } + + static List getDisplayNames() { + return Arrays.asList( + new DefaultLangStringNameType.Builder() + .text("text in English") + .language("en") + .build(), + new DefaultLangStringNameType.Builder() + .text("متن به فارسی") + .language("fa") + .build()); + } + + static List getExtensionList() { + return Arrays.asList( + new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .build(), + new DefaultExtension.Builder() + .name("extension2") + .value("extension2Value") + .build()); + } } From 2138ddfc773661f5eeea6e514f2d3f9e550f7d93 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 15:50:19 +0100 Subject: [PATCH 134/160] Add AssetAdministrationShell --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 381 ++++++++++++------ ...nnotatedRelationshipElementRDFHandler.java | 18 +- ...ultAssetAdministrationShellRDFHandler.java | 80 +++- .../DefaultAssetInformationRDFHandler.java | 97 ++++- .../handlers/DefaultExtensionRDFHandler.java | 2 +- .../handlers/DefaultQualifierRDFHandler.java | 71 +++- .../handlers/DefaultResourceRDFHandler.java | 43 ++ .../handlers/DefaultResrouceRDFHandler.java | 19 - .../DefaultSpecificAssetIdRDFHandler.java | 55 ++- .../rdf/DataSpecificationIec61360Test.java | 18 + .../v3/dataformat/rdf/SerializerTest.java | 135 ++++++- .../v3/dataformat/rdf/SerializerUtil.java | 146 ++++++- 12 files changed, 866 insertions(+), 199 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java delete mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java 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 index d17d9713a..93c63ddf4 100644 --- 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 @@ -1,15 +1,12 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; /** - * Elements of Asset Administration Shell as Resource and Property compatible with Apache Jena. + * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. */ public final class AASNamespace { public static final String AAS_NAMESPACE = "https://admin-shell.io/aas/3/0/"; @@ -70,51 +67,51 @@ public static class ConceptDescription { * @see AASNamespace.Key */ public static final class KeyTypes { - public static final Resource AnnotatedRelationshipElement = + public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AnnotatedRelationshipElement"); - public static final Resource AssetAdministrationShell = + public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/AssetAdministrationShell"); - public static final Resource BasicEventElement = + public static final org.apache.jena.rdf.model.Resource BasicEventElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/BasicEventElement"); - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Blob"); - public static final Resource Capability = + public static final org.apache.jena.rdf.model.Resource Capability = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Capability"); - public static final Resource ConceptDescription = + public static final org.apache.jena.rdf.model.Resource ConceptDescription = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ConceptDescription"); - public static final Resource DataElement = + public static final org.apache.jena.rdf.model.Resource DataElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/DataElement"); - public static final Resource Entity = + public static final org.apache.jena.rdf.model.Resource Entity = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Entity"); - public static final Resource EventElement = + public static final org.apache.jena.rdf.model.Resource EventElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/EventElement"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/File"); - public static final Resource FragmentReference = + public static final org.apache.jena.rdf.model.Resource FragmentReference = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/FragmentReference"); - public static final Resource GlobalReference = + public static final org.apache.jena.rdf.model.Resource GlobalReference = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/GlobalReference"); - public static final Resource Identifiable = + public static final org.apache.jena.rdf.model.Resource Identifiable = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Identifiable"); - public static final Resource MultiLanguageProperty = + public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/MultiLanguageProperty"); - public static final Resource Operation = + public static final org.apache.jena.rdf.model.Resource Operation = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Operation"); - public static final Resource Property = + public static final org.apache.jena.rdf.model.Resource Property = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Property"); - public static final Resource Range = + public static final org.apache.jena.rdf.model.Resource Range = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Range"); - public static final Resource ReferenceElement = + public static final org.apache.jena.rdf.model.Resource ReferenceElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/ReferenceElement"); - public static final Resource RelationshipElement = + public static final org.apache.jena.rdf.model.Resource RelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/RelationshipElement"); - public static final Resource Submodel = + public static final org.apache.jena.rdf.model.Resource Submodel = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/Submodel"); - public static final Resource SubmodelElement = + public static final org.apache.jena.rdf.model.Resource SubmodelElement = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElement"); - public static final Resource SubmodelElementCollection = + public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection = ResourceFactory.createResource(AAS_NAMESPACE + "KeyTypes/SubmodelElementCollection"); - public static final Resource SubmodelElementList = + 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) { @@ -127,7 +124,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes fromIRI(String str throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -143,9 +140,9 @@ public static Resource valueOf(String type) { } public static final class ReferenceTypes { - public static final Resource ExternalReference = + public static final org.apache.jena.rdf.model.Resource ExternalReference = ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceTypes/ExternalReference"); - public static final Resource ModelReference = + 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) { @@ -158,7 +155,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes fromIRI(Stri throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -171,78 +168,78 @@ public static Resource valueOf(String type) { public static final class Types { - public static final Resource AdministrativeInformation = + public static final org.apache.jena.rdf.model.Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); - public static final Resource AnnotatedRelationshipElement = + public static final org.apache.jena.rdf.model.Resource AnnotatedRelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "AnnotatedRelationshipElement"); - public static final Resource AssetAdministrationShell = + public static final org.apache.jena.rdf.model.Resource AssetAdministrationShell = ResourceFactory.createResource(AAS_NAMESPACE + "AssetAdministrationShell"); - public static final Resource AssetInformation = + public static final org.apache.jena.rdf.model.Resource AssetInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AssetInformation"); - public static final Resource BasicEventElement = + public static final org.apache.jena.rdf.model.Resource BasicEventElement = ResourceFactory.createResource(AAS_NAMESPACE + "BasicEventElement"); - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "Blob"); - public static final Resource Capability = + public static final org.apache.jena.rdf.model.Resource Capability = ResourceFactory.createResource(AAS_NAMESPACE + "Capability"); - public static final Resource ConceptDescription = + public static final org.apache.jena.rdf.model.Resource ConceptDescription = ResourceFactory.createResource(AAS_NAMESPACE + "ConceptDescription"); - public static final Resource DataSpecificationIec61360 = + public static final org.apache.jena.rdf.model.Resource DataSpecificationIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "DataSpecificationIec61360"); - public static final Resource EmbeddedDataSpecification = + public static final org.apache.jena.rdf.model.Resource EmbeddedDataSpecification = ResourceFactory.createResource(AAS_NAMESPACE + "EmbeddedDataSpecification"); - public static final Resource Entity = + public static final org.apache.jena.rdf.model.Resource Entity = ResourceFactory.createResource(AAS_NAMESPACE + "Entity"); - public static final Resource Extension = + public static final org.apache.jena.rdf.model.Resource Extension = ResourceFactory.createResource(AAS_NAMESPACE + "Extension"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "File"); - public static final Resource Key = + public static final org.apache.jena.rdf.model.Resource Key = ResourceFactory.createResource(AAS_NAMESPACE + "Key"); - public static final Resource LangStringDefinitionTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringDefinitionTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringDefinitionTypeIec61360"); - public static final Resource LangStringNameType = + public static final org.apache.jena.rdf.model.Resource LangStringNameType = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringNameType"); - public static final Resource LangStringPreferredNameTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringPreferredNameTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringPreferredNameTypeIec61360"); - public static final Resource LangStringShortNameTypeIec61360 = + public static final org.apache.jena.rdf.model.Resource LangStringShortNameTypeIec61360 = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringShortNameTypeIec61360"); - public static final Resource LangStringTextType = + public static final org.apache.jena.rdf.model.Resource LangStringTextType = ResourceFactory.createResource(AAS_NAMESPACE + "LangStringTextType"); - public static final Resource LevelType = + public static final org.apache.jena.rdf.model.Resource LevelType = ResourceFactory.createResource(AAS_NAMESPACE + "LevelType"); - public static final Resource MultiLanguageProperty = + public static final org.apache.jena.rdf.model.Resource MultiLanguageProperty = ResourceFactory.createResource(AAS_NAMESPACE + "MultiLanguageProperty"); - public static final Resource Operation = + public static final org.apache.jena.rdf.model.Resource Operation = ResourceFactory.createResource(AAS_NAMESPACE + "Operation"); - public static final Resource OperationVariable = + public static final org.apache.jena.rdf.model.Resource OperationVariable = ResourceFactory.createResource(AAS_NAMESPACE + "OperationVariable"); - public static final Resource Property = + public static final org.apache.jena.rdf.model.Resource Property = ResourceFactory.createResource(AAS_NAMESPACE + "Property"); - public static final Resource Qualifier = + public static final org.apache.jena.rdf.model.Resource Qualifier = ResourceFactory.createResource(AAS_NAMESPACE + "Qualifier"); - public static final Resource Range = + public static final org.apache.jena.rdf.model.Resource Range = ResourceFactory.createResource(AAS_NAMESPACE + "Range"); - public static final Resource Reference = + public static final org.apache.jena.rdf.model.Resource Reference = ResourceFactory.createResource(AAS_NAMESPACE + "Reference"); - public static final Resource ReferenceElement = + public static final org.apache.jena.rdf.model.Resource ReferenceElement = ResourceFactory.createResource(AAS_NAMESPACE + "ReferenceElement"); - public static final Resource RelationshipElement = + public static final org.apache.jena.rdf.model.Resource RelationshipElement = ResourceFactory.createResource(AAS_NAMESPACE + "RelationshipElement"); - public static final Resource Resource = + public static final org.apache.jena.rdf.model.Resource Resource = ResourceFactory.createResource(AAS_NAMESPACE + "Resource"); - public static final Resource SpecificAssetId = + public static final org.apache.jena.rdf.model.Resource SpecificAssetId = ResourceFactory.createResource(AAS_NAMESPACE + "SpecificAssetId"); - public static final Resource Submodel = + public static final org.apache.jena.rdf.model.Resource Submodel = ResourceFactory.createResource(AAS_NAMESPACE + "Submodel"); - public static final Resource SubmodelElementCollection = + public static final org.apache.jena.rdf.model.Resource SubmodelElementCollection = ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementCollection"); - public static final Resource SubmodelElementList = + public static final org.apache.jena.rdf.model.Resource SubmodelElementList = ResourceFactory.createResource(AAS_NAMESPACE + "SubmodelElementList"); - public static final Resource ValueList = + public static final org.apache.jena.rdf.model.Resource ValueList = ResourceFactory.createResource(AAS_NAMESPACE + "ValueList"); - public static final Resource ValueReferencePair = + public static final org.apache.jena.rdf.model.Resource ValueReferencePair = ResourceFactory.createResource(AAS_NAMESPACE + "ValueReferencePair"); } @@ -275,16 +272,19 @@ public static final class ValueReferencePair { public static final class ValueList { public static final Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } + public static final class EmbeddedDataSpecification { public static final Property dataSpecification = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); public static final Property dataSpecificationContent = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); } + public static final class HasDataSpecification { public static final Property embeddedDataSpecifications = ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); } + public static final class HasSemantics { public static final Property semanticId = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); @@ -292,6 +292,28 @@ public static final class HasSemantics { ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); } + + public static final class Qualifiable { + public static final Property qualifiers = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifiable/qualifiers"); + + } + + public static final class Qualifier { + public static final Property kind = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/kind"); + public static final Property type = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/type"); + public static final Property value = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/value"); + public static final Property valueId = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueId"); + public static final Property valueType = + ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueType"); + + + } + public static final class AdministrativeInformation { public static final Property version = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); @@ -301,8 +323,46 @@ public static final class AdministrativeInformation { ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); public static final Property templateId = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); - public static final Property valueReferencePairs = - ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/valueReferencePairs"); + } + + public static final class SpecificAssetId { + public static final Property externalSubjectId = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/externalSubjectId"); + public static final Property name = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/name"); + public static final Property value = + ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/value"); + } + + public static final class AssetAdministrationShell { + public static final Property assetInformation = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); + public static final Property derivedFrom = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/derivedFrom"); + public static final Property submodels = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/submodels"); + } + + public static final class AssetInformation { + public static final Property assetType = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetType"); + public static final Property defaultThumbnail = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/defaultThumbnail"); + public static final Property globalAssetId = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/globalAssetId"); + public static final Property specificAssetIds = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/specificAssetIds"); + + public static final Property assetKind = + ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetKind"); + + } + + public static final class Resource { + public static final Property contentType = + ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/contentType"); + public static final Property path = + ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/path"); } public static final class DataSpecificationIec61360 { @@ -320,44 +380,80 @@ public static final class DataSpecificationIec61360 { public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); } + 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 DataTypeIec61360 { - public static final Resource Blob = + public static final org.apache.jena.rdf.model.Resource Blob = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Blob"); - public static final Resource Boolean = + public static final org.apache.jena.rdf.model.Resource Boolean = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Boolean"); - public static final Resource Date = + public static final org.apache.jena.rdf.model.Resource Date = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Date"); - public static final Resource File = + public static final org.apache.jena.rdf.model.Resource File = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/File"); - public static final Resource Html = + public static final org.apache.jena.rdf.model.Resource Html = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Html"); - public static final Resource IntegerCount = + public static final org.apache.jena.rdf.model.Resource IntegerCount = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCount"); - public static final Resource IntegerCurrency = + public static final org.apache.jena.rdf.model.Resource IntegerCurrency = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerCurrency"); - public static final Resource IntegerMeasure = + public static final org.apache.jena.rdf.model.Resource IntegerMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/IntegerMeasure"); - public static final Resource Irdi = + public static final org.apache.jena.rdf.model.Resource Irdi = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Irdi"); - public static final Resource Iri = + public static final org.apache.jena.rdf.model.Resource Iri = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Iri"); - public static final Resource Rational = + public static final org.apache.jena.rdf.model.Resource Rational = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Rational"); - public static final Resource RationalMeasure = + public static final org.apache.jena.rdf.model.Resource RationalMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RationalMeasure"); - public static final Resource RealCount = + public static final org.apache.jena.rdf.model.Resource RealCount = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCount"); - public static final Resource RealCurrency = + public static final org.apache.jena.rdf.model.Resource RealCurrency = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealCurrency"); - public static final Resource RealMeasure = + public static final org.apache.jena.rdf.model.Resource RealMeasure = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/RealMeasure"); - public static final Resource String = + public static final org.apache.jena.rdf.model.Resource String = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/String"); - public static final Resource StringTranslatable = + public static final org.apache.jena.rdf.model.Resource StringTranslatable = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/StringTranslatable"); - public static final Resource Time = + public static final org.apache.jena.rdf.model.Resource Time = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeIec61360/Time"); - public static final Resource Timestamp = + 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) { @@ -422,7 +518,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360 fromIRI(St throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -486,65 +582,65 @@ public static Resource valueOf(String type) { } public static final class DataTypeDefXsd { - public static final Resource AnyUri = + public static final org.apache.jena.rdf.model.Resource AnyUri = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/AnyUri"); - public static final Resource Base64Binary = + public static final org.apache.jena.rdf.model.Resource Base64Binary = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Base64Binary"); - public static final Resource Boolean = + public static final org.apache.jena.rdf.model.Resource Boolean = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Boolean"); - public static final Resource Byte = + public static final org.apache.jena.rdf.model.Resource Byte = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Byte"); - public static final Resource Date = + public static final org.apache.jena.rdf.model.Resource Date = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Date"); - public static final Resource DateTime = + public static final org.apache.jena.rdf.model.Resource DateTime = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/DateTime"); - public static final Resource Decimal = + public static final org.apache.jena.rdf.model.Resource Decimal = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Decimal"); - public static final Resource Double = + public static final org.apache.jena.rdf.model.Resource Double = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Double"); - public static final Resource Duration = + public static final org.apache.jena.rdf.model.Resource Duration = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Duration"); - public static final Resource Float = + public static final org.apache.jena.rdf.model.Resource Float = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Float"); - public static final Resource GDay = + public static final org.apache.jena.rdf.model.Resource GDay = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GDay"); - public static final Resource GMonth = + public static final org.apache.jena.rdf.model.Resource GMonth = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonth"); - public static final Resource GMonthDay = + public static final org.apache.jena.rdf.model.Resource GMonthDay = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GMonthDay"); - public static final Resource GYear = + public static final org.apache.jena.rdf.model.Resource GYear = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYear"); - public static final Resource GYearMonth = + public static final org.apache.jena.rdf.model.Resource GYearMonth = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/GYearMonth"); - public static final Resource HexBinary = + public static final org.apache.jena.rdf.model.Resource HexBinary = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/HexBinary"); - public static final Resource Int = + public static final org.apache.jena.rdf.model.Resource Int = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Int"); - public static final Resource Integer = + public static final org.apache.jena.rdf.model.Resource Integer = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Integer"); - public static final Resource Long = + public static final org.apache.jena.rdf.model.Resource Long = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Long"); - public static final Resource NegativeInteger = + public static final org.apache.jena.rdf.model.Resource NegativeInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NegativeInteger"); - public static final Resource NonNegativeInteger = + public static final org.apache.jena.rdf.model.Resource NonNegativeInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonNegativeInteger"); - public static final Resource NonPositiveInteger = + public static final org.apache.jena.rdf.model.Resource NonPositiveInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/NonPositiveInteger"); - public static final Resource PositiveInteger = + public static final org.apache.jena.rdf.model.Resource PositiveInteger = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/PositiveInteger"); - public static final Resource Short = + public static final org.apache.jena.rdf.model.Resource Short = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Short"); - public static final Resource String = + public static final org.apache.jena.rdf.model.Resource String = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/String"); - public static final Resource Time = + public static final org.apache.jena.rdf.model.Resource Time = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/Time"); - public static final Resource UnsignedByte = + public static final org.apache.jena.rdf.model.Resource UnsignedByte = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedByte"); - public static final Resource UnsignedInt = + public static final org.apache.jena.rdf.model.Resource UnsignedInt = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedInt"); - public static final Resource UnsignedLong = + public static final org.apache.jena.rdf.model.Resource UnsignedLong = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedLong"); - public static final Resource UnsignedShort = + public static final org.apache.jena.rdf.model.Resource UnsignedShort = ResourceFactory.createResource(AAS_NAMESPACE + "DataTypeDefXsd/UnsignedShort"); @@ -643,7 +739,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd fromIRI(Stri throw new IllegalArgumentException("Invalid DataTypeIec61360 IRI provided."); } - public static Resource valueOf(String type) { + 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; } @@ -732,5 +828,48 @@ public static Resource valueOf(String type) { 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/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultAnnotatedRelationshipElementRDFHandler.java index aa9c77a42..d33586fe7 100644 --- 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 @@ -1,20 +1,30 @@ 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.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.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.AnnotatedRelationshipElement; public class DefaultAnnotatedRelationshipElementRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + throw new IncompatibleTypeException("AssetAdministrationShell"); + } + return null; } } 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 index c4dbd2074..92676c503 100644 --- 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 @@ -1,12 +1,18 @@ 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.*; 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.AssetAdministrationShell; +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.*; +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 @@ -16,16 +22,76 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); + 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() == false){ + 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.AdministrativeInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false){ throw new IncompatibleTypeException("AssetAdministrationShell"); } - - return null; + 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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + builder.submodels(langStringList); + } + 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 index e808db27c..e3ce43a99 100644 --- 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 @@ -1,20 +1,103 @@ 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.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.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.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +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) { - return null; + 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() == 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.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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false){ + 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); + }); + 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/DefaultExtensionRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultExtensionRDFHandler.java index 6d94b8f3c..873defd48 100644 --- 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 @@ -35,7 +35,7 @@ public RDFSerializationResult toModel(Extension object) { model.add(subject, AASNamespace.Extension.valueType, AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); } - if (object.getRefersTo() != null && object.getRefersTo().isEmpty() != false) { + if (object.getRefersTo() != null && object.getRefersTo().isEmpty() == false) { int index = 0; for (Reference reference : object.getRefersTo()) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(reference); 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 index 5e4639a23..b08979b7d 100644 --- 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 @@ -1,20 +1,77 @@ 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.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.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.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) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier) == false) { + 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/DefaultResourceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResourceRDFHandler.java new file mode 100644 index 000000000..f4622e7fb --- /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) == false){ + 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/DefaultResrouceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java deleted file mode 100644 index e146db227..000000000 --- a/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultResrouceRDFHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; - -import org.apache.jena.rdf.model.Model; -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.Resource; - -public class DefaultResrouceRDFHandler implements RDFHandler { - @Override - public RDFSerializationResult toModel(Resource object) { - return null; - } - - @Override - public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { - return null; - } -} 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 index af0b10809..7b75be0fd 100644 --- 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 @@ -1,20 +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.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.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.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId; public class DefaultSpecificAssetIdRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(SpecificAssetId object) { - return null; + 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 { - return null; + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId) == false){ + 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/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 index e5b89f53a..4a6bce649 100644 --- 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 @@ -67,6 +67,24 @@ public void testMaximalEmbeddedDataSpecification() throws IncompatibleTypeExcept } @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); +// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); + + DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); + assert dataSpecificationIec61360.equals(recreatedDataSpecification); + } + @Test public void testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() .text("test") diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index ca538d270..2600cc7b6 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -54,7 +54,7 @@ public void testKey() throws IOException { } @Test - public void testAdministrativeInformationSimple() throws IncompatibleTypeException { + public void testMinimalAdministrativeInformation() throws IncompatibleTypeException { AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() .version("1") .revision("0") @@ -72,7 +72,7 @@ public void testAdministrativeInformationSimple() throws IncompatibleTypeExcepti } @Test - public void testAdministrativeInformationComplex() throws IncompatibleTypeException { + public void testMaximalAdministrativeInformation() throws IncompatibleTypeException { AdministrativeInformation object = new DefaultAdministrativeInformation.Builder() .version("1") .revision("1") @@ -124,6 +124,120 @@ public void testReference() throws IncompatibleTypeException { assert reference.equals(recreatedKey); } + @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 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); + } + + @Test + public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -141,23 +255,6 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE System.out.println(output); } - @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); -// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); - DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); - assert dataSpecificationIec61360.equals(recreatedDataSpecification); - } } 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 index 74ea03f38..ec41dc0d8 100644 --- 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 @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.sql.Ref; import java.util.Arrays; import java.util.List; @@ -30,7 +31,6 @@ * Helper class for Serializer Tests * * @author sbader - * */ public class SerializerUtil { @@ -42,6 +42,8 @@ public static String readResourceToString(String resourceName) throws IOExceptio return writer.toString(); } + + public static String stripWhitespaces(String input) { return input.replaceAll("\\s+", ""); } @@ -118,6 +120,7 @@ public static DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { .build()) .build(); } + public static EmbeddedDataSpecification getEmbeddedDataSpecifications() { return new DefaultEmbeddedDataSpecification.Builder() .dataSpecification( @@ -137,6 +140,7 @@ public static EmbeddedDataSpecification getEmbeddedDataSpecifications() { .dataType(DataTypeIec61360.INTEGER_MEASURE).build()) .build(); } + public static EmbeddedDataSpecification getMaximalEmbeddedDataSpecifications() { return new DefaultEmbeddedDataSpecification.Builder() .dataSpecification( @@ -202,15 +206,139 @@ static List getDisplayNames() { .build()); } + static Extension getMaximalExtension(){ + return new DefaultExtension.Builder() + .name("extension1") + .value("extension1Value") + .valueType(DataTypeDefXsd.ANY_URI) + .refersTo(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("refersTo") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .semanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("semanticId") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build()) + .supplementalSemanticIds(Arrays.asList( + new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("supplementalSemanticIds") + .type(KeyTypes.GLOBAL_REFERENCE) + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .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 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() + .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("id1") + .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 Arrays.asList( - new DefaultExtension.Builder() - .name("extension1") - .value("extension1Value") - .build(), - new DefaultExtension.Builder() - .name("extension2") - .value("extension2Value") - .build()); + getMaximalExtension(), + getMiniamlExtension()); } } From d12f1d403263a525b2b76193baeb6bd8a96a0ad2 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 16:24:45 +0100 Subject: [PATCH 135/160] Rearrange code and cleanups --- dataformat-rdf/pom.xml | 4 +- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 2 - .../rdf/DefaultRDFHandlerResult.java | 1 - .../rdf/IncompatibleTypeException.java | 3 +- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 5 +- .../aas4j/v3/dataformat/rdf/RDFParser.java | 77 +++++++-------- .../v3/dataformat/rdf/RDFPartialHandler.java | 1 + .../v3/dataformat/rdf/RDFSerializer.java | 35 +++---- ...ltAdministrativeInformationRDFHandler.java | 32 +++---- ...nnotatedRelationshipElementRDFHandler.java | 2 +- ...ultAssetAdministrationShellRDFHandler.java | 27 +++--- .../DefaultAssetInformationRDFHandler.java | 34 ++++--- .../rdf/handlers/DefaultBlobRDFHandler.java | 10 +- .../DefaultConceptDescriptionRDFHandler.java | 10 +- ...ultDataSpecificationContentRDFHandler.java | 4 - ...ltDataSpecificationIEC61360RDFHandler.java | 3 +- ...ltEmbeddedDataSpecificationRDFHandler.java | 1 - .../handlers/DefaultExtensionRDFHandler.java | 15 ++- .../rdf/handlers/DefaultKeyRDFHandler.java | 4 +- .../handlers/DefaultPropertyRDFHandler.java | 21 +++- .../handlers/DefaultQualifierRDFHandler.java | 16 ++-- .../handlers/DefaultReferenceRDFHandler.java | 20 ++-- .../handlers/DefaultResourceRDFHandler.java | 20 ++-- .../DefaultSpecificAssetIdRDFHandler.java | 23 +++-- .../DefaultSubmodelElementRDFHandler.java | 4 - .../DefaultLevelTypeRDFHandler.java | 18 ++-- .../DefaultValueListRDFHandler.java | 2 +- .../DefaultValueReferencePairRDFHandler.java | 8 +- ...HasDataSpecificationRDFPartialHandler.java | 14 +-- .../DefaultHasSemanticsRDFPartialHandler.java | 19 ++-- .../DefaultIdentifiableRDFPartialHandler.java | 4 +- .../DefaultReferableRDFPartialHandler.java | 29 +++--- .../rdf/AssetAdministrationShellTest.java | 94 ++++++++++++++++++ .../rdf/ConceptDescriptionTest.java | 8 +- .../rdf/DataSpecificationIec61360Test.java | 2 + .../aas4j/v3/dataformat/rdf/ParserTest.java | 33 ------- .../v3/dataformat/rdf/SerializerTest.java | 96 +------------------ .../v3/dataformat/rdf/SerializerUtil.java | 77 +++++---------- .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 25 +++++ 39 files changed, 384 insertions(+), 419 deletions(-) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java delete mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index bd72cb847..93a8d4061 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 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 index 93c63ddf4..d84cf27ff 100644 --- 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 @@ -2,8 +2,6 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; /** * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. 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 index 57daf095d..3319a5dfc 100644 --- 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 @@ -2,7 +2,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; public class DefaultRDFHandlerResult implements RDFSerializationResult { private final Model model; 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 index 7c4da8781..972cf9e14 100644 --- 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 @@ -4,7 +4,8 @@ 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); + 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/RDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandler.java index 4e56f9bd6..736559469 100644 --- 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 @@ -6,11 +6,13 @@ /** * 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 is side effect free and idempotent. + * * @param element 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. @@ -19,7 +21,8 @@ public interface RDFHandler { /** * This method is side effect free and idempotent. - * @param model The graph model that holds information. + * + * @param model The graph model that holds information. * @param subjectToParse Root elements that correspond to the object. * @return instance of the object */ 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 index b6fad5601..46a0f2e14 100644 --- 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 @@ -14,6 +14,7 @@ public class RDFParser { private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + /** * Deserializes a given string into an instance of AssetAdministrationShellEnvironment * @@ -68,7 +69,7 @@ public Environment read(InputStream src) throws DeserializationException { /** * 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 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 @@ -83,10 +84,10 @@ public Environment read(InputStream src, Charset charset) throws Deserialization /** * 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 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 FileNotFoundException if file is not present * @throws DeserializationException if deserialization fails */ public Environment read(java.io.File file, Charset charset) @@ -99,7 +100,7 @@ public Environment read(java.io.File file, Charset 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 FileNotFoundException if the file is not present * @throws DeserializationException if deserialization fails */ public Environment read(java.io.File file) throws FileNotFoundException, DeserializationException { @@ -115,8 +116,8 @@ public Environment read(java.io.File file) throws FileNotFoundException, Deseria * 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 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) { @@ -127,9 +128,9 @@ public void useImplementation(Class aasInterface, Class impl /** * Deserializes a given string into an instance of the given Referable * - * @param src a string representation of the Referable + * @param src a string representation of the Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -144,9 +145,9 @@ public T readReferable(String src, Class outputClass) t /** * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET * - * @param src a input stream representing a Referable + * @param src a input stream representing a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -157,9 +158,9 @@ public T readReferable(InputStream src, Class outputCla /** * Deserializes a given input stream into an instance of the given Referable using DEFAULT_CHARSET * - * @param root Apache Jena Resource + * @param root Apache Jena Resource * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -174,10 +175,10 @@ public T readReferable(JsonNode root, Class outputClass /** * 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 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 + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -192,11 +193,11 @@ public T readReferable(InputStream src, Charset charset, C /** * 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 src a file containing string representation of a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @throws DeserializationException if deserialization fails * @throws java.io.FileNotFoundException if file is not found */ public T readReferable(File src, Class outputClass) throws DeserializationException, FileNotFoundException { @@ -206,12 +207,12 @@ public T readReferable(File src, Class outputClass) thr /** * 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 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 + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @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 { @@ -221,9 +222,9 @@ public T readReferable(File src, Charset charset, Class /** * 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 referables a string representation of an array of Referables * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of a list of the referables * @throws DeserializationException if deserialization of referable fails */ @@ -238,9 +239,9 @@ public List readReferables(String referables, Class /** * Deserializes a given string into an instance of a list of the given Referables * - * @param root Apache Jena Resource + * @param root Apache Jena Resource * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of a list of the referables * @throws DeserializationException if deserialization of referable fails */ @@ -255,9 +256,9 @@ public List readReferables(Resource root, Class outp /** * 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 src a input stream representing a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -268,10 +269,10 @@ public List readReferables(InputStream src, Class ou /** * 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 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 + * @param type of the returned element * @return an instance of the referable * @throws DeserializationException if deserialization fails */ @@ -286,11 +287,11 @@ public List readReferables(InputStream src, Charset cha /** * 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 src a file containing string representation of a Referable * @param outputClass most specific class of the given Referable - * @param type of the returned element + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @throws DeserializationException if deserialization fails * @throws java.io.FileNotFoundException if file is not found */ public List readReferables(File src, Class outputClass) throws DeserializationException, FileNotFoundException { @@ -300,12 +301,12 @@ public List readReferables(File src, Class outputCla /** * 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 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 + * @param type of the returned element * @return an instance of the referable - * @throws DeserializationException if deserialization fails + * @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 { 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 index aa7b3dac3..efcf1d5b3 100644 --- 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 @@ -6,5 +6,6 @@ public interface RDFPartialHandler { public void partialToModel(T object, Model model, Resource parentNode); + public 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/RDFSerializer.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java index 7b314ccea..328b0d1ea 100644 --- 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 @@ -18,7 +18,7 @@ public class RDFSerializer { /** * Serializes a given instance of AssetAdministrationShellEnvironment to string * - * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize + * @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 @@ -45,7 +45,7 @@ public String write(Environment aasEnvironment) throws SerializationException { /** * Serializes a given instance of a Referable to string * - * @param referable the referable to serialize + * @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 @@ -93,9 +93,9 @@ public RDFSerializationResult toModel(Referable referable) { /** * Serializes a given instance of Environment to an OutputStream using DEFAULT_CHARSET * - * @param out the Outputstream to serialize to + * @param out the Outputstream to serialize to * @param aasEnvironment the Environment to serialize - * @throws IOException if writing to the stream fails + * @throws IOException if writing to the stream fails * @throws SerializationException if serialization fails */ void write(OutputStream out, Environment aasEnvironment) throws IOException, SerializationException { @@ -105,10 +105,10 @@ void write(OutputStream out, Environment aasEnvironment) throws IOException, Ser /** * 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 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 IOException if writing to the stream fails * @throws SerializationException if serialization fails */ void write(OutputStream out, Charset charset, Environment aasEnvironment) @@ -119,14 +119,15 @@ void write(OutputStream out, Charset charset, Environment 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 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 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) @@ -139,10 +140,10 @@ void write(java.io.File file, Charset charset, Environment 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 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 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) @@ -151,11 +152,6 @@ void write(java.io.File file, Environment aasEnvironment) } - - - - - // /** // * // * @param referables the referables to serialize @@ -180,7 +176,6 @@ void write(java.io.File file, Environment aasEnvironment) // } - // public String writeReferables(List referables) throws SerializationException { // try { // throw new RuntimeException("Not Implemented"); 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 index 6fcdd5eca..629daf2f2 100644 --- 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 @@ -19,45 +19,45 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { 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,object.getVersion()); + model.add(subject, RDF.type, AASNamespace.Types.AdministrativeInformation); + if (object.getVersion() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, object.getVersion()); } - if(object.getRevision()!=null){ - model.addLiteral(subject,AASNamespace.AdministrativeInformation.revision,object.getRevision()); + if (object.getRevision() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, object.getRevision()); } - if(object.getTemplateId()!=null){ - model.addLiteral(subject,AASNamespace.AdministrativeInformation.templateId,object.getTemplateId()); + if (object.getTemplateId() != null) { + model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, object.getTemplateId()); } - if(object.getCreator()!=null){ + if (object.getCreator() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); - model.addLiteral(subject,AASNamespace.AdministrativeInformation.creator,res.getResource()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); model.add(res.getModel()); } //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialToModel(object,model,subject); + 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) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { throw new IncompatibleTypeException("AdministrativeInformation"); } DefaultAdministrativeInformation.Builder builder = new DefaultAdministrativeInformation.Builder(); - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.version)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.version)) { builder.version(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.version).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.revision)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.revision)) { builder.revision(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.revision).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.templateId)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.templateId)) { builder.templateId(model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.templateId).getString()); } - if(model.contains(subjectToParse,AASNamespace.AdministrativeInformation.creator)){ + if (model.contains(subjectToParse, AASNamespace.AdministrativeInformation.creator)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.AdministrativeInformation.creator).getResource(); Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); @@ -65,7 +65,7 @@ public AdministrativeInformation fromModel(Model model, Resource subjectToParse) } DefaultAdministrativeInformation object = builder.build(); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index d33586fe7..1f1ae995e 100644 --- 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 @@ -21,7 +21,7 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { throw new IncompatibleTypeException("AssetAdministrationShell"); } 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 index 92676c503..96bf75060 100644 --- 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 @@ -1,12 +1,13 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; import org.apache.jena.rdf.model.*; -import org.apache.jena.rdf.model.Resource; 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.*; +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; @@ -22,13 +23,13 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.AssetAdministrationShell); - if(object.getAssetInformation()!=null){ + 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(subject, AASNamespace.AssetAdministrationShell.assetInformation, res.getResource()); model.add(res.getModel()); } - if(object.getSubmodels()!=null && object.getSubmodels().isEmpty() == false){ + if (object.getSubmodels() != null && object.getSubmodels().isEmpty() == false) { int index = 0; for (Reference item : object.getSubmodels()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -39,9 +40,9 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { index = index + 1; } } - if(object.getDerivedFrom()!=null){ + if (object.getDerivedFrom() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getDerivedFrom()); - model.add(subject,AASNamespace.AssetAdministrationShell.derivedFrom,res.getResource()); + model.add(subject, AASNamespace.AssetAdministrationShell.derivedFrom, res.getResource()); model.add(res.getModel()); } //Identifiable @@ -53,16 +54,16 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { @Override public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false) { throw new IncompatibleTypeException("AssetAdministrationShell"); } DefaultAssetAdministrationShell.Builder builder = new DefaultAssetAdministrationShell.Builder(); - if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.assetInformation)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.submodels)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetAdministrationShell.submodels); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -81,7 +82,7 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) } builder.submodels(langStringList); } - if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom)){ + 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); @@ -90,7 +91,7 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) //Identifiable new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index e3ce43a99..e49608846 100644 --- 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 @@ -4,8 +4,6 @@ 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.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; @@ -22,26 +20,26 @@ public RDFSerializationResult toModel(AssetInformation object) { 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, + 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, + if (object.getAssetType() != null) { + model.add(subject, AASNamespace.AssetInformation.assetType, object.getAssetType()); } - if(object.getDefaultThumbnail()!=null){ + if (object.getDefaultThumbnail() != null) { RDFSerializationResult res = new DefaultResourceRDFHandler().toModel(object.getDefaultThumbnail()); - model.add(subject,AASNamespace.AssetInformation.defaultThumbnail, + model.add(subject, AASNamespace.AssetInformation.defaultThumbnail, res.getResource()); model.add(res.getModel()); } - if(object.getGlobalAssetId()!=null){ - model.add(subject,AASNamespace.AssetInformation.globalAssetId, + if (object.getGlobalAssetId() != null) { + model.add(subject, AASNamespace.AssetInformation.globalAssetId, object.getGlobalAssetId()); } - if(object.getSpecificAssetIds()!=null && object.getSpecificAssetIds().isEmpty() == false){ + if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -57,29 +55,29 @@ public RDFSerializationResult toModel(AssetInformation object) { @Override public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false) { throw new IncompatibleTypeException("AssetInformation"); } DefaultAssetInformation.Builder builder = new DefaultAssetInformation.Builder(); - if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetKind)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.assetType)) { builder.assetType(model.getProperty(subjectToParse, AASNamespace.AssetInformation.assetType).getString()); } - if (model.contains(subjectToParse, AASNamespace.AssetInformation.defaultThumbnail)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.globalAssetId)) { builder.globalAssetId(model.getProperty(subjectToParse, AASNamespace.AssetInformation.globalAssetId).getString()); } - if (model.contains(subjectToParse, AASNamespace.AssetInformation.specificAssetIds)){ + if (model.contains(subjectToParse, AASNamespace.AssetInformation.specificAssetIds)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.AssetInformation.specificAssetIds); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 5df58123d..a5888e465 100644 --- 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 @@ -1,7 +1,10 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; 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; @@ -10,7 +13,12 @@ public class DefaultBlobRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(Blob object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override 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 index 1796d4087..5927dcfcb 100644 --- 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 @@ -6,8 +6,6 @@ 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.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; @@ -27,12 +25,12 @@ public RDFSerializationResult toModel(ConceptDescription object) { Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - if(object.getIsCaseOf()!=null && object.getIsCaseOf().isEmpty() == false) { + if (object.getIsCaseOf() != null && object.getIsCaseOf().isEmpty() == false) { 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()); + model.add(conceptDescriptionResource, AASNamespace.ConceptDescription.isCaseOf, resultItem.getResource()); // It is important where to put model.add model.add(resultItem.getModel()); index = index + 1; @@ -54,7 +52,7 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws } DefaultConceptDescription.Builder builder = new DefaultConceptDescription.Builder(); - if(model.contains(subjectToParse,AASNamespace.ConceptDescription.isCaseOf)){ + if (model.contains(subjectToParse, AASNamespace.ConceptDescription.isCaseOf)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -77,7 +75,7 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws //Identifiable new DefaultIdentifiableRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasDataSpecification - new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object,model,subjectToParse); + 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 index 4ecda069d..a9d2a3ca4 100644 --- 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 @@ -8,12 +8,8 @@ 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.dataformat.rdf.handlers.DefaultAnnotatedRelationshipElementRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultRelationshipElementRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { @Override 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 index 1ce328b78..ee46feca3 100644 --- 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 @@ -1,12 +1,11 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.*; 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.builder.DataSpecificationIec61360Builder; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; import java.util.ArrayList; 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 index 22a115a98..03417cfc8 100644 --- 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 @@ -7,7 +7,6 @@ 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.DataSpecificationIec61360; 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; 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 index 873defd48..11ca61e6b 100644 --- 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 @@ -3,11 +3,8 @@ 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.DefaultLangStringDefinitionTypeIec61360RDFHandler; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial.DefaultHasSemanticsRDFPartialHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; @@ -56,17 +53,17 @@ public Extension fromModel(Model model, Resource subjectToParse) throws Incompat 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.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.value)) { + builder.value(model.getProperty(subjectToParse, AASNamespace.Extension.value).getString()); } - if(model.contains(subjectToParse,AASNamespace.Extension.valueType)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Extension.refersTo)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Extension.refersTo); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 2b05fbdc4..dbcf474b5 100644 --- 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 @@ -27,8 +27,8 @@ public RDFSerializationResult toModel(Key key) { return new DefaultRDFHandlerResult(model, subject); } - public Key fromModel(Model model, Resource subjectToParse){ - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false){ + public Key fromModel(Model model, Resource subjectToParse) { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false) { throw new IllegalArgumentException("Provided Resource is not a Key"); } String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); 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 index 478ef4406..a6416001f 100644 --- 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 @@ -1,20 +1,33 @@ 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.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.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.Property; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; public class DefaultPropertyRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(Property object) { - return null; + Model model = ModelFactory.createDefaultModel(); + if (object == null) { + return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); + } + Resource subject = model.createResource(); + return new DefaultRDFHandlerResult(model, subject); } @Override public Property fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property) == false) { + throw new IncompatibleTypeException("Property"); + } + DefaultProperty.Builder builder = new DefaultProperty.Builder(); + + return null; } } 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 index b08979b7d..e4a67a77e 100644 --- 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 @@ -1,10 +1,12 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.*; +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.Extension; 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; @@ -50,22 +52,22 @@ public Qualifier fromModel(Model model, Resource subjectToParse) throws Incompat throw new IncompatibleTypeException("Qualifier"); } DefaultQualifier.Builder builder = new DefaultQualifier.Builder(); - if (model.contains(subjectToParse, AASNamespace.Qualifier.kind)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.type)) { builder.type(model.getProperty(subjectToParse, AASNamespace.Qualifier.type).getString()); } - if (model.contains(subjectToParse, AASNamespace.Qualifier.value)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.value)) { builder.value(model.getProperty(subjectToParse, AASNamespace.Qualifier.value).getString()); } - if (model.contains(subjectToParse, AASNamespace.Qualifier.valueId)){ + 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)){ + if (model.contains(subjectToParse, AASNamespace.Qualifier.valueType)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.Qualifier.valueType).getResource(); builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); } 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 index 802b1b4f7..946a8a2a7 100644 --- 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 @@ -20,15 +20,15 @@ public RDFSerializationResult toModel(Reference key) { 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())); + 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()); + 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; @@ -39,19 +39,19 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false) { 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->{ + NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); + keysIterator.forEachRemaining(node -> { Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index,key); + keysMap.put(index, key); }); List keys = new ArrayList<>(); - for(int index=0;index { @Override 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 index a9a359ce3..a0622244d 100644 --- 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 @@ -18,23 +18,23 @@ public RDFSerializationResult toModel(LevelType object) { } 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()); + 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) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.LevelType) == false) { throw new IllegalArgumentException("Provided Resource is not a LevelType"); } return new DefaultLevelType.Builder() - .min(model.getProperty(subjectToParse,AASNamespace.LevelType.min).getBoolean()) - .max(model.getProperty(subjectToParse,AASNamespace.LevelType.max).getBoolean()) - .nom(model.getProperty(subjectToParse,AASNamespace.LevelType.nom).getBoolean()) - .typ(model.getProperty(subjectToParse,AASNamespace.LevelType.typ).getBoolean()) + .min(model.getProperty(subjectToParse, AASNamespace.LevelType.min).getBoolean()) + .max(model.getProperty(subjectToParse, AASNamespace.LevelType.max).getBoolean()) + .nom(model.getProperty(subjectToParse, AASNamespace.LevelType.nom).getBoolean()) + .typ(model.getProperty(subjectToParse, AASNamespace.LevelType.typ).getBoolean()) .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 index e9c2657f2..6d2b870e1 100644 --- 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 @@ -20,7 +20,7 @@ public RDFSerializationResult toModel(ValueList object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.ValueList); + model.add(subject, RDF.type, AASNamespace.Types.ValueList); int index = 0; for (ValueReferencePair valueReferencePair : object.getValueReferencePairs()) { RDFSerializationResult valueReferencePairSerializationResult = new DefaultValueReferencePairRDFHandler().toModel(valueReferencePair); 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 index 56b152a94..6fdb367b9 100644 --- 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 @@ -19,23 +19,23 @@ public RDFSerializationResult toModel(ValueReferencePair object) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } Resource subject = model.createResource(); - model.add(subject,RDF.type,AASNamespace.Types.ValueReferencePair); + model.add(subject, RDF.type, AASNamespace.Types.ValueReferencePair); model.add(subject, AASNamespace.ValueReferencePair.value, object.getValue()); RDFSerializationResult referenceSerializationResult = new DefaultReferenceRDFHandler().toModel(object.getValueId()); model.add(referenceSerializationResult.getModel()); - model.add(subject,AASNamespace.ValueReferencePair.valueId,referenceSerializationResult.getResource()); + model.add(subject, AASNamespace.ValueReferencePair.valueId, referenceSerializationResult.getResource()); return new DefaultRDFHandlerResult(model, subject); } @Override public ValueReferencePair fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false){ + if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueReferencePair) == false) { throw new IncompatibleTypeException("ValueReferencePair"); } Reference reference = new DefaultReferenceRDFHandler().fromModel(model, model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.valueId).getResource()); return new DefaultValueReferencePair.Builder() - .value(model.getProperty(subjectToParse,AASNamespace.ValueReferencePair.value).getString()) + .value(model.getProperty(subjectToParse, AASNamespace.ValueReferencePair.value).getString()) .valueId(reference) .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 index aff08f297..8803b691d 100644 --- 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 @@ -1,5 +1,3 @@ - - package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; import org.apache.jena.rdf.model.Model; @@ -10,12 +8,8 @@ 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.dataformat.rdf.handlers.DefaultKeyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultLangStringTextTypeRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; import java.util.ArrayList; import java.util.HashMap; @@ -40,11 +34,11 @@ public void partialToModel(HasDataSpecification object, Model model, Resource pa @Override public HasDataSpecification partialFromModel(HasDataSpecification object, Model model, Resource subjectToParse) { - if(model.contains(subjectToParse,AASNamespace.HasDataSpecification.embeddedDataSpecifications)){ + if (model.contains(subjectToParse, AASNamespace.HasDataSpecification.embeddedDataSpecifications)) { Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasDataSpecification.embeddedDataSpecifications); - keysIterator.forEachRemaining(node->{ + keysIterator.forEachRemaining(node -> { EmbeddedDataSpecification key = null; try { key = new DefaultEmbeddedDataSpecificationRDFHandler().fromModel(model, (Resource) node); @@ -52,10 +46,10 @@ public HasDataSpecification partialFromModel(HasDataSpecification object, Model throw new RuntimeException(e); } int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index,key); + keysMap.put(index, key); }); List keys = new ArrayList<>(); - for(int index=0;index { 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 index 8c00a9f19..204ffaa14 100644 --- 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 @@ -1,14 +1,19 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.partial; -import org.apache.jena.rdf.model.*; +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.*; +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.DefaultKeyRDFHandler; 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.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.*; +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; @@ -64,13 +69,13 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { @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.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.category)) { + object.setCategory(model.getProperty(subjectToParse, AASNamespace.Referable.category).getString()); } - if (model.contains(subjectToParse,AASNamespace.Referable.description)) { + if (model.contains(subjectToParse, AASNamespace.Referable.description)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.description); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -89,7 +94,7 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec } object.setDescription(langStringList); } - if (model.contains(subjectToParse,AASNamespace.Referable.displayName)) { + if (model.contains(subjectToParse, AASNamespace.Referable.displayName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.displayName); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { @@ -110,7 +115,7 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec } //HasExtension - if (model.contains(subjectToParse,AASNamespace.HasExtensions.extensions)) { + if (model.contains(subjectToParse, AASNamespace.HasExtensions.extensions)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.HasExtensions.extensions); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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..815a50b75 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/AssetAdministrationShellTest.java @@ -0,0 +1,94 @@ +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.rdf.handlers.DefaultAssetAdministrationShellRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultAssetInformationRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultResourceRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSpecificAssetIdRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.junit.Test; + +public class AssetAdministrationShellTest { + + @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); + } + + @Test + public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); + assert object.equals(recreatedObject); + } + + @Test + public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { + AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); + 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); + assert object.equals(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 index a5bf3cbce..308ee96ed 100644 --- 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 @@ -3,15 +3,12 @@ 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.DefaultConceptDescriptionRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEmbeddedDataSpecificationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.*; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; import org.junit.Test; import java.io.IOException; -import java.util.Arrays; public class ConceptDescriptionTest { @@ -30,7 +27,6 @@ public void simpleConceptDescription() throws IOException, IncompatibleTypeExcep } - @Test public void complexConceptDescription() throws IncompatibleTypeException { ConceptDescription object = new DefaultConceptDescription.Builder() 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 index 4a6bce649..cf2849d93 100644 --- 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 @@ -66,6 +66,7 @@ public void testMaximalEmbeddedDataSpecification() throws IncompatibleTypeExcept assert object.equals(recreatedObject); } + @Test public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 dataSpecificationIec61360 = new DefaultDataSpecificationIec61360.Builder() @@ -84,6 +85,7 @@ public void testDataSpecificationIec61360() throws IncompatibleTypeException { DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); assert dataSpecificationIec61360.equals(recreatedDataSpecification); } + @Test public void testLangStrings() throws IncompatibleTypeException { DefaultLangStringShortNameTypeIec61360 object = new DefaultLangStringShortNameTypeIec61360.Builder() diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java deleted file mode 100644 index 3fbb9bc0b..000000000 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/ParserTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.rdf; - - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; - -import junitparams.JUnitParamsRunner; - -import java.io.IOException; - -@RunWith(JUnitParamsRunner.class) -public class ParserTest { - -} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 2600cc7b6..1f6cc12bb 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -1,21 +1,6 @@ -/* - * 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.rdf; -import org.apache.jena.rdf.model.*; +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; @@ -24,7 +9,6 @@ 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; @@ -161,83 +145,6 @@ public void testMaximalQualifier() throws IncompatibleTypeException { assert object.equals(recreatedObject); } - @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); - } - - @Test - public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); - 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); - assert object.equals(recreatedObject); - } - - @Test - public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); - 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); - assert object.equals(recreatedObject); - } - @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { @@ -256,5 +163,4 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE } - } 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 index ec41dc0d8..7aef2be01 100644 --- 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 @@ -1,52 +1,15 @@ -/* - * 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.rdf; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.sql.Ref; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.io.IOUtils; import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -/** - * Helper class for Serializer Tests - * - * @author sbader - */ -public class SerializerUtil { - - public static String readResourceToString(String resourceName) throws IOException { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream is = classloader.getResourceAsStream(resourceName); - StringWriter writer = new StringWriter(); - IOUtils.copy(is, writer, "UTF-8"); - return writer.toString(); - } +import java.util.Arrays; +import java.util.List; +public class SerializerUtil { - public static String stripWhitespaces(String input) { - return input.replaceAll("\\s+", ""); - } public static DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { return new DefaultDataSpecificationIec61360.Builder() @@ -206,7 +169,7 @@ static List getDisplayNames() { .build()); } - static Extension getMaximalExtension(){ + static Extension getMaximalExtension() { return new DefaultExtension.Builder() .name("extension1") .value("extension1Value") @@ -234,7 +197,7 @@ static Extension getMaximalExtension(){ .build(); } - static Reference getMinimalReference(){ + static Reference getMinimalReference() { return new DefaultReference.Builder() .keys(new DefaultKey.Builder() .value("minimal") @@ -244,13 +207,14 @@ static Reference getMinimalReference(){ .build(); } - static Qualifier getMinimalQualifier(){ + static Qualifier getMinimalQualifier() { return new DefaultQualifier.Builder() .type("type1") .valueType(DataTypeDefXsd.STRING) .build(); } - static Qualifier getMaximalQualifier(){ + + static Qualifier getMaximalQualifier() { return new DefaultQualifier.Builder() .type("type1") .kind(QualifierKind.CONCEPT_QUALIFIER) @@ -262,7 +226,7 @@ static Qualifier getMaximalQualifier(){ .build(); } - static SpecificAssetId getMaximalSpecificAssetId(){ + static SpecificAssetId getMaximalSpecificAssetId() { return new DefaultSpecificAssetId.Builder() .semanticId(getMinimalReference()) .supplementalSemanticIds(getMinimalReference()) @@ -271,38 +235,43 @@ static SpecificAssetId getMaximalSpecificAssetId(){ .value("value1") .build(); } - static SpecificAssetId getMinimalSpecificAssetId(){ + + static SpecificAssetId getMinimalSpecificAssetId() { return new DefaultSpecificAssetId.Builder() .name("name1") .value("value1") .build(); } - static Property getMinimalProperty(){ + + static Property getMinimalProperty() { return new DefaultProperty.Builder() + .idShort("idShort1") + .valueType(DataTypeDefXsd.DECIMAL) .build(); } - static Extension getMiniamlExtension(){ + static Extension getMiniamlExtension() { return new DefaultExtension.Builder() .name("extension2") .value("extension2Value") .build(); } - static Resource getResource(){ + static Resource getResource() { return new DefaultResource.Builder() .path("path://") .contentType("content/type") .build(); } - static AssetInformation getMinimalAssetInformation(){ + static AssetInformation getMinimalAssetInformation() { return new DefaultAssetInformation.Builder() .assetKind(AssetKind.INSTANCE) .globalAssetId("global1") .build(); } - static AssetInformation getMaximalAssetInformation(){ + + static AssetInformation getMaximalAssetInformation() { return new DefaultAssetInformation.Builder() .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetId("global2") @@ -315,13 +284,14 @@ static AssetInformation getMaximalAssetInformation(){ .build(); } - static AssetAdministrationShell getMinimalAssetAdministrationShell(){ + static AssetAdministrationShell getMinimalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMinimalAssetInformation()) .id("id1") .build(); } - static AssetAdministrationShell getMaximalAssetAdministrationShell(){ + + static AssetAdministrationShell getMaximalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMaximalAssetInformation()) .administration(getAdministrativeInformation()) @@ -336,6 +306,7 @@ static AssetAdministrationShell getMaximalAssetAdministrationShell(){ .build(); } + static List getExtensionList() { return Arrays.asList( getMaximalExtension(), 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..ed15a4811 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java @@ -0,0 +1,25 @@ +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.rdf.handlers.DefaultPropertyRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.Property; +import org.junit.Test; + +public class SubmodelTest { + + @Test + public void testMinimalProperty() throws IncompatibleTypeException { + Property object = SerializerUtil.getMinimalProperty(); + RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + + +} From 3221b76b2cf44835ad281c69269656416c680b71 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Tue, 6 Feb 2024 23:07:26 +0100 Subject: [PATCH 136/160] Add Property --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 144 +++++++++--------- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 6 +- .../v3/dataformat/rdf/RDFPartialHandler.java | 4 +- .../rdf/RDFSerializationResult.java | 14 ++ ...ltAdministrativeInformationRDFHandler.java | 2 +- ...nnotatedRelationshipElementRDFHandler.java | 2 +- ...ultAssetAdministrationShellRDFHandler.java | 4 +- .../DefaultAssetInformationRDFHandler.java | 4 +- .../DefaultConceptDescriptionRDFHandler.java | 4 +- ...ultDataSpecificationContentRDFHandler.java | 2 +- ...ltDataSpecificationIEC61360RDFHandler.java | 8 +- ...ltEmbeddedDataSpecificationRDFHandler.java | 2 +- .../handlers/DefaultExtensionRDFHandler.java | 4 +- .../rdf/handlers/DefaultKeyRDFHandler.java | 27 ++-- .../DefaultLangStringNameTypeRDFHandler.java | 23 ++- .../DefaultLangStringTextTypeRDFHandler.java | 23 ++- .../handlers/DefaultPropertyRDFHandler.java | 52 ++++++- .../handlers/DefaultQualifierRDFHandler.java | 2 +- .../handlers/DefaultReferenceRDFHandler.java | 2 +- .../handlers/DefaultResourceRDFHandler.java | 2 +- .../DefaultSpecificAssetIdRDFHandler.java | 2 +- .../DefaultSubmodelElementRDFHandler.java | 28 ++-- ...tringDefinitionTypeIec61360RDFHandler.java | 23 ++- ...ngPreferredNameTypeIec61360RDFHandler.java | 25 +-- ...StringShortNameTypeIec61360RDFHandler.java | 10 +- .../DefaultLevelTypeRDFHandler.java | 2 +- .../DefaultValueListRDFHandler.java | 2 +- .../DefaultValueReferencePairRDFHandler.java | 30 ++-- ...HasDataSpecificationRDFPartialHandler.java | 2 +- .../DefaultHasSemanticsRDFPartialHandler.java | 2 +- .../DefaultQualifiableRDFPartialHandler.java | 58 +++++++ .../DefaultReferableRDFPartialHandler.java | 6 +- .../v3/dataformat/rdf/SerializerUtil.java | 17 +++ .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 12 ++ 34 files changed, 376 insertions(+), 174 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java 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 index d84cf27ff..3bf92b79a 100644 --- 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 @@ -1,15 +1,14 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; /** - * Elements of Asset Administration Shell as org.apache.jena.rdf.model.Resource and Property compatible with Apache Jena. + * 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 Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); + public static final org.apache.jena.rdf.model.Property index = ResourceFactory.createProperty(AAS_NAMESPACE + "index"); private AASNamespace() { @@ -24,39 +23,39 @@ public static final class Key { /** * The key value, for example an IRDI or an URI */ - public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/value"); + 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 Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); + public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Key/type"); } public static final class Reference { - public static final Property keys = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/keys"); - public static final Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Reference/type"); + 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 Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); + public static final org.apache.jena.rdf.model.Property extensions = ResourceFactory.createProperty(AAS_NAMESPACE + "HasExtensions/extensions"); } public static final class Referable { - public static final Property idShort = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/idShort"); - public static final Property displayName = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/displayName"); - public static final Property description = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/description"); - public static final Property category = ResourceFactory.createProperty(AAS_NAMESPACE + "Referable/category"); + 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 Property id = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/id"); - public static final Property administration = ResourceFactory.createProperty(AAS_NAMESPACE + "Identifiable/administration"); + 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 Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); + public static final org.apache.jena.rdf.model.Property isCaseOf = ResourceFactory.createProperty(AAS_NAMESPACE + "ConceptDescription/isCaseOf"); } /** @@ -243,139 +242,148 @@ public static final class Types { } public static final class LevelType { - public static final Property min = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/min"); - public static final Property nom = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/nom"); - public static final Property typ = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/typ"); - public static final Property max = ResourceFactory.createProperty(AAS_NAMESPACE + "LevelType/max"); + 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 Property language = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/language"); - public static final Property text = ResourceFactory.createProperty(AAS_NAMESPACE + "AbstractLangString/text"); + 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 Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/value"); - public static final Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/valueType"); - public static final Property refersTo = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/refersTo"); - public static final Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "Extension/name"); + 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 Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/value"); - public static final Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueReferencePair/valueId"); + 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 Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); + public static final org.apache.jena.rdf.model.Property valueReferencePairs = ResourceFactory.createProperty(AAS_NAMESPACE + "ValueList/valueReferencePairs"); } public static final class EmbeddedDataSpecification { - public static final Property dataSpecification = + public static final org.apache.jena.rdf.model.Property dataSpecification = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecification"); - public static final Property dataSpecificationContent = + public static final org.apache.jena.rdf.model.Property dataSpecificationContent = ResourceFactory.createProperty(AAS_NAMESPACE + "EmbeddedDataSpecification/dataSpecificationContent"); } public static final class HasDataSpecification { - public static final Property embeddedDataSpecifications = + public static final org.apache.jena.rdf.model.Property embeddedDataSpecifications = ResourceFactory.createProperty(AAS_NAMESPACE + "HasDataSpecification/embeddedDataSpecifications"); } public static final class HasSemantics { - public static final Property semanticId = + public static final org.apache.jena.rdf.model.Property semanticId = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/semanticId"); - public static final Property supplementalSemanticIds = + public static final org.apache.jena.rdf.model.Property supplementalSemanticIds = ResourceFactory.createProperty(AAS_NAMESPACE + "HasSemantics/supplementalSemanticIds"); } public static final class Qualifiable { - public static final Property qualifiers = + public static final org.apache.jena.rdf.model.Property qualifiers = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifiable/qualifiers"); } public static final class Qualifier { - public static final Property kind = + public static final org.apache.jena.rdf.model.Property kind = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/kind"); - public static final Property type = + public static final org.apache.jena.rdf.model.Property type = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/type"); - public static final Property value = + public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/value"); - public static final Property valueId = + public static final org.apache.jena.rdf.model.Property valueId = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueId"); - public static final Property valueType = + public static final org.apache.jena.rdf.model.Property valueType = ResourceFactory.createProperty(AAS_NAMESPACE + "Qualifier/valueType"); } public static final class AdministrativeInformation { - public static final Property version = + public static final org.apache.jena.rdf.model.Property version = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/version"); - public static final Property revision = + public static final org.apache.jena.rdf.model.Property revision = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/revision"); - public static final Property creator = + public static final org.apache.jena.rdf.model.Property creator = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/creator"); - public static final Property templateId = + public static final org.apache.jena.rdf.model.Property templateId = ResourceFactory.createProperty(AAS_NAMESPACE + "AdministrativeInformation/templateId"); } public static final class SpecificAssetId { - public static final Property externalSubjectId = + public static final org.apache.jena.rdf.model.Property externalSubjectId = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/externalSubjectId"); - public static final Property name = + public static final org.apache.jena.rdf.model.Property name = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/name"); - public static final Property value = + public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "SpecificAssetId/value"); } + 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 AssetAdministrationShell { - public static final Property assetInformation = + public static final org.apache.jena.rdf.model.Property assetInformation = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); - public static final Property derivedFrom = + public static final org.apache.jena.rdf.model.Property derivedFrom = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/derivedFrom"); - public static final Property submodels = + public static final org.apache.jena.rdf.model.Property submodels = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/submodels"); } public static final class AssetInformation { - public static final Property assetType = + public static final org.apache.jena.rdf.model.Property assetType = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetType"); - public static final Property defaultThumbnail = + public static final org.apache.jena.rdf.model.Property defaultThumbnail = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/defaultThumbnail"); - public static final Property globalAssetId = + public static final org.apache.jena.rdf.model.Property globalAssetId = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/globalAssetId"); - public static final Property specificAssetIds = + public static final org.apache.jena.rdf.model.Property specificAssetIds = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/specificAssetIds"); - public static final Property assetKind = + public static final org.apache.jena.rdf.model.Property assetKind = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetInformation/assetKind"); } public static final class Resource { - public static final Property contentType = + public static final org.apache.jena.rdf.model.Property contentType = ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/contentType"); - public static final Property path = + public static final org.apache.jena.rdf.model.Property path = ResourceFactory.createProperty(AAS_NAMESPACE + "Resource/path"); } public static final class DataSpecificationIec61360 { - public static final Property levelType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/levelType"); - public static final Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/value"); - public static final Property valueFormat = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueFormat"); - public static final Property definition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/definition"); - public static final Property dataType = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/dataType"); - public static final Property symbol = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/symbol"); - public static final Property sourceOfDefinition = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/sourceOfDefinition"); - public static final Property unitId = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unitId"); - public static final Property unit = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/unit"); - public static final Property shortName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/shortName"); - public static final Property preferredName = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/preferredName"); - public static final Property valueList = ResourceFactory.createProperty(AAS_NAMESPACE + "DataSpecificationIec61360/valueList"); + 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 AssetKind { 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 index 736559469..69c8f4450 100644 --- 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 @@ -13,11 +13,11 @@ public interface RDFHandler { /** * Convert to RDF model. This method is side effect free and idempotent. * - * @param element the object that should be converted to an RDF model + * @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. */ - public RDFSerializationResult toModel(T object); + RDFSerializationResult toModel(T object); /** * This method is side effect free and idempotent. @@ -26,5 +26,5 @@ public interface RDFHandler { * @param subjectToParse Root elements that correspond to the object. * @return instance of the object */ - public T fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException; + T fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException; } 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 index efcf1d5b3..981c59f85 100644 --- 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 @@ -5,7 +5,7 @@ public interface RDFPartialHandler { - public void partialToModel(T object, Model model, Resource parentNode); + void partialToModel(T object, Model model, Resource parentNode); - public T partialFromModel(T object, Model model, Resource subjectToParse) throws IncompatibleTypeException; + 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/RDFSerializationResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java index 89523965d..699177f14 100644 --- 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 @@ -3,8 +3,22 @@ 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 a Apache Jena's {@link org.apache.jena.rdf.model.Resource} + * + * @return a Resource in the graph + */ Resource getResource(); } 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 index 629daf2f2..ac7333c40 100644 --- 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 @@ -41,7 +41,7 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { @Override public AdministrativeInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation)) { throw new IncompatibleTypeException("AdministrativeInformation"); } DefaultAdministrativeInformation.Builder builder = new DefaultAdministrativeInformation.Builder(); 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 index 1f1ae995e..58c083ede 100644 --- 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 @@ -21,7 +21,7 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { @Override public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AdministrativeInformation)) { throw new IncompatibleTypeException("AssetAdministrationShell"); } 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 index 96bf75060..201304b3e 100644 --- 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 @@ -29,7 +29,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { model.add(subject, AASNamespace.AssetAdministrationShell.assetInformation, res.getResource()); model.add(res.getModel()); } - if (object.getSubmodels() != null && object.getSubmodels().isEmpty() == false) { + if (object.getSubmodels() != null && !object.getSubmodels().isEmpty()) { int index = 0; for (Reference item : object.getSubmodels()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -54,7 +54,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { @Override public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetAdministrationShell)) { throw new IncompatibleTypeException("AssetAdministrationShell"); } DefaultAssetAdministrationShell.Builder builder = new DefaultAssetAdministrationShell.Builder(); 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 index e49608846..64fbbced4 100644 --- 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 @@ -39,7 +39,7 @@ public RDFSerializationResult toModel(AssetInformation object) { model.add(subject, AASNamespace.AssetInformation.globalAssetId, object.getGlobalAssetId()); } - if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { + if (object.getSpecificAssetIds() != null && !object.getSpecificAssetIds().isEmpty()) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -55,7 +55,7 @@ public RDFSerializationResult toModel(AssetInformation object) { @Override public AssetInformation fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AssetInformation)) { throw new IncompatibleTypeException("AssetInformation"); } DefaultAssetInformation.Builder builder = new DefaultAssetInformation.Builder(); 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 index 5927dcfcb..2bfd7c4b4 100644 --- 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 @@ -25,7 +25,7 @@ public RDFSerializationResult toModel(ConceptDescription object) { Resource conceptDescriptionResource = model.createResource(object.getId()); model.add(conceptDescriptionResource, RDF.type, AASNamespace.Types.ConceptDescription); - if (object.getIsCaseOf() != null && object.getIsCaseOf().isEmpty() == false) { + if (object.getIsCaseOf() != null && !object.getIsCaseOf().isEmpty()) { int index = 0; for (Reference item : object.getIsCaseOf()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); @@ -47,7 +47,7 @@ public RDFSerializationResult toModel(ConceptDescription object) { @Override public ConceptDescription fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ConceptDescription)) { throw new IncompatibleTypeException(); } DefaultConceptDescription.Builder builder = new DefaultConceptDescription.Builder(); 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 index a9d2a3ca4..efa686c95 100644 --- 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 @@ -14,7 +14,7 @@ public class DefaultDataSpecificationContentRDFHandler implements RDFHandler { @Override public RDFSerializationResult toModel(DataSpecificationContent object) { - if (DataSpecificationIec61360.class.isInstance(object)) { + if (object instanceof DataSpecificationIec61360) { return new DefaultDataSpecificationIEC61360RDFHandler().toModel((DataSpecificationIec61360) object); } 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 index ee46feca3..44205388b 100644 --- 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 @@ -22,7 +22,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.DataSpecificationIec61360); - if (object.getPreferredName() != null && object.getPreferredName().isEmpty() == false) { + if (object.getPreferredName() != null && !object.getPreferredName().isEmpty()) { int index = 0; for (LangStringPreferredNameTypeIec61360 langString : object.getPreferredName()) { RDFSerializationResult res = new DefaultLangStringPreferredNameTypeIec61360RDFHandler().toModel(langString); @@ -32,7 +32,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getShortName() != null && object.getShortName().isEmpty() == false) { + if (object.getShortName() != null && !object.getShortName().isEmpty()) { int index = 0; for (LangStringShortNameTypeIec61360 langString : object.getShortName()) { RDFSerializationResult res = new DefaultLangStringShortNameTypeIec61360RDFHandler().toModel(langString); @@ -42,7 +42,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { index++; } } - if (object.getDefinition() != null && object.getDefinition().isEmpty() == false) { + if (object.getDefinition() != null && !object.getDefinition().isEmpty()) { int index = 0; for (LangStringDefinitionTypeIec61360 langString : object.getDefinition()) { RDFSerializationResult res = new DefaultLangStringDefinitionTypeIec61360RDFHandler().toModel(langString); @@ -90,7 +90,7 @@ public RDFSerializationResult toModel(DataSpecificationIec61360 object) { @Override public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.DataSpecificationIec61360)) { throw new IncompatibleTypeException("DataSpecificationIec61360"); } DefaultDataSpecificationIec61360.Builder builder = new DefaultDataSpecificationIec61360.Builder(); 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 index 03417cfc8..010d71f1e 100644 --- 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 @@ -36,7 +36,7 @@ public RDFSerializationResult toModel(EmbeddedDataSpecification object) { @Override public EmbeddedDataSpecification fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.EmbeddedDataSpecification)) { throw new IncompatibleTypeException("EmbeddedDataSpecification"); } DefaultEmbeddedDataSpecification.Builder builder = new DefaultEmbeddedDataSpecification.Builder(); 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 index 11ca61e6b..a30613c46 100644 --- 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 @@ -32,7 +32,7 @@ public RDFSerializationResult toModel(Extension object) { model.add(subject, AASNamespace.Extension.valueType, AASNamespace.DataTypeDefXsd.valueOf(object.getValueType().name())); } - if (object.getRefersTo() != null && object.getRefersTo().isEmpty() == false) { + if (object.getRefersTo() != null && !object.getRefersTo().isEmpty()) { int index = 0; for (Reference reference : object.getRefersTo()) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(reference); @@ -49,7 +49,7 @@ public RDFSerializationResult toModel(Extension object) { @Override public Extension fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Extension)) { throw new IncompatibleTypeException("Extension"); } DefaultExtension.Builder builder = new DefaultExtension.Builder(); 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 index dbcf474b5..b4910e6d9 100644 --- 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 @@ -11,7 +11,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; import org.eclipse.digitaltwin.aas4j.v3.model.Key; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.builder.KeyBuilder; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; public class DefaultKeyRDFHandler implements RDFHandler { @@ -22,21 +21,29 @@ public RDFSerializationResult toModel(Key key) { } Resource subject = model.createResource(); subject.addProperty(RDF.type, AASNamespace.Types.Key); - subject.addProperty(AASNamespace.Key.value, key.getValue()); - subject.addProperty(AASNamespace.Key.type, AASNamespace.KeyTypes.valueOf(key.getType().name())); + 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) { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key)) { throw new IllegalArgumentException("Provided Resource is not a Key"); } - String value = model.getProperty(subjectToParse, AASNamespace.Key.value).getString(); - KeyTypes type = AASNamespace.KeyTypes.fromIRI(model.getProperty(subjectToParse, AASNamespace.Key.type).getResource().getURI()); - KeyBuilder builder = new DefaultKey.Builder(); + 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.type(type) - .value(value) - .build(); + 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 index 024be783d..b4f483b14 100644 --- 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 @@ -19,20 +19,27 @@ public RDFSerializationResult toModel(LangStringNameType object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringNameType); - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType)) { throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); } - - return new DefaultLangStringNameType.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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 index 04e55de72..7c745524d 100644 --- 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 @@ -18,20 +18,27 @@ public RDFSerializationResult toModel(LangStringTextType object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringTextType); - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + if (object.getLanguage() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + } + if (object.getText() != null) { + model.addLiteral(subject, AASNamespace.AbstractLangString.text, 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType)) { throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); } - - return new DefaultLangStringTextType.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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/DefaultPropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultPropertyRDFHandler.java index a6416001f..b1fc18b48 100644 --- 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 @@ -6,7 +6,12 @@ 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 { @@ -17,17 +22,58 @@ public RDFSerializationResult toModel(Property object) { 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) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property)) { throw new IncompatibleTypeException("Property"); } DefaultProperty.Builder builder = new DefaultProperty.Builder(); - - return null; + if (model.contains(subjectToParse, AASNamespace.Property.value)) { + builder.value(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); + builder.valueId(reference); + } + if (model.contains(subjectToParse, AASNamespace.Property.valueType)) { + Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueType).getResource(); + builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + } + Property 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/DefaultQualifierRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultQualifierRDFHandler.java index e4a67a77e..16e860a43 100644 --- 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 @@ -48,7 +48,7 @@ public RDFSerializationResult toModel(Qualifier object) { @Override public Qualifier fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Qualifier)) { throw new IncompatibleTypeException("Qualifier"); } DefaultQualifier.Builder builder = new DefaultQualifier.Builder(); 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 index 946a8a2a7..d2a152450 100644 --- 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 @@ -39,7 +39,7 @@ public RDFSerializationResult toModel(Reference key) { @Override public Reference fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Reference)) { throw new IncompatibleTypeException("Reference"); } String typeString = model.getProperty(subjectToParse, AASNamespace.Reference.type).getResource().getURI(); 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 index d6fe74f18..f4c0308df 100644 --- 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 @@ -28,7 +28,7 @@ public RDFSerializationResult toModel(Resource object) { @Override public Resource fromModel(Model model, org.apache.jena.rdf.model.Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.Resource) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Resource)) { throw new IncompatibleTypeException("Resource"); } DefaultResource.Builder builder = new DefaultResource.Builder(); 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 index 036ef08d8..835d0b3e5 100644 --- 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 @@ -38,7 +38,7 @@ public RDFSerializationResult toModel(SpecificAssetId object) { @Override public SpecificAssetId fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { - if (model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId) == false) { + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SpecificAssetId)) { throw new IncompatibleTypeException("SpecificAssetId"); } DefaultSpecificAssetId.Builder builder = new DefaultSpecificAssetId.Builder(); 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 index ce839c9ea..1d6dce76f 100644 --- 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 @@ -14,46 +14,46 @@ public class DefaultSubmodelElementRDFHandler implements RDFHandler { @Override public void partialToModel(HasDataSpecification object, Model model, Resource parentNode) { - if (object.getEmbeddedDataSpecifications() != null && object.getEmbeddedDataSpecifications().isEmpty() == false) { + if (object.getEmbeddedDataSpecifications() != null && !object.getEmbeddedDataSpecifications().isEmpty()) { int index = 0; for (EmbeddedDataSpecification item : object.getEmbeddedDataSpecifications()) { RDFSerializationResult resultItem = new DefaultEmbeddedDataSpecificationRDFHandler().toModel(item); 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 index 793b1dd1b..8a0ee2a98 100644 --- 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 @@ -25,7 +25,7 @@ public void partialToModel(HasSemantics object, Model model, Resource parentNode model.add(parentNode, AASNamespace.HasSemantics.semanticId, res.getResource()); model.add(res.getModel()); } - if (object.getSupplementalSemanticIds() != null && object.getSupplementalSemanticIds().isEmpty() == false) { + if (object.getSupplementalSemanticIds() != null && !object.getSupplementalSemanticIds().isEmpty()) { int index = 0; for (Reference item : object.getSupplementalSemanticIds()) { RDFSerializationResult resultItem = new DefaultReferenceRDFHandler().toModel(item); 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..a4644169f --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/partial/DefaultQualifiableRDFPartialHandler.java @@ -0,0 +1,58 @@ +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); + }); + List langStringList = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + langStringList.add(keysMap.get(index)); + } + object.setQualifiers(langStringList); + } + 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 index 204ffaa14..92809acc0 100644 --- 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 @@ -31,7 +31,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { if (object.getCategory() != null) { parentNode.addProperty(AASNamespace.Referable.category, object.getCategory()); } - if (object.getDescription() != null && object.getDescription().isEmpty() == false) { + if (object.getDescription() != null && !object.getDescription().isEmpty()) { int index = 0; for (LangStringTextType item : object.getDescription()) { RDFSerializationResult resultItem = new DefaultLangStringTextTypeRDFHandler().toModel(item); @@ -42,7 +42,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { index = index + 1; } } - if (object.getDisplayName() != null && object.getDescription().isEmpty() == false) { + if (object.getDisplayName() != null && !object.getDescription().isEmpty()) { int index = 0; for (LangStringNameType item : object.getDisplayName()) { RDFSerializationResult resultItem = new DefaultLangStringNameTypeRDFHandler().toModel(item); @@ -54,7 +54,7 @@ public void partialToModel(Referable object, Model model, Resource parentNode) { } } //HasExtension - if (object.getExtensions() != null && object.getExtensions().isEmpty() == false) { + if (object.getExtensions() != null && !object.getExtensions().isEmpty()) { int index = 0; for (Extension item : object.getExtensions()) { RDFSerializationResult resultItem = new DefaultExtensionRDFHandler().toModel(item); 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 index 7aef2be01..6fa75238f 100644 --- 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 @@ -250,6 +250,23 @@ static Property getMinimalProperty() { .build(); } + 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 Extension getMiniamlExtension() { return new DefaultExtension.Builder() .name("extension2") 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 index ed15a4811..ba13ad251 100644 --- 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 @@ -21,5 +21,17 @@ public void testMinimalProperty() throws IncompatibleTypeException { assert object.equals(recreatedObject); } + @Test + public void testMaximalProperty() throws IncompatibleTypeException { + Property object = SerializerUtil.getMaximalProperty(); + RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(recreatedObject); + } + } From 733180ac9e7b7df6af9af4b5675773e6ff06f319 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 00:31:52 +0100 Subject: [PATCH 137/160] Add test cases for SubmodelElements --- .../v3/dataformat/rdf/SerializerUtil.java | 124 +++++++++++++++++- .../dataformat/rdf/SubmodelElementTest.java | 54 ++++++++ .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 37 ------ 3 files changed, 177 insertions(+), 38 deletions(-) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java delete mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java 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 index 6fa75238f..5a457ecb2 100644 --- 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 @@ -263,7 +263,129 @@ static Property getMaximalProperty() { .extensions(getMaximalExtension()) .supplementalSemanticIds(getIsCaseOfs()) .semanticId(getMinimalReference()) - .qualifiers(List.of(getMaximalQualifier(),getMinimalQualifier())) + .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 BasicEventElement getMinimalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .observed(getMinimalReference()) + .build(); + } + + static Blob getMinimalBlob() { + return new DefaultBlob.Builder() + .idShort("B1") + .contentType("image/png") + .build(); + } + + static Capability getMinimalCapability() { + return new DefaultCapability.Builder() + .idShort("C1") + .build(); + } + + static Entity getMinimalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .build(); + } + + static File getMinimalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + + static Range getMinimalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + + static ReferenceElement getMinimalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .build(); + } + + static RelationshipElement getMinimalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .build(); + } + + static SubmodelElementCollection getMinimalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("SEC1") + .build(); + } + + static SubmodelElementList getMinimalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .build(); + } + + static Operation getMinimalOperation() { + return new DefaultOperation.Builder() + .idShort("O1") + .build(); + } + + static MultiLanguageProperty getMinimalMultiLanguageProperty() { + return new DefaultMultiLanguageProperty.Builder() + .idShort("mlp1") .build(); } 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..e8e24b94a --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelElementTest.java @@ -0,0 +1,54 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; + +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +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.DefaultSubmodelElementRDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Parameterized.class) +public class SubmodelElementTest { + @Parameter + public SubmodelElement submodelElement; + + @Parameters(name = "{index}: SME - {0}") + public static Object[] data() { + return new Object[]{ + 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.getMaximalMultiLanguageProperty() + }; + } + + @Test + public void testGeneric() throws IncompatibleTypeException { + SubmodelElement object = submodelElement; + RDFSerializationResult rdfSerializationResult = new DefaultSubmodelElementRDFHandler().toModel(object); + rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); + Resource createdResource = rdfSerializationResult.getResource(); + assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); + + SubmodelElement submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); + assert object.equals(submodelElement); + + } + + +} 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 deleted file mode 100644 index ba13ad251..000000000 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java +++ /dev/null @@ -1,37 +0,0 @@ -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.rdf.handlers.DefaultPropertyRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.model.Property; -import org.junit.Test; - -public class SubmodelTest { - - @Test - public void testMinimalProperty() throws IncompatibleTypeException { - Property object = SerializerUtil.getMinimalProperty(); - RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); - rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - - Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); - } - - @Test - public void testMaximalProperty() throws IncompatibleTypeException { - Property object = SerializerUtil.getMaximalProperty(); - RDFSerializationResult rdfSerializationResult = new DefaultPropertyRDFHandler().toModel(object); - rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - - Property recreatedObject = new DefaultPropertyRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); - } - - -} From f4fcd4ff3904fbea058e7497bbf489430b809c5b Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 02:12:44 +0100 Subject: [PATCH 138/160] Add Blob --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 +++ .../rdf/handlers/DefaultBlobRDFHandler.java | 53 +++++++++++++++++-- .../v3/dataformat/rdf/SerializerTest.java | 6 +-- .../v3/dataformat/rdf/SerializerUtil.java | 4 +- .../dataformat/rdf/SubmodelElementTest.java | 10 ++-- 5 files changed, 62 insertions(+), 18 deletions(-) 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 index 3bf92b79a..ce58cd114 100644 --- 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 @@ -340,6 +340,13 @@ public static final class Property { ResourceFactory.createProperty(AAS_NAMESPACE + "Property/valueType"); } + 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 AssetAdministrationShell { public static final org.apache.jena.rdf.model.Property assetInformation = ResourceFactory.createProperty(AAS_NAMESPACE + "AssetAdministrationShell/assetInformation"); 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 index a5888e465..4dc157d6f 100644 --- 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 @@ -1,14 +1,20 @@ 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.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -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.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 @@ -18,11 +24,48 @@ public RDFSerializationResult toModel(Blob object) { 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 { - return null; + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 1f6cc12bb..7bf75e1d9 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -12,14 +12,10 @@ import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; public class SerializerTest { - @Test public void testKey() throws IOException { Key simpleKey = new DefaultKey.Builder() 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 index 5a457ecb2..42284d6aa 100644 --- 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 @@ -5,6 +5,7 @@ import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; import java.util.Arrays; +import java.util.Base64; import java.util.List; @@ -322,7 +323,8 @@ static BasicEventElement getMinimalBasicEventElement() { static Blob getMinimalBlob() { return new DefaultBlob.Builder() .idShort("B1") - .contentType("image/png") + .value(Base64.getDecoder().decode("aGVsbG8=")) // a `hello` in a text file + .contentType("plain/text") .build(); } 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 index e8e24b94a..1b124e9cf 100644 --- 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 @@ -1,15 +1,14 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; 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.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; @RunWith(Parameterized.class) public class SubmodelElementTest { @@ -43,11 +42,8 @@ public void testGeneric() throws IncompatibleTypeException { RDFSerializationResult rdfSerializationResult = new DefaultSubmodelElementRDFHandler().toModel(object); rdfSerializationResult.getModel().write(System.out, Lang.TTL.getName()); Resource createdResource = rdfSerializationResult.getResource(); - assert rdfSerializationResult.getModel().contains(createdResource, RDF.type, AASNamespace.Types.Property); - SubmodelElement submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); assert object.equals(submodelElement); - } From 77ae421299ffc848844fe5f766e6c00e6edc57bb Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 10:08:55 +0100 Subject: [PATCH 139/160] Add MultiLanguageProperty --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 ++ ...efaultMultiLanguagePropertyRDFHandler.java | 93 +++++++++++++++++-- 2 files changed, 93 insertions(+), 7 deletions(-) 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 index ce58cd114..dcfadd6f6 100644 --- 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 @@ -340,6 +340,13 @@ public static final class Property { 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 9f3d55f79..3ccccb5eb 100644 --- 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 @@ -1,20 +1,99 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; -import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.*; import org.apache.jena.rdf.model.Resource; -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.MultiLanguageProperty; +import org.apache.jena.vocabulary.RDF; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringShortNameTypeIec61360RDFHandler; +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.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultMultiLanguageProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; + +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) { - return null; + 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 { - return null; + 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.Property.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; } } From 164fa8532fe5ffb271e6fa49ca4cf50aedb89516 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:02:15 +0100 Subject: [PATCH 140/160] Add Range --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 9 +++ ...efaultMultiLanguagePropertyRDFHandler.java | 8 +-- .../rdf/handlers/DefaultRangeRDFHandler.java | 63 +++++++++++++++++-- .../v3/dataformat/rdf/SerializerTest.java | 5 +- 4 files changed, 74 insertions(+), 11 deletions(-) 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 index dcfadd6f6..d6d0cfa19 100644 --- 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 @@ -347,6 +347,15 @@ public static final class MultiLanguageProperty { ResourceFactory.createProperty(AAS_NAMESPACE + "MultiLanguageProperty/valueId"); } + 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 3ccccb5eb..62b20c348 100644 --- 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 @@ -1,18 +1,16 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers; import org.apache.jena.rdf.model.*; -import org.apache.jena.rdf.model.Resource; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringPreferredNameTypeIec61360RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.dataspecificationiec61360.DefaultLangStringShortNameTypeIec61360RDFHandler; 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.*; +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 org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; import java.util.ArrayList; import java.util.HashMap; 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 index 9a3395c14..e2c0ec2e0 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 7bf75e1d9..5f07d26fb 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -12,7 +12,10 @@ import org.junit.Test; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class SerializerTest { From f197a3bdc3c328200a73dbfbadc656c889746878 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:17:49 +0100 Subject: [PATCH 141/160] Add ReferenceElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 5 ++ .../DefaultReferenceElementRDFHandler.java | 55 +++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) 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 index d6d0cfa19..4e228c0bb 100644 --- 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 @@ -356,6 +356,11 @@ public static final class Range { 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 Blob { public static final org.apache.jena.rdf.model.Property value = ResourceFactory.createProperty(AAS_NAMESPACE + "Blob/value"); 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 index 4be19ea9a..4726edda2 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From e89a5892a43edec4d879f558074c29b00c99d42f Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:31:47 +0100 Subject: [PATCH 142/160] Add Capability --- .../handlers/DefaultCapabilityRDFHandler.java | 44 ++++++++++++++++--- ...efaultMultiLanguagePropertyRDFHandler.java | 2 +- 2 files changed, 40 insertions(+), 6 deletions(-) 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 index d4db934ee..f9791b6ff 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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/DefaultMultiLanguagePropertyRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultMultiLanguagePropertyRDFHandler.java index 62b20c348..b9d8fe0e0 100644 --- 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 @@ -79,7 +79,7 @@ public MultiLanguageProperty fromModel(Model model, Resource subjectToParse) thr builder.value(langStringList); } if (model.contains(subjectToParse, AASNamespace.MultiLanguageProperty.valueId)) { - Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueId).getResource(); + Resource resource = model.getProperty(subjectToParse, AASNamespace.MultiLanguageProperty.valueId).getResource(); Reference reference = new DefaultReferenceRDFHandler().fromModel(model, resource); builder.valueId(reference); } From 21b349e845ab81e952868a749c1b8644be233d9f Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 14:36:25 +0100 Subject: [PATCH 143/160] Add File --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 7 +++ .../rdf/handlers/DefaultFileRDFHandler.java | 56 +++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) 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 index 4e228c0bb..9b92e1b3b 100644 --- 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 @@ -361,6 +361,13 @@ public static final class ReferenceElement { ResourceFactory.createProperty(AAS_NAMESPACE + "ReferenceElement/value"); } + 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"); 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 index e3d88eecb..e1343dfaa 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From 1576f024333bd98c2720bd53fb7d56179b8598f4 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 16:29:36 +0100 Subject: [PATCH 144/160] Add AnnotatedRelationshipElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 220 +++++++++++++++++- ...nnotatedRelationshipElementRDFHandler.java | 96 +++++++- 2 files changed, 307 insertions(+), 9 deletions(-) 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 index 9b92e1b3b..b35b2e3fd 100644 --- 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 @@ -112,13 +112,76 @@ public static final class KeyTypes { 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; } - throw new IllegalArgumentException("Invalid ReferenceType IRI provided."); + 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) { @@ -131,8 +194,77 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { 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 ReferenceType provided."); + throw new IllegalArgumentException("Invalid KeyTypes provided."); } } @@ -331,6 +463,18 @@ public static final class SpecificAssetId { 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"); @@ -361,6 +505,21 @@ public static final class ReferenceElement { ResourceFactory.createProperty(AAS_NAMESPACE + "ReferenceElement/value"); } + 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 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"); @@ -457,6 +616,63 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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"); 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 index 58c083ede..e6f29a0f4 100644 --- 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 @@ -1,12 +1,21 @@ 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.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 @@ -16,15 +25,88 @@ public RDFSerializationResult toModel(AnnotatedRelationshipElement object) { 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.AdministrativeInformation)) { - throw new IncompatibleTypeException("AssetAdministrationShell"); + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.AnnotatedRelationshipElement)) { + throw new IncompatibleTypeException("AnnotatedRelationshipElement"); } + DefaultAnnotatedRelationshipElement.Builder builder = new DefaultAnnotatedRelationshipElement.Builder(); - return null; + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.annotations(references); + } + //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; } } From 35c7062ec3bfe1c480a9f5a91fbf714af5955446 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 17:39:29 +0100 Subject: [PATCH 145/160] Add BasicEventElement --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 20 ++++ .../DefaultBasicEventElementRDFHandler.java | 104 +++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) 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 index b35b2e3fd..3d36d1b19 100644 --- 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 @@ -510,6 +510,26 @@ public static final class OperationVariable { ResourceFactory.createProperty(AAS_NAMESPACE + "OperationVariable/value"); } + 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 = 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 index cf56a05cf..39b1cc5da 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + 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; } } From fe6b56945ad6ee493bfeaba80324721fc99c0feb Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:06:08 +0100 Subject: [PATCH 146/160] Add RelationshipElement --- .../DefaultRelationshipElementRDFHandler.java | 64 +++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) 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 index 4d5213f44..1876f1c48 100644 --- 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 @@ -1,20 +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.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.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) { - return null; + 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 { - return null; + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.RelationshipElement)) { + throw new IncompatibleTypeException("Capability"); + } + 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; } } From 3a4999f2e8d6d96d946e9fab44f27cb19eac19e5 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:33:22 +0100 Subject: [PATCH 147/160] Add Entity --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 40 ++++++ .../rdf/handlers/DefaultEntityRDFHandler.java | 124 +++++++++++++++++- 2 files changed, 157 insertions(+), 7 deletions(-) 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 index 3d36d1b19..287147bef 100644 --- 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 @@ -505,6 +505,18 @@ public static final class ReferenceElement { 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"); @@ -636,6 +648,34 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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"); 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 index b77a3ea74..198e3b8a8 100644 --- 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 @@ -1,20 +1,130 @@ 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.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.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) { - return null; + 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()) { + 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 { - return null; + 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()); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + }); + 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()); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } + int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); + keysMap.put(index, key); + }); + 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; } } From 69bb9321e0e4c9894baabd42670e3dcafd6d6fd0 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:52:01 +0100 Subject: [PATCH 148/160] Add Operation --- .../handlers/DefaultOperationRDFHandler.java | 140 +++++++++++++++++- .../DefaultOperationVariableRDFHandler.java | 43 ++++++ .../DefaultRelationshipElementRDFHandler.java | 2 +- 3 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultOperationVariableRDFHandler.java 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 index 36b71d462..80b9d978e 100644 --- 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 @@ -1,20 +1,146 @@ 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.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.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) { - return null; + 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.getOutputVariables()) { + 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.getOutputVariables()) { + 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 { - return null; + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.inoutputVariables(references); + } + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.inputVariables(references); + } + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.outputVariables(references); + } + 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/DefaultRelationshipElementRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultRelationshipElementRDFHandler.java index 1876f1c48..d722f40e7 100644 --- 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 @@ -47,7 +47,7 @@ public RDFSerializationResult toModel(RelationshipElement object) { @Override public RelationshipElement fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.RelationshipElement)) { - throw new IncompatibleTypeException("Capability"); + throw new IncompatibleTypeException("RelationshipElement"); } DefaultRelationshipElement.Builder builder = new DefaultRelationshipElement.Builder(); if (model.contains(subjectToParse, AASNamespace.RelationshipElement.second)) { From 5a8976d9e509da266a40c3a5e0e8bb8ffe2293d3 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 18:58:10 +0100 Subject: [PATCH 149/160] Add SubmodelElementCollection --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 5 ++ ...ltSubmodelElementCollectionRDFHandler.java | 83 +++++++++++++++++-- 2 files changed, 81 insertions(+), 7 deletions(-) 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 index 287147bef..16707c022 100644 --- 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 @@ -565,6 +565,11 @@ public static final class Blob { 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 AssetAdministrationShell { public static final org.apache.jena.rdf.model.Property assetInformation = 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 index d43abc395..c6f15ac58 100644 --- 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 @@ -1,20 +1,89 @@ 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.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.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.Capability; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultCapability; +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) { - return null; + 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 { - return null; + 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.ConceptDescription.isCaseOf); + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.value(references); + } + 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; } } From 71ee435b08594982d1529fb1e752824a2a8aafe2 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 19:24:10 +0100 Subject: [PATCH 150/160] Add SubmodelElementList --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 165 ++++++++++++++++++ ...ltSubmodelElementCollectionRDFHandler.java | 7 +- .../DefaultSubmodelElementListRDFHandler.java | 120 ++++++++++++- 3 files changed, 280 insertions(+), 12 deletions(-) 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 index 16707c022..a8e82dbf8 100644 --- 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 @@ -268,6 +268,156 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } } + 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.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"); @@ -565,12 +715,27 @@ public static final class Blob { 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"); 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 index c6f15ac58..3f55115d1 100644 --- 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 @@ -7,11 +7,8 @@ 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.Reference; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultCapability; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection; import java.util.ArrayList; @@ -28,7 +25,7 @@ public RDFSerializationResult toModel(SubmodelElementCollection object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.SubmodelElementCollection); - if(object.getValue()!=null && object.getValue().isEmpty()==false){ + if (object.getValue() != null && object.getValue().isEmpty() == false) { int index = 0; for (SubmodelElement item : object.getValue()) { RDFSerializationResult resultItem = new DefaultSubmodelElementRDFHandler().toModel(item); @@ -56,7 +53,7 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) throw new IncompatibleTypeException("SubmodelElementCollection"); } DefaultSubmodelElementCollection.Builder builder = new DefaultSubmodelElementCollection.Builder(); - if(model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)){ + if (model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { 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 index 0efd20430..8a15da7a5 100644 --- 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 @@ -1,22 +1,128 @@ 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.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.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) { - return null; + 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 { - return null; + if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.SubmodelElementList)) { + throw new IncompatibleTypeException("SubmodelElementList"); + } + DefaultSubmodelElementList.Builder builder = new DefaultSubmodelElementList.Builder(); + builder.orderRelevant(false); + 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.orderRelevant)) { + builder.orderRelevant(model.getProperty(subjectToParse, + AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); + } + if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.value)) { + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + 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); + }); + List references = new ArrayList<>(); + for (int index = 0; index < keysMap.keySet().size(); index++) { + references.add(keysMap.get(index)); + } + builder.value(references); + } + 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; } } From 099bd58dddc1a7b0c433273064d281d252df05db Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Wed, 7 Feb 2024 20:18:00 +0100 Subject: [PATCH 151/160] Add Submodel and Environment --- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 48 +++++++++ .../v3/dataformat/rdf/RDFSerializer.java | 6 +- ...ultAssetAdministrationShellRDFHandler.java | 2 +- .../DefaultEnvironmentRDFHandler.java | 97 +++++++++++++++++++ .../handlers/DefaultSubmodelRDFHandler.java | 95 ++++++++++++++++++ .../v3/dataformat/rdf/SerializerTest.java | 48 ++++++++- 6 files changed, 289 insertions(+), 7 deletions(-) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEnvironmentRDFHandler.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java 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 index a8e82dbf8..c673bfde5 100644 --- 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 @@ -446,6 +446,7 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } 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"); @@ -641,6 +642,11 @@ public static final class MultiLanguageProperty { 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"); @@ -672,6 +678,15 @@ public static final class OperationVariable { 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"); @@ -767,6 +782,12 @@ public static final class Resource { 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"); @@ -782,6 +803,33 @@ public static final class DataSpecificationIec61360 { 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"); 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 index 328b0d1ea..55f4e4fb7 100644 --- 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 @@ -4,6 +4,7 @@ import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultEnvironmentRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; @@ -25,7 +26,10 @@ public class RDFSerializer { */ public String write(Environment aasEnvironment, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + 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); } 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 index 201304b3e..aeea4b0e7 100644 --- 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 @@ -22,7 +22,7 @@ public RDFSerializationResult toModel(AssetAdministrationShell object) { if (object == null) { return new DefaultRDFHandlerResult(model, ResourceFactory.createResource()); } - Resource subject = model.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()); 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/DefaultSubmodelRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java new file mode 100644 index 000000000..ab4b05448 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultSubmodelRDFHandler.java @@ -0,0 +1,95 @@ +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); + }); + 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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 5f07d26fb..728876fab 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -148,11 +148,49 @@ public void testMaximalQualifier() throws IncompatibleTypeException { @Test public void serializeEnvironmentSmokeTest() throws IOException, DeserializationException, SerializationException { - AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder().assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).description(Arrays.asList(new DefaultLangStringTextType.Builder().text("This is a test AAS").language("en-us").build())).displayName(Arrays.asList(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().description(Arrays.asList(new DefaultLangStringTextType.Builder().text("My Submodel").language("en-us").build())).displayName(Arrays.asList(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().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(); + AssetAdministrationShell aas = new DefaultAssetAdministrationShell.Builder() + .id("test") + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .build()) + .description( + Arrays.asList( + new DefaultLangStringTextType.Builder() + .text("This is a test AAS") + .language("en-us").build())) + .displayName(Arrays.asList(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( + Arrays.asList(new DefaultLangStringTextType.Builder() + .text("My Submodel") + .language("en-us") + .build())) + .displayName(Arrays.asList(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(); From 2439e61a993162223664bfb249631f712a19f3a4 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 8 Feb 2024 13:35:06 +0100 Subject: [PATCH 152/160] Improve tests --- .../v3/dataformat/rdf/SerializerUtil.java | 140 +++++++++++++++++- .../dataformat/rdf/SubmodelElementTest.java | 24 +-- 2 files changed, 146 insertions(+), 18 deletions(-) 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 index 42284d6aa..14fcb24a7 100644 --- 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 @@ -251,6 +251,44 @@ static Property getMinimalProperty() { .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() + ); + } + static Property getMaximalProperty() { return new DefaultProperty.Builder() .idShort("idShort1") @@ -311,6 +349,32 @@ static AnnotatedRelationshipElement getMinimalAnnotatedRelationshipElement() { .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") @@ -320,6 +384,15 @@ static BasicEventElement getMinimalBasicEventElement() { .build(); } + static BasicEventElement getMaximalBasicEventElement() { + return new DefaultBasicEventElement.Builder() + .idShort("BEE1") + .direction(Direction.OUTPUT) + .state(StateOfEvent.OFF) + .observed(getMinimalReference()) + .build(); + } + static Blob getMinimalBlob() { return new DefaultBlob.Builder() .idShort("B1") @@ -328,12 +401,26 @@ static Blob getMinimalBlob() { .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") @@ -341,6 +428,13 @@ static Entity getMinimalEntity() { .build(); } + static Entity getMaximalEntity() { + return new DefaultEntity.Builder() + .idShort("E1") + .entityType(EntityType.SELF_MANAGED_ENTITY) + .build(); + } + static File getMinimalFile() { return new DefaultFile.Builder() .idShort("F1") @@ -348,6 +442,13 @@ static File getMinimalFile() { .build(); } + static File getMaximalFile() { + return new DefaultFile.Builder() + .idShort("F1") + .contentType("image/png") + .build(); + } + static Range getMinimalRange() { return new DefaultRange.Builder() .idShort("R1") @@ -355,36 +456,73 @@ static Range getMinimalRange() { .build(); } + static Range getMaximalRange() { + return new DefaultRange.Builder() + .idShort("R1") + .valueType(DataTypeDefXsd.DECIMAL) + .build(); + } + static ReferenceElement getMinimalReferenceElement() { return new DefaultReferenceElement.Builder() .idShort("RE1") .build(); } + static ReferenceElement getMaximalReferenceElement() { + return new DefaultReferenceElement.Builder() + .idShort("RE1") + .build(); + } + static RelationshipElement getMinimalRelationshipElement() { return new DefaultRelationshipElement.Builder() .idShort("ReE1") .build(); } + static RelationshipElement getMaximalRelationshipElement() { + return new DefaultRelationshipElement.Builder() + .idShort("ReE1") + .build(); + } + static SubmodelElementCollection getMinimalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() .idShort("SEC1") .build(); } + static SubmodelElementCollection getMaximalSubmodelElementCollection() { + return new DefaultSubmodelElementCollection.Builder() + .idShort("SEC1") + .build(); + } + static SubmodelElementList getMinimalSubmodelElementList() { return new DefaultSubmodelElementList.Builder() .idShort("SEL1") .build(); } + static SubmodelElementList getMaximalSubmodelElementList() { + return new DefaultSubmodelElementList.Builder() + .idShort("SEL1") + .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") @@ -428,7 +566,7 @@ static AssetInformation getMaximalAssetInformation() { static AssetAdministrationShell getMinimalAssetAdministrationShell() { return new DefaultAssetAdministrationShell.Builder() .assetInformation(getMinimalAssetInformation()) - .id("id1") + .id("AssetAdministrationShell_minimal") .build(); } 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 index 1b124e9cf..559f5978a 100644 --- 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 @@ -10,6 +10,9 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import java.util.LinkedList; +import java.util.List; + @RunWith(Parameterized.class) public class SubmodelElementTest { @Parameter @@ -17,23 +20,10 @@ public class SubmodelElementTest { @Parameters(name = "{index}: SME - {0}") public static Object[] data() { - return new Object[]{ - 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.getMaximalMultiLanguageProperty() - }; + List list = new LinkedList<>(); + list.addAll(SerializerUtil.getMaximalSubmodelElementsList()); + list.addAll(SerializerUtil.getMinimalSubmodelElementsList()); + return list.toArray(); } @Test From ea8f6c4bdfcaa346e660ae3e320a89107fc779e3 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 8 Feb 2024 13:46:18 +0100 Subject: [PATCH 153/160] Update maven --- dataformat-rdf/pom.xml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index 93a8d4061..aa42713c8 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -5,22 +5,20 @@ 4.0.0 org.eclipse.digitaltwin.aas4j - dataformat-parent + aas4j-dataformat-parent ${revision} - dataformat-rdf + aas4j-dataformat-rdf Asset Administration Shell RDF-Serializer - ${groupId} - dataformat-core - ${revision} + ${project.groupId} + aas4j-dataformat-core - ${groupId} - dataformat-core - ${revision} + ${project.groupId} + aas4j-dataformat-core tests test From 483275010ea601e1e3e8b59999e87e661d27c1c1 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Sat, 10 Feb 2024 12:16:06 +0100 Subject: [PATCH 154/160] Fix Operation --- .../v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java | 2 ++ .../digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java | 2 ++ 4 files changed, 8 insertions(+) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java 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..4a9274ef5 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferableRDFHandler.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;public class DefaultReferableRDFHandler { +} 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..c79fa2be3 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/EnvironmentTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class EnvironemntTest { +} 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..1f0cf68a5 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SubmodelTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SubmodelTest { +} diff --git a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java new file mode 100644 index 000000000..7bf4c32e8 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class TestCustomClass { +} From 91c977549fee2f4a6cbb252d3fca841f385e1dd9 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Sat, 10 Feb 2024 14:36:30 +0100 Subject: [PATCH 155/160] Fix tests --- .../v3/dataformat/core/CustomProperty.java | 15 +- .../aas4j/v3/dataformat/rdf/AASNamespace.java | 30 +++- ...nnotatedRelationshipElementRDFHandler.java | 10 +- ...ultAssetAdministrationShellRDFHandler.java | 10 +- .../DefaultAssetInformationRDFHandler.java | 10 +- .../DefaultConceptDescriptionRDFHandler.java | 10 +- ...ultDataSpecificationContentRDFHandler.java | 4 +- ...ltDataSpecificationIEC61360RDFHandler.java | 37 +++-- .../rdf/handlers/DefaultEntityRDFHandler.java | 30 ++-- .../handlers/DefaultExtensionRDFHandler.java | 10 +- .../rdf/handlers/DefaultKeyRDFHandler.java | 9 +- .../DefaultLangStringNameTypeRDFHandler.java | 2 +- .../DefaultLangStringTextTypeRDFHandler.java | 2 +- .../handlers/DefaultOperationRDFHandler.java | 34 +++-- .../handlers/DefaultPropertyRDFHandler.java | 10 +- .../handlers/DefaultReferableRDFHandler.java | 53 ++++++- .../handlers/DefaultReferenceRDFHandler.java | 7 +- ...ltSubmodelElementCollectionRDFHandler.java | 12 +- .../DefaultSubmodelElementListRDFHandler.java | 18 +-- .../DefaultSubmodelElementRDFHandler.java | 2 +- .../handlers/DefaultSubmodelRDFHandler.java | 10 +- ...tringDefinitionTypeIec61360RDFHandler.java | 2 +- ...StringShortNameTypeIec61360RDFHandler.java | 15 +- .../DefaultLevelTypeRDFHandler.java | 22 ++- .../DefaultValueListRDFHandler.java | 55 ++++--- ...HasDataSpecificationRDFPartialHandler.java | 15 +- .../DefaultHasSemanticsRDFPartialHandler.java | 10 +- .../DefaultQualifiableRDFPartialHandler.java | 10 +- .../DefaultReferableRDFPartialHandler.java | 30 ++-- .../rdf/AssetAdministrationShellTest.java | 95 ++++-------- .../rdf/ConceptDescriptionTest.java | 60 ++++---- .../rdf/DataSpecificationIec61360Test.java | 1 - .../v3/dataformat/rdf/EnvironmentTest.java | 52 ++++++- .../v3/dataformat/rdf/SerializerTest.java | 78 +++++++++- .../v3/dataformat/rdf/SerializerUtil.java | 143 +++++++++++++----- .../dataformat/rdf/SubmodelElementTest.java | 8 +- .../aas4j/v3/dataformat/rdf/SubmodelTest.java | 68 ++++++++- .../v3/dataformat/rdf/TestCustomClass.java | 29 +++- 38 files changed, 695 insertions(+), 323 deletions(-) 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-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 index c673bfde5..8ebe2468d 100644 --- 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 @@ -2,6 +2,8 @@ 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. */ @@ -360,9 +362,7 @@ public static org.eclipse.digitaltwin.aas4j.v3.model.AasSubmodelElements fromIRI } 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.ANNOTATED_RELATIONSHIP_ELEMENT.name())) { return AnnotatedRelationshipElement; } @@ -416,6 +416,8 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } throw new IllegalArgumentException("Invalid AasSubmodelElements provided."); } + + } public static final class ReferenceTypes { @@ -446,7 +448,10 @@ public static org.apache.jena.rdf.model.Resource valueOf(String type) { } 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 Environment = + ResourceFactory.createResource(AAS_NAMESPACE + "Environment"); public static final org.apache.jena.rdf.model.Resource AdministrativeInformation = ResourceFactory.createResource(AAS_NAMESPACE + "AdministrativeInformation"); @@ -522,6 +527,23 @@ public static final class Types { 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 { 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 index e6f29a0f4..a4b854983 100644 --- 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 @@ -81,11 +81,13 @@ public AnnotatedRelationshipElement fromModel(Model model, Resource subjectToPar int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.annotations(references); } //RelationshipElement if (model.contains(subjectToParse, AASNamespace.RelationshipElement.first)) { 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 index aeea4b0e7..425858d0f 100644 --- 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 @@ -76,11 +76,13 @@ public AssetAdministrationShell fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.submodels(langStringList); } if (model.contains(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.AssetAdministrationShell.derivedFrom).getResource(); 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 index 64fbbced4..e9ee94179 100644 --- 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 @@ -90,11 +90,13 @@ public AssetInformation fromModel(Model model, Resource subjectToParse) throws I int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List specificAssetIds = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - specificAssetIds.add(keysMap.get(index)); + 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); } - builder.specificAssetIds(specificAssetIds); } return builder.build(); } 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 index 2bfd7c4b4..feac5988b 100644 --- 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 @@ -65,11 +65,13 @@ public ConceptDescription fromModel(Model model, Resource subjectToParse) throws int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.isCaseOf(references); } ConceptDescription object = builder.build(); //Identifiable 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 index efa686c95..8d3b497e8 100644 --- 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 @@ -20,7 +20,7 @@ public RDFSerializationResult toModel(DataSpecificationContent object) { throw new IllegalArgumentException("Provided object " + object.getClass() + - " is not a known type"); + " is not a known DataSpecificationContent"); } @Override @@ -32,6 +32,6 @@ public DataSpecificationContent fromModel(Model model, Resource subjectToParse) //Other data specification content should be discriminated here. throw new IllegalArgumentException("Provided Resource " + typeStatement.getResource().getURI() + - " is not a SubmodelElement"); + " 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 index 44205388b..5058e05e9 100644 --- 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 @@ -102,17 +102,20 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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); } - 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)); + 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); } - builder.preferredName(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.shortName); @@ -127,11 +130,13 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.shortName(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.definition)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.definition); @@ -146,11 +151,13 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) 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)); + 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); } - builder.definition(langStringList); } if (model.contains(subjectToParse, AASNamespace.DataSpecificationIec61360.unit)) { builder.unit(model.getProperty(subjectToParse, AASNamespace.DataSpecificationIec61360.unit).getString()); @@ -190,8 +197,6 @@ public DataSpecificationIec61360 fromModel(Model model, Resource subjectToParse) .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/DefaultEntityRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultEntityRDFHandler.java index 198e3b8a8..850426423 100644 --- 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 @@ -43,7 +43,7 @@ public RDFSerializationResult toModel(Entity object) { if (object.getGlobalAssetId() != null) { model.add(subject, AASNamespace.Entity.globalAssetId, object.getGlobalAssetId()); } - if (object.getSpecificAssetIds() != null && !object.getSpecificAssetIds().isEmpty()) { + if (object.getSpecificAssetIds() != null && object.getSpecificAssetIds().isEmpty() == false) { int index = 0; for (SpecificAssetId item : object.getSpecificAssetIds()) { RDFSerializationResult resultItem = new DefaultSpecificAssetIdRDFHandler().toModel(item); @@ -78,17 +78,19 @@ public Entity fromModel(Model model, Resource subjectToParse) throws Incompatibl 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); }); - List submodelElements = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - submodelElements.add(keysMap.get(index)); + 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); } - builder.statements(submodelElements); } if (model.contains(subjectToParse, AASNamespace.Entity.globalAssetId)) { builder.globalAssetId(model.getProperty(subjectToParse, AASNamespace.Entity.globalAssetId).getString()); @@ -104,17 +106,19 @@ public Entity fromModel(Model model, Resource subjectToParse) throws Incompatibl 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); }); - List specificAssetIds = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - specificAssetIds.add(keysMap.get(index)); + 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); } - builder.specificAssetIds(specificAssetIds); } Entity object = builder.build(); //HasDataSpecification 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 index a30613c46..4a8eab390 100644 --- 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 @@ -76,11 +76,13 @@ public Extension fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.refersTo(references); } //HasSemantics Extension object = builder.build(); 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 index b4910e6d9..d7c30d72c 100644 --- 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 @@ -5,10 +5,7 @@ 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.AASNamespace; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.DefaultRDFHandlerResult; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.RDFSerializationResult; +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; @@ -30,9 +27,9 @@ public RDFSerializationResult toModel(Key key) { return new DefaultRDFHandlerResult(model, subject); } - public Key fromModel(Model model, Resource subjectToParse) { + public Key fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Key)) { - throw new IllegalArgumentException("Provided Resource is not a Key"); + throw new IncompatibleTypeException("Key"); } DefaultKey.Builder builder = new DefaultKey.Builder(); if (model.contains(subjectToParse, AASNamespace.Key.value)) { 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 index b4f483b14..d65cd543a 100644 --- 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 @@ -31,7 +31,7 @@ public RDFSerializationResult toModel(LangStringNameType object) { @Override public LangStringNameType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringNameType)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringNameType"); + throw new IncompatibleTypeException("LangStringNameType"); } DefaultLangStringNameType.Builder builder = new DefaultLangStringNameType.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 7c745524d..88e20bb35 100644 --- 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 @@ -30,7 +30,7 @@ public RDFSerializationResult toModel(LangStringTextType object) { @Override public LangStringTextType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringTextType)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringTextType"); + throw new IncompatibleTypeException("LangStringTextType"); } DefaultLangStringTextType.Builder builder = new DefaultLangStringTextType.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 80b9d978e..6422502dc 100644 --- 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 @@ -27,7 +27,7 @@ public RDFSerializationResult toModel(Operation object) { model.add(subject, RDF.type, AASNamespace.Types.Operation); if (object.getInoutputVariables() != null && object.getInoutputVariables().isEmpty() == false) { int index = 0; - for (OperationVariable item : object.getOutputVariables()) { + 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()); @@ -38,7 +38,7 @@ public RDFSerializationResult toModel(Operation object) { } if (object.getInputVariables() != null && object.getInputVariables().isEmpty() == false) { int index = 0; - for (OperationVariable item : object.getOutputVariables()) { + 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()); @@ -88,11 +88,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.inoutputVariables(references); } if (model.contains(subjectToParse, AASNamespace.Operation.inputVariables)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.inputVariables); @@ -107,11 +109,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.inputVariables(references); } if (model.contains(subjectToParse, AASNamespace.Operation.outputVariables)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Operation.outputVariables); @@ -126,11 +130,13 @@ public Operation fromModel(Model model, Resource subjectToParse) throws Incompat int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.outputVariables(references); } Operation object = builder.build(); //HasDataSpecification 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 index b1fc18b48..7f5b847eb 100644 --- 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 @@ -51,21 +51,21 @@ public Property fromModel(Model model, Resource subjectToParse) throws Incompati if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.Property)) { throw new IncompatibleTypeException("Property"); } - DefaultProperty.Builder builder = new DefaultProperty.Builder(); + //TODO: Get this from supplier + Property object = new DefaultProperty(); if (model.contains(subjectToParse, AASNamespace.Property.value)) { - builder.value(model.getProperty(subjectToParse, AASNamespace.Property.value).getString()); + 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); - builder.valueId(reference); + object.setValueId(reference); } if (model.contains(subjectToParse, AASNamespace.Property.valueType)) { Resource resource = model.getProperty(subjectToParse, AASNamespace.Property.valueType).getResource(); - builder.valueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); + object.setValueType(AASNamespace.DataTypeDefXsd.fromIRI(resource.getURI())); } - Property object = builder.build(); //HasDataSpecification new DefaultHasDataSpecificationRDFPartialHandler().partialFromModel(object, model, subjectToParse); //HasSemantics 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 index 4a9274ef5..e234176d1 100644 --- 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 @@ -1,2 +1,53 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers;public class DefaultReferableRDFHandler { +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/DefaultReferenceRDFHandler.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/handlers/DefaultReferenceRDFHandler.java index d2a152450..b3cd5517d 100644 --- 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 @@ -46,7 +46,12 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); keysIterator.forEachRemaining(node -> { - Key key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + Key key = null; + try { + key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + } catch (IncompatibleTypeException e) { + throw new RuntimeException(e); + } int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); keysMap.put(index, key); }); 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 index 3f55115d1..06f527d4b 100644 --- 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 @@ -54,7 +54,7 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) } DefaultSubmodelElementCollection.Builder builder = new DefaultSubmodelElementCollection.Builder(); if (model.contains(subjectToParse, AASNamespace.SubmodelElementCollection.value)) { - NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementCollection.value); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { SubmodelElement key = null; @@ -66,11 +66,13 @@ public SubmodelElementCollection fromModel(Model model, Resource subjectToParse) int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.value(references); } SubmodelElementCollection object = builder.build(); //HasDataSpecification 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 index 8a15da7a5..60cf1f3a8 100644 --- 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 @@ -70,7 +70,7 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw throw new IncompatibleTypeException("SubmodelElementList"); } DefaultSubmodelElementList.Builder builder = new DefaultSubmodelElementList.Builder(); - builder.orderRelevant(false); + builder.orderRelevant(true); if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant)) { builder.orderRelevant(model.getProperty(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); @@ -91,12 +91,8 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw AASNamespace.SubmodelElementList.typeValueListElement).getResource(); builder.typeValueListElement(AASNamespace.AasSubmodelElements.fromIRI(resource.getURI())); } - if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.orderRelevant)) { - builder.orderRelevant(model.getProperty(subjectToParse, - AASNamespace.SubmodelElementList.orderRelevant).getBoolean()); - } if (model.contains(subjectToParse, AASNamespace.SubmodelElementList.value)) { - NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.ConceptDescription.isCaseOf); + NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.SubmodelElementList.value); Map keysMap = new HashMap<>(); nodeIterator.forEachRemaining(node -> { SubmodelElement key = null; @@ -108,11 +104,13 @@ public SubmodelElementList fromModel(Model model, Resource subjectToParse) throw int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List references = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - references.add(keysMap.get(index)); + 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); } - builder.value(references); } SubmodelElementList object = builder.build(); //HasDataSpecification 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 index 1d6dce76f..b8f0add58 100644 --- 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 @@ -59,7 +59,7 @@ public RDFSerializationResult toModel(SubmodelElement object) { throw new IllegalArgumentException("Provided object " + object.getClass() + - " is not a known type"); + " is not a known SubmodelElement"); } @Override 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 index ab4b05448..9bf6a0893 100644 --- 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 @@ -70,11 +70,13 @@ public Submodel fromModel(Model model, Resource subjectToParse) throws Incompati int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); keysMap.put(index, key); }); - List submodelElements = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - submodelElements.add(keysMap.get(index)); + 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); } - builder.submodelElements(submodelElements); } //HasKind if (model.contains(subjectToParse, AASNamespace.HasKind.kind)) { 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 index c96bab8e9..10c1599e9 100644 --- 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 @@ -30,7 +30,7 @@ public RDFSerializationResult toModel(LangStringDefinitionTypeIec61360 object) { @Override public LangStringDefinitionTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringDefinitionTypeIec61360)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringDefinitionTypeIec61360"); + throw new IncompatibleTypeException("LangStringDefinitionTypeIec61360"); } DefaultLangStringDefinitionTypeIec61360.Builder builder = new DefaultLangStringDefinitionTypeIec61360.Builder(); if (model.contains(subjectToParse, AASNamespace.AbstractLangString.text)) { 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 index 7db3cb95d..c70cbba54 100644 --- 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 @@ -30,12 +30,15 @@ public RDFSerializationResult toModel(LangStringShortNameTypeIec61360 object) { @Override public LangStringShortNameTypeIec61360 fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360)) { - throw new IllegalArgumentException("Provided Resource is not a LangStringShortNameTypeIec61360"); + throw new IncompatibleTypeException("LangStringShortNameTypeIec61360"); } - - return new DefaultLangStringShortNameTypeIec61360.Builder() - .text(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.text).getString()) - .language(model.getProperty(subjectToParse, AASNamespace.AbstractLangString.language).getString()) - .build(); + 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 index 7fbb47d40..876203b4f 100644 --- 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 @@ -28,13 +28,21 @@ public RDFSerializationResult toModel(LevelType object) { @Override public LevelType fromModel(Model model, Resource subjectToParse) throws IncompatibleTypeException { if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.LevelType)) { - throw new IllegalArgumentException("Provided Resource is not a LevelType"); + throw new IncompatibleTypeException("LevelType"); } - return new DefaultLevelType.Builder() - .min(model.getProperty(subjectToParse, AASNamespace.LevelType.min).getBoolean()) - .max(model.getProperty(subjectToParse, AASNamespace.LevelType.max).getBoolean()) - .nom(model.getProperty(subjectToParse, AASNamespace.LevelType.nom).getBoolean()) - .typ(model.getProperty(subjectToParse, AASNamespace.LevelType.typ).getBoolean()) - .build(); + 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 index efdbdfe31..97c802a47 100644 --- 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 @@ -21,14 +21,17 @@ public RDFSerializationResult toModel(ValueList object) { } Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.ValueList); - 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++; + 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); } @@ -37,24 +40,28 @@ public ValueList fromModel(Model model, Resource subjectToParse) throws Incompat if (!model.contains(subjectToParse, RDF.type, AASNamespace.Types.ValueList)) { throw new IncompatibleTypeException("ValueList"); } - 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); + 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); } - int index = model.getProperty(node.asResource(), AASNamespace.index).getInt(); - keysMap.put(index, key); - }); - List valueReferencePairList = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - valueReferencePairList.add(keysMap.get(index)); } - return new DefaultValueList.Builder() - .valueReferencePairs(valueReferencePairList) - .build(); + 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 index f767d7005..a1e15f6a8 100644 --- 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 @@ -42,17 +42,20 @@ public HasDataSpecification partialFromModel(HasDataSpecification object, Model 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); } - int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index, key); + }); - List keys = new ArrayList<>(); - for (int index = 0; index < keysMap.keySet().size(); index++) { - keys.add(keysMap.get(index)); + 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); } - object.setEmbeddedDataSpecifications(keys); } 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 index 8a0ee2a98..c6f7e4404 100644 --- 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 @@ -58,11 +58,13 @@ public HasSemantics partialFromModel(HasSemantics object, Model model, Resource 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)); + 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); } - object.setSupplementalSemanticIds(langStringList); } 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 index a4644169f..31eb55b22 100644 --- 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 @@ -47,11 +47,13 @@ public Qualifiable partialFromModel(Qualifiable object, Model model, Resource su 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)); + 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); } - object.setQualifiers(langStringList); } 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 index 92809acc0..fd39940e6 100644 --- 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 @@ -88,11 +88,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setDescription(langStringList); } if (model.contains(subjectToParse, AASNamespace.Referable.displayName)) { NodeIterator nodeIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Referable.displayName); @@ -107,11 +109,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setDisplayName(langStringList); } //HasExtension @@ -128,11 +132,13 @@ public Referable partialFromModel(Referable object, Model model, Resource subjec 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)); + 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); } - object.setExtensions(langStringList); } return object; } 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 index 815a50b75..d97c1b92a 100644 --- 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 @@ -3,92 +3,49 @@ 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.dataformat.rdf.handlers.DefaultAssetInformationRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultResourceRDFHandler; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.handlers.DefaultSpecificAssetIdRDFHandler; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -public class AssetAdministrationShellTest { - - @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); +import java.util.LinkedList; +import java.util.List; +import static org.junit.Assert.assertEquals; - AssetInformation recreatedObject = new DefaultAssetInformationRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(recreatedObject); +@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 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); - } @Test - public void testMinimalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMinimalAssetAdministrationShell(); + 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); - assert object.equals(recreatedObject); + assertEquals(object, recreatedObject); } - @Test - public void testMaximalAssetAdministrationShell() throws IncompatibleTypeException { - AssetAdministrationShell object = SerializerUtil.getMaximalAssetAdministrationShell(); - 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); - assert object.equals(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 index 308ee96ed..4dfd9e272 100644 --- 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 @@ -3,49 +3,55 @@ 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.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) public class ConceptDescriptionTest { - @Test - public void simpleConceptDescription() throws IOException, IncompatibleTypeException { - ConceptDescription object = new DefaultConceptDescription.Builder() - .id("simple") - .build(); - RDFSerializationResult rdfSerializationResult = new DefaultConceptDescriptionRDFHandler().toModel(object); - Model model = rdfSerializationResult.getModel(); - model.write(System.out, Lang.TTL.getName()); - Resource createdResource = rdfSerializationResult.getResource(); - ConceptDescription recreatedObject = new DefaultConceptDescriptionRDFHandler().fromModel(model, createdResource); - assert object.equals(recreatedObject); + @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 complexConceptDescription() throws IncompatibleTypeException { - ConceptDescription object = 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.getEmbeddedDataSpecifications()) - .build(); + 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); - assert object.equals(recreatedObject); + 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 index cf2849d93..a14e9012e 100644 --- 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 @@ -80,7 +80,6 @@ public void testDataSpecificationIec61360() throws IncompatibleTypeException { model.write(System.out, Lang.TTL.getName()); Resource createdResource = rdfSerializationResult.getResource(); assert model.contains(createdResource, RDF.type, AASNamespace.Types.DataSpecificationIec61360); -// assert model.contains(createdResource, AASNamespace.Identifiable.id, conceptDescription.getId()); DataSpecificationIec61360 recreatedDataSpecification = new DefaultDataSpecificationIEC61360RDFHandler().fromModel(model, createdResource); assert dataSpecificationIec61360.equals(recreatedDataSpecification); 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 index c79fa2be3..1d26e6026 100644 --- 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 @@ -1,2 +1,52 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class EnvironemntTest { +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 testConceptDescription() 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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java index 728876fab..080f3ece7 100644 --- a/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java @@ -13,14 +13,13 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; public class SerializerTest { @Test - public void testKey() throws IOException { + public void testKey() throws IOException, IncompatibleTypeException { Key simpleKey = new DefaultKey.Builder() .value("simple") .type(KeyTypes.GLOBAL_REFERENCE) @@ -88,7 +87,7 @@ public void testMaximalAdministrativeInformation() throws IncompatibleTypeExcept public void testReference() throws IncompatibleTypeException { Reference reference = new DefaultReference.Builder() .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys(Arrays.asList( + .keys(List.of( new DefaultKey.Builder() .value("https://example.com") .type(KeyTypes.GLOBAL_REFERENCE) @@ -106,6 +105,20 @@ public void testReference() throws IncompatibleTypeException { 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 { @@ -154,11 +167,11 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE .assetKind(AssetKind.INSTANCE) .build()) .description( - Arrays.asList( + List.of( new DefaultLangStringTextType.Builder() .text("This is a test AAS") .language("en-us").build())) - .displayName(Arrays.asList(new DefaultLangStringNameType.Builder() + .displayName(List.of(new DefaultLangStringNameType.Builder() .text("Anzeigename 2").language("de").build(), new DefaultLangStringNameType.Builder().text("Display Name 1") .language("en").build())).build(); @@ -166,11 +179,11 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE Submodel submodel = new DefaultSubmodel.Builder() .id("example") .description( - Arrays.asList(new DefaultLangStringTextType.Builder() + List.of(new DefaultLangStringTextType.Builder() .text("My Submodel") .language("en-us") .build())) - .displayName(Arrays.asList(new DefaultLangStringNameType.Builder() + .displayName(List.of(new DefaultLangStringNameType.Builder() .text("First Submodel Element name") .language("en").build(), new DefaultLangStringNameType.Builder() @@ -199,5 +212,56 @@ public void serializeEnvironmentSmokeTest() throws IOException, DeserializationE 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/SerializerUtil.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerUtil.java index 14fcb24a7..d81be9685 100644 --- 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 @@ -4,15 +4,32 @@ import org.eclipse.digitaltwin.aas4j.v3.model.*; import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; -import java.util.Arrays; 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 DefaultDataSpecificationIec61360 getDataSpecificationIec61360() { + public static DataSpecificationIec61360 getDataSpecificationIec61360() { return new DefaultDataSpecificationIec61360.Builder() .dataType(DataTypeIec61360.STRING) .value("exampleValue") @@ -119,7 +136,7 @@ public static EmbeddedDataSpecification getMaximalEmbeddedDataSpecifications() { } static List getIsCaseOfs() { - return Arrays.asList( + return List.of( new DefaultReference.Builder() .keys(new DefaultKey.Builder() .value("https://example.com/outside") @@ -132,22 +149,12 @@ static AdministrativeInformation getAdministrativeInformation() { return new DefaultAdministrativeInformation.Builder() .version("1") .revision("0") - .creator(new DefaultReference.Builder().keys( - Arrays.asList(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()) + .creator(getMaximalReference()) .build(); } static List getDescriptions() { - return Arrays.asList( + return List.of( new DefaultLangStringTextType.Builder() .text("A long text in English") .language("en") @@ -159,7 +166,7 @@ static List getDescriptions() { } static List getDisplayNames() { - return Arrays.asList( + return List.of( new DefaultLangStringNameType.Builder() .text("text in English") .language("en") @@ -175,26 +182,9 @@ static Extension getMaximalExtension() { .name("extension1") .value("extension1Value") .valueType(DataTypeDefXsd.ANY_URI) - .refersTo(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("refersTo") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) - .semanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("semanticId") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build()) - .supplementalSemanticIds(Arrays.asList( - new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("supplementalSemanticIds") - .type(KeyTypes.GLOBAL_REFERENCE) - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE).build())) + .refersTo(getMaximalReference()) + .semanticId(getMaximalReference()) + .supplementalSemanticIds(getMaximalReferenceList()) .build(); } @@ -208,6 +198,78 @@ static Reference getMinimalReference() { .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") @@ -432,6 +494,13 @@ static Entity getMaximalEntity() { return new DefaultEntity.Builder() .idShort("E1") .entityType(EntityType.SELF_MANAGED_ENTITY) + .statements(List.of(getMinimalProperty(), getMinimalAnnotatedRelationshipElement())) + .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) + .globalAssetId("global") + .description(getDescriptions()) + .displayName(getDisplayNames()) + .qualifiers(getMaximalQualifier()) + .supplementalSemanticIds(getMaximalReferenceList()) .build(); } @@ -587,7 +656,7 @@ static AssetAdministrationShell getMaximalAssetAdministrationShell() { static List getExtensionList() { - return Arrays.asList( + 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 index 559f5978a..5b80674fc 100644 --- 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 @@ -13,6 +13,8 @@ import java.util.LinkedList; import java.util.List; +import static org.junit.Assert.assertEquals; + @RunWith(Parameterized.class) public class SubmodelElementTest { @Parameter @@ -27,13 +29,13 @@ public static Object[] data() { } @Test - public void testGeneric() throws IncompatibleTypeException { + 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 submodelElement = new DefaultSubmodelElementRDFHandler().fromModel(rdfSerializationResult.getModel(), createdResource); - assert object.equals(submodelElement); + 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 index 1f0cf68a5..d98d197db 100644 --- 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 @@ -1,2 +1,68 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SubmodelTest { +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 Date: Mon, 12 Feb 2024 11:00:18 +0100 Subject: [PATCH 156/160] Enhance tests and java docs --- .../aas4j/v3/dataformat/rdf/RDFHandler.java | 8 ++- .../rdf/RDFSerializationResult.java | 6 +- .../v3/dataformat/rdf/RDFSerializer.java | 15 +++-- .../handlers/DefaultReferenceRDFHandler.java | 7 +- .../v3/dataformat/rdf/SerializerUtil.java | 66 ++++++++++++++++++- 5 files changed, 85 insertions(+), 17 deletions(-) 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 index 69c8f4450..0f6078a8b 100644 --- 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 @@ -11,7 +11,7 @@ */ public interface RDFHandler { /** - * Convert to RDF model. This method is side effect free and idempotent. + * 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 @@ -20,11 +20,13 @@ public interface RDFHandler { RDFSerializationResult toModel(T object); /** - * This method is side effect free and idempotent. + * 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 elements that correspond to the object. + * @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/RDFSerializationResult.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializationResult.java index 699177f14..e2bb09145 100644 --- 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 @@ -15,10 +15,10 @@ public interface RDFSerializationResult { Model getModel(); /** - * corresponding node created in the graph as a starting point - * note that this is a Apache Jena's {@link org.apache.jena.rdf.model.Resource} + * 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 a Resource in the graph + * @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 index 55f4e4fb7..81b5af576 100644 --- 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 @@ -1,10 +1,10 @@ package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf; -import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; import org.eclipse.digitaltwin.aas4j.v3.dataformat.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; @@ -56,7 +56,10 @@ public String write(Environment aasEnvironment) throws SerializationException { */ public String write(Referable referable, Lang serializationFormat) throws SerializationException { try { - throw new RuntimeException("Not Implemented"); + 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); } @@ -79,8 +82,9 @@ public String write(Referable referable) throws SerializationException { * @param aasEnvironment the AssetAdministrationShellEnvironment to serialize * @return the Jena Model */ - public Model toModel(Environment aasEnvironment) { - throw new RuntimeException("Not Implemented"); + public RDFSerializationResult toModel(Environment aasEnvironment) { + RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(aasEnvironment); + return rdfSerializationResult; } /** @@ -90,7 +94,8 @@ public Model toModel(Environment aasEnvironment) { * @return the RDFSerializationResult contains the Apache Jena model as well as the corresponding created resource */ public RDFSerializationResult toModel(Referable referable) { - return null; + RDFSerializationResult rdfSerializationResult = new DefaultReferableRDFHandler().toModel(referable); + return rdfSerializationResult; } 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 index b3cd5517d..20ec5c2ab 100644 --- 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 @@ -46,14 +46,13 @@ public Reference fromModel(Model model, Resource subjectToParse) throws Incompat Map keysMap = new HashMap<>(); NodeIterator keysIterator = model.listObjectsOfProperty(subjectToParse, AASNamespace.Reference.keys); keysIterator.forEachRemaining(node -> { - Key key = null; try { - key = new DefaultKeyRDFHandler().fromModel(model, (Resource) node); + 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); } - int index = model.getProperty((Resource) node, AASNamespace.index).getInt(); - keysMap.put(index, key); }); List keys = new ArrayList<>(); for (int index = 0; index < keysMap.keySet().size(); index++) { 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 index d81be9685..fe48499c7 100644 --- 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 @@ -334,6 +334,20 @@ static List getMinimalSubmodelElementsList() { 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(), @@ -451,6 +465,12 @@ static BasicEventElement getMaximalBasicEventElement() { .idShort("BEE1") .direction(Direction.OUTPUT) .state(StateOfEvent.OFF) + .messageBroker(getMaximalReference()) + .messageTopic("topic") + .minInterval("1s") + .maxInterval("2s") + .lastUpdate("3s") + .semanticId(getMinimalReference()) .observed(getMinimalReference()) .build(); } @@ -497,6 +517,7 @@ static Entity getMaximalEntity() { .statements(List.of(getMinimalProperty(), getMinimalAnnotatedRelationshipElement())) .embeddedDataSpecifications(getMaximalEmbeddedDataSpecifications()) .globalAssetId("global") + .specificAssetIds(getMaximalSpecificAssetId()) .description(getDescriptions()) .displayName(getDisplayNames()) .qualifiers(getMaximalQualifier()) @@ -529,6 +550,9 @@ static Range getMaximalRange() { return new DefaultRange.Builder() .idShort("R1") .valueType(DataTypeDefXsd.DECIMAL) + .max("19") + .min("10") + .build(); } @@ -541,6 +565,7 @@ static ReferenceElement getMinimalReferenceElement() { static ReferenceElement getMaximalReferenceElement() { return new DefaultReferenceElement.Builder() .idShort("RE1") + .value(getMaximalReference()) .build(); } @@ -553,18 +578,53 @@ static RelationshipElement getMinimalRelationshipElement() { static RelationshipElement getMaximalRelationshipElement() { return new DefaultRelationshipElement.Builder() .idShort("ReE1") + .first(getMaximalReference()) + .second(getMinimalReference()) .build(); } static SubmodelElementCollection getMinimalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() - .idShort("SEC1") + .idShort("MinimalSubmodelElementCollection") .build(); } static SubmodelElementCollection getMaximalSubmodelElementCollection() { return new DefaultSubmodelElementCollection.Builder() - .idShort("SEC1") + .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(); } @@ -577,6 +637,8 @@ static SubmodelElementList getMinimalSubmodelElementList() { static SubmodelElementList getMaximalSubmodelElementList() { return new DefaultSubmodelElementList.Builder() .idShort("SEL1") + .semanticIdListElement(getMaximalReference()) + .valueTypeListElement(DataTypeDefXsd.STRING) .build(); } From b30cddeadda8d1cde9ecf73211a9af4d56d506aa Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Fri, 8 Mar 2024 19:30:28 +0100 Subject: [PATCH 157/160] Include Jena Shacl module --- dataformat-rdf/pom.xml | 5 + .../v3/dataformat/rdf/RDFDeserializer.java | 2 + .../v3/dataformat/rdf/RDFSchemaValidator.java | 2 + .../src/main/resources/rdf-ontology.ttl | 2058 +++++++++++++++++ .../main/resources/shacl-schema-original.ttl | 0 .../src/main/resources/shacl-schema.ttl | 1325 +++++++++++ ...tCustomClass.java => CustomClassTest.java} | 0 .../dataformat/rdf/RDFDeserializerTest.java | 2 + ...rializerTest.java => RDFHandlersTest.java} | 0 .../v3/dataformat/rdf/RDFSerializerTest.java | 2 + .../dataformat/rdf/SchemaValidatorTest.java | 2 + 11 files changed, 3398 insertions(+) create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java create mode 100644 dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java create mode 100644 dataformat-rdf/src/main/resources/rdf-ontology.ttl create mode 100644 dataformat-rdf/src/main/resources/shacl-schema-original.ttl create mode 100644 dataformat-rdf/src/main/resources/shacl-schema.ttl rename dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{TestCustomClass.java => CustomClassTest.java} (100%) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java rename dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/{SerializerTest.java => RDFHandlersTest.java} (100%) create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java create mode 100644 dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java diff --git a/dataformat-rdf/pom.xml b/dataformat-rdf/pom.xml index aa42713c8..4017ce587 100644 --- a/dataformat-rdf/pom.xml +++ b/dataformat-rdf/pom.xml @@ -27,6 +27,11 @@ jena-arq ${jena.version} + + org.apache.jena + jena-shacl + ${jena.version} + org.slf4j slf4j-api 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..b11c5fd66 --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializer.java @@ -0,0 +1,2 @@ +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/RDFSchemaValidator.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java new file mode 100644 index 000000000..f79e602ac --- /dev/null +++ b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class RDFSchemaValidator { +} 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..e69de29bb 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..03ec931db --- /dev/null +++ b/dataformat-rdf/src/main/resources/shacl-schema.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/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java similarity index 100% rename from dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/TestCustomClass.java rename to dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/CustomClassTest.java 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..7330b292a --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFDeserializerTest.java @@ -0,0 +1,2 @@ +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/SerializerTest.java b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java similarity index 100% rename from dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SerializerTest.java rename to dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java 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..96c7e13e4 --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializerTest.java @@ -0,0 +1,2 @@ +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..9dd3ee8ef --- /dev/null +++ b/dataformat-rdf/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/SchemaValidatorTest.java @@ -0,0 +1,2 @@ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SchemaValidatorTest { +} From f599c5312e92edbc987c5cdad90c586c54aac349 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Fri, 8 Mar 2024 19:30:51 +0100 Subject: [PATCH 158/160] Add initial SHACL validator --- .../v3/dataformat/rdf/RDFDeserializer.java | 4 +- .../v3/dataformat/rdf/RDFSchemaValidator.java | 54 +- .../main/resources/shacl-schema-original.ttl | 1325 +++++++++++++++++ .../src/main/resources/shacl-schema.ttl | 74 +- .../v3/dataformat/rdf/CustomClassTest.java | 12 +- .../v3/dataformat/rdf/EnvironmentTest.java | 2 +- .../dataformat/rdf/RDFDeserializerTest.java | 4 +- .../v3/dataformat/rdf/RDFHandlersTest.java | 2 +- .../v3/dataformat/rdf/RDFSerializerTest.java | 4 +- .../dataformat/rdf/SchemaValidatorTest.java | 70 +- 10 files changed, 1512 insertions(+), 39 deletions(-) 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 index b11c5fd66..3316efdb3 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFDeserializer { +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/RDFSchemaValidator.java b/dataformat-rdf/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/rdf/RDFSchemaValidator.java index f79e602ac..d33a2bbbe 100644 --- 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 @@ -1,2 +1,54 @@ -package PACKAGE_NAME;public class RDFSchemaValidator { +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.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/resources/shacl-schema-original.ttl b/dataformat-rdf/src/main/resources/shacl-schema-original.ttl index e69de29bb..03ec931db 100644 --- a/dataformat-rdf/src/main/resources/shacl-schema-original.ttl +++ 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 index 03ec931db..145069e23 100644 --- a/dataformat-rdf/src/main/resources/shacl-schema.ttl +++ b/dataformat-rdf/src/main/resources/shacl-schema.ttl @@ -23,6 +23,7 @@ aas:AbstractLangStringShape a sh:NodeShape ; 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 . @@ -45,7 +46,7 @@ aas:AbstractLangStringShape a sh:NodeShape ; sh:minCount 1 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -60,7 +61,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 4 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -71,7 +72,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 4 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -89,7 +90,7 @@ aas:AdministrativeInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -147,7 +148,7 @@ aas:AssetInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -163,7 +164,7 @@ aas:AssetInformationShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -206,7 +207,7 @@ aas:BasicEventElementShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 255 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -259,7 +260,7 @@ aas:BlobShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -289,6 +290,7 @@ aas:DataElementShape a sh:NodeShape ; 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 . @@ -305,6 +307,7 @@ aas:DataSpecificationContentShape a sh:NodeShape ; 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 . @@ -336,7 +339,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -352,7 +355,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -361,7 +364,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -383,7 +386,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:minCount 0 ; sh:maxCount 1 ; sh:minLength 1 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -400,7 +403,7 @@ aas:DataSpecificationIec61360Shape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -453,7 +456,7 @@ aas:EntityShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -493,6 +496,7 @@ aas:EventElementShape a sh:NodeShape ; 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 . @@ -540,7 +544,7 @@ aas:EventPayloadShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 255 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -577,7 +581,7 @@ aas:ExtensionShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -612,7 +616,7 @@ aas:FileShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -623,7 +627,7 @@ aas:FileShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -635,6 +639,7 @@ aas:HasDataSpecificationShape a sh:NodeShape ; 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 . @@ -657,6 +662,7 @@ aas:HasExtensionsShape a sh:NodeShape ; 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 . @@ -679,6 +685,7 @@ aas:HasKindShape a sh:NodeShape ; 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 . @@ -702,6 +709,7 @@ aas:HasSemanticsShape a sh:NodeShape ; 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 . @@ -732,6 +740,7 @@ aas:IdentifiableShape a sh:NodeShape ; 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 . @@ -754,7 +763,7 @@ aas:IdentifiableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -775,7 +784,7 @@ aas:KeyShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; . @@ -797,7 +806,7 @@ aas:LangStringNameTypeShape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -810,7 +819,7 @@ aas:LangStringPreferredNameTypeIec61360Shape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -823,7 +832,7 @@ aas:LangStringShortNameTypeIec61360Shape a sh:NodeShape ; rdfs:subClassOf aas:AbstractLangStringShape ; sh:property [ a sh:PropertyShape ; - sh:path ; + sh:path ; sh:datatype xs:string ; sh:minCount 1 ; sh:maxCount 1 ; @@ -961,6 +970,7 @@ aas:QualifiableShape a sh:NodeShape ; 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 . @@ -994,7 +1004,7 @@ aas:QualifierShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1053,6 +1063,7 @@ aas:ReferableShape a sh:NodeShape ; 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 . @@ -1068,7 +1079,7 @@ aas:ReferableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1078,7 +1089,7 @@ aas:ReferableShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 128 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -1160,7 +1171,7 @@ aas:ResourceShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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 [ @@ -1171,7 +1182,7 @@ aas:ResourceShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 100 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + 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]))*\"))*$" ; ] ; . @@ -1187,7 +1198,7 @@ aas:SpecificAssetIdShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 64 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1197,7 +1208,7 @@ aas:SpecificAssetIdShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; @@ -1234,6 +1245,7 @@ aas:SubmodelElementShape a sh:NodeShape ; 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 . @@ -1313,7 +1325,7 @@ aas:ValueReferencePairShape a sh:NodeShape ; sh:maxCount 1 ; sh:minLength 1 ; sh:maxLength 2000 ; - sh:pattern "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$" ; + sh:pattern "^([\\t\\n\\r -\ud7ff\ue000-\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$" ; ] ; sh:property [ a sh:PropertyShape ; 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 index 855d6e5c1..50bd9aeec 100644 --- 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 @@ -8,12 +8,22 @@ 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 TestCustomClass { +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"); 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 index 1d26e6026..4437b4868 100644 --- 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 @@ -33,7 +33,7 @@ public static Object[] data() { } @Test - public void testConceptDescription() throws IncompatibleTypeException { + public void testEnvironment() throws IncompatibleTypeException { Environment object = environment; RDFSerializationResult rdfSerializationResult = new DefaultEnvironmentRDFHandler().toModel(object); Model model = rdfSerializationResult.getModel(); 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 index 7330b292a..bfc09cd47 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFDeserializerTest { +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 index 080f3ece7..503d1812e 100644 --- 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 @@ -17,7 +17,7 @@ import java.util.List; -public class SerializerTest { +public class RDFHandlersTest { @Test public void testKey() throws IOException, IncompatibleTypeException { Key simpleKey = new DefaultKey.Builder() 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 index 96c7e13e4..b24805f08 100644 --- 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 @@ -1,2 +1,4 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class RDFSerializerTest { +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 index 9dd3ee8ef..99d8e9749 100644 --- 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 @@ -1,2 +1,70 @@ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf;public class SchemaValidatorTest { +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; + + } } From 04ec454941e7dfcb03f9bfc383d372dcfd662938 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 30 Jan 2025 12:53:57 +0100 Subject: [PATCH 159/160] Migrate to Apache Jena 5.3.0 --- .../DefaultAdministrativeInformationRDFHandler.java | 8 ++++---- .../rdf/handlers/DefaultExtensionRDFHandler.java | 4 ++-- .../DefaultLangStringNameTypeRDFHandler.java | 4 ++-- .../DefaultLangStringTextTypeRDFHandler.java | 4 ++-- ...tLangStringDefinitionTypeIec61360RDFHandler.java | 4 ++-- ...ngStringPreferredNameTypeIec61360RDFHandler.java | 4 ++-- ...ltLangStringShortNameTypeIec61360RDFHandler.java | 9 +++------ pom.xml | 13 ++++--------- 8 files changed, 21 insertions(+), 29 deletions(-) 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 index ac7333c40..dc2a43b53 100644 --- 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 @@ -21,17 +21,17 @@ public RDFSerializationResult toModel(AdministrativeInformation object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.AdministrativeInformation); if (object.getVersion() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, object.getVersion()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.version, model.createTypedLiteral(object.getVersion())); } if (object.getRevision() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, object.getRevision()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.revision, model.createTypedLiteral(object.getRevision())); } if (object.getTemplateId() != null) { - model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, object.getTemplateId()); + model.addLiteral(subject, AASNamespace.AdministrativeInformation.templateId, model.createTypedLiteral(object.getTemplateId())); } if (object.getCreator() != null) { RDFSerializationResult res = new DefaultReferenceRDFHandler().toModel(object.getCreator()); - model.addLiteral(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); + model.add(subject, AASNamespace.AdministrativeInformation.creator, res.getResource()); model.add(res.getModel()); } //HasDataSpecification 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 index 4a8eab390..c48f84a3d 100644 --- 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 @@ -23,10 +23,10 @@ public RDFSerializationResult toModel(Extension object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.Extension); if (object.getName() != null) { - model.addLiteral(subject, AASNamespace.Extension.name, object.getName()); + model.addLiteral(subject, AASNamespace.Extension.name, model.createTypedLiteral(object.getName())); } if (object.getValue() != null) { - model.addLiteral(subject, AASNamespace.Extension.value, object.getValue()); + model.addLiteral(subject, AASNamespace.Extension.value, model.createTypedLiteral(object.getValue())); } if (object.getValueType() != null) { model.add(subject, AASNamespace.Extension.valueType, 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 index d65cd543a..f1b841edc 100644 --- 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 @@ -20,10 +20,10 @@ public RDFSerializationResult toModel(LangStringNameType object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringNameType); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 88e20bb35..ea847cc72 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringTextType object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringTextType); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 10c1599e9..a9f9b91b2 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringDefinitionTypeIec61360 object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringDefinitionTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index 449941f3f..8748566ba 100644 --- 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 @@ -19,10 +19,10 @@ public RDFSerializationResult toModel(LangStringPreferredNameTypeIec61360 object Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringPreferredNameTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.add(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } 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 index c70cbba54..17e6a8656 100644 --- 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 @@ -1,9 +1,6 @@ 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.rdf.model.*; import org.apache.jena.vocabulary.RDF; import org.eclipse.digitaltwin.aas4j.v3.dataformat.rdf.*; import org.eclipse.digitaltwin.aas4j.v3.model.LangStringShortNameTypeIec61360; @@ -19,10 +16,10 @@ public RDFSerializationResult toModel(LangStringShortNameTypeIec61360 object) { Resource subject = model.createResource(); model.add(subject, RDF.type, AASNamespace.Types.LangStringShortNameTypeIec61360); if (object.getLanguage() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.language, object.getLanguage()); + model.addLiteral(subject, AASNamespace.AbstractLangString.language, model.createTypedLiteral(object.getLanguage())); } if (object.getText() != null) { - model.addLiteral(subject, AASNamespace.AbstractLangString.text, object.getText()); + model.addLiteral(subject, AASNamespace.AbstractLangString.text, model.createTypedLiteral(object.getText())); } return new DefaultRDFHandlerResult(model, subject); } diff --git a/pom.xml b/pom.xml index b4106a45f..559a2d2aa 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 2.0.1.Final 2.3.1 2.1.0 - 4.1.0 + 5.3.0 1.5.3 1.5.5 4.13.2 @@ -191,7 +191,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.8.1 + 3.6.1 @@ -206,7 +206,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.7 + 3.1.0 sign-artifacts @@ -228,7 +228,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.7.0 + 1.6.13 true ossrh @@ -298,11 +298,6 @@ aas4j-dataformat-xml ${revision} - - ${project.groupId} - aas4j-dataformat-json - ${revision} - ${project.groupId} aas4j-model From 30dfd3a1aeb57041912211984659f3120a751931 Mon Sep 17 00:00:00 2001 From: Hossein Rimaz Date: Thu, 30 Jan 2025 15:28:11 +0100 Subject: [PATCH 160/160] Migrate to latest aas4j structure --- .../digitaltwin/aas4j/v3/dataformat/rdf/RDFParser.java | 3 ++- .../aas4j/v3/dataformat/rdf/RDFSchemaValidator.java | 2 +- .../digitaltwin/aas4j/v3/dataformat/rdf/RDFSerializer.java | 3 ++- .../digitaltwin/aas4j/v3/dataformat/rdf/RDFHandlersTest.java | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) 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 index 46a0f2e14..a60634a2b 100644 --- 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 @@ -2,7 +2,8 @@ import com.fasterxml.jackson.databind.JsonNode; import org.apache.jena.rdf.model.Resource; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; + +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; 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 index d33a2bbbe..dc3f3d26d 100644 --- 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 @@ -7,7 +7,7 @@ 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.SchemaValidator; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.SchemaValidator; import java.io.StringReader; import java.util.Set; 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 index 81b5af576..ec7394591 100644 --- 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 @@ -2,7 +2,8 @@ import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFLanguages; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; + +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; 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 index 503d1812e..b328ae158 100644 --- 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 @@ -4,8 +4,9 @@ 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.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; + +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.*;