Package org.openhab.core.thing.link
Class ItemChannelLinkRegistry
java.lang.Object
org.openhab.core.common.registry.AbstractRegistry<ItemChannelLink,String,ItemChannelLinkProvider>
  
org.openhab.core.thing.link.AbstractLinkRegistry<ItemChannelLink,ItemChannelLinkProvider>
 
org.openhab.core.thing.link.ItemChannelLinkRegistry
- All Implemented Interfaces:
 ProviderChangeListener<ItemChannelLink>,Registry<ItemChannelLink,,String> RegistryChangeListener<Item>,EventSubscriber
@NonNullByDefault
public class ItemChannelLinkRegistry
extends AbstractLinkRegistry<ItemChannelLink,ItemChannelLinkProvider>
implements RegistryChangeListener<Item>, EventSubscriber 
- Author:
 - Dennis Nobel - Initial contribution, Markus Rathgeb - Linked items returns only existing items, Markus Rathgeb - Rewrite collection handling to improve performance, Andrew Fiddian-Green - Apply channel default tags to items
 
- 
Nested Class Summary
Nested Classes - 
Field Summary
FieldsFields inherited from interface org.openhab.core.events.EventSubscriber
ALL_EVENT_TYPES - 
Constructor Summary
ConstructorsConstructorDescriptionItemChannelLinkRegistry(@Nullable Map<String, @Nullable Object> configuration, ThingRegistry thingRegistry, ItemRegistry itemRegistry, ItemBuilderFactory itemBuilderFactory, org.osgi.framework.BundleContext bundleContext)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidIf a new item is added to the item registry and we already have prior "pre- orphaned" links to it, then update the tags from the default tags of the prior linked channels.protected voidgetBoundChannels(String itemName) Returns a set of bound channels for the given item name.getBoundThings(String itemName) Returns a set of bound things for the given item name.getLinkedItemNames(UID uid) Returns the item names, which are bound to the given UID.getLinkedItems(UID uid) Returns a set of bound items for the given channel UID.Get all orphan links (item or channel missing)Subscribe to system start level events.protected voidprotected voidprotected voidprotected voidnotifyListenersAboutUpdatedElement(ItemChannelLink oldElement, ItemChannelLink element) intpurge()Remove all orphaned (item or channel missing) links that are editablevoidRe-initialize (one off) all the channel default tags when startup is complete.voidIf the item has gone then clear the 'tagsLinked' flag.intremoveLinksForItem(String itemName) Remove all links related to an itemintremoveLinksForThing(ThingUID thingUID) Remove all links related to a thingprotected voidsetEventPublisher(EventPublisher eventPublisher) protected voidprotected voidsetReadyService(ReadyService readyService) protected voidunsetEventPublisher(EventPublisher eventPublisher) protected voidprotected voidunsetReadyService(ReadyService readyService) voidEither this class applied channel default tags to the item, or something else updated the item (including possibly updating its tags), so in any case do NOT try to re-apply the channel default tags.Methods inherited from class org.openhab.core.thing.link.AbstractLinkRegistry
getLinks, getLinks, isLinked, isLinked, isLinked, onAddElement, onRemoveElement, onUpdateElementMethods inherited from class org.openhab.core.common.registry.AbstractRegistry
activate, add, added, addProvider, addRegistryChangeListener, beforeUpdateElement, forEach, forEach, forEach, get, getAll, getEventPublisher, getManagedProvider, getProvider, getProvider, getValueAndProvider, notifyListeners, notifyListeners, postEvent, remove, removed, removeProvider, removeRegistryChangeListener, setManagedProvider, stream, unsetManagedProvider, update, updated, waitForCompletedAsyncActivationTasksMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openhab.core.events.EventSubscriber
getEventFilter 
- 
Field Details
- 
USE_TAGS
- See Also:
 
 
 - 
 - 
Constructor Details
- 
ItemChannelLinkRegistry
public ItemChannelLinkRegistry(@Nullable Map<String, @Nullable Object> configuration, ThingRegistry thingRegistry, ItemRegistry itemRegistry, ItemBuilderFactory itemBuilderFactory, org.osgi.framework.BundleContext bundleContext)  
 - 
 - 
Method Details
- 
modified
 - 
deactivate
protected void deactivate()- Overrides:
 deactivatein classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
getBoundChannels
Returns a set of bound channels for the given item name.- Parameters:
 itemName- item name- Returns:
 - an unmodifiable set of bound channels for the given item name
 
 - 
getLinkedItemNames
Description copied from class:AbstractLinkRegistryReturns the item names, which are bound to the given UID.- Overrides:
 getLinkedItemNamesin classAbstractLinkRegistry<ItemChannelLink,ItemChannelLinkProvider> - Parameters:
 uid- UID- Returns:
 - a non-null unmodifiable collection of item names that are linked to the given UID.
 
 - 
getLinkedItems
Returns a set of bound items for the given channel UID.- Parameters:
 uid- channel UID- Returns:
 - an unmodifiable set of bound items for the given channel UID
 
 - 
getBoundThings
Returns a set of bound things for the given item name.- Parameters:
 itemName- item name- Returns:
 - an unmodifiable set of bound things for the given item name
 
 - 
setManagedProvider
 - 
unsetManagedProvider
 - 
setEventPublisher
- Overrides:
 setEventPublisherin classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
setReadyService
- Overrides:
 setReadyServicein classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
unsetReadyService
- Overrides:
 unsetReadyServicein classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
unsetEventPublisher
- Overrides:
 unsetEventPublisherin classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
removeLinksForThing
Remove all links related to a thing- Parameters:
 thingUID- the UID of the thing- Returns:
 - the number of removed links
 
 - 
removeLinksForItem
Remove all links related to an item- Parameters:
 itemName- the name of the item- Returns:
 - the number of removed links
 
 - 
purge
public int purge()Remove all orphaned (item or channel missing) links that are editable- Returns:
 - the number of removed links
 - See Also:
 
 - 
getOrphanLinks
Get all orphan links (item or channel missing)- Returns:
 - a map with orphan links as key and reason they are broken as value
 - See Also:
 
 - 
notifyListenersAboutAddedElement
- Overrides:
 notifyListenersAboutAddedElementin classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
notifyListenersAboutRemovedElement
- Overrides:
 notifyListenersAboutRemovedElementin classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
notifyListenersAboutUpdatedElement
protected void notifyListenersAboutUpdatedElement(ItemChannelLink oldElement, ItemChannelLink element) - Overrides:
 notifyListenersAboutUpdatedElementin classAbstractRegistry<ItemChannelLink,String, ItemChannelLinkProvider> 
 - 
added
If a new item is added to the item registry and we already have prior "pre- orphaned" links to it, then update the tags from the default tags of the prior linked channels.- Specified by:
 addedin interfaceRegistryChangeListener<Item>- Parameters:
 item- the element that has been added
 - 
removed
If the item has gone then clear the 'tagsLinked' flag.- Specified by:
 removedin interfaceRegistryChangeListener<Item>- Parameters:
 item- the element that has been removed
 - 
updated
Either this class applied channel default tags to the item, or something else updated the item (including possibly updating its tags), so in any case do NOT try to re-apply the channel default tags. Since that might cause an infinite loop.- Specified by:
 updatedin interfaceRegistryChangeListener<Item>- Parameters:
 oldItem- the element that has been updateditem- the new element
 - 
getSubscribedEventTypes
Subscribe to system start level events.- Specified by:
 getSubscribedEventTypesin interfaceEventSubscriber- Returns:
 - subscribed event types (not null)
 
 - 
receive
Re-initialize (one off) all the channel default tags when startup is complete.- Specified by:
 receivein interfaceEventSubscriber- Parameters:
 event- the received event (not null)
 
 -