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