use of org.eclipse.smarthome.core.thing.dto.ChannelTypeDTO in project smarthome by eclipse.
the class ChannelTypeResource method convertToChannelTypeDTO.
private ChannelTypeDTO convertToChannelTypeDTO(ChannelType channelType, Locale locale) {
final ConfigDescription configDescription;
if (channelType.getConfigDescriptionURI() != null) {
configDescription = this.configDescriptionRegistry.getConfigDescription(channelType.getConfigDescriptionURI(), locale);
} else {
configDescription = null;
}
List<ConfigDescriptionParameterDTO> parameters;
List<ConfigDescriptionParameterGroupDTO> parameterGroups;
if (configDescription != null) {
ConfigDescriptionDTO configDescriptionDTO = ConfigDescriptionDTOMapper.map(configDescription);
parameters = configDescriptionDTO.parameters;
parameterGroups = configDescriptionDTO.parameterGroups;
} else {
parameters = new ArrayList<>(0);
parameterGroups = new ArrayList<>(0);
}
return new ChannelTypeDTO(channelType.getUID().toString(), channelType.getLabel(), channelType.getDescription(), channelType.getCategory(), channelType.getItemType(), channelType.getKind(), parameters, parameterGroups, channelType.getState(), channelType.getTags(), channelType.isAdvanced());
}
use of org.eclipse.smarthome.core.thing.dto.ChannelTypeDTO in project smarthome by eclipse.
the class ChannelTypeResource method getAll.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets all available channel types.", response = ChannelTypeDTO.class, responseContainer = "Set")
@ApiResponses(value = @ApiResponse(code = 200, message = "OK", response = ChannelTypeDTO.class, responseContainer = "Set"))
public Response getAll(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = HttpHeaders.ACCEPT_LANGUAGE) String language) {
Locale locale = LocaleUtil.getLocale(language);
Stream<ChannelTypeDTO> channelStream = channelTypeRegistry.getChannelTypes(locale).stream().map(c -> convertToChannelTypeDTO(c, locale));
return Response.ok(new Stream2JSONInputStream(channelStream)).build();
}
Aggregations