Search in sources :

Example 1 with GetPowerUsageHistoryDeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting get power usage history request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    Boolean isScheduled = null;
    int retryCount = 0;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        isScheduled = message.getBooleanProperty(Constants.IS_SCHEDULED);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        LOGGER.debug("scheduled: {}", isScheduled);
        return;
    }
    try {
        final PowerUsageHistoryMessageDataContainerDto powerUsageHistoryMessageDataContainerDto = (PowerUsageHistoryMessageDataContainerDto) message.getObject();
        LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
        final GetPowerUsageHistoryDeviceRequest deviceRequest = new GetPowerUsageHistoryDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, powerUsageHistoryMessageDataContainerDto, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
        this.deviceService.getPowerUsageHistory(deviceRequest);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : GetPowerUsageHistoryDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest) JMSException(javax.jms.JMSException) PowerUsageHistoryMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryMessageDataContainerDto) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 2 with GetPowerUsageHistoryDeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleGetPowerUsageHistoryDeviceResponse(deviceResponse, null, PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, isScheduled, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, ((PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData()).getRequestContainer(), PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    try {
        final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = (PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData();
        final TimePeriodDto timePeriod = new TimePeriodDto(powerUsageHistoryResponseMessageDataContainer.getStartTime(), powerUsageHistoryResponseMessageDataContainer.getEndTime());
        final HistoryTermTypeDto historyTermType = powerUsageHistoryResponseMessageDataContainer.getHistoryTermType();
        final GetPowerUsageHistoryDeviceRequest deviceRequest = new GetPowerUsageHistoryDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, new PowerUsageHistoryMessageDataContainerDto(timePeriod, historyTermType), domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
        this.deviceService.doGetPowerUsageHistory(oslpEnvelope, powerUsageHistoryResponseMessageDataContainer, deviceRequest, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope) PowerUsageHistoryResponseMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse) GetPowerUsageHistoryDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) HistoryTermTypeDto(com.alliander.osgp.dto.valueobjects.HistoryTermTypeDto) PowerUsageHistoryMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryMessageDataContainerDto) TimePeriodDto(com.alliander.osgp.dto.valueobjects.TimePeriodDto)

Aggregations

GetPowerUsageHistoryDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest)2 PowerUsageHistoryMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryMessageDataContainerDto)2 IOException (java.io.IOException)2 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)1 DeviceResponseHandler (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler)1 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse)1 HistoryTermTypeDto (com.alliander.osgp.dto.valueobjects.HistoryTermTypeDto)1 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)1 TimePeriodDto (com.alliander.osgp.dto.valueobjects.TimePeriodDto)1 OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)1 UnsignedOslpEnvelopeDto (com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto)1 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)1 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)1 JMSException (javax.jms.JMSException)1