Search in sources :

Example 1 with ChannelTypeUID

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();
    }
}
Also used : Locale(java.util.Locale) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ChannelTypeUID

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());
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) StateDescription(org.eclipse.smarthome.core.types.StateDescription)

Example 3 with ChannelTypeUID

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;
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) StateDescription(org.eclipse.smarthome.core.types.StateDescription)

Example 4 with ChannelTypeUID

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();
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) Configuration(org.eclipse.smarthome.config.core.Configuration) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID)

Example 5 with ChannelTypeUID

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());
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID)

Aggregations

ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)16 ChannelType (org.eclipse.smarthome.core.thing.type.ChannelType)9 StateDescription (org.eclipse.smarthome.core.types.StateDescription)4 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MeteringTypeEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum)2 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)2 Channel (org.eclipse.smarthome.core.thing.Channel)2 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)2 TriggerProfileType (org.eclipse.smarthome.core.thing.profiles.TriggerProfileType)2 ChannelTypeProvider (org.eclipse.smarthome.core.thing.type.ChannelTypeProvider)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1