Search in sources :

Example 1 with AbstractSurveyRestoreJob

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;
}
Also used : Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) AbstractSurveyRestoreJob(org.openforis.collect.io.AbstractSurveyRestoreJob) XMLSurveyRestoreJob(org.openforis.collect.io.XMLSurveyRestoreJob) UserGroup(org.openforis.collect.model.UserGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with AbstractSurveyRestoreJob

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();
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) AbstractSurveyRestoreJob(org.openforis.collect.io.AbstractSurveyRestoreJob) XMLSurveyRestoreJob(org.openforis.collect.io.XMLSurveyRestoreJob) UserGroup(org.openforis.collect.model.UserGroup)

Aggregations

AbstractSurveyRestoreJob (org.openforis.collect.io.AbstractSurveyRestoreJob)2 XMLSurveyRestoreJob (org.openforis.collect.io.XMLSurveyRestoreJob)2 UserGroup (org.openforis.collect.model.UserGroup)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 LabelledItem (org.openforis.collect.designer.model.LabelledItem)1 Response (org.openforis.commons.web.Response)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1