use of org.openforis.collect.datacleansing.DataReport in project collect by openforis.
the class DataReportController method startExport.
private JobView startExport(int reportId, Class<? extends CSVWriterDataReportItemProcessor> itemProcessorType) throws Exception {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataReport report = itemManager.loadById(survey, reportId);
exportJob = new ReportExportJob();
exportJob.setSurvey(survey);
exportJob.setReport(report);
exportJob.setItemProcessorType(itemProcessorType);
exportJob.setReportManager(itemManager);
collectJobManager.start(exportJob);
return new JobView(exportJob);
}
use of org.openforis.collect.datacleansing.DataReport in project collect by openforis.
the class DataReportController method loadItems.
@RequestMapping(value = "{reportId}/items.json", method = GET)
@ResponseBody
public PaginatedResponse loadItems(@PathVariable int reportId, @RequestParam int offset, @RequestParam int limit) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataReport report = itemManager.loadById(survey, reportId);
int total = itemManager.countItems(report);
List<DataReportItem> items = itemManager.loadItems(report, offset, limit);
List<DataReportItemForm> rows = new ArrayList<DataReportItemForm>(items.size());
for (DataReportItem item : items) {
rows.add(new DataReportItemForm(item));
}
return new PaginatedResponse(total, rows);
}
use of org.openforis.collect.datacleansing.DataReport in project collect by openforis.
the class DataReportController method downloadExportedFile.
@RequestMapping(value = "{reportId}/report.csv", method = GET)
private void downloadExportedFile(HttpServletResponse response, @PathVariable int reportId) throws Exception {
File file = exportJob.getOutputFile();
DataReport report = exportJob.report;
String outputFileName = String.format(DATA_REPORT_CSV_FILE_NAME_FORMAT, report.getQueryGroup().getTitle(), Dates.formatDate(report.getCreationDate()));
Controllers.writeFileToResponse(response, file, outputFileName, Controllers.CSV_CONTENT_TYPE);
}
Aggregations