aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController')
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js173
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js245
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js152
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js154
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js783
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js163
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js929
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js209
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js87
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js227
10 files changed, 3122 insertions, 0 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
new file mode 100644
index 000000000..fde8d4e9e
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('actionPolicyController', function ($scope, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ PolicyAppService.getData('getDictionary/get_ActionPolicyDictDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.actionPolicyDictionaryDatas = JSON.parse($scope.data.actionPolicyDictionaryDatas);
+ console.log($scope.actionPolicyDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_AttributeDatabyAttributeName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
+ console.log($scope.attributeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('get_FunctionDefinitionDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.functionDefinitionDatas = JSON.parse($scope.data.functionDefinitionDatas);
+ console.log($scope.functionDefinitionDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ $scope.saveActionPolicy = function(policy){
+ console.log(policy);
+ $scope.savebutton = false;
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data;
+ if($scope.data == '"success"'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ $scope.temp.policy.ruleAlgorithmschoices = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ if($scope.temp.policy.ruleAlgorithmschoices.length == 0){
+ $scope.temp.policy.ruleAlgorithmschoices = [];
+ }
+ }
+
+ $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes .length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+
+
+ $scope.ItemNo = 0;
+ $scope.ruleAlgorithmDatas = [{"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices}];
+
+ $scope.addNewRuleAlgorithm = function(){
+ var newItemNo = $scope.temp.policy.ruleAlgorithmschoices.length+1;
+ $scope.ItemNo = newItemNo;
+ if(newItemNo > 1){
+ var value = newItemNo-1;
+ $scope.attributeDictionaryDatas.push('A'+value);
+ }
+ $scope.temp.policy.ruleAlgorithmschoices.push({'id':'A'+newItemNo});
+
+ };
+
+ $scope.removeRuleAlgorithm = function() {
+ var lastItem = $scope.temp.policy.ruleAlgorithmschoices.length-1;
+ $scope.ItemNo = lastItem;
+ $scope.temp.policy.ruleAlgorithmschoices.splice(lastItem);
+ };
+
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
new file mode 100644
index 000000000..c5160e741
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
@@ -0,0 +1,245 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('brmsParamPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ $scope.validateSuccess = true;
+ var readValue = $scope.temp.policy.readOnly;
+ if(readValue){
+ $scope.validateSuccess = false;
+ }
+
+ PolicyAppService.getData('getDictionary/get_BRMSControllerDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.brmsControllerDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
+ console.log($scope.brmsControllerDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_BRMSDependencyDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.brmsDependencyDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
+ console.log($scope.brmsDependencyDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_BRMSParamDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.brmsParamDictionaryDatas = JSON.parse($scope.data.brmsParamDictionaryDatas);
+ console.log($scope.brmsParamDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ $scope.temp.policy.dynamicLayoutMap = {};
+ $scope.addDataToFields = function(ruleName){
+ console.log(ruleName);
+ if(ruleName != null){
+ var uuu = "policyController/getBRMSTemplateData.htm";
+ var postData={policyData: ruleName};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.temp.policy.dynamicLayoutMap = data.policyData;
+ });
+ console.log( $scope.temp.policy.dynamicLayoutMap);
+ },
+ error : function(data){
+ alert("Error While Retriving the Template Layout Pattren.");
+ }
+ });
+ }
+ };
+
+ $scope.ShowRule = function(policy){
+ console.log(policy);
+ var uuu = "policyController/ViewBRMSParamPolicyRule.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.datarule = data.policyData;
+ var modalInstance = $modal.open({
+ backdrop: 'static', keyboard: false,
+ templateUrl : 'brmsshowrule',
+ controller: 'showrulecontroller',
+ resolve: {
+ message: function () {
+ var message = {
+ datas: $scope.datarule
+ };
+ return message;
+ }
+ }
+ });
+ });
+ },
+ error : function(data){
+ Notification.error("Error Occured while Showing Rule.");
+ }
+ });
+ };
+
+ $scope.saveBrmsParamPolicy = function(policy){
+ console.log(policy);
+ $scope.savebutton = false;
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ $scope.safetyChecker = data.policyData.split("#")[2];
+ if ($scope.safetyChecker!=undefined) {
+ Notification.success($scope.safetyChecker);
+ }
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ $scope.validateSuccess = false;
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ }
+
+ $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes.length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+});
+
+app.controller('showrulecontroller' , function ($scope, $modalInstance, message){
+ if(message.datas!=null){
+ $scope.datarule=message.datas;
+ }
+
+ $scope.close = function() {
+ $modalInstance.close();
+ };
+
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
new file mode 100644
index 000000000..5b78193ee
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('brmsRawPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ PolicyAppService.getData('getDictionary/get_BRMSControllerDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.brmsControllerDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
+ console.log($scope.brmsControllerDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_BRMSDependencyDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.brmsDependencyDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
+ console.log($scope.brmsDependencyDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ $scope.saveBrmsRawPolicy = function(policy){
+ console.log(policy);
+ $scope.savebutton = false;
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ }
+ $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes.length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
new file mode 100644
index 000000000..9f2863579
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+app.controller('baseConfigController', function ($scope, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+
+ PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
+ console.log($scope.ecompNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_AttributeDatabyAttributeName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
+ console.log($scope.attributeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ $scope.savePolicy = function(policy){
+ $scope.savebutton = false;
+ console.log(policy);
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+ });
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ }
+
+
+ $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes .length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
new file mode 100644
index 000000000..a8dcd7b0a
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
@@ -0,0 +1,783 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module("abs").controller('clFaultController', function($scope, $window, PolicyAppService, modalService, $modal, Notification){
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ if($scope.temp.policy.triggerTrapSignatures == undefined){
+ $scope.temp.policy.triggerTrapSignatures = [];
+ $scope.temp.policy.triggerfaultSignatures = [];
+ }
+ var trapCollection = [];
+ var faultCollection = [];
+ if($scope.varbindDictionaryDatas == undefined){
+ $scope.varbindDictionaryDatas = [];
+ }
+
+ $scope.init = function(data){
+ if(data != undefined && $scope.temp.policy.triggerTrapSignatures.length == 0){
+ $scope.jsonData = data;
+ if($scope.jsonData.triggerSignaturesUsedForUI != null){
+ if($scope.jsonData.triggerSignaturesUsedForUI.signatures != null){
+ $scope.temp.policy.triggerTrapSignatures = {Trap1 : [], Trap2 : [], Trap3 : [], Trap4 : [], Trap5 : [], Trap6 : []};
+ var splitTraps = $scope.jsonData.triggerSignaturesUsedForUI.signatures.split("#!?!");
+ if(splitTraps.length > 1){
+ $scope.triggerdisabled = false;
+ var indexId = "Trap1";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+1});
+ var splitTrap1 = splitTraps[0];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 2){
+ var indexId = "Trap2";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+2});
+ var splitTrap1 = splitTraps[1];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 3){
+ var indexId = "Trap3";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+3});
+ var splitTrap1 = splitTraps[2];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 4){
+ var indexId = "Trap4";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+4});
+ var splitTrap1 = splitTraps[3];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 5){
+ var indexId = "Trap5";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+5});
+ var splitTrap1 = splitTraps[4];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 6){
+ var indexId = "Trap6";
+ trapCollection.push(indexId);
+ $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+6});
+ var splitTrap1 = splitTraps[5];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerTrapSignatures["Trap6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if($scope.jsonData.triggerSignaturesUsedForUI.connectSignatures != null){
+ var splitConnectTraps = $scope.jsonData.triggerSignaturesUsedForUI.connectSignatures.split("#!?!");
+ for(i=0; i < splitConnectTraps.length; i++){
+ if(splitConnectTraps[i] != ""){
+ var newConnectTrapItemNo = i+1;
+ var connects = splitConnectTraps[i].split("@!");
+ if(connects[0] == 'NOT' || connects[0] ==''){
+ var notBox = connects[0];
+ var connectTrap1 = connects[1];
+ var trapCount1 = connects[2];
+ var operatorBox = connects[3];
+ var connectTrap2 = connects[4];
+ var trapCount2 = connects[5];
+ }else{
+ var notBox = '';
+ var connectTrap1 = connects[0];
+ var trapCount1 = connects[1];
+ var operatorBox = connects[2];
+ var connectTrap2 = connects[3];
+ var trapCount2 = connects[4];
+ }
+ $scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1,
+ 'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2});
+ }
+ }
+ }
+ }
+ }
+ if($scope.jsonData.verificationSignaturesUsedForUI != null){
+ if($scope.jsonData.verificationSignaturesUsedForUI.signatures != null){
+ $scope.temp.policy.triggerfaultSignatures = {Fault1 : [], Fault2 : [], Fault3 : [], Fault4 : [], Fault5 : [], Fault6 : [],};
+ var splitTraps = $scope.jsonData.verificationSignaturesUsedForUI.signatures.split("#!?!");
+ if(splitTraps.length > 1){
+ $scope.verificationdisabled = false;
+ var indexId = "Fault1";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+1});
+ var splitTrap1 = splitTraps[0];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 2){
+ var indexId = "Fault2";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+2});
+ var splitTrap1 = splitTraps[1];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 3){
+ var indexId = "Fault3";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+3});
+ var splitTrap1 = splitTraps[2];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 4){
+ var indexId = "Fault4";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+4});
+ var splitTrap1 = splitTraps[3];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 5){
+ var indexId = "Fault5";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+5});
+ var splitTrap1 = splitTraps[4];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+ if(splitTraps.length > 6){
+ var indexId = "Fault6";
+ faultCollection.push(indexId);
+ $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+6});
+ var splitTrap1 = splitTraps[5];
+ var splitEachTrap = splitTrap1.split("#!");
+ for(i = 0 ; i < splitEachTrap.length; i++){
+ var splitEachRow = splitEachTrap[i].split("@!");
+ var count = i +1;
+ if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+ var notBox = splitEachRow[0];
+ var trigger1 = splitEachRow[1];
+ var operatorBox = splitEachRow[2];
+ var trigger2 = splitEachRow[3];
+ }else{
+ var notBox = '';
+ var trigger1 = splitEachRow[0];
+ var operatorBox = splitEachRow[1];
+ var trigger2 = splitEachRow[2];
+ }
+ $scope.varbindDictionaryDatas.push('A'+count);
+ $scope.temp.policy.triggerfaultSignatures["Fault6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});
+ }
+ }
+
+ if($scope.jsonData.verificationSignaturesUsedForUI.connectSignatures != null){
+ var splitConnectTraps = $scope.jsonData.verificationSignaturesUsedForUI.connectSignatures.split("#!?!");
+ for(i=0; i < splitConnectTraps.length; i++){
+ if(splitConnectTraps[i] != ""){
+ var newConnectTrapItemNo = i+1;
+ var connects = splitConnectTraps[i].split("@!");
+ if(connects[0] == 'NOT' || connects[0] ==''){
+ var notBox = connects[0];
+ var connectTrap1 = connects[1];
+ var trapCount1 = connects[2];
+ var operatorBox = connects[3];
+ var connectTrap2 = connects[4];
+ var trapCount2 = connects[5];
+ }else{
+ var notBox = '';
+ var connectTrap1 = connects[0];
+ var trapCount1 = connects[1];
+ var operatorBox = connects[2];
+ var connectTrap2 = connects[3];
+ var trapCount2 = connects[4];
+ }
+ $scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1,
+ 'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2});
+ }
+ }
+ }
+ }
+ }
+ }
+
+ };
+
+ if($scope.temp.policy.readOnly){
+ $scope.triggerdisabled = true;
+ $scope.verificationdisabled = true;
+ }else{
+ $scope.triggerdisabled = false;
+ $scope.verificationdisabled = false;
+ }
+
+
+ PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
+ console.log($scope.ecompNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_PEPOptionsDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.pepOptionsDictionaryDatas = JSON.parse($scope.data.pepOptionsDictionaryDatas);
+ console.log($scope.pepOptionsDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_PEPOptionsData').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.pepOptionsDictionaryDataEntity = JSON.parse($scope.data.pepOptionsDictionaryDatas);
+ console.log($scope.pepOptionsDictionaryDataEntity);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_VarbindDictionaryDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.varbindDictionaryDatas = JSON.parse($scope.data.varbindDictionaryDatas);
+ console.log($scope.varbindDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_VNFTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);
+ console.log($scope.vnfTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_VSCLActionDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
+ console.log($scope.vsclActionDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ $scope.pepActionDictionaryDatas = [];
+
+ $scope.getPepActionValues = function(pepOptionValue){
+ for (var i = 0; i < $scope.pepOptionsDictionaryDataEntity.length; ++i) {
+ var obj = $scope.pepOptionsDictionaryDataEntity[i];
+ if (obj.pepName == pepOptionValue){
+ var splitAlarm = obj.actions.split(':#@');
+ for (var j = 0; j < splitAlarm.length; ++j) {
+ $scope.pepActionDictionaryDatas.push(splitAlarm[j].split('=#@')[0]);
+ }
+ }
+ }
+ };
+
+ $scope.saveFaultPolicy = function(policy){
+ console.log(policy);
+ $scope.savebutton = false;
+ var data = {};
+ var faultData = {};
+ if($scope.temp.policy.triggerTrapSignatures.length == 1 || $scope.temp.policy.triggerTrapSignatures["Trap1"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1 }
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 2 || $scope.temp.policy.triggerTrapSignatures["Trap2"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1, trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2}
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 3 || $scope.temp.policy.triggerTrapSignatures["Trap3"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1, trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+ trap2 : $scope.temp.policy.triggerTrapSignatures.Trap3}
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerTrapSignatures["Trap4"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1, trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+ trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3, trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4}
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 5 || $scope.temp.policy.triggerTrapSignatures["Trap5"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1, trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+ trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3, trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
+ trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5}
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 6 || $scope.temp.policy.triggerTrapSignatures["Trap6"] != null){
+ var data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1, trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+ trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3, trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
+ trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5, trap6 : $scope.temp.policy.triggerTrapSignatures.Trap6}
+ }
+
+ if($scope.temp.policy.triggerfaultSignatures.length == 1 || $scope.temp.policy.triggerfaultSignatures["Fault1"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1 }
+ }
+ if($scope.temp.policy.triggerfaultSignatures.length == 2 || $scope.temp.policy.triggerfaultSignatures["Fault2"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1, trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2}
+ }
+ if($scope.temp.policy.triggerfaultSignatures.length == 3 || $scope.temp.policy.triggerfaultSignatures["Fault3"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1, trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+ trap2 : $scope.temp.policy.triggerfaultSignatures.Fault3}
+ }
+ if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerfaultSignatures["Fault4"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1, trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+ trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3, trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4}
+ }
+ if($scope.temp.policy.triggerfaultSignatures.length == 5 || $scope.temp.policy.triggerfaultSignatures["Fault5"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1, trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+ trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3, trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
+ trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5}
+ }
+ if($scope.temp.policy.triggerfaultSignatures.length == 6 || $scope.temp.policy.triggerfaultSignatures["Fault6"] != null){
+ var faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1, trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+ trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3, trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
+ trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5, trap6 : $scope.temp.policy.triggerfaultSignatures.Fault6}
+ }
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy,
+ trapData : data,
+ faultData : faultData
+ };
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ $scope.pushStatus=data.policyData.split("&")[1];
+ if($scope.pushStatus=="successPush"){
+ Notification.success("Policy pushed successfully");
+ }
+ $scope.triggerdisabled = true;
+ $scope.verificationdisabled = true;
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+ if($scope.connectTriggerTrapsList == undefined){
+ $scope.connectTriggerTrapsList = [];
+ }
+ if($scope.temp.policy.traptriggerSignatures == undefined){
+ $scope.temp.policy.traptriggerSignatures = [];
+ }
+
+ $scope.ItemNo = 0;
+ $scope.TriggerSignatureDatas = [{"triggerSignatures" : $scope.temp.policy.traptriggerSignatures}];
+ $scope.addTriggerButton = function() {
+ $scope.triggerdisabled = false;
+ var newItemNo = $scope.temp.policy.traptriggerSignatures.length+1;
+ $scope.ItemNo = newItemNo;
+ $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+newItemNo});
+ $scope.connectTriggerTrapsList.push('Trap'+newItemNo);
+ };
+ $scope.removeTriggerButton = function() {
+ var lastItem = $scope.temp.policy.traptriggerSignatures.length-1;
+ $scope.temp.policy.traptriggerSignatures.splice(lastItem);
+ $scope.connectTriggerTrapsList.splice('Trap'+lastItem);
+ };
+
+
+ $scope.trapItemNo = 0;
+ $scope.TrapTriggerSignatureDatas = [{"triggermainSignatures" : $scope.temp.policy.triggerTrapSignatures}];
+ $scope.addTrapTriggerButton = function(indexId) {
+ if(trapCollection.indexOf(indexId) !== -1){
+
+ }else{
+ $scope.temp.policy.triggerTrapSignatures[indexId] = [];
+ trapCollection.push(indexId);
+ }
+ var newTrapItemNo = $scope.temp.policy.triggerTrapSignatures[indexId].length+1;
+ $scope.trapItemNo = newTrapItemNo;
+ $scope.temp.policy.triggerTrapSignatures.push($scope.temp.policy.triggerTrapSignatures[indexId].push({'id':'A'+newTrapItemNo}));
+ if(newTrapItemNo > 1){
+ var count = newTrapItemNo-1;
+ $scope.varbindDictionaryDatas.push('A'+count);
+ }
+ };
+ $scope.removeTrapTriggerButton = function(indexId) {
+ var lastTrapItem = $scope.temp.policy.triggerTrapSignatures[indexId].length-1;
+ var checkLastTrapItem = lastTrapItem;
+ if(checkLastTrapItem == 0){
+ trapCollection.splice(indexId);
+ }
+ $scope.temp.policy.triggerTrapSignatures[indexId].splice(lastTrapItem);
+ };
+
+ if($scope.temp.policy.connecttriggerSignatures == undefined){
+ $scope.temp.policy.connecttriggerSignatures = [];
+ }
+
+ $scope.connecttrapItemNo = 0;
+ $scope.TrapConnectTriggerSignatureDatas = [{"connecttriggerSignatures" : $scope.temp.policy.connecttriggerSignatures}];
+ $scope.addTriggerConnectButton = function() {
+ var newConnectTrapItemNo = $scope.temp.policy.connecttriggerSignatures.length+1;
+ $scope.connecttrapItemNo = newConnectTrapItemNo;
+ $scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo});
+ if(newConnectTrapItemNo >1){
+ var count = newConnectTrapItemNo-1;
+ $scope.connectTriggerTrapsList.push('C'+count);
+ }
+ };
+ $scope.removeTriggerConnectButton = function() {
+ var lastConnectTrapItem = $scope.temp.policy.connecttriggerSignatures.length-1;
+ $scope.temp.policy.connecttriggerSignatures.splice(lastConnectTrapItem);
+ if(lastConnectTrapItem < 1){
+ var count = lastConnectTrapItem-1;
+ $scope.connectTriggerTrapsList.splice('C'+count);
+ }
+ };
+ if($scope.connectTriggerFaultsList == undefined){
+ $scope.connectTriggerFaultsList = [];
+ }
+ if($scope.temp.policy.faulttriggerSignatures == undefined){
+ $scope.temp.policy.faulttriggerSignatures = [];
+ }
+
+ $scope.FaultItemNo = 0;
+ $scope.FaultSignatureDatas = [{"verificationmainSignatures" : $scope.temp.policy.faulttriggerSignatures}];
+ $scope.addVerFaultButton = function() {
+ var newFaultItemNo = $scope.temp.policy.faulttriggerSignatures.length+1;
+ $scope.FaultItemNo = newFaultItemNo;
+ $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+newFaultItemNo});
+ $scope.connectTriggerFaultsList.push('Fault'+newFaultItemNo);
+ };
+ $scope.removeVerFaultButton = function() {
+ var lastFaultItem = $scope.temp.policy.faulttriggerSignatures.length-1;
+ $scope.temp.policy.faulttriggerSignatures.splice(lastFaultItem);
+ $scope.connectTriggerFaultsList.splice('Fault'+lastFaultItem);
+ };
+ if($scope.temp.policy.triggerfaultSignatures == undefined){
+ $scope.temp.policy.triggerfaultSignatures = [];
+ }
+
+ $scope.faultItemNo1 = 0;
+ $scope.FaultTriggerSignatureDatas = [{"verificationSignatures" : $scope.temp.policy.triggerfaultSignatures}];
+ $scope.addVerTriggerButton = function(indexId) {
+ $scope.verificationdisabled = false;
+ if(faultCollection.indexOf(indexId) !== -1){
+
+ }else{
+ $scope.temp.policy.triggerfaultSignatures[indexId] = [];
+ faultCollection.push(indexId);
+ }
+ var newFaultItemNo1 = $scope.temp.policy.triggerfaultSignatures[indexId].length+1;
+ $scope.faultItemNo1 = newFaultItemNo1;
+ $scope.temp.policy.triggerfaultSignatures.push($scope.temp.policy.triggerfaultSignatures[indexId].push({'id':'A'+newFaultItemNo1}));
+ if(newFaultItemNo1 > 1){
+ var count = newFaultItemNo1-1;
+ $scope.varbindDictionaryDatas.push('A'+count);
+ }
+ };
+ $scope.removeVerTriggerButton = function(indexId) {
+ var lastFaultItem1 = $scope.temp.policy.triggerfaultSignatures[indexId].length-1;
+ var checkLastFaultItem = lastFaultItem1;
+ if(checkLastFaultItem == 0){
+ faultCollection.splice(indexId);
+ }
+ $scope.temp.policy.triggerfaultSignatures[indexId].splice(lastFaultItem1);
+ };
+
+ if($scope.temp.policy.connectVerificationSignatures == undefined){
+ $scope.temp.policy.connectVerificationSignatures = [];
+ }
+
+ $scope.connectFaultItemNo = 0;
+ $scope.FaultConnectTriggerSignatureDatas = [{"connectVerificationSignatures" : $scope.temp.policy.connectVerificationSignatures}];
+ $scope.addFaultConnectButton = function() {
+ var newConnectFaultItemNo = $scope.temp.policy.connectVerificationSignatures.length+1;
+ $scope.connectFaultItemNo = newConnectFaultItemNo;
+ $scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectFaultItemNo});
+ if(newConnectFaultItemNo >1){
+ var count = newConnectFaultItemNo-1;
+ $scope.connectTriggerFaultsList.push('C'+count);
+ }
+ };
+ $scope.removeFaultConnectButton = function() {
+ var lastConnectFaultItem = $scope.temp.policy.connectVerificationSignatures.length-1;
+ $scope.temp.policy.connectVerificationSignatures.splice(lastConnectFaultItem);
+ if(lastConnectFaultItem < 1){
+ var count = lastConnectFaultItem-1;
+ $scope.connectTriggerFaultsList.splice('C'+count);
+ }
+ };
+
+
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
new file mode 100644
index 000000000..2f709a716
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module("abs").controller('clPMController', function($scope, $window, $timeout, PolicyAppService, modalService, $modal, Notification){
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
+ console.log($scope.ecompNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+
+ PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
+ var j = data;
+ $scope.PMData = j;
+ });
+
+ if($scope.temp.policy.readOnly && $scope.temp.policy.editPolicy){
+ $scope.temp.policy.verticaMetrics = [];
+ $scope.temp.policy.description = [];
+ $scope.temp.policy.attributes = [];
+ }
+
+ $scope.addDataToFields = function(serviceType){
+ if($scope.PMData == undefined){
+ $scope.temp.policy.verticaMetrics = [];
+ $scope.temp.policy.description = [];
+ $scope.temp.policy.attributes = [];
+ PolicyAppService.getData('app/policyApp/JSONDataFiles/JSONConfig.json').then(function(data){
+ var j = data;
+ $scope.PMData = j;
+ if(serviceType.serviceTypePolicyName == 'Registration Failure(Trinity)'){
+ var myNewData = $scope.PMData[0];
+ }else if(serviceType.serviceTypePolicyName == 'International Fraud(Trinity)'){
+ var myNewData = $scope.PMData[1];
+ }else if(serviceType.serviceTypePolicyName == 'No dial tone(Trinity)'){
+ var myNewData = $scope.PMData[2];
+ }else if(serviceType.serviceTypePolicyName == 'Call storm(Trinity)'){
+ var myNewData = $scope.PMData[3];
+ }else if(serviceType.serviceTypePolicyName == 'Registration storm(Trinity)'){
+ var myNewData = $scope.PMData[4];
+ }
+
+ $scope.temp.policy.verticaMetrics = myNewData;
+ $scope.temp.policy.description = myNewData;
+ $scope.temp.policy.attributeFields = myNewData;
+ });
+ }else{
+ $scope.temp.policy.verticaMetrics = serviceType;
+ $scope.temp.policy.description = serviceType;
+ $scope.temp.policy.attributeFields = serviceType;
+ }
+
+ };
+
+ $scope.saveCLPMPolicy = function(policy){
+ console.log(policy);
+ $scope.savebutton = false;
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+}) \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
new file mode 100644
index 000000000..d0f44d46e
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
@@ -0,0 +1,929 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $window, $compile, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+ $scope.isCheck = false;
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+// $scope.temp.policy.ttlDate = "2016-12-31";
+ if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly != undefined){
+ if ($scope.temp.policy.configName == undefined){
+ $scope.isCheck = false;
+ }else{
+ $scope.isCheck = true;
+ }
+ }else {
+ $scope.isCheck = false;
+ }
+
+ PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
+ console.log($scope.ecompNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
+ console.log($scope.priorityDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_GroupPolicyScopeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.groupPolicyScopeListDatas = JSON.parse($scope.data.groupPolicyScopeListDatas);
+ console.log($scope.groupPolicyScopeListDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_MicroServiceConfigNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.microServiceCongigNameDictionaryDatas = JSON.parse($scope.data.microServiceCongigNameDictionaryDatas);
+ console.log($scope.microServiceCongigNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_MicroServiceLocationDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.microServiceLocationDictionaryDatas = JSON.parse($scope.data.microServiceLocationDictionaryDatas);
+ console.log($scope.microServiceLocationDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ var inputModelList = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
+ var unique = {};
+ var uniqueList = [];
+ for(var i = 0; i < inputModelList.length; i++){
+ if(typeof unique[inputModelList[i]] == "undefined"){
+ unique[inputModelList[i]] = "";
+ uniqueList.push(inputModelList[i]);
+ }
+ }
+ $scope.microServiceModelsDictionaryDatas = uniqueList;
+ console.log($scope.microServiceModelsDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_DCAEUUIDDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.dcaeUUIDDictionaryDatas = JSON.parse($scope.data.dcaeUUIDDictionaryDatas);
+ console.log($scope.dcaeUUIDDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_MicroServiceAttributeData').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.microServiceAttributeDictionaryDatas = JSON.parse($scope.data.microServiceAttributeDictionaryDatas);
+ console.log($scope.microServiceAttributeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+
+ $scope.choices = [];
+ $scope.attributeDatas = [{"attributes" : $scope.choices}];
+
+ $scope.addNewChoice = function(value) {
+ console.log(value);
+ if(value != undefined){
+ if (value.startsWith('div.')){
+ value = value.replace('div.','');
+ }
+ var parentElement = document.getElementById("div."+value);
+ var div = document.getElementById(value+"@0");
+ if(div != null){
+ var clone = div.cloneNode(true);
+ var addElement = parentElement.childElementCount + 1;
+ clone.id = ''+value+'@'+addElement;
+ clone.value = '';
+ document.getElementById("div."+value).appendChild(clone);
+ plainAttributeKeys.push(''+value+'@'+addElement);
+ }else{
+ div = document.getElementById("div."+value+"@0");
+ var childElement = parentElement.firstElementChild;
+ var countParent = parentElement.childElementCount;
+ var childElementString = childElement.innerHTML;
+ var find = value+"@0";
+ var re = new RegExp(find, 'g');
+ childElementString = childElementString.replace(re,value+'@' + countParent);
+ var clone = childElement.cloneNode(true);
+ for (var ii = 0; ii < parentElement.childNodes.length; ii++){
+ var childId = parentElement.childNodes[ii].id;
+ if(ii = parentElement.childNodes.length){
+ var childnewId = childId.slice(0, -1);
+ var count = childId.slice(-1);
+ }
+ }
+ var countvalue = parseInt(count) + 1;
+ clone.id = childnewId+countvalue;
+ clone.value = '';
+ clone.innerHTML=childElementString;
+ document.getElementById("div."+value).appendChild(clone);
+ var selects = clone.getElementsByTagName("select");
+ var inputs = clone.getElementsByTagName("input");
+ var removeValues = [];
+ for(var i=0; i<inputs.length; i++){
+ if ($scope.temp.policy.ruleData!=undefined){
+ var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
+ if (checkValue!=undefined){
+ if($scope.temp.policy.ruleData != null){
+ var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
+ document.getElementById(inputs[i].id).value = $scope.temp.policy.ruleData[inputs[i].id];
+ plainAttributeKeys.push(inputs[i].id);
+ }
+ } else {
+// removeValues.push(inputs[i].id);
+ plainAttributeKeys.push(inputs[i].id);
+ }
+ }else {
+ plainAttributeKeys.push(inputs[i].id);
+ }
+ }
+
+ for(var i=0; i<selects.length; i++){
+ if ($scope.temp.policy.ruleData!=undefined){
+ var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+ if (checkValue!=undefined){
+ if($scope.temp.policy.ruleData != null){
+ var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+ document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
+ plainAttributeKeys.push(selects[i].id);
+ }
+ } else {
+ plainAttributeKeys.push(selects[i].id);
+ }
+ }else {
+ plainAttributeKeys.push(selects[i].id);
+ }
+ }
+
+ for (var k=0; k<removeValues.length; k++){
+ var elem = document.getElementById(removeValues[k]);
+ elem.parentNode.removeChild(elem);
+ }
+ var ele = angular.element(document.getElementById("div."+value));
+ $compile(ele.contents())($scope);
+ $scope.$apply();
+ }
+ }
+ };
+
+ $scope.removeChoice = function(value) {
+ console.log(value);
+ if(value != undefined){
+ document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild);
+ }
+ };
+
+ $scope.pullVersion = function(serviceName) {
+ console.log(serviceName);
+ if(serviceName != undefined){
+ var uuu = "policyController/getModelServiceVersioneData.htm";
+ var postData={policyData: serviceName};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.microServiceModelsDictionaryVersionDatas = data[0].dcaeModelVersionData;
+ });
+ },
+ error : function(data){
+ alert("Error While Retriving the Template Layout Pattren.");
+ }
+ });
+ }
+ };
+
+ var splitDash = '-';
+ var splitEqual = '=';
+ var splitComma = ',';
+ var splitcolon = ':';
+ var splitsemicolon = ";";
+ var splitEnum = "],";
+ var plainAttributeKeys = [];
+ var matching = [];
+ var enumKeyList = [];
+ var dictionaryList = [];
+ var dictionaryNameList = [];
+ $scope.addDataToFields = function(serviceName, version){
+ if(serviceName != null && version !=null){
+ var service=serviceName+"-v"+version;
+ var myNode = document.getElementById("DynamicTemplate");
+ myNode.innerHTML = '';
+ var uuu = "policyController/getDCAEMSTemplateData.htm";
+ var postData={policyData: service};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.addNewChoice();
+ var plainAttributeKeys = [];
+ $scope.dcaeModelData = data[0].dcaeModelData;
+ $scope.dcaeJsonDate = data[0].jsonValue;
+ var attributes = $scope.dcaeModelData.attributes;
+ var refAttributes = $scope.dcaeModelData.ref_attributes;
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+ var enumAttributes = $scope.dcaeModelData.enumValues;
+ var annotation = $scope.dcaeModelData.annotation;
+ var dictionary = $scope.microServiceAttributeDictionaryDatas;
+
+ if (annotation == null || annotation.length<1){
+ $scope.isCheck = true;
+ }else {
+ $scope.isCheck = false;
+ var annoationList = annotation.split(splitComma);
+ for (k = 0; k < annoationList.length; k++){
+ var splitAnnotation = annoationList[k].split(splitEqual);
+ if (splitAnnotation[1].includes("matching-true")){
+ matching.push(splitAnnotation[0].trim());
+ }
+ }
+
+ }
+
+ if (dictionary!= null || dictionary>1){
+ if (dictionary!= null || dictionary.length>1){
+ for (m=0; m < dictionary.length; m += 1){
+ var keyCompare = dictionary[m].name;
+ var valueCompare = dictionary[m].value;
+ var valueModel = dictionary[m].modelName;
+ var conpairService = serviceName;
+ if (valueModel.includes('-v')){
+ conpairService = service;
+ }
+ if(valueModel.localeCompare(conpairService) == 0){
+ console.log(valueCompare);
+ dictionaryList.push(dictionary[m]);
+ if (!dictionaryNameList.includes(dictionary[m].name)){
+ dictionaryNameList.push(dictionary[m].name)
+ }
+ }
+ }
+ }
+ }
+
+ $scope.temp.policy.ruleGridData = [];
+
+ $scope.jsonLayout($scope.dcaeJsonDate);
+
+ });
+ if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){
+ var checkData = [];
+ var data = [];
+ if($scope.temp.policy.ruleData != null){
+ var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
+ propNames.forEach(function(name) {
+ data.push(name);
+ });
+ for(a = 0; a < data.length; a++){
+ var splitPlainAttributeKey1 = data[a].split(".");
+ if(splitPlainAttributeKey1[0].indexOf("@") != -1){
+ var key = splitPlainAttributeKey1[0];
+ checkData.push(key);
+ }
+ }
+ var unique = checkData.filter(onlyUnique);
+ for(i =0; i < unique.length; i++){
+ if(unique[i].indexOf("@0") == -1){
+ var finalkey = unique[i].split("@")[0];
+ $scope.addNewChoice(finalkey);
+ }
+ }
+ }
+ }
+ var ele = angular.element(document.getElementById("DynamicTemplate"));
+ $compile(ele.contents())($scope);
+ $scope.$apply();
+ },
+ error : function(data){
+ alert("Error While Retriving the Template Layout Pattren.");
+ }
+ });
+ }
+ };
+
+ function getDictionary(attribute){
+ var dicName = attribute;
+ if(attribute){
+ if(attribute.includes(":")){
+ dicName = attribute.split(":")[0];
+ }
+ }
+ var dictionaryRegExp = new RegExp(dicName);
+ listemunerateValues = [];
+ if (dictionaryRegExp.test(dictionaryNameList)) {
+ for (p=0; p < dictionaryList.length; p += 1) {
+ if (dicName == dictionaryList[p].name) {
+ listemunerateValues.push(dictionaryList[p].value);
+ }
+ }
+ }
+ return listemunerateValues;
+ }
+
+ function getList(attribute) {
+
+ var baseEnum = $scope.dcaeModelData.enumValues;
+ var enumList = baseEnum.split(splitEnum);
+ var enumAttributes;
+ var patternTest = new RegExp(attribute);
+ for (k=0; k < enumList.length; k += 1){
+ if(patternTest.test(enumList[k]) == true){
+ enumAttributes = enumList[k].trim();
+ }
+ }
+
+ if(enumAttributes){
+ enumAttributes = enumAttributes.replace("[", "");
+ enumAttributes = enumAttributes.replace("]", "");
+ enumAttributes = enumAttributes.replace(/ /g, '');
+
+ var dropListAfterCommaSplit = enumAttributes.split(splitEqual);
+ listemunerateValues = dropListAfterCommaSplit[1].split(splitComma);
+
+ enumKeyList.push(attribute);
+
+ return listemunerateValues;
+ }
+
+ return [];
+ }
+
+ function getBooleanList(){
+ var booleanList = [];
+ booleanList.push(true);
+ booleanList.push(false);
+ return booleanList;
+ }
+
+
+ function isArray(arrayTest) {
+ return Object.prototype.toString.call(arrayTest) === '[object Array]';
+ }
+ var lableList = [];
+
+ function deconstructJSON(dataTest, level , name) {
+ var array = false;
+ var label = level;
+ var stringValue = "java.lang.String";
+ var intValue = "int";
+ var double = "double";
+ var boolean = "boolean";
+ var baseLevel = level;
+
+ if (name.length > 1){
+ label = label + name + '.';
+ }
+
+ for (key in dataTest) {
+ array = isArray(dataTest[key]);
+ console.log(key , dataTest[key]);
+ if (!!dataTest[key] && typeof(dataTest[key])=="object") {
+ if (array==false && key!=="0"){
+ $scope.labelLayout(label, key, array );
+ }
+
+ if (array == true && key!=0){
+ lableList.push(key);
+ }
+
+ if (lableList.length > 0){
+ array = true;
+ }
+ if ( key=="0"){
+ var newKey = lableList.pop();
+ $scope.labelLayout(baseLevel, newKey, array );
+ if (array){
+ label = baseLevel + newKey + '@0.';
+ } else {
+ label = baseLevel + newKey + '.';
+ }
+ }
+ deconstructJSON(dataTest[key] , label, key);
+ } else {
+ var attirbuteLabel = label;
+ var defaultValue='';
+ var isRequired = false;
+ if (dataTest[key].includes('defaultValue-')){
+ defaultValue = dataTest[key].split('defaultValue-')[1];
+ }
+
+ if (key==="0"){
+ array = true;
+ attributekey = lableList.pop();
+ attirbuteLabel = baseLevel;
+ } else {
+ attributekey = key.split();
+ }
+
+ if (dataTest[key].includes('required-true')){
+ isRequired = true;
+ }
+ console.log("attirbuteLabel = " + attirbuteLabel);
+ switch (dataTest[key].split(splitcolon)[0]){
+ case stringValue:
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ break;
+ case intValue:
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ break;
+ case double:
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ break;
+ case boolean:
+ $scope.dropBoxLayout(attirbuteLabel, attributekey, array, dataTest[key], getBooleanList());
+ break;
+ default:
+ if (dataTest[key].includes('dictionary-')){
+ var list = getDictionary(dataTest[key].split('dictionary-')[1]);
+ }else{
+ var list = getList(dataTest[key]);
+ }
+ if (list.length===0){
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ }else{
+ $scope.dropBoxLayout(attirbuteLabel, attributekey, array, dataTest[key], list);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ $scope.jsonLayout = function(dataTest){
+ deconstructJSON(dataTest , "", "");
+ }
+
+
+ $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired){
+ $scope.temp.policy.ruleGridData.push(attibuteKey);
+ var br = document.createElement("BR");
+
+ var label = document.createElement("Label");
+ var labeltext = null;
+ var requiredLabName = "";
+ if (matching.includes(attibuteKey)){
+ labeltext = document.createTextNode(attibuteKey + "*!");
+ }else {
+ //var labeltext = document.createTextNode(refattributeLabel);
+ if(isRequired){
+ requiredLabName = attibuteKey + " *";
+ labeltext = document.createTextNode(requiredLabName);
+ }else{
+ labeltext = document.createTextNode(attibuteKey);
+ }
+ }
+
+
+ var divID = labelValue;
+
+ if (labelValue.length < 1){
+ divID = "DynamicTemplate";
+ }else if (labelValue.endsWith('.')){
+ var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+ }
+
+ label.appendChild(labeltext);
+
+ var textField = document.createElement("INPUT");
+
+ textField.setAttribute("class" , "form-control");
+ textField.setAttribute("type" , "text");
+ textField.setAttribute("style" , "width:300px;");
+ textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ var checkKey;
+ if(attributeManyKey){
+ checkKey = labelValue + attibuteKey+'@0';
+ textField.setAttribute("id" , ''+labelValue + attibuteKey+'@0'+'');
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div."+ labelValue +attibuteKey);
+ var addButton = document.createElement("BUTTON");
+ var buttonaddLabel = document.createTextNode("+");
+ addButton.appendChild(buttonaddLabel);
+ addButton.setAttribute("id", labelValue + attibuteKey);
+ addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + attibuteKey+'");');
+ addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ var removeButton = document.createElement("BUTTON");
+ var buttonremoveLabel = document.createTextNode("-");
+ removeButton.appendChild(buttonremoveLabel);
+ removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue + attibuteKey+'");');
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ document.getElementById(divID).appendChild(addButton);
+ document.getElementById(divID).appendChild(removeButton);
+ document.getElementById(divID).appendChild(label);
+ document.getElementById(divID).appendChild(textField);
+ document.getElementById(divID).appendChild(br);
+ document.getElementById(divID).appendChild(divTag);
+ }else{
+ checkKey = labelValue + attibuteKey;
+ textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
+ if(requiredLabName.includes("*")){
+ textField.setAttribute("required", "true");
+ }
+ document.getElementById(divID).appendChild(label);
+ document.getElementById(divID).appendChild(textField);
+ document.getElementById(divID).appendChild(br);
+
+ }
+
+ if (defaultValue.length > 0){
+ if(defaultValue.includes(":")){
+ defaultValue = defaultValue.split(":")[0];
+ if(defaultValue === "NA") {
+ defaultValue = "";
+ }
+ }
+ document.getElementById(checkKey).value = defaultValue;
+ }
+
+ if($scope.temp.policy.ruleData != null){
+ //document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+ if (attributeManyKey){
+ var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
+ document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
+ var i =1 ;
+ while(true){
+ var newValue = $scope.temp.policy.ruleData[newCheckKey+'@'+i];
+ if(newValue==null){
+ break;
+ }else{
+ $scope.addNewChoice(newCheckKey);
+ document.getElementById(newCheckKey+'@'+i).value = newValue;
+ i = i+1;
+ }
+ }
+
+ }else{
+ document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+ }
+ }
+ plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);
+ };
+
+ $scope.labelLayout = function(labelValue, lableName, labelManyKey ){
+ var label = document.createElement("Label")
+ var divID = labelValue;
+ if (labelValue.endsWith('.')){
+ var workingLabel = labelValue.substring(0, labelValue.length-1);
+ }else {
+ var workingLabel = labelValue;
+ }
+
+ if (labelValue.length < 1){
+ divID = "DynamicTemplate";
+ } else if (labelValue.endsWith('.')){
+ var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+ }
+
+ var labeltext = document.createTextNode(lableName);
+
+ label.appendChild(labeltext);
+
+ if(labelManyKey){
+ var addButton = document.createElement("BUTTON");
+ var buttonLabel = document.createTextNode("+");
+ addButton.appendChild(buttonLabel);
+ addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + lableName+'");');
+ addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ var removeButton = document.createElement("BUTTON");
+ var buttonremoveLabel = document.createTextNode("-");
+ removeButton.appendChild(buttonremoveLabel);
+ removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue +lableName+'");');
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ document.getElementById(divID).appendChild(addButton);
+ document.getElementById(divID).appendChild(removeButton);
+ document.getElementById(divID).appendChild(label);
+ var id = "div."+labelValue+lableName;
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", id);
+ document.getElementById(divID).appendChild(divTag);
+
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", id +'@0');
+ document.getElementById(id).appendChild(divTag);
+ }else{
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div."+labelValue+lableName);
+ document.getElementById(divID).appendChild(label);
+ document.getElementById(divID).appendChild(divTag);
+ }
+ };
+
+ $scope.dropBoxLayout = function(labelLevel, attributeName, many , refValue, listemunerateValues){
+ var br = document.createElement("BR");
+
+ if (labelLevel.length < 1){
+ var divID = "DynamicTemplate";
+ } else if (labelLevel.endsWith('.')){
+ var divID = 'div.'+ labelLevel.substring(0, labelLevel.length-1);
+ }
+
+
+ var label = document.createElement("Label")
+ if (matching.includes(attributeName)){
+ var labeltext = document.createTextNode(attributeName + "*!");
+ }else {
+ var labeltext = document.createTextNode(attributeName);
+ }
+ label.appendChild(labeltext);
+
+ var listField = document.createElement("SELECT");
+ listField.setAttribute("class" , "form-control");
+ listField.setAttribute("style" , "width:300px;");
+ listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+
+ for (i=0; i < listemunerateValues.length; i += 1) {
+ option = document.createElement('option');
+ option.setAttribute('value', listemunerateValues[i]);
+ option.appendChild(document.createTextNode(listemunerateValues[i]));
+ listField.appendChild(option);
+ }
+ listField.setAttribute("id" , ''+ labelLevel + attributeName + '');;
+ document.getElementById(divID).appendChild(label);
+ document.getElementById(divID).appendChild(br);
+
+ if(many == true){
+ document.getElementById(divID).appendChild(listField).multiple = true;
+ plainAttributeKeys.push(labelLevel + attributeName+'*'+true);
+ }else {
+ document.getElementById(divID).appendChild(listField).multiple = false;
+ plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
+ }
+
+ if($scope.temp.policy.ruleData != null){
+ if (many == true){
+ document.getElementById(labelLevel +attributeName).options[0].selected = false;
+ for (i=0; i < listemunerateValues.length; i += 1) {
+ var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i];
+ if (testValue === undefined){
+ testValue = $scope.temp.policy.ruleData[labelLevel +attributeName];
+ }
+ var location = listemunerateValues.indexOf(testValue);
+ if (location!=-1){
+ document.getElementById(labelLevel +attributeName).options[location].selected = true;
+ }
+ }
+ }else {
+ document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];
+
+ }
+ }
+ };
+
+ function onlyUnique(value, index, self) {
+ return self.indexOf(value) === index;
+ };
+
+
+ function checkDictionary(value){
+ for (i = 0; i < $scope.microServiceAttributeDictionaryDatas.length; i++) {
+ if ($scope.microServiceAttributeDictionaryDatas[i].name.localeCompare(value)){
+ return true;
+ }
+ }
+
+ }
+ $scope.savePolicy = function(policy){
+ $scope.savebutton = false;
+ var splitAt = '*';
+ var dot ='.';
+ var jsonPolicy = {};
+ if(plainAttributeKeys != null){
+ for(a = 0; a < plainAttributeKeys.length; a++){
+ var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+ console.log(splitPlainAttributeKey[1]);
+ var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+ var key = splitPlainAttributeKey[0];
+ if(searchElement == null){
+ searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+ key = splitPlainAttributeKey[0]+'@0';
+ }else if (searchElement.nodeName == 'BUTTON'){
+ searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+ key = splitPlainAttributeKey[0]+'@0';
+ }
+ if(searchElement != null){
+ var keySplit = key.split(dot);
+ var elumentLocation = keySplit.length;
+ var enumKey = key;
+ if (elumentLocation > 1){
+ enumKey = keySplit[keySplit.length - 1];
+ }
+ var aWhiteSpace = " ";
+ if (enumKeyList.indexOf(enumKey) != -1){
+ if (splitPlainAttributeKey[1].indexOf("true") !== -1){
+ var multiSlect = [];
+ for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+ multiSlect.push(searchElement.selectedOptions[i].value);
+ }
+ jsonPolicy[key]= multiSlect;
+ }else{
+ //set a space due to empty value caused JSON format error in PolicyRestAdapter and remove it in back-end.
+ if(searchElement.value == ""){
+ searchElement.value = aWhiteSpace;
+ }
+ console.log(" searchElement.value = > " + searchElement.value);
+ jsonPolicy[key]= searchElement.value;
+ }
+ } else {
+ if(searchElement.value != null){
+ //set a default value due to empty value caused JSON format error in PolicyRestAdapter
+ if(searchElement.value == ""){
+ searchElement.value = aWhiteSpace;
+ }
+ console.log(" searchElement.value = > " + searchElement.value);
+ jsonPolicy[key]= searchElement.value;
+ }
+ }
+ }
+ }
+ }
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy, policyJSON : jsonPolicy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ $scope.safetyChecker = data.policyData.split("#")[2];
+ if ($scope.safetyChecker!=undefined) {
+ Notification.success($scope.safetyChecker);
+ }
+ $scope.pushStatus=data.policyData.split("&")[1];
+ if($scope.pushStatus=="successPush"){
+ Notification.success("Policy pushed successfully");
+ }
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ document.getElementById("validate").innerHTML = "";
+ var splitAt = '*';
+ var dot ='.';
+ var jsonPolicy = {};
+ if(plainAttributeKeys != null){
+ for(a = 0; a < plainAttributeKeys.length; a++){
+ var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+ console.log(splitPlainAttributeKey[1]);
+ var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+ var key = splitPlainAttributeKey[0];
+ if(searchElement == null){
+ searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+ key = splitPlainAttributeKey[0]+'@0';
+ }else if (searchElement.nodeName == 'BUTTON'){
+ searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+ key = splitPlainAttributeKey[0]+'@0';
+ }
+ if(searchElement != null){
+ if (enumKeyList.indexOf(key) != -1){
+ if (splitPlainAttributeKey[1].indexOf("true") !== -1){
+ var multiSlect = [];
+ for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+ multiSlect.push(searchElement.selectedOptions[i].value);
+ }
+ jsonPolicy[key]= multiSlect;
+ }else{
+ jsonPolicy[key]= searchElement.value;
+ }
+ } else {
+ if(searchElement.value != null){
+ jsonPolicy[key]= searchElement.value;
+ if(searchElement.getAttribute("required")){
+ if(!searchElement.value){
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy, policyJSON : jsonPolicy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size - 1);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+}); \ No newline at end of file
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
new file mode 100644
index 000000000..f5932e2f4
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -0,0 +1,209 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('decisionPolicyController', function ($scope, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ if($scope.temp.policy.ruleProvider==undefined){
+ $scope.temp.policy.ruleProvider="Custom";
+ }
+
+ PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas);
+ console.log($scope.ecompNameDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_SettingsDictionaryDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.settingsDictionaryDatas = JSON.parse($scope.data.settingsDictionaryDatas);
+ console.log($scope.settingsDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('get_FunctionDefinitionDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.functionDefinitionDatas = JSON.parse($scope.data.functionDefinitionDatas);
+ console.log($scope.functionDefinitionDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_AttributeDatabyAttributeName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
+ console.log($scope.attributeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ $scope.saveDecisionPolicy = function(policy){
+ $scope.savebutton = false;
+ console.log(policy);
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data;
+ if($scope.data == '"success"'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ $scope.temp.policy.settings = [];
+ $scope.temp.policy.ruleAlgorithmschoices = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ if($scope.temp.policy.settings.length == 0){
+ $scope.temp.policy.settings = [];
+ }
+ if($scope.temp.policy.ruleAlgorithmschoices.length == 0){
+ $scope.temp.policy.ruleAlgorithmschoices = [];
+ }
+ }
+ $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes.length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+
+
+ $scope.settingsDatas = [{"settings" : $scope.temp.policy.settings}];
+ $scope.addNewSettingsChoice = function() {
+ var newItemNo = $scope.temp.policy.settings.length+1;
+ $scope.temp.policy.settings.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeSettingsChoice = function() {
+ var lastItem = $scope.temp.policy.settings.length-1;
+ $scope.temp.policy.settings.splice(lastItem);
+ };
+
+ $scope.ItemNo = 0;
+ $scope.ruleAlgorithmDatas = [{"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices }];
+
+ $scope.addNewRuleAlgorithm = function() {
+ if($scope.temp.policy.ruleAlgorithmschoices != null){
+ var newItemNo = $scope.temp.policy.ruleAlgorithmschoices.length+1;
+ }else{
+ var newItemNo = 1;
+ }
+ if(newItemNo > 1){
+ var value = newItemNo-1;
+ $scope.attributeDictionaryDatas.push('A'+value);
+ }
+ $scope.temp.policy.ruleAlgorithmschoices.push({'id':'A'+newItemNo});
+ };
+
+ $scope.removeRuleAlgorithm = function() {
+ var lastItem = $scope.temp.policy.ruleAlgorithmschoices.length-1;
+ $scope.temp.policy.ruleAlgorithmschoices.splice(lastItem);
+ };
+
+ $scope.providerListener = function(ruleProvider) {
+ if (ruleProvider!="Custom"){
+ $scope.temp.policy.ruleAlgorithmschoices = [];
+ $scope.temp.policy.settings = [];
+ $scope.temp.policy.attributes = [];
+ }
+ };
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js
new file mode 100644
index 000000000..7c0300c9f
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+var app = appDS2;
+app.controller('exportPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification){
+ $( "#dialog" ).hide();
+ $scope.linkEnable = true;
+ $scope.gridOptions = {
+ data : 'policydatas',
+ onRegisterApi: function(gridApi) {
+ $scope.gridPolicyApi = gridApi;
+ },
+ enableSorting: true,
+ enableFiltering: true,
+ showTreeExpandNoChildren: true,
+ paginationPageSizes: [10, 20, 50, 100],
+ paginationPageSize: 20,
+ columnDefs: [{name: 'policyName', displayName : 'Policy Name', sort: { direction: 'asc', priority: 0 }},
+ {name: 'activeVersion', displayName : 'Version'},
+ {name: 'modifiedDate', displayName : 'Last Modified',type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' }]
+ };
+
+ $scope.files;
+ PolicyAppService.getData('get_AutoPushPoliciesContainerData').then(function (data) {
+ $scope.loading = false;
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.policydatas =JSON.parse($scope.data.policydatas);
+ console.log($scope.policydatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ $scope.urlLink;
+ $scope.download = function(){
+ var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
+ console.log(policySelection);
+ var finalData = {
+ "policyDatas": policySelection
+ };
+ console.log(finalData);
+ var uuu = "policy_download/exportPolicy.htm";
+ var postData={exportData: finalData};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.data;
+ var url = '../' + $scope.data;
+ window.location = url;
+ Notification.success("Policies Exported Successfully");
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while Exporting Policy.");
+ }
+ });
+
+ };
+
+ $scope.close = function() {
+ $modalInstance.close();
+ };
+
+});
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
new file mode 100644
index 000000000..cc051769c
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
@@ -0,0 +1,227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+angular.module('abs').controller('fwPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+ $scope.finalPath = null;
+
+ PolicyAppService.getData('getDictionary/get_SecurityZoneDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.securityZoneDictionaryDatas = JSON.parse($scope.data.securityZoneDictionaryDatas);
+ console.log($scope.securityZoneDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_TermListDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.termListDictionaryDatas = JSON.parse($scope.data.termListDictionaryDatas);
+ console.log($scope.termListDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_FWDictionaryListDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.fwDictListDictionaryDatas = JSON.parse($scope.data.fwDictListDictionaryDatas);
+ console.log($scope.fwDictListDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_FWParentListDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.fwParentListDictionaryDatas = JSON.parse($scope.data.fwParentListDictionaryDatas);
+ console.log($scope.fwParentListDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_TagPickerNameByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.fwTagPickerDictionaryDatas = JSON.parse($scope.data.fwTagPickerDictionaryDatas);
+ console.log($scope.fwTagPickerDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+ console.log($scope.riskTypeDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ $scope.viewFWRule = function(policy){
+ console.log(policy);
+ var uuu = "policyController/ViewFWPolicyRule.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ window.alert(data.policyData);
+ });
+ },
+ error : function(data){
+ Notification.error("Error Occured while Showing Rule.");
+ }
+ });
+ };
+
+
+ $scope.saveFWPolicy = function(policy){
+ $scope.savebutton = false;
+ console.log(policy);
+ var uuu = "policycreation/save_policy";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.data=data.policyData;
+ if($scope.data == 'success'){
+ $scope.temp.policy.readOnly = 'true';
+ $scope.pushStatus=data.policyData.split("&")[1];
+ if($scope.pushStatus=="successPush"){
+ Notification.success("Policy pushed successfully");
+ }
+ Notification.success("Policy Saved Successfully.");
+ }else if ($scope.data == 'PolicyExists'){
+ $scope.savebutton = true;
+ Notification.error("Policy Already Exists with Same Name in Scope.");
+ }
+ });
+ console.log($scope.data);
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ document.getElementById("validate").innerHTML = "";
+ var uuu = "policyController/validate_policy.htm";
+ var postData={policyData: policy};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.validateData = data.data.replace(/\"/g, "");
+ $scope.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ $scope.savebutton = false;
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ document.getElementById("validate").innerHTML = "Safe Policy Warning Message : "+displayWarning;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "skyblue";
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ document.getElementById("validate").innerHTML = $scope.validateData;
+ document.getElementById("validate").style.color = "white";
+ document.getElementById("validate").style.backgroundColor = "red";
+ $scope.savebutton = true;
+ }
+
+ });
+ console.log($scope.data);
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ $scope.savebutton = true;
+ }
+ });
+ };
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy.attributes = [];
+ $scope.temp.policy.fwattributes = [];
+ }else{
+ if($scope.temp.policy.attributes.length == 0){
+ $scope.temp.policy.attributes = [];
+ }
+ if($scope.temp.policy.fwPolicyType == 'Parent Policy'){
+ if($scope.temp.policy.fwattributes.length == 0){
+ $scope.temp.policy.fwattributes = [];
+ }
+ }
+ }
+
+ $scope.attributeDatas = [{"ruleSetup" : $scope.temp.policy.attributes}];
+ $scope.addNewChoice = function() {
+ var newItemNo = $scope.temp.policy.attributes.length+1;
+ $scope.temp.policy.attributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removeChoice = function() {
+ var lastItem = $scope.temp.policy.attributes.length-1;
+ $scope.temp.policy.attributes.splice(lastItem);
+ };
+
+ $scope.fwattributeDatas = [{"parentSetup" : $scope.temp.policy.fwattributes}];
+ $scope.addNewFWDictList = function() {
+ var newItemNo = $scope.temp.policy.fwattributes.length+1;
+ $scope.temp.policy.fwattributes.push({'id':'choice'+newItemNo});
+ };
+ $scope.removefwDictChoice = function() {
+ var lastItem = $scope.temp.policy.fwattributes.length-1;
+ $scope.temp.policy.fwattributes.splice(lastItem);
+ };
+
+}); \ No newline at end of file