Search in sources :

Example 1 with EmbeddedDataSpecification

use of io.adminshell.aas.v3.model.EmbeddedDataSpecification in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method elementCreated.

/**
 * Handles an elementCreated event.
 *
 * @param element Reference to the created element.
 * @param value The element that was added.
 * @throws StatusException If the operation fails
 * @throws ServiceResultException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 */
private void elementCreated(Reference element, Referable value) throws StatusException, ServiceResultException, ServiceException, AddressSpaceException {
    if (element == null) {
        throw new IllegalArgumentException("element is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        logger.debug("elementCreated called. Reference " + AasUtils.asString(element));
        // The element is the parent object where the value is added
        ObjectData parent = null;
        if (referableMap.containsKey(element)) {
            parent = referableMap.get(element);
        } else {
            logger.info("elementCreated: element not found in referableMap: " + AasUtils.asString(element));
        }
        if (value instanceof ConceptDescription) {
            addConceptDescriptions(List.of((ConceptDescription) value));
        } else if (value instanceof Asset) {
            addAsset(aasEnvironmentNode, (Asset) value);
        } else if (value instanceof Submodel) {
            addSubmodel(aasEnvironmentNode, (Submodel) value);
        } else if (value instanceof AssetAdministrationShell) {
            addAssetAdministrationShell((AssetAdministrationShell) value);
        } else if (parent != null) {
            if (value instanceof EmbeddedDataSpecification) {
                if (parent.getNode() instanceof AASAssetAdministrationShellType) {
                    addEmbeddedDataSpecifications((AASAssetAdministrationShellType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelType) {
                    addEmbeddedDataSpecifications((AASSubmodelType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addEmbeddedDataSpecifications((AASSubmodelElementType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASAssetType) {
                    addEmbeddedDataSpecifications((AASAssetType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else {
                    logger.warn("elementCreated: EmbeddedDataSpecification parent class not found");
                }
            } else if (value instanceof Constraint) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    addQualifiers(((AASSubmodelType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addQualifiers(((AASSubmodelElementType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else {
                    logger.warn("elementCreated: Constraint parent class not found");
                }
            } else if (value instanceof SubmodelElement) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    logger.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), (Submodel) parent.getReferable(), element);
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    logger.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), parent.getSubmodel(), element);
                } else {
                    logger.warn("elementCreated: SubmodelElement parent class not found: " + parent.getNode().getNodeId().toString() + "; " + parent.getNode());
                }
            }
        } else {
            logger.warn("elementCreated: element not found: " + AasUtils.asString(element));
        }
    } catch (Throwable ex) {
        logger.error("elementCreated Exception", ex);
        throw ex;
    }
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) AASAssetType(opc.i4aas.AASAssetType) Constraint(io.adminshell.aas.v3.model.Constraint) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) AASSubmodelType(opc.i4aas.AASSubmodelType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) Asset(io.adminshell.aas.v3.model.Asset) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription)

Example 2 with EmbeddedDataSpecification

use of io.adminshell.aas.v3.model.EmbeddedDataSpecification in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param assetNode The desired node where the DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASAssetType assetNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = assetNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(assetNode, refList, AASAssetType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Throwable ex) {
        logger.error("addEmbeddedDataSpecifications Exception", ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList)

Example 3 with EmbeddedDataSpecification

use of io.adminshell.aas.v3.model.EmbeddedDataSpecification in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param aasNode The desired object where the DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASAssetAdministrationShellType aasNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = aasNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(aasNode, refList, AASAssetAdministrationShellType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Throwable ex) {
        logger.error("addEmbeddedDataSpecifications Exception", ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList)

Example 4 with EmbeddedDataSpecification

use of io.adminshell.aas.v3.model.EmbeddedDataSpecification in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param submodelNode The desired object where the DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASSubmodelType submodelNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = submodelNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(submodelNode, refList, AASSubmodelType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Throwable ex) {
        logger.error("addEmbeddedDataSpecifications Exception", ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList)

Example 5 with EmbeddedDataSpecification

use of io.adminshell.aas.v3.model.EmbeddedDataSpecification in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param submodelElementNode The desired object where the
 *            DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASSubmodelElementType submodelElementNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = submodelElementNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(submodelElementNode, refList, AASSubmodelElementType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Throwable ex) {
        logger.error("addEmbeddedDataSpecifications Exception", ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList)

Aggregations

EmbeddedDataSpecification (io.adminshell.aas.v3.model.EmbeddedDataSpecification)5 Reference (io.adminshell.aas.v3.model.Reference)4 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)4 ArrayList (java.util.ArrayList)4 AASReferenceList (opc.i4aas.AASReferenceList)4 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 Asset (io.adminshell.aas.v3.model.Asset)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)1 Constraint (io.adminshell.aas.v3.model.Constraint)1 Submodel (io.adminshell.aas.v3.model.Submodel)1 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)1 AASAssetAdministrationShellType (opc.i4aas.AASAssetAdministrationShellType)1 AASAssetType (opc.i4aas.AASAssetType)1 AASSubmodelElementType (opc.i4aas.AASSubmodelElementType)1 AASSubmodelType (opc.i4aas.AASSubmodelType)1