use of org.openforis.collect.model.SamplingDesignItem in project collect by openforis.
the class SamplingDesignExportProcess method exportToCSV.
public void exportToCSV(OutputStream out, CollectSurvey survey) {
CsvWriter writer = null;
try {
writer = new CsvWriter(out);
SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(survey.getId());
ArrayList<String> colNames = new ArrayList<String>();
colNames.addAll(Arrays.asList(SamplingDesignFileColumn.LEVEL_COLUMN_NAMES));
colNames.add(SamplingDesignFileColumn.X.getColumnName());
colNames.add(SamplingDesignFileColumn.Y.getColumnName());
colNames.add(SamplingDesignFileColumn.SRS_ID.getColumnName());
// info columns
List<ReferenceDataDefinition.Attribute> infoAttributes = getInfoAttributes(survey);
for (ReferenceDataDefinition.Attribute attribute : infoAttributes) {
colNames.add(attribute.getName());
}
writer.writeHeaders(colNames);
List<SamplingDesignItem> items = summaries.getRecords();
for (SamplingDesignItem item : items) {
writeSummary(writer, survey, item);
}
} catch (Exception e) {
log.error(e);
} finally {
IOUtils.closeQuietly(writer);
}
}
Aggregations