Search in sources :

Example 1 with ConfigurationFlags

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags in project open-smart-grid-platform by OSGP.

the class ConfigurationObjectFactory method setConfigurationFlags.

private static void setConfigurationFlags(final ConfigurationObject configurationObject, final Map<String, String> requestParameters) {
    if (!hasConfigurationFlags(requestParameters)) {
        return;
    }
    final ConfigurationFlags configurationFlags = new ConfigurationFlags();
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    final int numberOfFlags = Integer.parseInt(requestParameters.get(PlatformSmartmeteringKeys.CONFIGURATION_FLAG_COUNT));
    for (int i = 1; i <= numberOfFlags; i++) {
        configurationFlagList.add(getConfigurationFlag(requestParameters, i));
    }
    configurationFlags.getConfigurationFlag().addAll(configurationFlagList);
    configurationObject.setConfigurationFlags(configurationFlags);
}
Also used : ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)

Example 2 with ConfigurationFlags

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags in project open-smart-grid-platform by OSGP.

the class ConfigurationObjectFactory method forGprsOperationModeAndFlags.

public static ConfigurationObject forGprsOperationModeAndFlags(final GprsOperationModeType gprsOperationMode, final Set<ConfigurationFlagType> enableFlags, final Set<ConfigurationFlagType> disableFlags) {
    final ConfigurationObject configurationObject = new ConfigurationObject();
    configurationObject.setGprsOperationMode(gprsOperationMode);
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    configurationFlagList.addAll(getFlags(enableFlags, true));
    configurationFlagList.addAll(getFlags(disableFlags, false));
    if (!configurationFlagList.isEmpty()) {
        final ConfigurationFlags configurationFlags = new ConfigurationFlags();
        configurationFlags.getConfigurationFlag().addAll(configurationFlagList);
        configurationObject.setConfigurationFlags(configurationFlags);
    }
    return configurationObject;
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject) ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)

Example 3 with ConfigurationFlags

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectRequestMappingTest method testWithCompleteObject.

/**
 * Tests if mapping succeeds with a complete SetConfigurationRequestData object.
 */
@Test
public void testWithCompleteObject() {
    // build test data
    final ConfigurationObject configurationObject = new ConfigurationObject();
    final ConfigurationFlag configurationFlag = new ConfigurationFlag();
    configurationFlag.setConfigurationFlagType(FLAGTYPE);
    configurationFlag.setEnabled(ISENABLED);
    final ConfigurationFlags configurationFlags = new ConfigurationFlags();
    configurationFlags.getConfigurationFlag().add(configurationFlag);
    configurationObject.setConfigurationFlags(configurationFlags);
    configurationObject.setGprsOperationMode(GPRSTYPE);
    final SetConfigurationObjectRequestData setConfigurationObjectRequestData = new SetConfigurationObjectRequestData();
    setConfigurationObjectRequestData.setConfigurationObject(configurationObject);
    final SetConfigurationObjectRequest requestOriginal = new SetConfigurationObjectRequest();
    requestOriginal.setDeviceIdentification(DEVICE_ID);
    requestOriginal.setSetConfigurationObjectRequestData(setConfigurationObjectRequestData);
    // actual mapping
    final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest requestMapped = this.configurationMapper.map(requestOriginal, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest.class);
    // check mapping
    assertThat(requestMapped).isNotNull();
    assertThat(requestMapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(requestMapped.getSetConfigurationObjectRequestData()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getGprsOperationMode()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0)).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0).getConfigurationFlagType()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getGprsOperationMode().name()).isEqualTo(GPRSTYPE.name());
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0).getConfigurationFlagType().name()).isEqualTo(FLAGTYPE.name());
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequest) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags) SetConfigurationObjectRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequestData) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationFlags

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectRequestBuilder method build.

public SetConfigurationObjectRequest build() {
    final ConfigurationObject configurationObject = new ConfigurationObject();
    configurationObject.setGprsOperationMode(this.gprsOperationModeType);
    if (!CollectionUtils.isEmpty(this.configurationFlags)) {
        final ConfigurationFlags configurationFlagsElement = new ConfigurationFlags();
        configurationFlagsElement.getConfigurationFlag().addAll(this.configurationFlags);
        configurationObject.setConfigurationFlags(configurationFlagsElement);
    }
    final SetConfigurationObjectRequest request = new SetConfigurationObjectRequest();
    request.setConfigurationObject(configurationObject);
    return request;
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.SetConfigurationObjectRequest) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)

Aggregations

ConfigurationFlags (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)4 ConfigurationFlag (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag)3 ConfigurationObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject)3 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)1 SetConfigurationObjectRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.SetConfigurationObjectRequest)1 SetConfigurationObjectRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequest)1 SetConfigurationObjectRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequestData)1