From 6b1e53d593a958254481f2043f6da8c6c96d4a0b Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Tue, 21 Jan 2020 12:20:37 +0200 Subject: originalName may be model's "entry name", customizationId or invariantId The classic originalName is the "entry name". So two more options were added through SharedTreeService::modelByIdentifier() function. Issue-ID: VID-724 Change-Id: I9f192d2b24c9c1659a95baabd21252bed392e9da Signed-off-by: Ittay Stern --- .../vfModuleGenerator/vfModule.control.generator.spec.ts | 8 +++++++- .../vfModuleGenerator/vfModule.control.generator.ts | 16 ++++++++++++---- .../genericFormPopup/generic-form-popup.service.spec.ts | 2 ++ .../vfModule/vfModule.popup.service.spec.ts | 2 ++ 4 files changed, 23 insertions(+), 5 deletions(-) (limited to 'vid-webpack-master/src/app/shared/components') diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts index f3d32b9bb..b3bb1fe54 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts @@ -6,12 +6,17 @@ import {AaiService} from "../../../../services/aaiService/aai.service"; import {GenericFormService} from "../../generic-form.service"; import {FormBuilder} from "@angular/forms"; import {LogService} from "../../../../utils/log/log.service"; -import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model"; +import { + FormControlModel, + ValidatorModel, + ValidatorOptions +} from "../../../../models/formControlModels/formControl.model"; import {FormControlNames, VfModuleControlGenerator} from "./vfModule.control.generator"; import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service"; import {VfModuleInstance} from "../../../../models/vfModuleInstance"; import {VfModule} from "../../../../models/vfModule"; import {SharedControllersService} from "../sharedControlles/shared.controllers.service"; +import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; class MockAppStore { getState() { @@ -925,6 +930,7 @@ describe('VFModule Control Generator', () => { AaiService, FormBuilder, LogService, + SharedTreeService, {provide:FeatureFlagsService, useClass: MockFeatureFlagsService}, {provide: NgRedux, useClass: MockAppStore}] }); diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts index 60ffc3e96..b00312d5f 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts @@ -20,6 +20,7 @@ import {VNFModel} from "../../../../models/vnfModel"; import {VnfInstance} from "../../../../models/vnfInstance"; import * as _ from 'lodash'; import {SharedControllersService} from "../sharedControlles/shared.controllers.service"; +import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; export enum FormControlNames { INSTANCE_NAME = 'instanceName', @@ -40,6 +41,7 @@ export class VfModuleControlGenerator { constructor(private genericFormService: GenericFormService, private _basicControlGenerator: ControlGeneratorUtil, private _sharedControllersService: SharedControllersService, + private _sharedTreeService: SharedTreeService, private store: NgRedux, private http: HttpClient, private _aaiService: AaiService, @@ -76,8 +78,7 @@ export class VfModuleControlGenerator { const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode)); const vfModuleModel = this.vfModuleModel; const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey]; - const vnfModelName: string = vnf.originalName; - const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfModelName]); + const vnfModel = this.newVNFModel(serviceId, vnf); let result: FormControlModel[] = []; @@ -90,6 +91,14 @@ export class VfModuleControlGenerator { return result; } + private newVNFModel(serviceId: string, vnf: VnfInstance) { + const vnfModelName: string = vnf.originalName; + + const serviceModelFromHierarchy = this.store.getState().service.serviceHierarchy[serviceId]; + const model = this._sharedTreeService.modelByIdentifier(serviceModelFromHierarchy, "vnfs", vnfModelName); + return new VNFModel(model); + } + pushInstanceAndVGToForm(result: FormControlModel[], vfModuleElement: any, serviceId: string, vnfModel: any, isALaCarte: boolean) :FormControlModel[]{ result.push(this.getInstanceName(vfModuleElement, serviceId, vnfModel.isEcompGeneratedNaming)); if (this.vfModuleModel.volumeGroupAllowed) { @@ -108,8 +117,7 @@ export class VfModuleControlGenerator { } } const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey] ; - const vnfModelName: string = vnf.originalName; - const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfModelName]); + const vnfModel = this.newVNFModel(serviceId, vnf); const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode)); let result: FormControlModel[] = []; diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts index 9680c0655..e69cd5692 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts @@ -24,6 +24,7 @@ import {VfModuleUpgradePopupService} from "./genericFormServices/vfModuleUpgrade import {SharedControllersService} from "../genericForm/formControlsServices/sharedControlles/shared.controllers.service"; import {AppState} from "../../store/reducers"; import each from 'jest-each'; +import {SharedTreeService} from "../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; class MockAppStore{ getState() { @@ -977,6 +978,7 @@ describe('Generic Form popup Service', () => { VfModuleUpgradePopupService, VfModuleControlGenerator, FeatureFlagsService, + SharedTreeService, {provide: ActivatedRoute, useClass: ActivatedRouteMock}, {provide: NgRedux, useClass: MockAppStore}] }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts index 85626528b..b8a592247 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts @@ -14,6 +14,7 @@ import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flag import {getTestBed, TestBed} from "@angular/core/testing"; import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service"; import {ModalService} from "../../../customModal/services/modal.service"; +import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; class MockModalService {} @@ -1993,6 +1994,7 @@ describe('VFModule popup service', () => { AaiService, LogService, BasicPopupService, + SharedTreeService, {provide:FeatureFlagsService, useClass: MockFeatureFlagsService}, {provide: NgRedux, useClass: MockReduxStore}, {provide: HttpClient, useClass: MockAppStore}, -- cgit 1.2.3-korg