Search in sources :

Example 1 with SurveyBackupInfoExtractorTask

use of org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask in project collect by openforis.

the class SurveyBackupInfoExtractorJob method initializeTask.

@Override
protected void initializeTask(Worker task) {
    if (task instanceof SurveyBackupVerifierTask) {
        SurveyBackupVerifierTask t = (SurveyBackupVerifierTask) task;
        t.setZipFile(zipFile);
    } else if (task instanceof SurveyBackupInfoExtractorTask) {
        File infoFile = backupFileExtractor.extractInfoFile();
        SurveyBackupInfoExtractorTask t = (SurveyBackupInfoExtractorTask) task;
        t.setFile(infoFile);
    } else if (task instanceof IdmlUnmarshallTask) {
        File idmlFile = zipFile == null ? file : backupFileExtractor.extractIdmlFile();
        IdmlUnmarshallTask t = (IdmlUnmarshallTask) task;
        t.setSurveyManager(surveyManager);
        t.setValidate(validate);
        t.setFile(idmlFile);
    }
}
Also used : SurveyBackupInfoExtractorTask(org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask) SurveyBackupVerifierTask(org.openforis.collect.io.internal.SurveyBackupVerifierTask) IdmlUnmarshallTask(org.openforis.collect.io.metadata.IdmlUnmarshallTask) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 2 with SurveyBackupInfoExtractorTask

use of org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask in project collect by openforis.

the class SurveyRestoreJob method onTaskCompleted.

@Override
protected void onTaskCompleted(Worker task) {
    super.onTaskCompleted(task);
    if (task instanceof SurveyBackupInfoExtractorTask) {
        SurveyBackupInfoExtractorTask t = (SurveyBackupInfoExtractorTask) task;
        this.backupInfo = t.getInfo();
    } else if (task instanceof IdmlUnmarshallTask) {
        CollectSurvey s = ((IdmlUnmarshallTask) task).getSurvey();
        s.setUserGroupId(userGroup.getId());
        this.surveyUri = s.getUri();
    } else if (task instanceof IdmlImportTask) {
        IdmlImportTask t = (IdmlImportTask) task;
        // get output survey and set it into job instance instance variable
        this.survey = t.getSurvey();
    } else if (task instanceof SamplingDesignImportTask) {
        saveSurvey();
    }
}
Also used : SurveyBackupInfoExtractorTask(org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask) SamplingDesignImportTask(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportTask) IdmlUnmarshallTask(org.openforis.collect.io.metadata.IdmlUnmarshallTask) CollectSurvey(org.openforis.collect.model.CollectSurvey) IdmlImportTask(org.openforis.collect.io.metadata.IdmlImportTask)

Example 3 with SurveyBackupInfoExtractorTask

use of org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask in project collect by openforis.

the class SurveyRestoreJob method initializeTask.

@Override
protected void initializeTask(Worker task) {
    if (task instanceof SurveyBackupInfoExtractorTask) {
        SurveyBackupInfoExtractorTask t = (SurveyBackupInfoExtractorTask) task;
        File infoFile = backupFileExtractor.extract(SurveyBackupJob.INFO_FILE_NAME);
        t.setFile(infoFile);
    } else if (task instanceof IdmlUnmarshallTask) {
        IdmlUnmarshallTask t = (IdmlUnmarshallTask) task;
        File idmlFile = backupFileExtractor.extractIdmlFile();
        t.setFile(idmlFile);
        t.setSurveyManager(surveyManager);
        t.setValidate(false);
    } else if (task instanceof IdmlImportTask) {
        IdmlImportTask t = (IdmlImportTask) task;
        t.setSurveyManager(surveyManager);
        File idmlFile = backupFileExtractor.extractIdmlFile();
        t.setFile(idmlFile);
        t.setSurveyUri(surveyUri);
        t.setSurveyName(surveyName);
        t.setImportInPublishedSurvey(restoreIntoPublishedSurvey);
        t.setValidate(false);
        t.setUserGroup(userGroup);
        t.setActiveUser(activeUser);
    } else if (task instanceof CodeListImagesImportTask) {
        CodeListImagesImportTask t = (CodeListImagesImportTask) task;
        t.setCodeListManager(codeListManager);
        t.setZipFile(zipFile);
        t.setSurvey(survey);
    } else if (task instanceof SamplingDesignCleanTask) {
        SamplingDesignCleanTask t = (SamplingDesignCleanTask) task;
        t.setSurveyId(survey.getId());
    } else if (task instanceof SamplingDesignImportTask) {
        SamplingDesignImportTask t = (SamplingDesignImportTask) task;
        File samplingDesignFile = backupFileExtractor.extract(SurveyBackupJob.SAMPLING_DESIGN_ENTRY_NAME);
        t.setSamplingDesignManager(samplingDesignManager);
        t.setFile(samplingDesignFile);
        t.setSkipValidation(true);
        t.setOverwriteAll(true);
        t.setSurvey(survey);
    } else if (task instanceof SpeciesBackupImportTask) {
        SpeciesBackupImportTask t = (SpeciesBackupImportTask) task;
        t.setSpeciesManager(speciesManager);
        t.setSurvey(survey);
    } else if (task instanceof SurveyFilesImportTask) {
        SurveyFilesImportTask t = (SurveyFilesImportTask) task;
        t.setSurvey(survey);
        t.setBackupFileExtractor(backupFileExtractor);
    } else if (task instanceof DataCleansingImportTask) {
        DataCleansingImportTask t = (DataCleansingImportTask) task;
        t.setSurvey(survey);
        t.setInputFile(backupFileExtractor.extract(SurveyBackupJob.DATA_CLEANSING_METADATA_ENTRY_NAME));
    }
    super.initializeTask(task);
}
Also used : SurveyBackupInfoExtractorTask(org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask) SpeciesBackupImportTask(org.openforis.collect.io.metadata.species.SpeciesBackupImportTask) SurveyFilesImportTask(org.openforis.collect.io.metadata.SurveyFilesImportTask) CodeListImagesImportTask(org.openforis.collect.io.metadata.CodeListImagesImportTask) SamplingDesignImportTask(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportTask) IdmlUnmarshallTask(org.openforis.collect.io.metadata.IdmlUnmarshallTask) ZipFile(java.util.zip.ZipFile) File(java.io.File) DataCleansingImportTask(org.openforis.collect.datacleansing.io.DataCleansingImportTask) IdmlImportTask(org.openforis.collect.io.metadata.IdmlImportTask)

Aggregations

SurveyBackupInfoExtractorTask (org.openforis.collect.io.internal.SurveyBackupInfoExtractorTask)3 IdmlUnmarshallTask (org.openforis.collect.io.metadata.IdmlUnmarshallTask)3 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 IdmlImportTask (org.openforis.collect.io.metadata.IdmlImportTask)2 SamplingDesignImportTask (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportTask)2 DataCleansingImportTask (org.openforis.collect.datacleansing.io.DataCleansingImportTask)1 SurveyBackupVerifierTask (org.openforis.collect.io.internal.SurveyBackupVerifierTask)1 CodeListImagesImportTask (org.openforis.collect.io.metadata.CodeListImagesImportTask)1 SurveyFilesImportTask (org.openforis.collect.io.metadata.SurveyFilesImportTask)1 SpeciesBackupImportTask (org.openforis.collect.io.metadata.species.SpeciesBackupImportTask)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1