From d86da782fa13652ab4fa7227394d4a3d1fe55e18 Mon Sep 17 00:00:00 2001 From: Michael Mokry Date: Tue, 26 Sep 2017 08:49:34 -0500 Subject: Policy API support for Rainy Day Decision Policy Enhances the Rainy Day Decision Policy by providing API support to manage Rainy Day Decision policies and dictionaries Change-Id: Ia7c49199ac057fa8bcc9de74f5e0b8dba395d43a Issue-ID: POLICY-269 Signed-off-by: Michael Mokry --- .../onap/policy/pdp/rest/api/services/DecisionPolicyService.java | 9 ++++++--- .../onap/policy/pdp/rest/api/services/GetDictionaryService.java | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'ONAP-PDP-REST/src/main') diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java index c283ff14c..915e3b30f 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java @@ -80,6 +80,8 @@ public class DecisionPolicyService{ } Map matchingAttributes = null; Map settingsAttributes = null; + + //Get the MATCHING and/or SETTINGS attributes if (policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)) { matchingAttributes = policyParameters.getAttributes().get(AttributeType.MATCHING); settingsAttributes = policyParameters.getAttributes().get(AttributeType.SETTINGS); @@ -88,9 +90,10 @@ public class DecisionPolicyService{ }else if(policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && !policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)){ matchingAttributes = policyParameters.getAttributes().get(AttributeType.MATCHING); } - // Create Policy. - StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(), onapName, ruleProvider.toString(), matchingAttributes, settingsAttributes, policyParameters.getDynamicRuleAlgorithmLabels(), - policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(), null, null, null, updateFlag, policyScope, 0); + // Create StdPAPPolicy object used to send policy data to PAP-REST. + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(), onapName, ruleProvider.toString(), matchingAttributes, settingsAttributes, + policyParameters.getTreatments(), policyParameters.getDynamicRuleAlgorithmLabels(), policyParameters.getDynamicRuleAlgorithmFunctions(), + policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(), null, null, null, updateFlag, policyScope, 0); // Send JSON to PAP. response = (String) papServices.callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Decision"}, policyParameters.getRequestID(), "Decision"); LOGGER.info(message); diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java index 8f88ef7c7..d3628f3c1 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java @@ -171,6 +171,9 @@ public class GetDictionaryService { case "Settings": jsonString = jsonString.replace("settingsDictionaryDatas", "DictionaryDatas"); break; + case "RainyDayTreatments": + jsonString = jsonString.replace("rainyDayDictionaryDatas", "DictionaryDatas"); + break; case "DescriptiveScope": jsonString = jsonString.replace("descriptiveScopeDictionaryDatas", "DictionaryDatas"); break; -- cgit 1.2.3-korg