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 | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 6 | property: string; |
| 7 | mandatory: 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; |
| 13 | this.property = param.property; |
| 14 | this.mandatory = param.mandatory; |
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 | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 29 | export class OperationModel { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 30 | operationType: 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 | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 34 | inputParams: IOperationParamsList; |
| 35 | outputParams: IOperationParamsList; |
| 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 | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 43 | this.operationType = operation.operationType; |
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 | |
| 47 | this.inputParams = operation.inputParams; |
| 48 | this.outputParams = operation.outputParams; |
| 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 | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 56 | public createInputParamsList(inputParams: Array<OperationParameter>): void { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 57 | this.inputParams = { |
| 58 | listToscaDataDefinition: inputParams |
| 59 | }; |
| 60 | } |
| 61 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 62 | public createOutputParamsList(outputParams: Array<OperationParameter>): void { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 63 | this.outputParams = { |
Arielk | 502b7b7 | 2018-10-03 14:06:13 +0300 | [diff] [blame] | 64 | listToscaDataDefinition: _.map(outputParams, output => { |
| 65 | const newOutput = {...output}; |
| 66 | delete newOutput.property; |
| 67 | return newOutput; |
| 68 | }) |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 69 | }; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | export interface CreateOperationResponse extends OperationModel { |
| 74 | artifactUUID: string; |
| 75 | } |