diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetChildrenVisitor.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetChildrenVisitor.java index 1122e7afa..a3f4d5b7d 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetChildrenVisitor.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetChildrenVisitor.java @@ -1,82 +1,82 @@ -/* - * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementVisitor; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; - -public class GetChildrenVisitor implements AssetAdministrationShellElementVisitor { - - private final List children = new ArrayList<>(); - private Environment environment; - - public GetChildrenVisitor() { - } - - public void reset() { - children.clear(); - } - - public GetChildrenVisitor(Environment environment) { - this.environment = environment; - } - - public List getChildren() { - return children; - } - - @Override - public void visit(Environment environment) { - children.addAll(environment.getAssetAdministrationShells()); - children.addAll(environment.getConceptDescriptions()); - children.addAll(environment.getSubmodels()); - } - - @Override - public void visit(AssetAdministrationShell assetAdministrationShell) { - List submodelIds = assetAdministrationShell.getSubmodels().stream() - .map(x -> x.getKeys().get(x.getKeys().size() - 1).getValue()) - .collect(Collectors.toList()); - if (environment != null) { - children.addAll(environment.getSubmodels().stream() - .filter(x -> submodelIds.contains(x.getId())) - .collect(Collectors.toList())); - } - } - - @Override - public void visit(Submodel submodel) { - children.addAll(submodel.getSubmodelElements()); - } - - @Override - public void visit(SubmodelElementCollection submodelElementCollection) { - children.addAll(submodelElementCollection.getValue()); - } - - @Override - public void visit(SubmodelElementList submodelElementList) { - children.addAll(submodelElementList.getValue()); - } -} +/* + * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementVisitor; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; + +public class GetChildrenVisitor implements AssetAdministrationShellElementVisitor { + + private final List children = new ArrayList<>(); + private Environment environment; + + public GetChildrenVisitor() { + } + + public void reset() { + children.clear(); + } + + public GetChildrenVisitor(Environment environment) { + this.environment = environment; + } + + public List getChildren() { + return children; + } + + @Override + public void visit(Environment environment) { + children.addAll(environment.getAssetAdministrationShells()); + children.addAll(environment.getConceptDescriptions()); + children.addAll(environment.getSubmodels()); + } + + @Override + public void visit(AssetAdministrationShell assetAdministrationShell) { + List submodelIds = assetAdministrationShell.getSubmodels().stream() + .map(x -> x.getKeys().get(x.getKeys().size() - 1).getValue()) + .collect(Collectors.toList()); + if (environment != null) { + children.addAll(environment.getSubmodels().stream() + .filter(x -> submodelIds.contains(x.getId())) + .collect(Collectors.toList())); + } + } + + @Override + public void visit(Submodel submodel) { + children.addAll(submodel.getSubmodelElements()); + } + + @Override + public void visit(SubmodelElementCollection submodelElementCollection) { + children.addAll(submodelElementCollection.getValue()); + } + + @Override + public void visit(SubmodelElementList submodelElementList) { + children.addAll(submodelElementList.getValue()); + } +} diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetIdentifierVisitor.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetIdentifierVisitor.java index e3df45436..f87ffa42e 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetIdentifierVisitor.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/GetIdentifierVisitor.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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 org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementVisitor; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; - -public class GetIdentifierVisitor implements AssetAdministrationShellElementVisitor { - - private String identifier; - - public static String getIdentifier(Referable referable) { - GetIdentifierVisitor visitor = new GetIdentifierVisitor(); - visitor.visit(referable); - return visitor.getIdentifier(); - } - - public String getIdentifier() { - return identifier; - } - - @Override - public void visit(Referable referable) { - if (referable != null) { - identifier = referable.getIdShort(); - } - AssetAdministrationShellElementVisitor.super.visit(referable); - } - - @Override - public void visit(Identifiable identifiable) { - if (identifiable != null) { - identifier = identifiable.getId(); - } - AssetAdministrationShellElementVisitor.super.visit(identifiable); - } -} +/* + * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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 org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementVisitor; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; + +public class GetIdentifierVisitor implements AssetAdministrationShellElementVisitor { + + private String identifier; + + public static String getIdentifier(Referable referable) { + GetIdentifierVisitor visitor = new GetIdentifierVisitor(); + visitor.visit(referable); + return visitor.getIdentifier(); + } + + public String getIdentifier() { + return identifier; + } + + @Override + public void visit(Referable referable) { + if (referable != null) { + identifier = referable.getIdShort(); + } + AssetAdministrationShellElementVisitor.super.visit(referable); + } + + @Override + public void visit(Identifiable identifiable) { + if (identifiable != null) { + identifier = identifiable.getId(); + } + AssetAdministrationShellElementVisitor.super.visit(identifiable); + } +} diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/IdentifiableCollector.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/IdentifiableCollector.java index 4a464f64a..1d703d036 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/IdentifiableCollector.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/IdentifiableCollector.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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 org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementWalkerVisitor; -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.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - -import java.util.HashSet; -import java.util.Set; - -/** - * Collects all Identifiable elements within an - * AssetAdministrationShellEnvironment - */ -public class IdentifiableCollector { - - private Environment env; - - public IdentifiableCollector(Environment env) { - this.env = env; - } - - public Set collect() { - Visitor visitor = new Visitor(); - visitor.visit(env); - return visitor.identifiables; - } - - private class Visitor implements AssetAdministrationShellElementWalkerVisitor { - - Set identifiables = new HashSet<>(); - - @Override - public void visit(AssetAdministrationShell value) { - identifiables.add(value); - AssetAdministrationShellElementWalkerVisitor.super.visit(value); - } - - @Override - public void visit(Submodel value) { - identifiables.add(value); - AssetAdministrationShellElementWalkerVisitor.super.visit(value); - } - - @Override - public void visit(ConceptDescription value) { - identifiables.add(value); - AssetAdministrationShellElementWalkerVisitor.super.visit(value); - } - } -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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 org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.visitor.AssetAdministrationShellElementWalkerVisitor; +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.Identifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; + +import java.util.HashSet; +import java.util.Set; + +/** + * Collects all Identifiable elements within an + * AssetAdministrationShellEnvironment + */ +public class IdentifiableCollector { + + private Environment env; + + public IdentifiableCollector(Environment env) { + this.env = env; + } + + public Set collect() { + Visitor visitor = new Visitor(); + visitor.visit(env); + return visitor.identifiables; + } + + private class Visitor implements AssetAdministrationShellElementWalkerVisitor { + + Set identifiables = new HashSet<>(); + + @Override + public void visit(AssetAdministrationShell value) { + identifiables.add(value); + AssetAdministrationShellElementWalkerVisitor.super.visit(value); + } + + @Override + public void visit(Submodel value) { + identifiables.add(value); + AssetAdministrationShellElementWalkerVisitor.super.visit(value); + } + + @Override + public void visit(ConceptDescription value) { + identifiables.add(value); + AssetAdministrationShellElementWalkerVisitor.super.visit(value); + } + } +} diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/MostSpecificTypeTokenComparator.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/MostSpecificTypeTokenComparator.java index 9893b7793..b69495bde 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/MostSpecificTypeTokenComparator.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/util/MostSpecificTypeTokenComparator.java @@ -1,37 +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.core.internal.util; - -import com.google.common.reflect.TypeToken; - -import java.util.Comparator; - -/** - * Comparator comparing two TypeToken regarding which type is more specific. - */ -public class MostSpecificTypeTokenComparator implements Comparator> { - - @Override - public int compare(TypeToken x, TypeToken y) { - if (x.isSubtypeOf(y)) { - if (y.isSubtypeOf(x)) { - return 0; - } - return -1; - } - return 1; - } -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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 com.google.common.reflect.TypeToken; + +import java.util.Comparator; + +/** + * Comparator comparing two TypeToken regarding which type is more specific. + */ +public class MostSpecificTypeTokenComparator implements Comparator> { + + @Override + public int compare(TypeToken x, TypeToken y) { + if (x.isSubtypeOf(y)) { + if (y.isSubtypeOf(x)) { + return 0; + } + return -1; + } + return 1; + } +} 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/internal/visitor/AssetAdministrationShellElementVisitor.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementVisitor.java index 24eb8f9d5..ee721c2c5 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementVisitor.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementVisitor.java @@ -1,309 +1,309 @@ -/* - * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * Copyright (c) 2023 SAP SE - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.visitor; - -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Blob; -import org.eclipse.digitaltwin.aas4j.v3.model.Capability; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; -import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; -import org.eclipse.digitaltwin.aas4j.v3.model.Entity; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.EventElement; -import org.eclipse.digitaltwin.aas4j.v3.model.EventPayload; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.File; -import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.HasExtensions; -import org.eclipse.digitaltwin.aas4j.v3.model.HasKind; -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.LangStringDefinitionTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.MultiLanguageProperty; -import org.eclipse.digitaltwin.aas4j.v3.model.Operation; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; -import org.eclipse.digitaltwin.aas4j.v3.model.Property; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; -import org.eclipse.digitaltwin.aas4j.v3.model.Range; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceElement; -import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Resource; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -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; - -public interface AssetAdministrationShellElementVisitor { - - public default void visit(DataElement dataElement) { - if (dataElement == null) { - return; - } - Class type = dataElement.getClass(); - if (Property.class.isAssignableFrom(type)) { - visit((Property) dataElement); - } else if (MultiLanguageProperty.class.isAssignableFrom(type)) { - visit((MultiLanguageProperty) dataElement); - } else if (Range.class.isAssignableFrom(type)) { - visit((Range) dataElement); - } else if (ReferenceElement.class.isAssignableFrom(type)) { - visit((ReferenceElement) dataElement); - } else if (File.class.isAssignableFrom(type)) { - visit((File) dataElement); - } else if (Blob.class.isAssignableFrom(type)) { - visit((Blob) dataElement); - } - } - - public default void visit(EventElement event) { - if (event == null) { - return; - } - Class type = event.getClass(); - if (BasicEventElement.class.isAssignableFrom(type)) { - visit((BasicEventElement) event); - } - } - - public default void visit(HasDataSpecification hasDataSpecification) { - if (hasDataSpecification == null) { - return; - } - Class type = hasDataSpecification.getClass(); - if (AssetAdministrationShell.class.isAssignableFrom(type)) { - visit((AssetAdministrationShell) hasDataSpecification); - } else if (Submodel.class.isAssignableFrom(type)) { - visit((Submodel) hasDataSpecification); - } else if (SubmodelElement.class.isAssignableFrom(type)) { - visit((SubmodelElement) hasDataSpecification); - } - - } - - public default void visit(HasExtensions hasExtensions) { - if (hasExtensions == null) { - return; - } - Class type = hasExtensions.getClass(); - if (Referable.class.isAssignableFrom(type)) { - visit((Referable) hasExtensions); - } - } - - public default void visit(HasKind hasKind) { - if (hasKind == null) { - return; - } - Class type = hasKind.getClass(); - if (Submodel.class.isAssignableFrom(type)) { - visit((Submodel) hasKind); - } - } - - public default void visit(HasSemantics hasSemantics) { - if (hasSemantics == null) { - return; - } - Class type = hasSemantics.getClass(); - if (Extension.class.isAssignableFrom(type)) { - visit((Extension) hasSemantics); - } else if (SpecificAssetId.class.isAssignableFrom(type)) { - visit((SpecificAssetId) hasSemantics); - } else if (Submodel.class.isAssignableFrom(type)) { - visit((Submodel) hasSemantics); - } else if (SubmodelElement.class.isAssignableFrom(type)) { - visit((SubmodelElement) hasSemantics); - } else if (Qualifier.class.isAssignableFrom(type)) { - visit((Qualifier) hasSemantics); - } - } - - public default void visit(Identifiable identifiable) { - if (identifiable == null) { - return; - } - Class type = identifiable.getClass(); - if (AssetAdministrationShell.class.isAssignableFrom(type)) { - visit((AssetAdministrationShell) identifiable); - } else if (Submodel.class.isAssignableFrom(type)) { - visit((Submodel) identifiable); - } else if (ConceptDescription.class.isAssignableFrom(type)) { - visit((ConceptDescription) identifiable); - } - } - - public default void visit(SubmodelElement submodelElement) { - if (submodelElement == null) { - return; - } - Class type = submodelElement.getClass(); - if (RelationshipElement.class.isAssignableFrom(type)) { - visit((RelationshipElement) submodelElement); - } else if (DataElement.class.isAssignableFrom(type)) { - visit((DataElement) submodelElement); - } else if (Capability.class.isAssignableFrom(type)) { - visit((Capability) submodelElement); - } else if (SubmodelElementCollection.class.isAssignableFrom(type)) { - visit((SubmodelElementCollection) submodelElement); - } else if (SubmodelElementList.class.isAssignableFrom(type)) { - visit((SubmodelElementList) submodelElement); - } else if (Operation.class.isAssignableFrom(type)) { - visit((Operation) submodelElement); - } else if (EventElement.class.isAssignableFrom(type)) { - visit((EventElement) submodelElement); - } else if (Entity.class.isAssignableFrom(type)) { - visit((Entity) submodelElement); - } - } - - public default void visit(Qualifiable qualifiable) { - if (qualifiable == null) { - return; - } - Class type = qualifiable.getClass(); - if (Submodel.class.isAssignableFrom(type)) { - visit((Submodel) qualifiable); - } else if (SubmodelElement.class.isAssignableFrom(type)) { - visit((SubmodelElement) qualifiable); - } - } - - public default void visit(Referable referable) { - if (referable == null) { - return; - } - Class type = referable.getClass(); - if (Identifiable.class.isAssignableFrom(type)) { - visit((Identifiable) referable); - } else if (SubmodelElement.class.isAssignableFrom(type)) { - visit((SubmodelElement) referable); - } - } - - public default void visit(Environment assetAdministrationShellEnvironment) { - } - - public default void visit(AdministrativeInformation administrativeInformation) { - } - - public default void visit(AnnotatedRelationshipElement annotatedRelationshipElement) { - } - - public default void visit(AssetAdministrationShell assetAdministrationShell) { - } - - public default void visit(AssetInformation assetInformation) { - } - - public default void visit(BasicEventElement basicEvent) { - } - - public default void visit(Blob blob) { - } - - public default void visit(Capability capability) { - } - - public default void visit(ConceptDescription conceptDescription) { - } - - public default void visit(DataSpecificationContent dataSpecificationContent) { - } - - public default void visit(Entity entity) { - } - - public default void visit(EventPayload eventMessage) { - } - - public default void visit(Extension extension) { - } - - public default void visit(File file) { - } - - public default void visit(SpecificAssetId identifierKeyValuePair) { - } - - public default void visit(Key key) { - } - - public default void visit(LangStringNameType langString) { - } - - public default void visit(LangStringDefinitionTypeIec61360 langString) { - } - - public default void visit(LangStringTextType langString) { - } - - public default void visit(LangStringPreferredNameTypeIec61360 langString) { - } - - public default void visit(MultiLanguageProperty multiLanguageProperty) { - } - - public default void visit(Operation operation) { - } - - public default void visit(OperationVariable operationVariable) { - } - - public default void visit(Property property) { - } - - public default void visit(Qualifier qualifier) { - } - - public default void visit(Range range) { - } - - public default void visit(Reference reference) { - } - - public default void visit(ReferenceElement referenceElement) { - } - - public default void visit(RelationshipElement relationshipElement) { - } - - public default void visit(Submodel submodel) { - } - - public default void visit(SubmodelElementCollection submodelElementCollection) { - } - - public default void visit(SubmodelElementList submodelElementList) { - } - - public default void visit(Resource resource) { - - } -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * Copyright (c) 2023 SAP SE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.visitor; + +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Blob; +import org.eclipse.digitaltwin.aas4j.v3.model.Capability; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.DataElement; +import org.eclipse.digitaltwin.aas4j.v3.model.DataSpecificationContent; +import org.eclipse.digitaltwin.aas4j.v3.model.Entity; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.EventElement; +import org.eclipse.digitaltwin.aas4j.v3.model.EventPayload; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.File; +import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.HasExtensions; +import org.eclipse.digitaltwin.aas4j.v3.model.HasKind; +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.LangStringDefinitionTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.MultiLanguageProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.Operation; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; +import org.eclipse.digitaltwin.aas4j.v3.model.Property; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; +import org.eclipse.digitaltwin.aas4j.v3.model.Range; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceElement; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +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; + +public interface AssetAdministrationShellElementVisitor { + + public default void visit(DataElement dataElement) { + if (dataElement == null) { + return; + } + Class type = dataElement.getClass(); + if (Property.class.isAssignableFrom(type)) { + visit((Property) dataElement); + } else if (MultiLanguageProperty.class.isAssignableFrom(type)) { + visit((MultiLanguageProperty) dataElement); + } else if (Range.class.isAssignableFrom(type)) { + visit((Range) dataElement); + } else if (ReferenceElement.class.isAssignableFrom(type)) { + visit((ReferenceElement) dataElement); + } else if (File.class.isAssignableFrom(type)) { + visit((File) dataElement); + } else if (Blob.class.isAssignableFrom(type)) { + visit((Blob) dataElement); + } + } + + public default void visit(EventElement event) { + if (event == null) { + return; + } + Class type = event.getClass(); + if (BasicEventElement.class.isAssignableFrom(type)) { + visit((BasicEventElement) event); + } + } + + public default void visit(HasDataSpecification hasDataSpecification) { + if (hasDataSpecification == null) { + return; + } + Class type = hasDataSpecification.getClass(); + if (AssetAdministrationShell.class.isAssignableFrom(type)) { + visit((AssetAdministrationShell) hasDataSpecification); + } else if (Submodel.class.isAssignableFrom(type)) { + visit((Submodel) hasDataSpecification); + } else if (SubmodelElement.class.isAssignableFrom(type)) { + visit((SubmodelElement) hasDataSpecification); + } + + } + + public default void visit(HasExtensions hasExtensions) { + if (hasExtensions == null) { + return; + } + Class type = hasExtensions.getClass(); + if (Referable.class.isAssignableFrom(type)) { + visit((Referable) hasExtensions); + } + } + + public default void visit(HasKind hasKind) { + if (hasKind == null) { + return; + } + Class type = hasKind.getClass(); + if (Submodel.class.isAssignableFrom(type)) { + visit((Submodel) hasKind); + } + } + + public default void visit(HasSemantics hasSemantics) { + if (hasSemantics == null) { + return; + } + Class type = hasSemantics.getClass(); + if (Extension.class.isAssignableFrom(type)) { + visit((Extension) hasSemantics); + } else if (SpecificAssetId.class.isAssignableFrom(type)) { + visit((SpecificAssetId) hasSemantics); + } else if (Submodel.class.isAssignableFrom(type)) { + visit((Submodel) hasSemantics); + } else if (SubmodelElement.class.isAssignableFrom(type)) { + visit((SubmodelElement) hasSemantics); + } else if (Qualifier.class.isAssignableFrom(type)) { + visit((Qualifier) hasSemantics); + } + } + + public default void visit(Identifiable identifiable) { + if (identifiable == null) { + return; + } + Class type = identifiable.getClass(); + if (AssetAdministrationShell.class.isAssignableFrom(type)) { + visit((AssetAdministrationShell) identifiable); + } else if (Submodel.class.isAssignableFrom(type)) { + visit((Submodel) identifiable); + } else if (ConceptDescription.class.isAssignableFrom(type)) { + visit((ConceptDescription) identifiable); + } + } + + public default void visit(SubmodelElement submodelElement) { + if (submodelElement == null) { + return; + } + Class type = submodelElement.getClass(); + if (RelationshipElement.class.isAssignableFrom(type)) { + visit((RelationshipElement) submodelElement); + } else if (DataElement.class.isAssignableFrom(type)) { + visit((DataElement) submodelElement); + } else if (Capability.class.isAssignableFrom(type)) { + visit((Capability) submodelElement); + } else if (SubmodelElementCollection.class.isAssignableFrom(type)) { + visit((SubmodelElementCollection) submodelElement); + } else if (SubmodelElementList.class.isAssignableFrom(type)) { + visit((SubmodelElementList) submodelElement); + } else if (Operation.class.isAssignableFrom(type)) { + visit((Operation) submodelElement); + } else if (EventElement.class.isAssignableFrom(type)) { + visit((EventElement) submodelElement); + } else if (Entity.class.isAssignableFrom(type)) { + visit((Entity) submodelElement); + } + } + + public default void visit(Qualifiable qualifiable) { + if (qualifiable == null) { + return; + } + Class type = qualifiable.getClass(); + if (Submodel.class.isAssignableFrom(type)) { + visit((Submodel) qualifiable); + } else if (SubmodelElement.class.isAssignableFrom(type)) { + visit((SubmodelElement) qualifiable); + } + } + + public default void visit(Referable referable) { + if (referable == null) { + return; + } + Class type = referable.getClass(); + if (Identifiable.class.isAssignableFrom(type)) { + visit((Identifiable) referable); + } else if (SubmodelElement.class.isAssignableFrom(type)) { + visit((SubmodelElement) referable); + } + } + + public default void visit(Environment assetAdministrationShellEnvironment) { + } + + public default void visit(AdministrativeInformation administrativeInformation) { + } + + public default void visit(AnnotatedRelationshipElement annotatedRelationshipElement) { + } + + public default void visit(AssetAdministrationShell assetAdministrationShell) { + } + + public default void visit(AssetInformation assetInformation) { + } + + public default void visit(BasicEventElement basicEvent) { + } + + public default void visit(Blob blob) { + } + + public default void visit(Capability capability) { + } + + public default void visit(ConceptDescription conceptDescription) { + } + + public default void visit(DataSpecificationContent dataSpecificationContent) { + } + + public default void visit(Entity entity) { + } + + public default void visit(EventPayload eventMessage) { + } + + public default void visit(Extension extension) { + } + + public default void visit(File file) { + } + + public default void visit(SpecificAssetId identifierKeyValuePair) { + } + + public default void visit(Key key) { + } + + public default void visit(LangStringNameType langString) { + } + + public default void visit(LangStringDefinitionTypeIec61360 langString) { + } + + public default void visit(LangStringTextType langString) { + } + + public default void visit(LangStringPreferredNameTypeIec61360 langString) { + } + + public default void visit(MultiLanguageProperty multiLanguageProperty) { + } + + public default void visit(Operation operation) { + } + + public default void visit(OperationVariable operationVariable) { + } + + public default void visit(Property property) { + } + + public default void visit(Qualifier qualifier) { + } + + public default void visit(Range range) { + } + + public default void visit(Reference reference) { + } + + public default void visit(ReferenceElement referenceElement) { + } + + public default void visit(RelationshipElement relationshipElement) { + } + + public default void visit(Submodel submodel) { + } + + public default void visit(SubmodelElementCollection submodelElementCollection) { + } + + public default void visit(SubmodelElementList submodelElementList) { + } + + public default void visit(Resource resource) { + + } +} diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementWalkerVisitor.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementWalkerVisitor.java index f373b8620..9988127be 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementWalkerVisitor.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/internal/visitor/AssetAdministrationShellElementWalkerVisitor.java @@ -1,339 +1,339 @@ -/* - * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * Copyright (c) 2023 SAP SE - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.visitor; - -import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.Entity; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.HasExtensions; -import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; -import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.MultiLanguageProperty; -import org.eclipse.digitaltwin.aas4j.v3.model.Operation; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; -import org.eclipse.digitaltwin.aas4j.v3.model.Property; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifiable; -import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceElement; -import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; -import org.eclipse.digitaltwin.aas4j.v3.model.Resource; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; - -public interface AssetAdministrationShellElementWalkerVisitor extends AssetAdministrationShellElementVisitor { - - @Override - public default void visit(AnnotatedRelationshipElement annotatedRelationshipElement) { - if (annotatedRelationshipElement == null) { - return; - } - annotatedRelationshipElement.getAnnotations().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(annotatedRelationshipElement); - } - - @Override - public default void visit(AssetAdministrationShell assetAdministrationShell) { - if (assetAdministrationShell == null) { - return; - } - visit(assetAdministrationShell.getDerivedFrom()); - visit(assetAdministrationShell.getAssetInformation()); - assetAdministrationShell.getSubmodels().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(assetAdministrationShell); - } - - @Override - public default void visit(AssetInformation assetInformation) { - if (assetInformation == null) { - return; - } - assetInformation.getSpecificAssetIds().forEach(x -> visit(x)); - visit(assetInformation.getDefaultThumbnail()); - AssetAdministrationShellElementVisitor.super.visit(assetInformation); - } - - @Override - public default void visit(Resource resource) { - if (resource == null) { - return; - } - AssetAdministrationShellElementVisitor.super.visit(resource); - } - - @Override - public default void visit(BasicEventElement basicEvent) { - if (basicEvent == null) { - return; - } - visit(basicEvent.getObserved()); - AssetAdministrationShellElementVisitor.super.visit(basicEvent); - } - - @Override - public default void visit(ConceptDescription conceptDescription) { - if (conceptDescription == null) { - return; - } - conceptDescription.getIsCaseOf().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(conceptDescription); - } - - @Override - public default void visit(HasDataSpecification hasDataSpecification) { - if (hasDataSpecification == null) { - return; - } - //hasDataSpecification.getEmbeddedDataSpecifications().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(hasDataSpecification); - } - - @Override - public default void visit(HasExtensions hasExtensions) { - if (hasExtensions == null) { - return; - } - hasExtensions.getExtensions().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(hasExtensions); - } - - @Override - public default void visit(HasSemantics hasSemantics) { - if (hasSemantics == null) { - return; - } - visit(hasSemantics.getSemanticId()); - hasSemantics.getSupplementalSemanticIds().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(hasSemantics); - } - - @Override - public default void visit(Identifiable identifiable) { - if (identifiable == null) { - return; - } - visit(identifiable.getAdministration()); - AssetAdministrationShellElementVisitor.super.visit(identifiable); - } - - @Override - public default void visit(SpecificAssetId specificAssetId) { - if (specificAssetId == null) { - return; - } - visit(specificAssetId.getExternalSubjectId()); - AssetAdministrationShellElementVisitor.super.visit(specificAssetId); - } - - @Override - public default void visit(MultiLanguageProperty multiLanguageProperty) { - if (multiLanguageProperty == null) { - return; - } - multiLanguageProperty.getValue().forEach(x -> visit(x)); - visit(multiLanguageProperty.getValueId()); - AssetAdministrationShellElementVisitor.super.visit(multiLanguageProperty); - } - - @Override - public default void visit(OperationVariable operationVariable) { - if (operationVariable == null) { - return; - } - visit(operationVariable.getValue()); - AssetAdministrationShellElementVisitor.super.visit(operationVariable); - } - - @Override - public default void visit(Property property) { - if (property == null) { - return; - } - visit(property.getValueId()); - AssetAdministrationShellElementVisitor.super.visit(property); - } - - @Override - public default void visit(Qualifiable qualifiable) { - if (qualifiable == null) { - return; - } - qualifiable.getQualifiers().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(qualifiable); - } - - @Override - public default void visit(Qualifier qualifier) { - if (qualifier == null) { - return; - } - visit(qualifier.getValueId()); - AssetAdministrationShellElementVisitor.super.visit(qualifier); - } - - @Override - public default void visit(Referable referable) { - if (referable == null) { - return; - } - referable.getDescription().forEach(x -> visit(x)); - referable.getDisplayName().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(referable); - } - - @Override - public default void visit(LangStringNameType langString) { - if (langString == null) { - return; - } - AssetAdministrationShellElementVisitor.super.visit(langString); - } - - @Override - public default void visit(LangStringPreferredNameTypeIec61360 langString) { - if (langString == null) { - return; - } - AssetAdministrationShellElementVisitor.super.visit(langString); - } - - @Override - public default void visit(LangStringDefinitionTypeIec61360 langString) { - if (langString == null) { - return; - } - AssetAdministrationShellElementVisitor.super.visit(langString); - } - - @Override - public default void visit(LangStringTextType langString) { - if (langString == null) { - return; - } - AssetAdministrationShellElementVisitor.super.visit(langString); - } - - @Override - public default void visit(Reference reference) { - if (reference == null) { - return; - } - reference.getKeys().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(reference); - } - - @Override - public default void visit(ReferenceElement referenceElement) { - if (referenceElement == null) { - return; - } - visit(referenceElement.getValue()); - AssetAdministrationShellElementVisitor.super.visit(referenceElement); - } - - @Override - public default void visit(RelationshipElement relationshipElement) { - if (relationshipElement == null) { - return; - } - visit(relationshipElement.getFirst()); - visit(relationshipElement.getSecond()); - AssetAdministrationShellElementVisitor.super.visit(relationshipElement); - } - - @Override - public default void visit(Entity entity) { - if (entity == null) { - return; - } - entity.getSpecificAssetIds().forEach(x -> visit(x)); - entity.getStatements().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(entity); - } - - @Override - public default void visit(Extension extension) { - if (extension == null) { - return; - } - extension.getRefersTo().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(extension); - } - - @Override - public default void visit(Environment assetAdministrationShellEnvironment) { - if (assetAdministrationShellEnvironment == null) { - return; - } - assetAdministrationShellEnvironment.getAssetAdministrationShells().forEach(x -> visit(x)); - assetAdministrationShellEnvironment.getConceptDescriptions().forEach(x -> visit(x)); - assetAdministrationShellEnvironment.getSubmodels().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(assetAdministrationShellEnvironment); - } - - @Override - public default void visit(Submodel submodel) { - if (submodel == null) { - return; - } - submodel.getSubmodelElements().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(submodel); - } - - @Override - public default void visit(SubmodelElementCollection submodelElementCollection) { - if (submodelElementCollection == null) { - return; - } - submodelElementCollection.getValue().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(submodelElementCollection); - } - - @Override - public default void visit(SubmodelElementList submodelElementList) { - if (submodelElementList == null) { - return; - } - submodelElementList.getValue().forEach(x -> visit(x)); - AssetAdministrationShellElementVisitor.super.visit(submodelElementList); - } - - @Override - public default void visit(Operation operation) { - if (operation == null) { - return; - } - operation.getInputVariables().forEach(x -> visit(x.getValue())); - operation.getInoutputVariables().forEach(x -> visit(x.getValue())); - operation.getOutputVariables().forEach(x -> visit(x.getValue())); - AssetAdministrationShellElementVisitor.super.visit(operation); - } - -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * Copyright (c) 2023 SAP SE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.visitor; + +import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.Entity; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.HasDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.HasExtensions; +import org.eclipse.digitaltwin.aas4j.v3.model.HasSemantics; +import org.eclipse.digitaltwin.aas4j.v3.model.Identifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringDefinitionTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringPreferredNameTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.MultiLanguageProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.Operation; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; +import org.eclipse.digitaltwin.aas4j.v3.model.Property; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifiable; +import org.eclipse.digitaltwin.aas4j.v3.model.Qualifier; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceElement; +import org.eclipse.digitaltwin.aas4j.v3.model.RelationshipElement; +import org.eclipse.digitaltwin.aas4j.v3.model.Resource; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; + +public interface AssetAdministrationShellElementWalkerVisitor extends AssetAdministrationShellElementVisitor { + + @Override + public default void visit(AnnotatedRelationshipElement annotatedRelationshipElement) { + if (annotatedRelationshipElement == null) { + return; + } + annotatedRelationshipElement.getAnnotations().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(annotatedRelationshipElement); + } + + @Override + public default void visit(AssetAdministrationShell assetAdministrationShell) { + if (assetAdministrationShell == null) { + return; + } + visit(assetAdministrationShell.getDerivedFrom()); + visit(assetAdministrationShell.getAssetInformation()); + assetAdministrationShell.getSubmodels().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(assetAdministrationShell); + } + + @Override + public default void visit(AssetInformation assetInformation) { + if (assetInformation == null) { + return; + } + assetInformation.getSpecificAssetIds().forEach(x -> visit(x)); + visit(assetInformation.getDefaultThumbnail()); + AssetAdministrationShellElementVisitor.super.visit(assetInformation); + } + + @Override + public default void visit(Resource resource) { + if (resource == null) { + return; + } + AssetAdministrationShellElementVisitor.super.visit(resource); + } + + @Override + public default void visit(BasicEventElement basicEvent) { + if (basicEvent == null) { + return; + } + visit(basicEvent.getObserved()); + AssetAdministrationShellElementVisitor.super.visit(basicEvent); + } + + @Override + public default void visit(ConceptDescription conceptDescription) { + if (conceptDescription == null) { + return; + } + conceptDescription.getIsCaseOf().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(conceptDescription); + } + + @Override + public default void visit(HasDataSpecification hasDataSpecification) { + if (hasDataSpecification == null) { + return; + } + //hasDataSpecification.getEmbeddedDataSpecifications().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(hasDataSpecification); + } + + @Override + public default void visit(HasExtensions hasExtensions) { + if (hasExtensions == null) { + return; + } + hasExtensions.getExtensions().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(hasExtensions); + } + + @Override + public default void visit(HasSemantics hasSemantics) { + if (hasSemantics == null) { + return; + } + visit(hasSemantics.getSemanticId()); + hasSemantics.getSupplementalSemanticIds().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(hasSemantics); + } + + @Override + public default void visit(Identifiable identifiable) { + if (identifiable == null) { + return; + } + visit(identifiable.getAdministration()); + AssetAdministrationShellElementVisitor.super.visit(identifiable); + } + + @Override + public default void visit(SpecificAssetId specificAssetId) { + if (specificAssetId == null) { + return; + } + visit(specificAssetId.getExternalSubjectId()); + AssetAdministrationShellElementVisitor.super.visit(specificAssetId); + } + + @Override + public default void visit(MultiLanguageProperty multiLanguageProperty) { + if (multiLanguageProperty == null) { + return; + } + multiLanguageProperty.getValue().forEach(x -> visit(x)); + visit(multiLanguageProperty.getValueId()); + AssetAdministrationShellElementVisitor.super.visit(multiLanguageProperty); + } + + @Override + public default void visit(OperationVariable operationVariable) { + if (operationVariable == null) { + return; + } + visit(operationVariable.getValue()); + AssetAdministrationShellElementVisitor.super.visit(operationVariable); + } + + @Override + public default void visit(Property property) { + if (property == null) { + return; + } + visit(property.getValueId()); + AssetAdministrationShellElementVisitor.super.visit(property); + } + + @Override + public default void visit(Qualifiable qualifiable) { + if (qualifiable == null) { + return; + } + qualifiable.getQualifiers().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(qualifiable); + } + + @Override + public default void visit(Qualifier qualifier) { + if (qualifier == null) { + return; + } + visit(qualifier.getValueId()); + AssetAdministrationShellElementVisitor.super.visit(qualifier); + } + + @Override + public default void visit(Referable referable) { + if (referable == null) { + return; + } + referable.getDescription().forEach(x -> visit(x)); + referable.getDisplayName().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(referable); + } + + @Override + public default void visit(LangStringNameType langString) { + if (langString == null) { + return; + } + AssetAdministrationShellElementVisitor.super.visit(langString); + } + + @Override + public default void visit(LangStringPreferredNameTypeIec61360 langString) { + if (langString == null) { + return; + } + AssetAdministrationShellElementVisitor.super.visit(langString); + } + + @Override + public default void visit(LangStringDefinitionTypeIec61360 langString) { + if (langString == null) { + return; + } + AssetAdministrationShellElementVisitor.super.visit(langString); + } + + @Override + public default void visit(LangStringTextType langString) { + if (langString == null) { + return; + } + AssetAdministrationShellElementVisitor.super.visit(langString); + } + + @Override + public default void visit(Reference reference) { + if (reference == null) { + return; + } + reference.getKeys().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(reference); + } + + @Override + public default void visit(ReferenceElement referenceElement) { + if (referenceElement == null) { + return; + } + visit(referenceElement.getValue()); + AssetAdministrationShellElementVisitor.super.visit(referenceElement); + } + + @Override + public default void visit(RelationshipElement relationshipElement) { + if (relationshipElement == null) { + return; + } + visit(relationshipElement.getFirst()); + visit(relationshipElement.getSecond()); + AssetAdministrationShellElementVisitor.super.visit(relationshipElement); + } + + @Override + public default void visit(Entity entity) { + if (entity == null) { + return; + } + entity.getSpecificAssetIds().forEach(x -> visit(x)); + entity.getStatements().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(entity); + } + + @Override + public default void visit(Extension extension) { + if (extension == null) { + return; + } + extension.getRefersTo().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(extension); + } + + @Override + public default void visit(Environment assetAdministrationShellEnvironment) { + if (assetAdministrationShellEnvironment == null) { + return; + } + assetAdministrationShellEnvironment.getAssetAdministrationShells().forEach(x -> visit(x)); + assetAdministrationShellEnvironment.getConceptDescriptions().forEach(x -> visit(x)); + assetAdministrationShellEnvironment.getSubmodels().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(assetAdministrationShellEnvironment); + } + + @Override + public default void visit(Submodel submodel) { + if (submodel == null) { + return; + } + submodel.getSubmodelElements().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(submodel); + } + + @Override + public default void visit(SubmodelElementCollection submodelElementCollection) { + if (submodelElementCollection == null) { + return; + } + submodelElementCollection.getValue().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(submodelElementCollection); + } + + @Override + public default void visit(SubmodelElementList submodelElementList) { + if (submodelElementList == null) { + return; + } + submodelElementList.getValue().forEach(x -> visit(x)); + AssetAdministrationShellElementVisitor.super.visit(submodelElementList); + } + + @Override + public default void visit(Operation operation) { + if (operation == null) { + return; + } + operation.getInputVariables().forEach(x -> visit(x.getValue())); + operation.getInoutputVariables().forEach(x -> visit(x.getValue())); + operation.getOutputVariables().forEach(x -> visit(x.getValue())); + AssetAdministrationShellElementVisitor.super.visit(operation); + } + +} 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..1b0f814a2 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,418 +1,418 @@ -/* - * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; - -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.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.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; -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"); - - private AasUtils() { - } - - /** - * Formats a Reference as string - * - * @param reference Reference to serialize - * @return string representation of the reference for serialization, null if reference is null - */ - public static String asString(Reference reference) { - return asString(reference, true, true); - } - - /** - * Serializes a {@link Reference} to string. - * - * @param reference the reference to serialize - * @param includeReferenceType if reference type information should be included - * @param includeReferredSemanticId if referred semanticId should be included - * @return the serialized reference or null if reference is null, reference.keys is null or reference does not - * contain any keys - */ - public static String asString(Reference reference, boolean includeReferenceType, boolean includeReferredSemanticId) { - if (Objects.isNull(reference) || Objects.isNull(reference.getKeys()) || reference.getKeys().isEmpty()) { - return null; - } - String result = ""; - if (includeReferenceType) { - String referredSemanticId = includeReferredSemanticId - ? asString(reference.getReferredSemanticId(), includeReferenceType, false) - : ""; - result = String.format("[%s%s]", - asString(reference.getType()), - (Objects.nonNull(referredSemanticId) && !referredSemanticId.isBlank()) ? String.format("- %s -", referredSemanticId) - : ""); - } - result += reference.getKeys().stream() - .map(x -> String.format("(%s)%s", - EnumSerializer.serializeEnumName(x.getType().name()), - x.getValue())) - .collect(Collectors.joining(", ")); - return result; - } - - private static String asString(ReferenceTypes referenceType) { - if (!REFERENCE_TYPE_REPRESENTATION.containsKey(referenceType)) { - throw new IllegalArgumentException(String.format("Unsupported reference type '%s'", referenceType)); - } - return REFERENCE_TYPE_REPRESENTATION.get(referenceType); - } - - /** - * Creates a reference for an Identifiable instance using provided implementation types for reference and key - * - * @param identifiable the identifiable to create the reference for - * @param referenceType implementation type of Reference interface - * @param keyType implementation type of Key interface - * @return a reference representing the identifiable - */ - public static Reference toReference(Identifiable identifiable, Class referenceType, Class keyType) { - try { - Reference reference = referenceType.getConstructor().newInstance(); - reference.setType(ReferenceTypes.MODEL_REFERENCE); - Key key = keyType.getConstructor().newInstance(); - key.setType(referableToKeyType(identifiable)); - key.setValue(identifiable.getId()); - reference.setKeys(List.of(key)); - return reference; - } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); - } - } - - /** - * Creates a reference for an Identifiable instance - * - * @param identifiable the identifiable to create the reference for - * @return a reference representing the identifiable - */ - public static Reference toReference(Identifiable identifiable) { - return toReference(identifiable, ReflectionHelper.getDefaultImplementation(Reference.class), ReflectionHelper.getDefaultImplementation(Key.class)); - } - - /** - * Gets the KeyElements type matching the provided Referable - * - * @param referable The referable to convert to KeyElements type - * @return the most specific KeyElements type representing the Referable, i.e. abstract types like SUBMODEL_ELEMENT - * or DATA_ELEMENT are never returned; null if there is no corresponding KeyElements type - */ - public static KeyTypes referableToKeyType(Referable referable) { - Class aasInterface = ReflectionHelper.getAasInterface(referable.getClass()); - if (aasInterface != null) { - return KeyTypes.valueOf(EnumDeserializer.deserializeEnumName(aasInterface.getSimpleName())); - } - return null; - } - - /** - * Gets a Java interface representing the type provided by key. - * - * @param key The KeyElements type - * @return a Java interface representing the provided KeyElements type or null if no matching Class/interface could - * be found. It also returns abstract types like SUBMODEL_ELEMENT or DATA_ELEMENT - */ - private static Class keyTypeToClass(KeyTypes key) { - return Stream.concat(ReflectionHelper.INTERFACES.stream(), ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream()) - .filter(x -> x.getSimpleName().equals(EnumSerializer.serializeEnumName(key.name()))) - .findAny() - .orElse(null); - } - - /** - * Creates a reference for an element given a potential parent using provided implementation types for reference and - * key - * - * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise - * result will always be null - * @param element the element to create a reference for - * @param referenceType implementation type of Reference interface - * @param keyType implementation type of Key interface - * - * @return A reference representing the element or null if either element is null or parent is null and element not - * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only - * contain one key pointing directly to the element. - */ - public static Reference toReference(Reference parent, Referable element, Class referenceType, Class keyType) { - if (element == null) { - return null; - } else if (Identifiable.class.isAssignableFrom(element.getClass())) { - return toReference((Identifiable) element, referenceType, keyType); - } else { - Reference result = clone(parent, referenceType, keyType); - if (result != null) { - try { - Key newKey = keyType.getConstructor().newInstance(); - newKey.setType(AasUtils.referableToKeyType(element)); - newKey.setValue(element.getIdShort()); - result.getKeys().add(newKey); - } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); - } - } - return result; - } - } - - /** - * Creates a reference for an element given a potential parent - * - * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise - * result will always be null - * @param element the element to create a reference for - * @return A reference representing the element or null if either element is null or parent is null and element not - * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only - * contain one key pointing directly to the element. - */ - public static Reference toReference(Reference parent, Referable element) { - return toReference(parent, - element, - ReflectionHelper.getDefaultImplementation(Reference.class), - ReflectionHelper.getDefaultImplementation(Key.class)); - } - - /** - * Checks if two references are refering to the same element ignoring referredSemanticId. - * - * @param ref1 reference 1 - * @param ref2 reference 2 - * @return returns true if both references are refering to the same element, otherwise false - */ - public static boolean sameAs(Reference ref1, Reference ref2) { - return sameAs(ref1, ref2, false); - } - - /** - * Checks if two references are referring to the same element. - * - * @param ref1 reference 1 - * @param ref2 reference 2 - * @param compareReferredSemanticId true if referredSemanticId should be compared, false otherwise - * @return returns true if both references are referring to the same element, otherwise false - */ - public static boolean sameAs(Reference ref1, Reference ref2, boolean compareReferredSemanticId) { - boolean ref1Empty = ref1 == null || ref1.getKeys() == null || ref1.getKeys().isEmpty(); - boolean ref2Empty = ref2 == null || ref2.getKeys() == null || ref2.getKeys().isEmpty(); - if (ref1Empty != ref2Empty) { - return false; - } - if (ref1.getType() != ref2.getType()) { - return false; - } - if (compareReferredSemanticId && !sameAs(ref1.getReferredSemanticId(), ref2.getReferredSemanticId())) { - return false; - } - if (ref1Empty && ref2Empty) { - return true; - } - if (ref1.getKeys().size() != ref2.getKeys().size()) { - return false; - } - for (int i = 0; i < ref1.getKeys().size(); i++) { - Key key1 = ref1.getKeys().get(ref1.getKeys().size() - (i + 1)); - Key key2 = ref2.getKeys().get(ref2.getKeys().size() - (i + 1)); - if (Objects.isNull(key1) != Objects.isNull(key2)) { - return false; - } - if (Objects.isNull(key1)) { - return true; - } - if (!Objects.equals(key1.getValue(), key2.getValue())) { - return false; - } - } - return true; - } - - /** - * Creates a deep-copy clone of a reference using provided implementation types for reference and key - * - * @param reference the reference to clone - * @param referenceType implementation type of Reference interface - * @param keyType implementation type of Key interface - * - * @return the cloned reference - */ - private static Reference clone(Reference reference, Class referenceType, Class keyType) { - if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) { - return null; - } - try { - Reference result = referenceType.getConstructor().newInstance(); - List newKeys = new ArrayList<>(); - result.setType(reference.getType()); - for (Key key : reference.getKeys()) { - Key newKey = keyType.getConstructor().newInstance(); - newKey.setType(key.getType()); - newKey.setValue(key.getValue()); - newKeys.add(newKey); - } - result.setKeys(newKeys); - return result; - } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); - } - } - - /** - * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available, - * null otherwise - * - * - * @param reference The reference to resolve - * @param env The AssetAdministrationShellEnvironment to resolve the reference against - * @return returns an instance of T if the reference could successfully be resolved, otherwise null - * @throws IllegalArgumentException if something goes wrong while resolving - */ - public static Referable resolve(Reference reference, Environment env) { - return resolve(reference, env, Referable.class); - } - - /** - * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available, - * null otherwise - * - * @param sub-type of Referable of the targeted type. If unknown use Referable.class - * @param reference The reference to resolve - * @param env The AssetAdministrationShellEnvironment to resolve the reference against - * @param type desired return type, use Referable.class is unknwon/not needed - * @return returns an instance of T if the reference could successfully be resolved, otherwise null - * @throws IllegalArgumentException if something goes wrong while resolving - */ - @SuppressWarnings("unchecked") - public static T resolve(Reference reference, Environment env, Class type) { - if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) { - return null; - } - GetChildrenVisitor findChildrenVisitor = new GetChildrenVisitor(env); - findChildrenVisitor.visit(env); - Referable current = null; - for (int i = 0; i < reference.getKeys().size(); i++) { - Key key = reference.getKeys().get(i); - try { - int index = Integer.parseInt(key.getValue()); - if (Objects.isNull(current) || !SubmodelElementList.class.isAssignableFrom(current.getClass())) { - throw new IllegalArgumentException("reference uses index notation on an element that is not a SubmodelElementList"); - } - List list = ((SubmodelElementList) current).getValue(); - if (list.size() <= index) { - throw new IllegalArgumentException(String.format( - "index notation out of bounds (list size: %s, requested index: %s)", - list.size(), - index)); - } - current = list.get(index); - } catch (NumberFormatException e) { - current = findChildrenVisitor.getChildren().stream() - .filter(x -> Objects.equals(key.getValue(), GetIdentifierVisitor.getIdentifier(x))) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException(String.format( - "unable to resolve reference '%s' as element '%s' does not exist", - asString(reference), - key.getValue()))); - } - findChildrenVisitor.reset(); - findChildrenVisitor.visit(current); - } - if (current == null) { - return null; - } - if (!type.isAssignableFrom(current.getClass())) { - throw new IllegalArgumentException(String.format( - "reference '%s' could not be resolved as target type is not assignable from actual type (target: %s, actual: %s)", - asString(reference), - type.getName(), - current.getClass().getName())); - } - return type.cast(current); - } - - /** - * Gets a list of all properties defined for a class implementing at least one AAS interface. - * - * @param type A class implementing at least one AAS interface. If it is does not implement any AAS interface the - * result will be an empty list - * @return a list of all properties defined in any of AAS interface implemented by type. If type does not implement - * any AAS interface an empty list is returned. - */ - private static List getAasProperties(Class type) { - Class aasType = ReflectionHelper.getAasInterface(type); - if (aasType == null) { - aasType = ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream() - .filter(x -> x.isAssignableFrom(type)) - .map(x -> TypeToken.of(x)) - .sorted(new MostSpecificTypeTokenComparator()) - .findFirst().get() - .getRawType(); - } - Set> types = new HashSet<>(); - if (aasType != null) { - types.add(aasType); - types.addAll(ReflectionHelper.getSuperTypes(aasType, true)); - } - return types.stream() - .flatMap(x -> { - try { - return Stream.of(Introspector.getBeanInfo(x).getPropertyDescriptors()); - } catch (IntrospectionException ex) { - log.warn("error finding properties of class '{}'", type, ex); - } - return Stream.empty(); - }) - .sorted(Comparator.comparing(x -> x.getName())) - .collect(Collectors.toList()); - } -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; + +import java.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.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; +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"); + + private AasUtils() { + } + + /** + * Formats a Reference as string + * + * @param reference Reference to serialize + * @return string representation of the reference for serialization, null if reference is null + */ + public static String asString(Reference reference) { + return asString(reference, true, true); + } + + /** + * Serializes a {@link Reference} to string. + * + * @param reference the reference to serialize + * @param includeReferenceType if reference type information should be included + * @param includeReferredSemanticId if referred semanticId should be included + * @return the serialized reference or null if reference is null, reference.keys is null or reference does not + * contain any keys + */ + public static String asString(Reference reference, boolean includeReferenceType, boolean includeReferredSemanticId) { + if (Objects.isNull(reference) || Objects.isNull(reference.getKeys()) || reference.getKeys().isEmpty()) { + return null; + } + String result = ""; + if (includeReferenceType) { + String referredSemanticId = includeReferredSemanticId + ? asString(reference.getReferredSemanticId(), includeReferenceType, false) + : ""; + result = String.format("[%s%s]", + asString(reference.getType()), + (Objects.nonNull(referredSemanticId) && !referredSemanticId.isBlank()) ? String.format("- %s -", referredSemanticId) + : ""); + } + result += reference.getKeys().stream() + .map(x -> String.format("(%s)%s", + EnumSerializer.serializeEnumName(x.getType().name()), + x.getValue())) + .collect(Collectors.joining(", ")); + return result; + } + + private static String asString(ReferenceTypes referenceType) { + if (!REFERENCE_TYPE_REPRESENTATION.containsKey(referenceType)) { + throw new IllegalArgumentException(String.format("Unsupported reference type '%s'", referenceType)); + } + return REFERENCE_TYPE_REPRESENTATION.get(referenceType); + } + + /** + * Creates a reference for an Identifiable instance using provided implementation types for reference and key + * + * @param identifiable the identifiable to create the reference for + * @param referenceType implementation type of Reference interface + * @param keyType implementation type of Key interface + * @return a reference representing the identifiable + */ + public static Reference toReference(Identifiable identifiable, Class referenceType, Class keyType) { + try { + Reference reference = referenceType.getConstructor().newInstance(); + reference.setType(ReferenceTypes.MODEL_REFERENCE); + Key key = keyType.getConstructor().newInstance(); + key.setType(referableToKeyType(identifiable)); + key.setValue(identifiable.getId()); + reference.setKeys(List.of(key)); + return reference; + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); + } + } + + /** + * Creates a reference for an Identifiable instance + * + * @param identifiable the identifiable to create the reference for + * @return a reference representing the identifiable + */ + public static Reference toReference(Identifiable identifiable) { + return toReference(identifiable, ReflectionHelper.getDefaultImplementation(Reference.class), ReflectionHelper.getDefaultImplementation(Key.class)); + } + + /** + * Gets the KeyElements type matching the provided Referable + * + * @param referable The referable to convert to KeyElements type + * @return the most specific KeyElements type representing the Referable, i.e. abstract types like SUBMODEL_ELEMENT + * or DATA_ELEMENT are never returned; null if there is no corresponding KeyElements type + */ + public static KeyTypes referableToKeyType(Referable referable) { + Class aasInterface = ReflectionHelper.getAasInterface(referable.getClass()); + if (aasInterface != null) { + return KeyTypes.valueOf(EnumDeserializer.deserializeEnumName(aasInterface.getSimpleName())); + } + return null; + } + + /** + * Gets a Java interface representing the type provided by key. + * + * @param key The KeyElements type + * @return a Java interface representing the provided KeyElements type or null if no matching Class/interface could + * be found. It also returns abstract types like SUBMODEL_ELEMENT or DATA_ELEMENT + */ + private static Class keyTypeToClass(KeyTypes key) { + return Stream.concat(ReflectionHelper.INTERFACES.stream(), ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream()) + .filter(x -> x.getSimpleName().equals(EnumSerializer.serializeEnumName(key.name()))) + .findAny() + .orElse(null); + } + + /** + * Creates a reference for an element given a potential parent using provided implementation types for reference and + * key + * + * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise + * result will always be null + * @param element the element to create a reference for + * @param referenceType implementation type of Reference interface + * @param keyType implementation type of Key interface + * + * @return A reference representing the element or null if either element is null or parent is null and element not + * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only + * contain one key pointing directly to the element. + */ + public static Reference toReference(Reference parent, Referable element, Class referenceType, Class keyType) { + if (element == null) { + return null; + } else if (Identifiable.class.isAssignableFrom(element.getClass())) { + return toReference((Identifiable) element, referenceType, keyType); + } else { + Reference result = clone(parent, referenceType, keyType); + if (result != null) { + try { + Key newKey = keyType.getConstructor().newInstance(); + newKey.setType(AasUtils.referableToKeyType(element)); + newKey.setValue(element.getIdShort()); + result.getKeys().add(newKey); + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); + } + } + return result; + } + } + + /** + * Creates a reference for an element given a potential parent + * + * @param parent Reference to the parent. Can only be null when element is instance of Identifiable, otherwise + * result will always be null + * @param element the element to create a reference for + * @return A reference representing the element or null if either element is null or parent is null and element not + * an instance of Identifiable. In case element is an instance of Identifiable, the returned reference will only + * contain one key pointing directly to the element. + */ + public static Reference toReference(Reference parent, Referable element) { + return toReference(parent, + element, + ReflectionHelper.getDefaultImplementation(Reference.class), + ReflectionHelper.getDefaultImplementation(Key.class)); + } + + /** + * Checks if two references are refering to the same element ignoring referredSemanticId. + * + * @param ref1 reference 1 + * @param ref2 reference 2 + * @return returns true if both references are refering to the same element, otherwise false + */ + public static boolean sameAs(Reference ref1, Reference ref2) { + return sameAs(ref1, ref2, false); + } + + /** + * Checks if two references are referring to the same element. + * + * @param ref1 reference 1 + * @param ref2 reference 2 + * @param compareReferredSemanticId true if referredSemanticId should be compared, false otherwise + * @return returns true if both references are referring to the same element, otherwise false + */ + public static boolean sameAs(Reference ref1, Reference ref2, boolean compareReferredSemanticId) { + boolean ref1Empty = ref1 == null || ref1.getKeys() == null || ref1.getKeys().isEmpty(); + boolean ref2Empty = ref2 == null || ref2.getKeys() == null || ref2.getKeys().isEmpty(); + if (ref1Empty != ref2Empty) { + return false; + } + if (ref1.getType() != ref2.getType()) { + return false; + } + if (compareReferredSemanticId && !sameAs(ref1.getReferredSemanticId(), ref2.getReferredSemanticId())) { + return false; + } + if (ref1Empty && ref2Empty) { + return true; + } + if (ref1.getKeys().size() != ref2.getKeys().size()) { + return false; + } + for (int i = 0; i < ref1.getKeys().size(); i++) { + Key key1 = ref1.getKeys().get(ref1.getKeys().size() - (i + 1)); + Key key2 = ref2.getKeys().get(ref2.getKeys().size() - (i + 1)); + if (Objects.isNull(key1) != Objects.isNull(key2)) { + return false; + } + if (Objects.isNull(key1)) { + return true; + } + if (!Objects.equals(key1.getValue(), key2.getValue())) { + return false; + } + } + return true; + } + + /** + * Creates a deep-copy clone of a reference using provided implementation types for reference and key + * + * @param reference the reference to clone + * @param referenceType implementation type of Reference interface + * @param keyType implementation type of Key interface + * + * @return the cloned reference + */ + private static Reference clone(Reference reference, Class referenceType, Class keyType) { + if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) { + return null; + } + try { + Reference result = referenceType.getConstructor().newInstance(); + List newKeys = new ArrayList<>(); + result.setType(reference.getType()); + for (Key key : reference.getKeys()) { + Key newKey = keyType.getConstructor().newInstance(); + newKey.setType(key.getType()); + newKey.setValue(key.getValue()); + newKeys.add(newKey); + } + result.setKeys(newKeys); + return result; + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + throw new IllegalArgumentException("error parsing reference - could not instantiate reference type", ex); + } + } + + /** + * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available, + * null otherwise + * + * + * @param reference The reference to resolve + * @param env The AssetAdministrationShellEnvironment to resolve the reference against + * @return returns an instance of T if the reference could successfully be resolved, otherwise null + * @throws IllegalArgumentException if something goes wrong while resolving + */ + public static Referable resolve(Reference reference, Environment env) { + return resolve(reference, env, Referable.class); + } + + /** + * Resolves a Reference within an AssetAdministrationShellEnvironment and returns the targeted object if available, + * null otherwise + * + * @param sub-type of Referable of the targeted type. If unknown use Referable.class + * @param reference The reference to resolve + * @param env The AssetAdministrationShellEnvironment to resolve the reference against + * @param type desired return type, use Referable.class is unknwon/not needed + * @return returns an instance of T if the reference could successfully be resolved, otherwise null + * @throws IllegalArgumentException if something goes wrong while resolving + */ + @SuppressWarnings("unchecked") + public static T resolve(Reference reference, Environment env, Class type) { + if (reference == null || reference.getKeys() == null || reference.getKeys().isEmpty()) { + return null; + } + GetChildrenVisitor findChildrenVisitor = new GetChildrenVisitor(env); + findChildrenVisitor.visit(env); + Referable current = null; + for (int i = 0; i < reference.getKeys().size(); i++) { + Key key = reference.getKeys().get(i); + try { + int index = Integer.parseInt(key.getValue()); + if (Objects.isNull(current) || !SubmodelElementList.class.isAssignableFrom(current.getClass())) { + throw new IllegalArgumentException("reference uses index notation on an element that is not a SubmodelElementList"); + } + List list = ((SubmodelElementList) current).getValue(); + if (list.size() <= index) { + throw new IllegalArgumentException(String.format( + "index notation out of bounds (list size: %s, requested index: %s)", + list.size(), + index)); + } + current = list.get(index); + } catch (NumberFormatException e) { + current = findChildrenVisitor.getChildren().stream() + .filter(x -> Objects.equals(key.getValue(), GetIdentifierVisitor.getIdentifier(x))) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException(String.format( + "unable to resolve reference '%s' as element '%s' does not exist", + asString(reference), + key.getValue()))); + } + findChildrenVisitor.reset(); + findChildrenVisitor.visit(current); + } + if (current == null) { + return null; + } + if (!type.isAssignableFrom(current.getClass())) { + throw new IllegalArgumentException(String.format( + "reference '%s' could not be resolved as target type is not assignable from actual type (target: %s, actual: %s)", + asString(reference), + type.getName(), + current.getClass().getName())); + } + return type.cast(current); + } + + /** + * Gets a list of all properties defined for a class implementing at least one AAS interface. + * + * @param type A class implementing at least one AAS interface. If it is does not implement any AAS interface the + * result will be an empty list + * @return a list of all properties defined in any of AAS interface implemented by type. If type does not implement + * any AAS interface an empty list is returned. + */ + private static List getAasProperties(Class type) { + Class aasType = ReflectionHelper.getAasInterface(type); + if (aasType == null) { + aasType = ReflectionHelper.INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION.stream() + .filter(x -> x.isAssignableFrom(type)) + .map(x -> TypeToken.of(x)) + .sorted(new MostSpecificTypeTokenComparator()) + .findFirst().get() + .getRawType(); + } + Set> types = new HashSet<>(); + if (aasType != null) { + types.add(aasType); + types.addAll(ReflectionHelper.getSuperTypes(aasType, true)); + } + return types.stream() + .flatMap(x -> { + try { + return Stream.of(Introspector.getBeanInfo(x).getPropertyDescriptors()); + } catch (IntrospectionException ex) { + log.warn("error finding properties of class '{}'", type, ex); + } + return Stream.empty(); + }) + .sorted(Comparator.comparing(x -> x.getName())) + .collect(Collectors.toList()); + } +} diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java index 437fa5065..6f055f797 100644 --- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java +++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java @@ -1,141 +1,141 @@ -/* - * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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; - -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.DefaultDummyDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultFile; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringDefinitionTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel; - -public class Examples { - - public static final Environment EXTENSION_MINIMAL = new DefaultEnvironment.Builder() - .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() - .id("something_142922d6") - .extensions(new DefaultExtension.Builder() - .name("something_aae6caf4") - .valueType(DataTypeDefXsd.STRING) - .build()) - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.NOT_APPLICABLE) - .globalAssetId("something_eea66fa1") - .build()) - .build()) - .build(); - - public static final Environment EXTENSION_MAXIMAL = new DefaultEnvironment.Builder() - .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() - .id("something_142922d6") - .extensions(new DefaultExtension.Builder() - .name("something_aae6caf4") - .value("10233") - .valueType(DataTypeDefXsd.UNSIGNED_SHORT) - .refersTo(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value("urn:another-example01:f7faa581") - .build()) - .type(ReferenceTypes.MODEL_REFERENCE) - .build()) - .semanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("urn:another-company07:4d1bd2cb") - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .build()) - .supplementalSemanticIds(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("urn:an-example13:be48ff29") - .build()) - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .build()) - .build()) - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.NOT_APPLICABLE) - .globalAssetId("something_eea66fa1") - .build()) - .build()) - .build(); - - public static final Environment ENVIRONMENT_WITH_DUMMYDATASPEC = new DefaultEnvironment.Builder() - .submodels( - new DefaultSubmodel.Builder() - .id("urn:test") - .submodelElements(new DefaultFile.Builder() - .idShort("myIdShort").value("FileValue") - .build()) - .embeddedDataSpecifications( - new DefaultEmbeddedDataSpecification.Builder() - .dataSpecificationContent( - new DefaultDummyDataSpecification.Builder() - .name(new DefaultLangStringNameType.Builder() - .language("en").text("myName").build()) - .text("myText") - .pages(42) - .build()) - .dataSpecification( - new DefaultReference.Builder() - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys( - new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("https://admin-shell.io/aas/3/0/CustomDataSpecification") - .build() - ) - .build() - ) - .build()) - .embeddedDataSpecifications( - new DefaultEmbeddedDataSpecification.Builder().dataSpecificationContent( - new DefaultDataSpecificationIec61360.Builder() - .dataType(DataTypeIec61360.BLOB) - .definition(new DefaultLangStringDefinitionTypeIec61360.Builder() - .language("en").text("myDefinition") - .build()) - .build() - ) - .dataSpecification( - new DefaultReference.Builder() - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys( - new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIec61360") - .build() - ) - .build() - ) - .build()) - .build() - ).build(); -} +/* + * Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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; + +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.DefaultDummyDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultFile; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringDefinitionTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel; + +public class Examples { + + public static final Environment EXTENSION_MINIMAL = new DefaultEnvironment.Builder() + .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() + .id("something_142922d6") + .extensions(new DefaultExtension.Builder() + .name("something_aae6caf4") + .valueType(DataTypeDefXsd.STRING) + .build()) + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.NOT_APPLICABLE) + .globalAssetId("something_eea66fa1") + .build()) + .build()) + .build(); + + public static final Environment EXTENSION_MAXIMAL = new DefaultEnvironment.Builder() + .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() + .id("something_142922d6") + .extensions(new DefaultExtension.Builder() + .name("something_aae6caf4") + .value("10233") + .valueType(DataTypeDefXsd.UNSIGNED_SHORT) + .refersTo(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("urn:another-example01:f7faa581") + .build()) + .type(ReferenceTypes.MODEL_REFERENCE) + .build()) + .semanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("urn:another-company07:4d1bd2cb") + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .supplementalSemanticIds(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("urn:an-example13:be48ff29") + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .build()) + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.NOT_APPLICABLE) + .globalAssetId("something_eea66fa1") + .build()) + .build()) + .build(); + + public static final Environment ENVIRONMENT_WITH_DUMMYDATASPEC = new DefaultEnvironment.Builder() + .submodels( + new DefaultSubmodel.Builder() + .id("urn:test") + .submodelElements(new DefaultFile.Builder() + .idShort("myIdShort").value("FileValue") + .build()) + .embeddedDataSpecifications( + new DefaultEmbeddedDataSpecification.Builder() + .dataSpecificationContent( + new DefaultDummyDataSpecification.Builder() + .name(new DefaultLangStringNameType.Builder() + .language("en").text("myName").build()) + .text("myText") + .pages(42) + .build()) + .dataSpecification( + new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys( + new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("https://admin-shell.io/aas/3/0/CustomDataSpecification") + .build() + ) + .build() + ) + .build()) + .embeddedDataSpecifications( + new DefaultEmbeddedDataSpecification.Builder().dataSpecificationContent( + new DefaultDataSpecificationIec61360.Builder() + .dataType(DataTypeIec61360.BLOB) + .definition(new DefaultLangStringDefinitionTypeIec61360.Builder() + .language("en").text("myDefinition") + .build()) + .build() + ) + .dataSpecification( + new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys( + new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("https://admin-shell.io/aas/3/0/RC02/DataSpecificationIec61360") + .build() + ) + .build() + ) + .build()) + .build() + ).build(); +} 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..a953b07b2 100644 --- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java +++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/AasUtilsTest.java @@ -1,508 +1,508 @@ -/* - * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. - * Copyright (C) 2023 SAP SE or an SAP affiliate company. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; - -import junitparams.JUnitParamsRunner; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.Operation; -import org.eclipse.digitaltwin.aas4j.v3.model.Referable; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -@RunWith(JUnitParamsRunner.class) -public class AasUtilsTest { - - @Test - public void whenResolve_withProperty_success() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - SubmodelElement expected = new DefaultProperty.Builder() - .idShort(submodelElementIdShort) - .value("bar") - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(expected) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value(submodelElementIdShort) - .build()) - .build(); - Referable actual = AasUtils.resolve(reference, environment); - Assert.assertEquals(expected, actual); - } - - @Test(expected = IllegalArgumentException.class) - public void whenResolve_withInvalidType_fail() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - SubmodelElement expected = new DefaultProperty.Builder() - .idShort(submodelElementIdShort) - .value("bar") - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(expected) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .type(ReferenceTypes.MODEL_REFERENCE) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value(submodelElementIdShort) - .build()) - .build(); - AasUtils.resolve(reference, environment, Operation.class); - } - - @Test - public void whenResolve_insideSubmodelElementList_success() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - String submodelElementListIdShort = "list"; - SubmodelElement expected = new DefaultProperty.Builder() - .idShort(submodelElementIdShort) - .value("bar") - .build(); - SubmodelElementList list = new DefaultSubmodelElementList.Builder() - .idShort(submodelElementListIdShort) - .value(expected) - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(list) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT_LIST) - .value(submodelElementListIdShort) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value("0") - .build()) - .build(); - Referable actual = AasUtils.resolve(reference, environment); - Assert.assertEquals(expected, actual); - } - - @Test(expected = IllegalArgumentException.class) - public void whenResolve_insideSubmodelElementList_indexOutOfBounds() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - String submodelElementListIdShort = "list"; - SubmodelElement expected = new DefaultProperty.Builder() - .idShort(submodelElementIdShort) - .value("bar") - .build(); - SubmodelElementList list = new DefaultSubmodelElementList.Builder() - .idShort(submodelElementListIdShort) - .value(expected) - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(list) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT_LIST) - .value(submodelElementListIdShort) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value("1") - .build()) - .build(); - AasUtils.resolve(reference, environment); - } - - @Test - public void whenResolve_insideSubmodelElementCollection_success() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - String submodelElementListIdShort = "list"; - SubmodelElement expected = new DefaultProperty.Builder() - .idShort(submodelElementIdShort) - .value("bar") - .build(); - SubmodelElementCollection list = new DefaultSubmodelElementCollection.Builder() - .idShort(submodelElementListIdShort) - .value(expected) - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(list) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT_LIST) - .value(submodelElementListIdShort) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value(submodelElementIdShort) - .build()) - .build(); - Referable actual = AasUtils.resolve(reference, environment); - Assert.assertEquals(expected, actual); - } - - @Test - public void whenResolve_withSubmodel_success() { - Environment environment = AASFull.createEnvironment(); - Reference submodelRef = AASFull.AAS_1.getSubmodels().get(0); - Submodel expected = AASFull.SUBMODEL_3; - Referable asReferable = AasUtils.resolve(submodelRef, environment); - assertEquals(expected, asReferable); - Submodel asSubmodel = AasUtils.resolve(submodelRef, environment, Submodel.class); - assertEquals(expected, asSubmodel); - } - - @Test - public void whenResolve_withElementWithinSubmodelElementList_success() { - String submodelId = "http://example.org/submodel"; - String submodelElementIdShort = "foo"; - SubmodelElement expected = new DefaultProperty.Builder() - .value("bar") - .build(); - Environment environment = new DefaultEnvironment.Builder() - .submodels(new DefaultSubmodel.Builder() - .id(submodelId) - .submodelElements(new DefaultSubmodelElementList.Builder() - .idShort(submodelElementIdShort) - .value(expected) - .build()) - .build()) - .build(); - Reference reference = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value(submodelId) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value(submodelElementIdShort) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT) - .value("0") - .build()) - .build(); - Referable actual = AasUtils.resolve(reference, environment); - Assert.assertEquals(expected, actual); - } - - @Test - public void whenSameAs_withDifferentKeyTypesButSameValues_success() { - String value = "0173-1#01-ADS698#010"; - Reference ref1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.FRAGMENT_REFERENCE) - .value(value) - .build()) - .build(); - Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withoutKeys_success() { - Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); - ref1.setKeys(null); - Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); - ref2.setKeys(new ArrayList<>()); - Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withoutKeysAndDifferentTypes_fail() { - Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); - ref1.setKeys(null); - Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).build(); - ref2.setKeys(new ArrayList<>()); - Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withoutKeysAndDifferentSemaniticIDs_fail() { - Reference semanticId1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .value("value1") - .build()) - .build(); - Reference semanticId2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.FRAGMENT_REFERENCE) - .value("value2") - .build()) - .build(); - Reference ref1 = new DefaultReference.Builder() - .referredSemanticId(semanticId1) - .build(); - ref1.setKeys(null); - Reference ref2 = new DefaultReference.Builder() - .referredSemanticId(semanticId2) - .build(); - ref2.setKeys(new ArrayList<>()); - Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true)); - } - - @Test - public void whenSameAs_withDifferentKeyTypesButSameValuesAndSemanticIDs_success() { - String value = "0173-1#01-ADS698#010"; - Reference semanticId1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Reference semanticId2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.FRAGMENT_REFERENCE) - .value(value) - .build()) - .build(); - Reference ref1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .referredSemanticId(semanticId1) - .build(); - Reference ref2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.FRAGMENT_REFERENCE) - .value(value) - .build()) - .referredSemanticId(semanticId2) - .build(); - Assert.assertTrue(AasUtils.sameAs(ref1, ref2, true)); - } - - @Test - public void whenSameAs_withDifferentKeyTypesAndValues_fail() { - Reference ref1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("foo") - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.FRAGMENT_REFERENCE) - .value("bar") - .build()) - .build(); - Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withSameKeyTypesAndValues_success() { - String value = "0173-1#01-ADS698#010"; - Reference ref1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withSameKeyTypesButDifferentValues_fail() { - Reference ref1 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("foo") - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("bar") - .build()) - .build(); - Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withDifferentReferredSemanticId_success() { - String value = "0173-1#01-ADS698#010"; - Reference ref1 = new DefaultReference.Builder() - .referredSemanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("foo") - .build()) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .referredSemanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("bar") - .build()) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); - } - - @Test - public void whenSameAs_withDifferentReferredSemanticId_fail() { - String value = "0173-1#01-ADS698#010"; - Reference ref1 = new DefaultReference.Builder() - .referredSemanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("foo") - .build()) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Reference ref2 = new DefaultReference.Builder() - .referredSemanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("bar") - .build()) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true)); - } - - @Test - public void whenAsString_withSubmodelElementList_success() { - Reference reference = new DefaultReference.Builder() - .type(ReferenceTypes.MODEL_REFERENCE) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL) - .value("submodel") - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.SUBMODEL_ELEMENT_LIST) - .value("list") - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.PROPERTY) - .value("0") - .build()) - .build(); - String expected = "[ModelRef](Submodel)submodel, (SubmodelElementList)list, (Property)0"; - String actual = AasUtils.asString(reference); - Assert.assertEquals(expected, actual); - } - - @Test - public void whenAsString_withReferredSemanticId_success() { - String value = "0173-1#01-ADS698#010"; - Reference reference = new DefaultReference.Builder() - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .referredSemanticId(new DefaultReference.Builder() - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("foo") - .build()) - .type(ReferenceTypes.MODEL_REFERENCE) - .build()) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value(value) - .build()) - .build(); - String expected = "[ExternalRef- [ModelRef](GlobalReference)foo -](GlobalReference)0173-1#01-ADS698#010"; - String actual = AasUtils.asString(reference); - Assert.assertEquals(expected, actual); - } -} +/* + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. + * Copyright (C) 2023 SAP SE or an SAP affiliate company. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util; + +import junitparams.JUnitParamsRunner; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.Operation; +import org.eclipse.digitaltwin.aas4j.v3.model.Referable; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(JUnitParamsRunner.class) +public class AasUtilsTest { + + @Test + public void whenResolve_withProperty_success() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + SubmodelElement expected = new DefaultProperty.Builder() + .idShort(submodelElementIdShort) + .value("bar") + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(expected) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value(submodelElementIdShort) + .build()) + .build(); + Referable actual = AasUtils.resolve(reference, environment); + Assert.assertEquals(expected, actual); + } + + @Test(expected = IllegalArgumentException.class) + public void whenResolve_withInvalidType_fail() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + SubmodelElement expected = new DefaultProperty.Builder() + .idShort(submodelElementIdShort) + .value("bar") + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(expected) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value(submodelElementIdShort) + .build()) + .build(); + AasUtils.resolve(reference, environment, Operation.class); + } + + @Test + public void whenResolve_insideSubmodelElementList_success() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + String submodelElementListIdShort = "list"; + SubmodelElement expected = new DefaultProperty.Builder() + .idShort(submodelElementIdShort) + .value("bar") + .build(); + SubmodelElementList list = new DefaultSubmodelElementList.Builder() + .idShort(submodelElementListIdShort) + .value(expected) + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(list) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT_LIST) + .value(submodelElementListIdShort) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value("0") + .build()) + .build(); + Referable actual = AasUtils.resolve(reference, environment); + Assert.assertEquals(expected, actual); + } + + @Test(expected = IllegalArgumentException.class) + public void whenResolve_insideSubmodelElementList_indexOutOfBounds() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + String submodelElementListIdShort = "list"; + SubmodelElement expected = new DefaultProperty.Builder() + .idShort(submodelElementIdShort) + .value("bar") + .build(); + SubmodelElementList list = new DefaultSubmodelElementList.Builder() + .idShort(submodelElementListIdShort) + .value(expected) + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(list) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT_LIST) + .value(submodelElementListIdShort) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value("1") + .build()) + .build(); + AasUtils.resolve(reference, environment); + } + + @Test + public void whenResolve_insideSubmodelElementCollection_success() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + String submodelElementListIdShort = "list"; + SubmodelElement expected = new DefaultProperty.Builder() + .idShort(submodelElementIdShort) + .value("bar") + .build(); + SubmodelElementCollection list = new DefaultSubmodelElementCollection.Builder() + .idShort(submodelElementListIdShort) + .value(expected) + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(list) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT_LIST) + .value(submodelElementListIdShort) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value(submodelElementIdShort) + .build()) + .build(); + Referable actual = AasUtils.resolve(reference, environment); + Assert.assertEquals(expected, actual); + } + + @Test + public void whenResolve_withSubmodel_success() { + Environment environment = AASFull.createEnvironment(); + Reference submodelRef = AASFull.AAS_1.getSubmodels().get(0); + Submodel expected = AASFull.SUBMODEL_3; + Referable asReferable = AasUtils.resolve(submodelRef, environment); + assertEquals(expected, asReferable); + Submodel asSubmodel = AasUtils.resolve(submodelRef, environment, Submodel.class); + assertEquals(expected, asSubmodel); + } + + @Test + public void whenResolve_withElementWithinSubmodelElementList_success() { + String submodelId = "http://example.org/submodel"; + String submodelElementIdShort = "foo"; + SubmodelElement expected = new DefaultProperty.Builder() + .value("bar") + .build(); + Environment environment = new DefaultEnvironment.Builder() + .submodels(new DefaultSubmodel.Builder() + .id(submodelId) + .submodelElements(new DefaultSubmodelElementList.Builder() + .idShort(submodelElementIdShort) + .value(expected) + .build()) + .build()) + .build(); + Reference reference = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value(submodelId) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value(submodelElementIdShort) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT) + .value("0") + .build()) + .build(); + Referable actual = AasUtils.resolve(reference, environment); + Assert.assertEquals(expected, actual); + } + + @Test + public void whenSameAs_withDifferentKeyTypesButSameValues_success() { + String value = "0173-1#01-ADS698#010"; + Reference ref1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value(value) + .build()) + .build(); + Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withoutKeys_success() { + Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); + ref1.setKeys(null); + Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); + ref2.setKeys(new ArrayList<>()); + Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withoutKeysAndDifferentTypes_fail() { + Reference ref1 = new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE).build(); + ref1.setKeys(null); + Reference ref2 = new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).build(); + ref2.setKeys(new ArrayList<>()); + Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withoutKeysAndDifferentSemaniticIDs_fail() { + Reference semanticId1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .value("value1") + .build()) + .build(); + Reference semanticId2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value("value2") + .build()) + .build(); + Reference ref1 = new DefaultReference.Builder() + .referredSemanticId(semanticId1) + .build(); + ref1.setKeys(null); + Reference ref2 = new DefaultReference.Builder() + .referredSemanticId(semanticId2) + .build(); + ref2.setKeys(new ArrayList<>()); + Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true)); + } + + @Test + public void whenSameAs_withDifferentKeyTypesButSameValuesAndSemanticIDs_success() { + String value = "0173-1#01-ADS698#010"; + Reference semanticId1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Reference semanticId2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value(value) + .build()) + .build(); + Reference ref1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .referredSemanticId(semanticId1) + .build(); + Reference ref2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value(value) + .build()) + .referredSemanticId(semanticId2) + .build(); + Assert.assertTrue(AasUtils.sameAs(ref1, ref2, true)); + } + + @Test + public void whenSameAs_withDifferentKeyTypesAndValues_fail() { + Reference ref1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("foo") + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.FRAGMENT_REFERENCE) + .value("bar") + .build()) + .build(); + Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withSameKeyTypesAndValues_success() { + String value = "0173-1#01-ADS698#010"; + Reference ref1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withSameKeyTypesButDifferentValues_fail() { + Reference ref1 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("foo") + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("bar") + .build()) + .build(); + Assert.assertFalse(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withDifferentReferredSemanticId_success() { + String value = "0173-1#01-ADS698#010"; + Reference ref1 = new DefaultReference.Builder() + .referredSemanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("foo") + .build()) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .referredSemanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("bar") + .build()) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Assert.assertTrue(AasUtils.sameAs(ref1, ref2)); + } + + @Test + public void whenSameAs_withDifferentReferredSemanticId_fail() { + String value = "0173-1#01-ADS698#010"; + Reference ref1 = new DefaultReference.Builder() + .referredSemanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("foo") + .build()) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Reference ref2 = new DefaultReference.Builder() + .referredSemanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("bar") + .build()) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + Assert.assertFalse(AasUtils.sameAs(ref1, ref2, true)); + } + + @Test + public void whenAsString_withSubmodelElementList_success() { + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("submodel") + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL_ELEMENT_LIST) + .value("list") + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.PROPERTY) + .value("0") + .build()) + .build(); + String expected = "[ModelRef](Submodel)submodel, (SubmodelElementList)list, (Property)0"; + String actual = AasUtils.asString(reference); + Assert.assertEquals(expected, actual); + } + + @Test + public void whenAsString_withReferredSemanticId_success() { + String value = "0173-1#01-ADS698#010"; + Reference reference = new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .referredSemanticId(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("foo") + .build()) + .type(ReferenceTypes.MODEL_REFERENCE) + .build()) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value(value) + .build()) + .build(); + String expected = "[ExternalRef- [ModelRef](GlobalReference)foo -](GlobalReference)0173-1#01-ADS698#010"; + String actual = AasUtils.asString(reference); + Assert.assertEquals(expected, actual); + } +} 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-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/ExampleData.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/ExampleData.java index 3acd6508b..21fff42b2 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/ExampleData.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/ExampleData.java @@ -1,64 +1,64 @@ -/* - * Copyright 2022 jab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; - -public class ExampleData { - - private static final ObjectMapper mapper = new ObjectMapper(); - - private final T model; - private final String file; - - public ExampleData(T model, String file) { - this.model = model; - this.file = file; - } - - public static ExampleData of(T model, String file) { - return new ExampleData<>(model, file); - } - - public T getModel() { - return model; - } - - public String getFile() { - return file; - } - - public String fileContent() throws IOException { - return new String(getClass().getClassLoader().getResourceAsStream(file).readAllBytes(), StandardCharsets.UTF_8); - } - - public InputStream fileContentStream() { - return getClass().getClassLoader().getResourceAsStream(file); - } - - public JsonNode getJsonNode() { - try { - return mapper.readTree(fileContent()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} +/* + * Copyright 2022 jab. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +public class ExampleData { + + private static final ObjectMapper mapper = new ObjectMapper(); + + private final T model; + private final String file; + + public ExampleData(T model, String file) { + this.model = model; + this.file = file; + } + + public static ExampleData of(T model, String file) { + return new ExampleData<>(model, file); + } + + public T getModel() { + return model; + } + + public String getFile() { + return file; + } + + public String fileContent() throws IOException { + return new String(getClass().getClassLoader().getResourceAsStream(file).readAllBytes(), StandardCharsets.UTF_8); + } + + public InputStream fileContentStream() { + return getClass().getClassLoader().getResourceAsStream(file); + } + + public JsonNode getJsonNode() { + try { + return mapper.readTree(fileContent()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index 1462331a9..3fe3c7ee8 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -1,294 +1,294 @@ -/* - * Copyright 2022 jab. - * Copyright (c) 2023 SAP SE - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util; - -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShellDescriptor; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; -import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.eclipse.digitaltwin.aas4j.v3.model.Key; -import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.OperationRequest; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; -import org.eclipse.digitaltwin.aas4j.v3.model.SecurityTypeEnum; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelDescriptor; -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.DefaultAdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShellDescriptor; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint; -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.DefaultLangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringPreferredNameTypeIec61360; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationRequest; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationVariable; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProtocolInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultResource; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSecurityAttributeObject; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelDescriptor; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import java.util.List; - -public class Examples { - - private static final String DEFAULT_IDENTIFICATION = "identification"; - - private static final Reference DEFAULT_SEMANTIC_ID = - new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys(new DefaultKey.Builder().type(KeyTypes.GLOBAL_REFERENCE).value("eClassDefaultSemanticId").build()) - .build(); - - private static final EmbeddedDataSpecification DEFAULT_EMBEDDED_DATA_SPECIFICATION = new DefaultEmbeddedDataSpecification.Builder() - .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() - .preferredName( - new DefaultLangStringPreferredNameTypeIec61360.Builder().language("en").text("defaultPreferredName").build()) - .build()) - .dataSpecification(createGlobalReference("defaultEmbeddedDataSpecificationDataSpecificationValue")).build(); - - private static final AdministrativeInformation DEFAULT_ADMINISTRATIVE_INFORMATION = - new DefaultAdministrativeInformation.Builder() - .embeddedDataSpecifications(DEFAULT_EMBEDDED_DATA_SPECIFICATION) - .revision("1") - .version("1").build(); - - private static final List DEFAULT_DESCRIPTION = List.of(createLangStringTextType("en", "defaultDescription")); - - private static final List DEFAULT_DISPLAY_NAME = List.of(createLangStringNameType("en", "defaultDisplayName")); - - private static final String DEFAULT_ID_SHORT = "defaultIdShort"; - - private static LangStringTextType createLangStringTextType(String langCode, String text) { - return new DefaultLangStringTextType.Builder().language(langCode).text(text).build(); - } - - private static LangStringNameType createLangStringNameType(String langCode, String text) { - return new DefaultLangStringNameType.Builder().language(langCode).text(text).build(); - } - - private static Reference createReference(ReferenceTypes type, KeyTypes keyType, String value) { - return new DefaultReference.Builder().type(type).keys(createKey(keyType, value)).build(); - } - - private static Reference createGlobalReference(String value) { - return createReference(ReferenceTypes.EXTERNAL_REFERENCE, KeyTypes.GLOBAL_REFERENCE, value); - } - - private static DefaultEndpoint.Builder createEndpointBuilder() { - - String DEFAULT_INTERFACE_VALUE = "defaultInterface"; - - return new DefaultEndpoint.Builder() - .protocolInformation(createProtocolInformationBuilder().build()) - ._interface(DEFAULT_INTERFACE_VALUE); - } - - private static Key createKey(KeyTypes type, String value) { - return new DefaultKey.Builder().type(type).value(value).build(); - } - - private static DefaultProtocolInformation.Builder createProtocolInformationBuilder() { - return new DefaultProtocolInformation.Builder() - .href("defaultEndpointAddress") - .endpointProtocol("defaultEndpointProtocol") - .endpointProtocolVersion(List.of("defaultEndpointProtocolVersion")) - .subprotocol("defaultSubprotocol") - .subprotocolBody("defaultSubprotocolBody") - .subprotocolBodyEncoding("defaultSubprotocolBodyEncoding") - .securityAttributes(new DefaultSecurityAttributeObject.Builder() - .key("NONE") - .type(SecurityTypeEnum.NONE) - .value("NONE") - .build()); - } - - private static SpecificAssetId createSpecificAssetId() { - return new DefaultSpecificAssetId.Builder() - .name("testSpecificAssetId") - .value("testValue") - .build(); - } - - private static AssetAdministrationShellDescriptor createAasDescriptor() { - - SpecificAssetId specificAssetId = new DefaultSpecificAssetId.Builder() - .semanticId(DEFAULT_SEMANTIC_ID) - .externalSubjectId(createReference( - ReferenceTypes.MODEL_REFERENCE, KeyTypes.ASSET_ADMINISTRATION_SHELL, "defaultSpecificAssetId")) - .name("defaultSpecificAssetIdName") - .value("http://example.company/myAsset").build(); - - return new DefaultAssetAdministrationShellDescriptor.Builder() - .administration(DEFAULT_ADMINISTRATIVE_INFORMATION) - .description(DEFAULT_DESCRIPTION) - .displayName(DEFAULT_DISPLAY_NAME) - .id(DEFAULT_IDENTIFICATION) - .idShort(DEFAULT_ID_SHORT) - .specificAssetIds(List.of(specificAssetId)) - .endpoints(List.of(createEndpointBuilder().build())) - .globalAssetId("defaultGlobalAssetId") - .submodelDescriptors(List.of(createDefaultSubmodelDescriptor())).build(); - } - - private static SubmodelDescriptor createDefaultSubmodelDescriptor () { - return new DefaultSubmodelDescriptor.Builder() - .administration(DEFAULT_ADMINISTRATIVE_INFORMATION) - .description(DEFAULT_DESCRIPTION) - .displayName(DEFAULT_DISPLAY_NAME) - .id(DEFAULT_IDENTIFICATION) - .idShort(DEFAULT_ID_SHORT) - .endpoints(List.of(createEndpointBuilder().build())) - .semanticId(DEFAULT_SEMANTIC_ID) - .build(); - } - - private static OperationRequest createOperationRequest() { - try { - return new DefaultOperationRequest.Builder() - .inoutputArguments(new DefaultOperationVariable.Builder() - .value(new DefaultProperty.Builder() - .valueType(DataTypeDefXsd.INT).value("42") - .idShort("TheAnswerOfAllQuestions") - .build()) - .build()) - .clientTimeoutDuration(DatatypeFactory.newInstance().newDurationDayTime("PT3M")) // three minutes - .build(); - } catch (DatatypeConfigurationException e) { - throw new RuntimeException(e); - } - } - public static final ExampleData EXAMPLE_FULL = ExampleData.of(AASFull.createEnvironment(), "Example-Full.json"); - - public static final ExampleData EXAMPLE_SIMPLE = ExampleData.of(AASSimple.createEnvironment(), "Example-Simple.json"); - - public static final ExampleData ENVIRONMENT_EMPTY = ExampleData.of(new DefaultEnvironment.Builder().build(), "Environment-Empty.json"); - - public static final ExampleData ENVIRONMENT_CUSTOM_DATA = ExampleData.of( - org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.ENVIRONMENT_WITH_DUMMYDATASPEC, - "Environment-CustomDataSpec.json"); - - public static final ExampleData SHELL_DESCRIPTOR = ExampleData.of( - createAasDescriptor(), "AssetAdministrationShellDescriptor.json"); - - public static final ExampleData SUBMODEL_DESCRIPTOR = ExampleData.of( - createDefaultSubmodelDescriptor(), "SubmodelDescriptor.json"); - - public static final ExampleData> ASSET_ADMINISTRATION_SHELL_LIST_OF = ExampleData.of( - List.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), - AASFull.createEnvironment().getAssetAdministrationShells().get(1)), - "AssetAdministrationShell-List.json"); - - public static final ExampleData ASSET_ADMINISTRATION_SHELL_WITH_ASSET_INFORMATION = ExampleData.of( - new DefaultAssetAdministrationShell.Builder() - .id("https://example.org/AssetAdministrationShell") - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) - .globalAssetId("https://example.org/Asset") - .specificAssetIds(new DefaultSpecificAssetId.Builder() - .name("ExampleAssetId") - .value("ExampleValue") - .externalSubjectId(new DefaultReference.Builder() - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("https://example.org/ExternalSubject") - .build()) - .build()) - .build()) - .defaultThumbnail(new DefaultResource.Builder() - .path("file:/example.jpg") - .contentType("image/jpeg") - .build()) - .build()) - .build(), - "AssetAdministrationShell-WithAssetInformation.json"); - - public static final ExampleData ASSET_ADMINISTRATION_SHELL = ExampleData.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), "AssetAdministrationShell.json"); - - - public static final ExampleData CONCEPT_DESCRIPTION_DATA_SPECIFICATION_PHYSICAL_UNIT = ExampleData.of( - new DefaultConceptDescription.Builder() - .id("https://example.org/ConceptDescription") - .category("PROPERTY") - .embeddedDataSpecifications(new DefaultEmbeddedDataSpecification.Builder() - .dataSpecification(new DefaultReference.Builder() - .type(ReferenceTypes.EXTERNAL_REFERENCE) - .keys(new DefaultKey.Builder() - .type(KeyTypes.GLOBAL_REFERENCE) - .value("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02") - .build()) - .build()) - .build()) - .build(), - "ConceptDescription-DataSpecificationPhysicalUnit.json"); - - public static final ExampleData> SUBMODEL_ELEMENT_LIST_OF = ExampleData.of( - List.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), - AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(1)), - "SubmodelElement-List.json"); - - public static final ExampleData> SUBMODEL_LIST_OF = ExampleData.of( - List.of(AASFull.createEnvironment().getSubmodels().get(0), - AASFull.createEnvironment().getSubmodels().get(1)), - "Submodel-List.json"); - - public static final ExampleData SUBMODEL = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0), "Submodel.json"); - - public static final ExampleData SUBMODEL_ELEMENT = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), "SubmodelElement.json"); - - public static final ExampleData SUBMODEL_ELEMENT_COLLECTION = ExampleData.of((SubmodelElementCollection) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(6), - "SubmodelElementCollection.json"); - - public static final ExampleData SUBMODEL_ELEMENT_LIST_EMPTY = ExampleData.of( - new DefaultSubmodelElementList.Builder() - .idShort("submodelElementList") - .orderRelevant(true) - .build(), "SubmodelElementList-Empty.json"); - - public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); - - public static final ExampleData EXTENSION_MINIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "admin-shell-io/Extension/Minimal.json"); - - public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "admin-shell-io/Extension/Maximal.json"); - - public static final ExampleData OPERATION_REQUEST = ExampleData.of( - createOperationRequest(), "OperationRequest.json"); -} +/* + * Copyright 2022 jab. + * Copyright (c) 2023 SAP SE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 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.util; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShellDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd; +import org.eclipse.digitaltwin.aas4j.v3.model.EmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.OperationRequest; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.SecurityTypeEnum; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelDescriptor; +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.DefaultAdministrativeInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShellDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint; +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.DefaultLangStringNameType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringPreferredNameTypeIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultLangStringTextType; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationRequest; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationVariable; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProperty; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProtocolInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultResource; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSecurityAttributeObject; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import java.util.List; + +public class Examples { + + private static final String DEFAULT_IDENTIFICATION = "identification"; + + private static final Reference DEFAULT_SEMANTIC_ID = + new DefaultReference.Builder().type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(new DefaultKey.Builder().type(KeyTypes.GLOBAL_REFERENCE).value("eClassDefaultSemanticId").build()) + .build(); + + private static final EmbeddedDataSpecification DEFAULT_EMBEDDED_DATA_SPECIFICATION = new DefaultEmbeddedDataSpecification.Builder() + .dataSpecificationContent(new DefaultDataSpecificationIec61360.Builder() + .preferredName( + new DefaultLangStringPreferredNameTypeIec61360.Builder().language("en").text("defaultPreferredName").build()) + .build()) + .dataSpecification(createGlobalReference("defaultEmbeddedDataSpecificationDataSpecificationValue")).build(); + + private static final AdministrativeInformation DEFAULT_ADMINISTRATIVE_INFORMATION = + new DefaultAdministrativeInformation.Builder() + .embeddedDataSpecifications(DEFAULT_EMBEDDED_DATA_SPECIFICATION) + .revision("1") + .version("1").build(); + + private static final List DEFAULT_DESCRIPTION = List.of(createLangStringTextType("en", "defaultDescription")); + + private static final List DEFAULT_DISPLAY_NAME = List.of(createLangStringNameType("en", "defaultDisplayName")); + + private static final String DEFAULT_ID_SHORT = "defaultIdShort"; + + private static LangStringTextType createLangStringTextType(String langCode, String text) { + return new DefaultLangStringTextType.Builder().language(langCode).text(text).build(); + } + + private static LangStringNameType createLangStringNameType(String langCode, String text) { + return new DefaultLangStringNameType.Builder().language(langCode).text(text).build(); + } + + private static Reference createReference(ReferenceTypes type, KeyTypes keyType, String value) { + return new DefaultReference.Builder().type(type).keys(createKey(keyType, value)).build(); + } + + private static Reference createGlobalReference(String value) { + return createReference(ReferenceTypes.EXTERNAL_REFERENCE, KeyTypes.GLOBAL_REFERENCE, value); + } + + private static DefaultEndpoint.Builder createEndpointBuilder() { + + String DEFAULT_INTERFACE_VALUE = "defaultInterface"; + + return new DefaultEndpoint.Builder() + .protocolInformation(createProtocolInformationBuilder().build()) + ._interface(DEFAULT_INTERFACE_VALUE); + } + + private static Key createKey(KeyTypes type, String value) { + return new DefaultKey.Builder().type(type).value(value).build(); + } + + private static DefaultProtocolInformation.Builder createProtocolInformationBuilder() { + return new DefaultProtocolInformation.Builder() + .href("defaultEndpointAddress") + .endpointProtocol("defaultEndpointProtocol") + .endpointProtocolVersion(List.of("defaultEndpointProtocolVersion")) + .subprotocol("defaultSubprotocol") + .subprotocolBody("defaultSubprotocolBody") + .subprotocolBodyEncoding("defaultSubprotocolBodyEncoding") + .securityAttributes(new DefaultSecurityAttributeObject.Builder() + .key("NONE") + .type(SecurityTypeEnum.NONE) + .value("NONE") + .build()); + } + + private static SpecificAssetId createSpecificAssetId() { + return new DefaultSpecificAssetId.Builder() + .name("testSpecificAssetId") + .value("testValue") + .build(); + } + + private static AssetAdministrationShellDescriptor createAasDescriptor() { + + SpecificAssetId specificAssetId = new DefaultSpecificAssetId.Builder() + .semanticId(DEFAULT_SEMANTIC_ID) + .externalSubjectId(createReference( + ReferenceTypes.MODEL_REFERENCE, KeyTypes.ASSET_ADMINISTRATION_SHELL, "defaultSpecificAssetId")) + .name("defaultSpecificAssetIdName") + .value("http://example.company/myAsset").build(); + + return new DefaultAssetAdministrationShellDescriptor.Builder() + .administration(DEFAULT_ADMINISTRATIVE_INFORMATION) + .description(DEFAULT_DESCRIPTION) + .displayName(DEFAULT_DISPLAY_NAME) + .id(DEFAULT_IDENTIFICATION) + .idShort(DEFAULT_ID_SHORT) + .specificAssetIds(List.of(specificAssetId)) + .endpoints(List.of(createEndpointBuilder().build())) + .globalAssetId("defaultGlobalAssetId") + .submodelDescriptors(List.of(createDefaultSubmodelDescriptor())).build(); + } + + private static SubmodelDescriptor createDefaultSubmodelDescriptor () { + return new DefaultSubmodelDescriptor.Builder() + .administration(DEFAULT_ADMINISTRATIVE_INFORMATION) + .description(DEFAULT_DESCRIPTION) + .displayName(DEFAULT_DISPLAY_NAME) + .id(DEFAULT_IDENTIFICATION) + .idShort(DEFAULT_ID_SHORT) + .endpoints(List.of(createEndpointBuilder().build())) + .semanticId(DEFAULT_SEMANTIC_ID) + .build(); + } + + private static OperationRequest createOperationRequest() { + try { + return new DefaultOperationRequest.Builder() + .inoutputArguments(new DefaultOperationVariable.Builder() + .value(new DefaultProperty.Builder() + .valueType(DataTypeDefXsd.INT).value("42") + .idShort("TheAnswerOfAllQuestions") + .build()) + .build()) + .clientTimeoutDuration(DatatypeFactory.newInstance().newDurationDayTime("PT3M")) // three minutes + .build(); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException(e); + } + } + public static final ExampleData EXAMPLE_FULL = ExampleData.of(AASFull.createEnvironment(), "Example-Full.json"); + + public static final ExampleData EXAMPLE_SIMPLE = ExampleData.of(AASSimple.createEnvironment(), "Example-Simple.json"); + + public static final ExampleData ENVIRONMENT_EMPTY = ExampleData.of(new DefaultEnvironment.Builder().build(), "Environment-Empty.json"); + + public static final ExampleData ENVIRONMENT_CUSTOM_DATA = ExampleData.of( + org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.ENVIRONMENT_WITH_DUMMYDATASPEC, + "Environment-CustomDataSpec.json"); + + public static final ExampleData SHELL_DESCRIPTOR = ExampleData.of( + createAasDescriptor(), "AssetAdministrationShellDescriptor.json"); + + public static final ExampleData SUBMODEL_DESCRIPTOR = ExampleData.of( + createDefaultSubmodelDescriptor(), "SubmodelDescriptor.json"); + + public static final ExampleData> ASSET_ADMINISTRATION_SHELL_LIST_OF = ExampleData.of( + List.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), + AASFull.createEnvironment().getAssetAdministrationShells().get(1)), + "AssetAdministrationShell-List.json"); + + public static final ExampleData ASSET_ADMINISTRATION_SHELL_WITH_ASSET_INFORMATION = ExampleData.of( + new DefaultAssetAdministrationShell.Builder() + .id("https://example.org/AssetAdministrationShell") + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .globalAssetId("https://example.org/Asset") + .specificAssetIds(new DefaultSpecificAssetId.Builder() + .name("ExampleAssetId") + .value("ExampleValue") + .externalSubjectId(new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("https://example.org/ExternalSubject") + .build()) + .build()) + .build()) + .defaultThumbnail(new DefaultResource.Builder() + .path("file:/example.jpg") + .contentType("image/jpeg") + .build()) + .build()) + .build(), + "AssetAdministrationShell-WithAssetInformation.json"); + + public static final ExampleData ASSET_ADMINISTRATION_SHELL = ExampleData.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), "AssetAdministrationShell.json"); + + + public static final ExampleData CONCEPT_DESCRIPTION_DATA_SPECIFICATION_PHYSICAL_UNIT = ExampleData.of( + new DefaultConceptDescription.Builder() + .id("https://example.org/ConceptDescription") + .category("PROPERTY") + .embeddedDataSpecifications(new DefaultEmbeddedDataSpecification.Builder() + .dataSpecification(new DefaultReference.Builder() + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02") + .build()) + .build()) + .build()) + .build(), + "ConceptDescription-DataSpecificationPhysicalUnit.json"); + + public static final ExampleData> SUBMODEL_ELEMENT_LIST_OF = ExampleData.of( + List.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), + AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(1)), + "SubmodelElement-List.json"); + + public static final ExampleData> SUBMODEL_LIST_OF = ExampleData.of( + List.of(AASFull.createEnvironment().getSubmodels().get(0), + AASFull.createEnvironment().getSubmodels().get(1)), + "Submodel-List.json"); + + public static final ExampleData SUBMODEL = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0), "Submodel.json"); + + public static final ExampleData SUBMODEL_ELEMENT = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), "SubmodelElement.json"); + + public static final ExampleData SUBMODEL_ELEMENT_COLLECTION = ExampleData.of((SubmodelElementCollection) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(6), + "SubmodelElementCollection.json"); + + public static final ExampleData SUBMODEL_ELEMENT_LIST_EMPTY = ExampleData.of( + new DefaultSubmodelElementList.Builder() + .idShort("submodelElementList") + .orderRelevant(true) + .build(), "SubmodelElementList-Empty.json"); + + public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); + + public static final ExampleData EXTENSION_MINIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "admin-shell-io/Extension/Minimal.json"); + + public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "admin-shell-io/Extension/Maximal.json"); + + public static final ExampleData OPERATION_REQUEST = ExampleData.of( + createOperationRequest(), "OperationRequest.json"); +} diff --git a/dataformat-json/src/test/resources/Example-Full.json b/dataformat-json/src/test/resources/Example-Full.json index 75c0cd989..36583e3b5 100644 --- a/dataformat-json/src/test/resources/Example-Full.json +++ b/dataformat-json/src/test/resources/Example-Full.json @@ -1,2561 +1,2561 @@ -{ - "assetAdministrationShells": [ - { - "modelType": "AssetAdministrationShell", - "assetInformation": { - "assetKind": "Instance", - "globalAssetId": "https://acplt.org/Test_Asset" - }, - "derivedFrom": { - "keys": [ - { - "type": "AssetAdministrationShell", - "value": "https://acplt.org/TestAssetAdministrationShell2" - } - ], - "type": "ExternalReference" - }, - "submodels": [ - { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel" - } - ], - "type": "ExternalReference" - }, - { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" - } - ], - "type": "ExternalReference" - }, - { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/Submodels/Assets/TestAsset/Identification" - } - ], - "type": "ExternalReference" - } - ], - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_AssetAdministrationShell", - "idShort": "TestAssetAdministrationShell", - "description": [ - { - "language": "en-us", - "text": "An Example Asset Administration Shell for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Verwaltungsschale für eine Test-Anwendung" - } - ] - }, - { - "modelType": "AssetAdministrationShell", - "assetInformation": { - "assetKind": "Instance", - "globalAssetId": "https://acplt.org/Test_Asset_Mandatory" - }, - "submodels": [ - { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - } - ], - "type": "ExternalReference" - }, - { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel2_Mandatory" - } - ], - "type": "ExternalReference" - } - ], - "id": "https://acplt.org/Test_AssetAdministrationShell_Mandatory", - "idShort": "Test_AssetAdministrationShell_Mandatory" - }, - { - "modelType": "AssetAdministrationShell", - "assetInformation": { - "assetKind": "Instance", - "globalAssetId": "https://acplt.org/Test_Asset_Mandatory" - }, - "id": "https://acplt.org/Test_AssetAdministrationShell2_Mandatory", - "idShort": "Test_AssetAdministrationShell2_Mandatory" - }, - { - "modelType": "AssetAdministrationShell", - "assetInformation": { - "assetKind": "Instance", - "globalAssetId": "https://acplt.org/Test_Asset_Missing" - }, - "submodels": [ - { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - } - ], - "type": "ExternalReference" - } - ], - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_AssetAdministrationShell_Missing", - "idShort": "TestAssetAdministrationShell", - "description": [ - { - "language": "en-us", - "text": "An Example Asset Administration Shell for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Verwaltungsschale für eine Test-Anwendung" - } - ] - } - ], - "conceptDescriptions": [ - { - "modelType": "ConceptDescription", - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_ConceptDescription", - "idShort": "TestConceptDescription", - "isCaseOf": [ - { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/DataSpecifications/Conceptdescription/TestConceptDescription" - } - ], - "type": "ExternalReference" - } - ], - "description": [ - { - "language": "en-us", - "text": "An example concept description for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-ConceptDescription für eine Test-Anwendung" - } - ] - }, - { - "modelType": "ConceptDescription", - "id": "https://acplt.org/Test_ConceptDescription_Mandatory", - "idShort": "Test_ConceptDescription_Mandatory" - }, - { - "modelType": "ConceptDescription", - "category": "PROPERTY", - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_ConceptDescription_Missing", - "idShort": "TestConceptDescription1", - "description": [ - { - "language": "en-us", - "text": "An example concept description for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-ConceptDescription für eine Test-Anwendung" - } - ] - }, - { - "modelType": "ConceptDescription", - "administration": { - "revision": "9", - "version": "0" - }, - "id": "http://acplt.org/DataSpecifciations/Example/Identification", - "idShort": "TestSpec_01", - "isCaseOf": [ - { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ReferenceElements/ConceptDescriptionX" - } - ], - "type": "ExternalReference" - } - ], - "embeddedDataSpecifications": [ - { - "dataSpecification": { - "keys": [ - { - "type": "GlobalReference", - "value": "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIec61360" - } - ], - "type": "ExternalReference" - }, - "dataSpecificationContent": { - "modelType": "DataSpecificationIec61360", - "dataType": "REAL_MEASURE", - "sourceOfDefinition": "http://acplt.org/DataSpec/ExampleDef", - "symbol": "SU", - "unit": "SpaceUnit", - "unitId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Units/SpaceUnit" - } - ], - "type": "ExternalReference" - }, - "levelType": { - "max": true, - "min": false, - "nom": false, - "typ": false - }, - "value": "TEST", - "valueFormat": "string", - "valueList": { - "valueReferencePairs": [ - { - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - } - }, - { - "value": "http://acplt.org/ValueId/ExampleValueId2", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId2" - } - ], - "type": "ExternalReference" - } - } - ] - }, - "definition": [ - { - "language": "de", - "text": "Dies ist eine Data Specification für Testzwecke" - }, - { - "language": "en-us", - "text": "This is a DataSpecification for testing purposes" - } - ], - "preferredName": [ - { - "language": "de", - "text": "Test Specification" - }, - { - "language": "en-us", - "text": "TestSpecification" - } - ], - "shortName": [ - { - "language": "de", - "text": "Test Spec" - }, - { - "language": "en-us", - "text": "TestSpec" - } - ] - } - } - ] - } - ], - "submodels": [ - { - "modelType": "Submodel", - "kind": "Instance", - "semanticId": { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/SubmodelTemplates/AssetIdentification" - } - ], - "type": "ExternalReference" - }, - "administration": { - "revision": "9", - "version": "0" - }, - "id": "http://acplt.org/Submodels/Assets/TestAsset/Identification", - "idShort": "Identification", - "submodelElements": [ - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "0173-1#02-AAO677#002" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ACPLT", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ACPLT" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "qualifiers": [ - { - "type": "http://acplt.org/Qualifier/ExampleQualifier", - "value": "100", - "valueType": "xs:int", - "kind": "ConceptQualifier" - }, - { - "type": "http://acplt.org/Qualifier/ExampleQualifier2", - "value": "50", - "valueType": "xs:int", - "kind": "ConceptQualifier" - } - ], - "idShort": "ManufacturerName", - "displayName": [ - { - "language": "en-us", - "text": "Manufacturer Name" - } - ], - "description": [ - { - "language": "en-us", - "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." - }, - { - "language": "de", - "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" - } - ] - }, - { - "modelType": "Property", - "category": "VARIABLE", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" - } - ], - "type": "ExternalReference" - }, - "supplementalSemanticIds": [ - { - "keys": [ - { - "type": "GlobalReference", - "value": "something_random_e14ad770" - } - ], - "type": "ExternalReference" - }, - { - "keys": [{ - "type": "GlobalReference", - "value": "something_random_bd061acd" - }], - "type": "ExternalReference" - } - - ], - "value": "978-8234-234-342", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "978-8234-234-342" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "idShort": "InstanceId", - "description": [ - { - "language": "en-us", - "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." - }, - { - "language": "de", - "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" - } - ] - } - ], - "description": [ - { - "language": "en-us", - "text": "An example asset identification submodel for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Identifikations-Submodel für eine Test-Anwendung" - } - ] - }, - { - "modelType": "Submodel", - "kind": "Instance", - "semanticId": { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/SubmodelTemplates/BillOfMaterial" - } - ], - "type": "ExternalReference" - }, - "administration": { - "version": "0" - }, - "id": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial", - "idShort": "BillOfMaterial", - "submodelElements": [ - { - "modelType": "Entity", - "entityType": "CoManagedEntity", - "statements": [ - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValue2", - "category": "CONSTANT", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValue2" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "idShort": "ExampleProperty2", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - }, - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "idShort": "ExampleProperty", - "category": "CONSTANT", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - ], - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" - } - ], - "type": "ExternalReference" - }, - "idShort": "ExampleEntity", - "description": [ - { - "language": "en-us", - "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." - }, - { - "language": "de", - "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" - } - ] - }, - { - "modelType": "Entity", - "entityType": "SelfManagedEntity", - "globalAssetId": "https://acplt.org/Test_Asset2", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" - } - ], - "type": "ExternalReference" - }, - "idShort": "ExampleEntity2", - "description": [ - { - "language": "en-us", - "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." - }, - { - "language": "de", - "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" - } - ] - } - ], - "description": [ - { - "language": "en-us", - "text": "An example bill of material submodel for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-BillofMaterial-Submodel für eine Test-Anwendung" - } - ] - }, - { - "modelType": "Submodel", - "kind": "Instance", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" - } - ], - "type": "ExternalReference" - }, - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_Submodel", - "idShort": "TestSubmodel", - "submodelElements": [ - { - "modelType": "RelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" - }, - { - "type": "Entity", - "value": "ExampleEntity" - }, - { - "type": "Property", - "value": "ExampleProperty2" - } - ], - "type": "ModelReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example RelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel RelationshipElement Element" - } - ] - }, - { - "modelType": "AnnotatedRelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleAnnotatedRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" - }, - { - "type": "Entity", - "value": "ExampleEntity" - }, - { - "type": "Property", - "value": "ExampleProperty2" - } - ], - "type": "ModelReference" - }, - "annotations": [ - { - "modelType": "Property", - "value": "some example annotation", - "valueType": "xs:string", - "category": "PARAMETER", - "idShort": "ExampleProperty3" - } - ], - "description": [ - { - "language": "en-us", - "text": "Example AnnotatedRelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel AnnotatedRelationshipElement Element" - } - ] - }, - { - "modelType": "Operation", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Operations/ExampleOperation" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleOperation", - "inoutputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty3", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "inputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty1", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "outputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty2", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "description": [ - { - "language": "en-us", - "text": "Example Operation object" - }, - { - "language": "de", - "text": "Beispiel Operation Element" - } - ] - }, - { - "modelType": "Capability", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Capabilities/ExampleCapability" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleCapability", - "description": [ - { - "language": "en-us", - "text": "Example Capability object" - }, - { - "language": "de", - "text": "Beispiel Capability Element" - } - ] - }, - { - "modelType": "BasicEventElement", - "observed": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Events/ExampleBasicEvent" - } - ], - "type": "ExternalReference" - }, - "direction": "input", - "state": "on", - "category": "PARAMETER", - "idShort": "ExampleBasicEvent", - "description": [ - { - "language": "en-us", - "text": "Example BasicEvent object" - }, - { - "language": "de", - "text": "Beispiel BasicEvent Element" - } - ] - }, - { - "modelType": "SubmodelElementList", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementListOrdered", - "orderRelevant": true, - "description": [ - { - "language": "en-us", - "text": "Example ExampleSubmodelElementListOrdered object" - }, - { - "language": "de", - "text": "Beispiel ExampleSubmodelElementListOrdered Element" - } - ], - "typeValueListElement": "SubmodelElement", - "value": [ - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "http://acplt.org/ValueId/ExampleValueId", - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleValueId" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - }, - { - "modelType": "MultiLanguageProperty", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" - } - ], - "type": "ExternalReference" - }, - "valueId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ValueId/ExampleMultiLanguageValueId" - } - ], - "type": "ExternalReference" - }, - "category": "CONSTANT", - "idShort": "ExampleMultiLanguageProperty", - "value": [ - { - "language": "en-us", - "text": "Example value of a MultiLanguageProperty element" - }, - { - "language": "de", - "text": "Beispielswert für ein MultiLanguageProperty-Element" - } - ], - "description": [ - { - "language": "en-us", - "text": "Example MultiLanguageProperty object" - }, - { - "language": "de", - "text": "Beispiel MultiLanguageProperty Element" - } - ] - }, - { - "modelType": "Range", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Ranges/ExampleRange" - } - ], - "type": "ExternalReference" - }, - "max": "100", - "min": "0", - "valueType": "xs:int", - "category": "PARAMETER", - "idShort": "ExampleRange", - "description": [ - { - "language": "en-us", - "text": "Example Range object" - }, - { - "language": "de", - "text": "Beispiel Range Element" - } - ] - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementCollection", - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementCollection object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementCollection Element" - } - ], - "value": [ - { - "modelType": "Blob", - "contentType": "application/pdf", - "value": "AQIDBAU=", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Blobs/ExampleBlob" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleBlob", - "description": [ - { - "language": "en-us", - "text": "Example Blob object" - }, - { - "language": "de", - "text": "Beispiel Blob Element" - } - ] - }, - { - "modelType": "File", - "contentType": "application/pdf", - "value": "file:///TestFile.pdf", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Files/ExampleFile" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleFile", - "description": [ - { - "language": "en-us", - "text": "Example File object" - }, - { - "language": "de", - "text": "Beispiel File Element" - } - ] - }, - { - "modelType": "ReferenceElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleReferenceElement", - "value": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example Reference Element object" - }, - { - "language": "de", - "text": "Beispiel Reference Element Element" - } - ] - } - ] - } - ], - "description": [ - { - "language": "en-us", - "text": "An example submodel for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" - } - ] - }, - { - "modelType": "Submodel", - "kind": "Template", - "id": "https://acplt.org/Test_Submodel_Mandatory", - "idShort": "Test_Submodel_Mandatory", - "submodelElements": [ - { - "modelType": "RelationshipElement", - "idShort": "ExampleRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListUnordered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListUnordered" - }, - { - "type": "MultiLanguageProperty", - "value": "ExampleMultiLanguageProperty" - } - ], - "type": "ModelReference" - } - }, - { - "modelType": "AnnotatedRelationshipElement", - "idShort": "ExampleAnnotatedRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - }, - { - "type": "SubmodelElementCollection", - "value": "ExampleSubmodelElementCollection" - }, - { - "type": "Blob", - "value": "ExampleBlob" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListUnordered" - }, - { - "type": "MultiLanguageProperty", - "value": "ExampleMultiLanguageProperty" - } - ], - "type": "ModelReference" - } - }, - { - "modelType": "Operation", - "idShort": "ExampleOperation" - }, - { - "modelType": "Capability", - "idShort": "ExampleCapability" - }, - { - "modelType": "BasicEventElement", - "observed": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Mandatory" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListUnordered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "idShort": "ExampleBasicEvent", - "direction": "output", - "state": "off" - }, - { - "modelType": "SubmodelElementList", - "idShort": "ExampleSubmodelElementListUnordered", - "orderRelevant": false, - "typeValueListElement": "SubmodelElement", - "value": [ - { - "modelType": "Property", - "valueType": "xs:string", - "idShort": "ExampleProperty" - }, - { - "modelType": "MultiLanguageProperty", - "idShort": "ExampleMultiLanguageProperty" - }, - { - "modelType": "Range", - "valueType": "xs:int", - "idShort": "ExampleRange" - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "idShort": "ExampleSubmodelElementCollection", - "value": [ - { - "modelType": "Blob", - "contentType": "application/pdf", - "idShort": "ExampleBlob" - }, - { - "modelType": "File", - "contentType": "application/pdf", - "idShort": "ExampleFile" - }, - { - "modelType": "ReferenceElement", - "idShort": "ExampleReferenceElement" - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "idShort": "ExampleSubmodelElementCollection2" - } - ] - }, - { - "modelType": "Submodel", - "kind": "Instance", - "id": "https://acplt.org/Test_Submodel2_Mandatory", - "idShort": "Test_Submodel2_Mandatory" - }, - { - "modelType": "Submodel", - "kind": "Instance", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" - } - ], - "type": "ExternalReference" - }, - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_Submodel_Missing", - "idShort": "TestSubmodelMissing", - "submodelElements": [ - { - "modelType": "RelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "MultiLanguageProperty", - "value": "ExampleMultiLanguageProperty" - } - ], - "type": "ModelReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example RelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel RelationshipElement Element" - } - ] - }, - { - "modelType": "AnnotatedRelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleAnnotatedRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "MultiLanguageProperty", - "value": "ExampleMultiLanguageProperty" - } - ], - "type": "ModelReference" - }, - "annotations": [ - { - "modelType": "Property", - "category": "PARAMETER", - "value": "some example annotation", - "valueType": "xs:string", - "idShort": "ExampleProperty" - } - ], - "description": [ - { - "language": "en-us", - "text": "Example AnnotatedRelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel AnnotatedRelationshipElement Element" - } - ] - }, - { - "modelType": "Operation", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Operations/ExampleOperation" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleOperation", - "inoutputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "exampleValue", - "valueType": "xs:string", - "qualifiers": [ - { - "type": "http://acplt.org/Qualifier/ExampleQualifier", - "valueType": "xs:string", - "kind": "ConceptQualifier" - } - ], - "category": "CONSTANT", - "idShort": "ExampleProperty3", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "inputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "exampleValue", - "valueType": "xs:string", - "qualifiers": [ - { - "type": "http://acplt.org/Qualifier/ExampleQualifier", - "valueType": "xs:string", - "kind": "ConceptQualifier" - } - ], - "category": "CONSTANT", - "idShort": "ExampleProperty1", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "outputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "exampleValue", - "valueType": "xs:string", - "qualifiers": [ - { - "type": "http://acplt.org/Qualifier/ExampleQualifier", - "valueType": "xs:string", - "kind": "ConceptQualifier" - } - ], - "category": "CONSTANT", - "idShort": "ExampleProperty2", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "description": [ - { - "language": "en-us", - "text": "Example Operation object" - }, - { - "language": "de", - "text": "Beispiel Operation Element" - } - ] - }, - { - "modelType": "Capability", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Capabilities/ExampleCapability" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleCapability", - "description": [ - { - "language": "en-us", - "text": "Example Capability object" - }, - { - "language": "de", - "text": "Beispiel Capability Element" - } - ] - }, - { - "modelType": "BasicEventElement", - "observed": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementList", - "value": "ExampleSubmodelElementListOrdered" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Events/ExampleBasicEvent" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleBasicEvent", - "direction": "input", - "state": "on", - "description": [ - { - "language": "en-us", - "text": "Example BasicEvent object" - }, - { - "language": "de", - "text": "Beispiel BasicEvent Element" - } - ] - }, - { - "modelType": "SubmodelElementList", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementListOrdered", - "orderRelevant": true, - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementListOrdered object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementListOrdered Element" - } - ], - "typeValueListElement": "SubmodelElement", - "value": [ - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "value": "exampleValue", - "valueType": "xs:string", - "qualifiers": [ - { - "type": "http://acplt.org/Qualifier/ExampleQualifier", - "valueType": "xs:string", - "kind": "ConceptQualifier" - } - ], - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - }, - { - "modelType": "MultiLanguageProperty", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" - } - ], - "type": "ExternalReference" - }, - "category": "CONSTANT", - "idShort": "ExampleMultiLanguageProperty", - "value": [ - { - "language": "en-us", - "text": "Example value of a MultiLanguageProperty element" - }, - { - "language": "de", - "text": "Beispielswert für ein MultiLanguageProperty-Element" - } - ], - "description": [ - { - "language": "en-us", - "text": "Example MultiLanguageProperty object" - }, - { - "language": "de", - "text": "Beispiel MultiLanguageProperty Element" - } - ] - }, - { - "modelType": "Range", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Ranges/ExampleRange" - } - ], - "type": "ExternalReference" - }, - "max": "100", - "min": "0", - "valueType": "xs:int", - "category": "PARAMETER", - "idShort": "ExampleRange", - "description": [ - { - "language": "en-us", - "text": "Example Range object" - }, - { - "language": "de", - "text": "Beispiel Range Element" - } - ] - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementCollection", - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementCollection object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementCollection Element" - } - ], - "value": [ - { - "modelType": "Blob", - "contentType": "application/pdf", - "value": "AQIDBAU=", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Blobs/ExampleBlob" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleBlob", - "description": [ - { - "language": "en-us", - "text": "Example Blob object" - }, - { - "language": "de", - "text": "Beispiel Blob Element" - } - ] - }, - { - "modelType": "File", - "contentType": "application/pdf", - "value": "file:///TestFile.pdf", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Files/ExampleFile" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleFile", - "description": [ - { - "language": "en-us", - "text": "Example File object" - }, - { - "language": "de", - "text": "Beispiel File Element" - } - ] - }, - { - "modelType": "ReferenceElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleReferenceElement", - "value": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Missing" - }, - { - "type": "SubmodelElementCollection", - "value": "ExampleSubmodelElementCollection" - }, - { - "type": "File", - "value": "ExampleFile" - } - ], - "type": "ModelReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example Reference Element object" - }, - { - "language": "de", - "text": "Beispiel Reference Element Element" - } - ] - } - ] - } - ], - "description": [ - { - "language": "en-us", - "text": "An example submodel for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" - } - ] - }, - { - "modelType": "Submodel", - "kind": "Template", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" - } - ], - "type": "ExternalReference" - }, - "administration": { - "revision": "9", - "version": "0" - }, - "id": "https://acplt.org/Test_Submodel_Template", - "idShort": "TestSubmodelTemplate", - "submodelElements": [ - { - "modelType": "RelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Template" - }, - { - "type": "Operation", - "value": "ExampleOperation" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Template" - }, - { - "type": "Operation", - "value": "ExampleOperation" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example RelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel RelationshipElement Element" - } - ] - }, - { - "modelType": "AnnotatedRelationshipElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleAnnotatedRelationshipElement", - "first": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Template" - }, - { - "type": "Operation", - "value": "ExampleOperation" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "second": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Template" - }, - { - "type": "Operation", - "value": "ExampleOperation" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "description": [ - { - "language": "en-us", - "text": "Example AnnotatedRelationshipElement object" - }, - { - "language": "de", - "text": "Beispiel AnnotatedRelationshipElement Element" - } - ] - }, - { - "modelType": "Operation", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Operations/ExampleOperation" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleOperation", - "inoutputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "inputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "outputVariables": [ - { - "value": { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - } - } - ], - "description": [ - { - "language": "en-us", - "text": "Example Operation object" - }, - { - "language": "de", - "text": "Beispiel Operation Element" - } - ] - }, - { - "modelType": "Capability", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Capabilities/ExampleCapability" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleCapability", - "description": [ - { - "language": "en-us", - "text": "Example Capability object" - }, - { - "language": "de", - "text": "Beispiel Capability Element" - } - ] - }, - { - "modelType": "BasicEventElement", - "observed": { - "keys": [ - { - "type": "Submodel", - "value": "https://acplt.org/Test_Submodel_Template" - }, - { - "type": "Operation", - "value": "ExampleOperation" - }, - { - "type": "Property", - "value": "ExampleProperty" - } - ], - "type": "ModelReference" - }, - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Events/ExampleBasicEvent" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleBasicEvent", - "direction": "output", - "state": "off", - "description": [ - { - "language": "en-us", - "text": "Example BasicEvent object" - }, - { - "language": "de", - "text": "Beispiel BasicEvent Element" - } - ] - }, - { - "modelType": "SubmodelElementList", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementListOrdered", - "orderRelevant": true, - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementListOrdered object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementListOrdered Element" - } - ], - "typeValueListElement": "SubmodelElement", - "value": [ - { - "modelType": "Property", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Properties/ExampleProperty" - } - ], - "type": "ExternalReference" - }, - "valueType": "xs:string", - "category": "CONSTANT", - "idShort": "ExampleProperty", - "description": [ - { - "language": "en-us", - "text": "Example Property object" - }, - { - "language": "de", - "text": "Beispiel Property Element" - } - ] - }, - { - "modelType": "MultiLanguageProperty", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" - } - ], - "type": "ExternalReference" - }, - "category": "CONSTANT", - "idShort": "ExampleMultiLanguageProperty", - "description": [ - { - "language": "en-us", - "text": "Example MultiLanguageProperty object" - }, - { - "language": "de", - "text": "Beispiel MultiLanguageProperty Element" - } - ] - }, - { - "modelType": "Range", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Ranges/ExampleRange" - } - ], - "type": "ExternalReference" - }, - "max": "100", - "valueType": "xs:int", - "category": "PARAMETER", - "idShort": "ExampleRange", - "description": [ - { - "language": "en-us", - "text": "Example Range object" - }, - { - "language": "de", - "text": "Beispiel Range Element" - } - ] - }, - { - "modelType": "Range", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Ranges/ExampleRange" - } - ], - "type": "ExternalReference" - }, - "min": "0", - "valueType": "xs:int", - "category": "PARAMETER", - "idShort": "ExampleRange2", - "description": [ - { - "language": "en-us", - "text": "Example Range object" - }, - { - "language": "de", - "text": "Beispiel Range Element" - } - ] - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementCollection", - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementCollection object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementCollection Element" - } - ], - "value": [ - { - "modelType": "Blob", - "contentType": "application/pdf", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Blobs/ExampleBlob" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleBlob", - "description": [ - { - "language": "en-us", - "text": "Example Blob object" - }, - { - "language": "de", - "text": "Beispiel Blob Element" - } - ] - }, - { - "modelType": "File", - "contentType": "application/pdf", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/Files/ExampleFile" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleFile", - "description": [ - { - "language": "en-us", - "text": "Example File object" - }, - { - "language": "de", - "text": "Beispiel File Element" - } - ] - }, - { - "modelType": "ReferenceElement", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleReferenceElement", - "description": [ - { - "language": "en-us", - "text": "Example Reference Element object" - }, - { - "language": "de", - "text": "Beispiel Reference Element Element" - } - ] - } - ] - }, - { - "modelType": "SubmodelElementCollection", - "semanticId": { - "keys": [ - { - "type": "GlobalReference", - "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" - } - ], - "type": "ExternalReference" - }, - "category": "PARAMETER", - "idShort": "ExampleSubmodelElementCollection2", - "description": [ - { - "language": "en-us", - "text": "Example SubmodelElementCollection object" - }, - { - "language": "de", - "text": "Beispiel SubmodelElementCollection Element" - } - ] - } - ], - "description": [ - { - "language": "en-us", - "text": "An example submodel for the test application" - }, - { - "language": "de", - "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" - } - ] - } - ] -} +{ + "assetAdministrationShells": [ + { + "modelType": "AssetAdministrationShell", + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "https://acplt.org/Test_Asset" + }, + "derivedFrom": { + "keys": [ + { + "type": "AssetAdministrationShell", + "value": "https://acplt.org/TestAssetAdministrationShell2" + } + ], + "type": "ExternalReference" + }, + "submodels": [ + { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel" + } + ], + "type": "ExternalReference" + }, + { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" + } + ], + "type": "ExternalReference" + }, + { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/Submodels/Assets/TestAsset/Identification" + } + ], + "type": "ExternalReference" + } + ], + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_AssetAdministrationShell", + "idShort": "TestAssetAdministrationShell", + "description": [ + { + "language": "en-us", + "text": "An Example Asset Administration Shell for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Verwaltungsschale für eine Test-Anwendung" + } + ] + }, + { + "modelType": "AssetAdministrationShell", + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "https://acplt.org/Test_Asset_Mandatory" + }, + "submodels": [ + { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + } + ], + "type": "ExternalReference" + }, + { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel2_Mandatory" + } + ], + "type": "ExternalReference" + } + ], + "id": "https://acplt.org/Test_AssetAdministrationShell_Mandatory", + "idShort": "Test_AssetAdministrationShell_Mandatory" + }, + { + "modelType": "AssetAdministrationShell", + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "https://acplt.org/Test_Asset_Mandatory" + }, + "id": "https://acplt.org/Test_AssetAdministrationShell2_Mandatory", + "idShort": "Test_AssetAdministrationShell2_Mandatory" + }, + { + "modelType": "AssetAdministrationShell", + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "https://acplt.org/Test_Asset_Missing" + }, + "submodels": [ + { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + } + ], + "type": "ExternalReference" + } + ], + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_AssetAdministrationShell_Missing", + "idShort": "TestAssetAdministrationShell", + "description": [ + { + "language": "en-us", + "text": "An Example Asset Administration Shell for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Verwaltungsschale für eine Test-Anwendung" + } + ] + } + ], + "conceptDescriptions": [ + { + "modelType": "ConceptDescription", + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_ConceptDescription", + "idShort": "TestConceptDescription", + "isCaseOf": [ + { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/DataSpecifications/Conceptdescription/TestConceptDescription" + } + ], + "type": "ExternalReference" + } + ], + "description": [ + { + "language": "en-us", + "text": "An example concept description for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-ConceptDescription für eine Test-Anwendung" + } + ] + }, + { + "modelType": "ConceptDescription", + "id": "https://acplt.org/Test_ConceptDescription_Mandatory", + "idShort": "Test_ConceptDescription_Mandatory" + }, + { + "modelType": "ConceptDescription", + "category": "PROPERTY", + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_ConceptDescription_Missing", + "idShort": "TestConceptDescription1", + "description": [ + { + "language": "en-us", + "text": "An example concept description for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-ConceptDescription für eine Test-Anwendung" + } + ] + }, + { + "modelType": "ConceptDescription", + "administration": { + "revision": "9", + "version": "0" + }, + "id": "http://acplt.org/DataSpecifciations/Example/Identification", + "idShort": "TestSpec_01", + "isCaseOf": [ + { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ReferenceElements/ConceptDescriptionX" + } + ], + "type": "ExternalReference" + } + ], + "embeddedDataSpecifications": [ + { + "dataSpecification": { + "keys": [ + { + "type": "GlobalReference", + "value": "https://admin-shell.io/aas/3/0/RC02/DataSpecificationIec61360" + } + ], + "type": "ExternalReference" + }, + "dataSpecificationContent": { + "modelType": "DataSpecificationIec61360", + "dataType": "REAL_MEASURE", + "sourceOfDefinition": "http://acplt.org/DataSpec/ExampleDef", + "symbol": "SU", + "unit": "SpaceUnit", + "unitId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Units/SpaceUnit" + } + ], + "type": "ExternalReference" + }, + "levelType": { + "max": true, + "min": false, + "nom": false, + "typ": false + }, + "value": "TEST", + "valueFormat": "string", + "valueList": { + "valueReferencePairs": [ + { + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + } + }, + { + "value": "http://acplt.org/ValueId/ExampleValueId2", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId2" + } + ], + "type": "ExternalReference" + } + } + ] + }, + "definition": [ + { + "language": "de", + "text": "Dies ist eine Data Specification für Testzwecke" + }, + { + "language": "en-us", + "text": "This is a DataSpecification for testing purposes" + } + ], + "preferredName": [ + { + "language": "de", + "text": "Test Specification" + }, + { + "language": "en-us", + "text": "TestSpecification" + } + ], + "shortName": [ + { + "language": "de", + "text": "Test Spec" + }, + { + "language": "en-us", + "text": "TestSpec" + } + ] + } + } + ] + } + ], + "submodels": [ + { + "modelType": "Submodel", + "kind": "Instance", + "semanticId": { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/SubmodelTemplates/AssetIdentification" + } + ], + "type": "ExternalReference" + }, + "administration": { + "revision": "9", + "version": "0" + }, + "id": "http://acplt.org/Submodels/Assets/TestAsset/Identification", + "idShort": "Identification", + "submodelElements": [ + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "0173-1#02-AAO677#002" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ACPLT", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ACPLT" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "qualifiers": [ + { + "type": "http://acplt.org/Qualifier/ExampleQualifier", + "value": "100", + "valueType": "xs:int", + "kind": "ConceptQualifier" + }, + { + "type": "http://acplt.org/Qualifier/ExampleQualifier2", + "value": "50", + "valueType": "xs:int", + "kind": "ConceptQualifier" + } + ], + "idShort": "ManufacturerName", + "displayName": [ + { + "language": "en-us", + "text": "Manufacturer Name" + } + ], + "description": [ + { + "language": "en-us", + "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." + }, + { + "language": "de", + "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" + } + ] + }, + { + "modelType": "Property", + "category": "VARIABLE", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" + } + ], + "type": "ExternalReference" + }, + "supplementalSemanticIds": [ + { + "keys": [ + { + "type": "GlobalReference", + "value": "something_random_e14ad770" + } + ], + "type": "ExternalReference" + }, + { + "keys": [{ + "type": "GlobalReference", + "value": "something_random_bd061acd" + }], + "type": "ExternalReference" + } + + ], + "value": "978-8234-234-342", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "978-8234-234-342" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "idShort": "InstanceId", + "description": [ + { + "language": "en-us", + "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." + }, + { + "language": "de", + "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" + } + ] + } + ], + "description": [ + { + "language": "en-us", + "text": "An example asset identification submodel for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Identifikations-Submodel für eine Test-Anwendung" + } + ] + }, + { + "modelType": "Submodel", + "kind": "Instance", + "semanticId": { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/SubmodelTemplates/BillOfMaterial" + } + ], + "type": "ExternalReference" + }, + "administration": { + "version": "0" + }, + "id": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial", + "idShort": "BillOfMaterial", + "submodelElements": [ + { + "modelType": "Entity", + "entityType": "CoManagedEntity", + "statements": [ + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValue2", + "category": "CONSTANT", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValue2" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "idShort": "ExampleProperty2", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + }, + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "idShort": "ExampleProperty", + "category": "CONSTANT", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + ], + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" + } + ], + "type": "ExternalReference" + }, + "idShort": "ExampleEntity", + "description": [ + { + "language": "en-us", + "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." + }, + { + "language": "de", + "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" + } + ] + }, + { + "modelType": "Entity", + "entityType": "SelfManagedEntity", + "globalAssetId": "https://acplt.org/Test_Asset2", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://opcfoundation.org/UA/DI/1.1/DeviceType/Serialnumber" + } + ], + "type": "ExternalReference" + }, + "idShort": "ExampleEntity2", + "description": [ + { + "language": "en-us", + "text": "Legally valid designation of the natural or judicial person which is directly responsible for the design, production, packaging and labeling of a product in respect to its being brought into circulation." + }, + { + "language": "de", + "text": "Bezeichnung für eine natürliche oder juristische Person, die für die Auslegung, Herstellung und Verpackung sowie die Etikettierung eines Produkts im Hinblick auf das 'Inverkehrbringen' im eigenen Namen verantwortlich ist" + } + ] + } + ], + "description": [ + { + "language": "en-us", + "text": "An example bill of material submodel for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-BillofMaterial-Submodel für eine Test-Anwendung" + } + ] + }, + { + "modelType": "Submodel", + "kind": "Instance", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" + } + ], + "type": "ExternalReference" + }, + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_Submodel", + "idShort": "TestSubmodel", + "submodelElements": [ + { + "modelType": "RelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" + }, + { + "type": "Entity", + "value": "ExampleEntity" + }, + { + "type": "Property", + "value": "ExampleProperty2" + } + ], + "type": "ModelReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example RelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel RelationshipElement Element" + } + ] + }, + { + "modelType": "AnnotatedRelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleAnnotatedRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial" + }, + { + "type": "Entity", + "value": "ExampleEntity" + }, + { + "type": "Property", + "value": "ExampleProperty2" + } + ], + "type": "ModelReference" + }, + "annotations": [ + { + "modelType": "Property", + "value": "some example annotation", + "valueType": "xs:string", + "category": "PARAMETER", + "idShort": "ExampleProperty3" + } + ], + "description": [ + { + "language": "en-us", + "text": "Example AnnotatedRelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel AnnotatedRelationshipElement Element" + } + ] + }, + { + "modelType": "Operation", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Operations/ExampleOperation" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleOperation", + "inoutputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty3", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "inputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty1", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "outputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty2", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "description": [ + { + "language": "en-us", + "text": "Example Operation object" + }, + { + "language": "de", + "text": "Beispiel Operation Element" + } + ] + }, + { + "modelType": "Capability", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Capabilities/ExampleCapability" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleCapability", + "description": [ + { + "language": "en-us", + "text": "Example Capability object" + }, + { + "language": "de", + "text": "Beispiel Capability Element" + } + ] + }, + { + "modelType": "BasicEventElement", + "observed": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Events/ExampleBasicEvent" + } + ], + "type": "ExternalReference" + }, + "direction": "input", + "state": "on", + "category": "PARAMETER", + "idShort": "ExampleBasicEvent", + "description": [ + { + "language": "en-us", + "text": "Example BasicEvent object" + }, + { + "language": "de", + "text": "Beispiel BasicEvent Element" + } + ] + }, + { + "modelType": "SubmodelElementList", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementListOrdered", + "orderRelevant": true, + "description": [ + { + "language": "en-us", + "text": "Example ExampleSubmodelElementListOrdered object" + }, + { + "language": "de", + "text": "Beispiel ExampleSubmodelElementListOrdered Element" + } + ], + "typeValueListElement": "SubmodelElement", + "value": [ + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "http://acplt.org/ValueId/ExampleValueId", + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleValueId" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + }, + { + "modelType": "MultiLanguageProperty", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" + } + ], + "type": "ExternalReference" + }, + "valueId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ValueId/ExampleMultiLanguageValueId" + } + ], + "type": "ExternalReference" + }, + "category": "CONSTANT", + "idShort": "ExampleMultiLanguageProperty", + "value": [ + { + "language": "en-us", + "text": "Example value of a MultiLanguageProperty element" + }, + { + "language": "de", + "text": "Beispielswert für ein MultiLanguageProperty-Element" + } + ], + "description": [ + { + "language": "en-us", + "text": "Example MultiLanguageProperty object" + }, + { + "language": "de", + "text": "Beispiel MultiLanguageProperty Element" + } + ] + }, + { + "modelType": "Range", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Ranges/ExampleRange" + } + ], + "type": "ExternalReference" + }, + "max": "100", + "min": "0", + "valueType": "xs:int", + "category": "PARAMETER", + "idShort": "ExampleRange", + "description": [ + { + "language": "en-us", + "text": "Example Range object" + }, + { + "language": "de", + "text": "Beispiel Range Element" + } + ] + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementCollection", + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementCollection object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementCollection Element" + } + ], + "value": [ + { + "modelType": "Blob", + "contentType": "application/pdf", + "value": "AQIDBAU=", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Blobs/ExampleBlob" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleBlob", + "description": [ + { + "language": "en-us", + "text": "Example Blob object" + }, + { + "language": "de", + "text": "Beispiel Blob Element" + } + ] + }, + { + "modelType": "File", + "contentType": "application/pdf", + "value": "file:///TestFile.pdf", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Files/ExampleFile" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleFile", + "description": [ + { + "language": "en-us", + "text": "Example File object" + }, + { + "language": "de", + "text": "Beispiel File Element" + } + ] + }, + { + "modelType": "ReferenceElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleReferenceElement", + "value": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example Reference Element object" + }, + { + "language": "de", + "text": "Beispiel Reference Element Element" + } + ] + } + ] + } + ], + "description": [ + { + "language": "en-us", + "text": "An example submodel for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" + } + ] + }, + { + "modelType": "Submodel", + "kind": "Template", + "id": "https://acplt.org/Test_Submodel_Mandatory", + "idShort": "Test_Submodel_Mandatory", + "submodelElements": [ + { + "modelType": "RelationshipElement", + "idShort": "ExampleRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListUnordered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListUnordered" + }, + { + "type": "MultiLanguageProperty", + "value": "ExampleMultiLanguageProperty" + } + ], + "type": "ModelReference" + } + }, + { + "modelType": "AnnotatedRelationshipElement", + "idShort": "ExampleAnnotatedRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + }, + { + "type": "SubmodelElementCollection", + "value": "ExampleSubmodelElementCollection" + }, + { + "type": "Blob", + "value": "ExampleBlob" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListUnordered" + }, + { + "type": "MultiLanguageProperty", + "value": "ExampleMultiLanguageProperty" + } + ], + "type": "ModelReference" + } + }, + { + "modelType": "Operation", + "idShort": "ExampleOperation" + }, + { + "modelType": "Capability", + "idShort": "ExampleCapability" + }, + { + "modelType": "BasicEventElement", + "observed": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Mandatory" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListUnordered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "idShort": "ExampleBasicEvent", + "direction": "output", + "state": "off" + }, + { + "modelType": "SubmodelElementList", + "idShort": "ExampleSubmodelElementListUnordered", + "orderRelevant": false, + "typeValueListElement": "SubmodelElement", + "value": [ + { + "modelType": "Property", + "valueType": "xs:string", + "idShort": "ExampleProperty" + }, + { + "modelType": "MultiLanguageProperty", + "idShort": "ExampleMultiLanguageProperty" + }, + { + "modelType": "Range", + "valueType": "xs:int", + "idShort": "ExampleRange" + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "idShort": "ExampleSubmodelElementCollection", + "value": [ + { + "modelType": "Blob", + "contentType": "application/pdf", + "idShort": "ExampleBlob" + }, + { + "modelType": "File", + "contentType": "application/pdf", + "idShort": "ExampleFile" + }, + { + "modelType": "ReferenceElement", + "idShort": "ExampleReferenceElement" + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "idShort": "ExampleSubmodelElementCollection2" + } + ] + }, + { + "modelType": "Submodel", + "kind": "Instance", + "id": "https://acplt.org/Test_Submodel2_Mandatory", + "idShort": "Test_Submodel2_Mandatory" + }, + { + "modelType": "Submodel", + "kind": "Instance", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" + } + ], + "type": "ExternalReference" + }, + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_Submodel_Missing", + "idShort": "TestSubmodelMissing", + "submodelElements": [ + { + "modelType": "RelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "MultiLanguageProperty", + "value": "ExampleMultiLanguageProperty" + } + ], + "type": "ModelReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example RelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel RelationshipElement Element" + } + ] + }, + { + "modelType": "AnnotatedRelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleAnnotatedRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "MultiLanguageProperty", + "value": "ExampleMultiLanguageProperty" + } + ], + "type": "ModelReference" + }, + "annotations": [ + { + "modelType": "Property", + "category": "PARAMETER", + "value": "some example annotation", + "valueType": "xs:string", + "idShort": "ExampleProperty" + } + ], + "description": [ + { + "language": "en-us", + "text": "Example AnnotatedRelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel AnnotatedRelationshipElement Element" + } + ] + }, + { + "modelType": "Operation", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Operations/ExampleOperation" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleOperation", + "inoutputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "exampleValue", + "valueType": "xs:string", + "qualifiers": [ + { + "type": "http://acplt.org/Qualifier/ExampleQualifier", + "valueType": "xs:string", + "kind": "ConceptQualifier" + } + ], + "category": "CONSTANT", + "idShort": "ExampleProperty3", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "inputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "exampleValue", + "valueType": "xs:string", + "qualifiers": [ + { + "type": "http://acplt.org/Qualifier/ExampleQualifier", + "valueType": "xs:string", + "kind": "ConceptQualifier" + } + ], + "category": "CONSTANT", + "idShort": "ExampleProperty1", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "outputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "exampleValue", + "valueType": "xs:string", + "qualifiers": [ + { + "type": "http://acplt.org/Qualifier/ExampleQualifier", + "valueType": "xs:string", + "kind": "ConceptQualifier" + } + ], + "category": "CONSTANT", + "idShort": "ExampleProperty2", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "description": [ + { + "language": "en-us", + "text": "Example Operation object" + }, + { + "language": "de", + "text": "Beispiel Operation Element" + } + ] + }, + { + "modelType": "Capability", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Capabilities/ExampleCapability" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleCapability", + "description": [ + { + "language": "en-us", + "text": "Example Capability object" + }, + { + "language": "de", + "text": "Beispiel Capability Element" + } + ] + }, + { + "modelType": "BasicEventElement", + "observed": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementList", + "value": "ExampleSubmodelElementListOrdered" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Events/ExampleBasicEvent" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleBasicEvent", + "direction": "input", + "state": "on", + "description": [ + { + "language": "en-us", + "text": "Example BasicEvent object" + }, + { + "language": "de", + "text": "Beispiel BasicEvent Element" + } + ] + }, + { + "modelType": "SubmodelElementList", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementListOrdered", + "orderRelevant": true, + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementListOrdered object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementListOrdered Element" + } + ], + "typeValueListElement": "SubmodelElement", + "value": [ + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "value": "exampleValue", + "valueType": "xs:string", + "qualifiers": [ + { + "type": "http://acplt.org/Qualifier/ExampleQualifier", + "valueType": "xs:string", + "kind": "ConceptQualifier" + } + ], + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + }, + { + "modelType": "MultiLanguageProperty", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" + } + ], + "type": "ExternalReference" + }, + "category": "CONSTANT", + "idShort": "ExampleMultiLanguageProperty", + "value": [ + { + "language": "en-us", + "text": "Example value of a MultiLanguageProperty element" + }, + { + "language": "de", + "text": "Beispielswert für ein MultiLanguageProperty-Element" + } + ], + "description": [ + { + "language": "en-us", + "text": "Example MultiLanguageProperty object" + }, + { + "language": "de", + "text": "Beispiel MultiLanguageProperty Element" + } + ] + }, + { + "modelType": "Range", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Ranges/ExampleRange" + } + ], + "type": "ExternalReference" + }, + "max": "100", + "min": "0", + "valueType": "xs:int", + "category": "PARAMETER", + "idShort": "ExampleRange", + "description": [ + { + "language": "en-us", + "text": "Example Range object" + }, + { + "language": "de", + "text": "Beispiel Range Element" + } + ] + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementCollection", + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementCollection object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementCollection Element" + } + ], + "value": [ + { + "modelType": "Blob", + "contentType": "application/pdf", + "value": "AQIDBAU=", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Blobs/ExampleBlob" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleBlob", + "description": [ + { + "language": "en-us", + "text": "Example Blob object" + }, + { + "language": "de", + "text": "Beispiel Blob Element" + } + ] + }, + { + "modelType": "File", + "contentType": "application/pdf", + "value": "file:///TestFile.pdf", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Files/ExampleFile" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleFile", + "description": [ + { + "language": "en-us", + "text": "Example File object" + }, + { + "language": "de", + "text": "Beispiel File Element" + } + ] + }, + { + "modelType": "ReferenceElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleReferenceElement", + "value": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Missing" + }, + { + "type": "SubmodelElementCollection", + "value": "ExampleSubmodelElementCollection" + }, + { + "type": "File", + "value": "ExampleFile" + } + ], + "type": "ModelReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example Reference Element object" + }, + { + "language": "de", + "text": "Beispiel Reference Element Element" + } + ] + } + ] + } + ], + "description": [ + { + "language": "en-us", + "text": "An example submodel for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" + } + ] + }, + { + "modelType": "Submodel", + "kind": "Template", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelTemplates/ExampleSubmodel" + } + ], + "type": "ExternalReference" + }, + "administration": { + "revision": "9", + "version": "0" + }, + "id": "https://acplt.org/Test_Submodel_Template", + "idShort": "TestSubmodelTemplate", + "submodelElements": [ + { + "modelType": "RelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Template" + }, + { + "type": "Operation", + "value": "ExampleOperation" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Template" + }, + { + "type": "Operation", + "value": "ExampleOperation" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example RelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel RelationshipElement Element" + } + ] + }, + { + "modelType": "AnnotatedRelationshipElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/RelationshipElements/ExampleAnnotatedRelationshipElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleAnnotatedRelationshipElement", + "first": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Template" + }, + { + "type": "Operation", + "value": "ExampleOperation" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "second": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Template" + }, + { + "type": "Operation", + "value": "ExampleOperation" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "description": [ + { + "language": "en-us", + "text": "Example AnnotatedRelationshipElement object" + }, + { + "language": "de", + "text": "Beispiel AnnotatedRelationshipElement Element" + } + ] + }, + { + "modelType": "Operation", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Operations/ExampleOperation" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleOperation", + "inoutputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "inputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "outputVariables": [ + { + "value": { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + } + } + ], + "description": [ + { + "language": "en-us", + "text": "Example Operation object" + }, + { + "language": "de", + "text": "Beispiel Operation Element" + } + ] + }, + { + "modelType": "Capability", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Capabilities/ExampleCapability" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleCapability", + "description": [ + { + "language": "en-us", + "text": "Example Capability object" + }, + { + "language": "de", + "text": "Beispiel Capability Element" + } + ] + }, + { + "modelType": "BasicEventElement", + "observed": { + "keys": [ + { + "type": "Submodel", + "value": "https://acplt.org/Test_Submodel_Template" + }, + { + "type": "Operation", + "value": "ExampleOperation" + }, + { + "type": "Property", + "value": "ExampleProperty" + } + ], + "type": "ModelReference" + }, + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Events/ExampleBasicEvent" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleBasicEvent", + "direction": "output", + "state": "off", + "description": [ + { + "language": "en-us", + "text": "Example BasicEvent object" + }, + { + "language": "de", + "text": "Beispiel BasicEvent Element" + } + ] + }, + { + "modelType": "SubmodelElementList", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementLists/ExampleSubmodelElementListOrdered" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementListOrdered", + "orderRelevant": true, + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementListOrdered object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementListOrdered Element" + } + ], + "typeValueListElement": "SubmodelElement", + "value": [ + { + "modelType": "Property", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Properties/ExampleProperty" + } + ], + "type": "ExternalReference" + }, + "valueType": "xs:string", + "category": "CONSTANT", + "idShort": "ExampleProperty", + "description": [ + { + "language": "en-us", + "text": "Example Property object" + }, + { + "language": "de", + "text": "Beispiel Property Element" + } + ] + }, + { + "modelType": "MultiLanguageProperty", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/MultiLanguageProperties/ExampleMultiLanguageProperty" + } + ], + "type": "ExternalReference" + }, + "category": "CONSTANT", + "idShort": "ExampleMultiLanguageProperty", + "description": [ + { + "language": "en-us", + "text": "Example MultiLanguageProperty object" + }, + { + "language": "de", + "text": "Beispiel MultiLanguageProperty Element" + } + ] + }, + { + "modelType": "Range", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Ranges/ExampleRange" + } + ], + "type": "ExternalReference" + }, + "max": "100", + "valueType": "xs:int", + "category": "PARAMETER", + "idShort": "ExampleRange", + "description": [ + { + "language": "en-us", + "text": "Example Range object" + }, + { + "language": "de", + "text": "Beispiel Range Element" + } + ] + }, + { + "modelType": "Range", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Ranges/ExampleRange" + } + ], + "type": "ExternalReference" + }, + "min": "0", + "valueType": "xs:int", + "category": "PARAMETER", + "idShort": "ExampleRange2", + "description": [ + { + "language": "en-us", + "text": "Example Range object" + }, + { + "language": "de", + "text": "Beispiel Range Element" + } + ] + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementCollection", + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementCollection object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementCollection Element" + } + ], + "value": [ + { + "modelType": "Blob", + "contentType": "application/pdf", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Blobs/ExampleBlob" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleBlob", + "description": [ + { + "language": "en-us", + "text": "Example Blob object" + }, + { + "language": "de", + "text": "Beispiel Blob Element" + } + ] + }, + { + "modelType": "File", + "contentType": "application/pdf", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/Files/ExampleFile" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleFile", + "description": [ + { + "language": "en-us", + "text": "Example File object" + }, + { + "language": "de", + "text": "Beispiel File Element" + } + ] + }, + { + "modelType": "ReferenceElement", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/ReferenceElements/ExampleReferenceElement" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleReferenceElement", + "description": [ + { + "language": "en-us", + "text": "Example Reference Element object" + }, + { + "language": "de", + "text": "Beispiel Reference Element Element" + } + ] + } + ] + }, + { + "modelType": "SubmodelElementCollection", + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "http://acplt.org/SubmodelElementCollections/ExampleSubmodelElementCollection" + } + ], + "type": "ExternalReference" + }, + "category": "PARAMETER", + "idShort": "ExampleSubmodelElementCollection2", + "description": [ + { + "language": "en-us", + "text": "Example SubmodelElementCollection object" + }, + { + "language": "de", + "text": "Beispiel SubmodelElementCollection Element" + } + ] + } + ], + "description": [ + { + "language": "en-us", + "text": "An example submodel for the test application" + }, + { + "language": "de", + "text": "Ein Beispiel-Teilmodell für eine Test-Anwendung" + } + ] + } + ] +} 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 5ff3b4e02..926e797a9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,413 +1,413 @@ - - - - - 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.3.0 - 3.6.3 - 3.5.0 - 3.3.1 - 0.8.12 - 4.8.170 - 1.15 - 2.16.1 - 1.26.1 - 3.14.0 - 33.1.0-jre - 5.0.1 - 2.2 - 2.16.2 - 2.0.1.Final - 2.3.1 - 2.1.0 - 4.1.0 - 1.5.1 - 1.4.0 - 4.13.2 - 1.1.1 - 2.7.8 - 5.2.5 - 2.0.12 - 1.3.2 - 4.4.1 - 2.12.1 - 2.9.1 - 5.11.0 - 0.0.20131108.vaadin1 - - - - - org.jacoco - jacoco-maven-plugin - ${plugin.jacoco.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - jacoco-check - - check - - - - - GROUP - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${plugin.compiler.version} - - 11 - 11 - - - - org.codehaus.mojo - flatten-maven-plugin - ${plugin.flatten.version} - - true - - - - - - - - - - - flatten - process-resources - - flatten - - - - flatten.clean - clean - - clean - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - ${plugin.projectinfo.version} - - - org.apache.maven.plugins - maven-source-plugin - ${plugin.source.version} - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${plugin.javadoc.version} - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.6.1 - - - - - - - - MavenCentral - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.2 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - ossrh - https://oss.sonatype.org/ - true - - - - - - - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - - - - org.apache.commons - commons-compress - ${commons-compress.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - junit - junit - ${junit.version} - test - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - org.hamcrest - hamcrest - ${hamcrest.version} - test - - - ${project.groupId} - aas4j-dataformat-core - ${revision} - - - ${project.groupId} - aas4j-dataformat-xml - ${revision} - - - ${project.groupId} - aas4j-model - ${model.version} - - - ${project.groupId} - aas4j-dataformat-core - tests - ${revision} - - - org.apache.poi - poi-ooxml - ${poi.version} - - - commons-io - commons-io - ${commons-io.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - io.github.classgraph - classgraph - ${classgraph.version} - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - pl.pragmatists - JUnitParams - ${junit-params.version} - - - com.vaadin.external.google - android-json - ${vaadin.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - - - org.xmlunit - xmlunit-core - ${xmlunit.version} - test - - - org.xmlunit - xmlunit-matchers - ${xmlunit.version} - test - - - org.hamcrest - hamcrest-core - ${hamcrest.version} - test - - - com.networknt - json-schema-validator - ${json-schema-validator.version} - - - org.skyscreamer - jsonassert - ${jsonassert.version} - test - - - - - - - github - GitHub Apache Maven Packages - https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} - - - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - + + + + + Eclipse AAS Model for Java (AAS4J) implements the specification of the Asset Administration Shell (AAS) such as metamodels, submodels, serialization and deserialization modules, and validators based on the AAS specifications.. + Eclipse Digital Twin - AAS Model for Java (AAS4J) + https://github.com/eclipse-digitaltwin/aas4j + + + SAP SE + https://projects.eclipse.org/projects/dt.aas4j/who + + + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + https://projects.eclipse.org/projects/dt.aas4j/who + + + + + scm:git:git://github.com/eclipse-digitaltwin/aas4j.git + scm:git:git:github.com/eclipse-digitaltwin/aas4j.git + https://github.com/eclipse-digitaltwin/aas4j/tree/main + + + 4.0.0 + org.eclipse.digitaltwin.aas4j + aas4j-dataformat-parent + ${revision} + pom + + model + dataformat-aasx + dataformat-core + dataformat-json + dataformat-xml + + + 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.3.0 + 3.6.3 + 3.5.0 + 3.3.1 + 0.8.12 + 4.8.170 + 1.15 + 2.16.1 + 1.26.1 + 3.14.0 + 33.1.0-jre + 5.0.1 + 2.2 + 2.16.2 + 2.0.1.Final + 2.3.1 + 2.1.0 + 4.1.0 + 1.5.1 + 1.4.0 + 4.13.2 + 1.1.1 + 2.7.8 + 5.2.5 + 2.0.12 + 1.3.2 + 4.4.1 + 2.12.1 + 2.9.1 + 5.11.0 + 0.0.20131108.vaadin1 + + + + + org.jacoco + jacoco-maven-plugin + ${plugin.jacoco.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + jacoco-check + + check + + + + + GROUP + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${plugin.compiler.version} + + 11 + 11 + + + + org.codehaus.mojo + flatten-maven-plugin + ${plugin.flatten.version} + + true + + + + + + + + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${plugin.projectinfo.version} + + + org.apache.maven.plugins + maven-source-plugin + ${plugin.source.version} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${plugin.javadoc.version} + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + + + + + + + + MavenCentral + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.2 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + + + org.apache.commons + commons-compress + ${commons-compress.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + junit + junit + ${junit.version} + test + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + org.hamcrest + hamcrest + ${hamcrest.version} + test + + + ${project.groupId} + aas4j-dataformat-core + ${revision} + + + ${project.groupId} + aas4j-dataformat-xml + ${revision} + + + ${project.groupId} + aas4j-model + ${model.version} + + + ${project.groupId} + aas4j-dataformat-core + tests + ${revision} + + + org.apache.poi + poi-ooxml + ${poi.version} + + + commons-io + commons-io + ${commons-io.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + io.github.classgraph + classgraph + ${classgraph.version} + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + pl.pragmatists + JUnitParams + ${junit-params.version} + + + com.vaadin.external.google + android-json + ${vaadin.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + + + org.xmlunit + xmlunit-core + ${xmlunit.version} + test + + + org.xmlunit + xmlunit-matchers + ${xmlunit.version} + test + + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + + + com.networknt + json-schema-validator + ${json-schema-validator.version} + + + org.skyscreamer + jsonassert + ${jsonassert.version} + test + + + + + + + github + GitHub Apache Maven Packages + https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} + + + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + +