diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2019-08-27 16:01:01 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-09-09 07:01:36 +0000 |
commit | e1f7974f0badbd4440d5b7ea5f1b1cb2d4973818 (patch) | |
tree | 46be9cdc44cbb475527bc3c43df23d16f7579d29 /vid-webpack-master/src/app/shared/resolvers/viewEdit | |
parent | e25b88b5a7a0f3bf63ca7160a441b53145484bcc (diff) |
Adding feature: Replace vfmodule
Issue-ID: VID-603
Change-Id: I59068a0979d6fb733e4243c8f78921f396dc9d17
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Signed-off-by: Amichai Hemli <amichai.hemli@intl.att.com>
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/resolvers/viewEdit')
-rw-r--r-- | vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts index 404f390fb..d2f76e4f6 100644 --- a/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts +++ b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts @@ -1,11 +1,14 @@ import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; import {Injectable} from "@angular/core"; -import {Observable} from "rxjs"; +import {from, Observable} from "rxjs"; import {AaiService} from "../../services/aaiService/aai.service"; import {forkJoin} from "rxjs/observable/forkJoin"; import {AppState} from "../../store/reducers"; import {NgRedux} from "@angular-redux/store"; import {createServiceInstance} from "../../storeUtil/utils/service/service.actions"; +import {ServiceInstance} from "../../models/serviceInstance"; +import * as _ from "lodash"; +import {ModelInfo} from "../../models/modelInfo"; @Injectable() export class ViewEditResolver implements Resolve<Observable<boolean>> { @@ -14,26 +17,51 @@ export class ViewEditResolver implements Resolve<Observable<boolean>> { } resolve(route: ActivatedRouteSnapshot): Observable<boolean> { - const serviceModeId: string = route.queryParamMap.get("serviceModelId"); + const serviceModelId: string = route.queryParamMap.get("serviceModelId"); const serviceInstanceId: string = route.queryParamMap.get("serviceInstanceId"); const subscriberId: string = route.queryParamMap.get("subscriberId"); const serviceType: string = route.queryParamMap.get("serviceType"); - let serviceModelApi = this._aaiService.getServiceModelById(serviceModeId); - let serviceInstanceApi = this._aaiService.retrieveAndStoreServiceInstanceTopology(serviceInstanceId, subscriberId, serviceType, serviceModeId); - return forkJoin([serviceModelApi, serviceInstanceApi]).map(([serviceModel, serviceInstance ]) => { - this.setIsALaCarte(serviceInstance,serviceModel.service.vidNotions.instantiationType ); - this.setTestApi(serviceInstance); - this._store.dispatch(createServiceInstance( serviceInstance, serviceModeId)); - return true; - }); + let serviceModelApi = this._aaiService.getServiceModelById(serviceModelId); + let serviceInstanceApi = this._aaiService.retrieveAndStoreServiceInstanceTopology(serviceInstanceId, subscriberId, serviceType, serviceModelId); + let streams: Observable<any>[] = [serviceModelApi, serviceInstanceApi]; + streams = streams.filter( stream => stream !== undefined); + return forkJoin(streams).switchMap(([serviceModel, serviceInstance]) => { + return from(this.retrieveLatestVersionAndSetServiceInstance(serviceInstance.modelInfo.modelInvariantId).then((response)=>{ + this.setServiceLatestAvailableVersion(serviceInstance, response); + this.applyRequestsResponsesToStateAndInitServiceInstance(serviceModelId, serviceInstance, serviceModel); + return true; + })); + + }); + } + + private retrieveLatestVersionAndSetServiceInstance(modelInvariantId: string) :Promise<ModelInfo>{ + return this._aaiService.retrieveServiceLatestUpdateableVersion(modelInvariantId).toPromise(); + } + + applyRequestsResponsesToStateAndInitServiceInstance(serviceModelId: string, + serviceInstance, serviceModel) { + this.setIsALaCarte(serviceInstance, serviceModel.service.vidNotions.instantiationType); + this.setTestApi(serviceInstance); + this._store.dispatch(createServiceInstance(serviceInstance, serviceModelId)); } - setTestApi = (service: any) => { + setServiceLatestAvailableVersion(serviceInstance :ServiceInstance, modelInfoObject: ModelInfo) :void{ + if(!_.isNil(modelInfoObject) && !_.isNil(modelInfoObject.modelVersion)){ + serviceInstance.latestAvailableVersion = Number(modelInfoObject.modelVersion); + } + else { + serviceInstance.latestAvailableVersion = 0; + } + } + + setTestApi(service: any) :void{ if (this._store.getState().global.flags['FLAG_ADD_MSO_TESTAPI_FIELD'] && service.isALaCarte) { service.testApi = sessionStorage.getItem("msoRequestParametersTestApiValue"); } }; - setIsALaCarte = (service: any, instantiationType) => { + + setIsALaCarte(service: any, instantiationType) :void{ service.isALaCarte = instantiationType === 'ALaCarte'; }; |