Search in sources :

Example 1 with ChannelGroupDefinitionDTO

use of org.eclipse.smarthome.core.thing.dto.ChannelGroupDefinitionDTO in project smarthome by eclipse.

the class ThingTypeResource method convertToChannelGroupDefinitionDTOs.

private List<ChannelGroupDefinitionDTO> convertToChannelGroupDefinitionDTOs(List<ChannelGroupDefinition> channelGroupDefinitions, Locale locale) {
    List<ChannelGroupDefinitionDTO> channelGroupDefinitionDTOs = new ArrayList<>();
    for (ChannelGroupDefinition channelGroupDefinition : channelGroupDefinitions) {
        String id = channelGroupDefinition.getId();
        ChannelGroupType channelGroupType = channelTypeRegistry.getChannelGroupType(channelGroupDefinition.getTypeUID(), locale);
        // Default to the channelGroupDefinition label to override the
        // channelGroupType
        String label = channelGroupDefinition.getLabel();
        if (label == null) {
            label = channelGroupType.getLabel();
        }
        // Default to the channelGroupDefinition description to override the
        // channelGroupType
        String description = channelGroupDefinition.getDescription();
        if (description == null) {
            description = channelGroupType.getDescription();
        }
        List<ChannelDefinition> channelDefinitions = channelGroupType.getChannelDefinitions();
        List<ChannelDefinitionDTO> channelDefinitionDTOs = convertToChannelDefinitionDTOs(channelDefinitions, locale);
        channelGroupDefinitionDTOs.add(new ChannelGroupDefinitionDTO(id, label, description, channelDefinitionDTOs));
    }
    return channelGroupDefinitionDTOs;
}
Also used : ChannelDefinitionDTO(org.eclipse.smarthome.core.thing.dto.ChannelDefinitionDTO) ChannelDefinition(org.eclipse.smarthome.core.thing.type.ChannelDefinition) ArrayList(java.util.ArrayList) ChannelGroupDefinitionDTO(org.eclipse.smarthome.core.thing.dto.ChannelGroupDefinitionDTO) ChannelGroupType(org.eclipse.smarthome.core.thing.type.ChannelGroupType) ChannelGroupDefinition(org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 ChannelDefinitionDTO (org.eclipse.smarthome.core.thing.dto.ChannelDefinitionDTO)1 ChannelGroupDefinitionDTO (org.eclipse.smarthome.core.thing.dto.ChannelGroupDefinitionDTO)1 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)1 ChannelGroupDefinition (org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition)1 ChannelGroupType (org.eclipse.smarthome.core.thing.type.ChannelGroupType)1