Search in sources :

Example 1 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.

private void handleGetConfigurationDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final DomainInformation domainInformation, final String messageType, final int retryCount, final boolean isScheduled) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    ConfigurationDto configuration = null;
    try {
        final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
        configuration = response.getConfiguration();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
    }
    final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceResponse.getDeviceIdentification()).withOrganisationIdentification(deviceResponse.getOrganisationIdentification()).withCorrelationUid(deviceResponse.getCorrelationUid()).withMessageType(messageType).withDomain(domainInformation.getDomain()).withDomainVersion(domainInformation.getDomainVersion()).withMessagePriority(deviceResponse.getMessagePriority()).withScheduled(isScheduled).withRetryCount(retryCount).build();
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(configuration).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)

Example 2 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class CommonGetConfigurationResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing common get configuration response message");
    String correlationUid = null;
    String messageType = null;
    int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
    String organisationIdentification = null;
    String deviceIdentification = null;
    ResponseMessage responseMessage;
    ResponseMessageResultType responseMessageResultType = null;
    OsgpException osgpException = null;
    Object dataObject;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        messagePriority = message.getJMSPriority();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        responseMessage = (ResponseMessage) message.getObject();
        responseMessageResultType = responseMessage.getResult();
        osgpException = responseMessage.getOsgpException();
        dataObject = responseMessage.getDataObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("messagePriority: {}", messagePriority);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("osgpException", osgpException);
        return;
    }
    try {
        LOGGER.info("Calling application service function to handle response: {}", messageType);
        final ConfigurationDto configurationDto = (ConfigurationDto) dataObject;
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.configurationManagementService.handleGetConfigurationResponse(configurationDto, ids, messageType, messagePriority, responseMessageResultType, osgpException);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Example 3 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class DomainCoreMapperTest method convertsConfigurationDtoToConfiguration.

@Test
void convertsConfigurationDtoToConfiguration() {
    final ConfigurationDto source = this.aConfigurationDto();
    final Configuration result = this.mapper.map(source, Configuration.class);
    assertThat(result).usingRecursiveComparison().isEqualTo(this.toConfiguration(source));
}
Also used : DaliConfigurationDto(org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto) RelayConfigurationDto(org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) RelayConfiguration(org.opensmartgridplatform.domain.core.valueobjects.RelayConfiguration) DaliConfiguration(org.opensmartgridplatform.domain.core.valueobjects.DaliConfiguration) Configuration(org.opensmartgridplatform.domain.core.valueobjects.Configuration) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method buildDeviceResponseGetConfiguration.

private DeviceResponse buildDeviceResponseGetConfiguration(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse) {
    ConfigurationDto configuration = null;
    final DeviceMessageStatus status;
    if (oslpResponse.getPayloadMessage().hasGetConfigurationResponse()) {
        final Oslp.GetConfigurationResponse getConfigurationResponse = oslpResponse.getPayloadMessage().getGetConfigurationResponse();
        configuration = this.mapper.map(getConfigurationResponse, ConfigurationDto.class);
        status = this.mapper.map(getConfigurationResponse.getStatus(), DeviceMessageStatus.class);
    } else {
        status = DeviceMessageStatus.FAILURE;
    }
    return new GetConfigurationDeviceResponse(deviceRequest, status, configuration);
}
Also used : DeviceMessageStatus(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceMessageStatus) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) Oslp(org.opensmartgridplatform.oslp.Oslp)

Example 5 with ConfigurationDto

use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.

the class CommonSetConfigurationRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing common set configuration message");
    MessageMetadata messageMetadata;
    ConfigurationDto configuration;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        configuration = (ConfigurationDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    try {
        this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
        final SetConfigurationDeviceRequest deviceRequest = new SetConfigurationDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), configuration);
        this.deviceService.setConfiguration(deviceRequest);
    } catch (final RuntimeException e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) JMSException(javax.jms.JMSException) SetConfigurationDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetConfigurationDeviceRequest)

Aggregations

ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)15 JMSException (javax.jms.JMSException)7 DaliConfigurationDto (org.opensmartgridplatform.dto.valueobjects.DaliConfigurationDto)4 RelayConfigurationDto (org.opensmartgridplatform.dto.valueobjects.RelayConfigurationDto)4 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)3 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)3 DateTime (org.joda.time.DateTime)2 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse)2 ConnectionFailureException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ConnectionFailureException)2 NodeException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.NodeException)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)2 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)2 DeviceFixedIpDto (org.opensmartgridplatform.dto.valueobjects.DeviceFixedIpDto)2 LightTypeDto (org.opensmartgridplatform.dto.valueobjects.LightTypeDto)2 LinkTypeDto (org.opensmartgridplatform.dto.valueobjects.LinkTypeDto)2 Oslp (org.opensmartgridplatform.oslp.Oslp)2 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)2