Search in sources :

Example 21 with ConfigDescription

use of org.eclipse.smarthome.config.core.ConfigDescription in project smarthome by eclipse.

the class ThingResource method normalizeConfiguration.

private Map<String, Object> normalizeConfiguration(Map<String, Object> properties, ThingTypeUID thingTypeUID, ThingUID thingUID) {
    if (properties == null || properties.isEmpty()) {
        return properties;
    }
    ThingType thingType = thingTypeRegistry.getThingType(thingTypeUID);
    if (thingType == null) {
        return properties;
    }
    List<ConfigDescription> configDescriptions = new ArrayList<>(2);
    if (thingType.getConfigDescriptionURI() != null) {
        ConfigDescription typeConfigDesc = configDescRegistry.getConfigDescription(thingType.getConfigDescriptionURI());
        if (typeConfigDesc != null) {
            configDescriptions.add(typeConfigDesc);
        }
    }
    if (getConfigDescriptionURI(thingUID) != null) {
        ConfigDescription thingConfigDesc = configDescRegistry.getConfigDescription(getConfigDescriptionURI(thingUID));
        if (thingConfigDesc != null) {
            configDescriptions.add(thingConfigDesc);
        }
    }
    if (configDescriptions.isEmpty()) {
        return properties;
    }
    return ConfigUtil.normalizeTypes(properties, configDescriptions);
}
Also used : ArrayList(java.util.ArrayList) ConfigDescription(org.eclipse.smarthome.config.core.ConfigDescription) ThingType(org.eclipse.smarthome.core.thing.type.ThingType)

Example 22 with ConfigDescription

use of org.eclipse.smarthome.config.core.ConfigDescription in project smarthome by eclipse.

the class ThingResource method normalizeConfiguration.

private Map<String, Object> normalizeConfiguration(Map<String, Object> properties, ChannelTypeUID channelTypeUID, ChannelUID channelUID) {
    if (properties == null || properties.isEmpty()) {
        return properties;
    }
    ChannelType channelType = channelTypeRegistry.getChannelType(channelTypeUID);
    if (channelType == null) {
        return properties;
    }
    List<ConfigDescription> configDescriptions = new ArrayList<>(2);
    if (channelType.getConfigDescriptionURI() != null) {
        ConfigDescription typeConfigDesc = configDescRegistry.getConfigDescription(channelType.getConfigDescriptionURI());
        if (typeConfigDesc != null) {
            configDescriptions.add(typeConfigDesc);
        }
    }
    if (getConfigDescriptionURI(channelUID) != null) {
        ConfigDescription channelConfigDesc = configDescRegistry.getConfigDescription(getConfigDescriptionURI(channelUID));
        if (channelConfigDesc != null) {
            configDescriptions.add(channelConfigDesc);
        }
    }
    if (configDescriptions.isEmpty()) {
        return properties;
    }
    return ConfigUtil.normalizeTypes(properties, configDescriptions);
}
Also used : ArrayList(java.util.ArrayList) ConfigDescription(org.eclipse.smarthome.config.core.ConfigDescription) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType)

Aggregations

ConfigDescription (org.eclipse.smarthome.config.core.ConfigDescription)22 URI (java.net.URI)10 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)9 ArrayList (java.util.ArrayList)5 List (java.util.List)3 ConfigDescriptionParameterGroup (org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup)3 BindingInfo (org.eclipse.smarthome.core.binding.BindingInfo)3 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)3 Test (org.junit.Test)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 URISyntaxException (java.net.URISyntaxException)2 Locale (java.util.Locale)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 ConfigDescriptionDTO (org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTO)2 ConfigDescriptionParameterDTO (org.eclipse.smarthome.config.core.dto.ConfigDescriptionParameterDTO)2 ConfigDescriptionParameterGroupDTO (org.eclipse.smarthome.config.core.dto.ConfigDescriptionParameterGroupDTO)2 NodeIterator (org.eclipse.smarthome.config.xml.util.NodeIterator)2 ThingType (org.eclipse.smarthome.core.thing.type.ThingType)2