summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/shared/storeUtil/utils/vfModule
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/vfModule')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts105
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts248
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts165
3 files changed, 518 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts
new file mode 100644
index 000000000..a3f0f4009
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts
@@ -0,0 +1,105 @@
+import {Action, ActionCreator} from "redux";
+
+export enum VfModuleActions {
+ REMOVE_VNF_MODULE_INSTANCE = 'REMOVE_VNF_MODULE_INSTANCE',
+ CREATE_VF_MODULE = 'CREATE_VF_MODULE',
+ UPDATE_VF_MODULE = 'UPDATE_VF_MODULE',
+ DELETE_ACTION_VF_MODULE_INSTANCE = "DELETE_ACTION_VF_MODULE_INSTANCE",
+ UNDO_DELETE_ACTION_VF_MODULE_INSTANCE = "UNDO_DELETE_ACTION_VF_MODULE_INSTANCE",
+ UPDATE_VFMODULE_POSITION = "UPDATE_VFMODULE_POSITION"
+}
+
+
+export interface UpdateVFModluePosition extends Action {
+ node: any,
+ instanceId : string,
+ vnfStoreKey ?: string;
+}
+
+export interface DeleteVfModuleInstanceAction extends Action {
+ modelName?: string;
+ serviceModelId?: string;
+ vfName?: string;
+ vnfStoreKey?:string;
+ dynamicModelName?: string;
+}
+
+export interface CreateVFModuleInstanceAction extends Action {
+ vfInstance: any;
+ vfId: string;
+ serviceUuid: string;
+ index : number
+ vnfStoreKey : string;
+}
+
+export interface UpdateVFModuleInstanceAction extends Action {
+ vfInstance: any;
+ vfId: string;
+ serviceUuid: string;
+ dynamicModelName : string;
+ vnfStoreKey : string
+}
+
+
+export interface DeleteActionVfModuleInstanceAction extends Action {
+ dynamicModelName: string;
+ vnfStoreKey : string;
+ serviceId?: string;
+}
+
+export interface UndoDeleteActionVfModuleInstanceAction extends Action {
+ dynamicModelName: string;
+ vnfStoreKey : string;
+ serviceId?: string;
+}
+
+export const removeVfModuleInstance: ActionCreator<DeleteVfModuleInstanceAction> = (modelName, serviceModelId, vfName, vnfStoreKey, dynamicModelName) => ({
+ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE,
+ modelName: modelName,
+ serviceModelId: serviceModelId,
+ vfName: vfName,
+ vnfStoreKey : vnfStoreKey,
+ dynamicModelName:dynamicModelName
+});
+
+
+export const createVFModuleInstance: ActionCreator<CreateVFModuleInstanceAction> = (vfInstance, vfId, serviceUuid, index, vnfStoreKey) => ({
+ type: VfModuleActions.CREATE_VF_MODULE,
+ vfInstance: vfInstance,
+ vfId: vfId,
+ serviceUuid: serviceUuid,
+ index : index,
+ vnfStoreKey : vnfStoreKey
+});
+
+export const updateVFModuleInstance: ActionCreator<UpdateVFModuleInstanceAction> = (vfInstance, vfId, serviceUuid, dynamicModelName, vnfStoreKey) => ({
+ type: VfModuleActions.UPDATE_VF_MODULE,
+ vfInstance: vfInstance,
+ vfId: vfId,
+ serviceUuid: serviceUuid,
+ dynamicModelName : dynamicModelName,
+ vnfStoreKey : vnfStoreKey
+});
+
+export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({
+ type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
+ dynamicModelName: dynamicModelName,
+ vnfStoreKey : vnfStoreKey,
+ serviceId: serviceId
+});
+
+export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({
+ type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE,
+ dynamicModelName: dynamicModelName,
+ vnfStoreKey : vnfStoreKey,
+ serviceId: serviceId
+});
+
+
+export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (node, instanceId, vnfStoreKey) => ({
+ type: VfModuleActions.UPDATE_VFMODULE_POSITION,
+ node: node,
+ instanceId: instanceId,
+ vnfStoreKey : vnfStoreKey
+});
+
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
new file mode 100644
index 000000000..de6d2142c
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts
@@ -0,0 +1,248 @@
+import {
+ CreateVFModuleInstanceAction,
+ DeleteActionVfModuleInstanceAction,
+ DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition,
+ VfModuleActions
+} from "./vfModule.actions";
+import {vfModuleReducer} from "./vfModule.reducers";
+import {VfModuleInstance} from "../../../models/vfModuleInstance";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+
+
+describe('vfModuleReducer', () => {
+ test('#REMOVE_VNF_MODULE_INSTANCE : should delete existing vnf module by dynamicModelName', () => {
+ let state = vfModuleReducer(<any>{serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vfName' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName1': {},
+ 'dynamicModelName2': {},
+ }
+ }
+ }
+ }
+ }
+ }},
+ <DeleteVfModuleInstanceAction>{
+ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE,
+ modelName : 'modelName',
+ vfName : 'vfName',
+ vnfStoreKey : 'vfName',
+ serviceModelId : 'serviceModelId',
+ dynamicModelName: 'dynamicModelName1'
+ });
+
+ expect(state).toBeDefined();
+ expect(state.serviceInstance['serviceModelId'].vnfs['vfName'].vfModules['modelName']['dynamicModelName2']).toBeDefined();
+ expect(state.serviceInstance['serviceModelId'].vnfs['vfName'].vfModules['modelName']['dynamicModelName1']).not.toBeDefined();
+ });
+
+ test('#DELETE_LAST_VNF_MODULE_INSTANCE : should delete existing vnf module', () => {
+ let state = vfModuleReducer(<any>{serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vfName' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName': {
+ }
+ }
+ }
+ }
+ }
+ }
+ }},
+ <DeleteVfModuleInstanceAction>{
+ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE,
+ modelName : 'modelName',
+ vfName : 'vfName',
+ vnfStoreKey : 'vfName',
+ serviceModelId : 'serviceModelId',
+ dynamicModelName: 'dynamicModelName'
+ });
+
+ expect(state).toBeDefined();
+ expect(state.serviceInstance['serviceModelId'].vnfs['vfName'].vfModules['modelName']).not.toBeDefined();
+ });
+
+ test('#CREATE_VF_MODULE: should create new vfModule to existing VNF', ()=>{
+ let vfModuleInstance : VfModuleInstance = new VfModuleInstance();
+ vfModuleInstance.instanceName = 'instanceName';
+ vfModuleInstance.isMissingData = false;
+ vfModuleInstance.volumeGroupName = 'volumeGroupName';
+ let vfModule = vfModuleReducer(<any>{serviceInstance : {
+ 'serviceUuid' : {
+ vnfs : {
+ 'vnfStoreKey' : {
+ 'vfModules' : {
+ }
+ }
+ }
+ }
+ }},
+ <CreateVFModuleInstanceAction>{
+ type: VfModuleActions.CREATE_VF_MODULE,
+ vfId : 'vfId',
+ vfInstance : new VfModuleInstance(),
+ vnfStoreKey : 'vnfStoreKey',
+ serviceUuid : 'serviceUuid',
+ index : 1
+ }).serviceInstance['serviceUuid'].vnfs['vnfStoreKey'].vfModules;
+
+ let firstVfModuleName = Object.keys(vfModule)[0];
+ expect(vfModule[firstVfModuleName]).toBeDefined();
+ expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy();
+ });
+
+ test('#UPDATE_VF_MODULE: should update existing VFModule', ()=>{
+ let vfModuleInstance : VfModuleInstance = new VfModuleInstance();
+ vfModuleInstance.instanceName = 'instanceName';
+ vfModuleInstance.isMissingData = false;
+ vfModuleInstance.volumeGroupName = 'volumeGroupName';
+ let vfModule = vfModuleReducer(<any>{
+ serviceHierarchy : {
+ 'serviceModelId' : {}
+ },
+ serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vfName' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName1': {
+ isMissingData : true
+ },
+ 'dynamicModelName2': {},
+ }
+ }
+ }
+ }
+ }
+ }},
+ <CreateVFModuleInstanceAction>{
+ type: VfModuleActions.UPDATE_VF_MODULE,
+ vfId : 'modelName',
+ vfInstance : new VfModuleInstance(),
+ vnfStoreKey : 'vfName',
+ dynamicModelName : 'dynamicModelName1',
+ serviceUuid : 'serviceModelId',
+ index : 1
+ }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules;
+
+ let firstVfModuleName = Object.keys(vfModule)[0];
+ expect(vfModule[firstVfModuleName]).toBeDefined();
+ expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy();
+ });
+
+
+ test('#UPDATE_VFMODULE_POSITION: should update position', ()=>{
+ let vfModule = vfModuleReducer(<any>{
+ serviceHierarchy : {
+ 'serviceModelId' : {}
+ },
+ serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vfName' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName': {
+ isMissingData : true
+ }
+ }
+ }
+ }
+ }
+ }
+ }},
+ <UpdateVFModluePosition>{
+ type: VfModuleActions.UPDATE_VFMODULE_POSITION,
+ node: {
+ position : 1,
+ dynamicModelName : "dynamicModelName",
+ modelName : "modelName"
+ },
+ instanceId : "serviceModelId",
+ vnfStoreKey : "vfName"
+
+ }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"];
+
+ expect(vfModule.position).toEqual(1);
+ });
+
+
+ test('#DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{
+ let vfModule = vfModuleReducer(<any>{
+ serviceHierarchy : {
+ 'serviceModelId' : {}
+ },
+ serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vnfStoreKey' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName1': {
+ isMissingData : true,
+ action : 'None'
+ },
+ 'dynamicModelName2': {},
+ }
+ }
+ }
+ }
+ }
+ }},
+ <DeleteActionVfModuleInstanceAction>{
+ type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
+ dynamicModelName: 'dynamicModelName1',
+ vnfStoreKey : 'vnfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+
+ console.log(vfModule.action);
+ expect(vfModule).toBeDefined();
+ expect(vfModule.isMissingData).toBeTruthy();
+ expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete);
+ });
+
+ test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{
+ let vfModule = vfModuleReducer(<any>{
+ serviceHierarchy : {
+ 'serviceModelId' : {}
+ },
+ serviceInstance : {
+ 'serviceModelId' : {
+ vnfs : {
+ 'vnfStoreKey' : {
+ vfModules : {
+ 'modelName' : {
+ 'dynamicModelName1': {
+ isMissingData : true,
+ action : 'None_Delete'
+ },
+ 'dynamicModelName2': {},
+ }
+ }
+ }
+ }
+ }
+ }},
+ <UndoDeleteActionVfModuleInstanceAction>{
+ type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE,
+ dynamicModelName: 'dynamicModelName1',
+ vnfStoreKey : 'vnfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+
+ console.log(vfModule.action);
+ expect(vfModule).toBeDefined();
+ expect(vfModule.action).toEqual(ServiceInstanceActions.None);
+ });
+
+});
+
+
+
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
new file mode 100644
index 000000000..f3636ff41
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
@@ -0,0 +1,165 @@
+import {Action} from "redux";
+import * as _ from "lodash";
+import {
+ CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction,
+ DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition,
+ UpdateVFModuleInstanceAction,
+ VfModuleActions
+} from "./vfModule.actions";
+import {ServiceInstance} from "../../../models/serviceInstance";
+import {VfModuleMap} from "../../../models/vfModulesMap";
+import {ServiceState} from "../main.reducer";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+
+
+export function vfModuleReducer(state: ServiceState , action: Action) : ServiceState{
+ switch (action.type) {
+ case VfModuleActions.CREATE_VF_MODULE: {
+ const updateVFModuleInstanceAction = <CreateVFModuleInstanceAction>action;
+ const vfInstance = updateVFModuleInstanceAction.vfInstance;
+ const serviceUuid = updateVFModuleInstanceAction.serviceUuid;
+ const vfModuleId = updateVFModuleInstanceAction.vfId;
+ const vnfStoreKey = updateVFModuleInstanceAction.vnfStoreKey;
+
+ let newState = Object.assign({}, state);
+
+ let vfModulesMap = newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId] || new VfModuleMap();
+ let randomId = generateId();
+ vfModulesMap[vfModuleId + randomId] = vfInstance;
+ updateUniqueNames(null, vfInstance.instanceName, newState.serviceInstance[serviceUuid]);
+ updateUniqueNames(null, vfInstance.volumeGroupName, newState.serviceInstance[serviceUuid]);
+ updateServiceValidationCounter(newState, false, vfInstance['isMissingData'], serviceUuid);
+
+ newState.serviceInstance[serviceUuid].vnfs[vnfStoreKey].vfModules[vfModuleId] = vfModulesMap;
+ return newState;
+ }
+ case VfModuleActions.UPDATE_VF_MODULE: {
+ const updateVFModuleInstanceAction = <UpdateVFModuleInstanceAction>action;
+ const vfInstance = updateVFModuleInstanceAction.vfInstance;
+ const serviceUuid = updateVFModuleInstanceAction.serviceUuid;
+ const vfModuleId = updateVFModuleInstanceAction.vfId;
+ const newState = _.cloneDeep(state);
+ const vnfs = newState.serviceHierarchy[serviceUuid].vnfs;
+ let vnfId = getVfModuleParentVnfId(vnfs, vfModuleId);
+ const vnfStoreKey = updateVFModuleInstanceAction.vnfStoreKey;
+ if (!_.isNil(vnfStoreKey)) {
+ vnfId = vnfStoreKey;
+ }
+ let vfModulesMap = newState.serviceInstance[serviceUuid].vnfs[vnfId].vfModules[vfModuleId] || new VfModuleMap();
+ updateServiceValidationCounter(newState, vfModulesMap[updateVFModuleInstanceAction.dynamicModelName]['isMissingData'], vfInstance.isMissingData, serviceUuid);
+ updateUniqueNames(vfModulesMap[updateVFModuleInstanceAction.dynamicModelName].instanceName, vfInstance.instanceName, newState.serviceInstance[serviceUuid]);
+ updateUniqueNames(vfModulesMap[updateVFModuleInstanceAction.dynamicModelName].volumeGroupName, vfInstance.volumeGroupName, newState.serviceInstance[serviceUuid]);
+ vfModulesMap[updateVFModuleInstanceAction.dynamicModelName] = vfInstance;
+ newState.serviceInstance[serviceUuid].vnfs[vnfId].vfModules[vfModuleId] = vfModulesMap;
+ return newState;
+ }
+ case VfModuleActions.REMOVE_VNF_MODULE_INSTANCE: {
+ const actionData = (<DeleteVfModuleInstanceAction>action);
+ if (state.serviceInstance[actionData.serviceModelId]) {
+ let vfModulesMap = state.serviceInstance[actionData.serviceModelId].vnfs[actionData.vnfStoreKey].vfModules;
+ updateIsMissingDataOnDeleteVFModule(state, actionData.serviceModelId, actionData.vnfStoreKey, actionData.modelName);
+ updateUniqueNames(vfModulesMap[actionData.modelName][actionData.dynamicModelName].instanceName, null, state.serviceInstance[actionData.serviceModelId] );
+ updateUniqueNames(vfModulesMap[actionData.modelName][actionData.dynamicModelName].volumeGroupName, null, state.serviceInstance[actionData.serviceModelId] );
+ delete vfModulesMap[actionData.modelName][actionData.dynamicModelName];
+ if(_.isEmpty(vfModulesMap[actionData.modelName])){
+ delete vfModulesMap[actionData.modelName];
+ }
+ }
+ return Object.assign({}, state);
+ }
+ case VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let vfModules = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules;
+
+ for(let key in vfModules){
+ let firstKey = Object.keys(vfModules[key])[0];
+ if(firstKey === (<DeleteActionVfModuleInstanceAction>action).dynamicModelName){
+ let oldAction = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action;
+ if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key);
+ return newState;
+ }
+ }
+ return newState;
+ }
+ case VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let vfModules = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules;
+
+ for(let key in vfModules){
+ let firstKey = Object.keys(vfModules[key])[0];
+ if(firstKey === (<UndoDeleteActionVfModuleInstanceAction>action).dynamicModelName){
+ let oldAction = newState.serviceInstance[(<UndoDeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action;
+ newState.serviceInstance[(<UndoDeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction.split('_')[0]) as ServiceInstanceActions;
+ updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key);
+ return newState;
+ }
+ }
+ return newState;
+ }
+
+ case VfModuleActions.UPDATE_VFMODULE_POSITION : {
+ const updateVFModluePosition = <UpdateVFModluePosition>action;
+ const serviceUuid = updateVFModluePosition.instanceId;
+ const dynamicModelName = updateVFModluePosition.node.dynamicModelName;
+ const modelName = updateVFModluePosition.node.modelName;
+ const newState = _.cloneDeep(state);
+
+ newState.serviceInstance[serviceUuid].vnfs[updateVFModluePosition.vnfStoreKey].vfModules[modelName][dynamicModelName].position = updateVFModluePosition.node.position;
+ return newState;
+ }
+ }
+}
+
+const updateIsMissingDataOnDeleteVFModule = (state: any, serviceModelId: string, vnfStoreKey: string, vfModuleName): void => {
+ const vfModules = state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].vfModules[vfModuleName];
+
+ _.forOwn(vfModules, (vfModuleInstance) => {
+ let isMissingData: boolean = vfModuleInstance.isMissingData;
+ updateServiceValidationCounter(state, isMissingData, false, serviceModelId);
+ });
+};
+
+
+const updateUniqueNames = (oldName : string, newName : string, serviceInstance : ServiceInstance) : void => {
+ let existingNames = serviceInstance.existingNames;
+ if (!_.isNil(oldName) && oldName.toLowerCase() in existingNames) {
+ delete existingNames[oldName.toLowerCase()];
+ }
+ if(!_.isNil(newName)) {
+ existingNames[newName.toLowerCase()] = "";
+ }
+};
+
+const updateServiceValidationCounter = (newState: any, oldValidationState: boolean, newValidationState: boolean, serviceUuid: string) => {
+ if (oldValidationState && !newValidationState) {
+ newState.serviceInstance[serviceUuid].validationCounter--;
+ } else if (!oldValidationState && newValidationState) {
+ newState.serviceInstance[serviceUuid].validationCounter++;
+ }
+};
+
+const generateId = () => {
+ return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
+};
+const getVfModuleParentVnfId = (vnfs: object, vfModuleId: string) => {
+ let vnfId = undefined;
+ _.forOwn(vnfs, (value, key) => {
+ if (vnfs[key].vfModules && vnfs[key].vfModules[vfModuleId]) {
+ vnfId = vnfs[key].modelCustomizationName;
+ return false;
+ }
+ });
+ return vnfId;
+};
+
+
+
+
+
+
+
+
+
+