Search in sources :

Example 1 with CodeListBatchImportJob

use of org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob in project collect by openforis.

the class CodeListsVM method jobFailed.

@GlobalCommand
public void jobFailed(@BindingParam("job") Job job) {
    closeJobStatusPopUp();
    if (job instanceof CodeListBatchImportJob && job.getCurrentTask() != null) {
        CodeListImportTask lastTask = (CodeListImportTask) ((CodeListBatchImportJob) job).getCurrentTask();
        dataImportErrorPopUp = ReferenceDataImportErrorPopUpVM.showPopUp(lastTask.getErrors(), Labels.getLabel("survey.code_list.import_data.error_popup.title", new String[] { lastTask.getEntryName() }));
    } else {
        String errorMessageKey = job.getErrorMessage();
        String errorMessage = StringUtils.defaultIfBlank(Labels.getLabel(errorMessageKey), errorMessageKey);
        MessageUtil.showError("global.job_status.failed.message", errorMessage);
    }
    clearJob(job);
}
Also used : CodeListImportTask(org.openforis.collect.io.metadata.codelist.CodeListImportTask) CodeListBatchImportJob(org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 2 with CodeListBatchImportJob

use of org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob in project collect by openforis.

the class CodeListsVM method batchImportFileUploaded.

@Command
public void batchImportFileUploaded(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent event) {
    Media media = event.getMedia();
    String fileName = media.getName();
    String extension = FilenameUtils.getExtension(fileName);
    File tempFile = OpenForisIOUtils.copyToTempFile(media.getStreamData(), extension);
    batchImportJob = new CodeListBatchImportJob();
    batchImportJob.setJobManager(jobManager);
    batchImportJob.setCodeListManager(codeListManager);
    batchImportJob.setSurvey(survey);
    batchImportJob.setOverwriteData(true);
    batchImportJob.setFile(tempFile);
    jobManager.start(batchImportJob);
    jobStatusPopUp = JobStatusPopUpVM.openPopUp(Labels.getLabel("survey.code_list.batch_import"), batchImportJob, true);
}
Also used : CodeListBatchImportJob(org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob) Media(org.zkoss.util.media.Media) File(java.io.File) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

CodeListBatchImportJob (org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 File (java.io.File)1 CodeListImportTask (org.openforis.collect.io.metadata.codelist.CodeListImportTask)1 Command (org.zkoss.bind.annotation.Command)1 Media (org.zkoss.util.media.Media)1