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;
40 $scope.init = function() {
42 $scope.schemaLocation = 'svn://svnrepo:3690';
43 $scope.upgrade_schemaLocation = 'svn://svnrepo:3690';
44 $scope.userID = 'user_id';
45 $scope.password = 'password';
51 $scope.close = function(){
53 $modalInstance.close("closed");
58 $scope.importSchema= function(){
59 console.log("importSchema");
60 isImportSchema = true;
61 var file=$rootScope.file_path;
62 //alert("file:"+schemaFile);
63 //console.log('file is ' + JSON.stringify(file));
64 var userID = document.getElementById("userID").value;
65 var password = document.getElementById("password").value;
66 var svnURL = document.getElementById("schemaLocation").value;
67 var schemaLocation = document.getElementById("schemaLocation").value;
69 if( schemaLocation && userID && password && document.getElementById("schemaLocation").disabled== false)
71 $scope.schemaLocation=schemaLocation;
73 $scope.password=password;
75 document.getElementById("fileUpload").disabled = true;
77 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
79 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
80 .then(function(pars) {
82 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
83 document.getElementById('Set Default Values').classList.remove('ThisLink');
84 $rootScope.wsdlInfo = angular.fromJson(pars);
85 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
86 serviceName = $rootScope.serviceInfo.service.name;
87 $rootScope.schemaLocation=$rootScope.wsdlInfo.schemaLocation;
88 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
89 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
91 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
92 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
94 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
95 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
97 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
99 $rootScope.inputSchemaServiceInputPartInfo=[];
100 $rootScope.inputSchemaServiceOutputPartInfo=[];
101 $rootScope.inputSchemaServicefaultPartInfo=[];
105 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
107 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
109 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
111 $rootScope.isModel = true;
115 //alert("File upload failed and parameters not returned");
118 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
120 fileUpload.uploadFileToUrl(file, uploadUrl)
121 .then(function(pars) {
123 document.getElementById('Upgrade Schema Version').classList.remove('ThisLink');
124 document.getElementById('Set Default Values').classList.remove('ThisLink');
125 //document.getElementById('Define/Modify Schema').classList.remove('ThisLink');
126 $rootScope.wsdlInfo = angular.fromJson(pars);
127 $rootScope.serviceInfo = $rootScope.wsdlInfo.serviceInfo;
128 serviceName = $rootScope.serviceInfo.service.name;
130 $rootScope.serviceInput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
131 $rootScope.serviceInputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
133 //alert("Input Part Info :: " + JSON.stringify($rootScope.serviceInputPartInfo));
134 //alert("Input Part 1 Info :: " + JSON.stringify($rootScope.serviceInputPartInfo[1]));
136 //alert("Input Element :: " + JSON.stringify($rootScope.serviceInputPartInfo[1].schemaElements[1].elements[0]));
138 $rootScope.serviceOutput = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
139 $rootScope.serviceOutputPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
141 $rootScope.servicefault = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
142 $rootScope.servicefaultPartInfo = $rootScope.serviceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
144 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
146 $rootScope.inputSchemaServiceInputPartInfo=[];
147 $rootScope.inputSchemaServiceOutputPartInfo=[];
148 $rootScope.inputSchemaServicefaultPartInfo=[];
152 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
154 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
156 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
158 $rootScope.isModel = true;
170 $modalInstance.close("closed");
173 $scope.setFile = function(element) {
174 console.log("setFile");
176 $scope.$apply(function($scope) {
177 console.log("apply");
178 $scope.theFile = element.files[0];
179 $rootScope.fileName =$scope.theFile.name;
180 var file =element.files[0];
181 $rootScope.file_path = file;
183 //$modalInstance.close("closed");
185 angular.element(document.getElementById('fileUpload')).val(null);
190 $scope.setUpgradeFile = function(element) {
191 console.log("setUpgradeFile");
192 $scope.$apply(function($scope) {
193 console.log("apply");
194 $scope.theUpgradeFile = element.files[0];
195 $rootScope.upgradeFileName =$scope.theUpgradeFile.name;
196 //alert("fname1"+$rootScope.upgradeFileName);
197 var file =element.files[0];
198 $rootScope.file_path = file;
200 //$modalInstance.close("closed");
202 angular.element(document.getElementById('fileUpload')).val(null);
209 $scope.reset = function(){
210 console.log("reset");
211 document.getElementById("fileUpload").disabled = false;
212 document.getElementById("schemaLocation").disabled = false;
213 document.getElementById("userID").disabled = false;
214 document.getElementById("password").disabled = false;
216 document.getElementById("schemaLocation").value='';
218 document.getElementById("userID").value='';
219 document.getElementById("password").value='';
220 $scope.theFile = null;
221 angular.element(document.getElementById('fileUpload')).val(null);
226 $scope.upgradeSchema = function(){
227 console.log("upgradeSchema");
228 //alert("inside upgrade schema");
229 var file=$rootScope.file_path;
230 //alert("file:"+schemaFile);
231 //console.log('file is ' + JSON.stringify(file));
232 var userID = document.getElementById("userID").value;
233 var password = document.getElementById("password").value;
234 var schemaLocation = document.getElementById("upgradeSchemaLocation").value;
235 var svnURL = document.getElementById("upgradeSchemaLocation").value;
236 console.log("after");
237 $rootScope.Currentmappedvalues = [];
238 if( schemaLocation && userID && password && document.getElementById("upgradeSchemaLocation").disabled== false)
240 $scope.schemaLocation=schemaLocation;
241 $scope.userID=userID;
242 $scope.password=password;
244 document.getElementById("fileUpload").disabled = true;
246 var svnUploadURL = "/utm-service/schema_upload/svnUploadWSDL";
248 svnservice.SVNToUrl(schemaLocation, userID, password,svnURL,svnUploadURL)
249 .then(function(pars) {
251 $rootScope.updateWsdlInfo = angular.fromJson(pars);
252 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
253 $rootScope.schemaLocation=$rootScope.updateWsdlInfo.schemaLocation;
254 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
255 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
257 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
258 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
260 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
261 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
263 //alert("serviceInputPartInfo :: " + JSON.stringify($rootScope.serviceInputPartInfo));
265 //$rootScope.isModel = true;
269 //alert("File upload failed and parameters not returned");
272 var uploadUrl = "/utm-service/schema_upload/uploadWSDL";
274 fileUpload.uploadFileToUrl(file, uploadUrl)
275 .then(function(pars) {
278 $rootScope.updateWsdlInfo = angular.fromJson(pars);
279 // alert("wsdlinfo:"+$rootScope.updateWsdlInfo);
280 $rootScope.updateServiceInfo = $rootScope.updateWsdlInfo.serviceInfo;
282 $rootScope.updateServiceInput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage;
283 $rootScope.updateServiceInputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].inputMessage.partInfo;
285 $rootScope.updateServiceOutput = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage;
286 $rootScope.updateServiceOutputPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].outputMessage.partInfo;
288 $rootScope.updateServicefault = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage;
289 $rootScope.updateServicefaultPartInfo = $rootScope.updateServiceInfo.bindingInfo.portTypeInfo.operationInfo[0].faultMessage.partInfo;
291 //alert("servicefaultPartInfo :: " + JSON.stringify($rootScope.servicefaultPartInfo));
294 //$rootScope.isModel = true;
302 $modalInstance.close("closed");
304 var dlg = dialogs.create('partials/portfolios/upgrade_schema_dtls.html','UpgradeSchemaCtrl',{},{size:'xlg',keyboard: true,backdrop: true,windowClass: 'my-class'});
305 dlg.result.then(function(name){
306 console.log("dlg.result");
307 //$scope.name = name;
309 //if(angular.equals($scope.name,''))
310 //$scope.name = 'You did not enter in your name!';