Add new actions DownloadNESw and ActivateNESw for CDT
[appc/cdt.git] / src / app / vnfs / build-artifacts / reference-dataform / reference-dataform.component.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
6
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software 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
20 ============LICENSE_END============================================
21 */
22
23 import * as XLSX from 'xlsx';
24 import * as _ from 'underscore';
25
26 import { ActivatedRoute, Router } from '@angular/router';
27 import { Component, OnInit, ViewChild } from '@angular/core';
28 import { Observable } from 'rxjs/Observable';
29 import { BuildDesignComponent } from '../build-artifacts.component';
30 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
31 import { Location } from '@angular/common';
32 import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
33 import { NgProgress } from 'ngx-progressbar';
34 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
35 import { NotificationService } from '../../../shared/services/notification.service';
36 import { NotificationsService } from 'angular2-notifications';
37 import { ParamShareService } from '../../..//shared/services/paramShare.service';
38 import { environment } from '../../../../environments/environment';
39 import { saveAs } from 'file-saver';
40 import { Jsonp } from '@angular/http';
41 import { ReferenceDataFormUtil } from './reference-dataform.util';
42 import { UtilityService } from '../../../shared/services/utilityService/utility.service';
43 import { APIService } from "../../../shared/services/cdt.apicall";
44
45 // Common Confirm Modal
46 import { DialogService } from 'ng2-bootstrap-modal';
47 import { ConfirmComponent } from "../../../shared/confirmModal/confirm.component";
48
49
50 declare var $: any;
51 type AOA = Array<Array<any>>;
52
53 @Component({
54     selector: 'reference-dataform',
55     templateUrl: './reference-dataform.component.html',
56     styleUrls: ['./reference-dataform.component.css'],
57     providers: [ReferenceDataFormUtil]
58 })
59 export class ReferenceDataformComponent implements OnInit {
60     public classNm= "ReferenceDataformComp";
61     public showUploadStatus: boolean = false;
62     public fileUploaded: boolean = false;
63     public uploadedData: any;
64     public statusMsg: string;
65     public uploadStatus: boolean = false;
66     public isCollapsedContent: boolean = true;
67     public vnfcCollLength: number = 0;
68     public vfncCollection = [];
69     public userForm: any;
70     public actionType: any;
71     numberTest: RegExp = /^[^.a-z]+$/;
72     public numberOfVmTest: boolean = true;
73     public tempAllData = [];
74     disableGrpNotationValue: boolean;
75     public noRefData = false;
76     public disableRetrieve = false;
77     public getRefStatus = false;
78     public uploadStatusError: boolean;
79     public showUploadErrorStatus: boolean;
80     public noData: string;
81     selectedActions = [];
82     public appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
83     public downloadData = {
84         reference: {},
85         template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
86         pd: { pdData: '', pdFileName: '' }
87     };
88     errorMessage = '';
89     invalid = true;
90     fileName: any;
91     vnfcIdentifier;
92     oldVnfcIdentifier: any
93     public uploadFileName: any;
94     public addVmClickedFlag: boolean = false;
95     public getExcelUploadStatus: boolean = false;
96     public uploadedDataArray: any;
97     public actionFlag = false;
98     currentAction: any;
99     oldAction: any;
100     nonConfigureAction: any;
101     templateId;
102     newVnfcType;
103     templateIdentifier;
104     public actionLevels = [
105         'vnfc', 'vnf'
106     ];
107     oldtemplateIdentifier: any
108     identifierDrp: any;
109     identifierDrpValues: any = [];
110     //settings for the notifications.
111     options = {
112         timeOut: 4500,
113         showProgressBar: true,
114         pauseOnHover: true,
115         clickToClose: true,
116         maxLength: 200
117     };
118     //initializing this object to contain all the parameters to be captured later
119     public referenceDataObject = {
120         action: '',
121         'action-level': 'vnf',
122         scope: { 'vnf-type': '', 'vnfc-type-list': [] },
123         'template': 'Y',
124         vm: [],
125         'device-protocol': '',
126         'user-name': '',
127         'port-number': '',
128         'artifact-list': []
129     };
130     public refernceScopeObj = { sourceType: '', from: '', to: '' };
131     public actions = ['', // using comma as prefix hereafter for easy reordering
132         , 'ConfigBackup'
133         , 'ConfigModify'
134         , 'ConfigRestore'
135         , 'ConfigScaleOut'
136         , 'ConfigScaleIn'
137         , 'Configure'
138         , 'DistributeTraffic'
139         , 'DistributeTrafficCheck'
140         , 'GetConfig'
141         , 'GetRunningConfig'
142         , 'HealthCheck'
143         , 'LicenseManagement'
144         , 'PostConfigure'
145         , 'PostEvacuate'
146         , 'PostMigrate'
147         , 'PostRebuild'
148         , 'PreConfigCheck'
149         , 'PreConfigure'
150         , 'PreEvacuate'
151         , 'PreMigrate'
152         , 'PreRebuild'
153         , 'ProvisionConfig'
154         , 'ProvisionData'
155         , 'Provisioning'
156         , 'QuiesceTraffic'
157         , 'ResumeTraffic'
158         , 'StartApplication'
159         , 'StartTraffic'
160         , 'StatusTraffic'
161         , 'StopApplication'
162         , 'StopTraffic'
163         , 'UpgradeBackout'
164         , 'UpgradeBackup'
165         , 'UpgradePostCheck'
166         , 'UpgradePreCheck'
167         , 'UpgradeSoftware'
168         , 'DownloadNESw'
169         , 'ActivateNESw'
170         , 'OpenStack Actions'
171         ]; //.. manual ordering
172     public groupAnotationValue = ['', 'Pair'];
173     public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
174     public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
175     public deviceTemplates = ['', 'Y', 'N'];
176     public sourceTypeColl = ['', 'vnfType', 'vnfcType'];
177     public ipAddressBoolean = ['', 'Y', 'N'];
178     public Sample: any = {
179         'vnfc-instance': '1',
180         'vnfc-function-code': '',
181         'ipaddress-v4-oam-vip': '',
182         'group-notation-type': '',
183         'group-notation-value': ''
184     };
185     hideModal: boolean = false;
186     public self: any;
187     public uploadTypes = [{
188         value: 'Reference Data',
189         display: 'Sample Json Param File'
190     },
191     {
192         value: 'Mapping Data',
193         display: 'Sample Json Param File'
194     }
195     ];
196     public selectedUploadType: string = this.uploadTypes[0].value;
197     public vnfcTypeData: string = '';
198     public title: string;
199     public allowAction: boolean = true;
200     public actionExist: boolean = false;
201     public disableVnftype: boolean = false;
202     public otherActions: boolean = false;
203     public actionHealthCheck: boolean = false;
204     public actionChanged: boolean = false;
205     public initialAction: string = '';
206     public noCacheData: boolean;
207     public updateParams: any;
208     public vnfParams: any;
209     public firstArrayElement = [];
210     public remUploadedDataArray = [];
211     isConfigScaleOut = false
212     isConfigScaleIn = false
213     isConfigOrConfigModify = false
214     displayVnfc = 'false';
215     isVnfcType: boolean;
216     isVnfcTypeList: boolean = true;
217     public referencDataTab = [
218         {
219
220             name: 'Reference Data',
221             url: 'references',
222         }];
223     public allTabs = [
224         {
225             name: 'Reference Data',
226             url: 'references',
227         }, {
228             name: 'Template',
229             url: 'templates/myTemplates',
230         }, {
231             name: 'Parameter Definition',
232             url: 'parameterDefinitions/create'
233         }/*, {
234                     name: "Test",
235                     url: 'test',
236                 }*/
237     ];
238     public actionList = require('../../../../cdt.application.properties.json').Actions;
239     
240     public versionNoForApiCall = require('../../../../cdt.application.properties.json').versionNoForApiCall;
241     private displayVMBlock: boolean = true;
242
243     constructor(
244       private buildDesignComponent: BuildDesignComponent, private apiService: APIService, private utilityService: UtilityService, private httpUtils: HttpUtilService, private referenceDataFormUtil: ReferenceDataFormUtil, private route: Router, private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService,
245         private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService, private ngProgress: NgProgress,
246         private dialogService: DialogService)
247     {
248       console.log(this.classNm+
249         ": new: start: tracelvl="+this.utilityService.getTracelvl() );
250     }
251
252     ngOnInit() {
253       let methName= "ngOnInit";
254       if( this.utilityService.getTracelvl() > 0 )
255         console.log( this.classNm+": "+methName+": start ");
256         // this.handleVMBlockDisplay();
257       if( this.utilityService.getTracelvl() > 0 ) {
258         console.log( this.classNm+": "+methName+
259           ": actions: count="+this.actions.length );
260         for( var i0=0; i0 < this.actions.length; i0++ ) {
261           console.log( this.classNm+": "+methName+
262             ": action #"+i0+" ["+this.actions[i0]+"]");
263         };
264       };
265       this.self = this;
266         let path = this.location.path;
267         this.title = 'Reference Data';
268       this.displayVnfc = sessionStorage.getItem("vnfcSelectionFlag");
269       this.vnfcIdentifier= ' ';
270       if( this.utilityService.getTracelvl() > 0 )
271         console.log( this.classNm+": "+methName+
272           ": from storage: displayVnfc:["+this.displayVnfc+"]");
273       //.. setting the structure for the reference data object 
274         this.referenceDataObject = {
275             action: '',
276             'action-level': 'vnf',
277             scope: { 'vnf-type': '', 'vnfc-type-list': [] },
278             'template': 'Y',
279             vm: [],
280             'device-protocol': '',
281             'user-name': '',
282             'port-number': '',
283             'artifact-list': []
284         };
285         //getting the data from session data, calling get Artifact if the data is undefined
286         this.updateParams = sessionStorage.getItem('updateParams');
287         //getting the data from the referencenameobjects if the nav is changed and assiging it to the cace data
288         let cacheData = this.mappingEditorService.referenceNameObjects;
289
290         if (this.utilityService.checkNotNull(cacheData)) {
291             //if cache data exists then assiging the data to the latest temp all data object.
292           if( this.utilityService.getTracelvl() > 0 )
293             console.log( this.classNm+": ngOnInit: have cacheData.");
294             this.tempAllData = cacheData;
295             //calling the highligted method to highlight the selected actions in the action dropdown
296             this.highlightSelectedActions(this.tempAllData)
297             // getting the latest action that the user has selected and assiging it to the reference data object once the user toggles between tabs from reference
298             if (this.mappingEditorService.latestAction != undefined) {
299                 //adding the latest action to the screen
300                 this.referenceDataObject = this.mappingEditorService.latestAction;
301                 this.toggleIdentifier(this.referenceDataObject.action);
302                 //this.referenceDataObject['template-id-list'] = this.mappingEditorService.identifier
303                 //use these commented objects to be used in template and pd pages
304                 //this.templateIdentifier = this.mappingEditorService.identifier
305                 //adding the scope from referencedata obj to referencescopeobject
306                 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
307                 //assigning the latest action fetched to the old action from reference data object
308                 this.oldAction = this.referenceDataObject.action;
309                 //this method is called with the action reterived and subsequent values are assigned to refdataobj for displaying
310                 this.populateExistinAction(this.referenceDataObject.action);
311                 this.displayHideVnfc();
312             }
313         } else if (this.updateParams != 'undefined') {
314             //calls the get artifact() to reterive the values if cache data is not present
315             this.getArtifact();
316         }
317         //getting the appdata & downloadDataObject from mapping editor service and assiging it.
318         var appData = this.mappingEditorService.appDataObject;
319         if (appData != null || appData != undefined) this.appData = appData;
320         var downloadData = this.mappingEditorService.downloadDataObject;
321         if (downloadData != null || downloadData != undefined) this.downloadData = downloadData;
322
323         if (sessionStorage.getItem('vnfParams')) {
324             this.vnfParams = JSON.parse(sessionStorage.getItem('vnfParams'));
325         }
326         if (this.vnfParams && this.vnfParams.vnfType) {
327           if( this.utilityService.getTracelvl() > 0 )
328             console.log( this.classNm+": "+methName+": vnfParams.vnfType:["+
329               this.vnfParams.vnfType+"]");
330             this.referenceDataObject['scope']['vnf-type'] = this.vnfParams.vnfType;
331         }
332         if (this.vnfParams && this.vnfParams.vnfcType) {
333           if( this.utilityService.getTracelvl() > 0 )
334             console.log( this.classNm+": "+methName+": vnfParams.vnfcType:["+
335               this.vnfParams.vnfcType+"]");
336             this.referenceDataObject['scope']['vnfc-type'] = this.vnfParams.vnfcType;
337         }
338         this.uploadedDataArray = [];
339         this.remUploadedDataArray = [];
340         this.firstArrayElement = [];
341         this.uploadFileName = '';
342         this.templateIdentifier = this.mappingEditorService.identifier
343         // if (this.mappingEditorService.newObject) {
344         //     this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
345         // }
346         // else {
347         //     this.vnfcIdentifier = '';
348         //     this.referenceDataObject['vnfcIdentifier'] = '';
349         // }
350         this.oldVnfcIdentifier = this.vnfcIdentifier;
351         if( this.utilityService.getTracelvl() > 1 )
352           console.log( this.classNm+": "+methName+": displayVnfc:["+
353             this.displayVnfc+"]");
354         if( this.utilityService.getTracelvl() > 1 )
355           console.log( this.classNm+": "+methName+": templateIdentifier:["+
356             this.templateIdentifier+"]");
357         // Enable or Block Template and PD Tabs
358         this.buildDesignComponent.getRefData(
359           { ...this.referenceDataObject, displayVnfc: this.displayVnfc },
360           { reqField: this.templateIdentifier });
361         //.. configure some drop-downs
362         this.configDrp(this.referenceDataObject.action);
363         if( this.utilityService.getTracelvl() > 0 )
364           console.log( this.classNm+": "+methName+": tempAllData:["+
365             JSON.stringify(this.tempAllData)+"]");
366         if( this.utilityService.getTracelvl() > 0 )
367           console.log( this.classNm+": "+methName+": finish.");
368     }
369
370     //setting the value to display or hide the template identifier dropdown in the screen
371     toggleIdentifier(data) {
372         if (data == 'ConfigScaleOut') {
373             this.isConfigScaleOut = true
374
375         } else {
376             this.isConfigScaleOut = false
377         }
378
379         if (data == 'ConfigScaleIn') {
380             this.isConfigScaleIn = true;
381         } else {
382             this.isConfigScaleIn = false;
383         }
384     }
385
386     //to retrive the data from appc and assign it to the vaiables, if no data display the message reterived from the API
387     getArtifact() {
388         if( this.utilityService.getTracelvl() > 0 )
389           console.log(this.classNm+": getArtifact: start...");
390         try {
391             // setting the isVnfcTypeList & isVnfcType to false initially
392             this.isVnfcTypeList = false;
393             this.isVnfcType = false
394             let data = this.utilityService.createPayloadForRetrieve(true, '', '', '');
395             this.ngProgress.start();
396             let serviceCall = this.apiService.callGetArtifactsApi(data);
397             serviceCall.subscribe(resp => {
398                 //getting the response and assigining it to the variables used and end the progress bar aftr the data is fetched.
399                 if (resp.output.data.block != undefined) {
400                     this.nService.success('Status', 'data fetched ');
401                     let artifactInfo = JSON.parse(resp.output.data.block).artifactInfo[0];
402                     let referenceDataAll = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
403                     let reference_data = JSON.parse(artifactInfo['artifact-content'])['reference_data'][0];
404                     this.referenceDataObject = reference_data;
405                     this.toggleIdentifier(this.referenceDataObject.action);
406                     if (this.referenceDataObject.action == 'ConfigScaleOut') {
407                         this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
408                     }
409                     if (this.referenceDataObject.action == 'ConfigScaleIn') {
410                         this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
411                     }
412                     this.highlightSelectedActions(referenceDataAll)
413                     
414                     //chck vnfc or vnfcTypeList
415                     this.displayHideVnfc();
416                     
417                     // Enable or Block Template and PD Tabs
418                     this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
419
420                     this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
421                     this.mappingEditorService.getReferenceList().push(JSON.parse(artifactInfo['artifact-content']));
422                     this.tempAllData = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
423                     this.oldAction = this.referenceDataObject.action;
424                     this.oldVnfcIdentifier = this.vnfcIdentifier;
425
426                     this.processReferenceDataAfterRetrieval();
427                     this.getArtifactsOpenStack();
428                 } else {
429                     this.nService.success('Status', 'Sorry !!! I dont have any artifact Named : ' + (JSON.parse(sessionStorage.getItem('updateParams')))['artifact-name']);
430                 }
431                 this.ngProgress.done();
432             });
433         }
434         catch (e) {
435             this.nService.warn('status', 'error while reteriving artifact');
436         }
437         setTimeout(() => {
438             this.ngProgress.done();
439         }, 3500);
440     }
441
442     displayHideVnfc() {
443         if( this.utilityService.getTracelvl() > 0 )
444           console.log(this.classNm+": displayHideVnfc: start...");
445         if( this.utilityService.getTracelvl() > 1 ) {
446           if( this.referenceDataObject.scope['vnfc-type-list'] ) {
447             console.log( this.classNm+
448               ": displayHideVnfc: refDataObj.scope.vnfc-type-list.length="+
449               this.referenceDataObject.scope['vnfc-type-list'].length );
450           } else {
451             console.log( this.classNm+
452               ": displayHideVnfc: refDataObj.scope.vnfc-type-list not defined");
453           };
454           console.log( this.classNm+": displayHideVnfc: scope.vnfc-type:["+
455             this.referenceDataObject.scope['vnfc-type']+"]");
456         };
457         if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && (this.referenceDataObject.scope['vnfc-type'] != undefined || this.referenceDataObject.scope['vnfc-type'] != "")) {
458             this.isVnfcType = true
459             this.displayVnfc = 'true'
460             this.isVnfcTypeList = false
461         }
462         if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length != 0 && (this.referenceDataObject.scope['vnfc-type'] == undefined || this.referenceDataObject.scope['vnfc-type'] == "")) {
463             this.isVnfcType = false
464             this.displayVnfc = 'true'
465             this.isVnfcTypeList = true
466             if(!this.mappingEditorService.newObject || !this.mappingEditorService.newObject.vnfc) {
467                 this.vnfcIdentifier = this.referenceDataObject.scope['vnfc-type-list'][0];
468                 // this.mappingEditorService.newObject.vnfc = this.vnfcIdentifier;
469             } else {
470                 this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
471             }
472             this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
473             //this.vnfcChanged(this.vnfcIdentifier, FormData);
474             if( this.utilityService.getTracelvl() > 0 )
475               console.log(this.classNm+": displayHideVnfc: vnfcIdentifier:["+
476                 this.vnfcIdentifier+"]");
477         }
478         if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length == 0 && this.referenceDataObject.scope['vnfc-type'] != undefined && this.referenceDataObject.scope['vnfc-type'].length == 0) {
479             if(this.displayVnfc == 'true') {
480                 this.isVnfcType = false
481                 this.displayVnfc = 'true'
482                 this.isVnfcTypeList = true
483             } else {
484                 this.isVnfcType = false
485                 this.displayVnfc = 'false'
486                 this.isVnfcTypeList = false
487             }
488         }
489         if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && this.referenceDataObject.scope['vnfc-type'] == '') {
490             this.isVnfcType = false
491             this.displayVnfc = 'false'
492             this.isVnfcTypeList = false
493         }
494       if( this.utilityService.getTracelvl() > 0 )
495         console.log(this.classNm+": displayHideVnfc: finish. isVnfcType:["+
496           this.isVnfcType+" displayVnfc:["+this.displayVnfc+"] isVnfcTypeList:["+
497           this.isVnfcTypeList+"]");
498     }
499
500     //reinitializing the required values. when changing to template or pd sending the values to mapping service
501     ngOnDestroy() {
502         let referenceObject = this.prepareReferenceObject();
503         this.mappingEditorService.changeNavAppData(this.appData);
504         this.mappingEditorService.changeNavDownloadData(this.downloadData);
505         this.uploadedDataArray = [];
506         this.remUploadedDataArray = [];
507         this.firstArrayElement = [];
508         this.uploadFileName = '';
509     }
510     // vaidating the number
511     numberValidation(event: any) {
512         if (this.numberTest.test(event) && event != 0) {
513             this.numberOfVmTest = true;
514         }
515         else {
516             this.numberOfVmTest = false;
517         }
518     }
519     // update my vnf pop up session values
520     updateSessionValues(event: any, type: string) {
521       if( this.utilityService.getTracelvl() > 0 )
522         console.log(this.classNm+": updateSessionValues: type:["+type+"]");
523         if (type === 'action') {
524             sessionStorage.setItem('action', event);
525         }
526         if (type === 'vnfType') {
527             sessionStorage.setItem('vnfType', event);
528         }
529     }
530     // adding vnfc data for each vm
531     addVnfcData(vmNumber: number) {
532       if( this.utilityService.getTracelvl() > 0 )
533         console.log(this.classNm+": addVnfcData: start: vmNumber="+ vmNumber);
534         var newObj = {
535             'vnfc-instance': this.referenceDataObject.vm[vmNumber].vnfc.length + 1,
536             'vnfc-type': this.vnfcTypeData,
537             'vnfc-function-code': '',
538             'ipaddress-v4-oam-vip': '',
539             'group-notation-type': '',
540             'group-notation-value': ''
541         };
542         this.referenceDataObject.vm[vmNumber].vnfc.push(newObj);
543     }
544     //validating the vnf and vnfc data in the pop up
545     validateVnfcName(name) {
546       if( this.utilityService.getTracelvl() > 0 )
547         console.log( this.classNm+": validateVnfcName: start: name:["+name+"]");
548         if (!name.trim() || name.length < 1) {
549             this.errorMessage = '';
550             this.invalid = true;
551         } else if (name.startsWith(' ') || name.endsWith(' ')) {
552             this.errorMessage = 'Leading and trailing spaces are not allowed';
553             this.invalid = true;
554         } else if (name.includes('  ')) {
555             this.errorMessage = 'More than one space is not allowed in VNFC Type';
556             this.invalid = true;
557         } else if (name.length > 50) {
558             this.errorMessage = 'VNFC Type should be of minimum one character and maximum 50 character';
559             this.invalid = true;
560         } else {
561             this.invalid = false;
562             this.errorMessage = '';
563         }
564     }
565
566
567     //to remove the VM's created by the user
568     removeFeature(vmNumber: any, index: any, templateId) {
569         if (this.referenceDataObject.action == "Configure") {
570             this.referenceDataObject.vm.splice(vmNumber, 1);
571             this.referenceDataObject.vm.forEach((obj, arrIndex) => {
572                 if (arrIndex >= vmNumber) {
573                     obj["vm-instance"] = obj["vm-instance"] - 1
574                 }
575                 // obj["vm-instance"] = arrIndex+1
576
577             })
578         } else {
579             let data = this.referenceDataObject.vm.filter(obj => {
580                 return obj['template-id'] == templateId;
581             })
582
583             let vmIndex = this.findVmindex(data, vmNumber, templateId)
584             this.referenceDataObject.vm.splice(vmIndex, 1);
585             let index = 0
586             this.referenceDataObject.vm.forEach((obj, arrIndex) => {
587                 if (obj['template-id'] == templateId) {
588
589                     obj["vm-instance"] = index + 1
590                     index++
591                 }
592
593             })
594         }
595
596     }
597     //utility function while adding VM to check index
598     findVmindex(data, vmNumber, templateId) {
599         return this.referenceDataObject.vm.findIndex(obj => {
600             let x = obj['vm-instance'] == (vmNumber + 1) && templateId == obj['template-id']//true
601             return x
602         })
603
604     }
605
606     //add new VM's to the configure and configmodify. 
607     addVms() {
608         let arr = [];
609
610         let mberOFVm = Number(this.refernceScopeObj.from);
611         let key
612         if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
613             key = "vnfcType-id"
614         } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
615             key = "template-id"
616         }
617         if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
618             let existingVmsLength = this.referenceDataObject.vm.map(obj => {
619                 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
620                     return obj["vnfcType-id"] == this.templateIdentifier
621                 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
622                     return obj["template-id"] == this.templateIdentifier
623                 }
624             }).length;
625             //mberOFVm = existingVmsLength + mberOFVm;
626             let index = 0;
627             let identifierValue
628             if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
629                 identifierValue = this.templateIdentifier
630             } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify'  || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
631                 identifierValue = this.vnfcIdentifier
632             }
633
634             for (var i = 0; i < mberOFVm; i++) {
635                 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
636
637                     if (identifierValue && identifierValue != "") {
638                         this.referenceDataObject.vm.push({ 'vnfcType-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
639                     } else {
640                         this.referenceDataObject.vm.push({ 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
641                     }
642
643                 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
644                     if (identifierValue && identifierValue != "") {
645                         this.referenceDataObject.vm.push({ 'template-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
646                     }
647
648                 }
649
650                 index++;
651             }
652
653         } else {
654             let arrlength = this.referenceDataObject.vm.length;
655             mberOFVm = arrlength + mberOFVm;
656             for (var i = (arrlength); i < mberOFVm; i++) {
657                 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
658                     this.referenceDataObject.vm.push({ 'template-id': this.templateIdentifier, 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
659                 } else {
660                     this.referenceDataObject.vm.push({ 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
661                 }
662             }
663         }
664     }
665
666     //preparing reference obj with required business use cases
667     prepareReferenceObject(isSaving?: any) {
668       let methName= "prepareReferenceObject";
669       if( this.utilityService.getTracelvl() > 0 )
670         console.log( this.classNm+": "+methName+": start: isSaving:["+
671           isSaving+"]");
672         let scopeName = this.resetParamsOnVnfcType();
673         let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
674         this.prepareArtifactList(scopeName, extension);
675
676         if (this.referenceDataObject.action === 'OpenStack Actions') {
677             this.referenceDataObject['template'] = 'N';
678             this.referenceDataObject['artifact-list'] = [];
679             this.referenceDataObject['firstRowVmSpreadSheet'] = this.firstArrayElement;
680         }
681         else{
682             this.referenceDataObject['firstRowVmSpreadSheet']=undefined;
683         }
684         //ditaching the object from the form and processing pfurther
685         let newObj = $.extend(true, {}, this.referenceDataObject);
686         let action = this.referenceDataObject.action;
687         // if (action=="ConfigScaleOut"){
688         //     this.referenceDataObject.action="true";
689         // }
690         //preparing Obj for save/download
691         newObj = this.deleteVmsforNonActions(newObj, action)
692
693         if (newObj['device-protocol'] != 'REST') {
694             delete newObj['url']
695         }
696         this.pushOrReplaceTempData(newObj, action);
697         this.addAllActionObj(newObj, scopeName);
698         this.resetTempData()
699
700
701         //rmove context url
702         //if()
703         //saving data to service
704         this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
705         this.buildDesignComponent.updateAccessUpdatePages(this.referenceDataObject.action, this.mappingEditorService.getReferenceList());
706         this.mappingEditorService.changeNav(this.tempAllData);
707         //on action change or template identifier change reset the form by restting values of Reference data object
708         this.resetVmsForScaleout(this.currentAction)
709         return { totlaRefDtaa: this.tempAllData, scopeName: scopeName };
710     }
711
712     // utility function to check element existence
713     public checkIfelementExistsInArray(element, array) {
714         var result: boolean = false;
715
716         array.forEach(function (item) {
717             if (element === item) {
718                 result = true;
719             }
720         }
721         );
722         return result;
723     }
724     // when uploading the file 
725     upload(evt: any) {
726         /* wire up file reader */
727         const target: DataTransfer = <DataTransfer>(evt.target);
728         this.uploadFileName = evt.target.files[0].name;
729         var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
730         if (target.files.length != 1) {
731             throw new Error('Cannot upload multiple files on the entry');
732         }
733         if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') {
734             const reader = new FileReader();
735             reader.onload = (e: any) => {
736                 /* read workbook */
737                 const bstr = e.target.result;
738                 const wb = XLSX.read(bstr, { type: 'binary' });
739                 /* grab first sheet */
740                 const wsname = wb.SheetNames[0];
741                 const ws = wb.Sheets[wsname];
742
743                 /* save data */
744                 this.firstArrayElement = []
745                 let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
746                 this.uploadedDataArray = arrData;
747                 for (var i = 0; i < arrData[0].length; i++) {
748                     this.firstArrayElement.push(arrData[0][i].replace(/[\n\r]+/g, ''))
749                 }
750                 var remUploadedDataArray = arrData;
751                 remUploadedDataArray.shift();
752                 this.remUploadedDataArray = remUploadedDataArray;
753                 if (arrData != null) {
754                     this.getExcelUploadStatus = true;
755                     this.nService.success('Success', 'Vm capabilities data uploaded successfully');
756
757                 }
758                 else {
759                     this.nService.success('Error', 'Empty Vm capabilities file uploaded');
760                 }
761             };
762             reader.readAsBinaryString(target.files[0]);
763         }
764         else {
765             this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
766         }
767
768     }
769
770     addVmCapabilitiesData() {
771         for (var i = 0; i < this.uploadedDataArray.length; i++) {
772             var vnfcFuncCodeArray = [];
773             var data = this.uploadedDataArray[i];
774             for (var j = 1; j < data.length; j++) {
775                 if (data[j] != undefined) {
776                     if (data[j].toUpperCase() === 'Y') {
777                         vnfcFuncCodeArray.push(this.firstArrayElement[j]);
778                         //vnfcFuncCodeArray.push({name:this.firstArrayElement[j]});
779                     }
780                 }
781             }
782             var action = this.uploadedDataArray[i][0];
783             if (action && action != undefined) {
784                 var json = {
785                     'action': action,
786                     'action-level': 'vm',
787                     'scope': {
788                         'vnf-type': this.referenceDataObject['scope']['vnf-type'], //need to confirm what should be this value
789                         'vnfc-type-list': null
790                     },
791                     'vnfc-function-code-list': vnfcFuncCodeArray,
792                     'template': 'N',
793                     'device-protocol': 'OS'
794                 };
795
796                 this.tempAllData.push(json);
797             }
798
799         }
800     }
801
802     //download the templae pd and reference file with all the actions added.
803     save(form: any, isValid: boolean) {
804         // will show error message
805         this.showValidationErrors(this.referenceDataObject);
806
807         if (isValid) {
808             let referenceObject = this.prepareReferenceObject();
809             let removedKeysArray = []
810             this.tempAllData.forEach((data, index) => {
811                 if (data.action) {
812                     removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
813                 }
814             });
815             this.tempAllData = removedKeysArray;
816            /* var tempAllData = this.tempAllData;
817             tempAllData=this.removeParamFileNameBeforeSave(tempAllData)*/
818             
819             //tempAllData["artifact_list"]=newArtifactList;
820             let theJSON = JSON.stringify({ 'reference_data': this.tempAllData }, null, '\t');
821             let uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(theJSON);
822             this.downloadData.reference = theJSON;
823             let referenceFileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
824             this.utilityService.downloadArtifactToPc(theJSON, 'json', referenceFileName, 100);
825             this.validateTempAllData();
826             var templateData = JSON.stringify(this.downloadData.template.templateData);
827             var templateFileName = this.downloadData.template.templateFileName;
828             if (templateFileName != null || templateFileName != '') {
829                 var fileExtensionArr = templateFileName.split('.');
830             }
831             var nameValueFileName = this.downloadData.template.nameValueFileName;
832             let pdFileName = this.downloadData.pd.pdFileName;
833             var nameValueData = JSON.stringify(this.downloadData.template.nameValueData);
834             var pdData = this.downloadData.pd.pdData;
835             if (templateData != '{}' && templateData != null && templateData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.templateData, fileExtensionArr[1], templateFileName, 130);
836             if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.nameValueData, 'json', nameValueFileName, 160);
837             if (pdData != '' && pdData != null && pdData != undefined) this.utilityService.downloadArtifactToPc(pdData, 'yaml', pdFileName, 180);
838         }
839     }
840
841   /*  removeParamFileNameBeforeSave(tempAllData)
842     {
843         var newArtifactList = [];
844             var element={};
845             for (var i = 0; i < tempAllData.length; i++) {
846                 if (this.checkIfelementExistsInArray(tempAllData[i].action,this.actions)) {
847                     var artifactList = tempAllData[i]["artifact-list"]
848                     
849                     for (var j = 0; j < artifactList.length; j++) {
850                         if (artifactList[j]["artifact-type"] != "param_values") {
851                             element = artifactList[j];
852                             newArtifactList.push(element);
853                         }
854                     }
855                     tempAllData[i]["artifact-list"] = newArtifactList
856                     newArtifactList = [];
857                     element={};
858                 }
859             }
860             return tempAllData;
861     }*/
862     // save the values to the cache, on action change without download
863     validateDataAndSaveToAppc( valid, form, event) {
864       let methName= "validateDataAndSaveToAppc";
865       if( this.utilityService.getTracelvl() > 0 )
866         console.log( this.classNm+": "+methName+": start: valid:["+valid+"]");
867         // will show error message
868         this.showValidationErrors(this.referenceDataObject);
869       if( this.utilityService.getTracelvl() > 0 )
870         console.log( this.classNm+": "+methName+": tempAllData:["+
871           JSON.stringify(this.tempAllData)+"]");
872         try {
873             form._submitted = true;
874             if (valid) {
875                 let referenceObject = this.prepareReferenceObject(true);
876                 let removedKeysArray = []
877                 this.tempAllData.forEach((data, index) => {
878                     if (data.action) {
879                         removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
880                     }
881                 });
882                 this.tempAllData = removedKeysArray;
883
884                 this.validateTempAllData();
885                 this.saveToAppc();
886                 if (this.actionChanged) {
887                     this.clearVnfcData()
888                     if (this.currentAction) {
889                         this.referenceDataObject.action = this.currentAction;
890                     }
891
892                     this.populateExistinAction(this.referenceDataObject.action);
893                     this.actionChanged = false;
894                 }
895             }
896         }
897         catch (e) {
898             this.nService.warn('status', 'unable to save the artifact');
899         }
900     }
901     //this method saves reference, template, param and PD data to APPC
902     saveToAppc() {
903       if( this.utilityService.getTracelvl() > 0 )
904         console.log( this.classNm+": saveToAppc: start: vnf-type:["+
905           this.referenceDataObject.scope['vnf-type']+"]");
906         let theJSON = JSON.stringify( this.tempAllData );
907       if( this.utilityService.getTracelvl() > 0 )
908         console.log( this.classNm+": saveToAppc: tempAllData:["+theJSON+"]");
909         let fileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
910         /*var tempAllData=this.removeParamFileNameBeforeSave(this.tempAllData);
911         this.tempAllData=tempAllData;*/
912         this.saveReferenceDataToAppc(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
913
914         var templateData = JSON.stringify(this.appData.template.templateData);
915         var nameValueData = JSON.stringify(this.appData.template.nameValueData);
916         var pdData = JSON.stringify(this.appData.pd);
917         if (templateData != '{}' && templateData != null && templateData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.templateData, 'template data');
918         if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.nameValueData, 'name value pairs');
919         if (pdData != '{}' && pdData != null && pdData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.pd, 'PD file');
920     }
921
922     // valaidation of template data
923     validateTempAllData() {
924         if (this.tempAllData) {
925             var updatedData = [];
926             this.tempAllData.forEach(data => {
927                 if (data.action) {
928                     updatedData.push(data);
929                 }
930             });
931             this.tempAllData = updatedData;
932         }
933     }
934
935     //preparig and send the data to the API.
936     saveReferenceDataToAppc(artifactData, dataJson, fileName) {
937         let data = [];
938         let slashedPayload = this.referenceDataFormUtil.appendSlashes(artifactData);
939
940         let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload);
941         this.ngProgress.start();
942         this.httpUtils.post({
943             url: environment.getDesigns,
944             data: payload
945         }).subscribe((resp) => {
946             if (resp != null && resp.output.status.code == '400') {
947                 window.scrollTo(0, 0);
948                 this.nService.success('Status', 'successfully uploaded the Reference Data');
949             } else {
950                 this.nService.warn('Status', 'Error while saving Reference Data');
951             }
952             this.uploadStatusError = false;
953             this.getRefStatus = false;
954             this.ngProgress.done();
955         }, (err) => {
956             this.nService.error('Status', 'Error Connecting to the APPC Network');
957             window.scrollTo(0, 0);
958         });
959         this.appData.reference = payload;
960         setTimeout(() => {
961             this.ngProgress.done();
962         }, 3500);
963     }
964     // if no data present in the session, fetching data from API
965     retriveFromAppc() {
966         if (sessionStorage.getItem('updateParams') != 'undefined') {
967             this.getArtifact();
968             this.noCacheData = false;
969         } else {
970             this.noCacheData = true;
971         }
972     }
973
974     public showUpload() {
975         this.selectedUploadType = this.uploadTypes[0].value;
976     };
977     // used when user uploads a file using upload file
978     public fileChange(input) {
979         this.fileName = input.target.files[0].name.replace(/C:\\fakepath\\/i, '');
980         this.fileUploaded = true;
981         this.disableRetrieve = true;
982         if (input.target.files && input.target.files[0]) {
983             // Create the file reader
984             let reader = new FileReader();
985             this.readFile(input.target.files[0], reader, (result) => {
986                 // After the callback fires do:
987                 if ('Reference Data' === this.selectedUploadType) {
988                     try {
989                         let obj: any;
990                         let jsonObject = (JSON.parse(result))['reference_data'];
991                         this.uploadedData = JSON.parse(JSON.stringify(jsonObject));
992                         //check for legacy artifact and do not allow it
993                         for (let i = 0; i < this.uploadedData.length; i++) {
994                             obj = this.uploadedData[i];
995                             if (obj.scope['vnfc-type'] != undefined && obj.scope['vnfc-type'] != '') {
996                                 this.nService.error('Error', 'The legacy reference artifact not supported');
997                                 return;
998                             }
999                         }
1000
1001                         this.displayVnfc = 'false';
1002                         this.isVnfcType = false;
1003                         this.isVnfcTypeList = false;
1004                         for (let i = 0; i < this.uploadedData.length; i++) {
1005                             obj = this.uploadedData[i];
1006                             if (obj.scope['vnfc-type-list'] && obj.scope['vnfc-type-list'].length > 0) {
1007                                 this.displayVnfc = 'true';
1008                                 this.isVnfcTypeList = true;
1009                                 this.vnfcIdentifier = obj.scope['vnfc-type-list'][0];
1010                                 
1011                             }
1012                         }
1013                         this.oldAction=obj.action;
1014                         this.tempAllData = JSON.parse(JSON.stringify(jsonObject));
1015                         //check vnfc tyoe list for old files
1016                         // if (this.referenceDataObject.scope['vnfc-type-list'] == undefined) {
1017                         //     this.tempAllData = []
1018                         //     this.referenceDataObject = {
1019                         //         action: '',
1020                         //         'action-level': 'vnf',
1021                         //         scope: { 'vnf-type': '', 'vnfc-type-list': [] },
1022                         //         'template': 'Y',
1023                         //         vm: [],
1024                         //         'device-protocol': '',
1025                         //         'user-name': '',
1026                         //         'port-number': '',
1027                         //         'artifact-list': []
1028                         //     }
1029                         //     this.nService.error('Error', 'Incorrect file format');
1030                         //     return
1031                         // }
1032                         this.notificationService.notifySuccessMessage('Reference Data file successfully uploaded..');
1033                         this.highlightSelectedActions(jsonObject)
1034                         this.toggleIdentifier(this.referenceDataObject.action)
1035                         this.populateExistinAction(this.referenceDataObject.action)
1036                         this.configDrp(this.referenceDataObject.action)
1037
1038
1039                         this.processReferenceDataAfterRetrieval();
1040
1041                         this.getArtifactsOpenStack();
1042                         if (this.referenceDataObject.template == null) {
1043                             this.referenceDataObject.template = 'Y';
1044                         }
1045                         if (this.referenceDataObject['action-level'] == null) {
1046                             this.referenceDataObject['action-level'] = 'VNF';
1047                         }
1048
1049                         
1050                         // Enable or Block Template and PD Tabs
1051                         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1052                     } catch (e) {
1053                         this.nService.error('Error', 'Incorrect file format');
1054                     }
1055                 }
1056                 this.hideModal = true;
1057             });
1058         } else {
1059             this.notificationService.notifyErrorMessage('Failed to read file..');
1060         }
1061
1062     }
1063
1064     // Highlights selected action on new file upload and on existing VNF 
1065     public highlightSelectedActions(jsonObject) {
1066         if (jsonObject instanceof Array) {
1067             this.referenceDataObject = jsonObject[0];
1068             jsonObject.forEach(obj => {
1069                 this.selectedActions.push(obj.action);
1070             });
1071         } else {
1072             this.referenceDataObject = jsonObject;
1073
1074             this.selectedActions.push(jsonObject.action);
1075         }
1076     }
1077
1078     public readFile(file, reader, callback) {
1079         // Set a callback funtion to fire after the file is fully loaded
1080         reader.onload = () => {
1081             // callback with the results
1082             callback(reader.result);
1083         };
1084         this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size);
1085         // Read the file
1086         reader.readAsText(file, 'UTF-8');
1087     }
1088
1089     fileChangeEvent(fileInput: any) {
1090         let obj: any = fileInput.target.files;
1091     }
1092     //resetting the values
1093     clearVnfcData() {
1094         this.Sample = {
1095             'vnfc-instance': '1',
1096             'vnfc-function-code': '',
1097             'ipaddress-v4-oam-vip': '',
1098             'group-notation-type': '',
1099             'group-notation-value': ''
1100         };
1101     }
1102
1103     setVmInstance(index) {
1104         this.referenceDataObject.vm[index]['vm-instance'] = index + 1;
1105     }
1106
1107     // setVnfcType(str: String) {
1108     //     this.Sample['vnfc-type'] = str;
1109     // }
1110
1111     // getChange(value: String) {
1112     //     if (value === 'vnfType') {
1113     //         this.referenceDataObject.scope['vnfc-type'] = '';
1114     //     }
1115     // }
1116     // resetting the form
1117     resetForm() {
1118         console.log( this.classNm+": resetForm: start.");
1119         this.referenceDataObject['action-level'] = 'vnf';
1120         this.referenceDataObject.template = 'Y';
1121         this.referenceDataObject['device-protocol'] = '';
1122         this.referenceDataObject['user-name'] = '';
1123         this.referenceDataObject['port-number'] = '';
1124         this.refernceScopeObj.sourceType = '';
1125         this.Sample['vnfc-type'] = '';
1126     }
1127
1128     //.. this method gets called with the action as parameter and
1129     // the respective action details are fetched and assigned to the current page
1130     populateExistinAction( action) {
1131       let methName= "populateExistinAction";
1132       if( this.utilityService.getTracelvl() > 0 )
1133         console.log( this.classNm+": "+methName+": start: action:["+action+"]");
1134       if( this.utilityService.getTracelvl() > 0 )
1135         console.log( this.classNm+": "+methName+": tempAllData:["+
1136           JSON.stringify(this.tempAllData)+"]");
1137       let existAction = this.tempAllData.findIndex(obj => {
1138         return obj.action == action;
1139       });
1140       if( this.utilityService.getTracelvl() > 0 )
1141         console.log( this.classNm+": "+methName+": existAction="+existAction );
1142       if( existAction > -1) {
1143         let obj = $.extend(true, {}, this.tempAllData[existAction]);
1144         this.referenceDataObject = obj;
1145         this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type'];
1146         this.referenceDataObject.scope['vnfc-type-list'] = obj['scope']['vnfc-type-list'];
1147         this.referenceDataObject['device-protocol'] = obj['device-protocol'];
1148         this.refernceScopeObj['sourceType'] = obj['scopeType'];
1149         if( obj['scope']['vnfc-type-list'] != undefined &&
1150             obj['scope']['vnfc-type-list'].length >0)
1151         {
1152           this.referenceDataObject['vnfcIdentifier']=
1153             obj['scope']['vnfc-type-list'][0];
1154         };
1155       }
1156       else {
1157         console.log( this.classNm+": populateExistinAction: action not found");
1158         this.resetForm();
1159         this.referenceDataObject.action = action;
1160       }
1161       //# iof healthCeck change deviceprotocol drp vaues
1162       switch( action) {
1163         case 'HealthCheck':
1164           this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST'];
1165           this.actionHealthCheck = true;
1166           break;
1167         case 'UpgradeBackout':
1168         case 'ResumeTraffic':
1169         case 'DistributeTraffic':
1170         case 'DistributeTrafficCheck':
1171         case 'QuiesceTraffic':
1172         case 'UpgradeBackup':
1173         case 'UpgradePostCheck':
1174         case 'UpgradePreCheck':
1175         case 'UpgradeSoftware':
1176         case 'DownloadNESw':
1177         case 'ActivateNESw':
1178         case 'ConfigRestore':
1179         case 'StartApplication':
1180         case 'StopApplication':
1181         case 'ConfigBackup':
1182           this.deviceProtocols = ['', 'CHEF', 'ANSIBLE'];
1183           break;
1184         case 'GetConfig':
1185         case 'LicenseManagement':
1186         case 'PostConfigure':
1187         case 'PostEvacuate':
1188         case 'PostMigrate':
1189         case 'PostRebuild':
1190         case 'PreConfigCheck':
1191         case 'PreConfigure':
1192         case 'PreEvacuate':
1193         case 'PreMigrate':
1194         case 'PreRebuild':
1195         case 'ProvisionConfig':
1196         case 'ProvisionData':
1197         case 'Provisioning':
1198         case 'StartTraffic':
1199         case 'StatusTraffic':
1200         case 'StopTraffic':
1201           this.deviceProtocols = ['', 'ANSIBLE'];
1202           break;
1203         case 'OpenStack Actions':
1204           this.deviceProtocols = ['', 'OpenStack'];
1205           break;
1206         case 'ConfigScaleOut':
1207           this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1208           break;
1209         case 'ConfigScaleIn':
1210             this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1211             break;
1212         case 'GetRunningConfig':
1213           this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF', 'CLI', 'REST'];
1214           break;
1215         default:
1216           this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
1217           this.actionHealthCheck = false;
1218       };
1219       if( this.utilityService.getTracelvl() > 0 )
1220         console.log( this.classNm+": "+methName+
1221           ": deviceProtocols count="+this.deviceProtocols.length+" finish.");
1222     }
1223
1224     //Modal pop up for action change with values entered. 
1225     actionChange( data, userForm) {
1226       let methName= "actionChange";
1227       if( this.utilityService.getTracelvl() > 0 )
1228         console.log( this.classNm+": "+methName+": start: data:["+data+"]"+
1229           " userForm.valid:["+userForm.valid+"]");
1230       if( this.utilityService.getTracelvl() > 0 )
1231         console.log( this.classNm+": "+methName+": tempAllData:["+
1232           JSON.stringify(this.tempAllData)+"]");
1233         this.disableGrpNotationValue = false
1234         if (data == null) {
1235             console.log( this.classNm+": "+methName+": data == null");
1236             return;
1237         }
1238         if((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
1239             this.actionChanged = true;
1240           if( this.utilityService.getTracelvl() > 0 )
1241             console.log( this.classNm+": "+methName+
1242               ": userForm valid and oldAction defined");
1243             // Calling common Confirmation Modal
1244             let disposable = this.dialogService.addDialog(ConfirmComponent)
1245                 .subscribe((isConfirmed)=>{
1246                     //We get dialog result
1247                     if(isConfirmed) {
1248                         // User clicked on Yes
1249                         this.currentAction = this.referenceDataObject.action;
1250                         this.referenceDataObject.action = this.oldAction;
1251                         $('#saveToAppc').click();//make sure the save all is done before the tempall obj is saved form the API
1252                         this.toggleIdentifier(data)
1253                         this.oldAction = this.currentAction;// this.referenceDataObject.action + '';
1254                         this.referenceDataObject.action = this.currentAction
1255
1256                         this.populateExistinAction(data);
1257                         if (this.oldAction === 'OpenStack Actions') {
1258
1259                             this.uploadedDataArray = [];
1260                             this.remUploadedDataArray = [];
1261                             this.firstArrayElement = [];
1262                             this.uploadFileName = '';
1263                             //this.tempAllData = [];
1264                         }
1265                         this.clearCache();
1266                         this.refernceScopeObj.from = '';
1267                         this.getArtifactsOpenStack();
1268
1269                         // Clears VNFC Information data on action change
1270                         this.clearVnfcData()
1271                         this.resetVmsForScaleout(data);
1272                     }
1273                     else {
1274                         // User clicked on No
1275                         this.toggleIdentifier(data)
1276                         this.currentAction = this.referenceDataObject.action;
1277                         this.populateExistinAction(data);
1278                         this.resetVmsForScaleout(data);
1279                         this.oldAction = this.referenceDataObject.action + '';
1280                         this.clearCache();
1281                         this.clearVnfcData()
1282                         this.refernceScopeObj.from = '';
1283                     }
1284
1285                     if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic' || this.referenceDataObject.action === 'DistributeTrafficCheck') {
1286                         this.isConfigOrConfigModify = true;
1287                     } else {
1288                         this.isConfigOrConfigModify = false;
1289                         delete this.mappingEditorService.newObject['vnfc'];
1290                     }
1291     
1292                     // Enable or Block Template and PD Tabs
1293                     if ((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleIn') && this.templateIdentifier && this.templateIdentifier != '') {
1294                         // let referenceDataObjectTemp = this.referenceDataObject;
1295                         // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1296                         // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1297                         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1298     
1299                     } else {
1300                         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1301                     }    
1302                 });
1303         } else {
1304             console.log( this.classNm+": "+methName+
1305               ": userForm Not valid or oldAction not defined");
1306             this.actionChanged = true;
1307             this.currentAction = this.referenceDataObject.action;
1308             this.oldAction = this.referenceDataObject.action + '';
1309             this.populateExistinAction(data);
1310             this.resetVmsForScaleout(data);
1311             this.toggleIdentifier(data);
1312
1313             // Enable or Block Template and PD Tabs
1314             if((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleOut') && this.templateIdentifier) {
1315                 // let referenceDataObjectTemp = this.referenceDataObject;
1316                 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1317                 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1318                 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1319             } else {
1320                 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1321             }
1322         }
1323         if( this.utilityService.getTracelvl() > 0 )
1324           console.log( this.classNm+": "+methName+": tempAllData:["+
1325             JSON.stringify(this.tempAllData)+"]");
1326         this.configDrp(data)
1327     }
1328
1329     configDrp(data) {
1330         console.log( this.classNm+": configDrp: start: data:["+data+"]");
1331         if (data == 'ConfigScaleOut' || data == 'ConfigScaleIn') {
1332             this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
1333         } else {
1334             this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
1335         }
1336         if (data == 'OpenStack Actions') {
1337             this.buildDesignComponent.tabs = this.referencDataTab;
1338         }
1339         else {
1340             this.buildDesignComponent.tabs = this.allTabs;
1341         }
1342         if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic' || data == 'DistributeTrafficCheck') {
1343             this.nonConfigureAction = false;
1344         } else {
1345             this.nonConfigureAction = true;
1346         }
1347     }
1348     // removing and adding the url key based on the protocol selected
1349     deviceProtocolChange() {
1350       let methName= "deviceProtocolChange";
1351       if( this.utilityService.getTracelvl() > 0 )
1352         console.log( this.classNm+": "+methName+": start.");
1353         if (this.referenceDataObject['device-protocol'] == 'REST') {
1354
1355         } else {
1356             delete this.referenceDataObject['context-url']
1357         }
1358         // Enable or Block Template and PD Tabs
1359         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, {reqField: this.templateIdentifier})
1360         if( this.utilityService.getTracelvl() > 0 )
1361           console.log( this.classNm+": "+methName+": tempAllData:["+
1362             JSON.stringify(this.tempAllData)+"]");
1363     }
1364
1365     // used to call or trigger save object on template Identifier changes
1366     idChange(data, userForm) {
1367       if( this.utilityService.getTracelvl() > 0 )
1368         console.log( this.classNm+": idChange: start: data:["+data+"]");
1369         if (data == null) {
1370             return;
1371         }
1372
1373         // Enable or Block Template and PD Tabs
1374         // let referenceDataObjectTemp = this.referenceDataObject;
1375         // referenceDataObjectTemp['template-id'] = data;
1376         // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1377         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1378
1379         if ((userForm.valid)) {
1380             this.currentAction = "ConfigScaleOut"
1381             this.oldtemplateIdentifier = this.templateIdentifier
1382             let referenceObject = this.prepareReferenceObject();
1383             this.actionChanged = true;
1384             if (this.templateIdentifier) {
1385                  // Calling common Confirmation Modal
1386                  let disposable = this.dialogService.addDialog(ConfirmComponent)
1387                  .subscribe((isConfirmed)=>{
1388                      //We get dialog result
1389                      if(isConfirmed) {
1390                          // User clicked on Yes
1391                          this.validateTempAllData();
1392                          this.saveToAppc();
1393                          this.clearCache();
1394                          this.clearVnfcData();
1395                          this.refernceScopeObj.from = '';
1396                      }
1397                      else {
1398                          // User clicked on No
1399                          this.clearCache();
1400                          this.refernceScopeObj.from = '';
1401                      }
1402                  });
1403             }
1404         } else {
1405             this.oldtemplateIdentifier = this.templateIdentifier
1406         }
1407
1408         // if (this.referenceDataObject.action == 'ConfigScaleOut' && data ) {
1409         //     let referenceDataObjectTemp = this.referenceDataObject;
1410         //     referenceDataObjectTemp['selectedTemplateId'] = data;
1411         //     this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1412         // } else {
1413         //     this.buildDesignComponent.getRefData(this.referenceDataObject);
1414         // }
1415     }
1416
1417     // used to call or trigger save object on multiple VNFC's changes
1418     vnfcChanged( data, userForm) {
1419       if( this.utilityService.getTracelvl() > 0 )
1420         console.log( this.classNm+": vnfcChanged: new vnfcIdentifier:["+data+"]");
1421       if( this.utilityService.getTracelvl() > 1 )
1422         console.log( this.classNm+": vnfcChanged: oldVnfcIdentifier:["+
1423           this.oldVnfcIdentifier+"]");
1424       if( this.utilityService.getTracelvl() > 0 )
1425         console.log(this.classNm+": vnfcChanged:  scope.vnfc-type:["+
1426           this.referenceDataObject.scope['vnfc-type']+"]");
1427         this.vnfcIdentifier = data;
1428         //this.clearCache();
1429         if (data == null) {
1430             return;
1431         }
1432       
1433         // Enable or Block Template and PD Tabs
1434         let referenceDataObjectTemp = this.referenceDataObject;
1435         referenceDataObjectTemp['vnfcIdentifier'] = data;
1436       if( this.utilityService.getTracelvl() > 0 )
1437         console.log( this.classNm+
1438           ": vnfcChanged: displayVnfc:["+this.displayVnfc+"]");
1439         //this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1440         this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1441
1442       
1443         console.log( this.classNm+
1444           ": vnfcChanged: userForm.valid:["+userForm.valid+"]");
1445         if ((userForm.valid) && this.oldVnfcIdentifier != '' && this.oldVnfcIdentifier != undefined) {
1446             this.currentAction = this.referenceDataObject.action
1447             this.oldVnfcIdentifier = this.vnfcIdentifier
1448             let referenceObject = this.prepareReferenceObject();
1449             this.actionChanged = true;
1450             if (this.vnfcIdentifier) {
1451                  // Calling common Confirmation Modal
1452                  let disposable = this.dialogService.addDialog(ConfirmComponent)
1453                  .subscribe((isConfirmed)=>{
1454                      //We get dialog result
1455                      if(isConfirmed) {
1456                          // User clicked on Yes
1457                          this.validateTempAllData();
1458                          this.saveToAppc();
1459                          this.clearCache();
1460                          this.clearVnfcData()
1461                          this.refernceScopeObj.from = '';
1462                          //.. populate VNFC Type in Sample field
1463                          this.setVnfcTypeInSample( this.vnfcIdentifier );
1464                      }
1465                      else {
1466                          // User clicked on No
1467                          this.clearCache();
1468                          this.clearVnfcData()
1469                          this.refernceScopeObj.from = '';
1470                          //.. populate VNFC Type in Sample field
1471                          this.setVnfcTypeInSample( this.vnfcIdentifier );
1472                      }
1473                  });
1474             }
1475         } else {
1476             if (data != null) {
1477                 this.oldVnfcIdentifier = this.vnfcIdentifier
1478             }
1479         }
1480     }
1481
1482     clearCache()
1483     //needed for the the clearing template cache.
1484     {
1485         // get the value and save the userid and persist it.
1486         this.clearTemplateCache();
1487         this.clearPdCache();
1488         this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
1489         this.downloadData = {
1490             reference: {},
1491             template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
1492             pd: { pdData: '', pdFileName: '' }
1493         };
1494     }
1495
1496     clearTemplateCache() {
1497         this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
1498         localStorage['paramsContent'] = '{}';
1499     }
1500     clearPdCache() {
1501         this.mappingEditorService.setParamContent(undefined);
1502         this.paramShareService.setSessionParamData(undefined);
1503     }
1504
1505     browseOption() {
1506         $('#inputFile').trigger('click');
1507     }
1508
1509     excelBrowseOption() {
1510         $('#excelInputFile').trigger('click');
1511     }
1512
1513     /* showIdentifier() {
1514          $('#identifierModal').modal();
1515      }
1516  
1517      showVnfcPopup() {
1518          $('#vnfcModal').modal();
1519      }*/
1520
1521     addToIdentDrp() {
1522         if (!(this.referenceDataObject['template-id-list'])) {
1523             this.referenceDataObject['template-id-list'] = [];
1524         }
1525         if (!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim()) > -1)) {
1526             this.referenceDataObject['template-id-list'].push(this.templateId.trim());
1527         }
1528
1529         // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1530         this.templateId = ''
1531     }
1532     // adds the vnfc to the vnfc dropdown list
1533     addVnfc() {
1534       var newVnfcTypeV= this.newVnfcType.trim();
1535       if( this.utilityService.getTracelvl() > 0 )
1536         console.log(this.classNm+
1537           ": addVnfc: start: newVnfcTypeV:["+newVnfcTypeV+"]");
1538         if (!(this.referenceDataObject.scope['vnfc-type-list'])) {
1539             this.referenceDataObject.scope['vnfc-type-list'] = [];
1540             this.vnfcIdentifier = newVnfcTypeV;
1541         } else {
1542             this.vnfcIdentifier = newVnfcTypeV;
1543         }
1544         //this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
1545         if (!(this.referenceDataObject.scope['vnfc-type-list'].indexOf(newVnfcTypeV) > -1)) {
1546             this.referenceDataObject.scope['vnfc-type-list'].push(newVnfcTypeV);
1547         }
1548         this.tempAllData.forEach(obj => {
1549             if (obj.action == "Configure" || obj.action == "ConfigModify" || obj.action == "DistributeTraffic" || obj.action == "DistributeTrafficCheck") {
1550                 obj.scope['vnfc-type-list'] = this.referenceDataObject.scope['vnfc-type-list']
1551             }
1552             this.resetArtifactList(obj);
1553         });
1554         //this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1555       this.setVnfcTypeInSample( newVnfcTypeV );
1556       let userForm = {valid: true};
1557       this.vnfcChanged(this.newVnfcType, userForm)
1558         // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1559         this.newVnfcType = ''
1560     }
1561
1562     resetVms() {
1563         this.referenceDataObject.vm = [];
1564     }
1565
1566     dataModified() {
1567         //  this.referenceDataObject.vm = this.referenceDataObject.vm;
1568     }
1569     // used to show and hide the group notation value in VNFC information
1570     resetGroupNotation() {
1571         if (this.Sample['group-notation-type'] == "existing-group-name") {
1572             this.Sample['group-notation-value'] = ""
1573             this.disableGrpNotationValue = true
1574         } else {
1575             this.disableGrpNotationValue = false
1576         }
1577     }
1578
1579     resetVmsForScaleout(action) {
1580         //reset currentform vms based on action
1581         if (action == "ConfigScaleOut" || action == "Configure") {
1582             let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
1583                 return obj['action'] == action
1584             });
1585             if (ConfigScaleOutIndex > -1) {
1586                 this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
1587             } else {
1588                 if (this.actionChanged) {
1589                     this.referenceDataObject.vm = []
1590                 }
1591             }
1592         }
1593     }
1594
1595     resetVmsForScaleIn(action) {
1596         //reset currentform vms based on action
1597         if (action == "ConfigScaleIn" || action == "Configure") {
1598             let ConfigScaleInIndex = this.tempAllData.findIndex(obj => {
1599                 return obj['action'] == action
1600             });
1601             if (ConfigScaleInIndex > -1) {
1602                 this.referenceDataObject.vm = this.tempAllData[ConfigScaleInIndex].vm
1603             } else {
1604                 if (this.actionChanged) {
1605                     this.referenceDataObject.vm = []
1606                 }
1607             }
1608         }
1609     }
1610
1611     resetParamsOnVnfcType() {
1612         let scopeName: any;
1613         let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list']
1614         let vnfcType = this.referenceDataObject.scope['vnfc-type']
1615         let vnfType = this.referenceDataObject.scope['vnf-type'];
1616         //called only if only vnf is there
1617         if ((this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) && (this.referenceDataFormUtil.nullCheckForVnfcType(vnfcType))
1618         ) {
1619             scopeName = vnfType;
1620             this.referenceDataObject.scope['vnfc-type'] = '';
1621             this.referenceDataObject['action-level'] = 'vnf';
1622             this.referenceDataObject['scopeType'] = 'vnf-type';
1623             scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1624         }
1625         //if VNFC is entered set action level & Scope type to VNFC for configure and configure modify, and default the values to vnf and vnf type for all other actions  
1626         else {
1627             if (this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) {
1628                 scopeName = vnfcType ? vnfcType : "";
1629             } else {
1630                 //    scopeName = this.referenceDataObject.scope['vnfc-type-list'];
1631             }
1632
1633             if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1634                 this.referenceDataObject['action-level'] = 'vnf';
1635                 this.referenceDataObject['scopeType'] = 'vnfc-type';
1636             } else {
1637                 this.referenceDataObject['action-level'] = 'vnf';
1638                 this.referenceDataObject['scopeType'] = 'vnf-type';
1639             }
1640         }
1641         this.referenceDataObject.scope['vnfc-type'] = this.referenceDataObject.scope['vnfc-type'] ? this.referenceDataObject.scope['vnfc-type'] : "";
1642         return scopeName
1643     }
1644
1645     //used to form the structure of the reference file
1646     prepareArtifactList(scopeName, extension) {
1647         this.referenceDataObject['artifact-list'] = [];
1648         let configTemplate
1649         let pdTemplate
1650         let paramValue
1651         let vnf = this.referenceDataObject.scope['vnf-type']
1652         if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1653             let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list'];
1654             let pd_fileName
1655             let config_template_fileName
1656
1657             let param_fileName
1658             if (vnfcTypeList && vnfcTypeList.length > 0) {
1659
1660
1661                 for (var x = 0; x < vnfcTypeList.length; x++) {
1662                     //for replacing spaces and "/" with "_"
1663                     let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1664                     pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.yaml')
1665                     config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, extension)
1666                     param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.json')
1667                     configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1668                     pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1669                     paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1670
1671                     this.referenceDataObject['artifact-list'].push(configTemplate,
1672                         pdTemplate, paramValue
1673                     );
1674                 }
1675             } else if (scopeName) {
1676                 pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
1677                 config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V' + extension;
1678                 param_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
1679                 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1680                 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1681                 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1682                 this.referenceDataObject['artifact-list'].push(configTemplate,
1683                     pdTemplate, paramValue
1684                 );
1685             }
1686
1687         } else {
1688
1689             //preparing the artifact list array file names along with extension
1690             let config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', extension);
1691             let pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.yaml');
1692             let reference_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1693             let param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1694             configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1695             pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1696             paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1697             if (this.referenceDataObject.action != 'ConfigScaleOut' && this.referenceDataObject.action != 'ConfigScaleIn') {
1698
1699                 this.referenceDataObject['artifact-list'].push(configTemplate,
1700                     pdTemplate, paramValue
1701                 );
1702
1703             } else {
1704
1705                 let identifiers = this.referenceDataObject['template-id-list'];
1706                 if (identifiers) {
1707                     for (var x = 0; x < identifiers.length; x++) {
1708                         //for replacing spaces and "/" with "_"
1709                         let type = identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1710                         pd_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.yaml');
1711                         config_template_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, extension);
1712                         param_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.json');
1713                         configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1714                         pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1715                         paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1716
1717                         this.referenceDataObject['artifact-list'].push(configTemplate,
1718                             pdTemplate, paramValue
1719                         );
1720                     }
1721                 }
1722
1723             }
1724         }
1725     }
1726     // used to remove the added vms for actions other than configure & scaleout
1727     deleteVmsforNonActions(newObj, action) {
1728         let configureObject = (action == 'Configure');
1729         let ConfigScale = (action == 'ConfigScaleOut') || (action == 'ConfigScaleIn');
1730         //delete VM's if selected action is not configure.
1731         if (!ConfigScale && !configureObject && this.tempAllData.length != 0) {
1732             if (ConfigScale) {
1733             } else {
1734                 newObj.vm = [];
1735             }
1736         } else {
1737             if (ConfigScale) {
1738             } else {
1739                 delete newObj['template-id-list'];
1740             }
1741         }
1742         return newObj
1743     }
1744     
1745     // used to replace the data in tempall obj and form the artifact names
1746     pushOrReplaceTempData(newObj, action) {
1747         let configTemplate
1748         let pdTemplate
1749         let paramValue
1750         if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic" || newObj.action == "DistributeTrafficCheck") {
1751             let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
1752             let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.yaml';
1753             let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V' + extension;
1754             let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.json';
1755             configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1756             pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1757             paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1758             let idValue = ""
1759             if (newObj.scope['vnfc-type']) {
1760                 idValue = newObj.scope['vnfc-type']
1761             } else if (this.vnfcIdentifier) {
1762                 idValue = this.vnfcIdentifier
1763             }
1764
1765             let arr = [configTemplate, pdTemplate, paramValue]
1766             this.mappingEditorService.selectedObj({
1767                 action: newObj.action,
1768                 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1769                 vnfc: idValue,
1770                 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1771                 param_artifact: paramValue['param_artifact'],
1772                 pd_artifact: pdTemplate['pd_artifact'],
1773                 template_artifact: configTemplate['template_artifact']
1774             });
1775         } else if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1776             let extension = this.referenceDataFormUtil.decideExtension(newObj);
1777             let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_0.0.1V' + '_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '')) : "") + ".yaml";
1778             let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + extension;
1779             let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + '.json';
1780             configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1781             pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1782             paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1783             let arr = [configTemplate, pdTemplate, paramValue]
1784             this.mappingEditorService.selectedObj({
1785                 action: newObj.action,
1786                 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1787                 //vnfc: newObj['vnfcIdentifier'] ? newObj['vnfcIdentifier'] : "",
1788                 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1789                 templateId: this.templateIdentifier,
1790                 param_artifact: paramValue['param_artifact'],
1791                 pd_artifact: pdTemplate['pd_artifact'],
1792                 template_artifact: configTemplate['template_artifact']
1793             });
1794         }
1795         else {
1796             let extension = this.referenceDataFormUtil.decideExtension(newObj);
1797             let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.yaml';
1798             let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V' + extension;
1799             let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
1800             configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1801             pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1802             paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1803             let arr = [configTemplate, pdTemplate, paramValue]
1804             this.mappingEditorService.selectedObj({
1805                 action: newObj.action,
1806                 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1807                 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1808                 param_artifact: paramValue['param_artifact'],
1809                 pd_artifact: pdTemplate['pd_artifact'],
1810                 template_artifact: configTemplate['template_artifact']
1811             });
1812         }
1813
1814         let actionObjIndex = this.tempAllData.findIndex(obj => {
1815             return obj['action'] == action;
1816         });
1817         if (actionObjIndex > -1) {
1818             this.tempAllData[actionObjIndex] = newObj;
1819             this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
1820             if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1821                 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1822             }
1823             else {
1824                 this.templateIdentifier = ('')
1825                 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1826             }
1827         } else {
1828             if (newObj.action != '') {
1829
1830                 this.tempAllData.push(newObj);
1831                 this.mappingEditorService.saveLatestAction(newObj);
1832
1833                 if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1834                     this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1835                 }
1836                 else {
1837                     this.templateIdentifier = ('')
1838                     this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1839                 }
1840             }
1841         }
1842     }
1843     // removes the unwanted keys added in the artifact for vnfc level actions
1844     deleteUnwantedKeys(newObj) {
1845         newObj = JSON.parse(JSON.stringify(newObj))
1846         delete newObj['template-id']
1847         delete newObj['vnfcIdentifier']
1848         if (newObj.action != "ConfigScaleOut" && newObj.action != "ConfigScaleIn") {
1849             delete newObj['template-id-list']
1850         }
1851         if (newObj.action != 'HealthCheck') {
1852             delete newObj['url'];
1853         }
1854         if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action != "DistributeTraffic" && newObj.action != "DistributeTrafficCheck") {
1855             newObj.scope['vnfc-type-list'] = [];
1856         }
1857         return newObj
1858     }
1859
1860     addAllActionObj(newObj, scopeName) {
1861
1862         //Creating all action block to allow mulitple actions at once
1863         let allAction = {
1864             action: 'AllAction',
1865             'action-level': 'vnf',
1866             scope: newObj.scope,
1867             'artifact-list': []
1868         };
1869         let vnfType = this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1870
1871         allAction['artifact-list'].push({
1872             'artifact-name': 'reference_AllAction' + '_' + vnfType + '_' + '0.0.1V.json',
1873             'artifact-type': 'reference_template'
1874         })
1875
1876         let allActionIndex = this.tempAllData.findIndex(obj => {
1877             return obj['action'] == 'AllAction';
1878         });
1879         if (allActionIndex > -1) {
1880             this.tempAllData[allActionIndex] = allAction;
1881         } else {
1882             this.tempAllData.push(allAction);
1883         }
1884     }
1885
1886     resetTempData() {
1887       let methName= "resetTempData";
1888       if( this.utilityService.getTracelvl() > 0 )
1889         console.log( this.classNm+": "+methName+": start.");
1890       if( this.utilityService.getTracelvl() > 0 )
1891         console.log( this.classNm+": "+methName+": tempAllData:["+
1892           JSON.stringify(this.tempAllData)+"]");
1893         if (this.utilityService.checkNotNull(this.uploadedDataArray)) {
1894
1895             if (this.utilityService.checkNotNull(this.tempAllData)) {
1896                 for (var i = 0; i < this.tempAllData.length; i++) {
1897                     var result = false;
1898
1899                     if (this.tempAllData[i].action === 'AllAction') {
1900                         result = true;
1901                     }
1902                     else {
1903                         result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
1904                     }
1905                     if (!result) {
1906                         this.tempAllData.splice(i, 1);
1907                         i = i - 1;
1908                     }
1909
1910                 }
1911             }
1912             this.addVmCapabilitiesData();
1913         }
1914     }
1915
1916     trackByFn(index, item) {
1917         return index; // or item.id
1918     }
1919     getArtifactsOpenStack() {
1920         var array = []
1921         var vnfcFunctionCodeArrayList = [];
1922         var vnfcSetArray = [];
1923         //  var vnfcSet = new Set();
1924         for (var i = 0; i < this.tempAllData.length; i++) {
1925             if (!this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions) && (this.tempAllData[i].action != 'AllAction')) {
1926                 var vnfcFunctionCodeArray = this.tempAllData[i]["vnfc-function-code-list"]
1927                 // vnfcSet.add("Actions")
1928                 /*  for (var j = 0; j < vnfcFunctionCodeArray.length; j++) {
1929                       vnfcSet.add(vnfcFunctionCodeArray[j])
1930                   }*/
1931                 vnfcFunctionCodeArrayList.push([this.tempAllData[i].action].concat(this.tempAllData[i]["vnfc-function-code-list"]))
1932             }
1933             if (this.tempAllData[i].action === 'OpenStack Actions') {
1934                 vnfcSetArray = this.tempAllData[i]['firstRowVmSpreadSheet']
1935             }
1936         }
1937
1938         if (vnfcSetArray) {
1939             let vnfcSetArrayLen = vnfcSetArray.length;
1940
1941             for (let i = 0; i < vnfcFunctionCodeArrayList.length; i++) {
1942                 let element = vnfcFunctionCodeArrayList[i];
1943                 for (let j = 1; j < element.length; j++) {
1944                     for (let k = j; k < vnfcSetArrayLen; k++) {
1945                         if (element[j] === vnfcSetArray[k]) {
1946                             element[j] = 'Y';
1947                         }
1948                         else {
1949                             element.splice(j, 0, '');
1950                         }
1951                         break;
1952                     }
1953                 }
1954             }
1955             this.firstArrayElement = vnfcSetArray;
1956             this.remUploadedDataArray = vnfcFunctionCodeArrayList;
1957         }
1958     }
1959
1960     // Common method to show validation errors
1961     private showValidationErrors(referenceDataObject) {
1962         if (this.referenceDataObject.action === '') {
1963             this.nService.error('Error', 'Select a valid Action');
1964             return;
1965         }
1966         if (this.referenceDataObject['device-protocol'] === '') {
1967             this.nService.error('Error', 'Select a valid Device protocol');
1968             return;
1969         }
1970
1971         if ((referenceDataObject.action === 'ConfigScaleOut' 
1972         || referenceDataObject.action === 'ConfigScaleIn') 
1973         && !this.templateIdentifier) {
1974             this.nService.error('Error', 'Select a valid Template Identifier');
1975         }
1976
1977         // if ((referenceDataObject.action === 'Configure' || referenceDataObject.action === 'ConfigModify') && !this.vnfcIdentifier && this.displayVnfc != 'false') {
1978         //     this.nService.error('Error', 'Select a valid Vnfc Type');
1979         //     return;
1980         // }
1981     }
1982
1983     resetArtifactList(obj) {
1984       if( this.utilityService.getTracelvl() > 0 )
1985         console.log( this.classNm+": resetArtifactList: start...");
1986         let vnfcTypeList = obj.scope['vnfc-type-list'];
1987         let vnf = this.referenceDataObject.scope['vnf-type']
1988         let pd_fileName
1989         let config_template_fileName
1990         let configTemplate
1991         let pdTemplate
1992         let paramValue
1993         let param_fileName
1994         obj['artifact-list'] = [];
1995         for (var x = 0; x < vnfcTypeList.length; x++) {
1996             let extension = this.referenceDataFormUtil.decideExtension(obj)
1997             //for replacing spaces and "/" with "_"
1998             let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1999             pd_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.yaml';
2000             config_template_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V' + extension;
2001             param_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.json';
2002             configTemplate = {
2003                 'artifact-name': 'template_' + config_template_fileName,
2004                 'artifact-type': 'config_template'
2005             };
2006             pdTemplate = {
2007                 'artifact-name': 'pd_' + pd_fileName,
2008                 'artifact-type': 'parameter_definitions'
2009             };
2010             paramValue = {
2011                 'artifact-name': 'param_' + param_fileName,
2012                 'artifact-type': 'param_values'
2013             };
2014
2015             this.referenceDataObject['artifact-list'].push(configTemplate,
2016                 pdTemplate, paramValue
2017             );
2018             obj['artifact-list'].push(configTemplate,
2019                 pdTemplate, paramValue
2020             );
2021         }
2022     }
2023
2024     /**
2025      * Handles the display of VM block based on the action change
2026      */
2027     handleVMBlockDisplay() {
2028         switch (this.referenceDataObject.action) {
2029             case this.actionList.ConfigScaleOut:
2030             case this.actionList.ConfigScaleIn:
2031             case this.actionList.Configure:
2032             case undefined:
2033             case '':
2034                 this.displayVMBlock = true;
2035                 break;
2036             default:
2037                 this.displayVMBlock = false;
2038         }
2039     }
2040
2041   //.. check VNFC Type equality in Upper Selection vs entered in Sample field
2042   checkVnfcTypeEqual( vnfctp: string ) {
2043     var methName= "checkVnfcTypeEqual";
2044     if( this.utilityService.getTracelvl() > 0 )
2045       console.log(this.classNm+": "+methName+": vnfctp:["+vnfctp+"]");
2046     if( this.utilityService.getTracelvl() > 0 )
2047       console.log( this.classNm+": "+methName+": vnfcIdentifier:["+
2048         this.vnfcIdentifier+"]");
2049     if( this.utilityService.getTracelvl() > 1 )
2050       console.log( this.classNm+": "+methName+":  Sample[vnfc-type]:["+
2051         this.Sample['vnfc-type']+"]");
2052     if( vnfctp != null && vnfctp.length > 0 ) {
2053       if( this.vnfcIdentifier != null && this.vnfcIdentifier.length > 0 ) {
2054         console.log(
2055           this.classNm+": "+methName+": compare non empty VNFC Types...");
2056         if( vnfctp != this.vnfcIdentifier ) {
2057           if( this.utilityService.getTracelvl() > 0 )
2058             console.log( this.classNm+": "+methName+": Non-match WARNING !");
2059           //.. display in pop-up
2060           this.nService.warn( 'WARNING',
2061             "The specified VNFC Types don't match."+
2062             " Can cause discrepancy in the artifacts.", this.options );
2063         } else {
2064           if( this.utilityService.getTracelvl() > 0 )
2065             console.log(this.classNm+": checkVnfcTypeEqual: VNFC Types're equal.");
2066         };
2067       };
2068     };
2069   };
2070
2071   //.. populating VNFC Type in Sample fields
2072   setVnfcTypeInSample( vnfctp: string ) {
2073     //clear vnfc information samples
2074       this.clearVnfcData();
2075
2076     if( this.utilityService.getTracelvl() > 0 )
2077       console.log( this.classNm+": setVnfcTypeInSample: vnfctp:["+vnfctp+"]");
2078     this.Sample['vnfc-type']= vnfctp;
2079   };
2080
2081     /**
2082      * Procesess reference data after retrieval from appc or after a reference file has been uploaded from PC.
2083     */
2084     processReferenceDataAfterRetrieval() {
2085       if( this.utilityService.getTracelvl() > 0 )
2086         console.log( this.classNm+": processReferenceDataAfterRetr: start...");
2087         if (this.referenceDataObject.action === 'OpenStack Actions') {
2088             this.deviceProtocols = ['', 'OpenStack'];
2089             this.buildDesignComponent.tabs = this.referencDataTab;
2090         } else {
2091             this.buildDesignComponent.tabs = this.allTabs;
2092         }
2093       if( this.utilityService.getTracelvl() > 1 )
2094         console.log( this.classNm+": processReferenceDataAfterRetr: done.");
2095       if( this.utilityService.getTracelvl() > 0 )
2096         console.log( this.classNm+":  vnfcIdentifier:["+this.vnfcIdentifier+"]");
2097       if( this.utilityService.getTracelvl() > 1 )
2098         console.log( this.classNm+":  oldVnfcIdentifier:["+
2099           this.oldVnfcIdentifier+"]");
2100       if( this.utilityService.getTracelvl() > 0 )
2101         console.log( this.classNm+":  refDataObj.scope.vnfc-type:["+
2102           this.referenceDataObject.scope['vnfc-type']+"]");
2103       this.setVnfcTypeInSample( this.vnfcIdentifier );
2104     }
2105
2106 }