Search in sources :

Example 11 with Response

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

the class RecordController method promoteRecord.

@RequestMapping(value = "survey/{surveyId}/data/records/promote/{recordId}", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public Response promoteRecord(@PathVariable("surveyId") int surveyId, @PathVariable("recordId") int recordId) throws MissingRecordKeyException, RecordPromoteException {
    CollectSurvey survey = surveyManager.getById(surveyId);
    CollectRecord record = recordManager.load(survey, recordId);
    recordManager.promote(record, sessionManager.getLoggedUser(), true);
    return new Response();
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CollectRecord(org.openforis.collect.model.CollectRecord) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with Response

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

the class RecordController method deleteRecord.

@RequestMapping(value = "survey/{surveyId}/data/records", method = DELETE, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public Response deleteRecord(@PathVariable("surveyId") int surveyId, @Valid RecordDeleteParameters params) throws RecordPersistenceException {
    if (canDeleteRecords(surveyId, Sets.newHashSet(params.getRecordIds()))) {
        recordManager.deleteByIds(new HashSet<Integer>(Arrays.asList(params.getRecordIds())));
        return new Response();
    } else {
        Response response = new Response();
        response.setErrorStatus();
        response.setErrorMessage("Cannot delete some of the specified records: unsufficient user privilegies");
        return response;
    }
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with Response

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

the class RecordController method demoteRecord.

@RequestMapping(value = "survey/{surveyId}/data/records/demote/{recordId}", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public Response demoteRecord(@PathVariable("surveyId") int surveyId, @PathVariable("recordId") int recordId) throws RecordPersistenceException {
    CollectSurvey survey = surveyManager.getById(surveyId);
    recordManager.demote(survey, recordId, sessionManager.getLoggedUser());
    return new Response();
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 14 with Response

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

the class SaikuController method getInfo.

@RequestMapping(value = "datasources/{surveyName}/info", method = GET)
@ResponseBody
public Response getInfo(@PathVariable String surveyName) {
    ReportingRepositoryInfo info = reportingRepositories.getInfo(surveyName);
    Response response = new Response();
    response.setObject(info);
    return response;
}
Also used : ReportingRepositoryInfo(org.openforis.collect.reporting.ReportingRepositoryInfo) Response(org.openforis.commons.web.Response) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with Response

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

the class SurveyController method createSurvey.

@Transactional
@RequestMapping(method = POST)
@ResponseBody
public Response createSurvey(@Valid SurveyCreationParameters params, BindingResult bindingResult) throws Exception {
    if (bindingResult.hasErrors()) {
        Response res = new Response();
        res.setErrorStatus();
        res.addObject("errors", bindingResult.getFieldErrors());
        return res;
    }
    CollectSurvey survey;
    switch(params.getTemplateType()) {
        case BLANK:
            survey = createEmptySurvey(params.getName(), params.getDefaultLanguageCode());
            break;
        default:
            survey = createNewSurveyFromTemplate(params.getName(), params.getDefaultLanguageCode(), params.getTemplateType());
    }
    UserGroup userGroup = userGroupManager.loadById(params.getUserGroupId());
    survey.setUserGroupId(userGroup.getId());
    surveyManager.save(survey);
    SurveySummary surveySummary = SurveySummary.createFromSurvey(survey);
    Response res = new Response();
    res.setObject(surveySummary);
    return res;
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) SurveySummary(org.openforis.collect.model.SurveySummary) CollectSurvey(org.openforis.collect.model.CollectSurvey) UserGroup(org.openforis.collect.model.UserGroup) Transactional(org.springframework.transaction.annotation.Transactional) 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