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; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 5 | type: string; |
| 6 | inputId?: string; |
| 7 | required?: boolean; |
| 8 | property?: string; |
| 9 | mandatory?: boolean; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 10 | |
Arielk | c21ba95 | 2019-04-21 16:07:44 +0300 | [diff] [blame] | 11 | constructor(param?: any) { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 12 | if (param) { |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 13 | this.name = param.name; |
| 14 | this.type = param.type; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 15 | this.inputId = param.inputId ; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 16 | this.required = param.required; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 17 | this.property = param.property; |
| 18 | this.mandatory = param.mandatory; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export interface IOperationParamsList { |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 24 | listToscaDataDefinition: Array<OperationParameter>; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 25 | } |
| 26 | |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 27 | export class WORKFLOW_ASSOCIATION_OPTIONS { |
| 28 | static NONE = 'NONE'; |
| 29 | static NEW = 'NEW'; |
| 30 | static EXISTING = 'EXISTING'; |
Arielk | c21ba95 | 2019-04-21 16:07:44 +0300 | [diff] [blame] | 31 | static EXTERNAL = 'EXTERNAL'; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 32 | } |
| 33 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 34 | export class BEOperationModel { |
| 35 | name: string; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 36 | description: string; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 37 | uniqueId: string; |
| 38 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 39 | inputs: IOperationParamsList; |
| 40 | outputs: IOperationParamsList; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 41 | |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 42 | workflowAssociationType: string; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 43 | workflowId: string; |
| 44 | workflowVersionId: string; |
xuegao | 84a5151 | 2020-09-04 15:29:15 +0200 | [diff] [blame] | 45 | workflowName: string; |
| 46 | workflowVersion: string; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 47 | |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 48 | implementation?: { |
| 49 | artifactName: string; |
| 50 | artifactUUID: string; |
| 51 | }; |
Arielk | e0c9868 | 2019-02-28 16:37:57 +0200 | [diff] [blame] | 52 | |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 53 | constructor(operation?: any) { |
| 54 | if (operation) { |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 55 | this.name = operation.name; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 56 | this.description = operation.description; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 57 | this.uniqueId = operation.uniqueId; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 58 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 59 | this.inputs = operation.inputs; |
| 60 | this.outputs = operation.outputs; |
Arielk | aefe391 | 2018-10-14 16:50:17 +0300 | [diff] [blame] | 61 | |
| 62 | this.workflowAssociationType = operation.workflowAssociationType; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 63 | this.workflowId = operation.workflowId; |
| 64 | this.workflowVersionId = operation.workflowVersionId; |
xuegao | 84a5151 | 2020-09-04 15:29:15 +0200 | [diff] [blame] | 65 | this.workflowName = operation.workflowName; |
| 66 | this.workflowVersion = operation.workflowVersion; |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 67 | this.implementation = operation.implementation || {}; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 71 | public createInputsList(inputs: Array<OperationParameter>): void { |
| 72 | this.inputs = { |
| 73 | listToscaDataDefinition: inputs |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 74 | }; |
| 75 | } |
| 76 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 77 | public createOutputsList(outputs: Array<OperationParameter>): void { |
| 78 | this.outputs = { |
| 79 | listToscaDataDefinition: _.map(outputs, output => { |
| 80 | delete output.inputId; |
| 81 | return output; |
Arielk | 502b7b7 | 2018-10-03 14:06:13 +0300 | [diff] [blame] | 82 | }) |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 83 | }; |
| 84 | } |
| 85 | } |
| 86 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 87 | export class OperationModel extends BEOperationModel{ |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 88 | interfaceType: string; |
| 89 | interfaceId: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 90 | operationType: string; |
| 91 | description: string; |
| 92 | uniqueId: string; |
| 93 | artifactFileName?: string; |
| 94 | artifactData?: any; |
| 95 | |
| 96 | inputParams: IOperationParamsList; |
| 97 | outputParams: IOperationParamsList; |
| 98 | |
| 99 | workflowId: string; |
| 100 | workflowVersionId: string; |
xuegao | 84a5151 | 2020-09-04 15:29:15 +0200 | [diff] [blame] | 101 | workflowName: string; |
| 102 | workflowVersion: string; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 103 | |
| 104 | protected OperationTypeEnum: Array<String> = [ |
| 105 | 'Create', |
| 106 | 'Delete', |
| 107 | 'Instantiate', |
| 108 | 'Start', |
| 109 | 'Stop' |
| 110 | ]; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 111 | |
| 112 | constructor(operation?: any) { |
| 113 | super(operation); |
| 114 | if (operation) { |
| 115 | this.interfaceId = operation.interfaceId; |
| 116 | this.interfaceType = operation.interfaceType; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 117 | this.description = operation.description; |
| 118 | this.inputParams = operation.inputParams; |
| 119 | this.operationType = operation.operationType; |
| 120 | this.outputParams = operation.outputParams; |
| 121 | this.uniqueId = operation.uniqueId; |
| 122 | this.workflowId = operation.workflowId; |
| 123 | this.workflowVersionId = operation.workflowVersionId; |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 124 | this.artifactFileName = operation.artifactFileName; |
| 125 | this.artifactData = operation.artifactData; |
xuegao | 84a5151 | 2020-09-04 15:29:15 +0200 | [diff] [blame] | 126 | this.workflowName = operation.workflowName; |
| 127 | this.workflowVersion = operation.workflowVersion; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Arielk | afd5f95 | 2019-01-27 16:30:57 +0200 | [diff] [blame] | 131 | public displayType(): string { |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 132 | return displayType(this.interfaceType); |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 133 | } |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 134 | |
| 135 | public createInputParamsList(inputParams: Array<OperationParameter>): void { |
| 136 | this.inputParams = { |
| 137 | listToscaDataDefinition: inputParams |
| 138 | }; |
| 139 | } |
| 140 | |
| 141 | public createOutputParamsList(outputParams: Array<OperationParameter>): void { |
| 142 | this.outputParams = { |
| 143 | listToscaDataDefinition: outputParams |
| 144 | }; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | export interface CreateOperationResponse extends OperationModel { |
| 149 | artifactUUID: string; |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 150 | } |
| 151 | |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 152 | export class InterfaceModel { |
| 153 | type: string; |
| 154 | uniqueId: string; |
| 155 | operations: Array<OperationModel>; |
| 156 | |
| 157 | constructor(interf?: any) { |
| 158 | if (interf) { |
| 159 | this.type = interf.type; |
| 160 | this.uniqueId = interf.uniqueId; |
| 161 | this.operations = interf.operations; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | public displayType(): string { |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 166 | return displayType(this.type); |
Arielk | 86a3752 | 2019-01-13 18:31:13 +0200 | [diff] [blame] | 167 | } |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 168 | } |
Arielk | 3d5b80b | 2019-05-13 15:30:27 +0300 | [diff] [blame] | 169 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 170 | const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1); |