use of org.openforis.collect.io.data.DataRestoreJob in project collect by openforis.
the class DataImportService method startImport.
@Secured(CLEANSING)
public JobProxy startImport(List<Integer> entryIdsToImport, boolean validateRecords, boolean processInTransaction) throws Exception {
if (dataRestoreJob == null || !dataRestoreJob.isRunning()) {
log.info("Starting data restore");
DataRestoreJob job;
if (processInTransaction) {
job = jobManager.createJob(TransactionalDataRestoreJob.JOB_NAME, TransactionalDataRestoreJob.class);
} else {
job = jobManager.createJob(DataRestoreJob.JOB_NAME, DataRestoreJob.class);
}
job.setFile(packagedFile);
job.setValidateRecords(validateRecords);
job.setRecordProvider(summaryJob.getRecordProvider());
job.setPackagedSurvey(summaryJob.getPackagedSurvey());
job.setPublishedSurvey(summaryJob.getPublishedSurvey());
job.setEntryIdsToImport(entryIdsToImport);
job.setRecordFilesToBeDeleted(summaryJob.getSummary().getConflictingRecordFiles(entryIdsToImport));
job.setRestoreUploadedFiles(true);
job.setValidateRecords(validateRecords);
resetJobs();
this.dataRestoreJob = job;
jobManager.start(job);
} else {
log.warn("Data restore job already running");
}
return getCurrentJob();
}
use of org.openforis.collect.io.data.DataRestoreJob in project collect by openforis.
the class DataRestoreServiceImpl method startSurveyDataRestore.
@Override
public String startSurveyDataRestore(String surveyName, File backupFile) {
CollectSurvey survey = surveyManager.get(surveyName);
String surveyUri = extractSurveyUri(backupFile);
checkValidSurvey(surveyName, surveyUri);
DataRestoreJob job = jobManager.createJob(DataRestoreJob.JOB_NAME, DataRestoreJob.class);
job.setStoreRestoredFile(true);
job.setPublishedSurvey(survey);
job.setFile(backupFile);
job.setRecordOverwriteStrategy(OverwriteStrategy.OVERWRITE_ALL);
job.setRestoreUploadedFiles(true);
job.setCloseRecordProviderOnComplete(true);
String lockId = surveyUri;
jobManager.start(job, lockId);
return lockId;
}
Aggregations