summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.ts
blob: b7e952a64a41004ca16b02b1f5cef8e8357593b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {Injectable} from "@angular/core";
import {NgRedux} from "@angular-redux/store";

import {ActivatedRouteSnapshot, Resolve} from "@angular/router";
import {Observable} from "rxjs";
import {AppState} from "../../store/reducers";
import {InstantiationTemplatesService} from "../../services/templateService/instantiationTemplates.service";
import {forkJoin} from "rxjs/observable/forkJoin";
import {AaiService} from "../../services/aaiService/aai.service";
import {ServiceInstance} from "../../models/serviceInstance";

@Injectable()
export class RecreateResolver implements Resolve<Observable<[any, ServiceInstance]>> {
  constructor(private _templateService: InstantiationTemplatesService,
              private _aaiService: AaiService,
              private _store: NgRedux<AppState>) {
  }

  resolve(route: ActivatedRouteSnapshot): Observable<[any, ServiceInstance]> {
    const serviceModelId: string = route.queryParamMap.get("serviceModelId");
    const jobId: string = route.queryParamMap.get("jobId");

    let serviceModelApi = this._aaiService.getServiceModelById(serviceModelId);
    let instantiationTemplateApi = this._templateService.retrieveAndStoreInstantiationTemplateTopology(jobId, serviceModelId);

    return forkJoin([serviceModelApi, instantiationTemplateApi])
  }

}