}
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);
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',
}
newProperty.value = undefined;
newProperty.toscaFunction = undefined;
-
if (typeof this.currentRule.value === 'string') {
newProperty.value = this.currentRule.value;
this.propertiesUtils.initValueObjectRef(newProperty);
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;
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;
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;
}
}
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 {
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;
}