Search in sources :

Example 6 with Languages_iso639

use of mom.trd.opentheso.bdd.datas.Languages_iso639 in project opentheso by miledrousset.

the class LanguageHelper method getSelectItemLanguages.

/**
 * Permet de remplir un tableau de SelectItem avec l'intégralité des langues
 * ayant un id_1 non null
 *
 * @param ds le pool de connexion
 * @return  le tableau de SelectItem plein
 */
public SelectItem[] getSelectItemLanguages(HikariDataSource ds) {
    SelectItem[] langues;
    ArrayList<Languages_iso639> arrayLangue1 = (getAllLanguages(ds));
    ArrayList<Languages_iso639> arrayLangue2 = new ArrayList<>();
    for (Languages_iso639 l : arrayLangue1) {
        if (l.getId_iso639_1() != null) {
            arrayLangue2.add(l);
        }
    }
    langues = new SelectItem[arrayLangue2.size()];
    int i = 0;
    for (Languages_iso639 l : arrayLangue2) {
        langues[i] = new SelectItem(l.getId_iso639_1(), l.getFrench_name() + " (" + l.getId_iso639_1().trim() + ")");
        i++;
    }
    return langues;
}
Also used : SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 7 with Languages_iso639

use of mom.trd.opentheso.bdd.datas.Languages_iso639 in project opentheso by miledrousset.

the class LanguageHelper method getLanguagesOfThesaurus.

/**
 * Permet de retourner un ArrayList d'objets Language_iso639
 * c'est la liste des langues utilisées par un thésaurus / ou null si rien
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @return Objet Class Thesaurus
 */
public ArrayList<Languages_iso639> getLanguagesOfThesaurus(HikariDataSource ds, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<Languages_iso639> language = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query1 = "select distinct languages_iso639.iso639_1," + " languages_iso639.iso639_2, languages_iso639.english_name," + " languages_iso639.french_name" + " from languages_iso639, thesaurus_label where thesaurus_label.lang = languages_iso639.iso639_1 " + " and thesaurus_label.id_thesaurus ='" + idThesaurus + "';";
                stmt.executeQuery(query1);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    language = new ArrayList<>();
                    while (resultSet.next()) {
                        Languages_iso639 languageTmp = new Languages_iso639();
                        languageTmp.setId_iso639_1(resultSet.getString("iso639_1").trim());
                        languageTmp.setId_iso639_2(resultSet.getString("iso639_2").trim());
                        languageTmp.setFrench_name(resultSet.getString("french_name"));
                        languageTmp.setEnglish_name(resultSet.getString("english_name"));
                        language.add(languageTmp);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting languages of thésaurus : " + idThesaurus, sqle);
    }
    return language;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 8 with Languages_iso639

use of mom.trd.opentheso.bdd.datas.Languages_iso639 in project opentheso by miledrousset.

the class SelectedThesaurus method preRenderView.

/**
 * récupère la variable URL et affiche le terme qu'elle désigne
 */
public void preRenderView() {
    // if the URL is for Concept
    if (idCurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type;
        Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
        if (c.isTopConcept()) {
            type = 2;
        } else {
            type = 3;
        }
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idCurl, idTurl, idLurl, c.getIdGroup(), "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is for Groups
    if (idGurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type = 1;
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is only for thésaurus
    if (idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        /*   if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
                idCurl = null;
                idGurl = null;
                idTurl = null;
                return;
            }*/
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        // MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null);
        // tree.getSelectedTerme().majTerme(mTN);
        // tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
    }
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 9 with Languages_iso639

use of mom.trd.opentheso.bdd.datas.Languages_iso639 in project opentheso by miledrousset.

the class SelectedThesaurus method getTradForSearch.

/**
 * Récupération des traductions du thésaurus
 *
 * @return une liste des traductions
 */
public ArrayList<Languages_iso639> getTradForSearch() {
    thesaurus.getLanguage();
    ArrayList<Languages_iso639> languages_iso639s = new ArrayList<>();
    ArrayList<Languages_iso639> languages_iso639s_temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus());
    // on replace la langue sélectionnée en premier
    for (Languages_iso639 languages_iso639 : languages_iso639s_temp) {
        if (languages_iso639.getId_iso639_1().equalsIgnoreCase(thesaurus.getLanguage())) {
            languages_iso639s.add(0, languages_iso639);
        } else {
            languages_iso639s.add(languages_iso639);
        }
    }
    Languages_iso639 languages_iso639_all = new Languages_iso639();
    languages_iso639_all.setFrench_name("");
    languages_iso639_all.setEnglish_name("");
    languages_iso639_all.setId_iso639_1("");
    languages_iso639_all.setId_iso639_1("");
    languages_iso639s.add(languages_iso639_all);
    return languages_iso639s;
// return (new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus()));
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ArrayList(java.util.ArrayList) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 10 with Languages_iso639

use of mom.trd.opentheso.bdd.datas.Languages_iso639 in project opentheso by miledrousset.

the class BackgroundTimeJob method synchroSparql.

private Runnable synchroSparql(int key) {
    SynchroSparql run = new SynchroSparql();
    run.setSparqlStruct(this.SparqlSyn.get(key));
    ArrayList<Languages_iso639> listeLang = new LanguageHelper().getLanguagesOfThesaurus(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeLang> nol = new ArrayList<>();
    for (Languages_iso639 lang : listeLang) {
        NodeLang nd = new NodeLang();
        nd.setValue(lang.getId_iso639_1());
        nd.setCode(lang.getId_iso639_1());
        nol.add(nd);
    }
    run.setListe_lang(nol);
    ArrayList<String> nog = new GroupHelper().getListIdOfGroup(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeGroup> groupes = new ArrayList<>();
    for (String group : nog) {
        NodeGroup ng1 = new NodeGroup();
        ng1.setId_group(group);
        ConceptGroup cg = new ConceptGroup();
        cg.setIdgroup(group);
        ng1.setConceptGroup(cg);
        groupes.add(ng1);
    }
    run.setListe_group(groupes);
    run.setConn(this.connect);
    return run;
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ArrayList(java.util.ArrayList) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) ConceptGroup(mom.trd.opentheso.bdd.datas.ConceptGroup) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Aggregations

Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)12 ArrayList (java.util.ArrayList)7 LanguageHelper (mom.trd.opentheso.bdd.helper.LanguageHelper)5 Connection (java.sql.Connection)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 Statement (java.sql.Statement)4 SelectItem (javax.faces.model.SelectItem)2 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 PreparedStatement (java.sql.PreparedStatement)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1 ConceptGroup (mom.trd.opentheso.bdd.datas.ConceptGroup)1 Term (mom.trd.opentheso.bdd.datas.Term)1 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)1 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)1