ee57ec0384d0ac96e064bd641af10914dac41c25
[vid.git] / vid-webpack-master / src / app / shared / models / nodeModel.ts
1 import {VfcInstanceGroupMap} from "./vfcInstanceGroupMap";
2
3 export interface NodeModelResponseInterface {
4   customizationUuid: string;
5   name: string;
6   version: string;
7   description: string;
8   category: string;
9   uuid: string;
10   invariantUuid: string;
11   max: number;
12   min:number;
13 }
14 export interface Level1ModelResponseInterface extends NodeModelResponseInterface{
15   serviceType: string;
16   serviceRole: string;
17   subCategory: string;
18   customizationUuid: string;
19   serviceEcompNaming: boolean;
20   type: string;
21   modelCustomizationName: string;
22   vfcInstanceGroups: VfcInstanceGroupMap;
23   properties: Level1ModelProperties;
24 }
25 export class NodeModel {
26   name: string;
27   version: string;
28   description: string;
29   category: string;
30   uuid: string;
31   invariantUuid: string;
32   max: number;
33   min: number;
34   customizationUuid?: string;
35
36   constructor(serviceJson?: NodeModelResponseInterface) {
37     if (serviceJson) {
38       this.customizationUuid = serviceJson.customizationUuid;
39       this.name = serviceJson.name;
40       this.version = serviceJson.version;
41       this.description = serviceJson.description;
42       this.category = serviceJson.category;
43       this.uuid = serviceJson.uuid;
44       this.invariantUuid = serviceJson.invariantUuid;
45       this.max = serviceJson.max;
46       this.min = serviceJson.min;
47     }
48   }
49
50 }
51 export class Level1ModelProperties {
52   max_instances : number;
53   min_instances : number;
54 }
55
56
57
58 export class Level1Model extends NodeModel{
59   serviceType: string;
60   serviceRole: string;
61   subCategory: string;
62   customizationUuid: string;
63   serviceEcompNaming: boolean;
64   type: string;
65   modelCustomizationName: string;
66   vfcInstanceGroups: VfcInstanceGroupMap;
67   isEcompGeneratedNaming: boolean;
68   constructor(nodeJson?: Level1ModelResponseInterface) {
69     super(nodeJson);
70     if (nodeJson) {
71       this.serviceType = nodeJson.serviceType;
72       this.serviceRole = nodeJson.serviceRole;
73       this.subCategory = nodeJson.subCategory;
74       this.customizationUuid = nodeJson.customizationUuid;
75       this.isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(nodeJson);
76       this.type = nodeJson.type;
77       this.modelCustomizationName = nodeJson.modelCustomizationName;
78       this.vfcInstanceGroups = nodeJson.vfcInstanceGroups;
79       this.max = 1;
80       this.min = 0;
81       if (nodeJson.properties) {
82         this.min = nodeJson.properties.min_instances || 0;
83         this.max = nodeJson.properties.max_instances || 1;
84       }
85
86
87     }
88   }
89   private getIsEcompGeneratedNaming(vnfJson) {
90     const ecompGeneratedNaming = vnfJson.properties.ecomp_generated_naming;
91     return ecompGeneratedNaming === "true";
92   };
93 }