Ray Milkey
Committed by Gerrit Code Review

ONOS-1539 - Only display application IDs that have created intents in remove command

Change-Id: I9ff10ce9c9b46b2e93d8ac1a7a7dc52064088883
...@@ -16,31 +16,29 @@ ...@@ -16,31 +16,29 @@
16 package org.onosproject.cli.app; 16 package org.onosproject.cli.app;
17 17
18 import java.util.List; 18 import java.util.List;
19 -import java.util.Set;
20 import java.util.SortedSet; 19 import java.util.SortedSet;
21 20
22 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
23 import org.apache.karaf.shell.console.completer.StringsCompleter; 22 import org.apache.karaf.shell.console.completer.StringsCompleter;
24 import org.onosproject.cli.AbstractShellCommand; 23 import org.onosproject.cli.AbstractShellCommand;
25 -import org.onosproject.core.ApplicationId; 24 +import org.onosproject.net.intent.IntentService;
26 -import org.onosproject.core.CoreService;
27 25
28 /** 26 /**
29 * Application name completer. 27 * Application name completer.
30 */ 28 */
31 -public class ApplicationIdNameCompleter implements Completer { 29 +public class ApplicationIdWithIntentNameCompleter implements Completer {
32 @Override 30 @Override
33 public int complete(String buffer, int cursor, List<String> candidates) { 31 public int complete(String buffer, int cursor, List<String> candidates) {
34 // Delegate string completer 32 // Delegate string completer
35 StringsCompleter delegate = new StringsCompleter(); 33 StringsCompleter delegate = new StringsCompleter();
36 34
37 // Fetch our service and feed it's offerings to the string completer 35 // Fetch our service and feed it's offerings to the string completer
38 - CoreService service = AbstractShellCommand.get(CoreService.class); 36 + IntentService service = AbstractShellCommand.get(IntentService.class);
39 - Set<ApplicationId> ids = service.getAppIds();
40 SortedSet<String> strings = delegate.getStrings(); 37 SortedSet<String> strings = delegate.getStrings();
41 - for (ApplicationId id : ids) { 38 +
42 - strings.add(id.name()); 39 + service.getIntents()
43 - } 40 + .forEach(intent ->
41 + strings.add(intent.appId().name()));
44 42
45 // Now let the completer do the work for figuring out what to offer. 43 // Now let the completer do the work for figuring out what to offer.
46 return delegate.complete(buffer, cursor, candidates); 44 return delegate.complete(buffer, cursor, candidates);
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
123 <command> 123 <command>
124 <action class="org.onosproject.cli.net.IntentRemoveCommand"/> 124 <action class="org.onosproject.cli.net.IntentRemoveCommand"/>
125 <completers> 125 <completers>
126 - <ref component-id="appIdNameCompleter"/> 126 + <ref component-id="appIdWithIntentNameCompleter"/>
127 <ref component-id="intentIdCompleter"/> 127 <ref component-id="intentIdCompleter"/>
128 <null/> 128 <null/>
129 </completers> 129 </completers>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
297 297
298 <bean id="appCommandCompleter" class="org.onosproject.cli.app.ApplicationCommandCompleter"/> 298 <bean id="appCommandCompleter" class="org.onosproject.cli.app.ApplicationCommandCompleter"/>
299 <bean id="appNameCompleter" class="org.onosproject.cli.app.ApplicationNameCompleter"/> 299 <bean id="appNameCompleter" class="org.onosproject.cli.app.ApplicationNameCompleter"/>
300 - <bean id="appIdNameCompleter" class="org.onosproject.cli.app.ApplicationIdNameCompleter"/> 300 + <bean id="appIdWithIntentNameCompleter" class="org.onosproject.cli.app.ApplicationIdWithIntentNameCompleter"/>
301 <bean id="cfgCommandCompleter" class="org.onosproject.cli.cfg.ComponentConfigCommandCompleter"/> 301 <bean id="cfgCommandCompleter" class="org.onosproject.cli.cfg.ComponentConfigCommandCompleter"/>
302 <bean id="componentNameCompleter" class="org.onosproject.cli.cfg.ComponentNameCompleter"/> 302 <bean id="componentNameCompleter" class="org.onosproject.cli.cfg.ComponentNameCompleter"/>
303 <bean id="nodeIdCompleter" class="org.onosproject.cli.NodeIdCompleter"/> 303 <bean id="nodeIdCompleter" class="org.onosproject.cli.NodeIdCompleter"/>
......