Search in sources :

Example 1 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD in project opentheso by miledrousset.

the class DownloadBean method conceptSkos.

public String conceptSkos(String idC, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    return exportFromBDD.exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
// new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
}
Also used : ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Example 2 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD in project opentheso by miledrousset.

the class DownloadBean method thesoSkos.

/**
 * Cette fonction permet d'exporter un thésaurus au format SKOS à 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 thesoSkos(String idTheso) {
    /**
     * Cette initialisation est pour exporter les PACTOLS au format accepté
     * par Koha
     */
    // ExportFromBDD_Frantiq exportFromBDD = new ExportFromBDD_Frantiq();
    /**
     * ici c'est la classe à utiliser pour un export standard au foramt SKOS
     */
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    StringBuffer skos_local = exportFromBDD.exportThesaurus(connect.getPoolConnexion(), idTheso);
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml", idTheso + "_skos.xml");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    vue.setThesoToSkosCsvFile(true);
    return file;
/*        if (temp.length() <= 1500000) {
            skos = temp.toString();
            vue.setThesoToSkosCsv(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.setThesoToSkosCsvFile(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)

Example 3 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD in project opentheso by miledrousset.

the class DownloadBean method brancheToJsonLd.

/**
 * Cette fonction permet de retourner une branche en JsonLd
 *
 * @param idConcept
 * @param idTheso
 * @return
 */
public StreamedContent brancheToJsonLd(String idConcept, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    StringBuffer skos_local = exportFromBDD.exportBranchOfConcept(connect.getPoolConnexion(), idTheso, idConcept);
    JsonHelper jsonHelper = new JsonHelper();
    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(jsonLd.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml", idConcept + "_Branch_jsonld.xml");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : JsonHelper(mom.trd.opentheso.core.jsonld.helper.JsonHelper) DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SKOSXmlDocument(skos.SKOSXmlDocument) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Example 4 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD in project opentheso by miledrousset.

the class DownloadBean method thisGroupToSkos.

/**
 * Cette fonction permet de retourner pour téléchargement un groupe en SKOS
 *
 * @param idGroup
 * @param idTheso
 * @return
 */
public StreamedContent thisGroupToSkos(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    StringBuffer skos_local = exportFromBDD.exportThisGroup(connect.getPoolConnexion(), idTheso, idGroup);
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml", idGroup + "_Group_skos.xml");
    } 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) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Example 5 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD in project opentheso by miledrousset.

the class DownloadBean method thesoToSkosAdvanced.

/**
 * Cette fonction permet d'exporter un thésaurus en SKOS en précisant les
 * langues et les domaines à exporter
 *
 * @param idTheso
 * @param selectedLanguages
 * @param selectedGroups
 * @return
 */
public StreamedContent thesoToSkosAdvanced(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();
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);
    StringBuffer skos_local = exportFromBDD.exportThesaurusAdvanced(connect.getPoolConnexion(), idTheso, selectedLanguages, selectedGroups, this);
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml", idTheso + "_skos.rdf");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    progress_per_100 = 0;
    progress_abs = 0;
    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) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Aggregations

ExportFromBDD (mom.trd.opentheso.core.exports.old.ExportFromBDD)27 ByteArrayInputStream (java.io.ByteArrayInputStream)11 InputStream (java.io.InputStream)11 UnsupportedEncodingException (java.io.UnsupportedEncodingException)11 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)11 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)9 JsonHelper (mom.trd.opentheso.core.jsonld.helper.JsonHelper)6 SKOSXmlDocument (skos.SKOSXmlDocument)6 ArrayList (java.util.ArrayList)3 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)3 WebMethod (javax.jws.WebMethod)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 FacesMessage (javax.faces.application.FacesMessage)1