Search in sources :

Example 21 with DefaultStreamedContent

use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.

the class DownloadBean method branchGroupSkos.

/*    public void branchSkos(String idC, String idTheso) {
        ExportFromBDD exportFromBDD = new ExportFromBDD();
        exportFromBDD.setServerAdress(serverAdress);
        exportFromBDD.setServerArk(serverArk);
        exportFromBDD.setArkActive(arkActive);

        StringBuffer temp = exportFromBDD.exportBranchOfConcept(connect.getPoolConnexion(), idTheso, idC);
        if (temp.length() <= 1500000) {
            //    if(temp.length() <= 150) {
            skos = temp.toString();
            vue.setBranchToSkos(true);
        } else {
            InputStream stream;
            try {
                stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
                file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
            } catch (UnsupportedEncodingException ex) {
                Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
            }
            vue.setBranchToSkosFile(true);
        }
    }*/
public void branchGroupSkos(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    StringBuffer temp = exportFromBDD.exportGroup(connect.getPoolConnexion(), idTheso, idGroup);
    if (temp.length() <= 1500000) {
        skos = temp.toString();
        vue.setBranchToSkos(true);
    } else {
        InputStream stream;
        try {
            stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
            file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        vue.setBranchToSkosFile(true);
    }
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)21 InputStream (java.io.InputStream)21 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)21 UnsupportedEncodingException (java.io.UnsupportedEncodingException)19 ExportFromBDD (mom.trd.opentheso.core.exports.old.ExportFromBDD)11 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)4 JsonHelper (mom.trd.opentheso.core.jsonld.helper.JsonHelper)4 SKOSXmlDocument (skos.SKOSXmlDocument)4 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)2 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)2 ExportStatistiques (mom.trd.opentheso.core.exports.helper.ExportStatistiques)2 ExportTabulateHelper (mom.trd.opentheso.core.exports.helper.ExportTabulateHelper)2 Document (com.itextpdf.text.Document)1 Paragraph (com.itextpdf.text.Paragraph)1 PdfWriter (com.itextpdf.text.pdf.PdfWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 FacesMessage (javax.faces.application.FacesMessage)1