Search in sources :

Example 1 with SetConfigurationObjectRequestDto

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

the class ConfigurationService method setConfigurationObject.

public void setConfigurationObject(final MessageMetadata messageMetadata, final SetConfigurationObjectRequest setConfigurationObjectRequest) throws FunctionalException {
    log.info("setConfigurationObject for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final SetConfigurationObjectRequestDto requestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto)

Example 2 with SetConfigurationObjectRequestDto

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

the class SetConfigurationObjectRequestMappingTest method testMappingWithNullConfigurationObject.

// Test if mapping with a null ConfigurationObject succeeds
@Test
public void testMappingWithNullConfigurationObject() {
    // build test data
    final String deviceIdentification = "nr1";
    final ConfigurationObjectDto configurationObject = null;
    final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestData = new SetConfigurationObjectRequestDataDto(configurationObject);
    // actual mapping
    final SetConfigurationObjectRequestDto setConfigurationObjectRequest = new SetConfigurationObjectRequestDto(deviceIdentification, setConfigurationObjectRequestData);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    // check values
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    assertThat(setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData().getConfigurationObject()).isNull();
}
Also used : ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) SetConfigurationObjectRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) Test(org.junit.jupiter.api.Test)

Example 3 with SetConfigurationObjectRequestDto

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

the class SetConfigurationObjectRequestMappingTest method testSetConfigurationObjectRequestMappingComplete.

// Tests if mapping with a complete SetConfigurationObjectRequestData object
// succeeds
@Test
public void testSetConfigurationObjectRequestMappingComplete() {
    // build test data
    final String deviceIdentification = "nr1";
    final GprsOperationModeType gprsOperationModeType = GprsOperationModeType.ALWAYS_ON;
    final ConfigurationFlagType configurationFlagType = ConfigurationFlagType.DISCOVER_ON_OPEN_COVER;
    final ConfigurationFlag configurationFlag = new ConfigurationFlag(configurationFlagType, true);
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    configurationFlagList.add(configurationFlag);
    final ConfigurationFlags configurationFlags = new ConfigurationFlags(configurationFlagList);
    final ConfigurationObject configurationObject = new ConfigurationObject(gprsOperationModeType, configurationFlags);
    final SetConfigurationObjectRequestData setConfigurationObjectRequestData = new SetConfigurationObjectRequestData(configurationObject);
    // actual mapping
    final SetConfigurationObjectRequest setConfigurationObjectRequest = new SetConfigurationObjectRequest(deviceIdentification, setConfigurationObjectRequestData);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    // check values
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    this.checkSetConfigurationObjectRequestData(gprsOperationModeType, configurationFlagType, configurationFlags, setConfigurationObjectRequestDto);
}
Also used : GprsOperationModeType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType) ConfigurationObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest) ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlag) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) ConfigurationFlagType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlagType) ConfigurationFlags(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlags) SetConfigurationObjectRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequestData) Test(org.junit.jupiter.api.Test)

Example 4 with SetConfigurationObjectRequestDto

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

the class SetConfigurationObjectRequestMappingTest method testSetConfigurationObjectRequestMappingNullObject.

// Tests if mapping a SetConfigurationObjectRequest with a null
// SetConfigurationObjectRequestData object succeeds.
@Test
public void testSetConfigurationObjectRequestMappingNullObject() {
    // build test data
    final String deviceIdentification = "nr1";
    final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestData = null;
    // actual mapping
    final SetConfigurationObjectRequestDto setConfigurationObjectRequest = new SetConfigurationObjectRequestDto(deviceIdentification, setConfigurationObjectRequestData);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    // check values
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    assertThat(setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData()).isNull();
}
Also used : SetConfigurationObjectRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) Test(org.junit.jupiter.api.Test)

Example 5 with SetConfigurationObjectRequestDto

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

the class SetConfigurationObjectRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(SetConfigurationObjectRequestDto.class, requestObject);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequest = (SetConfigurationObjectRequestDto) requestObject;
    this.configurationService.requestSetConfiguration(conn, device, setConfigurationObjectRequest, messageMetadata);
    return null;
}
Also used : SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto)

Aggregations

SetConfigurationObjectRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto)6 Test (org.junit.jupiter.api.Test)4 ConfigurationFlags (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlags)2 ConfigurationObject (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject)2 GprsOperationModeType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType)2 SetConfigurationObjectRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest)2 SetConfigurationObjectRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequestData)2 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)2 SetConfigurationObjectRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)2 ArrayList (java.util.ArrayList)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ConfigurationFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlag)1 ConfigurationFlagType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlagType)1