use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingDesignExportTask method execute.
@Override
protected void execute() throws Throwable {
if (getTotalItems() > 0) {
Integer surveyId = survey.getId();
CsvWriter writer = new CsvWriter(outputStream, OpenForisIOUtils.UTF_8, ',', '"');
SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(surveyId);
ArrayList<String> colNames = getHeaders();
writer.writeHeaders(colNames);
List<SamplingDesignItem> items = summaries.getRecords();
for (SamplingDesignItem item : items) {
writeSummary(writer, item);
incrementProcessedItems();
}
writer.flush();
}
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingDesignService method loadBySurvey.
protected SamplingDesignSummariesProxy loadBySurvey(boolean work, int surveyId, int offset, int maxRecords) {
SamplingDesignSummaries summaries;
CollectSurvey survey;
if (work) {
survey = surveyManager.loadSurvey(surveyId);
} else {
survey = surveyManager.getById(surveyId);
}
summaries = samplingDesignManager.loadBySurvey(surveyId, offset, maxRecords);
return new SamplingDesignSummariesProxy(survey, summaries);
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingPointDataKmlGenerator method loadSamplingDesignItems.
private List<SamplingDesignItem> loadSamplingDesignItems() {
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
List<SamplingDesignItem> result = new ArrayList<SamplingDesignItem>();
for (SamplingDesignItem item : samplingDesignItems) {
result.add(item);
}
return result;
}
use of org.openforis.collect.model.SamplingDesignSummaries 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