aboutsummaryrefslogtreecommitdiffstats
path: root/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController')
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js175
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js210
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js147
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js185
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js790
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js178
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js694
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js212
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js108
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js234
-rw-r--r--ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/PolicyDictionaryService.js522
11 files changed, 3455 insertions, 0 deletions
diff --git a/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
new file mode 100644
index 000000000..09d05524c
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
@@ -0,0 +1,175 @@
+/*-
+ * ============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, PapUrlService, PolicyDictionaryService,modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getActionPolicyDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getAttributeDictionaryData(papUrl).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");
+ });
+
+ });
+
+ PolicyDictionaryService.getFunctionDefinitionData().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);
+ /*var attributeData = extend(policy, $scope.attributeDatas[0]);*/
+ // var finalData = extend(policy, $scope.ruleAlgorithmDatas[0]);
+ //console.log(finalData);
+ var uuu = "policyController/save_Actionpolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data;
+ if($scope.data == '"success"'){
+ Notification.success("Validation Success.");
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+
+ 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.$apply();
+ }
+ $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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
new file mode 100644
index 000000000..5c9783347
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
@@ -0,0 +1,210 @@
+/*-
+ * ============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, PolicyDictionaryService, PapUrlService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ $scope.validateSuccess = true;
+ var readValue = $scope.temp.policy.readOnly;
+ if(readValue){
+ $scope.validateSuccess = false;
+ }
+
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getBRMSParamDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, 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(){
+ window.alert(data.policyData);
+ });
+ },
+ error : function(data){
+ Notification.error("Error Occured while Showing Rule.");
+ }
+ });
+ };
+
+ $scope.saveBrmsParamPolicy = function(policy){
+ console.log(policy);
+ var uuu = "policyController/save_BRMSParamPolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ $scope.validateSuccess = false;
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ 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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
new file mode 100644
index 000000000..10a0b2f20
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
@@ -0,0 +1,147 @@
+/*-
+ * ============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, PolicyDictionaryService, PapUrlService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ });
+ $scope.saveBrmsRawPolicy = function(policy){
+ console.log(policy);
+ /* var finalData = extend(policy, $scope.attributeDatas[0]);*/
+ var uuu = "policyController/save_BRMSRawPolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ 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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
new file mode 100644
index 000000000..b2712e7a9
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
@@ -0,0 +1,185 @@
+/*-
+ * ============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, PolicyDictionaryService,modalService, PapUrlService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.savebutton = true;
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ PapUrlService.getPapUrl().then(function(data) {
+ var papUrl;
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getEcompDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getAttributeDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, 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.close = function(){
+ $scope.temp = {};
+ };
+
+ $scope.savePolicy = function(policy){
+ console.log(policy);
+ var uuu = "policyController/save_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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicyName = false;
+ $scope.validateEcompName = false;
+ $scope.validateConfigName = false;
+ $scope.validateConfigType = false;
+ $scope.validateConfigTypeNull = false;
+ $scope.validateConfigTypeBody = false;
+ $scope.validateRiskType = false;
+ $scope.validateRiskLevel = false;
+ $scope.validateGuard = false;
+ $scope.policyNameErrorMessage = "";
+ $scope.errorMessage = "";
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.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);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+ });
+ },
+ 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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
new file mode 100644
index 000000000..e9fdae299
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
@@ -0,0 +1,790 @@
+/*-
+ * ============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, PolicyDictionaryService, PapUrlService, modalService, $modal, Notification){
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ 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.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});
+ }
+ }
+ }
+ }
+ }
+ }
+
+ };
+
+ $scope.triggerdisabled = true;
+ $scope.verificationdisabled = true;
+
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getEcompDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getPepOptionsDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getPepOptionsDictionaryDataEntity(papUrl).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");
+ });
+
+ PolicyDictionaryService.getVarbindDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getVnfTypeDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getVSCLActionDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, 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);
+ 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 = "policyController/save_Faultpolicy.htm";
+ 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.data;
+ $scope.temp.policy.readOnly = 'true';
+ $scope.triggerdisabled = true;
+ $scope.verificationdisabled = true;
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+ 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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
new file mode 100644
index 000000000..8497a810a
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
@@ -0,0 +1,178 @@
+/*-
+ * ============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, PapUrlService, ClosedLoopPMService, PolicyDictionaryService, modalService, $modal, Notification){
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getEcompDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ });
+
+ ClosedLoopPMService.getPMJSONBodyData().then(function(data){
+ var j = data;
+ $scope.PMData = j;
+ });
+
+ $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 = [];
+ ClosedLoopPMService.getPMJSONBodyData().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{
+ var key = $scope.PMData.indexOf(serviceType);
+ var myNewData = $scope.PMData[key];
+ $scope.temp.policy.verticaMetrics = myNewData;
+ $scope.temp.policy.description = myNewData;
+ $scope.temp.policy.attributeFields = myNewData;
+ }
+
+ };
+
+ $scope.saveCLPMPolicy = function(policy){
+ console.log(policy);
+ console.log();
+ var uuu = "policyController/save_PMPolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+
+}) \ No newline at end of file
diff --git a/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
new file mode 100644
index 000000000..ba1126311
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
@@ -0,0 +1,694 @@
+/*-
+ * ============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, PapUrlService, PolicyDictionaryService, modalService, $modal, Notification) {
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getEcompDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getPriorityValueData().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");
+ });
+
+ PolicyDictionaryService.getPolicyScopeData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getMSConfigDataByName(papUrl).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");
+ });
+
+ PolicyDictionaryService.getMSLocationDataByName(papUrl).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");
+ });
+
+ PolicyDictionaryService.getMSServiceModelsDataByName(papUrl).then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
+ console.log($scope.microServiceModelsDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyDictionaryService.getDCAEuuidDataByName(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+ });
+
+ $scope.choices = [];
+ $scope.attributeDatas = [{"attributes" : $scope.choices}];
+
+ $scope.addNewChoice = function(value) {
+ console.log(value);
+ if(value != undefined){
+ 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 inputs = clone.getElementsByTagName("input");
+ for(var i=0; i<inputs.length; i++){
+ if($scope.temp.policy.ruleData != null){
+ document.getElementById(inputs[i].id).value = $scope.temp.policy.ruleData[inputs[i].id];
+ }
+ plainAttributeKeys.push(inputs[i].id);
+ }
+ 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);
+ }
+ };
+
+ var splitDash = '-';
+ var splitEqual = '=';
+ var splitComma = ',';
+ var splitcolon = ':';
+ var plainAttributeKeys = [];
+ $scope.addDataToFields = function(serviceName){
+ if(serviceName != null){
+ var myNode = document.getElementById("DynamicTemplate");
+ myNode.innerHTML = '';
+ var uuu = "policyController/getDCAEMSTemplateData.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.addNewChoice();
+ var plainAttributeKeys = [];
+ $scope.dcaeModelData = data[0].dcaeModelData;
+ var attributes = $scope.dcaeModelData.attributes;
+ var refAttributes = $scope.dcaeModelData.ref_attributes;
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+
+ $scope.temp.policy.ruleGridData = [];
+ if(attributes != null && attributes.length>0){
+ if(attributes.indexOf(splitComma) >= 0){
+ var attributesAfterCommaSplit = attributes.split(splitComma);
+ for(i = 0; i < attributesAfterCommaSplit.length; i++){
+ if(attributesAfterCommaSplit[i].indexOf(splitcolon) > 0){
+ var splitAttribute = attributesAfterCommaSplit[i].split(splitcolon);
+ $scope.attributeLayout(splitAttribute);
+ }
+ }
+ }else{
+ //Implementation for single Attribute
+ var attributesAfterCommaSplit = attributes;
+ var splitAttribute = attributesAfterCommaSplit.split(splitcolon);
+ $scope.attributeLayout(splitAttribute);
+
+ }
+ }
+ if(refAttributes != null){
+ if(refAttributes.indexOf(splitComma) >= 0){
+ var refattributesAfterCommaSplit = refAttributes.split(splitComma);
+ for(j = 0; j < refattributesAfterCommaSplit.length; j++){
+ if(refattributesAfterCommaSplit[j].indexOf(splitcolon) > 0){
+ var splitRefAttribute = refattributesAfterCommaSplit[j].split(splitcolon);
+ $scope.refAttributeLayout(splitRefAttribute, subAttributes);
+ }
+ }
+ }else{
+ //Implementation for single RefAttribute
+ if(refAttributes != ""){
+ var refattributesAfterCommaSplit = refAttributes;
+ var splitRefAttribute = refattributesAfterCommaSplit.split(splitcolon);
+ $scope.refAttributeLayout(splitRefAttribute, subAttributes);
+ }
+ }
+ }
+ });
+ 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 onlyUnique(value, index, self) {
+ return self.indexOf(value) === index;
+ };
+
+ $scope.attributeLayout = function(splitAttribute){
+ var attributeValue = splitAttribute[0];
+ var splitAttributeValue = attributeValue.split(splitEqual);
+ var attibuteKey = splitAttributeValue[0].trim();
+ var attributeType = splitAttributeValue[1];
+ var attributedefaultValue = splitAttribute[1];
+ var attributeRequiredValue = splitAttribute[2];
+ var attributeManyValue = splitAttribute[3];
+ var splitAttributeMany = attributeManyValue.split(splitDash);
+ var attributeManyKey = splitAttributeMany[1];
+ $scope.temp.policy.ruleGridData.push(attibuteKey);
+ var br = document.createElement("BR");
+ var label = document.createElement("Label");
+ var labeltext = document.createTextNode(attibuteKey);
+ label.appendChild(labeltext);
+ var element = document.getElementById("DynamicTemplate");
+ 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 == 'true'){
+ checkKey = attibuteKey+'@0';
+ textField.setAttribute("id" , ''+attibuteKey+'@0'+'');
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div."+attibuteKey);
+ var addButton = document.createElement("BUTTON");
+ var buttonaddLabel = document.createTextNode("+");
+ addButton.appendChild(buttonaddLabel);
+ addButton.setAttribute("id", attibuteKey);
+ addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+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("'+attibuteKey+'");');
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ document.getElementById("DynamicTemplate").appendChild(addButton);
+ document.getElementById("DynamicTemplate").appendChild(removeButton);
+ document.getElementById("DynamicTemplate").appendChild(label);
+ document.getElementById("DynamicTemplate").appendChild(textField);
+ document.getElementById("DynamicTemplate").appendChild(divTag);
+ document.getElementById("DynamicTemplate").appendChild(br);
+ }else{
+ checkKey = attibuteKey;
+ textField.setAttribute("id" , ''+attibuteKey+'');
+ document.getElementById("DynamicTemplate").appendChild(label);
+ document.getElementById("DynamicTemplate").appendChild(textField);
+ document.getElementById("DynamicTemplate").appendChild(br);
+ }
+ if($scope.temp.policy.ruleData != null){
+ document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+ }
+ plainAttributeKeys.push(attibuteKey+'*'+attributeManyKey);
+ };
+
+ $scope.firstlayer = null;
+ $scope.secondlayer = null;
+ $scope.refAttributeLayout = function(splitRefAttribute, subAttributes){
+ var attibuteKey = splitRefAttribute[0];
+ var splitRefAttributeValue = attibuteKey.split(splitEqual);
+ var refattributeLabel = splitRefAttributeValue[0].trim();
+ var refattributeValue = splitRefAttributeValue[1].trim();
+
+ var refattributeManyValue = splitRefAttribute[1];
+ var splitRefAttributeMany = refattributeManyValue.split(splitDash);
+ var refattributeManyKey = splitRefAttributeMany[1];
+ var subAttributeJSON = JSON.parse(subAttributes);
+ var resultValue = subAttributeJSON[refattributeValue];
+ var br = document.createElement("BR");
+ var label = document.createElement("Label");
+ var labeltext = document.createTextNode(refattributeLabel);
+ label.appendChild(labeltext);
+
+ if(refattributeManyKey == 'true'){
+
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div."+refattributeLabel);
+ var addButton = document.createElement("BUTTON");
+ var buttonLabel = document.createTextNode("+");
+ addButton.appendChild(buttonLabel);
+ addButton.setAttribute("id", refattributeLabel);
+ addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+refattributeLabel+'");');
+ 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("'+refattributeLabel+'");');
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ document.getElementById("DynamicTemplate").appendChild(addButton);
+ document.getElementById("DynamicTemplate").appendChild(removeButton);
+ document.getElementById("DynamicTemplate").appendChild(label);
+ document.getElementById("DynamicTemplate").appendChild(br);
+ document.getElementById("DynamicTemplate").appendChild(divTag);
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div."+refattributeLabel+"@0");
+ document.getElementById("div."+refattributeLabel).appendChild(divTag);
+ $scope.firstlayer = refattributeLabel+"@0";
+ $scope.subAttributeLayout(resultValue, subAttributes, refattributeLabel);
+ document.getElementById("DynamicTemplate").appendChild(br);
+ }else{
+ document.getElementById("DynamicTemplate").appendChild(label);
+ document.getElementById("DynamicTemplate").appendChild(br);
+ $scope.firstlayer = refattributeLabel;
+ $scope.subAttributeLayout(resultValue, subAttributes, refattributeLabel);
+ }
+ };
+
+ $scope.subAttributeLayout = function(resultValue, subAttributes, refattributeLabel){
+ for(var key in resultValue){
+ key = key.trim();
+ if(key == 'logicalConnector'){
+ $scope.secondlayer = null;
+ }
+ var splitSubAttribute = resultValue[key].split(splitcolon);
+ var br = document.createElement("BR");
+ var label = document.createElement("Label");
+ var labeltext = document.createTextNode(key);
+ 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");
+
+ if(splitSubAttribute.length >= 3){
+ var subattributeType = splitSubAttribute[0];
+ var subattributedefaultValue = splitSubAttribute[1];
+ var subattributeRequiredValue = splitSubAttribute[2];
+ var subattributeManyValue = splitSubAttribute[3];
+ var splitSubAttributeMany = subattributeManyValue.split(splitDash);
+ var subattributeManyKey = splitSubAttributeMany[1];
+ if(subattributeManyKey == 'true'){
+ if($scope.firstlayer == null && $scope.secondlayer == null){
+ textField.setAttribute("id" , ''+key+'@0'+'');
+ }
+ if($scope.firstlayer != null && $scope.secondlayer == null){
+ textField.setAttribute("id" , ''+$scope.firstlayer+'.'+key+'@0'+'');
+ }
+ if($scope.firstlayer != null && $scope.secondlayer != null){
+ textField.setAttribute("id" , ''+$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0'+'');
+ }
+ var divTag = document.createElement("div");
+ var addButton = document.createElement("BUTTON");
+ var buttonLabel = document.createTextNode("+");
+ addButton.appendChild(buttonLabel);
+ addButton.setAttribute("class", "btn btn-default");
+ 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");
+ if($scope.secondlayer == null){
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+$scope.firstlayer+'.'+key+'");');
+ removeButton.setAttribute("ng-click" , 'removeChoice("'+$scope.firstlayer+'.'+key+'");');
+ divTag.setAttribute("id", "div."+$scope.firstlayer+'.'+key);
+ }else{
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'");');
+ removeButton.setAttribute("ng-click" , 'removeChoice("'+$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'");');
+ divTag.setAttribute("id", "div."+$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key);
+ }
+
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ if(!refattributeLabel.startsWith('div.')){
+ refattributeLabel = 'div.'+refattributeLabel+"@0";
+ }
+ document.getElementById(refattributeLabel).appendChild(addButton);
+ document.getElementById(refattributeLabel).appendChild(removeButton);
+ document.getElementById(refattributeLabel).appendChild(label);
+ document.getElementById(refattributeLabel).appendChild(textField);
+ document.getElementById(refattributeLabel).appendChild(divTag);
+ document.getElementById(refattributeLabel).appendChild(br);
+ }else{
+ if($scope.firstlayer == null && $scope.secondlayer == null){
+ textField.setAttribute("id" , ''+key+'');
+ }
+ if($scope.firstlayer != null && $scope.secondlayer == null){
+ textField.setAttribute("id" , ''+$scope.firstlayer+'.'+key+'');
+ }
+ if($scope.firstlayer != null && $scope.secondlayer != null){
+ textField.setAttribute("id" , ''+$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'');
+ }
+ if(!refattributeLabel.startsWith('div.')){
+ refattributeLabel = 'div.'+refattributeLabel+"@0";
+ }
+ document.getElementById(refattributeLabel).appendChild(label);
+ document.getElementById(refattributeLabel).appendChild(textField);
+ document.getElementById(refattributeLabel).appendChild(br);
+ }
+ if($scope.secondlayer == null){
+ plainAttributeKeys.push($scope.firstlayer+'.'+key+'*'+subattributeManyKey);
+ if($scope.temp.policy.ruleData != null){
+ if(document.getElementById($scope.firstlayer+'.'+key) != null){
+ document.getElementById($scope.firstlayer+'.'+key).value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+key];
+ }else{
+ document.getElementById($scope.firstlayer+'.'+key+'@0').value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+key+'@0'];
+ var i =1 ;
+ while(true){
+ var newValue = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+key+'@'+i];
+ if(newValue==null){
+ break;
+ }else{
+ $scope.addNewChoice($scope.firstlayer+'.'+key);
+ document.getElementById($scope.firstlayer+'.'+key+'@'+i).value = newValue;
+ i = i+1;
+ }
+ }
+ }
+
+ }
+ }else{
+ plainAttributeKeys.push($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'*'+subattributeManyKey);
+ if($scope.temp.policy.ruleData != null){
+ if(document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key) != null){
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key).value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key];
+ }else{
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0').value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0'];
+ var i =1 ;
+ while(true){
+ var newValue = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@'+i];
+ if(newValue==null){
+ break;
+ }else{
+ $scope.addNewChoice($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key);
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@'+i).value = newValue;
+ i = i+1;
+ }
+ }
+ }
+
+ }
+ }
+ }else{
+ //Add Recursive Function
+ var saveResultValue = resultValue;
+ var subAttributeJSON = JSON.parse(subAttributes);
+ var recursiveKey = splitSubAttribute[0].trim();
+ var resultValue = subAttributeJSON[recursiveKey];
+ var recursiveMany = splitSubAttribute[1];
+ var br = document.createElement("BR");
+ var label = document.createElement("Label");
+ var labeltext = document.createTextNode(key);
+ label.appendChild(labeltext);
+
+ if(recursiveMany == 'MANY-true'){
+ var addButton = document.createElement("BUTTON");
+ var buttonLabel = document.createTextNode("+");
+ addButton.appendChild(buttonLabel);
+ addButton.setAttribute("class", "btn btn-default");
+ 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");
+ addButton.setAttribute("ng-click" , 'addNewChoice("'+$scope.firstlayer+'.'+key+'");');
+ removeButton.setAttribute("ng-click" , 'removeChoice("'+$scope.firstlayer+'.'+key+'");');
+ removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ var idf = "div."+$scope.firstlayer;
+ document.getElementById(idf).appendChild(addButton);
+ document.getElementById(idf).appendChild(removeButton);
+ document.getElementById(idf).appendChild(label);
+ document.getElementById(idf).appendChild(br);
+ var id = "div."+$scope.firstlayer+'.'+key;
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id",id);
+ document.getElementById("div."+$scope.firstlayer).appendChild(divTag);
+ $scope.secondlayer = key;
+ var idc = "div."+$scope.firstlayer+key+'@0';
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", idc);
+ document.getElementById(id).appendChild(divTag);
+ $scope.subAttributeLayout(resultValue, subAttributes, idc);
+ document.getElementById(id).appendChild(br);
+ }else{
+ var id = "div."+$scope.firstlayer+'.'+key;
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id",id);
+ document.getElementById("div."+$scope.firstlayer).appendChild(divTag);
+ document.getElementById(id).appendChild(br);
+ document.getElementById(id).appendChild(label);
+ document.getElementById(id).appendChild(br);
+ $scope.secondlayer = key;
+ $scope.subAttributeLayout(resultValue, subAttributes, id);
+ }
+ resultValue = saveResultValue;
+ //$scope.secondlayer == null;
+ if($scope.secondlayer == null){
+ plainAttributeKeys.push($scope.firstlayer+'.'+key+'*'+recursiveMany);
+ if($scope.temp.policy.ruleData != null){
+ if(document.getElementById($scope.firstlayer+'.'+key) != null){
+ document.getElementById($scope.firstlayer+'.'+key).value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+key];
+ }else{
+ document.getElementById($scope.firstlayer+'.'+key+'@0').value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+key+'@0'];
+ }
+ }
+ }else{
+ plainAttributeKeys.push($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'*'+recursiveMany);
+ if($scope.temp.policy.ruleData != null){
+ if(document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key) != null){
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key).value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key];
+ }else{
+ if(document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0') != null){
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0').value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0'];
+ }else if(document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key) != null){
+ document.getElementById($scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key).value = $scope.temp.policy.ruleData[$scope.firstlayer+'.'+$scope.secondlayer+'@0.'+key+'@0'];
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ $scope.savePolicy = function(policy){
+ 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';
+ }
+ if(searchElement != null){
+ if(searchElement.value != null){
+ jsonPolicy[key]= searchElement.value;
+ }
+ }
+ }
+ }
+ var uuu = "policyController/save_DCAEMSPolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ 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;
+ }
+});
diff --git a/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
new file mode 100644
index 000000000..1e7c436f0
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -0,0 +1,212 @@
+/*-
+ * ============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, PapUrlService, PolicyDictionaryService,modalService, $modal, Notification) {
+ $("#dialog").hide();
+ var papUrl;
+ if($scope.temp.policy.ruleProvider==undefined){
+ $scope.temp.policy.ruleProvider="Custom";
+ }
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getEcompDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getDecisionSettingsDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getFunctionDefinitionData().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");
+ });
+
+ PolicyDictionaryService.getAttributeDictionaryData(papUrl).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){
+ console.log(policy);
+ var uuu = "policyController/save_DecisionPolicy.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.data=data.policyData;
+ if($scope.data.success != undefined){
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ }else{
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data;
+ if($scope.data == '"success"'){
+ Notification.success("Validation Success.");
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+
+ 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.$apply();
+ }
+ $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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js
new file mode 100644
index 000000000..94771503a
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ExportPolicyController.js
@@ -0,0 +1,108 @@
+/*-
+ * ============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 = angular.module('abs');
+app.controller('exportPolicyController', function ($scope, $window, ExportPolicyService, modalService, $modal, Notification){
+ $( "#dialog" ).hide();
+ $scope.linkEnable = true;
+ $scope.gridOptions = {
+ onRegisterApi: function(gridApi) {
+ $scope.gridPolicyApi = gridApi;
+ },
+ enableSorting: true,
+ enableFiltering: true,
+ showTreeExpandNoChildren: true,
+ paginationPageSizes: [10, 20, 50, 100],
+ paginationPageSize: 20,
+ columnDefs: [{name: 'name'}, {name: 'version'}, {name: 'dateModified'}]
+ };
+
+ $scope.files;
+ ExportPolicyService.getAutoPushPoliciesData().then(function (data1) {
+ $scope.loading = false;
+ $scope.files = data1.data;
+ var data = data1.data;
+
+ var id=0;
+ var writeoutNode = function(childArray, currentLevel, dataArray){
+ childArray.forEach( function(childNode){
+ if (childNode.files.length > 0){
+ childNode.$$treeLevel = currentLevel;
+ id=childNode.categoryId;
+ if(childNode.categoryId == childNode.parentCategoryId){
+ childNode.parent='';
+ }
+ }else{
+ if((id!=childNode.parentCategoryId) || (childNode.categoryId == childNode.parentCategoryId)){
+ if(childNode.categoryId == childNode.parentCategoryId){
+ childNode.parent='';
+ }
+ childNode.$$treeLevel = currentLevel;
+ }
+ }
+ dataArray.push( childNode );
+ writeoutNode( childNode.files, currentLevel + 1, dataArray );
+ });
+
+ };
+ $scope.gridOptions.data = [];
+ writeoutNode(data, 0, $scope.gridOptions.data);
+ }, 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/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
new file mode 100644
index 000000000..e1fa90bbb
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
@@ -0,0 +1,234 @@
+/*-
+ * ============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, PolicyDictionaryService,modalService, $modal, Notification, PapUrlService) {
+ $("#dialog").hide();
+
+ $scope.temp.policy.ttlDate = new Date($scope.temp.policy.ttlDate);
+ var papUrl;
+ PapUrlService.getPapUrl().then(function(data) {
+ var config = data;
+ papUrl = config.PAP_URL;
+ console.log(papUrl);
+
+ PolicyDictionaryService.getSecurityZoneDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getTermListDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getFWDictionaryListDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getFWParentListDictionaryData().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");
+ });
+
+ PolicyDictionaryService.getRiskTypeDictionaryData(papUrl).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");
+ });
+
+ PolicyDictionaryService.getRiskLevelValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.riskLevelDatas = JSON.parse($scope.data.riskLevelDatas);
+ console.log($scope.riskLevelDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyDictionaryService.getGuardValueData().then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.guardDatas = JSON.parse($scope.data.guardDatas);
+ console.log($scope.guardDatas);
+ }, 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){
+ console.log(policy);
+ /* var finalData = extend(policy, $scope.attributeDatas[0]);
+ console.log(finalData);*/
+ var uuu = "policyController/save_FirewallPolicy.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.data=data.data;
+ $scope.temp.policy.readOnly = 'true';
+ Notification.success("Policy Saved Successfully.");
+ });
+ console.log($scope.data);
+ $modalInstance.close();
+
+ },
+ error : function(data){
+ Notification.error("Error Occured while saving Policy.");
+ }
+ });
+ };
+
+ $scope.validatePolicy = function(policy){
+ console.log(policy);
+ 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.data=data.data.substring(1,8);
+ var size = data.data.length;
+ if($scope.data == 'success'){
+ Notification.success("Validation Success.");
+ if (size > 18){
+ var displayWarning = data.data.substring(19,size);
+ window.alert(displayWarning);
+ }
+ }else{
+ Notification.error("Validation Failed.");
+ }
+
+ });
+ console.log($scope.data);
+ /*$modalInstance.close();*/
+
+ },
+ error : function(data){
+ Notification.error("Validation Failed.");
+ }
+ });
+ };
+
+ 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
diff --git a/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/PolicyDictionaryService.js b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/PolicyDictionaryService.js
new file mode 100644
index 000000000..492855028
--- /dev/null
+++ b/ecomp-sdk-app/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/PolicyDictionaryService.js
@@ -0,0 +1,522 @@
+/*-
+ * ============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").factory('PolicyDictionaryService', function ($http, $q) {
+ return {
+
+ getActionPolicyDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_ActionPolicyDictDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getFunctionDefinitionData : function(){
+ return $http.get('get_FunctionDefinitionDataByName')
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getAttributeDictionaryData: function(url) {
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_AttributeDatabyAttributeName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+
+ getEcompDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_EcompNameDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+
+ getBRMSParamDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_BRMSParamDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+
+ getDecisionSettingsDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_SettingsDictionaryDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getDescriptiveDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_DescriptiveScopeByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getPepOptionsDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_PEPOptionsDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getVSCLActionDictionaryData: function(url) {
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_VSCLActionDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getVnfTypeDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_VNFTypeDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getServiceDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_ClosedLoopServicesDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+
+ getSiteDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_ClosedLoopSiteDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+
+ getVarbindDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_VarbindDictionaryDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getSecurityZoneDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_SecurityZoneDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getTermListDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_TermListDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getPepOptionsDictionaryDataEntity : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_PEPOptionsData';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getFWDictionaryListDictionaryData : function(url){
+ var url = url+'/ecomp/get_FWDictionaryListDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getFWParentListDictionaryData : function(){
+ return $http.get('get_FWParentListDataByName')
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getMSConfigDataByName : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_MicroServiceConfigNameDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getMSLocationDataByName : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_MicroServiceLocationDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getMSServiceModelsDataByName : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_MicroServiceModelsDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getDCAEuuidDataByName : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_DCAEUUIDDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getPriorityValueData : function(){
+ return $http.get('get_DCAEPriorityValues')
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getPolicyScopeData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_GroupPolicyScopeDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+
+ getRiskTypeDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_RiskTypeDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+ getRiskLevelValueData : function(){
+ return $http.get('get_RiskLevelValues')
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+ getGuardValueData : function(){
+ return $http.get('get_GuardlValues')
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+ getSafePolicyWarningDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_SafePolicyWarningDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+ getRCAlarmDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_RCAlarmDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ },
+ getServerScopeDictionaryData : function(url){
+ console.log("url on the service js: " + url);
+ var url = url+'/ecomp/get_ServerScopeDataByName';
+ return $http.get(url)
+ .then(function(response) {
+ if (typeof response.data === 'object') {
+ return response.data;
+ } else {
+ return $q.reject(response.data);
+ }
+
+ }, function(response) {
+ // something went wrong
+ return $q.reject(response.data);
+ });
+ }
+ };
+
+}); \ No newline at end of file