use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectRequestBuilder method fromParameterMap.
public SetConfigurationObjectRequestBuilder fromParameterMap(final Map<String, String> parameters) {
final ConfigurationObject configurationObject = ConfigurationObjectFactory.fromParameterMap(parameters);
this.gprsOperationModeType = configurationObject.getGprsOperationMode();
if (configurationObject.getConfigurationFlags() != null) {
this.configurationFlags = configurationObject.getConfigurationFlags().getConfigurationFlag();
}
return this;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject in project open-smart-grid-platform by OSGP.
the class ConfigurationObjectFactory method fromParameterMap.
public static ConfigurationObject fromParameterMap(final Map<String, String> requestParameters) {
final ConfigurationObject configurationObject = new ConfigurationObject();
setConfigurationFlags(configurationObject, requestParameters);
configurationObject.setGprsOperationMode(ReadSettingsHelper.getEnum(requestParameters, PlatformSmartmeteringKeys.GPRS_OPERATION_MODE_TYPE, GprsOperationModeType.class));
return configurationObject;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject 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;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject 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());
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject 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;
}
Aggregations