@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 = localeService.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(); } }
private void normalizeChannels(ThingDTO thingBean, ThingUID thingUID) { if (thingBean.channels != null) { for (ChannelDTO channelBean : thingBean.channels) { if (channelBean.channelTypeUID != null) { channelBean.configuration = normalizeConfiguration(channelBean.configuration, new ChannelTypeUID(channelBean.channelTypeUID), new ChannelUID(thingUID, channelBean.id)); } } } }
public Response getLinkableItemTypes( @PathParam("channelTypeUID") @ApiParam(value = "channelTypeUID") String channelTypeUID) { ChannelTypeUID ctUID = new ChannelTypeUID(channelTypeUID); ChannelType channelType = channelTypeRegistry.getChannelType(ctUID); if (channelType == null) {
protected List<ChannelDefinition> toChannelDefinitions(List<ChannelXmlResult> channelTypeReferences) throws ConversionException { List<ChannelDefinition> channelTypeDefinitions = null; if ((channelTypeReferences != null) && (channelTypeReferences.size() > 0)) { channelTypeDefinitions = new ArrayList<>(channelTypeReferences.size()); for (ChannelXmlResult channelTypeReference : channelTypeReferences) { String id = channelTypeReference.getId(); String typeId = channelTypeReference.getTypeId(); String typeUID = String.format("%s:%s", this.thingTypeUID.getBindingId(), typeId); int systemPrefixIdx = typeId.indexOf(XmlHelper.SYSTEM_NAMESPACE_PREFIX); if (systemPrefixIdx != -1) { typeUID = XmlHelper.getSystemUID(typeId); } // Convert the channel properties into a map Map<String, String> propertiesMap = new HashMap<>(); for (NodeValue property : channelTypeReference.getProperties()) { propertiesMap.put(property.getAttributes().get("name"), (String) property.getValue()); } ChannelDefinition channelDefinition = new ChannelDefinition(id, new ChannelTypeUID(typeUID), propertiesMap, channelTypeReference.getLabel(), channelTypeReference.getDescription()); channelTypeDefinitions.add(channelDefinition); } } return channelTypeDefinitions; }
new ChannelTypeUID(channelTypeUID.getAsString()), advanced, itemType, field.getName(), field.getInformativeText(), null, null, new StateDescription(getMinimum(field), getMaximum(field),
private Predicate<ProfileType> matchesChannelUID(String channelTypeUID, Locale locale) { if (channelTypeUID == null) { return t -> true; } ChannelType channelType = channelTypeRegistry.getChannelType(new ChannelTypeUID(channelTypeUID), locale); if (channelType == null) { // requested to filter against an unknown channel type -> do not return a ProfileType return t -> false; } switch (channelType.getKind()) { case STATE: return t -> stateProfileMatchesProfileType(t, channelType); case TRIGGER: return t -> triggerProfileMatchesProfileType(t, channelType); } return t -> false; }
protected ChannelDefinition toChannelDefinition(String bindingId) throws ConversionException { String id = getId(); String typeId = getTypeId(); String typeUID = getTypeUID(bindingId, typeId); // Convert the channel properties into a map Map<String, String> propertiesMap = new HashMap<>(); for (NodeValue property : getProperties()) { propertiesMap.put(property.getAttributes().get("name"), (String) property.getValue()); } return new ChannelDefinitionBuilder(id, new ChannelTypeUID(typeUID)).withProperties(propertiesMap) .withLabel(getLabel()).withDescription(getDescription()).withAutoUpdatePolicy(getAutoUpdatePolicy()) .build(); }
protected Channel buildBinaryChannel(URL characteristicURL, boolean advanced, boolean readOnly) { ChannelUID channelUID = new ChannelUID(handler.getThing().getUID(), BluetoothUtils.getChannelUID(characteristicURL)); String channelType = getChannelType(advanced, readOnly); ChannelTypeUID channelTypeUID = new ChannelTypeUID(BluetoothBindingConstants.BINDING_ID, channelType); return ChannelBuilder.create(channelUID, "String") .withType(channelTypeUID) .withLabel(characteristicURL.getCharacteristicUUID()) .build(); }
private Channel buildFieldChannel(URL characteristicURL, Field field, String label, boolean advanced, boolean readOnly) { String acceptedType = getAcceptedItemType(field); if (acceptedType == null) { // unknown field format return null; } URL channelURL = characteristicURL.copyWithField(field.getName()); logger.debug("Building a new channel for a field: {}", channelURL); ChannelUID channelUID = new ChannelUID(handler.getThing().getUID(), BluetoothUtils.getChannelUID(channelURL)); String channelType = String.format(CHANNEL_TYPE_NAME_PATTERN, advanced ? "advncd" : "simple", readOnly ? "readable" : "writable", characteristicURL.getCharacteristicUUID(), BluetoothUtils.encodeFieldID(field)); ChannelTypeUID channelTypeUID = new ChannelTypeUID(BluetoothBindingConstants.BINDING_ID, channelType); return ChannelBuilder.create(channelUID, getAcceptedItemType(field)) .withType(channelTypeUID) .withProperties(getFieldProperties(characteristicURL, field)) .withLabel(label) .build(); }
/** * 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(); } }
@Override protected ChannelTypeXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException { boolean advanced = readBoolean(attributes, "advanced", false); boolean system = readBoolean(attributes, "system", false); String uid = system ? XmlHelper.getSystemUID(super.getID(attributes)) : super.getUID(attributes, context); ChannelTypeUID channelTypeUID = new ChannelTypeUID(uid); String itemType = readItemType(nodeIterator); String label = super.readLabel(nodeIterator); String description = super.readDescription(nodeIterator); String category = readCategory(nodeIterator); Set<String> tags = readTags(nodeIterator); StateDescription stateDescription = readStateDescription(nodeIterator); Object[] configDescriptionObjects = super.getConfigDescriptionObjects(nodeIterator); ChannelType channelType = new ChannelType(channelTypeUID, advanced, itemType, label, description, category, tags, stateDescription, (URI) configDescriptionObjects[0]); ChannelTypeXmlResult channelTypeXmlResult = new ChannelTypeXmlResult(channelType, (ConfigDescription) configDescriptionObjects[1], system); return channelTypeXmlResult; }
String _bindingId = thingUID.getBindingId(); String _channelType_1 = it.getChannelType(); ChannelTypeUID _channelTypeUID = new ChannelTypeUID(_bindingId, _channelType_1); channelTypeUID = _channelTypeUID; final ChannelType resolvedChannelType = this.getChannelType(channelTypeUID);
ChannelTypeUID channelTypeUID = new ChannelTypeUID(uid);