Search in sources :

Example 1 with CodeListExportProcess

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";
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) ServletOutputStream(javax.servlet.ServletOutputStream) CodeListExportProcess(org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 2 with CodeListExportProcess

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);
}
Also used : CodeListExportProcess(org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess) FileOutputStream(java.io.FileOutputStream) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

CodeListExportProcess (org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 CodeList (org.openforis.idm.metamodel.CodeList)1 Command (org.zkoss.bind.annotation.Command)1 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)1