Search in sources :

Example 1 with ExportRdf4jHelper

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

the class DownloadBean method thesoPDF.

public StreamedContent thesoPDF(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, String codeLang, String codeLang2, int type) {
    progress_per_100 = 0;
    progress_abs = 0;
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    sizeOfTheso = new ConceptHelper().getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.addThesaurus(idTheso, selectedLanguages);
    exportRdf4jHelper.addGroup(idTheso, selectedLanguages, selectedGroups);
    exportRdf4jHelper.addConcept(idTheso, this, selectedLanguages);
    WritePdf writePdf = new WritePdf(exportRdf4jHelper.getSkosXmlDocument(), codeLang, codeLang2, type);
    InputStream stream;
    stream = new ByteArrayInputStream(writePdf.getOutput().toByteArray());
    file = new DefaultStreamedContent(stream, "application/pdf", "test.pdf");
    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) WritePdf(mom.trd.opentheso.core.exports.pdf.WritePdf) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 2 with ExportRdf4jHelper

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

the class Rest method getJsonDatas.

// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// //////// Fonctions Privées     //////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
/**
 * Temporaire à refaire (Miled)
 */
/**
 * @param idConcept
 * @param idTheso
 * @return
 */
private String getJsonDatas(String value, String idLang, String idTheso) {
    ArrayList<String> listId = getListId(value, idLang, idTheso);
    NodePreference nodePreference1 = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference != null) {
        ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
        exportRdf4jHelper.setNodePreference(nodePreference1);
        exportRdf4jHelper.setInfos(ds, "dd-mm-yyyy", false, idTheso, nodePreference1.getCheminSite());
        exportRdf4jHelper.setNodePreference(nodePreference1);
        for (String idConcept : listId) {
            exportRdf4jHelper.addSignleConcept(idTheso, idConcept);
        }
        WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
        ByteArrayOutputStream out;
        out = new ByteArrayOutputStream();
        Rio.write(writeRdf4j.getModel(), out, RDFFormat.RDFJSON);
        // System.out.println(out.toString());
        return out.toString();
    }
    return messageEmptyJson();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 3 with ExportRdf4jHelper

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

the class DownloadBean method brancheToFile.

/**
 * Cette fonction permet de retourner une branche en SKOS
 *
 * @param idConcept
 * @param idTheso
 * @return
 */
public StreamedContent brancheToFile(String idConcept, String idTheso, int type) {
    RDFFormat format = null;
    String extention = "";
    switch(type) {
        case 0:
            format = RDFFormat.RDFXML;
            extention = "_skos.xml";
            break;
        case 1:
            format = RDFFormat.JSONLD;
            extention = "_json-ld.json";
            break;
        case 2:
            format = RDFFormat.TURTLE;
            extention = "_turtle.ttl";
            break;
    }
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.addBranch(idTheso, idConcept);
    WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, format);
    file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
    return file;
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayContent(org.primefaces.model.ByteArrayContent) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 4 with ExportRdf4jHelper

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

the class DownloadBean method loadExportHelper.

private WriteRdf4j loadExportHelper(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
    progress_per_100 = 0;
    progress_abs = 0;
    ConceptHelper conceptHelper = new ConceptHelper();
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    sizeOfTheso = conceptHelper.getConceptCountOfThesaurus(connect.getPoolConnexion(), idTheso);
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.addThesaurus(idTheso, selectedLanguages);
    exportRdf4jHelper.addGroup(idTheso, selectedLanguages, selectedGroups);
    exportRdf4jHelper.addConcept(idTheso, this, selectedLanguages);
    WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
    return writeRdf4j;
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 5 with ExportRdf4jHelper

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

the class DownloadBean method conceptToFile.

/**
 * Cette fonction permet d'exporter un concept en SKOS en temps réel dans la
 * page principale
 *
 * @param idConcept
 * @param idTheso
 * @param type
 * @return
 */
public StreamedContent conceptToFile(String idConcept, String idTheso, int type) {
    RDFFormat format = null;
    String extention = "";
    switch(type) {
        case 0:
            format = RDFFormat.RDFXML;
            extention = "_skos.xml";
            break;
        case 1:
            format = RDFFormat.JSONLD;
            extention = "_json-ld.json";
            break;
        case 2:
            format = RDFFormat.TURTLE;
            extention = "_turtle.ttl";
            break;
        case 3:
            format = RDFFormat.RDFJSON;
            extention = "_turtle.ttl";
            break;
    }
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.addSignleConcept(idTheso, idConcept);
    WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, format);
    file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
    return file;
// new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayContent(org.primefaces.model.ByteArrayContent) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Aggregations

PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)7 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)7 ExportRdf4jHelper (mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper)7 WriteRdf4j (mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)3 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 ByteArrayContent (org.primefaces.model.ByteArrayContent)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 WritePdf (mom.trd.opentheso.core.exports.pdf.WritePdf)1 Test (org.junit.Test)1 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)1