use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.
the class SimulatedConfigurationObjectSteps method createFlagsForConfigurationObject.
private JsonNode createFlagsForConfigurationObject(final ConfigurationFlags configurationFlags, final JsonNodeFactory jsonNodeFactory) {
final int bitStringLength = 16;
final char[] flags = new char[bitStringLength];
for (int i = 0; i < bitStringLength; i++) {
flags[i] = '0';
}
if (configurationFlags != null && configurationFlags.getConfigurationFlag() != null) {
final List<ConfigurationFlag> configurationFlagList = configurationFlags.getConfigurationFlag();
for (final ConfigurationFlag configurationFlag : configurationFlagList) {
if (configurationFlag.isEnabled()) {
flags[configurationFlag.getConfigurationFlagType().ordinal()] = '1';
}
}
}
return this.jsonObjectCreator.createAttributeValue("bit-string", new String(flags), jsonNodeFactory);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag 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);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag 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.ConfigurationFlag in project open-smart-grid-platform by OSGP.
the class ConfigurationObjectFactory method getConfigurationFlag.
private static ConfigurationFlag getConfigurationFlag(final Map<String, String> parameters, final int index) {
final ConfigurationFlag configurationFlag = new ConfigurationFlag();
configurationFlag.setConfigurationFlagType(getConfigurationFlagType(parameters, index));
configurationFlag.setEnabled(getConfigurationFlagEnabled(parameters, index));
return configurationFlag;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag 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());
}
Aggregations