aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 8 | * |
| 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. |
| 15 | * |
| 16 | * SPDX-License-Identifier: Apache-2.0 |
| 17 | * ============LICENSE_END========================================================= |
| 18 | */ |
| 19 | |
| 20 | 'use strict'; |
| 21 | |
aribeiro | 1de1692 | 2021-10-01 11:30:49 +0100 | [diff] [blame] | 22 | import {ArtifactModel} from "./artifacts"; |
| 23 | |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 24 | export class InputOperationParameter { |
| 25 | name: string; |
| 26 | type: string; |
| 27 | inputId: string; |
| 28 | toscaDefaultValue?: string; |
| 29 | |
| 30 | constructor(param?: any) { |
| 31 | if (param) { |
| 32 | this.name = param.name; |
| 33 | this.type = param.type; |
| 34 | this.inputId = param.inputId; |
| 35 | this.toscaDefaultValue = param.toscaDefaultValue; |
| 36 | } |
| 37 | console.info("InputOperationParameter Constructor: ", param) |
| 38 | } |
| 39 | } |
| 40 | |
aribeiro | 1de1692 | 2021-10-01 11:30:49 +0100 | [diff] [blame] | 41 | export class PropertyOperationParameter { |
| 42 | name: string; |
| 43 | type: string; |
| 44 | value?: string; |
| 45 | propertyId: string; |
| 46 | |
| 47 | constructor(param?: any) { |
| 48 | if (param) { |
| 49 | this.name = param.name; |
| 50 | this.type = param.type; |
| 51 | this.value = param.value; |
| 52 | this.propertyId = param.propertyId; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 57 | export interface IOperationParamsList { |
| 58 | listToscaDataDefinition: Array<InputOperationParameter>; |
| 59 | } |
| 60 | |
| 61 | export class BEInterfaceOperationModel { |
| 62 | name: string; |
| 63 | description: string; |
| 64 | uniqueId: string; |
| 65 | inputs: IOperationParamsList; |
aribeiro | 1de1692 | 2021-10-01 11:30:49 +0100 | [diff] [blame] | 66 | implementation: ArtifactModel; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 67 | |
| 68 | constructor(operation?: any) { |
| 69 | if (operation) { |
| 70 | this.name = operation.name; |
| 71 | this.description = operation.description; |
| 72 | this.uniqueId = operation.uniqueId; |
| 73 | this.inputs = operation.inputs; |
| 74 | this.implementation = operation.implementation; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | export class InterfaceOperationModel extends BEInterfaceOperationModel { |
| 80 | interfaceType: string; |
| 81 | interfaceId: string; |
| 82 | operationType: string; |
| 83 | description: string; |
| 84 | uniqueId: string; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 85 | inputParams: IOperationParamsList; |
aribeiro | 1de1692 | 2021-10-01 11:30:49 +0100 | [diff] [blame] | 86 | implementation: ArtifactModel; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 87 | |
| 88 | constructor(operation?: any) { |
| 89 | super(operation); |
| 90 | if (operation) { |
| 91 | this.interfaceId = operation.interfaceId; |
| 92 | this.interfaceType = operation.interfaceType; |
| 93 | this.description = operation.description; |
| 94 | this.operationType = operation.operationType; |
| 95 | this.uniqueId = operation.uniqueId; |
| 96 | this.inputParams = operation.inputParams; |
aribeiro | 1de1692 | 2021-10-01 11:30:49 +0100 | [diff] [blame] | 97 | this.implementation = operation.implementation; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
| 101 | public displayType(): string { |
| 102 | return displayType(this.interfaceType); |
| 103 | } |
| 104 | } |
| 105 | |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 106 | export class ComponentInstanceInterfaceModel { |
| 107 | type: string; |
| 108 | uniqueId: string; |
| 109 | operations: Array<InterfaceOperationModel>; |
| 110 | |
| 111 | constructor(interfaceOperation?: any) { |
| 112 | if (interfaceOperation) { |
| 113 | this.type = interfaceOperation.type; |
| 114 | this.uniqueId = interfaceOperation.uniqueId; |
| 115 | this.operations = interfaceOperation.operations; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | public displayType(): string { |
| 120 | return displayType(this.type); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1); |