Search in sources :

Example 1 with GetAllSubmodelsBySemanticIdResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsBySemanticIdResponse in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testGetAllSubmodelsBySemanticIdRequest.

@Test
public void testGetAllSubmodelsBySemanticIdRequest() throws ResourceNotFoundException {
    when(persistence.get(null, SUBMODEL_ELEMENT_REF, new OutputModifier())).thenReturn(environment.getSubmodels());
    GetAllSubmodelsBySemanticIdRequest request = new GetAllSubmodelsBySemanticIdRequest.Builder().semanticId(SUBMODEL_ELEMENT_REF).outputModifier(new OutputModifier()).build();
    GetAllSubmodelsBySemanticIdResponse response = manager.execute(request);
    GetAllSubmodelsBySemanticIdResponse expected = new GetAllSubmodelsBySemanticIdResponse.Builder().payload(environment.getSubmodels()).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : GetAllSubmodelsBySemanticIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsBySemanticIdResponse) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) GetAllSubmodelsBySemanticIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsBySemanticIdRequest) Test(org.junit.Test)

Example 2 with GetAllSubmodelsBySemanticIdResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsBySemanticIdResponse in project FAAAST-Service by FraunhoferIOSB.

the class GetAllSubmodelsBySemanticIdRequestHandler method process.

@Override
public GetAllSubmodelsBySemanticIdResponse process(GetAllSubmodelsBySemanticIdRequest request) {
    GetAllSubmodelsBySemanticIdResponse response = new GetAllSubmodelsBySemanticIdResponse();
    try {
        List<Submodel> submodels = persistence.get(null, request.getSemanticId(), request.getOutputModifier());
        response.setPayload(submodels);
        response.setStatusCode(StatusCode.Success);
        if (submodels != null) {
            for (Submodel submodel : submodels) {
                Reference reference = AasUtils.toReference(submodel);
                readValueFromAssetConnectionAndUpdatePersistence(reference, submodel.getSubmodelElements());
                publishElementReadEventMessage(reference, submodel);
            }
        }
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) GetAllSubmodelsBySemanticIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsBySemanticIdResponse) Reference(io.adminshell.aas.v3.model.Reference)

Aggregations

GetAllSubmodelsBySemanticIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsBySemanticIdResponse)2 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 GetAllSubmodelsBySemanticIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsBySemanticIdRequest)1 Reference (io.adminshell.aas.v3.model.Reference)1 Submodel (io.adminshell.aas.v3.model.Submodel)1 Test (org.junit.Test)1