Search in sources :

Example 1 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class AdHocManagementEndpoint method getData.

// === GET DATA ===
@PayloadRoot(localPart = "GetDataRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDataAsyncResponse getData(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDataRequest request) throws OsgpException {
    LOGGER.info("Get Data Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
    final GetDataAsyncResponse response = new GetDataAsyncResponse();
    try {
        final org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataRequest dataRequest = this.mapper.map(request, org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataRequest.class);
        final String correlationUid = this.service.enqueueGetDataRequest(organisationIdentification, request.getDeviceIdentification(), dataRequest);
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncResponse) GetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse) GetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class AdHocManagementEndpoint method setData.

// === SET DATA ===
@PayloadRoot(localPart = "SetDataRequest", namespace = NAMESPACE)
@ResponsePayload
public SetDataAsyncResponse setData(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDataRequest request) throws OsgpException {
    LOGGER.info("Set Data Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
    final SetDataAsyncResponse response = new SetDataAsyncResponse();
    try {
        final org.opensmartgridplatform.domain.microgrids.valueobjects.SetDataRequest setDataRequest = this.mapper.map(request, org.opensmartgridplatform.domain.microgrids.valueobjects.SetDataRequest.class);
        final String correlationUid = this.service.enqueueSetDataRequest(organisationIdentification, request.getDeviceIdentification(), setDataRequest);
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncResponse) SetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncResponse) GetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException)2 GetDataAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse)2 SetDataAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncResponse)2 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncResponse)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)2 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)2 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)2