use of org.openforis.commons.web.Response in project collect by openforis.
the class AbstractPersistedObjectEditFormController method delete.
@RequestMapping(value = "/{id}", method = DELETE)
@ResponseBody
public Response delete(@PathVariable int id) {
try {
T item = loadItem(id);
itemManager.delete(item);
return new Response();
} catch (Exception e) {
return createErrorResponse(e);
}
}
use of org.openforis.commons.web.Response 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;
}
use of org.openforis.commons.web.Response in project collect by openforis.
the class DataCleansingChainController method run.
@RequestMapping(value = "{chainId}/run.json", method = RequestMethod.POST)
@ResponseBody
public Response run(@PathVariable int chainId, @RequestParam Step recordStep) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataCleansingChain chain = itemManager.loadById(survey, chainId);
DataCleansingChainExecutorJob job = collectJobManager.createJob(DataCleansingChainExecutorJob.class);
job.setChain(chain);
job.setRecordStep(recordStep);
collectJobManager.startSurveyJob(job);
Response response = new Response();
return response;
}
use of org.openforis.commons.web.Response in project collect by openforis.
the class DataQueryController method startTest.
@RequestMapping(value = "start-test.json", method = RequestMethod.POST)
@ResponseBody
public Response startTest(@Validated DataQueryForm form, @RequestParam Step recordStep, BindingResult result) {
List<ObjectError> errors = result.getAllErrors();
if (errors.isEmpty()) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataQuery query = new DataQuery(survey);
form.copyTo(query);
testJob = collectJobManager.createJob(DataQueryExecutorJob.class);
testJob.setInput(new DataQueryExecutorJobInput(query, recordStep, new MemoryStoreDataQueryResultItemProcessor(query), TEST_MAX_RECORDS));
collectJobManager.start(testJob);
return new Response();
} else {
return new SimpleFormUpdateResponse(errors);
}
}
use of org.openforis.commons.web.Response in project collect by openforis.
the class DataReportController method generate.
@RequestMapping(value = "generate.json", method = POST)
@ResponseBody
public Response generate(@RequestParam int queryGroupId, @RequestParam Step recordStep) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataQueryGroup queryGroup = dataQueryGroupManager.loadById(survey, queryGroupId);
generationJob = collectJobManager.createJob(DataReportGeneratorJob.class);
generationJob.setQueryGroup(queryGroup);
generationJob.setRecordStep(recordStep);
generationJob.setActiveUser(getLoggedUser());
collectJobManager.start(generationJob);
return new Response();
}
Aggregations