use of org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess in project collect by openforis.
the class CodeListController method exportCodeList.
protected String exportCodeList(HttpServletResponse response, int surveyId, int codeListId) throws IOException {
CollectSurvey survey = surveyManager.getOrLoadSurveyById(surveyId);
CodeList list = survey.getCodeListById(codeListId);
String fileName = list.getName() + CSV_EXTENSION;
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setContentType(CSV_CONTENT_TYPE);
ServletOutputStream out = response.getOutputStream();
CodeListExportProcess process = new CodeListExportProcess(codeListManager);
process.exportToCSV(out, survey, codeListId);
return "ok";
}
use of org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess in project collect by openforis.
the class CodeListsVM method exportCodeList.
@Command
public void exportCodeList() throws IOException {
CollectSurvey survey = getSurvey();
CodeListExportProcess codeListExportProcess = new CodeListExportProcess(codeListManager);
File tempFile = File.createTempFile("code_list_" + editedItem.getName(), ".csv");
FileOutputStream os = new FileOutputStream(tempFile);
codeListExportProcess.exportToCSV(os, survey, editedItem.getId());
Filedownload.save(tempFile, CSV_CONTENT_TYPE);
}
Aggregations