diff options
author | Michael Mokry <mm117s@att.com> | 2017-09-26 08:49:34 -0500 |
---|---|---|
committer | Michael Mokry <mm117s@att.com> | 2017-09-26 09:40:47 -0500 |
commit | d86da782fa13652ab4fa7227394d4a3d1fe55e18 (patch) | |
tree | 409466e9afd7685fcfa5e7b6810383c2fbb83b95 /ONAP-PAP-REST/src/main/java/org | |
parent | 04c6945fea6a17b89affe2e1a1304e03005136b7 (diff) |
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 <mm117s@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org')
5 files changed, 26 insertions, 5 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java index d870ca86c..22d2da311 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java @@ -230,7 +230,8 @@ public class DecisionPolicy extends Policy { decisionPolicy.setTarget(target); Map<String, String> dynamicFieldDecisionSettings = policyAdapter.getDynamicSettingsMap(); - if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFPROVIDER)){ + if(policyAdapter.getRuleProvider()!=null && (policyAdapter.getRuleProvider().equals(AAFPROVIDER)|| + policyAdapter.getRuleProvider().equals(RAINY_DAY))){ dynamicFieldDecisionSettings = new HashMap<>(); } @@ -242,8 +243,8 @@ public class DecisionPolicy extends Policy { VariableDefinitionType dynamicVariable = createDynamicVariable(key, value, dataType); decisionPolicy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(dynamicVariable); } - Map<String, String> dynamicFieldTreatmentAttributes = policyAdapter.getRainydayMap(); + Map<String, String> dynamicFieldTreatmentAttributes = policyAdapter.getRainydayMap(); if(policyAdapter.getRuleProvider().equals(RAINY_DAY)){ for(String keyField : dynamicFieldTreatmentAttributes.keySet()) { String errorcode = keyField; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java index aac777a67..ab077b9ca 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java @@ -264,7 +264,7 @@ public class DecisionPolicyDictionaryController { @RequestMapping(value={"/get_RainyDayDictionaryData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getRainyDayDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){ + public void getRainyDayDictionaryEntityData(HttpServletResponse response){ try{ Map<String, Object> model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); @@ -329,8 +329,8 @@ public class DecisionPolicyDictionaryController { counter ++; } } + decisionRainyDay.setTreatments(userValue); } - decisionRainyDay.setTreatments(userValue); if(decisionRainyDay.getId() == 0){ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(decisionRainyDay.getBbid()+":"+decisionRainyDay.getWorkstep(), "bbid:workstep", RainyDayTreatments.class); @@ -416,7 +416,7 @@ public class DecisionPolicyDictionaryController { } class TreatmentValues { - private ArrayList<Object> userDataTypeValues; + private ArrayList<Object> userDataTypeValues = new ArrayList<>(); public ArrayList<Object> getUserDataTypeValues() { return userDataTypeValues; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java index 13eee4a3f..ae749adb5 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java @@ -69,6 +69,9 @@ public class DictionaryHandlerImpl implements DictionaryHandler{ case "Settings": dictionary.getSettingsDictionary(response); break; + case "RainyDayTreatments": + dictionary.getRainyDayDictionary(response); + break; case "DescriptiveScope": dictionary.getDescriptiveDictionary(response); break; @@ -212,6 +215,9 @@ public class DictionaryHandlerImpl implements DictionaryHandler{ case "Settings": result = dictionary.saveSettingsDictionary(request, response); break; + case "RainyDayTreatments": + result = dictionary.saveRainyDayDictionary(request, response); + break; case "DescriptiveScope": result = dictionary.saveDescriptiveDictionary(request, response); break; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java index c86ded43f..e7680c3e2 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java @@ -131,6 +131,8 @@ public class SavePolicyHandler { policyAdapter.setRuleProvider(policy.getProviderComboBox()); policyAdapter.setDomainDir(policyAdapter.getPolicyScope()); policyAdapter.setDomain(policyAdapter.getPolicyScope()); + policyAdapter.setRainydayMap(policy.getTreatments()); + return policyAdapter; } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java index 5b2fc4cd7..6e19b9b1c 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java @@ -121,6 +121,13 @@ public class DictionaryService { return result.getViewName(); } + public String saveRainyDayDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); + ModelAndView result = dictionary.saveRainyDayDictionary(request, response); + return result.getViewName(); + } + public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController(); @@ -343,6 +350,11 @@ public class DictionaryService { dictionary.getSettingsDictionaryEntityData(response); } + public void getRainyDayDictionary(HttpServletResponse response){ + DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); + dictionary.getRainyDayDictionaryEntityData(response); + } + public void getDescriptiveDictionary(HttpServletResponse response){ DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController(); dictionary.getDescriptiveDictionaryEntityData(response); |