2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 app.controller('ImportSchemaCtrl', ['$scope', '$rootScope','$modalInstance','data','svnservice', 'fileUpload','dialogs', function($scope,$rootScope,$modalInstance,data,svnservice,fileUpload,dialogs){
25 console.log("//////ImportSchemaCtrl");
26 $rootScope.serviceInfo;
27 $rootScope.serviceInput;
28 $rootScope.serviceOutput;
29 $rootScope.serviceFault;
30 $rootScope.serviceInputPartInfo;
31 $rootScope.schemElemant1;
33 $rootScope.updateServiceInfo;
34 $rootScope.updateServiceInput;
35 $rootScope.updateServiceOutput;
36 $rootScope.updateServiceFault;
37 $rootScope.updateServiceInputPartInfo;
38 $rootScope.updateSchemElemant1;
41 // Below code is added to get the policyNames
42 for ( var polElement in elementMap) {
43 if (polElement.indexOf('Policy_') === 0) {
44 var obj = elementMap[polElement];
45 if (!($.isEmptyObject(obj))) {
46 allPolicies = jQuery.extend({}, obj);
47 $scope.policyNames = [];
48 for ( var policy in allPolicies) {
49 $scope.policyNames.push(policy);
56 setTimeout(function(){
57 console.log("setTimeout");
58 setMultiSelect(); }, 100);
60 $scope.close = function(){
62 $modalInstance.close("closed");
67 $scope.importSchema= function(){
68 console.log("importSchema");
69 isImportSchema = true;
70 var file=$rootScope.file_path;
71 //alert("file:"+schemaFile);
72 //console.log('file is ' + JSON.stringify(file));
73 var userID = document.getElementById("userID").value;
74 var password = document.getElementById("password").value;
75 var svnURL = document.getElementById("schemaLocation").value;
76 var schemaLocation = document.getElementById("schemaLocation").value;
78 if( schemaLocation && userID && password && document.getElementById("schemaLocation").disabled== false)
80 $scope.schemaLocation=schemaLocation;
82 $scope.password=password;
84 document.getElementById("fileUpload").disabled = true;
86 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
88 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
89 .then(function(pars) {
91 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
92 document.getElementById('Set Default Values').classList.remove('ThisLink');
93 $rootScope.wsdlInfo = angular.fromJson(pars);
94 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
95 serviceName = $rootScope.serviceInfo.service.name;
96 $rootScope.schemaLocation=$rootScope.wsdlInfo.schemaLocation;
97 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
98 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
100 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
101 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
103 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
104 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
106 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
108 $rootScope.inputSchemaServiceInputPartInfo=[];
109 $rootScope.inputSchemaServiceOutputPartInfo=[];
110 $rootScope.inputSchemaServicefaultPartInfo=[];
114 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
116 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
118 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
120 $rootScope.isModel = true;
124 //alert("File upload failed and parameters not returned");
127 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
129 fileUpload.uploadFileToUrl(file, uploadUrl)
130 .then(function(pars) {
132 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
133 document.getElementById('Set Default Values').classList.remove('ThisLink');
134 //document.getElementById('Define/Modify Schema').classList.remove('ThisLink');
135 $rootScope.wsdlInfo = angular.fromJson(pars);
136 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
137 serviceName = $rootScope.serviceInfo.service.name;
139 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
140 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
142 //alert("Input Part Info :: " + JSON.stringify($rootScope.serviceInputPartInfo));
143 //alert("Input Part 1 Info :: " + JSON.stringify($rootScope.serviceInputPartInfo[1]));
145 //alert("Input Element :: " + JSON.stringify($rootScope.serviceInputPartInfo[1].schemaElements[1].elements[0]));
147 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
148 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
150 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
151 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
153 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
155 $rootScope.inputSchemaServiceInputPartInfo=[];
156 $rootScope.inputSchemaServiceOutputPartInfo=[];
157 $rootScope.inputSchemaServicefaultPartInfo=[];
161 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
163 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
165 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
167 $rootScope.isModel = true;
179 $modalInstance.close("closed");
182 $scope.setFile = function(element) {
183 console.log("setFile");
185 $scope.$apply(function($scope) {
186 console.log("apply");
187 $scope.theFile = element.files[0];
188 $rootScope.fileName =$scope.theFile.name;
189 var file =element.files[0];
190 $rootScope.file_path = file;
192 //$modalInstance.close("closed");
194 angular.element(document.getElementById('fileUpload')).val(null);
199 $scope.setUpgradeFile = function(element) {
200 console.log("setUpgradeFile");
201 $scope.$apply(function($scope) {
202 console.log("apply");
203 $scope.theUpgradeFile = element.files[0];
204 $rootScope.upgradeFileName =$scope.theUpgradeFile.name;
205 //alert("fname1"+$rootScope.upgradeFileName);
206 var file =element.files[0];
207 $rootScope.file_path = file;
209 //$modalInstance.close("closed");
211 angular.element(document.getElementById('fileUpload')).val(null);
218 $scope.reset = function(){
219 console.log("reset");
220 document.getElementById("fileUpload").disabled = false;
221 document.getElementById("schemaLocation").disabled = false;
222 document.getElementById("userID").disabled = false;
223 document.getElementById("password").disabled = false;
225 document.getElementById("schemaLocation").value='';
227 document.getElementById("userID").value='';
228 document.getElementById("password").value='';
229 $scope.theFile = null;
230 angular.element(document.getElementById('fileUpload')).val(null);
235 $scope.upgradeSchema = function(){
236 console.log("upgradeSchema");
237 //alert("inside upgrade schema");
238 var file=$rootScope.file_path;
239 //alert("file:"+schemaFile);
240 //console.log('file is ' + JSON.stringify(file));
241 var userID = document.getElementById("userID").value;
242 var password = document.getElementById("password").value;
243 var schemaLocation = document.getElementById("upgradeSchemaLocation").value;
244 var svnURL = document.getElementById("upgradeSchemaLocation").value;
245 console.log("after");
246 $rootScope.Currentmappedvalues = [];
247 if( schemaLocation && userID && password && document.getElementById("upgradeSchemaLocation").disabled== false)
249 $scope.schemaLocation=schemaLocation;
250 $scope.userID=userID;
251 $scope.password=password;
253 document.getElementById("fileUpload").disabled = true;
255 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
257 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
258 .then(function(pars) {
260 $rootScope.updateWsdlInfo = angular.fromJson(pars);
261 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
262 $rootScope.schemaLocation=$rootScope.updateWsdlInfo.schemaLocation;
263 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
264 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
266 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
267 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
269 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
270 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
272 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
274 //$rootScope.isModel = true;
278 //alert("File upload failed and parameters not returned");
281 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
283 fileUpload.uploadFileToUrl(file, uploadUrl)
284 .then(function(pars) {
287 $rootScope.updateWsdlInfo = angular.fromJson(pars);
288 // alert("wsdlinfo:"+$rootScope.updateWsdlInfo);
289 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
291 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
292 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
294 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
295 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
297 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
298 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
300 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
303 //$rootScope.isModel = true;
311 $modalInstance.close("closed");
313 var dlg = dialogs.create('partials/portfolios/upgrade_schema_dtls.html','UpgradeSchemaCtrl',{},{size:'xlg',keyboard: true,backdrop: true,windowClass: 'my-class'});
314 dlg.result.then(function(name){
315 console.log("dlg.result");
316 //$scope.name = name;
318 //if(angular.equals($scope.name,''))
319 //$scope.name = 'You did not enter in your name!';