Search in sources :

Example 1 with ExportTxtHelper

use of mom.trd.opentheso.core.exports.helper.ExportTxtHelper in project opentheso by miledrousset.

the class DownloadBean method thesoTxtCsv.

/**
 * Permet d'exporter le thésauurus au format txt (tabulé et hiérarchisé)
 * avec des options de colonnes supplémentaires NT, BT, RT, Notes, traductions
 * ceci figure dans le tableau (String[] selectedOptions)
 * @param idTheso
 * @param selectedGroups
 * @param codeLang
 * @param selectedOptions
 * @return
 * MR
 */
public StreamedContent thesoTxtCsv(String idTheso, List<NodeGroup> selectedGroups, String codeLang, ArrayList<String> selectedOptions) {
    progress_per_100 = 0;
    progress_abs = 0;
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    ExportTxtHelper exportTxtHelper = new ExportTxtHelper();
    exportTxtHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso, codeLang, selectedGroups, nodePreference, selectedOptions);
    exportTxtHelper.exportToTxtCsv();
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(exportTxtHelper.getTxtBuff().toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "text/csv", "Txt_" + idTheso + ".csv");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper) ExportTxtHelper(mom.trd.opentheso.core.exports.helper.ExportTxtHelper)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)1 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)1 ExportTxtHelper (mom.trd.opentheso.core.exports.helper.ExportTxtHelper)1 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)1