aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/operation.ts
blob: 2aa1332f06e5b26e8504d69483722dceaf1e68f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';

export class OperationParameter {
    name: string;
    type: String;
    property: string;
    mandatory: boolean;

    constructor(param?: OperationParameter) {
        if (param) {
            this.name = param.name;
            this.type = param.type;
            this.property = param.property;
            this.mandatory = param.mandatory;
        }
    }
}

export interface IOperationParamsList {
    listToscaDataDefinition: Array<OperationParameter>;
}

export class WORKFLOW_ASSOCIATION_OPTIONS {
    static NONE = 'NONE';
    static NEW = 'NEW';
    static EXISTING = 'EXISTING';
}

export class OperationModel {
    operationType: string;
    description: string;
    uniqueId: string;

    inputParams: IOperationParamsList;
    outputParams: IOperationParamsList;

    workflowAssociationType: string;
    workflowId: string;
    workflowVersionId: string;

    constructor(operation?: any) {
        if (operation) {
            this.operationType = operation.operationType;
            this.description = operation.description;
            this.uniqueId = operation.uniqueId;

            this.inputParams = operation.inputParams;
            this.outputParams = operation.outputParams;

            this.workflowAssociationType = operation.workflowAssociationType;
            this.workflowId = operation.workflowId;
            this.workflowVersionId = operation.workflowVersionId;
        }
    }

    public createInputParamsList(inputParams: Array<OperationParameter>): void {
        this.inputParams = {
            listToscaDataDefinition: inputParams
        };
    }

    public createOutputParamsList(outputParams: Array<OperationParameter>): void {
        this.outputParams = {
            listToscaDataDefinition: _.map(outputParams, output => {
                const newOutput = {...output};
                delete newOutput.property;
                return newOutput;
            })
        };
    }
}

export interface CreateOperationResponse extends OperationModel {
    artifactUUID: string;
}