Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 1 | 'use strict'; |
2 | |||||
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 3 | export class OperationParameter { |
4 | name: string; | ||||
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 5 | type: String; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 6 | inputId: string; |
7 | required: boolean; | ||||
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 8 | |
Arielk | c21ba95 | 2019-04-21 16:07:44 +0300 | [diff] [blame] | 9 | constructor(param?: any) { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 10 | if (param) { |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 11 | this.name = param.name; |
12 | this.type = param.type; | ||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 13 | this.inputId = param.inputId; |
14 | this.required = param.required; | ||||
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 15 | } |
16 | } | ||||
17 | } | ||||
18 | |||||
19 | export interface IOperationParamsList { | ||||
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 20 | listToscaDataDefinition: Array<OperationParameter>; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 21 | } |
22 | |||||
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 23 | export class WORKFLOW_ASSOCIATION_OPTIONS { |
24 | static NONE = 'NONE'; | ||||
25 | static NEW = 'NEW'; | ||||
26 | static EXISTING = 'EXISTING'; | ||||
Arielk | c21ba95 | 2019-04-21 16:07:44 +0300 | [diff] [blame] | 27 | static EXTERNAL = 'EXTERNAL'; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 28 | } |
29 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 30 | export class BEOperationModel { |
31 | name: string; | ||||
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 32 | description: string; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 33 | uniqueId: string; |
34 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 35 | inputs: IOperationParamsList; |
36 | outputs: IOperationParamsList; | ||||
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 37 | |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 38 | workflowAssociationType: string; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 39 | workflowId: string; |
40 | workflowVersionId: string; | ||||
41 | |||||
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 42 | implementation?: { |
43 | artifactName: string; | ||||
44 | artifactUUID: string; | ||||
45 | }; | ||||
Arielk | e0c9868 | 2019-02-28 16:37:57 +0200 | [diff] [blame] | 46 | |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 47 | constructor(operation?: any) { |
48 | if (operation) { | ||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 49 | this.name = operation.name; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 50 | this.description = operation.description; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 51 | this.uniqueId = operation.uniqueId; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 52 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 53 | this.inputs = operation.inputs; |
54 | this.outputs = operation.outputs; | ||||
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 55 | |
56 | this.workflowAssociationType = operation.workflowAssociationType; | ||||
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 57 | this.workflowId = operation.workflowId; |
58 | this.workflowVersionId = operation.workflowVersionId; | ||||
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 59 | this.implementation = operation.implementation || {}; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 60 | } |
61 | } | ||||
62 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 63 | public createInputsList(inputs: Array<OperationParameter>): void { |
64 | this.inputs = { | ||||
65 | listToscaDataDefinition: inputs | ||||
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 66 | }; |
67 | } | ||||
68 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 69 | public createOutputsList(outputs: Array<OperationParameter>): void { |
70 | this.outputs = { | ||||
71 | listToscaDataDefinition: _.map(outputs, output => { | ||||
72 | delete output.inputId; | ||||
73 | return output; | ||||
Arielk | 502b7b7 | 2018-10-03 14:06:13 +0300 | [diff] [blame] | 74 | }) |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 75 | }; |
76 | } | ||||
77 | } | ||||
78 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 79 | export class OperationModel extends BEOperationModel { |
80 | interfaceType: string; | ||||
81 | interfaceId: string; | ||||
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 82 | artifactFileName: string; |
Arielk | c21ba95 | 2019-04-21 16:07:44 +0300 | [diff] [blame] | 83 | artifactData: any; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 84 | |
85 | constructor(operation?: any) { | ||||
86 | super(operation); | ||||
87 | if (operation) { | ||||
88 | this.interfaceId = operation.interfaceId; | ||||
89 | this.interfaceType = operation.interfaceType; | ||||
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 90 | this.artifactFileName = operation.artifactFileName; |
91 | this.artifactData = operation.artifactData; | ||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 92 | } |
93 | } | ||||
94 | |||||
Arielk | afd5f95 | 2019-01-27 16:30:57 +0200 | [diff] [blame] | 95 | public displayType(): string { |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 96 | return displayType(this.interfaceType); |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 97 | } |
98 | } | ||||
99 | |||||
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 100 | export class InterfaceModel { |
101 | type: string; | ||||
102 | uniqueId: string; | ||||
103 | operations: Array<OperationModel>; | ||||
104 | |||||
105 | constructor(interf?: any) { | ||||
106 | if (interf) { | ||||
107 | this.type = interf.type; | ||||
108 | this.uniqueId = interf.uniqueId; | ||||
109 | this.operations = interf.operations; | ||||
110 | } | ||||
111 | } | ||||
112 | |||||
113 | public displayType(): string { | ||||
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 114 | return displayType(this.type); |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 115 | } |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 116 | } |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame^] | 117 | |
118 | const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1); |