ONOS-1539 - Only display application IDs that have created intents in remove command
Change-Id: I9ff10ce9c9b46b2e93d8ac1a7a7dc52064088883
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationIdNameCompleter.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java
similarity index 78%
rename from cli/src/main/java/org/onosproject/cli/app/ApplicationIdNameCompleter.java
rename to cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java
index 479b727..2539ca7 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationIdNameCompleter.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java
@@ -16,31 +16,29 @@
package org.onosproject.cli.app;
import java.util.List;
-import java.util.Set;
import java.util.SortedSet;
import org.apache.karaf.shell.console.Completer;
import org.apache.karaf.shell.console.completer.StringsCompleter;
import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
+import org.onosproject.net.intent.IntentService;
/**
* Application name completer.
*/
-public class ApplicationIdNameCompleter implements Completer {
+public class ApplicationIdWithIntentNameCompleter implements Completer {
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
- CoreService service = AbstractShellCommand.get(CoreService.class);
- Set<ApplicationId> ids = service.getAppIds();
+ IntentService service = AbstractShellCommand.get(IntentService.class);
SortedSet<String> strings = delegate.getStrings();
- for (ApplicationId id : ids) {
- strings.add(id.name());
- }
+
+ service.getIntents()
+ .forEach(intent ->
+ strings.add(intent.appId().name()));
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(buffer, cursor, candidates);
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 98328b6..01d6e62 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -123,7 +123,7 @@
<command>
<action class="org.onosproject.cli.net.IntentRemoveCommand"/>
<completers>
- <ref component-id="appIdNameCompleter"/>
+ <ref component-id="appIdWithIntentNameCompleter"/>
<ref component-id="intentIdCompleter"/>
<null/>
</completers>
@@ -297,7 +297,7 @@
<bean id="appCommandCompleter" class="org.onosproject.cli.app.ApplicationCommandCompleter"/>
<bean id="appNameCompleter" class="org.onosproject.cli.app.ApplicationNameCompleter"/>
- <bean id="appIdNameCompleter" class="org.onosproject.cli.app.ApplicationIdNameCompleter"/>
+ <bean id="appIdWithIntentNameCompleter" class="org.onosproject.cli.app.ApplicationIdWithIntentNameCompleter"/>
<bean id="cfgCommandCompleter" class="org.onosproject.cli.cfg.ComponentConfigCommandCompleter"/>
<bean id="componentNameCompleter" class="org.onosproject.cli.cfg.ComponentNameCompleter"/>
<bean id="nodeIdCompleter" class="org.onosproject.cli.NodeIdCompleter"/>