use of org.openforis.collect.io.SurveyRestoreJob in project collect by openforis.
the class DataRestoreBaseJob method initializeTask.
@Override
protected void initializeTask(Worker task) {
if (task instanceof SurveyRestoreJob) {
SurveyRestoreJob t = (SurveyRestoreJob) task;
t.setFile(file);
t.setRestoreIntoPublishedSurvey(true);
t.setSurveyName(surveyName);
t.setValidateSurvey(true);
t.setUserGroup(newSurveyUserGroup);
} else if (task instanceof IdmlUnmarshallTask) {
IdmlUnmarshallTask t = (IdmlUnmarshallTask) task;
File idmlFile = backupFileExtractor.extractIdmlFile();
t.setSurveyManager(surveyManager);
t.setFile(idmlFile);
t.setValidate(false);
} else if (task instanceof RecordProviderInitializerTask) {
RecordProviderInitializerTask t = (RecordProviderInitializerTask) task;
Input input = new Input();
input.setActiveUser(user);
input.setExistingSurvey(publishedSurvey);
input.setFile(file);
input.setPackagedSurvey(packagedSurvey);
input.setUserManager(userManager);
input.setValidateRecords(validateRecords);
t.setInput(input);
}
super.initializeTask(task);
}
use of org.openforis.collect.io.SurveyRestoreJob in project collect by openforis.
the class CollectMobileBackupConvertTask method execute.
@Override
protected void execute() throws Throwable {
// import survey into db file
CollectJobManager jobManager = (CollectJobManager) ctx.getBean("jobManager");
SurveyRestoreJob restoreJob = ctx.getBean(SurveyRestoreJob.class);
restoreJob.setFile(collectBackupFile);
restoreJob.setSurveyName(surveyName);
restoreJob.setUserGroup(userGroupManager.getDefaultPublicUserGroup());
restoreJob.setRestoreIntoPublishedSurvey(true);
restoreJob.setValidateSurvey(false);
jobManager.start(restoreJob, false);
incrementProcessedItems();
if (restoreJob.isCompleted()) {
createOutpuFile();
incrementProcessedItems();
} else {
changeStatus(Status.FAILED);
setErrorMessage(restoreJob.getErrorMessage());
setLastException(restoreJob.getLastException());
}
}
Aggregations