Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | import {NodeModel, NodeModelResponseInterface} from "./nodeModel"; |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 2 | import {VidNotions} from "./vidNotions"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 3 | |
| 4 | |
| 5 | export interface ServiceModelResponseInterface extends NodeModelResponseInterface{ |
| 6 | |
| 7 | serviceType: string; |
| 8 | serviceRole: string; |
| 9 | serviceEcompNaming: boolean; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 10 | vidNotions: any; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | export class ServiceModel extends NodeModel{ |
| 14 | |
| 15 | serviceType: string; |
| 16 | serviceRole: string; |
| 17 | servicesQty: number; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 18 | isEcompGeneratedNaming: boolean; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 19 | isMultiStepDesign: boolean; |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 20 | vidNotions?: VidNotions; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 21 | |
| 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 Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 28 | this.vidNotions= service.vidNotions; |
| 29 | this.isEcompGeneratedNaming = this.getServiceEcompNaming(service); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 30 | this.isMultiStepDesign = this.getIsMultiStepDesign(serviceModelJson); |
| 31 | } |
| 32 | } |
| 33 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 34 | private getServiceEcompNaming(serviceJson): boolean { |
| 35 | return serviceJson.serviceEcompNaming === "true"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 36 | }; |
| 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 | } |