Add Policy Type to PolicyChain. 91/30491/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 6 Feb 2018 15:50:56 +0000 (16:50 +0100)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 6 Feb 2018 15:50:56 +0000 (16:50 +0100)
Add Policy Type to PolicyChain as needed by future elements.

Issue-ID: CLAMP-85
Change-Id: Id12d71e378319cf93220520cc51ef4cc57e5ff39
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java

index 5264629..217f7fd 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP CLAMP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,21 +63,26 @@ public class PolicyChain {
     private String                    policyId;
     private Integer                   timeout;
     private List<PolicyItem>          policyItems;
+    private String                    policyType;
 
     public PolicyChain(JsonNode node) {
 
         policyId = AbstractModelElement.getValueByName(node, "pid");
         timeout = AbstractModelElement.getIntValueByName(node, "timeout");
-
-        // process policy configurations
-        JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations");
-        Iterator<JsonNode> itr = policyNode.elements();
-        policyItems = new ArrayList<>();
-        while (itr.hasNext()) {
-            policyItems.add(new PolicyItem(itr.next()));
-        }
+        policyType = AbstractModelElement.getValueByName(node, "policyType");
+    
+        if(node != null && node.size() > 0) {                  
+               JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations");
+               if(policyNode != null) {
+                       Iterator<JsonNode> itr = policyNode.elements();
+                       policyItems = new ArrayList<>();
+                       while (itr.hasNext()) {
+                           policyItems.add(new PolicyItem(itr.next()));
+                       }
+           
+                } 
+             }  
     }
-
     /**
      * @return the policyId
      */
@@ -98,5 +103,12 @@ public class PolicyChain {
     public List<PolicyItem> getPolicyItems() {
         return policyItems;
     }
+    
+    /**
+     * @return the policyType
+     */
+    public String getPolicyType() {
+        return policyType;
+    }
 
 }