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.
26 app.directive('inputInfoUpgradeClass', function ($compile) {
27 console.log("////UpgradeSchemaCtrl");
31 link: function(scope,element,attrs){
33 angular.forEach(scope.infoType.schemaElements, function(value, key){
35 scope.schemaElement = value;
37 if(scope.schemaElement.complexType != null){
38 if(scope.currentElementName == ''){
39 scope.currentElementName = scope.schemaElement.complexType.name;
42 scope.ParentKey = scope.parentName + '_' + scope.currentElementName;
43 if(scope.schemaElement.repeatableHierarchicalPrefix != null){
44 scope.ParentKey = scope.ParentKey + scope.schemaElement.repeatableHierarchicalPrefix;
46 scope.parElement = scope.schemaElement;
47 scope.tableStyle = 'table-level' + scope.heirarchyLevel + '-tree';
48 scope.tdLabelStyle = 'td-level' + scope.heirarchyLevel + '-label-tree';
49 scope.heirLevel = scope.heirarchyLevel;
51 elementHTML = elementHTML + '<div ng-show="schemaElement.complexType != null">';
52 elementHTML = elementHTML + '<table class="{{tableStyle}}"> <tr>';
53 elementHTML = elementHTML + '<td class="{{tdLabelStyle}}">';
54 elementHTML = elementHTML + '<span class="pull-left" ng-click="showUTMViewMsgHeader=!showUTMViewMsgHeader">';
55 elementHTML = elementHTML + '<i ng-class="showUTMViewMsgHeader == true ?\'fa fa-plus-circle\':\'fa fa-minus-circle\'"></i>';
56 elementHTML = elementHTML + '</span>';
57 elementHTML = elementHTML + '<b>{{currentElementName}}</b>';
58 elementHTML = elementHTML + '</td>';
59 elementHTML = elementHTML + '<td class="td-tree"></td>';
60 elementHTML = elementHTML + '<td class="td-default_value-tree"> </td>';
61 elementHTML = elementHTML + '</tr></table>';
62 elementHTML = elementHTML + '<div style="margin-left: 10px" ng-class="{hidden:showUTMViewMsgHeader,chaldean:showUTMViewMsgHeader}">';
63 elementHTML = elementHTML + '<div class="inputInfoUpgradeClassMember" style="margin-left: 10px" ng-repeat="schemaElement in schemaElement.elements"></div>';
64 elementHTML = elementHTML + '</div>';
65 elementHTML = elementHTML + '</div>';
66 var x = angular.element(elementHTML);
76 app.directive('inputInfoUpgradeClassMember', function ($compile) {
80 link: function(scope,element,attrs){
83 scope.currentElementName=scope.objectName;
84 scope.parentName=scope.ParentKey;
85 scope.parentElement=scope.parElement;
86 scope.heirarchyLevel = scope.heirLevel + 1;
88 if(scope.schemaElement.element.name != null){
90 scope.elementKey=scope.parentName + '_' + scope.schemaElement.element.name;
91 if(scope.schemaElement.repeatableHierarchicalPrefix != null){
92 scope.elementKey = scope.elementKey + scope.schemaElement.repeatableHierarchicalPrefix;
94 scope.tableStyle='table-level' + scope.heirarchyLevel + '-tree';
95 scope.tdLabelStyle='td-level' + scope.heirarchyLevel +'-label-tree';
97 if(scope.schemaElement.type.complexType != null){
98 scope.showUTMViewMsgHeader = false;
101 scope.showUTMViewMsgHeader = true;
105 elementHTML = elementHTML + '<div ng-show="schemaElement.element.name != null">';
106 elementHTML = elementHTML + '<table class="{{tableStyle}}"> ';
107 elementHTML = elementHTML + '<tr>';
108 elementHTML = elementHTML + '<td style="text-align: left;vertical-align: top;" class="{{tdLabelStyle}}">';
109 elementHTML = elementHTML + '<span class="pull-left" ng-click="showUTMViewMsgHeader=!showUTMViewMsgHeader">';
110 elementHTML = elementHTML + '<div style="display:inline">';
111 elementHTML = elementHTML + '<input type="radio" name={{radioName}} id="{{elementKey}}" value={{schemaElement.element.name}}>';
112 elementHTML = elementHTML + '</div>';
113 elementHTML = elementHTML + '<i expandable ng-class="showUTMViewMsgHeader == true ?\'fa fa-minus-circle\':\'fa fa-plus-circle\'"></i>';
114 elementHTML = elementHTML + '{{schemaElement.element.name}} ';
115 elementHTML = elementHTML + '';
116 elementHTML = elementHTML + '';
117 elementHTML = elementHTML + '';
118 elementHTML = elementHTML + '';
119 elementHTML = elementHTML + '</span>';
120 elementHTML = elementHTML + '<div ng-init="complexMapElements(elementKey,schemaElement,radioName)"></div>';
121 elementHTML = elementHTML + '</td>';
123 elementHTML = elementHTML + '</tr>';
124 elementHTML = elementHTML + '</table>';
125 elementHTML = elementHTML + '';
126 elementHTML = elementHTML + '';
127 elementHTML = elementHTML + '</div>';
129 var x = angular.element(elementHTML);
134 if(scope.schemaElement.type.complexType != null){
135 var elementHTML2 = '<div ng-show="schemaElement.type.complexType != null">'
136 elementHTML2 = elementHTML2 + '<div ng-init="parKey=parentName + \'_\' + schemaElement.element.name + (schemaElement.repeatableHierarchicalPrefix != null ? schemaElement.repeatableHierarchicalPrefix : \'\'); heirLevel=heirarchyLevel; parElement=schemaElement; ParentKey=ParentKey+\'_\'+schemaElement.element.name + (schemaElement.repeatableHierarchicalPrefix != null ? schemaElement.repeatableHierarchicalPrefix : \'\')">'
137 elementHTML2 = elementHTML2 + '<div style="margin-left: 10px" ng-class="{hidden:!showUTMViewMsgHeader,chaldean:!showUTMViewMsgHeader}">'
138 elementHTML2 = elementHTML2 + '<div class="{{sourceExplorer+\'_\'+parKey}}"></div>'
139 elementHTML2 = elementHTML2 + '</div>'
140 elementHTML2 = elementHTML2 + '</div>'
141 elementHTML2 = elementHTML2 + '</div>';
142 var x = angular.element(elementHTML2);
160 function($scope, $rootScope, $modalInstance,dialogs) {
162 $rootScope.Currentmappedvalues = [];
163 $scope.utmSchemaExts = {};
165 $scope.callFromMap=false;
166 $scope.oldMapValFlag=false;
168 $scope.complexMappedValuesOld = {};
169 $scope.complexMappedValuesNew = {};
170 var allCurrentElementKeyArray=[];
172 $scope.checkedValues = {};
173 var checkedElementValueArray=[];
176 $scope.complexMapElements = function(elementKey,schemaElement,radioName) {
177 if (schemaElement.complexType != null || (schemaElement.type != null && schemaElement.type.complexType != null)) {
178 if(radioName=="oldChk")
179 $scope.complexMappedValuesOld[elementKey]=schemaElement;
180 else if(radioName=="newChk")
181 $scope.complexMappedValuesNew[elementKey]=schemaElement;
183 if(elementKey != null)
184 allCurrentElementKeyArray.push(elementKey);
188 $scope.mapElements = function() {
190 var oldVal = $('input[name=oldChk]:checked')
192 var newVal = $('input[name=newChk]:checked')
194 var oldId = $('input[name=oldChk]:checked')
196 var newId = $('input[name=newChk]:checked')
198 $scope.mappedvalues = {};
200 $scope.checkedValues.oldVal=oldVal;
201 $scope.checkedValues.newVal=newVal;
203 checkedElementValueArray.push($scope.checkedValues);
206 $scope.oldMappedvaluesKeyArray = [];
207 $scope.newMappedvaluesKeyArray = [];
208 $scope.oldmappedvaluesArray = [];
209 $scope.newMappedvaluesArray = [];
211 if($scope.complexMappedValuesOld[oldId] != null && $scope.complexMappedValuesNew[newId] != null){
213 $scope.matchType=$scope.compareElements($scope.complexMappedValuesOld[oldId],$scope.complexMappedValuesNew[newId]);
214 if($scope.matchType == "true"){
215 console.log("Element Type Matches and eligible for upgrade schema");
217 $scope.callFromMap=true;
218 for (var i = 0; i < $scope.complexMappedValuesOld[oldId].type.elements.length; i++) {
219 $scope.oldMapValFlag=true;
220 getElementkeys(oldId, $scope.complexMappedValuesOld[oldId].type.elements[i]);
223 for (var j = 0; j < $scope.complexMappedValuesNew[newId].type.elements.length; j++) {
224 $scope.oldMapValFlag=false;
225 getElementkeys(newId, $scope.complexMappedValuesNew[newId].type.elements[j]);
228 for (var k = 0; k < $scope.oldmappedvaluesArray.length; k++) {
230 $scope.mappedvalues = {};
232 $scope.mappedvalues.oldvalue = $scope.oldmappedvaluesArray[k];
233 $scope.mappedvalues.newvalue = $scope.newMappedvaluesArray[k];
234 $scope.mappedvalues.oldidvalue = $scope.oldMappedvaluesKeyArray[k];
235 $scope.mappedvalues.newidvalue = $scope.newMappedvaluesKeyArray[k];
236 $rootScope.Currentmappedvalues
237 .push($scope.mappedvalues);
240 else if($scope.matchType == "false") {
242 dialogs.error('Invalid Selection Error','The mapping of the selected elements is invalid. Please select valid complex elements for Upgrade Schema');
248 else if(($scope.complexMappedValuesOld[oldId] == null && $scope.complexMappedValuesNew[newId] != null) || ($scope.complexMappedValuesOld[oldId] != null && $scope.complexMappedValuesNew[newId] == null)){
250 dialogs.error('Invalid Selection Error','The mapping of the selected elements is invalid. Please select valid complex elements for Upgrade Schema');
254 $scope.mappedvalues.oldvalue = oldVal;
255 $scope.mappedvalues.newvalue = newVal;
256 $scope.mappedvalues.oldidvalue = oldId;
257 $scope.mappedvalues.newidvalue = newId;
258 $rootScope.Currentmappedvalues
259 .push($scope.mappedvalues);
261 $rootScope.checkRepeatable = false;
265 //Utility Method to compare Object Structure of Complex Type Elements before upgrade schema
266 $scope.compareElements = function(oldElement, newElement) {
268 if (oldElement.type.complexType !=null && newElement.type.complexType !=null) {
269 if (oldElement.type.elements.length==newElement.type.elements.length) {
270 for (var i = 0; i < oldElement.type.elements.length; i++) {
271 if(oldElement.type.elements[i].type.complexType !=null && newElement.type.elements[i].type.complexType !=null){
272 $scope.compareElements(oldElement.type.elements[i], newElement.type.elements[i]);
274 }else if(oldElement.type.elements[i].type.complexType ==null && newElement.type.elements[i].type.complexType !=null){
275 $scope.matchType="false";
276 return $scope.matchType;
278 if($scope.matchType == "false")
279 return $scope.matchType;
281 for (var i = 0; i < newElement.type.elements.length; i++) {
282 if(newElement.type.elements[i].type.complexType !=null && oldElement.type.elements[i].type.complexType !=null){
283 $scope.compareElements(newElement.type.elements[i], oldElement.type.elements[i]);
284 }else if(newElement.type.elements[i].type.complexType ==null && oldElement.type.elements[i].type.complexType !=null){
285 $scope.matchType="false";
286 return $scope.matchType;
288 if($scope.matchType == "false")
289 return $scope.matchType;
291 $scope.matchType="true";
292 return $scope.matchType;
295 $scope.matchType="false";
296 return $scope.matchType;
303 $scope.checkRepeatableElement = function(
306 if (elementKey != key)
307 $rootScope.checkRepeatable = true;
311 $scope.upgradeSchema = function() {
312 //console.log("List Model Path Details before Upgrade Schema :: " + JSON.stringify(list_model_path_details[selected_model]));
314 $scope.callFromMap=false;
315 $rootScope.isHorR = true;
317 $rootScope.repeatableHeirarchicalElementMap = map_model_repeatable_heirarchical_elements[selected_model];
319 //Checking Repeatable Hierarchical elements mapping and changing elementkey if repeatable hierarchical is mapped
320 for (var key in $rootScope.repeatableHeirarchicalElementMap) {
321 for(var i=0;i<allCurrentElementKeyArray.length;i++){
322 if(allCurrentElementKeyArray[i].indexOf(key) > -1)
323 elementKeys.push(allCurrentElementKeyArray[i]);
325 for (var j = 0; j< checkedElementValueArray.length; j++) {
326 var currentCheckedMappedvalue = checkedElementValueArray[j];
327 if (key.indexOf(currentCheckedMappedvalue.oldVal) > -1){
329 var newObject=JSON.stringify($rootScope.repeatableHeirarchicalElementMap);
331 var oldvalue=currentCheckedMappedvalue.oldVal;
332 var newvalue=currentCheckedMappedvalue.newVal;
334 var modObject= newObject.replace(oldvalue, newvalue);
336 $rootScope.repeatableHeirarchicalElementMap=angular.fromJson(modObject);
338 /*for (var k = 0; k < elementKeys.length; k++) {
340 if (elementKeys[k].indexOf(currentCheckedMappedvalue.oldVal) > -1){
342 elementKeys[k]=elementKeys[k].replace(oldvalue, newvalue);
354 $scope.oldSchemaLocation = $rootScope.wsdlInfo.schemaLocation;
355 $rootScope.wsdlInfo = $rootScope.updateWsdlInfo;
356 $rootScope.wsdlInfo.schemaUpgradedFlag = true;
357 $rootScope.wsdlInfo.oldSchemaLocation = $scope.oldSchemaLocation;
359 $rootScope.serviceInfo = $rootScope.updateServiceInfo;
360 $rootScope.schemaLocation = $rootScope.updateWsdlInfo.schemaLocation;
361 $rootScope.serviceInput = $rootScope.updateServiceInput;
362 $rootScope.serviceInputPartInfo = $rootScope.updateServiceInputPartInfo;
364 $rootScope.inputSchemaServiceInputPartInfo=[];
365 $rootScope.inputSchemaServiceOutputPartInfo=[];
366 $rootScope.inputSchemaServicefaultPartInfo=[];
367 angular.copy($rootScope.serviceInputPartInfo, $rootScope.inputSchemaServiceInputPartInfo);
368 angular.copy($rootScope.serviceOutputPartInfo, $rootScope.inputSchemaServiceOutputPartInfo);
369 angular.copy($rootScope.servicefaultPartInfo, $rootScope.inputSchemaServicefaultPartInfo);
371 //Form all the element keys of the Upgraded Schema so that to know the attibutes removed
372 for (var i = 0; i < $rootScope.serviceInputPartInfo.length; i++) {
373 for (var j = 0; j < $rootScope.serviceInputPartInfo[i].schemaElements.length; j++) {
376 $rootScope.serviceInputPartInfo[i].schemaElements[j]);
379 $rootScope.serviceOutput = $rootScope.updateServiceOutput;
380 $rootScope.serviceOutputPartInfo = $rootScope.updateServiceOutputPartInfo;
381 for (var i = 0; i < $rootScope.serviceOutputPartInfo.length; i++) {
382 for (var j = 0; j < $rootScope.serviceOutputPartInfo[i].schemaElements.length; j++) {
385 $rootScope.serviceOutputPartInfo[i].schemaElements[j]);
388 $rootScope.servicefault = $rootScope.updateServicefault;
389 $rootScope.servicefaultPartInfo = $rootScope.updateServicefaultPartInfo;
390 for (var i = 0; i < $rootScope.servicefaultPartInfo.length; i++) {
391 for (var j = 0; j < $rootScope.servicefaultPartInfo[i].schemaElements.length; j++) {
394 $rootScope.servicefaultPartInfo[i].schemaElements[j]);
397 console.log("mapped values of current"+ JSON.stringify($rootScope.Currentmappedvalues));
399 //For each model in the project
400 // a) For the mapped elements
401 // i) replace the old ids with new ids for the Schema Extensions
402 // ii) replace the old ids with new ids for the Path Details
403 // b) For the deleted attributes in the Upgraded schema
404 // i) Remove the ids from Schema Extensions
405 // ii) Remove the ids from Path Details
406 for(var modelIndex=0; modelIndex < $rootScope.models.length; modelIndex++) {
407 var current_model = $rootScope.models[modelIndex];
408 $scope.utmSchemaExts = list_model_schema_extensions[current_model].utmSchemaExtentionMap;
409 $scope.pathDetailsArray = list_model_path_details[current_model];
411 for (var i = 0; i < $rootScope.Currentmappedvalues.length; i++) {
412 $scope.mappedvalues = $rootScope.Currentmappedvalues[i];
414 if($scope.utmSchemaExts != null) {
415 $scope.utmSchemaExts[$scope.mappedvalues.newidvalue] = $scope.utmSchemaExts[$scope.mappedvalues.oldidvalue];
416 if($scope.mappedvalues.newidvalue != $scope.mappedvalues.oldidvalue)
417 delete $scope.utmSchemaExts[$scope.mappedvalues.oldidvalue];
420 if($scope.pathDetailsArray != null && $scope.pathDetailsArray.length > 0 ) {
421 for (var k = 0; k < $scope.pathDetailsArray.length; k++) {
422 $scope.pathDetails = $scope.pathDetailsArray[k];
424 if ($scope.pathDetails != null) {
425 for (var j = 0; j < $scope.pathDetails.decisionIdentifiers.length; j++) {
426 if($scope.pathDetails.decisionIdentifiers[j].elementValues[$scope.mappedvalues.oldidvalue] != null)
427 $scope.pathDetails.decisionIdentifiers[j].elementValues[$scope.mappedvalues.newidvalue] = $scope.pathDetails.decisionIdentifiers[j].elementValues[$scope.mappedvalues.oldidvalue];
428 if($scope.mappedvalues.newidvalue != $scope.mappedvalues.oldidvalue)
429 delete $scope.pathDetails.decisionIdentifiers[j].elementValues[$scope.mappedvalues.oldidvalue];
436 $scope.schemenExts = angular.copy($scope.utmSchemaExts);
438 //If an attribute is removed from upgraded schema, remove that attribute related details from SchemaExtensions
439 Object.keys($scope.schemenExts).forEach(
441 var key_isavailable = false;
442 for (var j = 0; j < elementKeys.length; j++) {
444 /*for (var m = 0; m < checkedElementValueArray.length; m++) {
446 var currentCheckedMappedvalue = checkedElementValueArray[m];
447 if ((key.indexOf(currentCheckedMappedvalue.oldVal) > -1) && (currentCheckedMappedvalue.oldVal != currentCheckedMappedvalue.newVal)){
449 var oldvalue=currentCheckedMappedvalue.oldVal;
450 var newvalue=currentCheckedMappedvalue.newVal;
452 key= key.replace(oldvalue, newvalue);
454 elementKeys.push(key);
456 //list_model_schema_extensions[current_model].utmSchemaExtentionMap=angular.fromJson(newUTMSchemaExtentionMapObject);
460 if (elementKeys[j] === key) {
461 key_isavailable = true;
464 if (!key_isavailable) {
465 //Implement this later. Commented this as this is wiping out all the Repeatable/Heirarchical values
466 //delete $scope.utmSchemaExts[key];
471 //If an attribute is removed from upgraded schema, remove that attribute related details from PathDetails
472 if($scope.pathDetailsArray != null && $scope.pathDetailsArray.length > 0 ) {
473 for (var k = 0; k < $scope.pathDetailsArray.length; k++) {
474 $scope.pathDetails = $scope.pathDetailsArray[k];
476 for (var j = 0; j < $scope.pathDetails.decisionIdentifiers.length; j++) {
477 $scope.decisionElementValues = angular.copy($scope.pathDetails.decisionIdentifiers[j].elementValues);
478 Object.keys($scope.decisionElementValues).forEach(
480 var key_isavailable = false;
481 for (var l = 0; l < elementKeys.length; l++) {
483 /*for (var m = 0; m < checkedElementValueArray.length; m++) {
485 var currentCheckedMappedvalue = checkedElementValueArray[m];
486 if ((key.indexOf(currentCheckedMappedvalue.oldVal) > -1) && (currentCheckedMappedvalue.oldVal != currentCheckedMappedvalue.newVal)){
488 var oldvalue=currentCheckedMappedvalue.oldVal;
489 var newvalue=currentCheckedMappedvalue.newVal;
491 key= key.replace(oldvalue, newvalue);
493 //list_model_schema_extensions[current_model].utmSchemaExtentionMap=angular.fromJson(newUTMSchemaExtentionMapObject);
496 if (elementKeys[l] === key) {
497 key_isavailable = true;
500 if (!key_isavailable) {
501 //Implement this later. Commented this as this is wiping out all the Repeatable/Heirarchical values
502 //delete $scope.pathDetails.decisionIdentifiers[j].elementValues[key];
510 //console.log("List Model Path Details after Upgrade Schema :: " + JSON.stringify(list_model_path_details[current_model]));
511 //console.log("UTMSchema Extension after Upgrade Schema :: " + JSON.stringify($scope.utmSchemaExts));
514 $modalInstance.close("closed");
517 $scope.close = function() {
519 $modalInstance.close("closed");
523 function getElementkeys(parentname, schemaelement) {
524 if (schemaelement.complexType != null) {
525 var parentkey = parentname + "_" + schemaelement.complexType.name;
526 for (var i = 0; i < schemaelement.elements.length; i++) {
527 getElementkeys(parentkey, schemaelement.elements[i]);
530 if (schemaelement.element != null && schemaelement.element.name != null) {
531 var elementKey = parentname + '_' + schemaelement.element.name;
533 if(!$scope.callFromMap){
534 elementKeys.push(elementKey);
537 if($scope.oldMapValFlag){
538 $scope.oldmappedvaluesArray.push(schemaelement.element.name);
539 $scope.oldMappedvaluesKeyArray.push(elementKey);
543 $scope.newMappedvaluesArray.push(schemaelement.element.name);
544 $scope.newMappedvaluesKeyArray.push(elementKey);
551 if (schemaelement.type != null && schemaelement.type.complexType != null) {
552 var parentkey = parentname + '_' + schemaelement.element.name;
553 for (var i = 0; i < schemaelement.type.elements.length; i++) {
554 getElementkeys(parentkey, schemaelement.type.elements[i]);