Simplify MP2S compiler, fix ingress/egress on same switch bug in SP2M compiler

Change-Id: Ib47bba01aac0f358f2caa5525c18e0e90a0b13ff
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index 3a40622..5c158e0 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -15,12 +15,8 @@
  */
 package org.onosproject.net.intent.impl.compiler;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -40,10 +36,11 @@
 import org.onosproject.net.resource.link.LinkResourceAllocations;
 import org.onosproject.net.topology.PathService;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * An intent compiler for
@@ -73,37 +70,32 @@
     public List<Intent> compile(MultiPointToSinglePointIntent intent, List<Intent> installable,
                                 Set<LinkResourceAllocations> resources) {
         Map<DeviceId, Link> links = new HashMap<>();
-        Map<DeviceId, Link> edgeLinks = new HashMap<>();
         ConnectPoint egressPoint = intent.egressPoint();
 
         for (ConnectPoint ingressPoint : intent.ingressPoints()) {
             if (ingressPoint.deviceId().equals(egressPoint.deviceId())) {
-                edgeLinks.put(ingressPoint.deviceId(), createEdgeLink(ingressPoint, true));
-                edgeLinks.put(egressPoint.deviceId(), createEdgeLink(egressPoint, false));
-            } else {
-                Path path = getPath(ingressPoint, intent.egressPoint());
-                for (Link link : path.links()) {
-                    if (links.containsKey(link.src().deviceId())) {
-                        // We've already reached the existing tree with the first
-                        // part of this path. Add the merging point with different
-                        // incoming port, but don't add the remainder of the path
-                        // in case it differs from the path we already have.
-                        links.put(link.src().deviceId(), link);
-                        break;
-                    }
-
+                continue;
+            }
+            Path path = getPath(ingressPoint, intent.egressPoint());
+            for (Link link : path.links()) {
+                if (links.containsKey(link.src().deviceId())) {
+                    // We've already reached the existing tree with the first
+                    // part of this path. Add the merging point with different
+                    // incoming port, but don't add the remainder of the path
+                    // in case it differs from the path we already have.
                     links.put(link.src().deviceId(), link);
+                    break;
                 }
+
+                links.put(link.src().deviceId(), link);
             }
         }
 
-        Set<Link> allLinks = Sets.newHashSet(links.values());
-        allLinks.addAll(edgeLinks.values());
         Intent result = LinkCollectionIntent.builder()
                 .appId(intent.appId())
                 .selector(intent.selector())
                 .treatment(intent.treatment())
-                .links(Sets.newHashSet(allLinks))
+                .links(Sets.newHashSet(links.values()))
                 .ingressPoints(intent.ingressPoints())
                 .egressPoints(ImmutableSet.of(intent.egressPoint()))
                 .priority(intent.priority())