Search in sources :

Example 11 with PreferencesHelper

use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.

the class Rest method conceptToSkosFromArk.

/**
 * Fonction qui permet de récupérer un concept skos par identifiant ark
 *
 * @param idConcept
 * @param idThesaurus
 * @return skos
 */
private StringBuffer conceptToSkosFromArk(String arkId, String idTheso) {
    if (ds == null) {
        return null;
    }
    nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference == null) {
        return null;
    }
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setNodePreference(nodePreference);
    exportFromBDD.setServerArk(nodePreference.getServeurArk());
    exportFromBDD.setServerAdress(nodePreference.getCheminSite());
    StringBuffer skos = exportFromBDD.exportConcept(ds, arkId);
    if (skos == null) {
        return new StringBuffer("");
    }
    return skos;
}
Also used : ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 12 with PreferencesHelper

use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.

the class Rest method conceptsOfGroupToSkos.

/**
 * Fonction qui permet de récupérer un concept skos par identifiant
 *
 * @param idGroup
 * @param idThesaurus
 * @return skos
 */
private StringBuffer conceptsOfGroupToSkos(String idGroup, String idTheso) {
    if (ds == null) {
        return null;
    }
    nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference == null) {
        return null;
    }
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(nodePreference.getServeurArk());
    exportFromBDD.setServerAdress(nodePreference.getCheminSite());
    exportFromBDD.setNodePreference(nodePreference);
    StringBuffer skos = exportFromBDD.exportGroup(ds, idTheso, idGroup);
    return skos;
}
Also used : ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 13 with PreferencesHelper

use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.

the class Rest method brancheOfConceptsToSkosFromDate.

/**
 * Fonction qui permet de récupérer les concepts à partir d'une date donnée
 * (modifiés ou crées)
 *
 * @param idConcept
 * @param idThesaurus
 * @return skos
 */
private StringBuffer brancheOfConceptsToSkosFromDate(String idTheso, String date) {
    if (ds == null) {
        return null;
    }
    nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference == null) {
        return null;
    }
    ArrayList<String> tabId;
    ArrayList<ArrayList<String>> multiTabId = new ArrayList<>();
    ConceptHelper conceptHelper = new ConceptHelper();
    tabId = conceptHelper.getConceptsDelta(ds, idTheso, date);
    if (tabId == null) {
        ds.close();
        return null;
    }
    if (tabId.isEmpty()) {
        ds.close();
        return new StringBuffer("");
    }
    multiTabId.add(tabId);
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(nodePreference.getServeurArk());
    exportFromBDD.setServerAdress(nodePreference.getCheminSite());
    exportFromBDD.setNodePreference(nodePreference);
    StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, multiTabId);
    return skos;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 14 with PreferencesHelper

use of mom.trd.opentheso.bdd.helper.PreferencesHelper 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 15 with PreferencesHelper

use of mom.trd.opentheso.bdd.helper.PreferencesHelper 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)

Aggregations

PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)20 ExportFromBDD (mom.trd.opentheso.core.exports.old.ExportFromBDD)9 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)8 ExportRdf4jHelper (mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper)7 WriteRdf4j (mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)4 RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 ByteArrayContent (org.primefaces.model.ByteArrayContent)2 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 FacesMessage (javax.faces.application.FacesMessage)1 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)1