From 8520e52a00d52dc5db202268668ed88389b3bc0d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 6 Feb 2018 16:50:56 +0100 Subject: Add Policy Type to PolicyChain. Add Policy Type to PolicyChain as needed by future elements. Issue-ID: CLAMP-85 Change-Id: Id12d71e378319cf93220520cc51ef4cc57e5ff39 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/model/prop/PolicyChain.java | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java index 5264629f2..217f7fd2d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java @@ -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 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 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 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 getPolicyItems() { return policyItems; } + + /** + * @return the policyType + */ + public String getPolicyType() { + return policyType; + } } -- cgit 1.2.3-korg