From e957a1d9a9fa6bd0f9f8348d1e864c09cfe2cb92 Mon Sep 17 00:00:00 2001 From: Michael Mokry Date: Mon, 10 Sep 2018 15:23:15 -0500 Subject: New min/max Guard Policy Made changes to support Guard policy create/update and other policy manager functions including deletePolicy and pushPolicy. Includes changes for new Guard policy support using GUI and API (Rest and Java Client) Made changes to address Jim's comments Made changes to address Liam's comments Change-Id: I133fe1fd9287ea77ea41a2788de90c7642c36b6a Issue-ID: POLICY-1038 Signed-off-by: Mike Mokry --- .../controller/DecisionPolicyController.java | 11 +- .../DecisionPolicyController.js | 17 +-- .../PolicyTemplates/DecisionPolicyTemplate.html | 116 +++++++++++++++++++++ 3 files changed, 136 insertions(+), 8 deletions(-) (limited to 'POLICY-SDK-APP') diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java index 69c3d2fcb..4e8c8c141 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java @@ -69,6 +69,7 @@ public class DecisionPolicyController extends RestrictedBaseController { private static final String DECISIONRAWTYPE = "@#RuleProvider@#Decision_Raw@#RuleProvider@#"; private static final String GUARD_YAML= "GUARD_YAML"; private static final String GUARD_BL_YAML= "GUARD_BL_YAML"; + private static final String GUARD_MIN_MAX= "GUARD_MIN_MAX"; protected PolicyRestAdapter policyAdapter = null; private ArrayList ruleAlgorithmList; @@ -233,6 +234,9 @@ public class DecisionPolicyController extends RestrictedBaseController { } else if (GUARD_BL_YAML.equalsIgnoreCase(((RuleType) object).getAdviceExpressions() .getAdviceExpression().get(0).getAdviceId())) { policyAdapter.setRuleProvider(GUARD_BL_YAML); + } else if (GUARD_MIN_MAX.equalsIgnoreCase(((RuleType) object).getAdviceExpressions() + .getAdviceExpression().get(0).getAdviceId())) { + policyAdapter.setRuleProvider(GUARD_MIN_MAX); } } else { policyAdapter.setRuleProvider("Custom"); @@ -244,7 +248,8 @@ public class DecisionPolicyController extends RestrictedBaseController { ruleAlgoirthmTracker = new LinkedList<>(); if (policyAdapter.getRuleProvider() != null && (GUARD_YAML.equals(policyAdapter.getRuleProvider()) - || (GUARD_BL_YAML.equals(policyAdapter.getRuleProvider())))) { + || (GUARD_BL_YAML.equals(policyAdapter.getRuleProvider())) + || (GUARD_MIN_MAX.equals(policyAdapter.getRuleProvider())))){ YAMLParams yamlParams = new YAMLParams(); for (int i = 0; i < attributeList.size(); i++) { Map map = (Map) attributeList.get(i); @@ -256,6 +261,10 @@ public class DecisionPolicyController extends RestrictedBaseController { yamlParams.setTargets(Arrays.asList(map.get("value").split("\\|"))); } else if ("clname".equals(map.get("key"))) { yamlParams.setClname(map.get("value")); + } else if ("min".equals(map.get("key"))) { + yamlParams.setMin(map.get("value")); + } else if ("max".equals(map.get("key"))) { + yamlParams.setMax(map.get("value")); } } ApplyType apply = diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js index ba9e44868..0e53ce9de 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js @@ -238,10 +238,11 @@ angular.module('abs').controller('decisionPolicyController', [ '$scope', 'Policy $scope.blackListEntries = []; $scope.temp.policy.appendBlackListEntries = []; $scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList)); - } else if ($scope.temp.policy.ruleProvider == "GUARD_YAML") { - if ($scope.temp.policy.yamlparams.targets.length == 0) { - $scope.temp.policy.yamlparams.targets = []; - } + + }else if($scope.temp.policy.ruleProvider=="GUARD_YAML" || $scope.temp.policy.ruleProvider=="GUARD_MIN_MAX"){ + if($scope.temp.policy.yamlparams.targets.length==0){ + $scope.temp.policy.yamlparams.targets = []; + } } else if ($scope.temp.policy.ruleProvider == "Rainy_Day") { if ($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0) { $scope.temp.policy.rainyday.treatmentTableChoices = []; @@ -286,9 +287,9 @@ angular.module('abs').controller('decisionPolicyController', [ '$scope', 'Policy $scope.addNewBL = function() { $scope.temp.policy.yamlparams.blackList.push(''); }; - - $scope.removeBL = function(id) { - $scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function(obj) { + + $scope.removeBL = function(id) { + $scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function (obj){ return obj !== id; }); }; @@ -296,9 +297,11 @@ angular.module('abs').controller('decisionPolicyController', [ '$scope', 'Policy $scope.treatmentDatas = [ { "treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices } ]; + $scope.addNewTreatment = function() { $scope.temp.policy.rainyday.treatmentTableChoices.push({}); }; + $scope.removeTreatment = function() { var lastItem = $scope.temp.policy.rainyday.treatmentTableChoices.length - 1; $scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html index f27d5c619..f482554a2 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html @@ -55,6 +55,7 @@ + @@ -438,6 +439,121 @@ +
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
-- cgit 1.2.3-korg