Search in sources :

Example 6 with Response

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);
    }
}
Also used : AbstractFormUpdateValidationResponse(org.openforis.commons.web.AbstractFormUpdateValidationResponse) Response(org.openforis.commons.web.Response) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Response

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;
}
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)

Example 8 with 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;
}
Also used : Response(org.openforis.commons.web.Response) DataCleansingChain(org.openforis.collect.datacleansing.DataCleansingChain) DataCleansingChainExecutorJob(org.openforis.collect.datacleansing.DataCleansingChainExecutorJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with 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);
    }
}
Also used : DataQueryExecutorJobInput(org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput) Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) ObjectError(org.springframework.validation.ObjectError) DataQueryExecutorJob(org.openforis.collect.datacleansing.DataQueryExecutorJob) DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with Response

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();
}
Also used : DataReportGeneratorJob(org.openforis.collect.datacleansing.DataReportGeneratorJob) PaginatedResponse(org.openforis.collect.web.controller.PaginatedResponse) Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CollectSurvey(org.openforis.collect.model.CollectSurvey) DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Response (org.openforis.commons.web.Response)19 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)13 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 AbstractFormUpdateValidationResponse (org.openforis.commons.web.AbstractFormUpdateValidationResponse)3 ObjectError (org.springframework.validation.ObjectError)3 DataQuery (org.openforis.collect.datacleansing.DataQuery)2 SurveySummary (org.openforis.collect.model.SurveySummary)2 UserGroup (org.openforis.collect.model.UserGroup)2 Transactional (org.springframework.transaction.annotation.Transactional)2 File (java.io.File)1 DataCleansingChain (org.openforis.collect.datacleansing.DataCleansingChain)1 DataCleansingChainExecutorJob (org.openforis.collect.datacleansing.DataCleansingChainExecutorJob)1 DataQueryExecutorJob (org.openforis.collect.datacleansing.DataQueryExecutorJob)1 DataQueryExecutorJobInput (org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput)1 DataQueryGroup (org.openforis.collect.datacleansing.DataQueryGroup)1 DataReportGeneratorJob (org.openforis.collect.datacleansing.DataReportGeneratorJob)1 AbstractSurveyRestoreJob (org.openforis.collect.io.AbstractSurveyRestoreJob)1 SurveyBackupInfoExtractorJob (org.openforis.collect.io.SurveyBackupInfoExtractorJob)1