Search in sources :

Example 1 with ExportTabulateHelper

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

the class DownloadBean method thesoCsv2.

/**
 * Cette fonction permet d'exporter un thésaurus au format CSV à partir de
 * son identifiant.
 * Il est filtré par Langue et par Groupe
 * Le résultat est enregistré dans la variable 'skos' du
 * downloadBean si la taille est petite, ou dans la variable 'file' du
 * downloadBean sinon. Dans le premier cas on affiche la variable, dans le
 * second cas l'utilisateur télécharge de fichier.
 *
 * @param idTheso
 * @param selectedLanguages
 * @param selectedGroups
 * @return
 */
public StreamedContent thesoCsv2(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
    progress_per_100 = 0;
    progress_abs = 0;
    ConceptHelper conceptHelper = new ConceptHelper();
    sizeOfTheso = conceptHelper.getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
    ExportTabulateHelper exportTabulateHelper = new ExportTabulateHelper();
    exportTabulateHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso, selectedLanguages, selectedGroups);
    exportTabulateHelper.exportToTabulate();
    StringBuffer temp = exportTabulateHelper.getTabulateBuff();
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "text/csv", "downloadedCsv.csv");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ExportTabulateHelper(mom.trd.opentheso.core.exports.helper.ExportTabulateHelper) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with ExportTabulateHelper

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

the class DownloadBean method thesoCsv.

/**
 * Cette fonction permet d'exporter un thésaurus au format CSV à partir de
 * son identifiant. Le résultat est enregistré dans la variable 'skos' du
 * downloadBean si la taille est petite, ou dans la variable 'file' du
 * downloadBean sinon. Dans le premier cas on affiche la variable, dans le
 * second cas l'utilisateur télécharge de fichier.
 *
 * @param idTheso
 * @return
 */
public StreamedContent thesoCsv(String idTheso) {
    progress_per_100 = 0;
    progress_abs = 0;
    ConceptHelper conceptHelper = new ConceptHelper();
    sizeOfTheso = conceptHelper.getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
    ExportTabulateHelper exportTabulateHelper = new ExportTabulateHelper();
    exportTabulateHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso);
    exportTabulateHelper.exportToTabulate();
    StringBuffer temp = exportTabulateHelper.getTabulateBuff();
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "text/csv", "downloadedCsv.csv");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ExportTabulateHelper(mom.trd.opentheso.core.exports.helper.ExportTabulateHelper) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with ExportTabulateHelper

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

the class TestExportTabulate method testExportAllDatas.

/**
 * Test of Tabulate reading.
 */
@org.junit.Test
public void testExportAllDatas() {
    HikariDataSource conn = openConnexionPool();
    ExportTabulateHelper exportTabulateHelper = new ExportTabulateHelper();
    // exportTabulateHelper.setThesaurusDatas(conn, "TH_1");
    // exportTabulateHelper.exportToTabulate();
    StringBuffer datas = exportTabulateHelper.getTabulateBuff();
    System.out.println(datas.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ExportTabulateHelper(mom.trd.opentheso.core.exports.helper.ExportTabulateHelper)

Aggregations

ExportTabulateHelper (mom.trd.opentheso.core.exports.helper.ExportTabulateHelper)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1