Search in sources :

Example 1 with AssetInformation

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

the class IntegrationTestHttpEndpoint method testPUTAssetInformation.

@Test
public void testPUTAssetInformation() throws IOException, DeserializationException {
    AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
    AssetInformation expected = aas.getAssetInformation();
    expected.setAssetKind(AssetKind.TYPE);
    String url = HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(aas.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)) + "/aas/asset-information";
    HttpResponse response = putCall(url, expected);
    // TODO: StatusCode of spec seems to be wrong 204
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    AssetInformation actual = getCall(url, AssetInformation.class);
    Assert.assertEquals(expected, actual);
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) HttpResponse(org.apache.http.HttpResponse) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 2 with AssetInformation

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

the class JsonSerializerTest method testIdentifiableSerialization.

@Test
public void testIdentifiableSerialization() throws Exception {
    AssetAdministrationShell shell = new DefaultAssetAdministrationShell.Builder().idShort("testShell").assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).build();
    compareToAdminShellIoSerialization(shell);
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) Test(org.junit.Test)

Example 3 with AssetInformation

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

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

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

the class AasServiceNodeManager method addAssetAdministrationShell.

/**
 * Adds the given AssetAdministrationShell.
 *
 * @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 addAssetAdministrationShell(AssetAdministrationShell aas) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        TypeDefinitionBasedNodeBuilderConfiguration.Builder conf = TypeDefinitionBasedNodeBuilderConfiguration.builder();
        Reference derivedFrom = aas.getDerivedFrom();
        if (derivedFrom != null) {
            UaBrowsePath bp = UaBrowsePath.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAssetAdministrationShellType.DERIVED_FROM));
            conf.addOptional(bp);
        }
        this.setNodeBuilderConfiguration(conf.build());
        QualifiedName browseName = UaQualifiedName.from(NAMESPACE_URI, aas.getIdShort()).toQualifiedName(getNamespaceTable());
        String displayName = "AAS:" + aas.getIdShort();
        NodeId nid = new NodeId(getNamespaceIndex(), aas.getIdShort());
        if (findNode(nid) != null) {
            // The NodeId already exists
            nid = getDefaultNodeId();
        }
        AASAssetAdministrationShellType aasShell = createInstance(AASAssetAdministrationShellTypeNode.class, nid, browseName, LocalizedText.english(displayName));
        addIdentifiable(aasShell, aas.getIdentification(), aas.getAdministration(), aas.getCategory());
        // DataSpecifications
        addEmbeddedDataSpecifications(aasShell, aas.getEmbeddedDataSpecifications());
        // AssetInformation
        AssetInformation assetInformation = aas.getAssetInformation();
        if (assetInformation != null) {
            addAssetInformation(aasShell, assetInformation);
        }
        // submodel references
        List<Reference> submodelRefs = aas.getSubmodels();
        if ((submodelRefs != null) && (!submodelRefs.isEmpty())) {
            addSubmodelReferences(aasShell, submodelRefs);
        }
        // add AAS to Environment
        addNodeAndReference(aasEnvironmentNode, aasShell, Identifiers.Organizes);
        referableMap.put(AasUtils.toReference(aas), new ObjectData(aas, aasShell));
    } catch (Throwable ex) {
        logger.error("addAssetAdministrationShell Exception", ex);
        throw ex;
    }
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) 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) TypeDefinitionBasedNodeBuilderConfiguration(com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) UaBrowsePath(com.prosysopc.ua.UaBrowsePath)

Aggregations

UaQualifiedName (com.prosysopc.ua.UaQualifiedName)3 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)3 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)3 LangString (io.adminshell.aas.v3.model.LangString)3 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)2 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)2 AssetInformation (io.adminshell.aas.v3.model.AssetInformation)2 IdentifierKeyValuePair (io.adminshell.aas.v3.model.IdentifierKeyValuePair)2 Reference (io.adminshell.aas.v3.model.Reference)2 DefaultAssetAdministrationShell (io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell)2 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 Test (org.junit.Test)2 UaBrowsePath (com.prosysopc.ua.UaBrowsePath)1 TypeDefinitionBasedNodeBuilderConfiguration (com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration)1 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 AssetKind (io.adminshell.aas.v3.model.AssetKind)1 File (io.adminshell.aas.v3.model.File)1 AASAssetAdministrationShellType (opc.i4aas.AASAssetAdministrationShellType)1 AASAssetInformationType (opc.i4aas.AASAssetInformationType)1 AASIdentifierKeyValuePairList (opc.i4aas.AASIdentifierKeyValuePairList)1