Search in sources :

Example 1 with DescendantNodeFilter

use of org.openforis.collect.io.data.DescendantNodeFilter in project collect by openforis.

the class DataQueryController method startExport.

@RequestMapping(value = "start-export.json", method = RequestMethod.POST)
@ResponseBody
public Response startExport(@Validated DataQueryForm form, @RequestParam Step recordStep) throws Exception {
    CollectSurvey survey = sessionManager.getActiveSurvey();
    DataQuery query = new DataQuery(survey);
    form.copyTo(query);
    exportJob = collectJobManager.createJob(CSVDataExportJob.class);
    exportJob.setOutputFile(File.createTempFile("data-query-export", ".csv"));
    CSVDataExportParameters parameters = new CSVDataExportParameters();
    RecordFilter recordFilter = new RecordFilter(survey);
    recordFilter.setStepGreaterOrEqual(recordStep);
    parameters.setRecordFilter(recordFilter);
    parameters.setEntityId(query.getEntityDefinitionId());
    parameters.setAlwaysGenerateZipFile(false);
    parameters.setNodeFilter(new DescendantNodeFilter(query.getAttributeDefinition(), query.getConditions()));
    exportJob.setParameters(parameters);
    collectJobManager.start(exportJob);
    /*
		csvExportItemProcessor = new CSVWriterDataQueryResultItemProcessor(query);
		csvExportItemProcessor.init();
		exportJob = collectJobManager.createJob(DataQueryExecutorJob.class);
		exportJob.setInput(new DataQueryExecutorJobInput(query, recordStep, csvExportItemProcessor));
		collectJobManager.start(exportJob);
		*/
    Response response = new Response();
    return response;
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) DescendantNodeFilter(org.openforis.collect.io.data.DescendantNodeFilter) DataQuery(org.openforis.collect.datacleansing.DataQuery) CSVDataExportJob(org.openforis.collect.io.data.CSVDataExportJob) CSVDataExportParameters(org.openforis.collect.io.data.csv.CSVDataExportParameters) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DataQuery (org.openforis.collect.datacleansing.DataQuery)1 CSVDataExportJob (org.openforis.collect.io.data.CSVDataExportJob)1 DescendantNodeFilter (org.openforis.collect.io.data.DescendantNodeFilter)1 CSVDataExportParameters (org.openforis.collect.io.data.csv.CSVDataExportParameters)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 RecordFilter (org.openforis.collect.model.RecordFilter)1 Response (org.openforis.commons.web.Response)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1