Search in sources :

Example 1 with Languages_iso639

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

the class LanguageHelper method getSelectItemLanguagesOneThesaurus.

/**
 * Permet de remplir un tableau de SelectItem avec les langues d'un thesaurus
 *
 * @param ds le pool de connexion
 * @param idTheso l'identifiant du thesaurus
 * @param idLangue la langue du thesaurus
 * @return  le tableau de SelectItem plein
 */
public SelectItem[] getSelectItemLanguagesOneThesaurus(HikariDataSource ds, String idTheso, String idLangue) {
    SelectItem[] langues;
    ArrayList<Languages_iso639> arrayLangue1 = (getLanguagesOfThesaurus(ds, idTheso));
    if (idLangue.equals("")) {
        langues = new SelectItem[arrayLangue1.size()];
    } else {
        langues = new SelectItem[arrayLangue1.size() - 1];
    }
    int i = 0;
    for (Languages_iso639 l : arrayLangue1) {
        if (!(l.getId_iso639_1().trim()).equals(idLangue)) {
            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) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 2 with Languages_iso639

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

the class LanguageHelper method getThisLanguage.

/**
 * Permet de retourner un objet Langauge par identifiant / ou null si rien
 *
 * @param ds le pool de connexion
 * @param idLang
 * @return Objet Class Thesaurus
 */
public Languages_iso639 getThisLanguage(HikariDataSource ds, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    Languages_iso639 language = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query1 = "select * from languages_iso639" + " where iso639_1 = '" + idLang + "'";
                stmt.executeQuery(query1);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    resultSet.next();
                    language = new Languages_iso639();
                    language.setId_iso639_1(idLang);
                    language.setId_iso639_2(resultSet.getString("iso639_2"));
                    language.setFrench_name(resultSet.getString("french_name"));
                    language.setEnglish_name(resultSet.getString("english_name"));
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding element : " + language, 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 3 with Languages_iso639

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

the class LanguageHelper method getAllLanguages.

/**
 * Permet de retourner un ArrayList d'Objet Languages_iso639 de toute la table Language_iso639
 * c'est la liste des langues ISO639 / ou null si rien
 *
 * @param ds le pool de connexion
 * @return Objet Class Thesaurus
 */
public ArrayList<Languages_iso639> getAllLanguages(HikariDataSource ds) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<Languages_iso639> language = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query1 = "select distinct * from languages_iso639 ORDER BY french_name";
                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"));
                        languageTmp.setId_iso639_2(resultSet.getString("iso639_2"));
                        languageTmp.setFrench_name(resultSet.getString("french_name"));
                        languageTmp.setEnglish_name(resultSet.getString("english_name"));
                        language.add(languageTmp);
                    }
                    resultSet.close();
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding element : " + language, sqle);
    }
    return language;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 4 with Languages_iso639

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

the class GpsBeans method integreTraduction.

/**
 * Permet d'intégrer les traductions à un Concept venant de l'alignement
 * source On intègre que les traductions disponible pour le thésaurus en
 * cours
 *
 * @param idTerm
 * @return
 */
private boolean integreTraduction(String idTerm, String langEnCour) {
    boolean status = false;
    LanguageHelper languageHelper = new LanguageHelper();
    TermHelper termHelper = new TermHelper();
    // la liste des langues du thésaurus
    listLanguesInTheso = languageHelper.getLanguagesOfThesaurus(connect.getPoolConnexion(), id_theso);
    if (alignment_choisi.getAlltraductions() != null) {
        if (!alignment_choisi.getAlltraductions().isEmpty()) {
            ArrayList<String> langsOfTheso = new ArrayList<>();
            ArrayList<NodeLang> ourLangs = new ArrayList<>();
            // classer les langues dasn une liste
            for (Languages_iso639 languages_iso639 : listLanguesInTheso) {
                if (// on ignore la langue en cours
                !langEnCour.equalsIgnoreCase(languages_iso639.getId_iso639_1())) {
                    langsOfTheso.add(languages_iso639.getId_iso639_1());
                }
            }
            // filtrer les langues récupérées de l'alignement et qui sont dans notre thésaurus
            for (NodeLang traduction : alignment_choisi.getAlltraductions()) {
                if (langsOfTheso.contains(traduction.getCode())) {
                    ourLangs.add(traduction);
                }
            }
            Term termTemp = new Term();
            for (NodeLang ourLang : ourLangs) {
                termTemp.setLexical_value(ourLang.getValue());
                termTemp.setId_term(idTerm);
                termTemp.setId_thesaurus(id_theso);
                termTemp.setLang(ourLang.getCode());
                termTemp.setSource("");
                termTemp.setStatus("");
                if (termHelper.isTermExist(connect.getPoolConnexion(), termTemp.getLexical_value(), termTemp.getId_thesaurus(), termTemp.getLang())) {
                    if (remplacerTraduction) {
                        // si le terme existe et on a autorisé le remplacement, on remplace la traduction
                        termHelper.updateTermTraduction(connect.getPoolConnexion(), termTemp, theUser.getUser().getId());
                    }
                } else {
                    // on ajoute simplement la traduction
                    termHelper.addTraduction(connect.getPoolConnexion(), termTemp, theUser.getUser().getId());
                }
            }
        }
    }
    return status;
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) ArrayList(java.util.ArrayList) Term(mom.trd.opentheso.bdd.datas.Term) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 5 with Languages_iso639

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

the class SelectedThesaurus method getThisTrad.

/**
 * Récupération des traductions du thésaurus
 *
 * @return une liste des traductions
 */
public ArrayList<Languages_iso639> getThisTrad() {
    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);
        }
    }
    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)

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