import org.openecomp.sdc.be.components.impl.NodeFilterUploadCreator;
import org.openecomp.sdc.be.components.impl.PolicyTypeBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.utils.PropertiesUtils;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
parsedToscaYamlInfo.setProperties(getProperties(loadYamlAsStrictMap(interfaceTemplateYaml)));
parsedToscaYamlInfo.setSubstitutionFilterProperties(getSubstitutionFilterProperties(mappedToscaTemplate));
}
+ if (substitutionMappings.get("properties") != null) {
+ parsedToscaYamlInfo.setSubstitutionMappingProperties((Map<String, List<String>>) substitutionMappings.get("properties"));
+ }
parsedToscaYamlInfo.setSubstitutionMappingNodeType((String) substitutionMappings.get(NODE_TYPE.getElementName()));
}
log.debug("#parseResourceInfoFromYAML - The yaml {} has been parsed ", fileName);
}
final UploadPropInfo uploadPropInfo = buildProperty(propertyJson.getKey(), propertyJson.getValue());
final PropertyDefinition propertyDefinition = new PropertyDefinition(originalProperty);
- propertyDefinition.setValue(gson.toJson(uploadPropInfo.getValue()));
propertyDefinition.setToscaFunction(uploadPropInfo.getToscaFunction());
propertyDefinition.setSubPropertyToscaFunctions(uploadPropInfo.getSubPropertyToscaFunctions());
propertyDefinition.setGetInputValues(uploadPropInfo.getGet_input());
propertyDefinition.setDescription(uploadPropInfo.getDescription());
+ String propertyValue = gson.toJson(uploadPropInfo.getValue());
+ if (!propertyDefinition.isToscaFunction()) {
+ propertyValue = PropertiesUtils.trimQuotes(propertyValue);
+ }
+ propertyDefinition.setValue(propertyValue);
return propertyDefinition;
})
.filter(Objects::nonNull)
@SuppressWarnings("unchecked")
private Map<String, List<UploadCapInfo>> createCapModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
Map<String, List<UploadCapInfo>> moduleCap = new HashMap<>();
- Either<List<Object>, ResultStatusEnum> capabilitiesListRes = findFirstToscaListElement(nodeTemplateJsonMap, CAPABILITIES);
- if (capabilitiesListRes.isLeft()) {
- for (Object jsonCapObj : capabilitiesListRes.left().value()) {
- String key = ((Map<String, Object>) jsonCapObj).keySet().iterator().next();
- Object capJson = ((Map<String, Object>) jsonCapObj).get(key);
- addModuleNodeTemplateCap(moduleCap, capJson, key);
- }
- } else {
- Either<Map<String, Object>, ResultStatusEnum> capabilitiesMapRes = findFirstToscaMapElement(nodeTemplateJsonMap, CAPABILITIES);
- if (capabilitiesMapRes.isLeft()) {
- for (Map.Entry<String, Object> entry : capabilitiesMapRes.left().value().entrySet()) {
- String capName = entry.getKey();
- Object capJson = entry.getValue();
- addModuleNodeTemplateCap(moduleCap, capJson, capName);
- }
+ Map<String, Object> capabilities = (Map<String, Object>) nodeTemplateJsonMap.get(CAPABILITIES.getElementName());
+ if (MapUtils.isNotEmpty(capabilities)) {
+ for (Map.Entry<String, Object> entry : capabilities.entrySet()) {
+ String capName = entry.getKey();
+ Object capJson = entry.getValue();
+ addModuleNodeTemplateCap(moduleCap, capJson, capName);
}
}
return moduleCap;
@SuppressWarnings("unchecked")
private void fillInputsListRecursively(UploadPropInfo propertyDef, List<Object> propValueList) {
+ int index = 0;
for (Object objValue : propValueList) {
if (objValue instanceof Map) {
Map<String, Object> objMap = (Map<String, Object>) objValue;
+ Map<String, Object> propValueMap = new HashMap<String, Object>();
+ propValueMap.put(String.valueOf(index),objValue);
+ final Collection<SubPropertyToscaFunction> subPropertyToscaFunctions = buildSubPropertyToscaFunctions(propValueMap, new ArrayList<>());
+ if (CollectionUtils.isNotEmpty(subPropertyToscaFunctions)) {
+ Collection<SubPropertyToscaFunction> existingSubPropertyToscaFunctions = propertyDef.getSubPropertyToscaFunctions();
+ if (existingSubPropertyToscaFunctions == null) {
+ propertyDef.setSubPropertyToscaFunctions(subPropertyToscaFunctions);
+ } else {
+ propertyDef.getSubPropertyToscaFunctions().addAll(subPropertyToscaFunctions);
+ }
+ }
if (objMap.containsKey(GET_INPUT.getElementName())) {
fillInputRecursively(propertyDef.getName(), objMap, propertyDef);
} else {
List<Object> propSubValueList = (List<Object>) objValue;
fillInputsListRecursively(propertyDef, propSubValueList);
}
+ index++;
}
}