use of org.eclipse.smarthome.config.discovery.internal.PersistentInbox in project smarthome by eclipse.
the class InboxConsoleCommandExtension method execute.
@Override
public void execute(String[] args, Console console) {
if (args.length > 0) {
final String subCommand = args[0];
switch(subCommand) {
case SUBCMD_APPROVE:
if (args.length > 2) {
String label = args[2];
try {
ThingUID thingUID = new ThingUID(args[1]);
List<DiscoveryResult> results = inbox.stream().filter(forThingUID(thingUID)).collect(Collectors.toList());
if (results.isEmpty()) {
console.println("No matching inbox entry could be found.");
return;
}
inbox.approve(thingUID, label);
} catch (Exception e) {
console.println(e.getMessage());
}
} else {
console.println("Specify thing id to approve: inbox approve <thingUID> <label>");
}
break;
case SUBCMD_IGNORE:
if (args.length > 1) {
try {
ThingUID thingUID = new ThingUID(args[1]);
PersistentInbox persistentInbox = (PersistentInbox) inbox;
persistentInbox.setFlag(thingUID, DiscoveryResultFlag.IGNORED);
} catch (IllegalArgumentException e) {
console.println("'" + args[1] + "' is no valid thing UID.");
}
} else {
console.println("Cannot approve thing as managed thing provider is missing.");
}
break;
case SUBCMD_LIST_IGNORED:
printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.IGNORED))).collect(Collectors.toList()));
break;
case SUBCMD_CLEAR:
clearInboxEntries(console, inbox.getAll());
break;
default:
break;
}
} else {
printInboxEntries(console, inbox.stream().filter(withFlag((DiscoveryResultFlag.NEW))).collect(Collectors.toList()));
}
}
Aggregations