use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.
the class ChannelTypeResource method getByUID.
@GET
@Path("/{channelTypeUID}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets channel type by UID.", response = ChannelTypeDTO.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Channel type with provided channelTypeUID does not exist.", response = ChannelTypeDTO.class), @ApiResponse(code = 404, message = "No content") })
public Response getByUID(@PathParam("channelTypeUID") @ApiParam(value = "channelTypeUID") String channelTypeUID, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = HttpHeaders.ACCEPT_LANGUAGE) String language) {
Locale locale = LocaleUtil.getLocale(language);
ChannelType channelType = channelTypeRegistry.getChannelType(new ChannelTypeUID(channelTypeUID), locale);
if (channelType != null) {
return Response.ok(convertToChannelTypeDTO(channelType, locale)).build();
} else {
return Response.noContent().build();
}
}
use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.
the class XmlChannelTypeProvider method localize.
@Override
protected ChannelType localize(Bundle bundle, ChannelType channelType, Locale locale) {
if (thingTypeI18nUtil == null) {
return null;
}
ChannelTypeUID channelTypeUID = channelType.getUID();
String label = thingTypeI18nUtil.getChannelLabel(bundle, channelTypeUID, channelType.getLabel(), locale);
String description = thingTypeI18nUtil.getChannelDescription(bundle, channelTypeUID, channelType.getDescription(), locale);
StateDescription state = createLocalizedChannelState(bundle, channelType, channelTypeUID, locale);
return new ChannelType(channelTypeUID, channelType.isAdvanced(), channelType.getItemType(), channelType.getKind(), label, description, channelType.getCategory(), channelType.getTags(), state, channelType.getEvent(), channelType.getConfigDescriptionURI());
}
use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.
the class DefaultSystemChannelTypeProvider method createLocalizedChannelType.
private ChannelType createLocalizedChannelType(Bundle bundle, ChannelType channelType, Locale locale) {
LocalizedChannelTypeKey localizedChannelTypeKey = getLocalizedChannelTypeKey(channelType.getUID(), locale);
ChannelType cachedEntry = localizedChannelTypeCache.get(localizedChannelTypeKey);
if (cachedEntry != null) {
return cachedEntry;
}
if (thingTypeI18nUtil != null) {
ChannelTypeUID channelTypeUID = channelType.getUID();
String label = thingTypeI18nUtil.getChannelLabel(bundle, channelTypeUID, channelType.getLabel(), locale);
String description = thingTypeI18nUtil.getChannelDescription(bundle, channelTypeUID, channelType.getDescription(), locale);
StateDescription state = createLocalizedChannelState(bundle, channelType, channelTypeUID, locale);
ChannelType localizedChannelType = new ChannelType(channelTypeUID, channelType.isAdvanced(), channelType.getItemType(), channelType.getKind(), label, description, channelType.getCategory(), channelType.getTags(), state, channelType.getEvent(), channelType.getConfigDescriptionURI());
localizedChannelTypeCache.put(localizedChannelTypeKey, localizedChannelType);
return localizedChannelType;
}
return channelType;
}
use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.
the class ChannelDTOMapper method map.
/**
* Maps channel DTO into channel object.
*
* @param channelDTO the channel DTO
* @return the channel object
*/
public static Channel map(ChannelDTO channelDTO) {
ChannelUID channelUID = new ChannelUID(channelDTO.uid);
ChannelTypeUID channelTypeUID = new ChannelTypeUID(channelDTO.channelTypeUID);
return ChannelBuilder.create(channelUID, channelDTO.itemType).withConfiguration(new Configuration(channelDTO.configuration)).withLabel(channelDTO.label).withDescription(channelDTO.description).withProperties(channelDTO.properties).withType(channelTypeUID).withDefaultTags(channelDTO.defaultTags).withKind(ChannelKind.parse(channelDTO.kind)).build();
}
use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.
the class ChannelDTOMapper method map.
/**
* Maps channel into channel DTO object.
*
* @param channel the channel
* @return the channel DTO object
*/
public static ChannelDTO map(Channel channel) {
ChannelTypeUID channelTypeUID = channel.getChannelTypeUID();
String channelTypeUIDValue = channelTypeUID != null ? channelTypeUID.toString() : null;
return new ChannelDTO(channel.getUID(), channelTypeUIDValue, channel.getAcceptedItemType(), channel.getKind(), channel.getLabel(), channel.getDescription(), channel.getProperties(), channel.getConfiguration(), channel.getDefaultTags());
}
Aggregations