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