Search in sources :

Example 1 with SearchHelper

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

the class Rest method getListId.

/**
 * Fin Temporaire à refaire (Miled)
 */
private ArrayList<String> getListId(String value, String idLang, String idTheso) {
    ArrayList<String> listId = new ArrayList<>();
    ArrayList<NodeSearch> listRes = new SearchHelper().searchTerm(ds, value, idLang, idTheso, "", 1, false);
    for (NodeSearch listRe : listRes) {
        listId.add(listRe.getIdConcept());
    }
    return listId;
}
Also used : ArrayList(java.util.ArrayList) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper)

Example 2 with SearchHelper

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

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

the class SearchBean method researchDeconn.

/**
 * méthode pour la recherceh qui ne passe pas par l'arbre
 */
public void researchDeconn() {
    ConceptHelper ch = new ConceptHelper();
    SearchHelper sh = new SearchHelper();
    if (onlyNote) {
        result1 = new SearchHelper().searchNote(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain);
    } else {
        if (onlyNotation) {
            result1 = new SearchHelper().searchNotation(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup);
        } else {
            result1 = new SearchHelper().searchTerm(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain, withNote);
        }
    }
    nbRes = result1.size();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper)

Example 4 with SearchHelper

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

the class SearchBean method research.

public void research() {
    result1 = new ArrayList<>();
    result2 = new ArrayList<>();
    if (typeSearch == 1) {
        // ALPHABETIQUE/HIERARCHIQUE
        if (typeValueSearch == 0) {
            if (onlyNote) {
                result1 = new SearchHelper().searchNote(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain);
            } else {
                if (onlyNotation) {
                    result1 = new SearchHelper().searchNotation(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup);
                } else {
                    result1 = new SearchHelper().searchTerm(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain, withNote);
                }
            }
        } else if (typeValueSearch == 1) {
            // idC
            result1 = new SearchHelper().searchIdConcept(connect.getPoolConnexion(), entry, theso.getThesaurus().getId_thesaurus(), theso.getWorkLanguage());
        }
        nbRes = result1.size();
    } else if (typeSearch == 2) {
        // PERMUTEE
        if (typeValueSearch == 0) {
            // Terme
            if (idGroup == null || idGroup.equals("")) {
                result2 = new SearchHelper().getListPermute(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry);
            // result2.addAll(new SearchHelper().getListPermuteNonPreferredTerm(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry));
            } else {
                result2 = new SearchHelper().getListPermute(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry, idGroup);
            // result2.addAll(new SearchHelper().getListPermuteNonPreferredTerm(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry, idGroup));
            }
            nbRes = result2.size();
        } else if (typeValueSearch == 1) {
            // idC
            typeSearch = 1;
            result1 = new SearchHelper().searchIdConcept(connect.getPoolConnexion(), entry, theso.getThesaurus().getId_thesaurus());
            nbRes = result1.size();
        }
    }
    if (!langue.isEmpty()) {
        if (!langue.trim().equals(theso.getThesaurus().getLanguage())) {
            theso.getThesaurus().setLanguage(langue.trim());
            theso.update();
        }
    }
    for (NodeSearch ns : result1) {
        String temp;
        if (typeValueSearch == 1) {
            temp = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), ns.getIdGroup(), theso.getThesaurus().getId_thesaurus(), theso.getWorkLanguage());
        } else
            temp = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), ns.getIdGroup(), theso.getThesaurus().getId_thesaurus(), theso.getThesaurus().getLanguage());
        ns.setGroupLabel(temp);
    }
    theso.getVue().setOnglet(1);
}
Also used : NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 5 with SearchHelper

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

the class CompareCandidatConceptTest method compareCandidatPactols.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void compareCandidatPactols() {
    ConnexionTest connexionTest = new ConnexionTest();
    HikariDataSource conn = connexionTest.getConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    String idGroup = "6";
    SearchHelper searchHelper = new SearchHelper();
    ArrayList<String> nodeSearchTerm;
    HashMap<String, String> hashMapSyn;
    StringBuilder stringBuilder = new StringBuilder();
    // lecture du fichier tabulé /Users/Miled/
    // String path = "/Users/Miled/Desktop/candidatsPactols.csv";
    String path = "C:/Users/jm.prudham/Desktop/candidatsPactols.csv";
    String line;
    boolean first;
    // stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
    // new InputStreamReader(file));
    BufferedWriter bw = openFile("C:/Users/jm.prudham/Desktop/candidatsPactols_out.csv");
    if (bw == null)
        return;
    // int i=0;
    try {
        File file = new File(path);
        BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
        while ((line = bf.readLine()) != null) {
            /*    lineOrigine = line.split("\t");
                if(lineOrigine.length < 2) continue;
                
                lineTmp = removeStopWords(lineOrigine[1]);
                */
            nodeSearchTerm = searchHelper.simpleSearchPreferredTerm(conn, line.trim(), idLang, idTheso, idGroup);
            hashMapSyn = searchHelper.simpleSearchNonPreferredTerm(conn, line.trim(), idLang, idTheso, idGroup);
            stringBuilder.append(line.trim());
            // stringBuilder.append(" #### ");
            stringBuilder.append("\t");
            first = true;
            for (String term : nodeSearchTerm) {
                if (!first) {
                    stringBuilder.append("##");
                }
                stringBuilder.append(term);
                first = false;
            }
            stringBuilder.append("\t");
            first = true;
            for (Map.Entry<String, String> entry : hashMapSyn.entrySet()) {
                String key = entry.getKey();
                String value = entry.getValue();
                if (!first) {
                    stringBuilder.append("##");
                }
                stringBuilder.append("Alt: ");
                stringBuilder.append(value);
                stringBuilder.append("-> Pref: ");
                stringBuilder.append(key);
                first = false;
            }
            // System.out.println(stringBuilder.toString());
            bw.write(stringBuilder.toString());
            bw.newLine();
            stringBuilder.delete(0, stringBuilder.capacity());
        /*     i++;
                if(i==1000) {
                    closeFile(bw);
                    conn.close();
                    return;
                }*/
        }
    } catch (IOException ex) {
        Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    closeFile(bw);
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConnexionTest(connexion.ConnexionTest) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper) FileInputStream(java.io.FileInputStream) BufferedWriter(java.io.BufferedWriter) BufferedReader(java.io.BufferedReader) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) TestGetSiteMap(mom.trd.opentheso.bdd.helper.TestGetSiteMap)

Aggregations

SearchHelper (mom.trd.opentheso.bdd.helper.SearchHelper)5 NodeSearch (mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)3 HikariDataSource (com.zaxxer.hikari.HikariDataSource)2 ConnexionTest (connexion.ConnexionTest)2 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)1 TestGetSiteMap (mom.trd.opentheso.bdd.helper.TestGetSiteMap)1 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)1 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)1 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)1 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)1