Search in sources :

Example 1 with AssetIdentification

use of de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testGetAllAssetAdministrationShellRequest.

@Test
public void testGetAllAssetAdministrationShellRequest() {
    when(persistence.get(any(), argThat((List<AssetIdentification> t) -> true), any())).thenReturn(environment.getAssetAdministrationShells());
    GetAllAssetAdministrationShellsRequest request = new GetAllAssetAdministrationShellsRequest();
    GetAllAssetAdministrationShellsResponse response = manager.execute(request);
    GetAllAssetAdministrationShellsResponse expected = new GetAllAssetAdministrationShellsResponse.Builder().payload(environment.getAssetAdministrationShells()).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : SpecificAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) GetAllAssetAdministrationShellsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse) GetAllAssetAdministrationShellsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest) Test(org.junit.Test)

Example 2 with AssetIdentification

use of de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testGetAllAssetAdministrationShellRequestAsync.

@Test
public void testGetAllAssetAdministrationShellRequestAsync() throws InterruptedException {
    when(persistence.get(any(), argThat((List<AssetIdentification> t) -> true), any())).thenReturn(environment.getAssetAdministrationShells());
    GetAllAssetAdministrationShellsRequest request = new GetAllAssetAdministrationShellsRequest();
    final AtomicReference<GetAllAssetAdministrationShellsResponse> response = new AtomicReference<>();
    CountDownLatch condition = new CountDownLatch(1);
    manager.executeAsync(request, x -> response.set(x));
    condition.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
    Assert.assertEquals(environment.getAssetAdministrationShells(), response.get().getPayload());
}
Also used : SpecificAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) GetAllAssetAdministrationShellsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) GetAllAssetAdministrationShellsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest) Test(org.junit.Test)

Example 3 with AssetIdentification

use of de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification in project FAAAST-Service by FraunhoferIOSB.

the class GetAllAssetAdministrationShellsByIdShortRequestHandler method process.

@Override
public GetAllAssetAdministrationShellsByIdShortResponse process(GetAllAssetAdministrationShellsByIdShortRequest request) {
    GetAllAssetAdministrationShellsByIdShortResponse response = new GetAllAssetAdministrationShellsByIdShortResponse();
    try {
        List<AssetAdministrationShell> shells = persistence.get(request.getIdShort(), (List<AssetIdentification>) null, request.getOutputModifier());
        response.setPayload(shells);
        response.setStatusCode(StatusCode.Success);
        if (shells != null) {
            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) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) GetAllAssetAdministrationShellsByIdShortResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsByIdShortResponse)

Example 4 with AssetIdentification

use of de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification in project FAAAST-Service by FraunhoferIOSB.

the class GetAllAssetAdministrationShellsRequestHandler method process.

@Override
public GetAllAssetAdministrationShellsResponse process(GetAllAssetAdministrationShellsRequest request) {
    GetAllAssetAdministrationShellsResponse response = new GetAllAssetAdministrationShellsResponse();
    try {
        List<AssetAdministrationShell> shells = persistence.get(null, (List<AssetIdentification>) null, request.getOutputModifier());
        response.setPayload(shells);
        response.setStatusCode(StatusCode.Success);
        if (shells != null) {
            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) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) GetAllAssetAdministrationShellsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse)

Example 5 with AssetIdentification

use of de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification 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)

Aggregations

AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)8 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)6 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)5 Test (org.junit.Test)5 SpecificAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification)4 GetAllAssetAdministrationShellsResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse)3 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)2 GetAllAssetAdministrationShellsByIdShortResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsByIdShortResponse)2 GetAllAssetAdministrationShellsRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest)2 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)2 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)1 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)1 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)1 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)1 Extend (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend)1 Level (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level)1 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 ExecutionState (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.ExecutionState)1 OperationHandle (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle)1