use of org.eclipse.smarthome.core.thing.link.ItemChannelLink in project smarthome by eclipse.
the class LinkConsoleCommandExtension method removeChannelLink.
private void removeChannelLink(Console console, String itemName, ChannelUID channelUID) {
ItemChannelLink itemChannelLink = new ItemChannelLink(itemName, channelUID);
ItemChannelLink removedItemChannelLink = itemChannelLinkRegistry.remove(itemChannelLink.getUID());
if (removedItemChannelLink != null) {
console.println("Link " + itemChannelLink.toString() + "successfully removed.");
} else {
console.println("Could not remove link " + itemChannelLink.toString() + ".");
}
}
use of org.eclipse.smarthome.core.thing.link.ItemChannelLink in project smarthome by eclipse.
the class ChannelItemProviderTest method testItemRemoval_itemFromOtherProvider.
@Test
public void testItemRemoval_itemFromOtherProvider() throws Exception {
provider.linkRegistryListener.added(new ItemChannelLink(ITEM_NAME, CHANNEL_UID));
resetAndPrepareListener();
provider.itemRegistryListener.beforeAdding(new NumberItem(ITEM_NAME));
verify(listener, only()).removed(same(provider), same(ITEM));
verify(listener, never()).added(same(provider), same(ITEM));
}
use of org.eclipse.smarthome.core.thing.link.ItemChannelLink in project smarthome by eclipse.
the class GenericItemChannelLinkProvider method createItemChannelLink.
private void createItemChannelLink(String context, String itemName, String channelUID, Configuration configuration) throws BindingConfigParseException {
ChannelUID channelUIDObject = null;
try {
channelUIDObject = new ChannelUID(channelUID);
} catch (IllegalArgumentException e) {
throw new BindingConfigParseException(e.getMessage());
}
ItemChannelLink itemChannelLink = new ItemChannelLink(itemName, channelUIDObject, configuration);
Set<String> itemNames = contextMap.get(context);
if (itemNames == null) {
itemNames = new HashSet<>();
contextMap.put(context, itemNames);
}
itemNames.add(itemName);
if (previousItemNames != null) {
previousItemNames.remove(itemName);
}
Set<ItemChannelLink> links = itemChannelLinkMap.get(itemName);
if (links == null) {
itemChannelLinkMap.put(itemName, links = new HashSet<>());
}
if (!links.contains(itemChannelLink)) {
links.add(itemChannelLink);
notifyListenersAboutAddedElement(itemChannelLink);
} else {
notifyListenersAboutUpdatedElement(itemChannelLink, itemChannelLink);
}
}
use of org.eclipse.smarthome.core.thing.link.ItemChannelLink in project smarthome by eclipse.
the class ChannelItemProviderTest method testItemCreation_alreadyExists.
@Test
public void testItemCreation_alreadyExists() throws Exception {
when(itemRegistry.get(eq(ITEM_NAME))).thenReturn(ITEM);
provider.linkRegistryListener.added(new ItemChannelLink(ITEM_NAME, CHANNEL_UID));
verify(listener, never()).added(same(provider), same(ITEM));
}
use of org.eclipse.smarthome.core.thing.link.ItemChannelLink in project smarthome by eclipse.
the class ChannelItemProviderTest method testItemCreation_notThere.
@Test
public void testItemCreation_notThere() throws Exception {
provider.linkRegistryListener.added(new ItemChannelLink(ITEM_NAME, CHANNEL_UID));
verify(listener, only()).added(same(provider), same(ITEM));
}
Aggregations