blob: d36b72a1401dbf4aad845134111cbd0e0f4fe007 [file] [log] [blame]
Arielk802bd2a2018-04-16 15:37:39 +03001'use strict';
2
Arielkeaaf8012018-07-31 12:59:36 +03003export class OperationParameter {
4 name: string;
Arielkaefe3912018-10-14 16:50:17 +03005 type: String;
Arielk86a37522019-01-13 18:31:13 +02006 inputId: string;
7 required: boolean;
Arielk802bd2a2018-04-16 15:37:39 +03008
Arielkeaaf8012018-07-31 12:59:36 +03009 constructor(param?: OperationParameter) {
Arielk802bd2a2018-04-16 15:37:39 +030010 if (param) {
Arielkeaaf8012018-07-31 12:59:36 +030011 this.name = param.name;
12 this.type = param.type;
Arielk86a37522019-01-13 18:31:13 +020013 this.inputId = param.inputId;
14 this.required = param.required;
Arielk802bd2a2018-04-16 15:37:39 +030015 }
16 }
17}
18
19export interface IOperationParamsList {
Arielkeaaf8012018-07-31 12:59:36 +030020 listToscaDataDefinition: Array<OperationParameter>;
Arielk802bd2a2018-04-16 15:37:39 +030021}
22
Arielkaefe3912018-10-14 16:50:17 +030023export class WORKFLOW_ASSOCIATION_OPTIONS {
24 static NONE = 'NONE';
25 static NEW = 'NEW';
26 static EXISTING = 'EXISTING';
27}
28
Arielk86a37522019-01-13 18:31:13 +020029export class BEOperationModel {
30 name: string;
Arielkeaaf8012018-07-31 12:59:36 +030031 description: string;
Arielk802bd2a2018-04-16 15:37:39 +030032 uniqueId: string;
33
Arielk86a37522019-01-13 18:31:13 +020034 inputs: IOperationParamsList;
35 outputs: IOperationParamsList;
Arielkeaaf8012018-07-31 12:59:36 +030036
Arielkaefe3912018-10-14 16:50:17 +030037 workflowAssociationType: string;
Arielkeaaf8012018-07-31 12:59:36 +030038 workflowId: string;
39 workflowVersionId: string;
40
Arielk802bd2a2018-04-16 15:37:39 +030041 constructor(operation?: any) {
42 if (operation) {
Arielk86a37522019-01-13 18:31:13 +020043 this.name = operation.name;
Arielkaefe3912018-10-14 16:50:17 +030044 this.description = operation.description;
Arielk802bd2a2018-04-16 15:37:39 +030045 this.uniqueId = operation.uniqueId;
Arielkaefe3912018-10-14 16:50:17 +030046
Arielk86a37522019-01-13 18:31:13 +020047 this.inputs = operation.inputs;
48 this.outputs = operation.outputs;
Arielkaefe3912018-10-14 16:50:17 +030049
50 this.workflowAssociationType = operation.workflowAssociationType;
Arielkeaaf8012018-07-31 12:59:36 +030051 this.workflowId = operation.workflowId;
52 this.workflowVersionId = operation.workflowVersionId;
Arielk802bd2a2018-04-16 15:37:39 +030053 }
54 }
55
Arielk86a37522019-01-13 18:31:13 +020056 public createInputsList(inputs: Array<OperationParameter>): void {
57 this.inputs = {
58 listToscaDataDefinition: inputs
Arielk802bd2a2018-04-16 15:37:39 +030059 };
60 }
61
Arielk86a37522019-01-13 18:31:13 +020062 public createOutputsList(outputs: Array<OperationParameter>): void {
63 this.outputs = {
64 listToscaDataDefinition: _.map(outputs, output => {
65 delete output.inputId;
66 return output;
Arielk502b7b72018-10-03 14:06:13 +030067 })
Arielk802bd2a2018-04-16 15:37:39 +030068 };
69 }
70}
71
Arielk86a37522019-01-13 18:31:13 +020072export 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
Arielkafd5f952019-01-27 16:30:57 +020084 public displayType(): string {
85 const lastDot = this.interfaceType ? this.interfaceType.lastIndexOf('.') : -1;
86 return lastDot === -1 ? this.interfaceType : this.interfaceType.substr(lastDot + 1);
Arielk86a37522019-01-13 18:31:13 +020087 }
88}
89
90export class CreateOperationResponse extends OperationModel {
Arielk802bd2a2018-04-16 15:37:39 +030091 artifactUUID: string;
Arielk86a37522019-01-13 18:31:13 +020092
93 constructor(operation?: any) {
94 super(operation);
95 if (operation) {
96 this.artifactUUID = operation.artifactUUID;
97 }
98 }
99}
100
101export 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 }
Arielk802bd2a2018-04-16 15:37:39 +0300118}