import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CustomYamlFunction;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
final var property = new ComponentInstanceProperty(curPropertyDef, value, null);
String validatePropValue = serviceBusinessLogic.validatePropValueBeforeCreate(property, value, isValidate, allDataTypes);
property.setValue(validatePropValue);
- property.setToscaFunction(propertyInfo.getToscaFunction());
+
+ if (tryHandlingAsYamlToscaFunction(validatePropValue, value, propertyInfo)) {
+ try {
+ final Object yamlValue = new Yaml().loadAs(value, Object.class);
+ CustomYamlFunction toscaFunction = new CustomYamlFunction();
+ toscaFunction.setYamlValue(yamlValue);
+ property.setToscaFunction(toscaFunction);
+ } catch (Exception exception) {
+ log.info("Cannot create YAML value for {}", propName);
+ }
+ } else {
+ property.setToscaFunction(propertyInfo.getToscaFunction());
+ }
if (!getInputs.isEmpty()) {
final List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
for (final GetInputValueDataDefinition getInput : getInputs) {
instProperties.put(currentCompInstance.getUniqueId(), instPropList);
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
+
+ private boolean tryHandlingAsYamlToscaFunction(String validatePropValue, String value, UploadPropInfo propertyInfo) {
+ return StringUtils.isEmpty(validatePropValue) && StringUtils.isNotEmpty(value) && propertyInfo.getToscaFunction() == null;
+ }
protected ResponseFormat addInterfaceValuesToRi(
UploadComponentInstanceInfo uploadComponentInstanceInfo,