use of org.openforis.commons.io.csv.CsvWriter in project collect by openforis.
the class DataBackupTask method initializeDataSummaryCSVWriter.
private void initializeDataSummaryCSVWriter() throws IOException, UnsupportedEncodingException, FileNotFoundException {
summaryTempFile = File.createTempFile("summary", ".csv");
summaryCSVWriter = new CsvWriter(new FileOutputStream(summaryTempFile), OpenForisIOUtils.UTF_8, ',', '"');
List<String> headers = new ArrayList<String>(Arrays.asList(DATA_SUMMARY_FIXED_HEADERS));
for (int i = 0; i < SurveyValidator.MAX_KEY_ATTRIBUTE_DEFINITION_COUNT; i++) {
headers.add(DATA_SUMMARY_RECORD_KEY_PREFIX + (i + 1));
}
summaryCSVWriter.writeHeaders(headers);
}
use of org.openforis.commons.io.csv.CsvWriter in project collect by openforis.
the class ValidationReportJob method initializeInternalVariables.
@Override
protected void initializeInternalVariables() throws Throwable {
super.initializeInternalVariables();
validationMessageBuilder = ValidationMessageBuilder.createInstance(messageSource);
outputFile = File.createTempFile("of_collect_validation_report", ".csv");
outputStream = new FileOutputStream(outputFile);
switch(input.reportType) {
case CSV:
csvWriter = new CsvWriter(outputStream, IOUtils.UTF_8, ',', '"');
break;
}
}
use of org.openforis.commons.io.csv.CsvWriter in project collect by openforis.
the class CodeListExportProcess method exportToCSV.
public void exportToCSV(OutputStream out, CollectSurvey survey, int codeListId) {
CsvWriter writer = null;
try {
OutputStreamWriter osWriter = new OutputStreamWriter(out, Charset.forName("UTF-8"));
writer = new CsvWriter(osWriter, SEPARATOR, QUOTECHAR);
CodeList list = survey.getCodeListById(codeListId);
initHeaders(writer, survey, list);
List<CodeListItem> rootItems = codeListManager.loadRootItems(list);
for (CodeListItem item : rootItems) {
List<CodeListItem> ancestors = Collections.emptyList();
writeItem(writer, item, ancestors);
}
} catch (Exception e) {
LOG.error(e);
} finally {
IOUtils.closeQuietly(writer);
}
}
use of org.openforis.commons.io.csv.CsvWriter in project collect by openforis.
the class CodeListExportTask method createInternalVariables.
@Override
protected void createInternalVariables() throws Throwable {
super.createInternalVariables();
OutputStreamWriter osWriter = new OutputStreamWriter(out, OpenForisIOUtils.UTF_8);
writer = new CsvWriter(osWriter, SEPARATOR, QUOTECHAR);
}
use of org.openforis.commons.io.csv.CsvWriter in project collect by openforis.
the class CSVWriterDataQueryResultItemProcessor method init.
private void init() {
try {
tempFile = File.createTempFile("collect-data-cleansing-query", ".csv");
csvWriter = new CsvWriter(new FileOutputStream(tempFile), IOUtils.UTF_8, ',', '"');
writeCSVHeader();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations