Search in sources :

Example 6 with ConceptDescription

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

the class GetAllConceptDescriptionsByIdShortRequestHandler method process.

@Override
public GetAllConceptDescriptionsByIdShortResponse process(GetAllConceptDescriptionsByIdShortRequest request) {
    GetAllConceptDescriptionsByIdShortResponse response = new GetAllConceptDescriptionsByIdShortResponse();
    try {
        List<ConceptDescription> conceptDescriptions = persistence.get(request.getIdShort(), null, null, request.getOutputModifier());
        response.setPayload(conceptDescriptions);
        response.setStatusCode(StatusCode.Success);
        if (conceptDescriptions != null) {
            conceptDescriptions.forEach(x -> publishElementReadEventMessage(AasUtils.toReference(x), x));
        }
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) GetAllConceptDescriptionsByIdShortResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllConceptDescriptionsByIdShortResponse)

Example 7 with ConceptDescription

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

the class GetAllConceptDescriptionsRequestHandler method process.

@Override
public GetAllConceptDescriptionsResponse process(GetAllConceptDescriptionsRequest request) {
    GetAllConceptDescriptionsResponse response = new GetAllConceptDescriptionsResponse();
    try {
        List<ConceptDescription> conceptDescriptions = persistence.get(null, null, null, request.getOutputModifier());
        response.setPayload(conceptDescriptions);
        response.setStatusCode(StatusCode.Success);
        if (conceptDescriptions != null) {
            conceptDescriptions.forEach(x -> publishElementReadEventMessage(AasUtils.toReference(x), x));
        }
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : GetAllConceptDescriptionsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllConceptDescriptionsResponse) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription)

Example 8 with ConceptDescription

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

the class AasServiceNodeManager method addConceptDescriptionReference.

/**
 * Adds a reference to a ConceptDescription.
 *
 * @param node The desired UA node
 * @param ref The reference to create
 * @throws StatusException If the operation fails
 * @throws ServiceResultException Generic service exception
 */
private void addConceptDescriptionReference(UaNode node, Reference ref) throws StatusException, ServiceResultException {
    try {
        if (ref != null) {
            String name = "ConceptDescription";
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(node, browseName);
            AASReferenceType nodeRef = createInstance(AASReferenceTypeNode.class, nid, browseName, LocalizedText.english(name));
            setAasReferenceData(ref, nodeRef);
            node.addComponent(nodeRef);
            node.addReference(nodeRef, Identifiers.HasDictionaryEntry, false);
        }
    } catch (Throwable ex) {
        logger.error("addConceptDescriptionReference Exception", ex);
        throw ex;
    }
}
Also used : AASReferenceType(opc.i4aas.AASReferenceType) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString)

Example 9 with ConceptDescription

use of io.adminshell.aas.v3.model.ConceptDescription 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 10 with ConceptDescription

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

the class GetAllConceptDescriptionsByIsCaseOfRequestHandler method process.

@Override
public GetAllConceptDescriptionsByIsCaseOfResponse process(GetAllConceptDescriptionsByIsCaseOfRequest request) {
    GetAllConceptDescriptionsByIsCaseOfResponse response = new GetAllConceptDescriptionsByIsCaseOfResponse();
    try {
        List<ConceptDescription> conceptDescriptions = persistence.get(null, request.getIsCaseOf(), null, request.getOutputModifier());
        response.setPayload(conceptDescriptions);
        response.setStatusCode(StatusCode.Success);
        if (conceptDescriptions != null) {
            conceptDescriptions.forEach(x -> publishElementReadEventMessage(AasUtils.toReference(x), x));
        }
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) GetAllConceptDescriptionsByIsCaseOfResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllConceptDescriptionsByIsCaseOfResponse)

Aggregations

ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)18 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)8 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)8 Test (org.junit.Test)7 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)6 Identifier (io.adminshell.aas.v3.model.Identifier)6 Submodel (io.adminshell.aas.v3.model.Submodel)6 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)5 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)5 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)5 DeepCopyHelper (de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper)5 Identifiable (io.adminshell.aas.v3.model.Identifiable)5 Reference (io.adminshell.aas.v3.model.Reference)5 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)5 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)4 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)4 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)4