blob: 15fb4fb0c539c42086a25d74f3d192363f62c3a9 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import {NodeModel, NodeModelResponseInterface} from "./nodeModel";
Ittay Sternf7926712019-07-07 19:23:03 +03002import {VidNotions} from "./vidNotions";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03003
4
5export interface ServiceModelResponseInterface extends NodeModelResponseInterface{
6
7 serviceType: string;
8 serviceRole: string;
9 serviceEcompNaming: boolean;
Ittay Stern6f900cc2018-08-29 17:01:32 +030010 vidNotions: any;
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030011}
12
13export class ServiceModel extends NodeModel{
14
15 serviceType: string;
16 serviceRole: string;
17 servicesQty: number;
Ittay Stern6f900cc2018-08-29 17:01:32 +030018 isEcompGeneratedNaming: boolean;
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030019 isMultiStepDesign: boolean;
Ittay Sternf7926712019-07-07 19:23:03 +030020 vidNotions?: VidNotions;
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030021
22 constructor(serviceModelJson?: any){
23 super(serviceModelJson.service);
24 if (serviceModelJson) {
25 const service: ServiceModelResponseInterface = serviceModelJson.service;
26 this.serviceType = service.serviceType;
27 this.serviceRole = service.serviceRole;
Ittay Stern6f900cc2018-08-29 17:01:32 +030028 this.vidNotions= service.vidNotions;
29 this.isEcompGeneratedNaming = this.getServiceEcompNaming(service);
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030030 this.isMultiStepDesign = this.getIsMultiStepDesign(serviceModelJson);
31 }
32 }
33
Ittay Stern6f900cc2018-08-29 17:01:32 +030034 private getServiceEcompNaming(serviceJson): boolean {
35 return serviceJson.serviceEcompNaming === "true";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030036 };
37
38 private getIsMultiStepDesign(serviceModel): boolean {
39 for (let key in serviceModel.vnfs) {
40 const vnf = serviceModel.vnfs[key];
41 if (vnf.properties.multi_stage_design === "true") {
42 return true
43 }
44 }
45 return false;
46 }
47}