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