ONOS-6071 adding Mods for protection links

Change-Id: I116f6af0044debac635e9a8ddeae12ab43bb1fe6
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/ProtectedIntentMonitor.java b/web/gui/src/main/java/org/onosproject/ui/impl/ProtectedIntentMonitor.java
index 5d928a0..3a92428 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/ProtectedIntentMonitor.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/ProtectedIntentMonitor.java
@@ -17,6 +17,7 @@
 package org.onosproject.ui.impl;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.ElementId;
@@ -38,6 +39,7 @@
 import org.onosproject.ui.topo.Highlights;
 import org.onosproject.ui.topo.HostHighlight;
 import org.onosproject.ui.topo.LinkHighlight.Flavor;
+import org.onosproject.ui.topo.Mod;
 import org.onosproject.ui.topo.NodeHighlight;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,7 +62,18 @@
 
     private static final Logger log =
             LoggerFactory.getLogger(ProtectedIntentMonitor.class);
-    public static final String PRIMARY_PATH_TAG = "protection1";
+    private static final String PRIMARY_PATH_TAG = "protection1";
+
+    private static final String PROT_PRIMARY = "protPrimary";
+    private static final String PROT_BACKUP = "protBackup";
+
+
+    private static final Mod MOD_PROT_PRIMARY = new Mod(PROT_PRIMARY);
+    private static final Set<Mod> PROTECTED_MOD_PRIMARY_SET = ImmutableSet.of(MOD_PROT_PRIMARY);
+
+    private static final Mod MOD_PROT_BACKUP = new Mod(PROT_BACKUP);
+    private static final Set<Mod> PROTECTED_MOD_BACKUP_SET = ImmutableSet.of(MOD_PROT_BACKUP);
+
 
     /**
      * Designates the different modes of operation.
@@ -202,10 +215,13 @@
                 //Flavor is swapped so green is primary path.
                 if (usingBackup(primary)) {
                     //the backup becomes in use so we have a dotted line
-                    processLinks(linkMap, backup, Flavor.PRIMARY_HIGHLIGHT, isOptical, true);
+                    processLinks(linkMap, backup, Flavor.PRIMARY_HIGHLIGHT,
+                                 isOptical, true, PROTECTED_MOD_BACKUP_SET);
                 } else {
-                    processLinks(linkMap, primary, Flavor.SECONDARY_HIGHLIGHT, isOptical, true);
-                    processLinks(linkMap, backup, Flavor.PRIMARY_HIGHLIGHT, isOptical, false);
+                    processLinks(linkMap, primary, Flavor.PRIMARY_HIGHLIGHT,
+                                 isOptical, true, PROTECTED_MOD_PRIMARY_SET);
+                    processLinks(linkMap, backup, Flavor.SECONDARY_HIGHLIGHT,
+                                 isOptical, false, PROTECTED_MOD_BACKUP_SET);
                 }
                 updateHighlights(highlights, primary);
                 updateHighlights(highlights, backup);
@@ -279,7 +295,7 @@
 
     private void processLinks(TrafficLinkMap linkMap, Iterable<Link> links,
                               Flavor flavor, boolean isOptical,
-                              boolean showTraffic) {
+                              boolean showTraffic, Set<Mod> mods) {
         if (links != null) {
             for (Link link : links) {
                 TrafficLink tlink = linkMap.add(link);
@@ -288,6 +304,7 @@
                 if (showTraffic) {
                     tlink.antMarch(true);
                 }
+                tlink.tagMods(mods);
             }
         }
     }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
index 0089292..16d3db7 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
@@ -22,11 +22,13 @@
 import org.onosproject.ui.topo.BiLink;
 import org.onosproject.ui.topo.LinkHighlight;
 import org.onosproject.ui.topo.LinkHighlight.Flavor;
+import org.onosproject.ui.topo.Mod;
 import org.onosproject.ui.topo.TopoUtils;
 
-import static org.onosproject.ui.topo.LinkHighlight.Flavor.NO_HIGHLIGHT;
-import static org.onosproject.ui.topo.LinkHighlight.Flavor.PRIMARY_HIGHLIGHT;
-import static org.onosproject.ui.topo.LinkHighlight.Flavor.SECONDARY_HIGHLIGHT;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.onosproject.ui.topo.LinkHighlight.Flavor.*;
 
 /**
  * Representation of a link and its inverse, and associated traffic data.
@@ -45,6 +47,7 @@
     private boolean hasTraffic = false;
     private boolean isOptical = false;
     private boolean antMarch = false;
+    private Set<Mod> mods = new HashSet<>();
 
     /**
      * Constructs a traffic link for the given key and initial link.
@@ -90,6 +93,19 @@
     }
 
     /**
+     * Tags this traffic link with the mods to be used in visual rendering.
+     *
+     * @param mods the mods to tag on this link
+     * @return self, for chaining
+     */
+    public TrafficLink tagMods(Set<Mod> mods) {
+        if (mods != null) {
+            this.mods.addAll(mods);
+        }
+        return this;
+    }
+
+    /**
      * Adds load statistics, marks the traffic link as having traffic.
      *
      * @param load load to add
@@ -103,7 +119,7 @@
      * load {@link Load#rate rate} is greater than the given threshold
      * (expressed in bytes per second).
      *
-     * @param load load to add
+     * @param load      load to add
      * @param threshold threshold to register traffic
      */
     public void addLoad(Load load, double threshold) {
@@ -143,14 +159,23 @@
     }
 
     private LinkHighlight highlightForStats(StatsType type) {
-        return new LinkHighlight(linkId(), SECONDARY_HIGHLIGHT)
+        LinkHighlight hlite = new LinkHighlight(linkId(), SECONDARY_HIGHLIGHT)
                 .setLabel(generateLabel(type));
+        if (!mods.isEmpty()) {
+            mods.forEach(hlite::addMod);
+        }
+        return hlite;
     }
 
     private LinkHighlight highlightForFlowCount(StatsType type) {
         Flavor flavor = flows > 0 ? PRIMARY_HIGHLIGHT : SECONDARY_HIGHLIGHT;
-        return new LinkHighlight(linkId(), flavor)
+        LinkHighlight hlite = new LinkHighlight(linkId(), flavor)
                 .setLabel(generateLabel(type));
+        if (!mods.isEmpty()) {
+            mods.forEach(hlite::addMod);
+        }
+        return hlite;
+
     }
 
     private LinkHighlight highlightForTagging(StatsType type) {
@@ -162,6 +187,9 @@
         if (antMarch) {
             hlite.addMod(LinkHighlight.MOD_ANIMATED);
         }
+        if (!mods.isEmpty()) {
+            mods.forEach(hlite::addMod);
+        }
         return hlite;
     }
 
diff --git a/web/gui/src/main/webapp/app/view/topo/protected-intents.css b/web/gui/src/main/webapp/app/view/topo/protected-intents.css
new file mode 100644
index 0000000..6fca91c
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/topo/protected-intents.css
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ov-topo svg .link.protPrimary {
+    stroke-width: 5px;
+    stroke: #00cc00;
+}
+
+#ov-topo svg .link.protBackup {
+    stroke-width: 4px;
+    stroke: #cc4400;
+}
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index b391cde..f053f02 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -216,6 +216,7 @@
     <!-- Builtin views stylesheets. -->
     <link rel="stylesheet" href="app/view/topo/topo.css">
     <link rel="stylesheet" href="app/view/topo/topo-theme.css">
+    <link rel="stylesheet" href="app/view/topo/protected-intents.css">
     <link rel="stylesheet" href="app/view/device/device.css">
     <link rel="stylesheet" href="app/view/device/device-theme.css">
     <link rel="stylesheet" href="app/view/flow/flow.css">