Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I51bbc92ea355dd36206746f96984d3593446f188
Issue-ID: SDC-4586
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
-import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.text.StringEscapeUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.sdc.tosca.datatypes.model.PropertyType;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.sdc.tosca.datatypes.model.PropertyType;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
if (property.isToscaFunction()) {
toscaFunctionValidator.validate(property, containerComponent);
property.setValue(StringEscapeUtils.unescapeJava(property.getToscaFunction().getValue()));
if (property.isToscaFunction()) {
toscaFunctionValidator.validate(property, containerComponent);
property.setValue(StringEscapeUtils.unescapeJava(property.getToscaFunction().getValue()));
+ if (ToscaFunctionType.GET_INPUT == property.getToscaFunction().getType()) {
+ property.setGetInputValues(Collections.singletonList(buildGetInputValue(property)));
+ }
}
if (CollectionUtils.isNotEmpty(property.getSubPropertyToscaFunctions())) {
ToscaPropertyType type = ToscaPropertyType.isValidType(property.getType());
}
if (CollectionUtils.isNotEmpty(property.getSubPropertyToscaFunctions())) {
ToscaPropertyType type = ToscaPropertyType.isValidType(property.getType());
+ private GetInputValueDataDefinition buildGetInputValue(final ComponentInstanceProperty property) {
+ final GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ getInputValueDataDefinition.setPropName(property.getName());
+ getInputValueDataDefinition.setInputName(((ToscaGetFunctionDataDefinition) property.getToscaFunction()).getPropertyName());
+ getInputValueDataDefinition.setInputId(((ToscaGetFunctionDataDefinition) property.getToscaFunction()).getPropertyUniqueId());
+ return getInputValueDataDefinition;
+ }
+
private void addE(JSONArray jsonArray, List<String> path, String value) {
Object objectForPath = jsonArray.opt(Integer.parseInt(path.get(0)));
if (objectForPath == null) {
private void addE(JSONArray jsonArray, List<String> path, String value) {
Object objectForPath = jsonArray.opt(Integer.parseInt(path.get(0)));
if (objectForPath == null) {
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
- if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !"list".equalsIgnoreCase(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
+ if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType())
+ && !"list".equalsIgnoreCase(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
throw ToscaGetFunctionExceptionSupplier
.propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}
throw ToscaGetFunctionExceptionSupplier
.propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}
propertyCopy.setDefaultValue(property.getDefaultValue());
propertyCopy.setInputId(property.getInputId());
propertyCopy.setGetInputValues(property.getGetInputValues());
propertyCopy.setDefaultValue(property.getDefaultValue());
propertyCopy.setInputId(property.getInputId());
propertyCopy.setGetInputValues(property.getGetInputValues());
+ propertyCopy.setToscaFunction(property.getToscaFunction());
this.origComponentInstanceProperties.add(propertyCopy);
});
}
this.origComponentInstanceProperties.add(propertyCopy);
});
}
private void mergeInstanceDefinition(MergePropertyData mergeData) {
if (isSameType(mergeData.getOldProp(), mergeData.getNewProp())) {
propertyValueMergeBL.mergePropertyValue(mergeData.getOldProp(), mergeData.getNewProp(), mergeData.getGetInputNamesToMerge());
private void mergeInstanceDefinition(MergePropertyData mergeData) {
if (isSameType(mergeData.getOldProp(), mergeData.getNewProp())) {
propertyValueMergeBL.mergePropertyValue(mergeData.getOldProp(), mergeData.getNewProp(), mergeData.getGetInputNamesToMerge());
+ if (mergeData.getOldProp().isToscaFunction()) {
+ mergeData.getNewProp().setToscaFunction(mergeData.getOldProp().getToscaFunction());
+ }
}
private Object convertPropertyStrValueToObject(PropertyDataDefinition propertyDataDefinition, Map<String, DataTypeDefinition> dataTypes) {
}
private Object convertPropertyStrValueToObject(PropertyDataDefinition propertyDataDefinition, Map<String, DataTypeDefinition> dataTypes) {
- String propValue = propertyDataDefinition.getValue() == null ? "" : propertyDataDefinition.getValue();
- String propertyType = propertyDataDefinition.getType();
- String innerType = propertyDataDefinition.getSchemaType();
+ final String propValue = propertyDataDefinition.getValue() == null ? "" : propertyDataDefinition.getValue();
return propertyConvertor.convertToToscaObject(propertyDataDefinition, propValue, dataTypes, true);
}
return propertyConvertor.convertToToscaObject(propertyDataDefinition, propValue, dataTypes, true);
}
protected Map<String, Object> toscaPresentation;
protected Map<String, Object> toscaPresentation;
- public ToscaDataDefinition() {
+ protected ToscaDataDefinition() {
toscaPresentation = new HashMap<>();
}
@JsonCreator
toscaPresentation = new HashMap<>();
}
@JsonCreator
- public ToscaDataDefinition(Map<String, Object> art) {
+ protected ToscaDataDefinition(Map<String, Object> art) {
toscaPresentation = art;
}
toscaPresentation = art;
}