Search in sources :

Example 1 with CsvWriter

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);
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList)

Example 2 with CsvWriter

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;
    }
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) FileOutputStream(java.io.FileOutputStream)

Example 3 with CsvWriter

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);
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CsvWriter(org.openforis.commons.io.csv.CsvWriter) OutputStreamWriter(java.io.OutputStreamWriter) CodeListItem(org.openforis.idm.metamodel.CodeListItem)

Example 4 with CsvWriter

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);
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) OutputStreamWriter(java.io.OutputStreamWriter)

Example 5 with CsvWriter

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);
    }
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException)

Aggregations

CsvWriter (org.openforis.commons.io.csv.CsvWriter)11 FileOutputStream (java.io.FileOutputStream)4 ArrayList (java.util.ArrayList)4 OutputStreamWriter (java.io.OutputStreamWriter)3 TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)3 TaxonSummary (org.openforis.collect.metamodel.TaxonSummary)3 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)3 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)2 SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)2 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 Task (org.openforis.concurrency.Task)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 CodeList (org.openforis.idm.metamodel.CodeList)1 CodeListItem (org.openforis.idm.metamodel.CodeListItem)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)1 ReferenceDataDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition)1 Schema (org.openforis.idm.metamodel.Schema)1