Add id field to Intent classes

Change-Id: If3938446de9b65f84e7bbe1a9f5adb8b26de475a
diff --git a/src/main/java/net/onrc/onos/intent/ConstrainedShortestPathIntent.java b/src/main/java/net/onrc/onos/intent/ConstrainedShortestPathIntent.java
index c5db590..b659179 100644
--- a/src/main/java/net/onrc/onos/intent/ConstrainedShortestPathIntent.java
+++ b/src/main/java/net/onrc/onos/intent/ConstrainedShortestPathIntent.java
@@ -10,19 +10,19 @@
 public class ConstrainedShortestPathIntent extends ShortestPathIntent {
 	protected Double bandwidth;
 
-	public ConstrainedShortestPathIntent(
+	public ConstrainedShortestPathIntent(String id,
 			Port srcPort, MACAddress srcMac,
 			Port dstPort, MACAddress dstMac,
 			Double bandwidth) {
-		super(srcPort, srcMac, dstPort, dstMac);
+		super(id, srcPort, srcMac, dstPort, dstMac);
 		this.bandwidth = bandwidth;
 	}
 
-	public ConstrainedShortestPathIntent(NetworkGraph graph,
-			Long srcSwitch, Long srcPort, long srcMac,
-			Long dstSwitch, Long dstPort, long dstMac,
+	public ConstrainedShortestPathIntent(NetworkGraph graph, String id,
+			long srcSwitch, long srcPort, long srcMac,
+			long dstSwitch, long dstPort, long dstMac,
 			Double bandwidth) {
-		super(graph, srcSwitch, srcPort, srcMac, dstSwitch, dstPort, dstMac);
+		super(graph, id, srcSwitch, srcPort, srcMac, dstSwitch, dstPort, dstMac);
 		this.bandwidth = bandwidth;
 	}
 
diff --git a/src/main/java/net/onrc/onos/intent/Intent.java b/src/main/java/net/onrc/onos/intent/Intent.java
index 33888ae..823b106 100644
--- a/src/main/java/net/onrc/onos/intent/Intent.java
+++ b/src/main/java/net/onrc/onos/intent/Intent.java
@@ -4,4 +4,18 @@
  * @author Toshio Koide (t-koide@onlab.us)
  */
 public abstract class Intent {
+	protected String id;
+
+	public Intent(String id) {
+		this.id = id;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	@Override
+	public int hashCode() {
+		return id.hashCode();
+	}
 }
diff --git a/src/main/java/net/onrc/onos/intent/PathIntent.java b/src/main/java/net/onrc/onos/intent/PathIntent.java
index 22948b9..07f53e1 100644
--- a/src/main/java/net/onrc/onos/intent/PathIntent.java
+++ b/src/main/java/net/onrc/onos/intent/PathIntent.java
@@ -9,6 +9,7 @@
 	protected Path path;
 	protected Double bandwidth;
 	protected Intent parentIntent;
+	protected int id;
 
 	/**
 	 * 
@@ -17,8 +18,10 @@
 	 * @param bandwidth bandwidth which should be allocated for the path.
 	 * If null, it means no intent for bandwidth allocation (best effort).
 	 * @param parentIntent parent intent. If null, it means this is root intent.
+	 * @param id
 	 */
-	public PathIntent(Path path, Double bandwidth, Intent parentIntent) {
+	public PathIntent(String id, Path path, Double bandwidth, Intent parentIntent) {
+		super(id);
 		this.path = path;
 		this.bandwidth = bandwidth;
 		this.parentIntent = parentIntent;
diff --git a/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java b/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java
index e7f1a13..b1f58f5 100644
--- a/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java
+++ b/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java
@@ -13,18 +13,20 @@
 	protected MACAddress srcMac = null;
 	protected MACAddress dstMac = null;
 
-	public ShortestPathIntent(
+	public ShortestPathIntent(String id,
 			Port srcPort, MACAddress srcMac,
 			Port dstPort, MACAddress dstMac) {
+		super(id);
 		this.srcPort = srcPort;
 		this.dstPort = dstPort;
 		this.srcMac = srcMac;
 		this.dstMac = dstMac;
 	}
 
-	public ShortestPathIntent(NetworkGraph graph,
-			Long srcSwitch, Long srcPort, long srcMac,
-			Long dstSwitch, Long dstPort, long dstMac) {
+	public ShortestPathIntent(NetworkGraph graph, String id,
+			long srcSwitch, long srcPort, long srcMac,
+			long dstSwitch, long dstPort, long dstMac) {
+		super(id);
 		this.srcPort = graph.getSwitch(srcSwitch).getPort(srcPort);
 		this.dstPort = graph.getSwitch(dstSwitch).getPort(srcPort);
 		this.srcMac = MACAddress.valueOf(srcMac);
diff --git a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
index 3e09f8c..60cf10d 100644
--- a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
+++ b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
@@ -73,7 +73,7 @@
 				continue;
 			}
 
-			pathIntents.addIntent(new PathIntent(path, bandwidth, intent));
+			pathIntents.addIntent(new PathIntent("pi" + intent.getId(), path, bandwidth, intent));
 		}
 		return pathIntents;
 	}