Search in sources :

Example 1 with IdentifierKeyValuePair

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

the class AasServiceNodeManager method addAasEntity.

/**
 * Adds an AAS entity to the given node.
 *
 * @param node The desired UA node
 * @param aasEntity The AAS entity to add
 * @param submodel The corresponding Submodel
 * @param parentRef The AAS reference to the parent object
 * @param ordered Specifies whether the entity should be added ordered
 *            (true) or unordered (false)
 * @throws StatusException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 * @throws ServiceResultException If the operation fails
 */
private void addAasEntity(UaNode node, Entity aasEntity, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        if ((node != null) && (aasEntity != null)) {
            String name = aasEntity.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASEntityType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASEntityType entityNode = createInstance(AASEntityType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(entityNode, aasEntity);
            Reference entityRef = AasUtils.toReference(parentRef, aasEntity);
            // EntityType
            entityNode.setEntityType(ValueConverter.getAasEntityType(aasEntity.getEntityType()));
            submodelElementAasMap.put(entityNode.getEntityTypeNode().getNodeId(), new SubmodelElementData(aasEntity, submodel, SubmodelElementData.Type.ENTITY_TYPE, entityRef));
            // GlobalAssetId
            if (aasEntity.getGlobalAssetId() != null) {
                if (entityNode.getGlobalAssetIdNode() == null) {
                    addAasReferenceAasNS(entityNode, aasEntity.getGlobalAssetId(), AASEntityType.GLOBAL_ASSET_ID, false);
                } else {
                    setAasReferenceData(aasEntity.getGlobalAssetId(), entityNode.getGlobalAssetIdNode(), false);
                }
                submodelElementAasMap.put(entityNode.getGlobalAssetIdNode().getKeysNode().getNodeId(), new SubmodelElementData(aasEntity, submodel, SubmodelElementData.Type.ENTITY_GLOBAL_ASSET_ID, entityRef));
            }
            // SpecificAssetIds
            IdentifierKeyValuePair specificAssetId = aasEntity.getSpecificAssetId();
            if (specificAssetId != null) {
                if (entityNode.getSpecificAssetIdNode() == null) {
                    addIdentifierKeyValuePair(entityNode, specificAssetId, AASEntityType.SPECIFIC_ASSET_ID);
                } else {
                    setIdentifierKeyValuePairData(entityNode.getSpecificAssetIdNode(), specificAssetId);
                }
            }
            // Statements
            addSubmodelElements(entityNode.getStatementNode(), aasEntity.getStatements(), submodel, entityRef);
            submodelElementOpcUAMap.put(entityRef, entityNode);
            if (ordered) {
                node.addReference(entityNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(entityNode);
            }
            referableMap.put(entityRef, new ObjectData(aasEntity, entityNode, submodel));
        }
    } catch (Throwable ex) {
        logger.error("addAasEntity Exception", ex);
        throw ex;
    }
}
Also used : AASEntityType(opc.i4aas.AASEntityType) IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 2 with IdentifierKeyValuePair

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

the class GetAllAssetAdministrationShellsByAssetIdRequestHandler method process.

@Override
public GetAllAssetAdministrationShellsByAssetIdResponse process(GetAllAssetAdministrationShellsByAssetIdRequest request) {
    GetAllAssetAdministrationShellsByAssetIdResponse response = new GetAllAssetAdministrationShellsByAssetIdResponse();
    try {
        List<AssetIdentification> assetIdentifications = new ArrayList<>();
        List<IdentifierKeyValuePair> identifierKeyValuePairs = request.getAssetIds();
        for (IdentifierKeyValuePair pair : identifierKeyValuePairs) {
            AssetIdentification id = null;
            if (pair.getKey().equalsIgnoreCase("globalAssetId")) {
                id = new GlobalAssetIdentification.Builder().reference(new DefaultReference.Builder().key(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.GLOBAL_REFERENCE).value(pair.getValue()).build()).build()).build();
            } else {
                id = new SpecificAssetIdentification.Builder().value(pair.getValue()).key(pair.getKey()).build();
            }
            assetIdentifications.add(id);
        }
        List<AssetAdministrationShell> shells = new ArrayList<>(persistence.get(null, assetIdentifications, request.getOutputModifier()));
        response.setPayload(shells);
        response.setStatusCode(StatusCode.Success);
        shells.forEach(x -> publishElementReadEventMessage(AasUtils.toReference(x), x));
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) GetAllAssetAdministrationShellsByAssetIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsByAssetIdResponse) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) SpecificAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) ArrayList(java.util.ArrayList) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference)

Example 3 with IdentifierKeyValuePair

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

the class AasServiceNodeManager method addAssetInformation.

/**
 * Adds an AssetInformation object to the given Node.
 *
 * @param aasNode The AAS node where the AssetInformation should be added
 * @param assetInformation The desired AssetInformation object
 * @throws StatusException If the operation fails
 */
private void addAssetInformation(AASAssetAdministrationShellType aasNode, AssetInformation assetInformation) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    if (aasNode == null) {
        throw new IllegalArgumentException("aasNode = null");
    } else if (assetInformation == null) {
        throw new IllegalArgumentException("assetInformation = null");
    }
    try {
        boolean created = false;
        AASAssetInformationType assetInfoNode;
        assetInfoNode = aasNode.getAssetInformationNode();
        if (assetInfoNode == null) {
            String displayName = "AssetInformation";
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelType.getNamespaceUri(), displayName).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(aasNode, browseName);
            assetInfoNode = createInstance(AASAssetInformationType.class, nid, browseName, LocalizedText.english(displayName));
            created = true;
        }
        if (assetInfoNode != null) {
            // AssetKind
            AssetKind assetKind = assetInformation.getAssetKind();
            assetInfoNode.setAssetKind(ValueConverter.convertAssetKind(assetKind));
            // BillOfMaterials
            List<Reference> assetBills = assetInformation.getBillOfMaterials();
            if ((assetBills != null) && (!assetBills.isEmpty())) {
                AASReferenceList assetBillsNode = assetInfoNode.getBillOfMaterialNode();
                addBillOfMaterials(assetBillsNode, assetBills);
            }
            // DefaultThumbnail
            File thumbnail = assetInformation.getDefaultThumbnail();
            if (thumbnail != null) {
                addAasFile(assetInfoNode, thumbnail, null, null, false, AASAssetInformationType.DEFAULT_THUMBNAIL);
            }
            // GlobalAssetId
            Reference globalAssetId = assetInformation.getGlobalAssetId();
            if (globalAssetId != null) {
                addAasReferenceAasNS(assetInfoNode, globalAssetId, AASAssetInformationType.GLOBAL_ASSET_ID);
            }
            // SpecificAssetIds
            List<IdentifierKeyValuePair> specificAssetIds = assetInformation.getSpecificAssetIds();
            if ((specificAssetIds != null) && (!specificAssetIds.isEmpty())) {
                addSpecificAssetIds(assetInfoNode, specificAssetIds, "SpecificAssetIds");
            }
            if (created) {
                aasNode.addComponent(assetInfoNode);
            }
        }
    } catch (Throwable ex) {
        logger.error("addAssetInformation Exception", ex);
        throw ex;
    }
}
Also used : IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) AASAssetInformationType(opc.i4aas.AASAssetInformationType) AssetKind(io.adminshell.aas.v3.model.AssetKind) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) AASReferenceList(opc.i4aas.AASReferenceList) File(io.adminshell.aas.v3.model.File)

Example 4 with IdentifierKeyValuePair

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

the class AasServiceNodeManager method addSpecificAssetIds.

/**
 * Adds a list of IdentifierKeyValuePairs to the given Node.
 *
 * @param assetInfoNode The AssetInformation node in which the
 *            IdentifierKeyValuePairs should be created or added
 * @param list The desired list of IdentifierKeyValuePairs
 * @param name The desired name of the Node
 * @throws StatusException If the operation fails
 */
private void addSpecificAssetIds(AASAssetInformationType assetInfoNode, List<IdentifierKeyValuePair> list, String name) throws StatusException {
    if (assetInfoNode == null) {
        throw new IllegalArgumentException("assetInfoNode = null");
    } else if (list == null) {
        throw new IllegalArgumentException("list = null");
    }
    try {
        logger.info("addSpecificAssetIds " + name + "; to Node: " + assetInfoNode.toString());
        AASIdentifierKeyValuePairList listNode = assetInfoNode.getSpecificAssetIdNode();
        boolean created = false;
        if (listNode == null) {
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASIdentifierKeyValuePairList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(assetInfoNode, browseName);
            listNode = createInstance(AASIdentifierKeyValuePairList.class, nid, browseName, LocalizedText.english(name));
            created = true;
        }
        for (IdentifierKeyValuePair ikv : list) {
            if (ikv != null) {
                addIdentifierKeyValuePair(listNode, ikv, ikv.getKey());
            }
        }
        if (created) {
            assetInfoNode.addComponent(listNode);
        }
    } catch (Throwable ex) {
        logger.error("addSpecificAssetIds Exception", ex);
        throw ex;
    }
}
Also used : IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) AASIdentifierKeyValuePairList(opc.i4aas.AASIdentifierKeyValuePairList) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId)

Example 5 with IdentifierKeyValuePair

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

the class RequestMappingManagerTest method testGetAllAssetAdministrationShellsByAssetId.

@Test
public void testGetAllAssetAdministrationShellsByAssetId() throws SerializationException, InvalidRequestException {
    List<IdentifierKeyValuePair> assetIds = Arrays.asList(new DefaultIdentifierKeyValuePair.Builder().key(GLOBAL_ASSET_ID).value(AAS.getAssetInformation().getGlobalAssetId().getKeys().get(0).getValue()).build());
    Request expected = GetAllAssetAdministrationShellsByAssetIdRequest.builder().outputModifier(OutputModifier.DEFAULT).assetIds(assetIds).build();
    Request actual = mappingManager.map(HttpRequest.builder().method(HttpMethod.GET).path("shells").query("assetIds=" + EncodingHelper.base64UrlEncode(serializer.write(assetIds))).build());
    Assert.assertEquals(expected, actual);
}
Also used : DefaultIdentifierKeyValuePair(io.adminshell.aas.v3.model.impl.DefaultIdentifierKeyValuePair) IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) GetAllAssetAdministrationShellsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest) InvokeOperationSyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationSyncRequest) PutSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelElementByPathRequest) PutConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutConceptDescriptionByIdRequest) PutSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelRequest) SetSubmodelElementValueByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.SetSubmodelElementValueByPathRequest) GetAllConceptDescriptionsByIsCaseOfRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByIsCaseOfRequest) DeleteAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAllAssetLinksByIdRequest) PostSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelElementByPathRequest) PostConceptDescriptionRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostConceptDescriptionRequest) PostAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAssetAdministrationShellRequest) PostAASXPackageRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAASXPackageRequest) GetAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetAdministrationShellByIdRequest) InvokeOperationAsyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationAsyncRequest) GetAllSubmodelElementsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelElementsRequest) GetAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetLinksByIdRequest) PutSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelByIdRequest) HttpRequest(de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.model.HttpRequest) PutAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetAdministrationShellRequest) DeleteConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteConceptDescriptionByIdRequest) GetAssetInformationRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetInformationRequest) GetAllSubmodelsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsRequest) DeleteSubmodelReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelReferenceRequest) PostSubmodelElementRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelElementRequest) Request(de.fraunhofer.iosb.ilt.faaast.service.model.api.Request) GetAllSubmodelsBySemanticIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsBySemanticIdRequest) GetSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelByIdRequest) PostSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelRequest) DeleteSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelElementByPathRequest) GetAllSubmodelsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsByIdShortRequest) GetSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelElementByPathRequest) GetOperationAsyncResultRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetOperationAsyncResultRequest) GetAllSubmodelReferencesRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelReferencesRequest) PutAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetAdministrationShellByIdRequest) GetAllConceptDescriptionsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByIdShortRequest) PostAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAllAssetLinksByIdRequest) DeleteSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelByIdRequest) GetAllConceptDescriptionsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsRequest) PutAssetInformationRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetInformationRequest) DeleteAASXPackageByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAASXPackageByIdRequest) GetAllConceptDescriptionsByDataSpecificationReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByDataSpecificationReferenceRequest) GetAASXByPackageIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAASXByPackageIdRequest) GetAllAssetAdministrationShellIdsByAssetLinkRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellIdsByAssetLinkRequest) GetAllAssetAdministrationShellsByAssetIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByAssetIdRequest) GetAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetAdministrationShellRequest) GetSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelRequest) GetAllAssetAdministrationShellsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByIdShortRequest) DeleteAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAssetAdministrationShellByIdRequest) PostSubmodelReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelReferenceRequest) GetAllAASXPackageIdsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAASXPackageIdsRequest) GetConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetConceptDescriptionByIdRequest) Test(org.junit.Test)

Aggregations

IdentifierKeyValuePair (io.adminshell.aas.v3.model.IdentifierKeyValuePair)6 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)4 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)3 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)3 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)3 Reference (io.adminshell.aas.v3.model.Reference)3 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)2 GetAllAssetAdministrationShellsByAssetIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsByAssetIdResponse)2 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)2 SpecificAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification)2 GetAllAssetAdministrationShellsByAssetIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByAssetIdRequest)2 DefaultIdentifierKeyValuePair (io.adminshell.aas.v3.model.impl.DefaultIdentifierKeyValuePair)2 Test (org.junit.Test)2 HttpRequest (de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.model.HttpRequest)1 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)1 Request (de.fraunhofer.iosb.ilt.faaast.service.model.api.Request)1 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)1 DeleteAASXPackageByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAASXPackageByIdRequest)1 DeleteAllAssetLinksByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAllAssetLinksByIdRequest)1