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.init = function() {
62 $scope.schemaLocation = 'svn://svnrepo:3690';
63 $scope.upgrade_schemaLocation = 'svn://svnrepo:3690';
64 $scope.userID = 'user_id';
65 $scope.password = 'password';
71 $scope.close = function(){
73 $modalInstance.close("closed");
78 $scope.importSchema= function(){
79 console.log("importSchema");
80 isImportSchema = true;
81 var file=$rootScope.file_path;
82 //alert("file:"+schemaFile);
83 //console.log('file is ' + JSON.stringify(file));
84 var userID = document.getElementById("userID").value;
85 var password = document.getElementById("password").value;
86 var svnURL = document.getElementById("schemaLocation").value;
87 var schemaLocation = document.getElementById("schemaLocation").value;
89 if( schemaLocation && userID && password && document.getElementById("schemaLocation").disabled== false)
91 $scope.schemaLocation=schemaLocation;
93 $scope.password=password;
95 document.getElementById("fileUpload").disabled = true;
97 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
99 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
100 .then(function(pars) {
102 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
103 document.getElementById('Set Default Values').classList.remove('ThisLink');
104 $rootScope.wsdlInfo = angular.fromJson(pars);
105 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
106 serviceName = $rootScope.serviceInfo.service.name;
107 $rootScope.schemaLocation=$rootScope.wsdlInfo.schemaLocation;
108 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
109 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
111 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
112 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
114 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
115 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
117 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
119 $rootScope.inputSchemaServiceInputPartInfo=[];
120 $rootScope.inputSchemaServiceOutputPartInfo=[];
121 $rootScope.inputSchemaServicefaultPartInfo=[];
125 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
127 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
129 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
131 $rootScope.isModel = true;
135 //alert("File upload failed and parameters not returned");
138 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
140 fileUpload.uploadFileToUrl(file, uploadUrl)
141 .then(function(pars) {
143 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
144 document.getElementById('Set Default Values').classList.remove('ThisLink');
145 //document.getElementById('Define/Modify Schema').classList.remove('ThisLink');
146 $rootScope.wsdlInfo = angular.fromJson(pars);
147 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
148 serviceName = $rootScope.serviceInfo.service.name;
150 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
151 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
153 //alert("Input Part Info :: " + JSON.stringify($rootScope.serviceInputPartInfo));
154 //alert("Input Part 1 Info :: " + JSON.stringify($rootScope.serviceInputPartInfo[1]));
156 //alert("Input Element :: " + JSON.stringify($rootScope.serviceInputPartInfo[1].schemaElements[1].elements[0]));
158 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
159 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
161 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
162 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
164 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
166 $rootScope.inputSchemaServiceInputPartInfo=[];
167 $rootScope.inputSchemaServiceOutputPartInfo=[];
168 $rootScope.inputSchemaServicefaultPartInfo=[];
172 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
174 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
176 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
178 $rootScope.isModel = true;
190 $modalInstance.close("closed");
193 $scope.setFile = function(element) {
194 console.log("setFile");
196 $scope.$apply(function($scope) {
197 console.log("apply");
198 $scope.theFile = element.files[0];
199 $rootScope.fileName =$scope.theFile.name;
200 var file =element.files[0];
201 $rootScope.file_path = file;
203 //$modalInstance.close("closed");
205 angular.element(document.getElementById('fileUpload')).val(null);
210 $scope.setUpgradeFile = function(element) {
211 console.log("setUpgradeFile");
212 $scope.$apply(function($scope) {
213 console.log("apply");
214 $scope.theUpgradeFile = element.files[0];
215 $rootScope.upgradeFileName =$scope.theUpgradeFile.name;
216 //alert("fname1"+$rootScope.upgradeFileName);
217 var file =element.files[0];
218 $rootScope.file_path = file;
220 //$modalInstance.close("closed");
222 angular.element(document.getElementById('fileUpload')).val(null);
229 $scope.reset = function(){
230 console.log("reset");
231 document.getElementById("fileUpload").disabled = false;
232 document.getElementById("schemaLocation").disabled = false;
233 document.getElementById("userID").disabled = false;
234 document.getElementById("password").disabled = false;
236 document.getElementById("schemaLocation").value='';
238 document.getElementById("userID").value='';
239 document.getElementById("password").value='';
240 $scope.theFile = null;
241 angular.element(document.getElementById('fileUpload')).val(null);
246 $scope.upgradeSchema = function(){
247 console.log("upgradeSchema");
248 //alert("inside upgrade schema");
249 var file=$rootScope.file_path;
250 //alert("file:"+schemaFile);
251 //console.log('file is ' + JSON.stringify(file));
252 var userID = document.getElementById("userID").value;
253 var password = document.getElementById("password").value;
254 var schemaLocation = document.getElementById("upgradeSchemaLocation").value;
255 var svnURL = document.getElementById("upgradeSchemaLocation").value;
256 console.log("after");
257 $rootScope.Currentmappedvalues = [];
258 if( schemaLocation && userID && password && document.getElementById("upgradeSchemaLocation").disabled== false)
260 $scope.schemaLocation=schemaLocation;
261 $scope.userID=userID;
262 $scope.password=password;
264 document.getElementById("fileUpload").disabled = true;
266 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
268 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
269 .then(function(pars) {
271 $rootScope.updateWsdlInfo = angular.fromJson(pars);
272 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
273 $rootScope.schemaLocation=$rootScope.updateWsdlInfo.schemaLocation;
274 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
275 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
277 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
278 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
280 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
281 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
283 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
285 //$rootScope.isModel = true;
289 //alert("File upload failed and parameters not returned");
292 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
294 fileUpload.uploadFileToUrl(file, uploadUrl)
295 .then(function(pars) {
298 $rootScope.updateWsdlInfo = angular.fromJson(pars);
299 // alert("wsdlinfo:"+$rootScope.updateWsdlInfo);
300 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
302 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
303 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
305 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
306 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
308 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
309 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
311 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
314 //$rootScope.isModel = true;
322 $modalInstance.close("closed");
324 var dlg = dialogs.create('partials/portfolios/upgrade_schema_dtls.html','UpgradeSchemaCtrl',{},{size:'xlg',keyboard: true,backdrop: true,windowClass: 'my-class'});
325 dlg.result.then(function(name){
326 console.log("dlg.result");
327 //$scope.name = name;
329 //if(angular.equals($scope.name,''))
330 //$scope.name = 'You did not enter in your name!';