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