Fixed Sonar issues for Console Logs
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / dictionaryController / MSHeaderDefaultValuesDictController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2018, 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 app.controller('editMSHeaderDefaultValuesController' ,  
21     function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
22        if(message.modelAttributeDictionaryData==null)
23             $scope.label='Set Header Default Values'
24         else{
25             $scope.label='Edit Header Default Values'
26             $scope.disableCd=true;
27         }
28
29         PolicyAppService.getData('getDictionary/get_MicroServiceHeaderDefaultsData').then(function (data) {
30             var j = data;
31             $scope.data = JSON.parse(j.data);
32             $scope.microServiceHeaderDefaultDatas = JSON.parse($scope.data.microServiceHeaderDefaultDatas);
33         });
34
35         PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataServiceVersion').then(function (data) {
36             var j = data;
37             $scope.data = JSON.parse(j.data);
38             $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
39         });
40         
41     PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
42         var j = data;
43         $scope.data = JSON.parse(j.data);
44         $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
45     });
46
47     PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
48         var j = data;
49         $scope.data = JSON.parse(j.data);
50         $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
51     });
52     
53     PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
54         var j = data;
55         $scope.data = JSON.parse(j.data);
56         $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
57     });
58
59     PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
60         var j = data;
61         $scope.data = JSON.parse(j.data);
62         $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
63     });
64         
65     /*getting user info from session*/
66     var userid = null;
67     UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
68           .then(function (response) {          
69           userid = response.userid;          
70      });
71     
72         $scope.editHeaderDefaults = message.modelAttributeDictionaryData;
73         $scope.editModelAttribute1 = {microservice: []};
74         if($scope.edit){
75             if(message.modelAttributeDictionaryData.groupList != null){
76             var splitValue = message.modelAttributeDictionaryData.groupList.split(",");
77             }    
78         }
79         $scope.saveHeaderDefaults = function(editHeaderDefaultsData) {
80             var uuu = "saveDictionary/ms_dictionary/save_headerDefaults";
81             var postData={modelAttributeDictionaryData: editHeaderDefaultsData, userid: userid};
82             $.ajax({
83                 type : 'POST',
84                 url : uuu,
85                 dataType: 'json',
86                 contentType: 'application/json',
87                 data: JSON.stringify(postData),
88                 success : function(data){
89                 $scope.$apply(function(){
90                     $scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
91                 if($scope.microServiceAttributeDictionaryDatas == "Duplicate"){
92                     Notification.error("Model Attribute Dictionary exists with Same Attribute Name.")
93                 }else{      
94                     $modalInstance.close({microServiceHeaderDefaultDatas:$scope.microServiceHeaderDefaultDatas});
95                 }
96                 },
97                 error : function(data){
98                 Notification.error("Error while saving.");
99                 }
100             });
101             
102         };
103
104         $scope.close = function() {
105             $modalInstance.close();
106         };
107     });