blob: 7b0039b184456ab26eef0c29577cb9a5bdbff27a [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
Arielkc21ba952019-04-21 16:07:44 +03009 constructor(param?: any) {
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';
Arielkc21ba952019-04-21 16:07:44 +030027 static EXTERNAL = 'EXTERNAL';
Arielkaefe3912018-10-14 16:50:17 +030028}
29
Arielk86a37522019-01-13 18:31:13 +020030export class BEOperationModel {
31 name: string;
Arielkeaaf8012018-07-31 12:59:36 +030032 description: string;
Arielk802bd2a2018-04-16 15:37:39 +030033 uniqueId: string;
34
Arielk86a37522019-01-13 18:31:13 +020035 inputs: IOperationParamsList;
36 outputs: IOperationParamsList;
Arielkeaaf8012018-07-31 12:59:36 +030037
Arielkaefe3912018-10-14 16:50:17 +030038 workflowAssociationType: string;
Arielkeaaf8012018-07-31 12:59:36 +030039 workflowId: string;
40 workflowVersionId: string;
41
Arielke0c98682019-02-28 16:37:57 +020042 implementation?: { artifactUUID: string; };
43
Arielk802bd2a2018-04-16 15:37:39 +030044 constructor(operation?: any) {
45 if (operation) {
Arielk86a37522019-01-13 18:31:13 +020046 this.name = operation.name;
Arielkaefe3912018-10-14 16:50:17 +030047 this.description = operation.description;
Arielk802bd2a2018-04-16 15:37:39 +030048 this.uniqueId = operation.uniqueId;
Arielkaefe3912018-10-14 16:50:17 +030049
Arielk86a37522019-01-13 18:31:13 +020050 this.inputs = operation.inputs;
51 this.outputs = operation.outputs;
Arielkaefe3912018-10-14 16:50:17 +030052
53 this.workflowAssociationType = operation.workflowAssociationType;
Arielkeaaf8012018-07-31 12:59:36 +030054 this.workflowId = operation.workflowId;
55 this.workflowVersionId = operation.workflowVersionId;
Arielke0c98682019-02-28 16:37:57 +020056 this.implementation = operation.implementation;
Arielk802bd2a2018-04-16 15:37:39 +030057 }
58 }
59
Arielk86a37522019-01-13 18:31:13 +020060 public createInputsList(inputs: Array<OperationParameter>): void {
61 this.inputs = {
62 listToscaDataDefinition: inputs
Arielk802bd2a2018-04-16 15:37:39 +030063 };
64 }
65
Arielk86a37522019-01-13 18:31:13 +020066 public createOutputsList(outputs: Array<OperationParameter>): void {
67 this.outputs = {
68 listToscaDataDefinition: _.map(outputs, output => {
69 delete output.inputId;
70 return output;
Arielk502b7b72018-10-03 14:06:13 +030071 })
Arielk802bd2a2018-04-16 15:37:39 +030072 };
73 }
74}
75
Arielk86a37522019-01-13 18:31:13 +020076export class OperationModel extends BEOperationModel {
77 interfaceType: string;
78 interfaceId: string;
Arielkc21ba952019-04-21 16:07:44 +030079 artifactFile: any;
80 artifactData: any;
Arielk86a37522019-01-13 18:31:13 +020081
82 constructor(operation?: any) {
83 super(operation);
84 if (operation) {
85 this.interfaceId = operation.interfaceId;
86 this.interfaceType = operation.interfaceType;
87 }
88 }
89
Arielkafd5f952019-01-27 16:30:57 +020090 public displayType(): string {
91 const lastDot = this.interfaceType ? this.interfaceType.lastIndexOf('.') : -1;
92 return lastDot === -1 ? this.interfaceType : this.interfaceType.substr(lastDot + 1);
Arielk86a37522019-01-13 18:31:13 +020093 }
94}
95
Arielk86a37522019-01-13 18:31:13 +020096export 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 }
Arielk802bd2a2018-04-16 15:37:39 +0300113}