use of org.openforis.collect.io.AbstractSurveyRestoreJob in project collect by openforis.
the class SurveyController method startSurveyFileImport.
@RequestMapping(value = "startimport", method = POST)
@ResponseBody
public Response startSurveyFileImport(@Valid SurveyImportParameters params, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
Response res = new Response();
res.setErrorStatus();
res.addObject("errors", bindingResult.getFieldErrors());
return res;
}
String surveyName = params.getName();
UserGroup userGroup = userGroupManager.loadById(params.getUserGroupId());
String uploadedFileNameExtension = FilenameUtils.getExtension(this.uploadedSurveyFile.getName());
AbstractSurveyRestoreJob job;
if (Files.XML_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(XMLSurveyRestoreJob.class);
} else if (COLLECT_EARTH_PROJECT_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(CESurveyRestoreJob.class);
} else {
job = jobManager.createJob(SurveyRestoreJob.class);
}
job.setFile(this.uploadedSurveyFile);
job.setSurveyName(surveyName);
job.setSurveyUri(uploadedSurveyInfo == null ? null : uploadedSurveyInfo.getSurveyUri());
job.setUserGroup(userGroup);
job.setRestoreIntoPublishedSurvey(false);
job.setValidateSurvey(false);
job.setActiveUser(sessionManager.getLoggedUser());
jobManager.start(job);
this.surveyImportJob = job;
Response res = new Response();
res.setObject(new SurveyImportJobView(job));
return res;
}
use of org.openforis.collect.io.AbstractSurveyRestoreJob in project collect by openforis.
the class SurveyImportVM method startSurveyImport.
protected void startSurveyImport() {
String surveyName = getFormSurveyName();
LabelledItem userGroupItem = (LabelledItem) form.get(USER_GROUP_FIELD_NAME);
UserGroup userGroup = userGroupManager.findByName(userGroupItem.getCode());
String uploadedFileNameExtension = FilenameUtils.getExtension(this.uploadedFileName);
AbstractSurveyRestoreJob job;
if (XML_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(XMLSurveyRestoreJob.class);
} else if (CEP_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(CESurveyRestoreJob.class);
} else {
job = jobManager.createJob(SurveyRestoreJob.class);
}
job.setFile(uploadedFile);
job.setSurveyName(surveyName);
job.setSurveyUri(uploadedSurveyUri);
job.setUserGroup(userGroup);
job.setRestoreIntoPublishedSurvey(false);
job.setValidateSurvey(false);
job.setActiveUser(getLoggedUser());
jobManager.start(job);
this.restoreJob = job;
openSurveyRestoreStatusPopUp();
}
Aggregations