Search in sources :

Example 1 with DataReport

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);
}
Also used : JobView(org.openforis.collect.web.controller.CollectJobController.JobView) DataReport(org.openforis.collect.datacleansing.DataReport) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 2 with DataReport

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);
}
Also used : DataReportItem(org.openforis.collect.datacleansing.DataReportItem) PaginatedResponse(org.openforis.collect.web.controller.PaginatedResponse) DataReportItemForm(org.openforis.collect.datacleansing.form.DataReportItemForm) DataReport(org.openforis.collect.datacleansing.DataReport) ArrayList(java.util.ArrayList) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with DataReport

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);
}
Also used : DataReport(org.openforis.collect.datacleansing.DataReport) File(java.io.File) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataReport (org.openforis.collect.datacleansing.DataReport)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 DataReportItem (org.openforis.collect.datacleansing.DataReportItem)1 DataReportItemForm (org.openforis.collect.datacleansing.form.DataReportItemForm)1 JobView (org.openforis.collect.web.controller.CollectJobController.JobView)1 PaginatedResponse (org.openforis.collect.web.controller.PaginatedResponse)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1