diff options
author | Jorge Hernandez <jh1730@att.com> | 2017-09-28 03:40:01 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-28 03:40:01 +0000 |
commit | b6dee4c18a7384e765a36a8dbbaef301da232847 (patch) | |
tree | 75f3981be56fe1d4420cde6e564b71916cbc01b3 /ONAP-PAP-REST | |
parent | b5caf28492a151d811dd3ce7e6ade26e56deade9 (diff) | |
parent | d86da782fa13652ab4fa7227394d4a3d1fe55e18 (diff) |
Merge "Policy API support for Rainy Day Decision Policy"
Diffstat (limited to 'ONAP-PAP-REST')
7 files changed, 30 insertions, 9 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); diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java index 0463585cb..ba5539f4b 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java @@ -206,7 +206,7 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create"); Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Decision"); StdPAPPolicy newPAPPolicy = new StdPAPPolicy("test", "test rule", "ONAP", "AAF", null, null, null, - null, null, null, null, null, null, false, "test", 0); + null, null, null, null, null, null, null, false, "test", 0); MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); @@ -238,7 +238,7 @@ public class XACMLPAPTest { matchingAttributes.put("guardActiveStart","05:00"); matchingAttributes.put("guardActiveEnd","10:00"); StdPAPPolicy newPAPPolicy = new StdPAPPolicy("testGuard", "test rule", "PDPD", "GUARD_YAML", matchingAttributes , null, null, - null, null, null, null, null, null, false, "test", 0); + null, null, null, null, null, null, null, false, "test", 0); MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); @@ -267,7 +267,7 @@ public class XACMLPAPTest { matchingAttributes.put("guardActiveEnd","10:00"); matchingAttributes.put("blackList","bl1,bl2"); StdPAPPolicy newPAPPolicy = new StdPAPPolicy("testblGuard", "test rule", "PDPD", "GUARD_BL_YAML", matchingAttributes , null, null, - null, null, null, null, null, null, false, "test", 0); + null, null, null, null, null, null, null, false, "test", 0); MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java index 529047181..a2c67ea81 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java @@ -198,7 +198,7 @@ public class DecisionPolicyDictionaryControllerTest { MockHttpServletResponse response = new MockHttpServletResponse(); - controller.getRainyDayDictionaryEntityData(request, response); + controller.getRainyDayDictionaryEntityData(response); try { assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("rainyDayDictionaryDatas")); |