aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/models/serviceModel.ts
blob: 21a34cc95596acb181d5ff69c733b0b3c4968216 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {NodeModel, NodeModelResponseInterface} from "./nodeModel";
import * as _ from "lodash";


export interface ServiceModelResponseInterface extends NodeModelResponseInterface{

  serviceType: string;
  serviceRole: string;
  serviceEcompNaming: boolean;
  vidNotions: any;
}

export class ServiceModel extends NodeModel{

  serviceType: string;
  serviceRole: string;
  servicesQty: number;
  isEcompGeneratedNaming: boolean;
  isMultiStepDesign: boolean;
  vidNotions?: any;

  constructor(serviceModelJson?: any){
    super(serviceModelJson.service);
    if (serviceModelJson) {
      const service: ServiceModelResponseInterface = serviceModelJson.service;
      this.serviceType = service.serviceType;
      this.serviceRole = service.serviceRole;
      this.vidNotions= service.vidNotions;
      this.isEcompGeneratedNaming = this.getServiceEcompNaming(service);
      this.isMultiStepDesign = this.getIsMultiStepDesign(serviceModelJson);
    }
  }

  private getServiceEcompNaming(serviceJson): boolean {
    return serviceJson.serviceEcompNaming === "true";
  };

  private getIsMultiStepDesign(serviceModel): boolean {
    for (let key in serviceModel.vnfs) {
      const vnf = serviceModel.vnfs[key];
      if (vnf.properties.multi_stage_design === "true") {
        return true
      }
    }
    return false;
  }
}