small fix to flowid

Change-Id: I7ba950cf3fe874a094ddd3f93a8d72df0cba89c0
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
new file mode 100644
index 0000000..07d15e2
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
@@ -0,0 +1,78 @@
+package org.onlab.onos.cli.net;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.cli.AbstractShellCommand;
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.device.DeviceService;
+import org.onlab.onos.net.flow.FlowRule;
+import org.onlab.onos.net.flow.FlowRuleService;
+
+import com.google.common.collect.Maps;
+
+/**
+ * Lists all currently-known hosts.
+ */
+@Command(scope = "onos", name = "flows",
+description = "Lists all currently-known flows.")
+public class FlowsListCommand extends AbstractShellCommand {
+
+    private static final String FMT =
+            "   id=%s, selector=%s, treatment=%s, state=%s";
+
+    protected static final Comparator<FlowRule> ID_COMPARATOR = new Comparator<FlowRule>() {
+        @Override
+        public int compare(FlowRule f1, FlowRule f2) {
+            return Long.valueOf(f1.id().value()).compareTo(f2.id().value());
+        }
+    };
+
+    @Override
+    protected Object doExecute() throws Exception {
+        DeviceService deviceService = getService(DeviceService.class);
+        FlowRuleService service = getService(FlowRuleService.class);
+        Map<Device, List<FlowRule>> flows = getSortedFlows(deviceService, service);
+        for (Device d : deviceService.getDevices()) {
+            printFlows(d, flows.get(d));
+        }
+        return null;
+    }
+
+
+    /**
+     * Returns the list of devices sorted using the device ID URIs.
+     *
+     * @param service device service
+     * @return sorted device list
+     */
+    protected Map<Device, List<FlowRule>> getSortedFlows(DeviceService deviceService, FlowRuleService service) {
+        Map<Device, List<FlowRule>> flows = Maps.newHashMap();
+        List<FlowRule> rules;
+        for (Device d : deviceService.getDevices()) {
+            rules = newArrayList(service.getFlowEntries(d.id()));
+            Collections.sort(rules, ID_COMPARATOR);
+            flows.put(d, rules);
+        }
+        return flows;
+    }
+
+    /**
+     * Prints flows.
+     * @param d the device
+     * @param flows the set of flows for that device.
+     */
+    protected void printFlows(Device d, List<FlowRule> flows) {
+        print("Device: " + d.id());
+        for (FlowRule f : flows) {
+            print(FMT, f.id().value(), f.selector(), f.treatment(), f.state());
+        }
+
+    }
+
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index 62e331f..829db3f 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -37,7 +37,7 @@
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
             TrafficTreatment treatment, int priority, FlowRuleState state,
-            long life, long packets, long bytes, Integer flowId) {
+            long life, long packets, long bytes, long flowId) {
         this.deviceId = deviceId;
         this.priority = priority;
         this.selector = selector;
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java
index c7c44cb..6bcf1db 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java
@@ -13,7 +13,7 @@
         this.flowid = id;
     }
 
-    public static FlowId valueOf(int id) {
+    public static FlowId valueOf(long id) {
         return new FlowId(id);
     }