Search in sources :

Example 1 with ScanMbusChannelsResponseData

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData in project open-smart-grid-platform by OSGP.

the class SmartMeteringAdhocEndpoint method getScanMbusChannelsResponse.

@PayloadRoot(localPart = "ScanMbusChannelsAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public ScanMbusChannelsResponse getScanMbusChannelsResponse(@RequestPayload final ScanMbusChannelsAsyncRequest request) throws OsgpException {
    ScanMbusChannelsResponse response = null;
    try {
        response = new ScanMbusChannelsResponse();
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "retrieving the scan m-bus channels response");
        response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
        final ScanMbusChannelsResponseData scanMbusChannelsResponse = (ScanMbusChannelsResponseData) responseData.getMessageData();
        if (ResponseMessageResultType.OK == responseData.getResultType()) {
            final List<MbusChannelShortEquipmentIdentifier> channelShortIds = response.getChannelShortIds();
            channelShortIds.addAll(this.adhocMapper.mapAsList(scanMbusChannelsResponse.getChannelShortIds(), MbusChannelShortEquipmentIdentifier.class));
        } else if (responseData.getMessageData() instanceof OsgpException) {
            throw (OsgpException) responseData.getMessageData();
        } else if (responseData.getMessageData() instanceof Exception) {
            throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", (Exception) responseData.getMessageData());
        } else {
            throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", null);
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) MbusChannelShortEquipmentIdentifier(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.MbusChannelShortEquipmentIdentifier) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ScanMbusChannelsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsResponse) ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) 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 ScanMbusChannelsResponseData

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData in project open-smart-grid-platform by OSGP.

the class AdhocService method handleScanMbusChannelsResponse.

public void handleScanMbusChannelsResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final ScanMbusChannelsResponseDto resultData) {
    LOGGER.debug("handleScanMbusChannelsResponse for MessageType: {}", messageMetadata.getMessageType());
    ResponseMessageResultType result = deviceResult;
    if (exception != null) {
        LOGGER.error(DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION, exception);
        result = ResponseMessageResultType.NOT_OK;
    }
    final ScanMbusChannelsResponseData scanMbusChannelsResponseData = this.mapperFactory.getMapperFacade().map(resultData, ScanMbusChannelsResponseData.class);
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(scanMbusChannelsResponseData).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : ScanMbusChannelsResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

Aggregations

ScanMbusChannelsResponseData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData)2 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 MbusChannelShortEquipmentIdentifier (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.MbusChannelShortEquipmentIdentifier)1 ScanMbusChannelsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.ScanMbusChannelsResponse)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1