Search in sources :

Example 1 with ConceptHelper

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

the class ExportRdf4jHelper method addFilsConceptRecursif.

private void addFilsConceptRecursif(String idThesaurus, String idPere, SKOSResource sKOSResource) {
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<String> listIdsOfConceptChildren = conceptHelper.getListChildrenOfConcept(ds, idPere, idThesaurus);
    writeConceptInfo(conceptHelper, sKOSResource, idThesaurus, idPere);
    for (String idOfConceptChildren : listIdsOfConceptChildren) {
        sKOSResource = new SKOSResource();
        // writeConceptInfo(conceptHelper, concept, idThesaurus, idOfConceptChildren, downloadBean, selectedLanguages);
        // if (conceptHelper.haveChildren(ds, idThesaurus, idOfConceptChildren)) {
        addFilsConceptRecursif(idThesaurus, idOfConceptChildren, sKOSResource);
    // }
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper)

Example 2 with ConceptHelper

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

the class ExportRdf4jHelper method addSignleConcept.

public void addSignleConcept(String idThesaurus, String idConcept) {
    idTheso = idThesaurus;
    ConceptHelper conceptHelper = new ConceptHelper();
    SKOSResource sKOSResource = new SKOSResource();
    NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, false);
    if (nodeConcept == null) {
        return;
    }
    // concept.setUri(getUriFromId(idConcept));
    sKOSResource.setUri(getUri(nodeConcept));
    sKOSResource.setProperty(SKOSProperty.Concept);
    // prefLabel
    for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
        sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
    }
    // altLabel
    for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
        sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
    }
    ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
    nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
    addNoteGiven(nodeNotes, sKOSResource);
    addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
    addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
    addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
    String notation = nodeConcept.getConcept().getNotation();
    String created = nodeConcept.getConcept().getCreated().toString();
    String modified = nodeConcept.getConcept().getModified().toString();
    if (notation != null && !notation.equals("null")) {
        sKOSResource.addNotation(notation);
    }
    if (created != null) {
        sKOSResource.addDate(created, SKOSProperty.created);
    }
    if (modified != null) {
        sKOSResource.addDate(modified, SKOSProperty.modified);
    }
    sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
    sKOSResource.addIdentifier(idConcept, SKOSProperty.identifier);
    skosXmlDocument.addconcept(sKOSResource);
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 3 with ConceptHelper

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

the class CompareConceptTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    ConnexionTest connexionTest = new ConnexionTest();
    HikariDataSource conn = connexionTest.getConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    String idGroup = "6";
    ConceptHelper conceptHelper = new ConceptHelper();
    StringPlus stringPlus = new StringPlus();
    NodeConcept nodeConcept;
    SearchHelper searchHelper = new SearchHelper();
    ArrayList<NodeSearch> nodeSearchs;
    StringBuilder stringBuilder = new StringBuilder();
    // lecture du fichier tabulé /Users/Miled/
    String path = "/Users/Miled/Desktop/inist.csv";
    FileInputStream file = readFile(path);
    if (file == null)
        return;
    String line;
    String lineTmp;
    String[] lineOrigine;
    boolean first = true;
    stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
    BufferedReader bf = new BufferedReader(new InputStreamReader(file));
    try {
        while ((line = bf.readLine()) != null) {
            lineOrigine = line.split("\t");
            if (lineOrigine.length < 2)
                continue;
            lineTmp = removeStopWords(lineOrigine[1]);
            nodeSearchs = searchHelper.searchTerm(conn, lineTmp, idLang, idTheso, idGroup, 2, false);
            stringBuilder.append(lineOrigine[0]);
            stringBuilder.append("\t");
            stringBuilder.append(lineOrigine[1]);
            // stringBuilder.append(" #### ");
            stringBuilder.append("\t");
            first = true;
            for (NodeSearch nodeSearch : nodeSearchs) {
                if (!first) {
                    // stringBuilder.append(" $$$$ ");
                    stringBuilder.append("\n");
                    stringBuilder.append("\t");
                    stringBuilder.append("\t");
                }
                stringBuilder.append(nodeSearch.getLexical_value());
                stringBuilder.append("\t");
                stringBuilder.append(nodeSearch.getIdConcept());
                // récupération des données d'un Concept
                nodeConcept = conceptHelper.getConcept(conn, nodeSearch.getIdConcept(), idTheso, idLang);
                // URL
                stringBuilder.append("\t");
                if (nodeConcept.getConcept().getIdArk() != null || !nodeConcept.getConcept().getIdArk().isEmpty()) {
                    stringBuilder.append("http://ark.frantiq.fr/ark:/");
                    stringBuilder.append(nodeConcept.getConcept().getIdArk());
                }
                // définition
                stringBuilder.append("\t");
                for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                    if (nodeNote.getNotetypecode().equalsIgnoreCase("definition"))
                        stringBuilder.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                }
                // BT
                stringBuilder.append("\t");
                for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                    stringBuilder.append(nodeBT.getTitle());
                }
                // UF
                stringBuilder.append("\t");
                for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
                    stringBuilder.append(nodeEM.getLexical_value());
                }
                first = false;
            }
            System.out.println(stringBuilder.toString());
            stringBuilder.delete(0, stringBuilder.capacity());
        }
    } catch (IOException ex) {
        Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    // ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    // StringBuilder file = new StringBuilder();
    /*  ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurusByGroup(conn, idTheso, idGroup);
        
        
        for (String idConcept : allIds) {

            nodeConcept = conceptHelper.getConcept(conn, idConcept, idTheso, idLang);
            System.out.println("idConcept = " + idConcept + "  " + nodeConcept.getTerm().getLexical_value());
            
        }*/
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConnexionTest(connexion.ConnexionTest) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) InputStreamReader(java.io.InputStreamReader) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) IOException(java.io.IOException) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper) FileInputStream(java.io.FileInputStream) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) BufferedReader(java.io.BufferedReader) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 4 with ConceptHelper

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

the class TreeChange method getPathFromSelectedConcept.

public ArrayList<String> getPathFromSelectedConcept(Connexion conn, MyTreeNode selectedNode) {
    String id = selectedNode.getIdConcept();
    String theso = selectedNode.getIdTheso();
    GroupHelper gh = new GroupHelper();
    ArrayList<NodeGroup> groups = gh.getListGroupOfConcept(conn.getPoolConnexion(), theso, id, selectedNode.getLangue());
    ConceptHelper ch = new ConceptHelper();
    ArrayList<String> result = new ArrayList<>();
    ArrayList<String> bt = new ArrayList<>();
    ArrayList<String> groupIds = new ArrayList<>();
    for (NodeGroup ng : groups) {
        groupIds.add(ng.getConceptGroup().getIdgroup());
        bt.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), id, ng.getConceptGroup().getIdgroup(), theso));
    }
    result.addAll(bt);
    while (!bt.isEmpty()) {
        ArrayList<String> tmp = new ArrayList<>();
        for (String idBt : bt) {
            for (String idGroup : groupIds) {
                tmp.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), idBt, idGroup, theso));
            }
        }
        bt = new ArrayList<>(tmp);
        result.addAll(bt);
    }
    for (String idGroup : groupIds) {
        String fat = gh.getIdFather(conn.getPoolConnexion(), idGroup, theso);
        result.add(fat);
        while (fat != null && !fat.isEmpty()) {
            fat = gh.getIdFather(conn.getPoolConnexion(), fat, theso);
            result.add(fat);
        }
    }
    result.addAll(groupIds);
    return result;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 5 with ConceptHelper

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

Aggregations

ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)186 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)47 SQLException (java.sql.SQLException)44 FacesMessage (javax.faces.application.FacesMessage)42 Connection (java.sql.Connection)36 ArrayList (java.util.ArrayList)29 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)29 Concept (mom.trd.opentheso.bdd.datas.Concept)25 Term (mom.trd.opentheso.bdd.datas.Term)25 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)24 PrefixString (com.k_int.IR.QueryModels.PrefixString)20 HikariDataSource (com.zaxxer.hikari.HikariDataSource)19 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)17 JsonString (javax.json.JsonString)16 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)16 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)16 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)15 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)15 ConnexionTest (connexion.ConnexionTest)14 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)13