Search in sources :

Example 1 with ConfigurationObject

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;
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject)

Example 2 with ConfigurationObject

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;
}
Also used : GprsOperationModeType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GprsOperationModeType) ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject)

Example 3 with 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;
}
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 4 with 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());
}
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 5 with ConfigurationObject

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;
}
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

ConfigurationObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject)9 ConfigurationFlags (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)3 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Then (io.cucumber.java.en.Then)2 Test (org.junit.jupiter.api.Test)2 ConfigurationFlag (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag)2 SetConfigurationObjectRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequest)2 SetConfigurationObjectRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequestData)2 Given (io.cucumber.java.en.Given)1 ArrayList (java.util.ArrayList)1 GetConfigurationObjectResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetConfigurationObjectResponse)1 SetConfigurationObjectRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.SetConfigurationObjectRequest)1 Response (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response)1 GprsOperationModeType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GprsOperationModeType)1