Search in sources :

Example 11 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD 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 12 with ExportFromBDD

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

the class Soap method conceptToSkos.

/**
 * Web service operation
 * @param idConcept
 * @param idThesaurus
 * @return
 */
@WebMethod(operationName = "conceptToSkos")
public String conceptToSkos(@WebParam(name = "idConcept") String idConcept, @WebParam(name = "idThesaurus") String idThesaurus) {
    if (ds == null)
        return null;
    if (prefs == null)
        return null;
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(prefs.getProperty("serverArk"));
    exportFromBDD.setServerAdress(prefs.getProperty("cheminSite"));
    String skos = exportFromBDD.exportConcept(ds, idThesaurus, idConcept).toString();
    return skos;
}
Also used : ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) WebMethod(javax.jws.WebMethod)

Example 13 with ExportFromBDD

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

the class TestRestService method testGetInvertPathConcept.

/**
 *  permet de retourner les concepts d'une branche à l'envers(en partant du concept jusqu'au concept TT)
 */
@org.junit.Test
public void testGetInvertPathConcept() {
    ArrayList<String> path = new ArrayList<>();
    ArrayList<ArrayList<String>> tabId = new ArrayList<>();
    String idTheso = "TH_1";
    String idConcept = "150082";
    HikariDataSource conn = openConnexionPool();
    ConceptHelper conceptHelper = new ConceptHelper();
    path.add(idConcept);
    tabId = conceptHelper.getPathOfConceptWithoutGroup(conn, idConcept, idTheso, path, tabId);
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk("http://ark.frantiq.fr/ark:/");
    exportFromBDD.setServerAdress("http://pactols.frantiq.fr/");
    StringBuffer skos = exportFromBDD.exportConceptByLot(conn, idTheso, tabId);
    if (skos == null)
        System.out.println("");
    else
        System.err.println(skos.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ArrayList(java.util.ArrayList) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD)

Example 14 with ExportFromBDD

use of mom.trd.opentheso.core.exports.old.ExportFromBDD 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 15 with ExportFromBDD

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

the class SelectedThesaurus method getMetaData.

/**
 * ************************************ GETTERS SETTERS
 * *************************************
 */
/**
 * @return
 */
public String getMetaData() {
    if (this.tree.getSelectedTerme() != null) {
        if (this.tree.getSelectedTerme().getIdC() != null) {
            if (this.tree.getSelectedTerme().getIdTheso() != null) {
                // cas d'un domaine ou  Groupe
                if (tree.getSelectedTerme().getType() == 1) {
                    ExportFromBDD exportFromBDD = new ExportFromBDD();
                    exportFromBDD.setNodePreference(nodePreference);
                    exportFromBDD.setServerArk(serverArk);
                    exportFromBDD.setServerAdress(cheminSite);
                    StringBuffer skos = exportFromBDD.exportThisGroup(connect.getPoolConnexion(), this.tree.getSelectedTerme().getIdTheso(), this.tree.getSelectedTerme().getIdC());
                    JsonHelper jsonHelper = new JsonHelper();
                    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
                    StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrg(sKOSXmlDocument);
                    if (jsonLd != null) {
                        return jsonLd.toString();
                    } else {
                        return "";
                    }
                }
                // cas d'un concept
                if (tree.getSelectedTerme().getType() == 2 || tree.getSelectedTerme().getType() == 3) {
                    ExportFromBDD exportFromBDD = new ExportFromBDD();
                    exportFromBDD.setNodePreference(nodePreference);
                    exportFromBDD.setServerArk(serverArk);
                    exportFromBDD.setServerAdress(cheminSite);
                    StringBuffer skos = exportFromBDD.exportConcept(connect.getPoolConnexion(), this.tree.getSelectedTerme().getIdTheso(), this.tree.getSelectedTerme().getIdC());
                    if (skos == null) {
                        return "";
                    }
                    JsonHelper jsonHelper = new JsonHelper();
                    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
                    if (sKOSXmlDocument == null) {
                        return "";
                    }
                    StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrg(sKOSXmlDocument);
                    if (jsonLd != null) {
                        return jsonLd.toString();
                    } else {
                        return "";
                    }
                }
            }
        }
    }
    // Envoye les domaines (MT)
    if (thesaurus != null && thesaurus.getId_thesaurus() != null) {
        if (!thesaurus.getId_thesaurus().trim().isEmpty()) {
            ExportFromBDD exportFromBDD = new ExportFromBDD();
            exportFromBDD.setNodePreference(nodePreference);
            exportFromBDD.setServerArk(serverArk);
            exportFromBDD.setServerAdress(cheminSite);
            StringBuffer skos = exportFromBDD.exportGroupsOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus());
            JsonHelper jsonHelper = new JsonHelper();
            SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
            StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrgForConceptScheme(sKOSXmlDocument);
            if (jsonLd == null) {
                return "";
            }
            return jsonLd.toString();
        }
    }
    return "";
// ancienne version
/*        if(this.tree.getSelectedTerme() != null ) {
            if(this.tree.getSelectedTerme().getIdC() != null ) {
                if(this.tree.getSelectedTerme().getIdTheso() != null ) {
                    // cas d'un domaine ou  Groupe
                    if(tree.getSelectedTerme().getType() == 1) {
                        ExportFromBDD exportFromBDD = new ExportFromBDD();
                        exportFromBDD.setServerArk(serverArk);
                        exportFromBDD.setServerAdress(cheminSite);
                        StringBuffer skos = exportFromBDD.exportThisGroup(
                                connect.getPoolConnexion(), 
                                this.tree.getSelectedTerme().getIdTheso(),
                                this.tree.getSelectedTerme().getIdC());

                    JsonHelper jsonHelper = new JsonHelper();
                    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
                    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
                    return jsonLd.toString();
                }
                // cas d'un concept
                if(tree.getSelectedTerme().getType() == 2 || tree.getSelectedTerme().getType() == 3) {
                    ExportFromBDD exportFromBDD = new ExportFromBDD();
                    exportFromBDD.setServerArk(serverArk);
                    exportFromBDD.setServerAdress(cheminSite);
                    StringBuffer skos = exportFromBDD.exportConcept(
                            connect.getPoolConnexion(), 
                            this.tree.getSelectedTerme().getIdTheso(),
                            this.tree.getSelectedTerme().getIdC());

                        JsonHelper jsonHelper = new JsonHelper();
                        SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
                        StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
                        return jsonLd.toString();
                    }
                }
            }
        }
        
        // Envoye les domaines (MT)
        if(thesaurus.getId_thesaurus() != null) {
            if(!thesaurus.getId_thesaurus().trim().isEmpty()) {
                ExportFromBDD exportFromBDD = new ExportFromBDD();
                exportFromBDD.setServerArk(serverArk);
                exportFromBDD.setServerAdress(cheminSite);
                StringBuffer skos = exportFromBDD.exportGroupsOfThesaurus(
                        connect.getPoolConnexion(), 
                        thesaurus.getId_thesaurus());

                JsonHelper jsonHelper = new JsonHelper();
                SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
                StringBuffer jsonLd = jsonHelper.getJsonLdForConceptScheme(sKOSXmlDocument);
                if(jsonLd == null) return "";
                return jsonLd.toString();
            }
        }
        return ""; */
}
Also used : JsonHelper(mom.trd.opentheso.core.jsonld.helper.JsonHelper) SKOSXmlDocument(skos.SKOSXmlDocument) 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