From 0814238f615f3e3b855a53add72730b957f6c790 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Sun, 2 Feb 2020 18:09:40 +0200 Subject: NodeInfo::getModel expects the instance-model Now callers (objectToInstanceTree, objectToModelTree, etc.) pass the hierarchy itself, instead of providing only the service hierarchy and keys. Issue-ID: VID-724 Change-Id: I80cde29887d86b2cc986d96b220ff769562f38b8 Signed-off-by: Ittay Stern --- .../models/vrf/vrf.model.info.spec.ts | 92 +++------------------- .../objectsToTree/models/vrf/vrf.model.info.ts | 14 ++-- 2 files changed, 22 insertions(+), 84 deletions(-) (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf') diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.spec.ts index 07d4cee9b..f3e479aca 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.spec.ts @@ -32,6 +32,7 @@ describe('Vrf Model Info', () => { let _iframeService : IframeService; let _networkStepService : NetworkStepService; let _vpnStepService : VpnStepService; + let _featureFlagsService : FeatureFlagsService; let vrfModel: VrfModelInfo; beforeEach(() => { @@ -59,11 +60,12 @@ describe('Vrf Model Info', () => { _dialogService = injector.get(DialogService); _iframeService = injector.get(IframeService); _networkStepService = injector.get(NetworkStepService); + _featureFlagsService = injector.get(FeatureFlagsService); _vpnStepService = injector.get(VpnStepService); _store = injector.get(NgRedux); _componentInfoService = injector.get(ComponentInfoService); - vrfModel = new VrfModelInfo(_store,_sharedTreeService, _dialogService, _iframeService, _networkStepService, _vpnStepService); + vrfModel = new VrfModelInfo(_store,_sharedTreeService, _dialogService, _iframeService, _featureFlagsService, _networkStepService, _vpnStepService); }); @@ -94,9 +96,16 @@ describe('Vrf Model Info', () => { test('getModel should return VRF model with min and max are equal to 1 (hard coded)', () => { - let model: VrfModel = vrfModel.getModel('VRF Entry Configuration 0', { - originalName : 'VRF Entry Configuration 0' - }, getServiceHierarchy()); + let model: VrfModel = vrfModel.getModel({ + "uuid": "9cac02be-2489-4374-888d-2863b4511a59", + "invariantUuid": "b67a289b-1688-496d-86e8-1583c828be0a", + "properties": { + "ecomp_generated_naming": "false", + "type": "VRF-ENTRY", + }, + "type": "Configuration" + } + ); expect(model.properties['type']).toEqual('VRF-ENTRY'); expect(model.min).toEqual(1); expect(model.max).toEqual(1); @@ -159,80 +168,5 @@ describe('Vrf Model Info', () => { }; } - function getServiceHierarchy() { - return { - "service": { - "uuid": "f028b2e2-7080-4b13-91b2-94944d4c42d8", - "invariantUuid": "dfc2c44c-2429-44ca-ae26-1e6dc1f207fb", - "name": "infraVPN", - "version": "1.0", - "toscaModelURL": null, - "category": "Network Service", - "serviceType": "BONDING", - "serviceRole": "INFRASTRUCTURE-VPN", - "description": "ddd", - "serviceEcompNaming": "true", - "instantiationType": "A-La-Carte", - "inputs": {}, - "vidNotions": { - "instantiationUI": "macroService", - "modelCategory": "other", - "viewEditUI": "legacy" - } - }, - "vnfs": {}, - "networks": {}, - "collectionResources": {}, - "configurations": {}, - "fabricConfigurations": {}, - "serviceProxies": { - "misvpn_service_proxy 0": { - "uuid": "35186eb0-e6b6-4fa5-86bb-1501b342a7b1", - "invariantUuid": "73f89e21-b96c-473f-8884-8b93bcbd2f76", - "description": "A Proxy for Service MISVPN_SERVICE", - "name": "MISVPN_SERVICE Service Proxy", - "version": "3.0", - "customizationUuid": "4c2fb7e0-a0a5-4b32-b6ed-6a974e55d923", - "inputs": {}, - "commands": {}, - "properties": { - "ecomp_generated_naming": "false" - }, - "type": "Service Proxy", - "sourceModelUuid": "d5cc7d15-c842-450e-95ae-2a69e66dd23b", - "sourceModelInvariant": "c126ec86-59fe-48c0-9532-e39a9b3e5272", - "sourceModelName": "MISVPN_SERVICE" - } - }, - "vfModules": {}, - "volumeGroups": {}, - "pnfs": {}, - "vnfGroups": {}, - "vrfs": { - "VRF Entry Configuration 0": { - "uuid": "9cac02be-2489-4374-888d-2863b4511a59", - "invariantUuid": "b67a289b-1688-496d-86e8-1583c828be0a", - "description": "VRF Entry configuration object", - "name": "VRF Entry Configuration", - "version": "30.0", - "customizationUuid": "dd024d73-9bd1-425d-9db5-476338d53433", - "inputs": {}, - "commands": {}, - "properties": { - "ecomp_generated_naming": "false", - "type": "VRF-ENTRY", - "role": "INFRASTRUCTURE-CLOUD-VPN" - }, - "type": "Configuration", - "modelCustomizationName": "VRF Entry Configuration 0", - "sourceNodes": [], - "collectorNodes": null, - "configurationByPolicy": false - } - } - } - } - - }) diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts index 7b7437c5e..53985d07d 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts @@ -3,7 +3,6 @@ import {ComponentInfoType} from "../../../component-info/component-info-model"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component"; -import {VrfInstance} from "../../../../../shared/models/vrfInstance"; import {VrfTreeNode} from "../../../../../shared/models/vrfTreeNode"; import {VrfModel} from "../../../../../shared/models/vrfModel"; import {NgRedux} from "@angular-redux/store"; @@ -50,9 +49,8 @@ export class VrfModelInfo implements ILevelNodeInfo { updateDynamicInputsDataFromModel = (currentModel): any => []; - getModel = (vrfModelId: string, instance: VrfInstance, serviceHierarchy): VrfModel => { - const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); - return new VrfModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, vrfModelId)); + getModel = (instanceModel: any): VrfModel => { + return new VrfModel(instanceModel); }; @@ -111,7 +109,13 @@ export class VrfModelInfo implements ILevelNodeInfo { let counter: number = !_.isNil(this._store.getState().service.serviceInstance[serviceModelId]) ? (this._store.getState().service.serviceInstance[serviceModelId].existingVRFCounterMap[node.data.modelUniqueId] || 0) : 0; counter -= this._sharedTreeService.getExistingInstancesWithDeleteMode(node, serviceModelId, 'vrfs'); - const model = node.data.getModel(node.data.name, node.data, serviceHierarchy); + + const instanceModel = this._sharedTreeService.modelByIdentifiers( + serviceHierarchy, node.data.modelTypeName, + this._sharedTreeService.modelUniqueNameOrId(node.data), node.data.name + ); + + const model = node.data.getModel(instanceModel); const maxInstances: number = model.max; const isReachedLimit = !(maxInstances > counter); const showAddIcon = this._sharedTreeService.shouldShowAddIcon() && !isReachedLimit; -- cgit 1.2.3-korg