refactoring OpticalPathIntent

Change-Id: Ic6ab6237237b2a5019851182b2869110bc5b1b73
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
index afa0004..372da91 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
@@ -6,46 +6,45 @@
 import org.onlab.onos.net.ConnectPoint;
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.Path;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
 
 import com.google.common.base.MoreObjects;
 
-public class OpticalPathIntent extends OpticalConnectivityIntent {
+public class OpticalPathIntent extends ConnectivityIntent {
+
+    private final ConnectPoint src;
+    private final ConnectPoint dst;
     private final Path path;
-    // private final TrafficSelector opticalMatch;
-    // private final TrafficTreatment opticalAction;
+
 
     public OpticalPathIntent(ApplicationId appId,
             ConnectPoint src,
             ConnectPoint dst,
-            TrafficSelector match,
-            TrafficTreatment action,
             Path path) {
-        super(appId, src, dst);
-        // this.opticalMatch = match;
-        // this.opticalAction = action;
+        super(id(OpticalPathIntent.class, src, dst),
+              appId, resources(path.links()), null, null);
+        this.src = src;
+        this.dst = dst;
         this.path = path;
     }
 
     protected OpticalPathIntent() {
-        // this.opticalMatch = null;
-        // this.opticalAction = null;
+        this.src = null;
+        this.dst = null;
         this.path = null;
     }
 
+    public ConnectPoint src() {
+        return src;
+    }
+
+    public ConnectPoint dst() {
+        return dst;
+    }
+
     public Path path() {
         return path;
     }
-/*
-    public TrafficSelector selector() {
-        // return opticalMatch;
-    }
 
-    public TrafficTreatment treatment() {
-        // return opticalAction;
-    }
-*/
     @Override
     public boolean isInstallable() {
         return true;
@@ -55,10 +54,8 @@
     public String toString() {
         return MoreObjects.toStringHelper(getClass())
                 .add("id", id())
-                //.add("match", opticalMatch)
-                //.add("action", opticalAction)
-                .add("ingressPort", this.getSrcConnectPoint())
-                .add("egressPort", this.getDst())
+                .add("ingressPort", src)
+                .add("egressPort", dst)
                 .add("path", path)
                 .toString();
     }
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
index 9b98cec..f5272f2 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
@@ -14,16 +14,11 @@
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.onlab.onos.CoreService;
 import org.onlab.onos.net.ConnectPoint;
-
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.Path;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-
 import org.onlab.onos.net.intent.Intent;
 import org.onlab.onos.net.intent.IntentCompiler;
 import org.onlab.onos.net.intent.IntentExtensionService;
-
 import org.onlab.onos.net.intent.OpticalConnectivityIntent;
 import org.onlab.onos.net.intent.OpticalPathIntent;
 import org.onlab.onos.net.provider.ProviderId;
@@ -32,7 +27,6 @@
 import org.onlab.onos.net.topology.PathService;
 import org.onlab.onos.net.topology.Topology;
 import org.onlab.onos.net.topology.TopologyEdge;
-
 import org.onlab.onos.net.topology.TopologyService;
 import org.slf4j.Logger;
 
@@ -88,15 +82,10 @@
         links.addAll(path.links());
         //links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false));
 
-        TrafficSelector opticalSelector = null;
-        TrafficTreatment opticalTreatment = null;
-
         // create a new opticalPathIntent
         Intent newIntent = new OpticalPathIntent(intent.appId(),
                 path.src(),
                 path.dst(),
-                opticalSelector,
-                opticalTreatment,
                 path);
 
         retList.add(newIntent);
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
index 57ae6dd..5cfee19 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
@@ -3,7 +3,6 @@
 import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
 import static org.slf4j.LoggerFactory.getLogger;
 
-
 import java.util.List;
 
 import org.apache.felix.scr.annotations.Activate;
@@ -20,11 +19,11 @@
 import org.onlab.onos.net.flow.DefaultTrafficTreatment;
 import org.onlab.onos.net.flow.FlowRule;
 import org.onlab.onos.net.flow.FlowRuleBatchEntry;
+import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
 import org.onlab.onos.net.flow.FlowRuleBatchOperation;
 import org.onlab.onos.net.flow.FlowRuleService;
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
-import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
 import org.onlab.onos.net.intent.IntentExtensionService;
 import org.onlab.onos.net.intent.IntentInstaller;
 import org.onlab.onos.net.intent.OpticalPathIntent;
@@ -86,12 +85,12 @@
         LinkResourceAllocations allocations = assignWavelength(intent);
 
         TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-        selectorBuilder.matchInport(intent.getSrcConnectPoint().port());
+        selectorBuilder.matchInport(intent.src().port());
 
         TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
 
         List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
-        ConnectPoint prev = intent.getSrcConnectPoint();
+        ConnectPoint prev = intent.src();
 
         //TODO throw exception if the lambda was not assigned successfully
         for (Link link : intent.path().links()) {
@@ -127,8 +126,8 @@
 
         // build the last T port rule
         TrafficTreatment treatmentLast = builder()
-                .setOutput(intent.getDst().port()).build();
-        FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(),
+                .setOutput(intent.dst().port()).build();
+        FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
                 selectorBuilder.build(),
                 treatmentLast,
                 100,
@@ -190,12 +189,12 @@
         LinkResourceAllocations allocations = resourceService.getAllocations(intent.id());
 
         TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-        selectorBuilder.matchInport(intent.getSrcConnectPoint().port());
+        selectorBuilder.matchInport(intent.src().port());
 
         TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
 
         List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
-        ConnectPoint prev = intent.getSrcConnectPoint();
+        ConnectPoint prev = intent.src();
 
         //TODO throw exception if the lambda was not retrieved successfully
         for (Link link : intent.path().links()) {
@@ -231,8 +230,8 @@
 
         // build the last T port rule
         TrafficTreatment treatmentLast = builder()
-                .setOutput(intent.getDst().port()).build();
-        FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(),
+                .setOutput(intent.dst().port()).build();
+        FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
                 selectorBuilder.build(),
                 treatmentLast,
                 100,