@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(); } }
String channelID = channelTypeUID.getId(); boolean advanced = "advncd".equals(channelID.substring(15, 21)); boolean readOnly = "readable".equals(channelID.substring(22, 30)); new ChannelTypeUID(channelTypeUID.getAsString()), advanced, itemType, field.getName(), field.getInformativeText(), null, null, new StateDescription(getMinimum(field), getMaximum(field),
@Override public ChannelType getChannelType(ChannelTypeUID channelTypeUID, Locale locale) { Collection<Entry<Bundle, List<ChannelType>>> channelTypesList = this.bundleChannelTypesMap.entrySet(); if (channelTypesList != null) { for (Entry<Bundle, List<ChannelType>> channelTypes : channelTypesList) { for (ChannelType channelType : channelTypes.getValue()) { if (channelType.getUID().equals(channelTypeUID)) { return createLocalizedChannelType(channelTypes.getKey(), channelType, locale); } } } } else { } return null; }
private String inferChannelKey(ChannelTypeUID channelTypeUID, String lastSegment) { return "channel-type." + channelTypeUID.getBindingId() + "." + channelTypeUID.getId() + "." + lastSegment; }
String _bindingId = thingUID.getBindingId(); String _channelType_1 = it.getChannelType(); ChannelTypeUID _channelTypeUID = new ChannelTypeUID(_bindingId, _channelType_1); channelTypeUID = _channelTypeUID; final ChannelType resolvedChannelType = this.getChannelType(channelTypeUID); this.applyDefaultConfiguration(configuration, resolvedChannelType); } else { GenericThingProvider.logger.error("Channel type {} could not be resolved.", channelTypeUID.getAsString());
@Override public synchronized void addingFinished() { Map<String, ChannelType> channelTypes = new HashMap<>(10); // create channel types for (ChannelTypeXmlResult type : this.channelTypeRefs) { ChannelType channelType = type.toChannelType(); channelTypes.put(channelType.getUID().getAsString(), channelType); this.channelTypeProvider.addChannelType(this.bundle, channelType); } // create channel group types for (ChannelGroupTypeXmlResult type : this.channelGroupTypeRefs) { this.channelTypeProvider.addChannelGroupType(this.bundle, type.toChannelGroupType(channelTypes)); } // create thing and bridge types for (ThingTypeXmlResult type : this.thingTypeRefs) { this.thingTypeProvider.addThingType(this.bundle, type.toThingType()); } // release temporary cache this.thingTypeRefs.clear(); this.channelGroupTypeRefs.clear(); this.channelTypeRefs.clear(); }
public List<ZWaveCommandClassTransactionPayload> receiveCommand(ZWaveThingChannel channel, ZWaveNode node, Command command) { if (!channel.getChannelTypeUID().getId().equals("sensor_report")) { return null;
private List<ChannelDefinitionDTO> convertToChannelDefinitionDTOs(List<ChannelDefinition> channelDefinitions, Locale locale) { List<ChannelDefinitionDTO> channelDefinitionDTOs = new ArrayList<>(); for (ChannelDefinition channelDefinition : channelDefinitions) { ChannelType channelType = channelTypeRegistry.getChannelType(channelDefinition.getChannelTypeUID(), locale); if (channelType == null) { logger.warn("Cannot find channel type: {}", channelDefinition.getChannelTypeUID()); return null; } // Default to the channelDefinition label to override the // channelType String label = channelDefinition.getLabel(); if (label == null) { label = channelType.getLabel(); } // Default to the channelDefinition description to override the // channelType String description = channelDefinition.getDescription(); if (description == null) { description = channelType.getDescription(); } ChannelDefinitionDTO channelDefinitionDTO = new ChannelDefinitionDTO(channelDefinition.getId(), channelDefinition.getChannelTypeUID().toString(), label, description, channelType.getTags(), channelType.getCategory(), channelType.getState(), channelType.isAdvanced(), channelDefinition.getProperties()); channelDefinitionDTOs.add(channelDefinitionDTO); } return channelDefinitionDTOs; }
@Override public ChannelType getChannelType(ChannelTypeUID channelTypeUID, Locale locale) { if (channelTypeUID.getBindingId().equals(BluetoothBindingConstants.BINDING_ID)) { if (channelTypeUID.getId().startsWith(BluetoothBindingConstants.CHANNEL_CHARACTERISTIC)) { return cache.computeIfAbsent(channelTypeUID, uid -> { return buildChannelType(channelTypeUID); }); } } return null; }
@Override public synchronized void addingFinished() { Map<String, ChannelType> channelTypes = new HashMap<>(10); // create channel types for (ChannelTypeXmlResult type : this.channelTypeRefs) { ChannelType channelType = type.toChannelType(); channelTypes.put(channelType.getUID().getAsString(), channelType); this.channelTypeProvider.add(this.bundle, channelType); } // create channel group types for (ChannelGroupTypeXmlResult type : this.channelGroupTypeRefs) { this.channelGroupTypeProvider.add(this.bundle, type.toChannelGroupType()); } // create thing and bridge types for (ThingTypeXmlResult type : this.thingTypeRefs) { this.thingTypeProvider.add(this.bundle, type.toThingType()); } // release temporary cache this.thingTypeRefs.clear(); this.channelGroupTypeRefs.clear(); this.channelTypeRefs.clear(); }
String channelType = channel.getChannelTypeUID().getId(); switch (channelType) { case "alarm_raw":
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()); }
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)); } } } }
if (channel.getChannelTypeUID().getId().equals("sensor_report")) { return null;
@Nullable @Override public ProfileTypeUID getSuggestedProfileTypeUID(@Nullable ChannelType channelType, @Nullable String itemType) { if (channelType == null) { return null; } switch (channelType.getKind()) { case STATE: return SystemProfiles.DEFAULT; case TRIGGER: if (DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON.getUID().equals(channelType.getUID())) { if (CoreItemFactory.SWITCH.equalsIgnoreCase(itemType)) { return SystemProfiles.RAWBUTTON_TOGGLE_SWITCH; } } else if (DefaultSystemChannelTypeProvider.SYSTEM_RAWROCKER.getUID().equals(channelType.getUID())) { if (CoreItemFactory.SWITCH.equalsIgnoreCase(itemType)) { return SystemProfiles.RAWROCKER_ON_OFF; } else if (CoreItemFactory.DIMMER.equalsIgnoreCase(itemType)) { return SystemProfiles.RAWROCKER_DIMMER; } else if (CoreItemFactory.PLAYER.equalsIgnoreCase(itemType)) { return SystemProfiles.RAWROCKER_PLAY_PAUSE; } } break; default: throw new IllegalArgumentException("Unsupported channel kind: " + channelType.getKind()); } return null; }
/** * 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()); }
public Response getLinkableItemTypes( @PathParam("channelTypeUID") @ApiParam(value = "channelTypeUID") String channelTypeUID) { ChannelTypeUID ctUID = new ChannelTypeUID(channelTypeUID); ChannelType channelType = channelTypeRegistry.getChannelType(ctUID); if (channelType == null) {
@Override public ChannelType getChannelType(ChannelTypeUID channelTypeUID, Locale locale) { final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class); for (final ChannelType channelType : CHANNEL_TYPES) { if (channelTypeUID.equals(channelType.getUID())) { return createLocalizedChannelType(bundle, channelType, locale); } } return 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; }
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; }