[VOL-4179] Multi UNI changes for Sadis

Review fixes finished

Multi UNI changes for Sadis implemented. New bandwidth profile fields are added for Olt device.

Inside of constructor made it more readible

Change-Id: I82bf45a6a4e7aa056fdfb555ba32a63da3a01284
diff --git a/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java b/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
index 7656cf0..216b5f8 100644
--- a/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
+++ b/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
@@ -227,6 +227,7 @@
 
         if (info != null) {
             local.put(id, info);
+            log.debug("Returning Info {}", info);
             return info;
         } else {
             log.warn("Data not found for id {}", id);
diff --git a/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java b/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
index d794433..43170a8 100644
--- a/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
+++ b/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
@@ -62,23 +62,25 @@
  *             "remoteId"                   : string,
  *             "uniTagList": [
  *                  {
- *                  "uniTagMatch"               : int,
- *                  "ponCTag"                   : string,
- *                  "ponSTag"                   : string,
- *                  "usPonCTagPriority"         : int,
- *                  "dsPonCTagPriority"         : int,
- *                  "usPonSTagPriority"         : int,
- *                  "dsPonSTagPriority"         : int,
- *                  "technologyProfileId"       : int,
- *                  "upstreamBandwidthProfile"  : string,
- *                  "downstreamBandwidthProfile": string,
- *                  "enableMacLearning"         : string,
- *                  "configuredDacAddress"      : string,
- *                  "isDhcpRequired"            : string,
- *                  "isIgmpRequired"            : string,
- *                  "serviceName"               : string
+ *                  "uniTagMatch"                   : int,
+ *                  "ponCTag"                       : string,
+ *                  "ponSTag"                       : string,
+ *                  "usPonCTagPriority"             : int,
+ *                  "dsPonCTagPriority"             : int,
+ *                  "usPonSTagPriority"             : int,
+ *                  "dsPonSTagPriority"             : int,
+ *                  "technologyProfileId"           : int,
+ *                  "upstreamBandwidthProfile"      : string,
+ *                  "downstreamBandwidthProfile"    : string,
+ *                  "upstreamOltBandwidthProfile"   : string,
+ *                  "downstreamOltBandwidthProfile" : string,
+ *                  "enableMacLearning"             : string,
+ *                  "configuredDacAddress"          : string,
+ *                  "isDhcpRequired"                : string,
+ *                  "isIgmpRequired"                : string,
+ *                  "serviceName"                   : string
  *                 }
- *                 ]
+ *              ]
  *         }, ...
  *     ]
  * }
@@ -100,6 +102,8 @@
     private static final String TP_ID = "technologyProfileId";
     private static final String US_BW = "upstreamBandwidthProfile";
     private static final String DS_BW = "downstreamBandwidthProfile";
+    private static final String US_OLT_BW = "upstreamOltBandwidthProfile";
+    private static final String DS_OLT_BW = "downstreamOltBandwidthProfile";
     private static final String SERVICE_NAME = "serviceName";
     private static final String IS_DHCP_REQ = "isDhcpRequired";
     private static final String IS_IGMP_REQ = "isIgmpRequired";
@@ -156,6 +160,8 @@
     }
 
     public UniTagInformation getUniTagInformation(JsonNode node) {
+        String usBw = node.get(US_BW) == null ? null : node.get(US_BW).asText();
+        String dsBw = node.get(DS_BW) == null ? null : node.get(DS_BW).asText();
         return new UniTagInformation.Builder()
                 .setUniTagMatch(VlanId.vlanId(node.get(UNI_TAG_MATCH) == null ? VlanId.NO_VID
                         : (short) node.get(UNI_TAG_MATCH).asInt()))
@@ -172,10 +178,12 @@
                 .setEnableMacLearning(node.get(MAC_LEARNING) == null ? false :
                         node.get(MAC_LEARNING).asBoolean())
                 .setTechnologyProfileId(node.get(TP_ID).asInt())
-                .setUpstreamBandwidthProfile(node.get(US_BW) == null ? null
-                        : node.get(US_BW).asText())
-                .setDownstreamBandwidthProfile(node.get(DS_BW) == null ? null
-                        : node.get(DS_BW).asText())
+                .setUpstreamBandwidthProfile(usBw)
+                .setDownstreamBandwidthProfile(dsBw)
+                .setUpstreamOltBandwidthProfile(node.get(US_OLT_BW) == null ? usBw
+                        : node.get(US_OLT_BW).asText())
+                .setDownstreamOltBandwidthProfile(node.get(DS_OLT_BW) == null ? dsBw
+                        : node.get(DS_OLT_BW).asText())
                 .setServiceName(node.get(SERVICE_NAME) == null ? NO_SN :
                         node.get(SERVICE_NAME).asText())
                 .setIsDhcpRequired(node.get(IS_DHCP_REQ) == null ? false : node.get(IS_DHCP_REQ).asBoolean())
diff --git a/app/src/main/java/org/opencord/sadis/impl/SubscriberManager.java b/app/src/main/java/org/opencord/sadis/impl/SubscriberManager.java
index b0de0c4..01f948f 100644
--- a/app/src/main/java/org/opencord/sadis/impl/SubscriberManager.java
+++ b/app/src/main/java/org/opencord/sadis/impl/SubscriberManager.java
@@ -29,6 +29,7 @@
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.config.ConfigFactory;
 import org.opencord.sadis.SubscriberAndDeviceInformation;
+import org.opencord.sadis.UniTagInformation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -74,8 +75,10 @@
         SubscriberAndDeviceInformationConfig config = new SubscriberAndDeviceInformationConfig();
         SubscriberAndDeviceInformationConfig.VlanIdDeserializer vlanID = config.new VlanIdDeserializer();
         SubscriberAndDeviceInformationConfig.Ip4AddressDeserializer ip4Address = config.new Ip4AddressDeserializer();
+        SubscriberAndDeviceInformationConfig.UniTagDeserializer uniTagSerializer = config.new UniTagDeserializer();
         module.addDeserializer(VlanId.class, vlanID);
         module.addDeserializer(Ip4Address.class, ip4Address);
+        module.addDeserializer(UniTagInformation.class, uniTagSerializer);
         mapper.registerModule(module);
     }
 
diff --git a/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java b/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
index 5e27e52..cad67c0 100644
--- a/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
+++ b/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
@@ -20,9 +20,14 @@
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
 import org.opencord.sadis.UniTagInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class UniTagInformationCodec extends JsonCodec<UniTagInformation> {
 
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+
     private static final String UNI_TAG_MATCH = "uniTagMatch";
     private static final String PON_CTAG = "ponCTag";
     private static final String PON_STAG = "ponSTag";
@@ -33,6 +38,8 @@
     private static final String TP_ID = "technologyProfileId";
     private static final String US_BP = "upstreamBandwidthProfile";
     private static final String DS_BP = "downstreamBandwidthProfile";
+    private static final String US_OLT_BP = "upstreamOltBandwidthProfile";
+    private static final String DS_OLT_BP = "downstreamOltBandwidthProfile";
     private static final String SN = "serviceName";
     private static final String MAC_LEARN = "enableMacLearning";
     private static final String MAC = "configuredMacAddress";
@@ -60,6 +67,8 @@
                 .put(TP_ID, entry.getTechnologyProfileId())
                 .put(US_BP, entry.getUpstreamBandwidthProfile())
                 .put(DS_BP, entry.getDownstreamBandwidthProfile())
+                .put(US_OLT_BP, entry.getUpstreamOltBandwidthProfile())
+                .put(DS_OLT_BP, entry.getDownstreamOltBandwidthProfile())
                 .put(SN, entry.getServiceName())
                 .put(MAC_LEARN, entry.getEnableMacLearning())
                 .put(MAC, entry.getConfiguredMacAddress())
@@ -74,6 +83,12 @@
         }
 
         UniTagInformation.Builder tagInfoBuilder = new UniTagInformation.Builder();
+        String usBp = json.get(US_BP) == null ? EMPTY_BP :
+                json.get(US_BP).asText();
+        String dsBp = json.get(DS_BP) == null ? EMPTY_BP :
+                json.get(DS_BP).asText();
+        String usOltBp = json.get(US_OLT_BP) == null ? usBp : json.get(US_OLT_BP).asText();
+        String dsOltBp = json.get(DS_OLT_BP) == null ? dsBp : json.get(DS_OLT_BP).asText();
         tagInfoBuilder.setUniTagMatch(json.get(UNI_TAG_MATCH) == null ? VlanId.vlanId(VlanId.NO_VID) :
                 VlanId.vlanId(json.get(UNI_TAG_MATCH).shortValue()))
                 .setPonCTag(json.get(PON_CTAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
@@ -90,10 +105,10 @@
                         json.get(DS_PON_STAG_PCP).asInt())
                 .setTechnologyProfileId(json.get(TP_ID) == null ? NO_TP :
                         json.get(TP_ID).asInt())
-                .setUpstreamBandwidthProfile(json.get(US_BP) == null ? EMPTY_BP :
-                        json.get(US_BP).asText())
-                .setDownstreamBandwidthProfile(json.get(DS_BP) == null ? EMPTY_BP :
-                        json.get(DS_BP).asText())
+                .setUpstreamBandwidthProfile(usBp)
+                .setDownstreamBandwidthProfile(dsBp)
+                .setUpstreamOltBandwidthProfile(usOltBp)
+                .setDownstreamOltBandwidthProfile(dsOltBp)
                 .setServiceName(json.get(SN) == null ? EMPTY_SN :
                         json.get(SN).asText())
                 .setEnableMacLearning(json.get(MAC_LEARN) == null ? DEFAULT_MAC_LEARN :
@@ -104,7 +119,7 @@
                         json.get(DHCP_REQ).asBoolean())
                 .setIsIgmpRequired(json.get(IGMP_REQ) == null ? DEFAULT_IGMP_REQ :
                         json.get(IGMP_REQ).asBoolean());
-
+        log.info("Codec UniTagInformation Codec builder returning {}", tagInfoBuilder.build());
         return tagInfoBuilder.build();
     }
 }