blob: bf037729e49321df304bb5db7732a2e80791110a [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
Arielk3d5b80b2019-05-13 15:30:27 +030042 implementation?: {
43 artifactName: string;
44 artifactUUID: string;
45 };
Arielke0c98682019-02-28 16:37:57 +020046
Arielk802bd2a2018-04-16 15:37:39 +030047 constructor(operation?: any) {
48 if (operation) {
Arielk86a37522019-01-13 18:31:13 +020049 this.name = operation.name;
Arielkaefe3912018-10-14 16:50:17 +030050 this.description = operation.description;
Arielk802bd2a2018-04-16 15:37:39 +030051 this.uniqueId = operation.uniqueId;
Arielkaefe3912018-10-14 16:50:17 +030052
Arielk86a37522019-01-13 18:31:13 +020053 this.inputs = operation.inputs;
54 this.outputs = operation.outputs;
Arielkaefe3912018-10-14 16:50:17 +030055
56 this.workflowAssociationType = operation.workflowAssociationType;
Arielkeaaf8012018-07-31 12:59:36 +030057 this.workflowId = operation.workflowId;
58 this.workflowVersionId = operation.workflowVersionId;
Arielk3d5b80b2019-05-13 15:30:27 +030059 this.implementation = operation.implementation || {};
Arielk802bd2a2018-04-16 15:37:39 +030060 }
61 }
62
Arielk86a37522019-01-13 18:31:13 +020063 public createInputsList(inputs: Array<OperationParameter>): void {
64 this.inputs = {
65 listToscaDataDefinition: inputs
Arielk802bd2a2018-04-16 15:37:39 +030066 };
67 }
68
Arielk86a37522019-01-13 18:31:13 +020069 public createOutputsList(outputs: Array<OperationParameter>): void {
70 this.outputs = {
71 listToscaDataDefinition: _.map(outputs, output => {
72 delete output.inputId;
73 return output;
Arielk502b7b72018-10-03 14:06:13 +030074 })
Arielk802bd2a2018-04-16 15:37:39 +030075 };
76 }
77}
78
Arielk86a37522019-01-13 18:31:13 +020079export class OperationModel extends BEOperationModel {
80 interfaceType: string;
81 interfaceId: string;
Arielk3d5b80b2019-05-13 15:30:27 +030082 artifactFileName: string;
Arielkc21ba952019-04-21 16:07:44 +030083 artifactData: any;
Arielk86a37522019-01-13 18:31:13 +020084
85 constructor(operation?: any) {
86 super(operation);
87 if (operation) {
88 this.interfaceId = operation.interfaceId;
89 this.interfaceType = operation.interfaceType;
Arielk3d5b80b2019-05-13 15:30:27 +030090 this.artifactFileName = operation.artifactFileName;
91 this.artifactData = operation.artifactData;
Arielk86a37522019-01-13 18:31:13 +020092 }
93 }
94
Arielkafd5f952019-01-27 16:30:57 +020095 public displayType(): string {
Arielk3d5b80b2019-05-13 15:30:27 +030096 return displayType(this.interfaceType);
Arielk86a37522019-01-13 18:31:13 +020097 }
98}
99
Arielk86a37522019-01-13 18:31:13 +0200100export class InterfaceModel {
101 type: string;
102 uniqueId: string;
103 operations: Array<OperationModel>;
104
105 constructor(interf?: any) {
106 if (interf) {
107 this.type = interf.type;
108 this.uniqueId = interf.uniqueId;
109 this.operations = interf.operations;
110 }
111 }
112
113 public displayType(): string {
Arielk3d5b80b2019-05-13 15:30:27 +0300114 return displayType(this.type);
Arielk86a37522019-01-13 18:31:13 +0200115 }
Arielk802bd2a2018-04-16 15:37:39 +0300116}
Arielk3d5b80b2019-05-13 15:30:27 +0300117
118const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1);