Search in sources :

Example 16 with Response

use of org.openforis.commons.web.Response in project collect by openforis.

the class RecordController method updateOwner.

@RequestMapping(value = "survey/{surveyId}/data/update/records/{recordId}", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public Response updateOwner(@PathVariable("surveyId") int surveyId, @PathVariable("recordId") int recordId, @RequestBody Map<String, String> body) throws RecordLockedException, MultipleEditException {
    String ownerIdStr = body.get("ownerId");
    Integer ownerId = ownerIdStr == null ? null : Integer.parseInt(ownerIdStr);
    CollectSurvey survey = surveyManager.getById(surveyId);
    SessionState sessionState = sessionManager.getSessionState();
    recordManager.assignOwner(survey, recordId, ownerId, sessionState.getUser(), sessionState.getSessionId());
    return new Response();
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) SessionState(org.openforis.collect.web.session.SessionState) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 17 with Response

use of org.openforis.commons.web.Response in project collect by openforis.

the class AbstractPersistedObjectEditFormController method validate.

@RequestMapping(value = "validate", method = POST)
@ResponseBody
public Response validate(@Validated F form, BindingResult result) {
    List<ObjectError> errors = result.getAllErrors();
    Response response = new SimpleFormUpdateResponse(errors);
    return response;
}
Also used : AbstractFormUpdateValidationResponse(org.openforis.commons.web.AbstractFormUpdateValidationResponse) Response(org.openforis.commons.web.Response) ObjectError(org.springframework.validation.ObjectError) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with Response

use of org.openforis.commons.web.Response in project collect by openforis.

the class AbstractPersistedObjectEditFormController method createErrorResponse.

protected Response createErrorResponse(Exception e) {
    Response response = new Response();
    response.setErrorStatus();
    response.setErrorMessage(e.getMessage());
    return response;
}
Also used : AbstractFormUpdateValidationResponse(org.openforis.commons.web.AbstractFormUpdateValidationResponse) Response(org.openforis.commons.web.Response)

Example 19 with Response

use of org.openforis.commons.web.Response in project collect by openforis.

the class BasicController method generateFormValidationResponse.

protected Response generateFormValidationResponse(BindingResult result) {
    List<ObjectError> errors = result.getAllErrors();
    Response response = new Response();
    if (!errors.isEmpty()) {
        response.setErrorStatus();
        response.addObject("errors", errors);
    }
    return response;
}
Also used : Response(org.openforis.commons.web.Response) ObjectError(org.springframework.validation.ObjectError)

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