use of org.talend.dataprep.exception.error.CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON in project data-prep by Talend.
the class CSVFormatUtils method compileParameterProperties.
/**
* Retrieve properties associated with a dataset content and put them in a
* map with their corresponding key.
*
* @param separator the specified separator
* @param updatedParameters the updated header
*/
Map<String, String> compileParameterProperties(Separator separator, Map<String, String> updatedParameters) {
List<String> header = separator.getHeaders().stream().map(p -> p.getKey()).collect(Collectors.toList());
// header
String jsonHeader;
try {
jsonHeader = mapper.writeValueAsString(header);
} catch (Exception e) {
throw new TDPException(UNABLE_TO_SERIALIZE_TO_JSON, e);
}
updatedParameters.put(HEADER_COLUMNS_PARAMETER, jsonHeader);
// separator
updatedParameters.put(SEPARATOR_PARAMETER, String.valueOf(separator.getSeparator()));
// if no parameter set set take the default one
updatedParameters.putIfAbsent(TEXT_ENCLOSURE_CHAR, defaultTextEnclosure);
updatedParameters.putIfAbsent(ESCAPE_CHAR, defaultEscapeChar);
return updatedParameters;
}
Aggregations