blob: d9d0858870e00069a6cf9ebd9d6f343c7ce97920 [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
Arielke0c98682019-02-28 16:37:57 +020041 implementation?: { artifactUUID: string; };
42
Arielk802bd2a2018-04-16 15:37:39 +030043 constructor(operation?: any) {
44 if (operation) {
Arielk86a37522019-01-13 18:31:13 +020045 this.name = operation.name;
Arielkaefe3912018-10-14 16:50:17 +030046 this.description = operation.description;
Arielk802bd2a2018-04-16 15:37:39 +030047 this.uniqueId = operation.uniqueId;
Arielkaefe3912018-10-14 16:50:17 +030048
Arielk86a37522019-01-13 18:31:13 +020049 this.inputs = operation.inputs;
50 this.outputs = operation.outputs;
Arielkaefe3912018-10-14 16:50:17 +030051
52 this.workflowAssociationType = operation.workflowAssociationType;
Arielkeaaf8012018-07-31 12:59:36 +030053 this.workflowId = operation.workflowId;
54 this.workflowVersionId = operation.workflowVersionId;
Arielke0c98682019-02-28 16:37:57 +020055 this.implementation = operation.implementation;
Arielk802bd2a2018-04-16 15:37:39 +030056 }
57 }
58
Arielk86a37522019-01-13 18:31:13 +020059 public createInputsList(inputs: Array<OperationParameter>): void {
60 this.inputs = {
61 listToscaDataDefinition: inputs
Arielk802bd2a2018-04-16 15:37:39 +030062 };
63 }
64
Arielk86a37522019-01-13 18:31:13 +020065 public createOutputsList(outputs: Array<OperationParameter>): void {
66 this.outputs = {
67 listToscaDataDefinition: _.map(outputs, output => {
68 delete output.inputId;
69 return output;
Arielk502b7b72018-10-03 14:06:13 +030070 })
Arielk802bd2a2018-04-16 15:37:39 +030071 };
72 }
73}
74
Arielk86a37522019-01-13 18:31:13 +020075export class OperationModel extends BEOperationModel {
76 interfaceType: string;
77 interfaceId: string;
78
79 constructor(operation?: any) {
80 super(operation);
81 if (operation) {
82 this.interfaceId = operation.interfaceId;
83 this.interfaceType = operation.interfaceType;
84 }
85 }
86
Arielkafd5f952019-01-27 16:30:57 +020087 public displayType(): string {
88 const lastDot = this.interfaceType ? this.interfaceType.lastIndexOf('.') : -1;
89 return lastDot === -1 ? this.interfaceType : this.interfaceType.substr(lastDot + 1);
Arielk86a37522019-01-13 18:31:13 +020090 }
91}
92
Arielk86a37522019-01-13 18:31:13 +020093export class InterfaceModel {
94 type: string;
95 uniqueId: string;
96 operations: Array<OperationModel>;
97
98 constructor(interf?: any) {
99 if (interf) {
100 this.type = interf.type;
101 this.uniqueId = interf.uniqueId;
102 this.operations = interf.operations;
103 }
104 }
105
106 public displayType(): string {
107 const lastDot = this.type ? this.type.lastIndexOf('.') : -1;
108 return lastDot === -1 ? this.type : this.type.substr(lastDot + 1);
109 }
Arielk802bd2a2018-04-16 15:37:39 +0300110}