2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
22 import {ArtifactModel} from "./artifacts";
23 import {SchemaPropertyGroupModel} from "./schema-property";
24 import {PROPERTY_DATA, PROPERTY_TYPES} from "../utils/constants";
26 export class InputOperationParameter {
29 schema: SchemaPropertyGroupModel;
31 toscaDefaultValue?: string;
34 constructor(param?: any) {
36 this.name = param.name;
37 this.type = param.type;
38 this.schema = param.schema;
39 this.inputId = param.inputId;
40 this.toscaDefaultValue = param.toscaDefaultValue;
41 this.value = param.value;
45 public getDefaultValue(): any {
46 if (this.isTypeNotSimple()) {
47 if (this.toscaDefaultValue) {
48 this.toscaDefaultValue = JSON.parse(this.toscaDefaultValue);
49 return JSON.parse(this.toscaDefaultValue);
52 case PROPERTY_TYPES.LIST:
59 return this.toscaDefaultValue;
62 private isTypeNotSimple() {
63 return PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) == -1;
67 export class PropertyOperationParameter {
73 constructor(param?: any) {
75 this.name = param.name;
76 this.type = param.type;
77 this.value = param.value;
78 this.propertyId = param.propertyId;
83 export interface IOperationParamsList {
84 listToscaDataDefinition: Array<InputOperationParameter>;
87 export class BEInterfaceOperationModel {
91 inputs: IOperationParamsList;
92 implementation: ArtifactModel;
94 constructor(operation?: any) {
96 this.name = operation.name;
97 this.description = operation.description;
98 this.uniqueId = operation.uniqueId;
99 this.inputs = operation.inputs;
100 this.implementation = operation.implementation;
105 export class InterfaceOperationModel extends BEInterfaceOperationModel {
106 interfaceType: string;
108 operationType: string;
111 inputParams: IOperationParamsList;
112 implementation: ArtifactModel;
114 constructor(operation?: any) {
117 this.interfaceId = operation.interfaceId;
118 this.interfaceType = operation.interfaceType;
119 this.description = operation.description;
120 this.operationType = operation.operationType;
121 this.uniqueId = operation.uniqueId;
122 this.inputParams = operation.inputParams;
123 this.implementation = operation.implementation;
127 public displayType(): string {
128 return displayType(this.interfaceType);
132 export class ComponentInstanceInterfaceModel {
135 operations: Array<InterfaceOperationModel>;
137 constructor(interfaceOperation?: any) {
138 if (interfaceOperation) {
139 this.type = interfaceOperation.type;
140 this.uniqueId = interfaceOperation.uniqueId;
141 this.operations = interfaceOperation.operations;
145 public displayType(): string {
146 return displayType(this.type);
150 const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1);