Search in sources :

Example 1 with DefaultReference

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

the class RequestHandlerManagerTest method testReadValueFromAssetConnection.

@Test
public void testReadValueFromAssetConnection() throws AssetConnectionException {
    RequestHandler requestHandler = new DeleteSubmodelByIdRequestHandler(persistence, messageBus, assetConnectionManager);
    PropertyValue expected = new PropertyValue.Builder().value(new StringValue("test")).build();
    when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
    when(assetValueProvider.getValue()).thenReturn(expected);
    DataElementValue actual = requestHandler.readDataElementValueFromAssetConnection(new DefaultReference());
    Assert.assertEquals(expected, actual);
}
Also used : DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) RequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.RequestHandler) DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) StringValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue) Test(org.junit.Test)

Example 2 with DefaultReference

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

the class AasServiceNodeManager method setReferenceElementValue.

/**
 * Sets the value for the given ReferenceElement.
 *
 * @param refElement The desired ReferenceElement.
 * @param value The new value.
 * @throws StatusException If the operation fails
 */
private void setReferenceElementValue(AASReferenceElementType refElement, ReferenceElementValue value) throws StatusException {
    if (refElement == null) {
        throw new IllegalArgumentException("refElement is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        DefaultReference ref = new DefaultReference.Builder().keys(value.getKeys()).build();
        setAasReferenceData(ref, refElement.getValueNode());
    } catch (Throwable ex) {
        logger.error("setReferenceElementValue Exception", ex);
        throw ex;
    }
}
Also used : DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference)

Example 3 with DefaultReference

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

the class AasServiceNodeManager method setEntityValue.

/**
 * Sets the values for the given Entity.
 *
 * @param entity The desired Entity.
 * @param value The new value.
 * @throws StatusException If the operation fails
 */
private void setEntityValue(AASEntityType entity, EntityValue value) throws StatusException {
    if (entity == null) {
        throw new IllegalArgumentException("entity is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        // EntityType
        entity.setEntityType(ValueConverter.getAasEntityType(value.getEntityType()));
        // GlobalAssetId
        if ((value.getGlobalAssetId() != null) && (value.getGlobalAssetId().size() > 0)) {
            DefaultReference ref = new DefaultReference.Builder().keys(value.getGlobalAssetId()).build();
            setAasReferenceData(ref, entity.getGlobalAssetIdNode());
        }
        // Statements
        Map<String, ElementValue> valueMap = value.getStatements();
        AASSubmodelElementList statementNode = entity.getStatementNode();
        if (statementNode != null) {
            UaNode[] statementNodes = statementNode.getComponents();
            if (statementNodes.length != valueMap.size()) {
                logger.warn("Size of Value (" + valueMap.size() + ") doesn't match the number of StatementNodes (" + statementNodes.length + ")");
                throw new IllegalArgumentException("Size of Value doesn't match the number of StatementNodes");
            }
            for (UaNode statementNode1 : statementNodes) {
                if (statementNode1 instanceof AASSubmodelElementType) {
                    if (value.getStatements().containsKey(statementNode1.getBrowseName().getName())) {
                        setSubmodelElementValue((AASSubmodelElementType) statementNode1, value.getStatements().get(statementNode1.getBrowseName().getName()));
                    }
                }
            }
        }
    } catch (Throwable ex) {
        logger.error("setEntityValue Exception", ex);
        throw ex;
    }
}
Also used : AASSubmodelElementList(opc.i4aas.AASSubmodelElementList) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) ReferenceElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference)

Example 4 with DefaultReference

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

the class RequestHandlerManagerTest method testWriteValueToAssetConnection.

@Test
public void testWriteValueToAssetConnection() throws AssetConnectionException {
    RequestHandler requestHandler = new DeleteSubmodelByIdRequestHandler(persistence, messageBus, assetConnectionManager);
    PropertyValue expected = new PropertyValue.Builder().value(new StringValue("test")).build();
    when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
    requestHandler.writeValueToAssetConnection(new DefaultReference(), expected);
    verify(assetValueProvider).setValue(expected);
}
Also used : DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) RequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.RequestHandler) DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) StringValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Example 5 with DefaultReference

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

the class PersistenceInMemoryTest method getSubmodelsNullTest.

@Test
public void getSubmodelsNullTest() {
    String AAS_ID = "Test_AssetAdministrationShell_Mandatory";
    List<AssetAdministrationShell> actualAASList = persistence.get(AAS_ID, new DefaultReference(), new QueryModifier());
    List<AssetAdministrationShell> expectedAASList = null;
    Assert.assertEquals(expectedAASList, actualAASList);
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Aggregations

DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)5 Test (org.junit.Test)3 DataElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue)2 PropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue)2 StringValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue)2 DeleteSubmodelByIdRequestHandler (de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler)2 RequestHandler (de.fraunhofer.iosb.ilt.faaast.service.request.handler.RequestHandler)2 UaNode (com.prosysopc.ua.nodes.UaNode)1 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)1 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)1 AnnotatedRelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue)1 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)1 ReferenceElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue)1 RelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 LangString (io.adminshell.aas.v3.model.LangString)1 AASSubmodelElementList (opc.i4aas.AASSubmodelElementList)1 AASSubmodelElementType (opc.i4aas.AASSubmodelElementType)1