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