added ansible server functionality
[appc/cdt.git] / src / app / vnfs / build-artifacts / parameter-definitions / parameter-definition.service.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5
6 Copyright (C) 2018 IBM.
7 ===================================================================
8
9 Unless otherwise specified, all software contained herein is licensed
10 under the Apache License, Version 2.0 (the License);
11 you may not use this software except in compliance with the License.
12 You may obtain a copy of the License at
13
14     http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21 ============LICENSE_END============================================
22 */
23
24
25 import {Injectable, ViewChild} from '@angular/core';
26 import {saveAs} from 'file-saver';
27 import {ParamShareService} from '../../../shared/services/paramShare.service';
28 import {MappingEditorService} from '../../../shared/services/mapping-editor.service';
29 import {ModalComponent} from '../../../shared/modal/modal.component';
30 import {UtilityService} from '../../../shared/services/utilityService/utility.service';
31 import {NotificationsService} from 'angular2-notifications';
32 import 'rxjs/add/operator/map';
33 import { appConstants } from '../../../../constants/app-constants';
34 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
35
36
37 let YAML = require('yamljs');
38
39 declare var $: any;
40
41 @Injectable()
42 export class ParameterDefinitionService {
43     clName= "ParameterDefinitionSvc";
44     public vnfcTypeData: string = '';
45     public selectedUploadType: string;
46     @ViewChild(ModalComponent) modalComponent: ModalComponent;
47     public title: string;
48     public parameterDefinitionMap: { [index: string]: string; } = {};
49     public parameterNameValues = {};
50     public displayParamObjects;
51     public modelParamDefinitionObjects;
52     public vnfType: any;
53     vnfcType: any;
54     protocol: any;
55     public refNameObj = {};
56     public action;
57     public artifactName;
58     public type;
59     public appDataObject: any;
60     public downloadDataObject: any;
61     public artifact_fileName;
62     identifier: any;
63     public myKeyFileName = null;
64     public myPdFileName = null;
65     private selectedActionReference: any;
66     private apiToken = localStorage['apiToken'];
67     private userId = localStorage['userId'];
68     public versionNoForApiCall=require('../../../../cdt.application.properties.json').versionNoForApiCall;
69
70     constructor(private mappingEditorService: MappingEditorService,
71                 private paramShareService: ParamShareService,
72                 private nService: NotificationsService,
73                 private httpService: HttpUtilService,
74                 private utilService: UtilityService) {
75     }
76
77     public initialize() {
78
79     }
80
81     public setValues(vnfType, vnfcType, protocol, action, artifactName) {
82         this.vnfType = vnfType;
83         this.vnfcType = vnfcType;
84         this.protocol = protocol;
85         this.action = action;
86         this.artifact_fileName = artifactName;
87         this.appDataObject = this.mappingEditorService.appDataObject;
88         this.downloadDataObject = this.mappingEditorService.downloadDataObject;
89     }
90
91     public afterInit(artifactName, displayParamObjects) {
92
93     }
94
95     //========================== End of saveChanges() Method============================================
96     /* Saves pd to appc */
97     public sendPD(yamlString: String) {
98         let result: any;
99         let input = this.utilService.createPayLoadForSave("pd_data",this.vnfType,this.action,this.artifact_fileName, this.versionNoForApiCall, yamlString);
100         /*let payload = '{"userID": "' + this.userId + '","vnf-type" : "' + this.vnfType + '","action" : "' + this.action + '","artifact-name" : "' + this.artifact_fileName + '","artifact-type" : "APPC-CONFIG","artifact-version" : "0.0.1","artifact-contents" : ' + yamlString + '}';
101         let input = {
102             'input': {
103                 'design-request': {
104                     'request-id': this.apiToken,
105                     'action': 'uploadArtifact',
106                     'payload': payload
107                 }
108             }
109         };*/
110         this.appDataObject.pd = input;
111     }
112
113
114     //========================== End of filetrByFieldChanged() Method============================================
115     removeUnwantedvalues(obj) {
116         let result = Object.assign({}, obj);
117         result['vnf-parameter-list'].forEach(obj => {
118             delete obj['ruleTypeValues'];
119             delete obj['showFilterFields'];
120             delete obj['enableFilterByValue'];
121         });
122         return result;
123     }
124
125     //.. setup display of each parameter row depending on the paramater name,
126     //   pre-set values of source and rule-type fields (columns)
127     populateDataUponSource( displayParamObjects) {
128       var methName= "populateDataUponSource";
129       if( this.utilService.getTracelvl() > 0 )
130         console.log( this.clName+": "+methName+": start: displayParamObjects "+
131           "length="+displayParamObjects.length );
132         displayParamObjects.forEach( parameter => {
133           if( this.utilService.getTracelvl() > 0 )
134             console.log( this.clName+": "+methName+": param: name:["+
135               parameter.name+"] source:["+
136               parameter.source+"] rule-type:["+parameter['rule-type']+"]");
137             if( parameter.name == 'NodeList-DD') {
138               if( this.utilService.getTracelvl() > 0 )
139                 console.log( this.clName+": "+methName+": the Param is NodeList");
140               parameter.source= "DataDictionary";
141             }
142             else if( parameter.name == 'vnfName-DD' ) {
143               if( this.utilService.getTracelvl() > 0 )
144                 console.log( this.clName+": "+methName+": the Param's vnfName-DD");
145               parameter.source= "A&AI";
146               parameter['rule-type']= "vnf-name";
147             };
148             if( parameter.source == 'A&AI') {
149               parameter.ruleTypeValues = [null, 'vnf-name', 'vm-name-list', 'vnfc-name-list', 'vnf-oam-ipv4-address', 'vnfc-oam-ipv4-address-list'];
150               if( parameter['rule-type'] == 'vm-name-list' ||
151                   parameter['rule-type'] == 'vnfc-name-list' ||
152                   parameter['rule-type'] == 'vnfc-oam-ipv4-address-list')
153               {
154                  parameter.showFilterFields = true;
155                  parameter.enableFilterByValue = false;
156               } else {
157                  parameter.showFilterFields = false;
158               }
159             }
160             else if( parameter.source == 'Manual') {
161                 parameter.ruleTypeValues = [null];
162             }
163             else if( parameter.source == 'DataDictionary') {
164                 parameter.sourceValues = ['DataDictionary'];
165                 parameter.ruleTypeValues = ['NodeList'];
166                 parameter['rule-type']= 'NodeList';
167             }
168             else {
169                 parameter.ruleTypeValues = [parameter['rule-type']];
170             }
171           //.. print-out the parameter's drop-downs for source and rule-type
172           if( this.utilService.getTracelvl() > 1 ) {
173             if( parameter.sourceValues != null &&
174                 parameter.sourceValues != undefined )
175             {
176               console.log( this.clName+": "+methName+": sourceValues length="+
177                 parameter.sourceValues.length );
178               if( parameter.sourceValues.length > 0 ) {
179                 for( var i0=0; i0 < parameter.sourceValues.length; i0++ )
180                   console.log( methName+": sourceValues["+i0+"]:["+
181                     parameter.sourceValues[i0]+"]");
182               };
183             };
184             if( parameter.ruleTypeValues != null &&
185                 parameter.ruleTypeValues != undefined )
186             {
187               console.log( this.clName+": "+methName+": ruleTypeValues length="+
188                 parameter.ruleTypeValues.length );
189               if( parameter.ruleTypeValues.length > 0 ) {
190                 for( var i0=0; i0 < parameter.ruleTypeValues.length; i0++ )
191                   console.log( methName+": ruleTypeValues["+i0+"]:["+
192                     parameter.ruleTypeValues[i0]+"]");
193               };
194             };
195           };
196         });
197     }
198
199     //========================== End of getPD() Method============================================
200     populatePD(result: any) {
201         let fileContent = JSON.stringify(result);
202         //Added code to deserialize, serialize and format the response keys for display purposes ??May be unneessary?? To Do: - Check 
203         let fileObj = JSON.parse(fileContent);
204         this.displayParamObjects = this.formatFileContentForDisplay(fileObj);
205         this.populateDataUponSource( this.displayParamObjects);
206         this.formatResponseForKey(this.displayParamObjects);
207         if (undefined !== this.displayParamObjects)
208             this.modelParamDefinitionObjects = this.displayParamObjects;
209         if (this.displayParamObjects !== undefined && this.displayParamObjects.length > 0) {
210             this.paramShareService.setSessionParamData(this.displayParamObjects);
211         }
212         return this.displayParamObjects;
213     }
214
215     /* Formats each object read from YAML file as per page expectations */
216     formatResponseForKey(param: any[]) {
217         for (var i = 0; i < param.length; i++) {
218             this.formatKeys(param[i]);
219         }
220     }
221
222     //========================== End of formatResponseForKey() Method============================================
223     /* Formats for responsekeys of each object */
224     formatKeys(parameterDefinitionObject: any) {
225         if (null == parameterDefinitionObject || undefined === parameterDefinitionObject)
226             return;
227         if (null == parameterDefinitionObject['response-keys'])
228             parameterDefinitionObject['response-keys'] = [{}];
229         for (var j = 0; j < 5; j++) {
230             var keysObj = {
231                 'key-name': null,
232                 'key-value': null
233             };
234             if (undefined == parameterDefinitionObject['response-keys'][j] || null == parameterDefinitionObject['response-keys'][j]) {
235                 parameterDefinitionObject['response-keys'].push(keysObj);
236             }
237             if (undefined == parameterDefinitionObject['response-keys'][j]['key-name']) {
238                 parameterDefinitionObject['response-keys'][j]['key-name'] = null;
239             }
240             if (undefined == parameterDefinitionObject['response-keys'][j]['key-value']) {
241                 parameterDefinitionObject['response-keys'][j]['key-value'] = null;
242             }
243         }
244         if (null == parameterDefinitionObject['request-keys'])
245             parameterDefinitionObject['request-keys'] = [{}];
246         for (var k = 0; k < 3; k++) {
247             var keysObj = {
248                 'key-name': null,
249                 'key-value': null
250             };
251             if (undefined == parameterDefinitionObject['request-keys'][k] || null == parameterDefinitionObject['request-keys'][k]) {
252                 parameterDefinitionObject['request-keys'].push(keysObj);
253             }
254             if (undefined == parameterDefinitionObject['request-keys'][k]['key-name']) {
255                 parameterDefinitionObject['request-keys'][k]['key-name'] = null;
256             }
257             if (undefined == parameterDefinitionObject['request-keys'][k]['key-value']) {
258                 parameterDefinitionObject['request-keys'][k]['key-value'] = null;
259             }
260         }
261     }
262     //========================== End of formatKeys() Method============================================
263
264     //Send null if there are no keys present - Check with key names being absent
265     formatKeysForFileGeneration() {
266         for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
267             if (this.modelParamDefinitionObjects[i]['response-keys'][0]['key-name'] == null && this.modelParamDefinitionObjects[i]['response-keys'][1]['key-name'] == null && this.modelParamDefinitionObjects[i]['response-keys'][2]['key-name'] == null)
268                 this.modelParamDefinitionObjects[i]['response-keys'] = null;
269             if (this.modelParamDefinitionObjects[i]['request-keys'][0]['key-name'] == null && this.modelParamDefinitionObjects[i]['request-keys'][1]['key-name'] == null && this.modelParamDefinitionObjects[i]['request-keys'][2]['key-name'] == null)
270                 this.modelParamDefinitionObjects[i]['request-keys'] = null;
271         }
272     }
273
274     //========================== End of formatKeysForFileGeneration() Method============================================
275     /* Fn to restore response keys in desired format per backend consumption*/
276     processResponseKeys(saveModel: any[]) {
277         for (var i = 0; i < saveModel.length; i++) {
278             if (saveModel[i]['response-keys'] != null) {
279                 saveModel[i]['response-keys-new'] = [{}];
280                 saveModel[i]['response-keys-new'][0] = {};//An array of objects ?? so accessing first element
281                 if (undefined != saveModel[i]['response-keys'][0]['key-name'] && undefined != saveModel[i]['response-keys'][0]['key-value']) {
282                     let keyName1 = saveModel[i]['response-keys'][0]['key-name'];
283                     saveModel[i]['response-keys-new'][0][keyName1] = saveModel[i]['response-keys'][0]['key-value'];
284                 }
285                 if (undefined != saveModel[i]['response-keys'][1]['key-name'] && undefined != saveModel[i]['response-keys'][1]['key-value']) {
286                     let keyName2 = saveModel[i]['response-keys'][1]['key-name'];
287                     saveModel[i]['response-keys-new'][0][keyName2] = saveModel[i]['response-keys'][1]['key-value'];
288                 }
289                 if (undefined != saveModel[i]['response-keys'][2]['key-name'] && undefined != saveModel[i]['response-keys'][2]['key-value']) {
290                     let keyName3 = saveModel[i]['response-keys'][2]['key-name'];
291                     saveModel[i]['response-keys-new'][0][keyName3] = saveModel[i]['response-keys'][2]['key-value'];
292                 }
293                 if (saveModel[i]['response-keys'][3]['key-value'] != undefined && saveModel[i]['response-keys'][3]['key-value'] != null) {
294                     let keyName4 = saveModel[i]['response-keys'][3]['key-name'];
295                     saveModel[i]['response-keys-new'][0]['filter-by-key'] = saveModel[i]['response-keys'][3]['key-value'];
296                 }
297                 if (saveModel[i]['response-keys'][4]['key-value'] != undefined && saveModel[i]['response-keys'][4]['key-value'] != null) {
298                     let keyName4 = saveModel[i]['response-keys'][4]['key-name'];
299                     saveModel[i]['response-keys-new'][0]['filter-by-value'] = saveModel[i]['response-keys'][4]['key-value'];
300                 }
301             }
302             else {
303                 saveModel[i]['response-keys-new'] = null;
304             }
305             delete saveModel[i]['response-keys'];
306             saveModel[i]['response-keys'] = saveModel[i]['response-keys-new'];
307             delete saveModel[i]['response-keys-new'];
308         }
309         return saveModel;
310     }
311
312     //========================== End of processResponseKeys() Method============================================
313     /*Fn to format response keys for front end display */
314     formatFileContentForDisplay(fileModel: any[]) {
315         for (var i = 0; i < fileModel.length; i++) {
316             if (undefined != fileModel[i]['response-keys']) {
317                 let testObj = fileModel[i]['response-keys'];
318                 let keyNum = 0;
319                 fileModel[i]['response-keys-new'] = [{}];
320                 for (var prop in testObj[0]) {
321                     if (testObj[0].hasOwnProperty(prop)) {
322                         let key = prop;
323                         fileModel[i]['response-keys-new'][keyNum] = {};
324                         fileModel[i]['response-keys-new'][keyNum]['key-name'] = key;
325                         fileModel[i]['response-keys-new'][keyNum]['key-value'] = testObj[0][key];
326                     }
327                     keyNum++;
328                 }
329                 delete fileModel[i]['response-keys'];
330                 fileModel[i]['response-keys'] = fileModel[i]['response-keys-new'];
331                 delete fileModel[i]['response-keys-new'];
332             }
333         }
334         return fileModel;
335     }
336
337     //========================== End of openModal() Method============================================
338     getCorrectParameterDefinitionObject(paramName: string) {
339         var result = {
340             'obj': {},
341             'present': false
342         };
343         for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
344             var paramObj = this.modelParamDefinitionObjects[i];
345             if (paramObj.name === paramName) {
346                 result.obj = this.modelParamDefinitionObjects[i];
347                 result.present = true;
348                 return result;
349             }
350         }
351         var parameterDefinitionObject = {
352             'name': paramName,
353             'type': null,
354             'description': null,
355             'required': null,
356             'default': null,
357             'source': null,
358             'rule-type': null,
359             'response-keys': [{}],
360             'request-keys': [{}]
361         };
362         result.obj = parameterDefinitionObject;
363         result.present = false;
364         return result;
365     }
366
367     //========================== End of clearSessionStorageForParam() Method============================================
368     isValidateSourceAndResponseKeys(objs: any[]) {
369         let isValid = true;
370         if (undefined != objs || null != objs) {
371             for (var i = 0; i < objs.length; i++) {
372                 if (objs[i].source == 'INSTAR' && (null == objs[i]['response-keys'] || undefined == objs[i]['response-keys'])) {
373                     isValid = false;
374                     return isValid;
375                 }
376             }
377         }
378         return isValid;
379     }
380
381
382     
383     public destroy(displayParamObjects) {
384         this.displayParamObjects = displayParamObjects;
385         if (this.mappingEditorService.referenceNameObjects) {
386             this.saveChanges('send');
387             this.saveChanges('download');
388             this.mappingEditorService.changeNavAppData(this.appDataObject);
389             this.mappingEditorService.changeNavDownloadData(this.downloadDataObject);
390         }
391     }
392
393     //========================== End of fileChangeEvent() Method============================================
394     /* Saves pd file in YAML format */
395     public saveChanges(downLoadOrSend: String) {
396         if (undefined != this.displayParamObjects && null != this.displayParamObjects && this.displayParamObjects.length > 0) {
397             this.paramShareService.setSessionParamData(this.displayParamObjects);
398
399             //Generate File Name per given rules - if not, return without saving
400             this.modelParamDefinitionObjects = this.displayParamObjects.slice(0);
401             this.paramShareService.setDisplayData(this.displayParamObjects);
402             this.formatKeysForFileGeneration();
403             //Added code to serialize, deserialize and then make changes needed to save response keys as needed in pd file
404             let jsonString = JSON.stringify(this.modelParamDefinitionObjects, null, '\t');
405             jsonString = jsonString.replace(/"null"/g, 'null');
406             let saveModel = JSON.parse(jsonString);
407             let pdFileObject = this.processResponseKeys(saveModel);
408             //Validate for Source =INSTAR and responsekeys present
409             if (this.isValidateSourceAndResponseKeys(pdFileObject)) {
410                 let yamlObject = {
411                     'kind': 'Property Definition',
412                     'version': 'V1',
413                     'vnf-parameter-list': []
414                 };
415                 yamlObject['vnf-parameter-list'] = pdFileObject;
416                 yamlObject = this.removeUnwantedvalues(yamlObject);
417                 let yamlStringTemp = YAML.stringify(yamlObject, 6, 1);
418                 var re = /\'/gi;
419                 var newYamlStringTemp = yamlStringTemp.replace(re, '"');
420                 var re2 = / -\n  +/gi;
421                 var newYamlStringTemp2 = newYamlStringTemp.replace(re2, '- ');
422                 let yamlString = '---\n' + newYamlStringTemp2;
423                 if (downLoadOrSend === 'download') {
424                     var blob = new Blob([yamlString], {
425                         type: 'text/plain'
426                     });
427                     //let fileName = "pd_" + this.action + "_" + this.type + "_0.0.1V.yaml"
428                     this.downloadDataObject.pd.pdData = yamlString;
429                     this.downloadDataObject.pd.pdFileName = this.artifact_fileName;
430                 }
431                 else {
432                     this.sendPD(JSON.stringify(yamlString));
433                 }
434             }
435             else {
436                 for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
437                     this.formatKeys(this.modelParamDefinitionObjects[i]);
438                 }
439                 this.nService.error('Error', 'Response Keys cannot be empty if source is INSTAR');
440                 return;
441             }
442             //Restore Keys for display
443             for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
444                 this.formatKeys(this.modelParamDefinitionObjects[i]);
445             }
446         }
447
448     }
449
450
451     //This method will create parameter definitions as an array of objects from template name-value pairs and associative array for value from external key file if present
452     createOrUpdateParameterDefinitionData(usecase) {
453         this.parameterNameValues = JSON.parse(localStorage['paramsContent']);
454         this.parameterDefinitionMap = this.paramShareService.getData();
455         //Return if there are no name-value pairs or send some alert notification
456         if (undefined != this.modelParamDefinitionObjects && this.modelParamDefinitionObjects.length > 0 && usecase == 'create') {
457             //Do not recreate if object is already created
458             return;
459         }
460         else {
461         }
462         this.parameterDefinitionMap = this.paramShareService.getData();
463         //To Do:: Add Check for empty parameterDefinitionmap
464         var nameValueObj = {}, pName, pValue;
465         for (var key in this.parameterNameValues) {
466             if (this.parameterNameValues.hasOwnProperty(key)) {
467                 pName = key;
468                 pValue = this.parameterNameValues[key];
469             }
470
471             if (this.parameterDefinitionMap !== undefined)
472             //Check if parameter exists - if so, just update the keys, else create new object
473                 var result = this.getCorrectParameterDefinitionObject(pName);
474             var parameterDefinitionObject = result.obj;
475             if (parameterDefinitionObject['source'] != 'A&AI' && (undefined !== this.parameterDefinitionMap) && (undefined !== this.parameterDefinitionMap[pValue.toUpperCase()])) {
476                 var fields = this.parameterDefinitionMap[pValue.toUpperCase()].split('|');
477                 //Starts with 2, first vallue is source, second is rule-type
478                 let respInd = 0;
479                 for (var i = 2; i < fields.length; i += 2) {
480                     parameterDefinitionObject['response-keys'][respInd] = {};
481                     parameterDefinitionObject['response-keys'][respInd]['key-name'] = fields[i];
482                     if ((i + 1) < fields.length) {
483                         parameterDefinitionObject['response-keys'][respInd]['key-value'] = fields[i + 1];
484                     }
485                     respInd++;
486                 }
487                 parameterDefinitionObject['source'] = fields[0];
488                 parameterDefinitionObject['rule-type'] = fields[1];
489             } else {
490                 if (parameterDefinitionObject['source'] === 'INSTAR') {
491                     parameterDefinitionObject['source'] = 'Manual';
492                     parameterDefinitionObject['ruleTypeValues'] = [null];
493                     parameterDefinitionObject['rule-type'] = null;
494                     parameterDefinitionObject['showFilterFields'] = false;
495                     for (let x = 0; x < 5; x++) {
496                         parameterDefinitionObject['response-keys'][x]['key-name'] = null;
497                         parameterDefinitionObject['response-keys'][x]['key-value'] = null;
498                     }
499                 }
500             }
501             this.formatKeys(parameterDefinitionObject); //Ensure there are 3 elements for response-keys, request-keys for display purposes
502             if (!result.present) { //only push if not present
503                 this.modelParamDefinitionObjects.push(parameterDefinitionObject);
504             }
505         }
506         for (var indx in this.modelParamDefinitionObjects) {
507             if (this.modelParamDefinitionObjects[indx] != undefined && (this.modelParamDefinitionObjects[indx].source == undefined || this.modelParamDefinitionObjects[indx].source == null || this.modelParamDefinitionObjects[indx].source == '')) {
508                 this.modelParamDefinitionObjects[indx].source = 'Manual';
509             }
510         }
511         this.displayParamObjects = this.modelParamDefinitionObjects.slice(0);
512         this.paramShareService.setDisplayData(this.displayParamObjects);
513     }
514
515     public processKeyFile(fileName, result) {
516         this.myKeyFileName = fileName;
517         if (!this.myKeyFileName.endsWith('.txt')) {
518             this.nService.error(appConstants.notifications.titles.error, appConstants.errors.notTxtFileError);
519         }
520         this.parameterDefinitionMap = {};
521         var rows = result.split(/\r\n|\r|\n/g);
522         for (var i = 1; i < rows.length; i++) { //Omit headings, so start from 1
523             let ind = rows[i].indexOf('|');
524             let key = rows[i].slice(0, ind);
525             let value = rows[i].slice(ind + 1);
526             this.parameterDefinitionMap[key.toUpperCase()] = value;
527         }
528         this.paramShareService.setData(this.parameterDefinitionMap);
529         //this.notificationService.notifySuccessMessage('External Key file successfully uploaded..');
530         let sessionVar = [{}];
531         sessionVar = this.paramShareService.getSessionParamData();
532         if (sessionVar !== undefined && sessionVar != null && sessionVar.length > 0) {
533             if (undefined == this.displayParamObjects)
534                 this.displayParamObjects = this.modelParamDefinitionObjects = [];
535             this.displayParamObjects = sessionVar;
536             this.modelParamDefinitionObjects = this.displayParamObjects;
537             if (localStorage['paramsContent'] && (undefined !== this.displayParamObjects) && (this.displayParamObjects.length > 0)) {
538                 this.createOrUpdateParameterDefinitionData('update');
539                 //update the session variable with the updated data
540                 this.paramShareService.setSessionParamData(this.displayParamObjects);
541             }
542         } else {
543             this.displayParamObjects = this.modelParamDefinitionObjects = [];
544         }
545         this.populateDataUponSource(this.displayParamObjects);
546         return this.displayParamObjects;
547     }
548
549     public processPDfile(fileName, result) {
550         this.myPdFileName = fileName;
551         if (!this.myPdFileName.endsWith('.yaml')) {
552             this.nService.error(appConstants.notifications.titles.error, appConstants.errors.notYAMLFileError);
553         }
554         var pdObject = YAML.parse(result);
555         let fileModel = pdObject['vnf-parameter-list'];
556         this.populatePD(fileModel);
557         return this.displayParamObjects;
558     }
559 }