Search in sources :

Example 1 with SurveyRestoreJob

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);
}
Also used : SurveyRestoreJob(org.openforis.collect.io.SurveyRestoreJob) Input(org.openforis.collect.io.data.RecordProviderInitializerTask.Input) IdmlUnmarshallTask(org.openforis.collect.io.metadata.IdmlUnmarshallTask) File(java.io.File)

Example 2 with SurveyRestoreJob

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());
    }
}
Also used : SurveyRestoreJob(org.openforis.collect.io.SurveyRestoreJob) CollectJobManager(org.openforis.collect.concurrency.CollectJobManager)

Aggregations

SurveyRestoreJob (org.openforis.collect.io.SurveyRestoreJob)2 File (java.io.File)1 CollectJobManager (org.openforis.collect.concurrency.CollectJobManager)1 Input (org.openforis.collect.io.data.RecordProviderInitializerTask.Input)1 IdmlUnmarshallTask (org.openforis.collect.io.metadata.IdmlUnmarshallTask)1