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());
}
}
}
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);
}
Aggregations