Search in sources :

Example 1 with DataRestoreSummaryJob

use of org.openforis.collect.io.data.DataRestoreSummaryJob in project collect by openforis.

the class RecordController method startRecordImportSummaryJob.

@RequestMapping(value = "survey/{surveyId}/data/import/records/summary", method = POST, consumes = MULTIPART_FORM_DATA_VALUE)
@ResponseBody
public JobView startRecordImportSummaryJob(@PathVariable("surveyId") int surveyId, @RequestParam("file") MultipartFile multipartFile, @RequestParam String rootEntityName) throws IOException {
    File file = File.createTempFile("ofc_data_restore", ".collect-data");
    FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
    CollectSurvey survey = surveyManager.getById(surveyId);
    DataRestoreSummaryJob job = jobManager.createJob(DataRestoreSummaryJob.class);
    job.setUser(sessionManager.getLoggedUser());
    job.setFullSummary(true);
    job.setFile(file);
    job.setPublishedSurvey(survey);
    job.setCloseRecordProviderOnComplete(false);
    jobManager.start(job);
    this.dataRestoreSummaryJob = job;
    return new JobView(job);
}
Also used : JobView(org.openforis.collect.web.controller.CollectJobController.JobView) DataRestoreSummaryJob(org.openforis.collect.io.data.DataRestoreSummaryJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with DataRestoreSummaryJob

use of org.openforis.collect.io.data.DataRestoreSummaryJob in project collect by openforis.

the class DataImportService method startSummaryCreation.

@Secured(CLEANSING)
public JobProxy startSummaryCreation(String filePath, String selectedSurveyUri, boolean overwriteAll, boolean fullSummary) throws DataImportExeption {
    if (summaryJob == null || !summaryJob.isRunning()) {
        log.info("Starting data import summary creation");
        packagedFile = new File(filePath);
        log.info("Using file: " + packagedFile.getAbsolutePath());
        CollectSurvey survey = surveyManager.getByUri(selectedSurveyUri);
        DataRestoreSummaryJob job = jobManager.createJob(DataRestoreSummaryJob.class);
        job.setFullSummary(fullSummary);
        job.setFile(packagedFile);
        job.setPublishedSurvey(survey);
        job.setCloseRecordProviderOnComplete(false);
        resetJobs();
        this.summaryJob = job;
        jobManager.start(job);
    } else {
        log.warn("Summary creation job already running");
    }
    return getCurrentJob();
}
Also used : DataRestoreSummaryJob(org.openforis.collect.io.data.DataRestoreSummaryJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

File (java.io.File)2 DataRestoreSummaryJob (org.openforis.collect.io.data.DataRestoreSummaryJob)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 JobView (org.openforis.collect.web.controller.CollectJobController.JobView)1 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1