[CLAMP-1] Initial ONAP CLAMP seed code commit
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / UpgradeSchemaCtrl.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
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.
22  */
23
24 var elementKeys = [];
25
26 app.directive('inputInfoUpgradeClass', function ($compile) {
27     console.log("////UpgradeSchemaCtrl");
28   return {
29       restrict: "C",
30       replace: true,
31       link: function(scope,element,attrs){
32           var elementHTML = '';
33           angular.forEach(scope.infoType.schemaElements, function(value, key){
34               
35               scope.schemaElement = value;
36               
37               if(scope.schemaElement.complexType != null){
38                   if(scope.currentElementName == ''){
39                       scope.currentElementName = scope.schemaElement.complexType.name;
40                   }
41                   
42                   scope.ParentKey = scope.parentName + '_' + scope.currentElementName;
43                   if(scope.schemaElement.repeatableHierarchicalPrefix != null){
44                       scope.ParentKey = scope.ParentKey + scope.schemaElement.repeatableHierarchicalPrefix; 
45                   }
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;
50                   
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);
67                     element.append(x);
68                     $compile(x)(scope);
69               }
70           });
71           
72       }
73   }
74 });
75
76 app.directive('inputInfoUpgradeClassMember', function ($compile) {
77   return {
78       restrict: "C",
79
80       link: function(scope,element,attrs){
81           var elementHTML = '';
82           
83           scope.currentElementName=scope.objectName;
84           scope.parentName=scope.ParentKey; 
85           scope.parentElement=scope.parElement; 
86           scope.heirarchyLevel = scope.heirLevel + 1;
87           
88           if(scope.schemaElement.element.name != null){
89               
90               scope.elementKey=scope.parentName + '_' + scope.schemaElement.element.name;
91               if(scope.schemaElement.repeatableHierarchicalPrefix != null){
92                   scope.elementKey = scope.elementKey + scope.schemaElement.repeatableHierarchicalPrefix;
93               }
94               scope.tableStyle='table-level' + scope.heirarchyLevel + '-tree'; 
95               scope.tdLabelStyle='td-level' + scope.heirarchyLevel +'-label-tree';
96               
97               if(scope.schemaElement.type.complexType != null){
98                   scope.showUTMViewMsgHeader = false;
99                   
100               }else{
101                   scope.showUTMViewMsgHeader = true;
102                   
103               }
104               
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>';
122               
123               elementHTML = elementHTML + '</tr>';
124               elementHTML = elementHTML + '</table>';
125               elementHTML = elementHTML + '';
126               elementHTML = elementHTML + '';
127               elementHTML = elementHTML + '</div>';
128               
129               var x = angular.element(elementHTML);
130                 element.append(x);
131                 $compile(x)(scope);
132               
133               
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);
143                     element.append(x);
144                     $compile(x)(scope);
145               }
146               
147           }
148
149       }
150   }
151 });
152
153 app.controller(
154                 'UpgradeSchemaCtrl',
155                 [
156                         '$scope',
157                         '$rootScope',
158                         '$modalInstance',
159                         'dialogs',
160                         function($scope, $rootScope, $modalInstance,dialogs) {
161
162                             $rootScope.Currentmappedvalues = [];
163                             $scope.utmSchemaExts = {};
164                             
165                             $scope.callFromMap=false;
166                             $scope.oldMapValFlag=false;
167                             
168                             $scope.complexMappedValuesOld = {};
169                             $scope.complexMappedValuesNew = {};
170                             var allCurrentElementKeyArray=[];
171                             
172                             $scope.checkedValues = {};
173                             var checkedElementValueArray=[];
174                             
175                             
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;
182                                 }
183                                 if(elementKey != null)
184                                     allCurrentElementKeyArray.push(elementKey);
185                             
186                             };
187                             
188                             $scope.mapElements = function() {
189                                 
190                                 var oldVal = $('input[name=oldChk]:checked')
191                                         .val();
192                                 var newVal = $('input[name=newChk]:checked')
193                                         .val();
194                                 var oldId = $('input[name=oldChk]:checked')
195                                         .attr('id');
196                                 var newId = $('input[name=newChk]:checked')
197                                         .attr('id');
198                                 $scope.mappedvalues = {};
199                                 
200                                 $scope.checkedValues.oldVal=oldVal;
201                                 $scope.checkedValues.newVal=newVal;
202                                 
203                                 checkedElementValueArray.push($scope.checkedValues);
204                                 
205                                 
206                                 $scope.oldMappedvaluesKeyArray = [];
207                                 $scope.newMappedvaluesKeyArray = [];
208                                 $scope.oldmappedvaluesArray = [];
209                                 $scope.newMappedvaluesArray = [];
210                                 
211                                 if($scope.complexMappedValuesOld[oldId] != null && $scope.complexMappedValuesNew[newId] != null){
212                                     $scope.matchType='';
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");
216                                         
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]);
221                                         }
222                                         
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]);
226                                         }
227                                         
228                                         for (var k = 0; k < $scope.oldmappedvaluesArray.length; k++) {
229                                             
230                                             $scope.mappedvalues = {};
231                                             
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);
238                                         }
239                                     }
240                                     else if($scope.matchType == "false")    {
241                                         
242                                         dialogs.error('Invalid Selection Error','The mapping of the selected elements is invalid. Please select valid complex elements for Upgrade Schema');
243                                             
244                                     }
245                                     
246                                     
247                                 }
248                                 else if(($scope.complexMappedValuesOld[oldId] == null && $scope.complexMappedValuesNew[newId] != null) || ($scope.complexMappedValuesOld[oldId] != null && $scope.complexMappedValuesNew[newId] == null)){
249                                         
250                                     dialogs.error('Invalid Selection Error','The mapping of the selected elements is invalid. Please select valid complex elements for Upgrade Schema');
251                                 }
252                                 else{
253                                     
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);
260                                 }
261                                 $rootScope.checkRepeatable = false;
262
263                             };
264                             
265                             //Utility Method to compare Object Structure of Complex Type Elements before upgrade schema
266                             $scope.compareElements = function(oldElement, newElement) {
267                                 
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]);
273                                             
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;
277                                             }
278                                             if($scope.matchType == "false")
279                                                 return $scope.matchType;
280                                             }
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;
287                                             }
288                                             if($scope.matchType == "false")
289                                                 return $scope.matchType;
290                                             }
291                                         $scope.matchType="true";
292                                         return $scope.matchType;
293                                     }
294                                     else
295                                         $scope.matchType="false";
296                                         return $scope.matchType;
297                                         
298                                 }
299                                 
300                             };
301
302
303                             $scope.checkRepeatableElement = function(
304                                     elementKey, key) {
305
306                                 if (elementKey != key)
307                                     $rootScope.checkRepeatable = true;
308
309                             };
310
311                             $scope.upgradeSchema = function() {
312                                 //console.log("List Model Path Details before Upgrade Schema :: " + JSON.stringify(list_model_path_details[selected_model]));
313                                 
314                                 $scope.callFromMap=false;
315                                 $rootScope.isHorR = true;
316                                 
317                                 $rootScope.repeatableHeirarchicalElementMap = map_model_repeatable_heirarchical_elements[selected_model];
318                                 
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]);
324                                     }
325                                     for (var j = 0; j< checkedElementValueArray.length; j++) {
326                                         var currentCheckedMappedvalue = checkedElementValueArray[j];    
327                                         if (key.indexOf(currentCheckedMappedvalue.oldVal) > -1){
328                                             
329                                             var newObject=JSON.stringify($rootScope.repeatableHeirarchicalElementMap);
330                                             
331                                             var oldvalue=currentCheckedMappedvalue.oldVal;
332                                             var newvalue=currentCheckedMappedvalue.newVal;
333                                             
334                                             var modObject= newObject.replace(oldvalue, newvalue);
335                                         
336                                             $rootScope.repeatableHeirarchicalElementMap=angular.fromJson(modObject);
337                                             
338                                             /*for (var k = 0; k < elementKeys.length; k++) {
339                                                 
340                                                 if (elementKeys[k].indexOf(currentCheckedMappedvalue.oldVal) > -1){
341                                                     
342                                                 elementKeys[k]=elementKeys[k].replace(oldvalue, newvalue);
343                                                     
344                                                 }
345                                                 
346                                             }*/
347                                             
348                                         }
349                                     }
350                                     
351                                 }
352                                 
353                                 
354                                 $scope.oldSchemaLocation = $rootScope.wsdlInfo.schemaLocation;
355                                 $rootScope.wsdlInfo = $rootScope.updateWsdlInfo;
356                                 $rootScope.wsdlInfo.schemaUpgradedFlag = true;
357                                 $rootScope.wsdlInfo.oldSchemaLocation = $scope.oldSchemaLocation;
358                                 
359                                 $rootScope.serviceInfo = $rootScope.updateServiceInfo;
360                                 $rootScope.schemaLocation = $rootScope.updateWsdlInfo.schemaLocation;
361                                 $rootScope.serviceInput = $rootScope.updateServiceInput;
362                                 $rootScope.serviceInputPartInfo = $rootScope.updateServiceInputPartInfo;
363                                 
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);
370
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++) {
374                                         getElementkeys(
375                                                 'ServiceInput',
376                                                 $rootScope.serviceInputPartInfo[i].schemaElements[j]);
377                                     }
378                                 }
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++) {
383                                         getElementkeys(
384                                                 'ServiceOutput',
385                                                 $rootScope.serviceOutputPartInfo[i].schemaElements[j]);
386                                     }
387                                 }
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++) {
392                                         getElementkeys(
393                                                 'ServiceFault',
394                                                 $rootScope.servicefaultPartInfo[i].schemaElements[j]);
395                                     }
396                                 }
397                                 console.log("mapped values of current"+ JSON.stringify($rootScope.Currentmappedvalues));
398                                 
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];
410                                 
411                                     for (var i = 0; i < $rootScope.Currentmappedvalues.length; i++) {
412                                         $scope.mappedvalues = $rootScope.Currentmappedvalues[i];
413     
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];
418                                         }
419                                         
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];
423                                                 
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];
430                                                     }
431                                                 }
432                                             }
433                                         }
434                                     }
435                                     
436                                     $scope.schemenExts = angular.copy($scope.utmSchemaExts);
437     
438                                     //If an attribute is removed from upgraded schema, remove that attribute related details from SchemaExtensions
439                                     Object.keys($scope.schemenExts).forEach(
440                                         function(key) {
441                                             var key_isavailable = false;
442                                             for (var j = 0; j < elementKeys.length; j++) {
443                                                 
444                                                 /*for (var m = 0; m < checkedElementValueArray.length; m++) {
445                                                     
446                                                     var currentCheckedMappedvalue = checkedElementValueArray[m];
447                                                     if ((key.indexOf(currentCheckedMappedvalue.oldVal) > -1) && (currentCheckedMappedvalue.oldVal != currentCheckedMappedvalue.newVal)){
448                                                     
449                                                         var oldvalue=currentCheckedMappedvalue.oldVal;
450                                                         var newvalue=currentCheckedMappedvalue.newVal;
451                                                         
452                                                         key= key.replace(oldvalue, newvalue);
453                                                         
454                                                         elementKeys.push(key);
455                                                     
456                                                         //list_model_schema_extensions[current_model].utmSchemaExtentionMap=angular.fromJson(newUTMSchemaExtentionMapObject);
457                                                     }
458                                                 }*/
459                                                 
460                                                 if (elementKeys[j] === key) {
461                                                     key_isavailable = true;
462                                                 }
463                                             }
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];
467                                             }
468                                         }
469                                     );
470                                     
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];
475     
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(
479                                                     function(key) {
480                                                         var key_isavailable = false;
481                                                         for (var l = 0; l < elementKeys.length; l++) {
482                                                             
483                                                             /*for (var m = 0; m < checkedElementValueArray.length; m++) {
484                                                                 
485                                                                 var currentCheckedMappedvalue = checkedElementValueArray[m];
486                                                                 if ((key.indexOf(currentCheckedMappedvalue.oldVal) > -1) && (currentCheckedMappedvalue.oldVal != currentCheckedMappedvalue.newVal)){
487                                                                 
488                                                                     var oldvalue=currentCheckedMappedvalue.oldVal;
489                                                                     var newvalue=currentCheckedMappedvalue.newVal;
490                                                                     
491                                                                     key= key.replace(oldvalue, newvalue);
492                                                                 
493                                                                     //list_model_schema_extensions[current_model].utmSchemaExtentionMap=angular.fromJson(newUTMSchemaExtentionMapObject);
494                                                                 }
495                                                             }*/
496                                                             if (elementKeys[l] === key) {
497                                                                 key_isavailable = true;
498                                                             }
499                                                         }
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];
503                                                         }
504                                                     }
505                                                 );
506                                             }
507                                         }
508                                     }
509     
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));
512                                     
513                                 }
514                                 $modalInstance.close("closed");
515                             };
516                             
517                             $scope.close = function() {
518
519                                 $modalInstance.close("closed");
520                             };
521                             
522                             
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]);
528                                     }
529                                 }
530                                 if (schemaelement.element != null && schemaelement.element.name != null) {
531                                     var elementKey = parentname + '_' + schemaelement.element.name;
532                                     
533                                     if(!$scope.callFromMap){
534                                         elementKeys.push(elementKey);
535                                     }
536                                     else{
537                                         if($scope.oldMapValFlag){
538                                             $scope.oldmappedvaluesArray.push(schemaelement.element.name);
539                                             $scope.oldMappedvaluesKeyArray.push(elementKey);
540                                         }
541                                         else{
542                                             
543                                             $scope.newMappedvaluesArray.push(schemaelement.element.name);
544                                             $scope.newMappedvaluesKeyArray.push(elementKey);
545                                         }
546                                     }
547                                         
548                                     
549                                     
550                                 }
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]);
555                                     }
556                                 }
557                             }
558
559                         }]);
560