diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2023-06-27 11:20:23 +0100 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2023-08-18 12:37:57 +0000 |
commit | d32437595314c9b5b2aa439a482d0b07286a8072 (patch) | |
tree | 1ae162901579eb0fb9f403ecd41308ac91c17c2a | |
parent | 98826572a529d01250cf4925dc3f26ac8c35478a (diff) |
Custom tosca functions with valid_values and in_range operators not showing properly
Issue-ID: SDC-4554
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I8c6ad232951d887593a15562b11c03d8613be29b
5 files changed, 52 insertions, 11 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts index 66ae3cc23c..412e29a427 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts @@ -167,9 +167,9 @@ export class ToscaFunctionComponent implements OnInit, OnChanges { } this.toscaFunctionForm.setValue(this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction); - let type = this.property.toscaFunction.type; + let type = this.property.toscaFunction.type ? this.property.toscaFunction.type : this.toscaFunctionForm.value.type; if (type == ToscaFunctionType.CUSTOM) { - let name = (this.property.toscaFunction as ToscaCustomFunction).name; + let name = (this.toscaFunctionForm.value as ToscaCustomFunction).name; let customToscaFunc = this.customToscaFunctions.find(custToscFunc => _.isEqual(custToscFunc.name, name)) if (customToscaFunc) { this.toscaFunctionTypeForm.setValue(name); diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less index 36772a2f96..871af143ac 100644 --- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less +++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less @@ -5,6 +5,11 @@ justify-content: flex-end; } +.service-dependencies-editor { + overflow: scroll; + max-height: 700px; +} + .i-sdc-form-content { display: flex; flex-direction: column; diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts index 5f26bd7547..fdaf2f3573 100644 --- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts +++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts @@ -31,6 +31,7 @@ import {ToscaFunctionHelper} from "../../../utils/tosca-function-helper"; import {TopologyTemplateService} from "app/ng2/services/component-services/topology-template.service"; import {CustomToscaFunction} from "../../../models/default-custom-functions"; import {ToscaFunction} from "../../../models/tosca-function"; +import {ToscaCustomFunction} from "../../../models/tosca-custom-function"; @Component({ selector: 'service-dependencies-editor', @@ -302,7 +303,6 @@ export class ServiceDependenciesEditorComponent implements OnInit { } newProperty.value = undefined; newProperty.toscaFunction = undefined; - if (typeof this.currentRule.value === 'string') { newProperty.value = this.currentRule.value; this.propertiesUtils.initValueObjectRef(newProperty); @@ -310,8 +310,7 @@ export class ServiceDependenciesEditorComponent implements OnInit { newProperty.toscaFunction = ToscaFunctionHelper.convertObjectToToscaFunction(this.currentRule.value); newProperty.value = newProperty.toscaFunction.buildValueString(); } else if (Array.isArray(this.currentRule.value) && - typeof this.currentRule.value[0] === "object" && - this.currentRule.value[0]['propertySource'] != undefined) { + typeof this.currentRule.value[0] === "object") { this.validValuesToscaFunctionList = this.currentRule.value; this.rangeToscaFunctionList = this.currentRule.value; newProperty.toscaFunction = this.currentRule.value; @@ -391,6 +390,10 @@ export class ServiceDependenciesEditorComponent implements OnInit { if (validationEvent.toscaFunction instanceof ToscaGetFunction) { this.currentRule.sourceName = SourceType.TOSCA_FUNCTION_LIST; } + else if (validationEvent.toscaFunction instanceof ToscaCustomFunction) { + this.currentRule.sourceName = SourceType.TOSCA_FUNCTION_LIST; + this.currentRule.sourceType = SourceType.TOSCA_FUNCTION_LIST; + } } else { if (this.isLengthOperator()) { this.overridingType = PROPERTY_TYPES.INTEGER; diff --git a/catalog-ui/src/app/utils/filter-constraint-helper.ts b/catalog-ui/src/app/utils/filter-constraint-helper.ts index 6504a35acd..4ea7532969 100644 --- a/catalog-ui/src/app/utils/filter-constraint-helper.ts +++ b/catalog-ui/src/app/utils/filter-constraint-helper.ts @@ -29,7 +29,7 @@ export class FilterConstraintHelper { if (ToscaFunctionHelper.isValueToscaFunction(constraint.value)) { const toscaFunction = ToscaFunctionHelper.convertObjectToToscaFunction(constraint.value); if (toscaFunction) { - value = toscaFunction.value === undefined || toscaFunction.value == null ? toscaFunction.buildValueString() : toscaFunction.value + value = toscaFunction.value === undefined || toscaFunction.value == null ? toscaFunction.buildValueString() : toscaFunction.value } else { value = JSON.stringify(constraint.value, null, 4); } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java index 1f7459c59d..fa9e4d5fc7 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java @@ -67,10 +67,25 @@ public class PropertyFilterConstraintDataDefinitionHelper { final Optional<ToscaFunction> toscaFunction = createToscaFunctionFromLegacyConstraintValue(valueYaml); if (toscaFunction.isPresent()) { propertyFilterConstraint.setValue(toscaFunction.get()); - } else { + propertyFilterConstraint.setValueType(detectValueType(valueYaml)); + } + else { propertyFilterConstraint.setValue(valueYaml); + if (valueYaml instanceof List) { + List<ToscaFunction> listToscaFunction = new ArrayList<>(); + ((List<?>) valueYaml).stream().forEach(val -> { + final Optional<ToscaFunction> optToscaFunctionLst = createToscaFunctionFromLegacyConstraintValue(val); + if (optToscaFunctionLst.isPresent()) { + listToscaFunction.add(optToscaFunctionLst.get()); + } + }); + propertyFilterConstraint.setValue(listToscaFunction); + propertyFilterConstraint.setValueType(FilterValueType.SEVERAL); + } + else { + propertyFilterConstraint.setValueType(detectValueType(valueYaml)); + } } - propertyFilterConstraint.setValueType(detectValueType(valueYaml)); propertyFilterConstraint.setTargetType(PropertyFilterTargetType.PROPERTY); return propertyFilterConstraint; } @@ -90,9 +105,7 @@ public class PropertyFilterConstraintDataDefinitionHelper { } ToscaFunctionType toscaFunctionType = ToscaFunctionType.findType((String) toscaFunctionTypeObject).orElse(null); if (toscaFunctionType == null) { - if (((String) toscaFunctionTypeObject).equalsIgnoreCase("$get_input_ext") || - ((String) toscaFunctionTypeObject).equalsIgnoreCase("$juel") || - ((String) toscaFunctionTypeObject).equalsIgnoreCase("$other")) { + if (((String) toscaFunctionTypeObject).startsWith("$")) { toscaFunctionType = ToscaFunctionType.CUSTOM; } else { @@ -509,6 +522,26 @@ public class PropertyFilterConstraintDataDefinitionHelper { return FilterValueType.CUSTOM; } } + else if (value instanceof List) { + final Map<?, ?> valueAsMap = (Map<?, ?>) ((List<?>) value).get(0); + if (valueAsMap.containsKey(ToscaFunctionType.CONCAT.getName())) { + return FilterValueType.CONCAT; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_ATTRIBUTE.getName())) { + return FilterValueType.GET_ATTRIBUTE; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_PROPERTY.getName())) { + return FilterValueType.GET_PROPERTY; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_INPUT.getName())) { + return FilterValueType.GET_INPUT; + } + if (valueAsMap.containsKey("$get_input_ext") || + valueAsMap.containsKey("$juel") || + valueAsMap.containsKey("$other")) { + return FilterValueType.CUSTOM; + } + } return FilterValueType.STATIC; } |