Search in sources :

Example 1 with SchemaSummaryCSVExportJob

use of org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob in project collect by openforis.

the class SurveyEditVM method jobCompleted.

@GlobalCommand
public void jobCompleted(@BindingParam("job") Job job) {
    closeJobStatusPopUp();
    if (job instanceof SchemaSummaryCSVExportJob) {
        File file = ((SchemaSummaryCSVExportJob) job).getOutputFile();
        String surveyName = survey.getName();
        String dateStr = Dates.formatLocalDateTime(new Date());
        String fileName = String.format(SCHEMA_SUMMARY_FILE_NAME_PATTERN, surveyName, dateStr, "csv");
        String contentType = URLConnection.guessContentTypeFromName(fileName);
        try {
            FileInputStream is = new FileInputStream(file);
            Filedownload.save(is, contentType, fileName);
        } catch (FileNotFoundException e) {
            log.error(e);
            MessageUtil.showError("survey.schema.export_summary.error", e.getMessage());
        }
    }
}
Also used : SchemaSummaryCSVExportJob(org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) Date(java.util.Date) FileInputStream(java.io.FileInputStream) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 2 with SchemaSummaryCSVExportJob

use of org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob in project collect by openforis.

the class SurveyEditVM method exportSchemaSummary.

@Command
public void exportSchemaSummary() {
    SchemaSummaryCSVExportJob job = new SchemaSummaryCSVExportJob();
    job.setJobManager(jobManager);
    job.setSurvey(survey);
    job.setLabelLanguage(currentLanguageCode);
    jobManager.start(job, survey.getId().toString());
    String statusPopUpTitle = Labels.getLabel("survey.schema.export_summary.process_status_popup.message", new String[] { survey.getName() });
    jobStatusPopUp = JobStatusPopUpVM.openPopUp(statusPopUpTitle, job, true);
}
Also used : SchemaSummaryCSVExportJob(org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

SchemaSummaryCSVExportJob (org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 Date (java.util.Date)1 Command (org.zkoss.bind.annotation.Command)1