summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts35
-rw-r--r--catalog-ui/src/app/models/tosca-concat-function.ts38
-rw-r--r--catalog-ui/src/app/models/tosca-function-parameter.ts27
-rw-r--r--catalog-ui/src/app/models/tosca-function-type.enum.ts8
-rw-r--r--catalog-ui/src/app/models/tosca-function.ts27
-rw-r--r--catalog-ui/src/app/models/tosca-get-function-dto.ts45
-rw-r--r--catalog-ui/src/app/models/tosca-get-function-type-converter.ts47
-rw-r--r--catalog-ui/src/app/models/tosca-get-function.ts7
-rw-r--r--catalog-ui/src/app/models/tosca-string-parameter.ts28
9 files changed, 192 insertions, 70 deletions
diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
index a5bf3cb7a0..ae7141353b 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -23,9 +23,10 @@ import {SchemaProperty, SchemaPropertyGroupModel} from '../schema-property';
import {ToscaPresentationData} from '../tosca-presentation';
import {PropertyInputDetail} from './property-input-detail';
import {Metadata} from '../metadata';
-import {ToscaGetFunctionType} from "../tosca-get-function-type";
-import {ToscaGetFunctionDto} from '../tosca-get-function-dto';
-import {PropertySource} from '../property-source';
+import {ToscaFunction} from "../tosca-function";
+import {ToscaGetFunction} from "../tosca-get-function";
+import {ToscaGetFunctionTypeConverter} from "../tosca-get-function-type-converter";
+import {ToscaGetFunctionDto} from "../tosca-get-function-dto";
export enum DerivedPropertyType {
SIMPLE,
@@ -68,9 +69,11 @@ export class PropertyBEModel {
inputPath: string;
toscaPresentation: ToscaPresentationData;
metadata: Metadata;
- //deprecated
- toscaGetFunctionType: ToscaGetFunctionType;
+ /**
+ * @deprecated Use toscaFunction instead
+ */
toscaGetFunction: ToscaGetFunctionDto;
+ toscaFunction: ToscaFunction;
constructor(property?: PropertyBEModel) {
if (property) {
@@ -96,12 +99,20 @@ export class PropertyBEModel {
this.getPolicyValues = property.getPolicyValues;
this.inputPath = property.inputPath;
this.metadata = property.metadata;
- if (property.toscaGetFunction) {
- this.toscaGetFunction = property.toscaGetFunction;
- } else if (property.toscaGetFunctionType) {
- this.toscaGetFunction = new ToscaGetFunctionDto();
- this.toscaGetFunction.functionType = property.toscaGetFunctionType;
- this.toscaGetFunction.propertySource = PropertySource.SELF;
+ if (property.toscaFunction) {
+ this.toscaFunction = property.toscaFunction;
+ } else if (property.toscaGetFunction) {
+ //support for legacy tosca function
+ const toscaGetFunction1 = new ToscaGetFunction();
+ toscaGetFunction1.type = ToscaGetFunctionTypeConverter.convertToToscaFunctionType(property.toscaGetFunction.functionType);
+ toscaGetFunction1.propertyUniqueId = property.toscaGetFunction.propertyUniqueId;
+ toscaGetFunction1.propertyName = property.toscaGetFunction.propertyName;
+ toscaGetFunction1.propertySource = property.toscaGetFunction.propertySource;
+ toscaGetFunction1.sourceUniqueId = property.toscaGetFunction.sourceUniqueId;
+ toscaGetFunction1.sourceName = property.toscaGetFunction.sourceName;
+ toscaGetFunction1.functionType = property.toscaGetFunction.functionType;
+ toscaGetFunction1.propertyPathFromSource = property.toscaGetFunction.propertyPathFromSource;
+ this.toscaFunction = toscaGetFunction1;
}
}
@@ -181,7 +192,7 @@ export class PropertyBEModel {
* Checks whether the property value is a tosca get function (e.g. get_input, get_property, get_attribute)
*/
public isToscaGetFunction(): boolean {
- return this.toscaGetFunction != null;
+ return this.toscaFunction != null;
}
}
diff --git a/catalog-ui/src/app/models/tosca-concat-function.ts b/catalog-ui/src/app/models/tosca-concat-function.ts
new file mode 100644
index 0000000000..9656d8ddb9
--- /dev/null
+++ b/catalog-ui/src/app/models/tosca-concat-function.ts
@@ -0,0 +1,38 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import {ToscaFunction} from "./tosca-function";
+import {ToscaFunctionType} from "./tosca-function-type.enum";
+import {ToscaFunctionParameter} from "./tosca-function-parameter";
+
+export class ToscaConcatFunction implements ToscaFunction, ToscaFunctionParameter {
+ type = ToscaFunctionType.CONCAT;
+ value: any;
+ parameters: Array<ToscaFunctionParameter> = [];
+
+ constructor(toscaConcatFunction?: ToscaConcatFunction) {
+ if (!toscaConcatFunction) {
+ return;
+ }
+ this.value = toscaConcatFunction.value;
+ }
+
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/tosca-function-parameter.ts b/catalog-ui/src/app/models/tosca-function-parameter.ts
new file mode 100644
index 0000000000..84c4f0b014
--- /dev/null
+++ b/catalog-ui/src/app/models/tosca-function-parameter.ts
@@ -0,0 +1,27 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import {ToscaFunctionType} from "./tosca-function-type.enum";
+
+export interface ToscaFunctionParameter {
+ type: ToscaFunctionType;
+ value: any;
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/tosca-function-type.enum.ts b/catalog-ui/src/app/models/tosca-function-type.enum.ts
new file mode 100644
index 0000000000..116c8815ab
--- /dev/null
+++ b/catalog-ui/src/app/models/tosca-function-type.enum.ts
@@ -0,0 +1,8 @@
+export enum ToscaFunctionType {
+ GET_INPUT = 'GET_INPUT',
+ GET_ATTRIBUTE = 'GET_ATTRIBUTE',
+ GET_PROPERTY = 'GET_PROPERTY',
+ CONCAT = 'CONCAT',
+ YAML = 'YAML',
+ STRING = 'STRING'
+}
diff --git a/catalog-ui/src/app/models/tosca-function.ts b/catalog-ui/src/app/models/tosca-function.ts
new file mode 100644
index 0000000000..ebb024ee7c
--- /dev/null
+++ b/catalog-ui/src/app/models/tosca-function.ts
@@ -0,0 +1,27 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import {ToscaFunctionType} from "./tosca-function-type.enum";
+
+export interface ToscaFunction {
+ type: ToscaFunctionType;
+ value: any;
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/tosca-get-function-dto.ts b/catalog-ui/src/app/models/tosca-get-function-dto.ts
index b5ddad7b71..b16ae8be9a 100644
--- a/catalog-ui/src/app/models/tosca-get-function-dto.ts
+++ b/catalog-ui/src/app/models/tosca-get-function-dto.ts
@@ -21,8 +21,10 @@
import {ToscaGetFunctionType} from './tosca-get-function-type';
import {PropertySource} from './property-source';
+import {ToscaFunctionType} from "./tosca-function-type.enum";
export class ToscaGetFunctionDto {
+ type: ToscaFunctionType;
propertyUniqueId: string;
propertyName: string;
propertySource: PropertySource;
@@ -31,46 +33,3 @@ export class ToscaGetFunctionDto {
functionType: ToscaGetFunctionType;
propertyPathFromSource: Array<string>;
}
-
-export class ToscaGetFunctionDtoBuilder {
- toscaGetFunctionDto: ToscaGetFunctionDto = new ToscaGetFunctionDto();
-
- withPropertyUniqueId(propertyUniqueId: string): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.propertyUniqueId = propertyUniqueId;
- return this;
- }
-
- withPropertyName(propertyName: string): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.propertyName = propertyName;
- return this;
- }
-
- withPropertySource(propertySource: PropertySource): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.propertySource = propertySource;
- return this;
- }
-
- withSourceUniqueId(sourceUniqueId: string): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.sourceUniqueId = sourceUniqueId;
- return this;
- }
-
- withSourceName(sourceName: string): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.sourceName = sourceName;
- return this;
- }
-
- withFunctionType(functionType: ToscaGetFunctionType): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.functionType = functionType;
- return this;
- }
-
- withPropertyPathFromSource(propertyPathFromSource: Array<string>): ToscaGetFunctionDtoBuilder {
- this.toscaGetFunctionDto.propertyPathFromSource = propertyPathFromSource;
- return this;
- }
-
- build(): ToscaGetFunctionDto {
- return this.toscaGetFunctionDto;
- }
-}
diff --git a/catalog-ui/src/app/models/tosca-get-function-type-converter.ts b/catalog-ui/src/app/models/tosca-get-function-type-converter.ts
index 0447c4bce3..ad3385af64 100644
--- a/catalog-ui/src/app/models/tosca-get-function-type-converter.ts
+++ b/catalog-ui/src/app/models/tosca-get-function-type-converter.ts
@@ -20,28 +20,47 @@
*/
import {ToscaGetFunctionType} from './tosca-get-function-type';
+import {ToscaFunctionType} from "./tosca-function-type.enum";
export class ToscaGetFunctionTypeConverter {
- static convertFromString(toscaGetFunction: string): ToscaGetFunctionType {
- if (!toscaGetFunction) {
- return;
- }
+ static convertFromString(toscaGetFunction: string): ToscaGetFunctionType {
+ if (!toscaGetFunction) {
+ return;
+ }
- if (ToscaGetFunctionType.GET_INPUT === toscaGetFunction.toUpperCase()) {
- return ToscaGetFunctionType.GET_INPUT;
- }
+ if (ToscaGetFunctionType.GET_INPUT === toscaGetFunction.toUpperCase()) {
+ return ToscaGetFunctionType.GET_INPUT;
+ }
- if (ToscaGetFunctionType.GET_PROPERTY === toscaGetFunction.toUpperCase()) {
- return ToscaGetFunctionType.GET_PROPERTY;
- }
+ if (ToscaGetFunctionType.GET_PROPERTY === toscaGetFunction.toUpperCase()) {
+ return ToscaGetFunctionType.GET_PROPERTY;
+ }
+
+ if (ToscaGetFunctionType.GET_ATTRIBUTE === toscaGetFunction.toUpperCase()) {
+ return ToscaGetFunctionType.GET_ATTRIBUTE;
+ }
+
+ return undefined;
- if (ToscaGetFunctionType.GET_ATTRIBUTE === toscaGetFunction.toUpperCase()) {
- return ToscaGetFunctionType.GET_ATTRIBUTE;
}
- return undefined;
+ /**
+ * Converts a ToscaGetFunctionType to a ToscaFunctionType
+ * @param toscaGetFunctionType
+ */
+ static convertToToscaFunctionType(toscaGetFunctionType: ToscaGetFunctionType): ToscaFunctionType {
+ switch (toscaGetFunctionType) {
+ case ToscaGetFunctionType.GET_INPUT:
+ return ToscaFunctionType.GET_INPUT;
+ case ToscaGetFunctionType.GET_ATTRIBUTE:
+ return ToscaFunctionType.GET_ATTRIBUTE;
+ case ToscaGetFunctionType.GET_PROPERTY:
+ return ToscaFunctionType.GET_PROPERTY;
+ default:
+ return undefined;
+ }
- }
+ }
}
diff --git a/catalog-ui/src/app/models/tosca-get-function.ts b/catalog-ui/src/app/models/tosca-get-function.ts
index 97497fc948..2386338c98 100644
--- a/catalog-ui/src/app/models/tosca-get-function.ts
+++ b/catalog-ui/src/app/models/tosca-get-function.ts
@@ -21,8 +21,11 @@
import {PropertySource} from "./property-source";
import {ToscaGetFunctionType} from "./tosca-get-function-type";
+import {ToscaFunction} from "./tosca-function";
+import {ToscaFunctionType} from "./tosca-function-type.enum";
-export class ToscaGetFunction {
+export class ToscaGetFunction implements ToscaFunction {
+ type: ToscaFunctionType;
propertyUniqueId: string;
propertyName: string;
propertySource: PropertySource;
@@ -30,6 +33,7 @@ export class ToscaGetFunction {
sourceName: string;
functionType: ToscaGetFunctionType;
propertyPathFromSource: Array<string>;
+ value: any
constructor(toscaGetFunction?: ToscaGetFunction) {
if (!toscaGetFunction) {
@@ -45,4 +49,5 @@ export class ToscaGetFunction {
this.propertyPathFromSource = [...toscaGetFunction.propertyPathFromSource];
}
}
+
} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/tosca-string-parameter.ts b/catalog-ui/src/app/models/tosca-string-parameter.ts
new file mode 100644
index 0000000000..0f7423582c
--- /dev/null
+++ b/catalog-ui/src/app/models/tosca-string-parameter.ts
@@ -0,0 +1,28 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import {ToscaFunctionParameter} from "./tosca-function-parameter";
+import {ToscaFunctionType} from "./tosca-function-type.enum";
+
+export class ToscaStringParameter implements ToscaFunctionParameter {
+ type: ToscaFunctionType = ToscaFunctionType.STRING;
+ value: string;
+} \ No newline at end of file