Search in sources :

Example 11 with Languages_iso639

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

the class ThesaurusHelper method getNodeThesaurus.

/**
 * Permet de retourner un thésaurus par identifiant sous forme de
 * NodeThesaurus avec les traductions
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @return Objet Class Thesaurus
 */
public NodeThesaurus getNodeThesaurus(HikariDataSource ds, String idThesaurus) {
    ArrayList<Languages_iso639> listLangTheso = getLanguagesOfThesaurus(ds, idThesaurus);
    NodeThesaurus nodeThesaurus = new NodeThesaurus();
    ArrayList<Thesaurus> thesaurusTraductionsList = new ArrayList<>();
    for (int i = 0; i < listLangTheso.size(); i++) {
        Thesaurus thesaurus = getThisThesaurus(ds, idThesaurus, listLangTheso.get(i).getId_iso639_1());
        if (thesaurus != null) {
            thesaurusTraductionsList.add(thesaurus);
        }
    }
    nodeThesaurus.setIdThesaurus(idThesaurus);
    nodeThesaurus.setListThesaurusTraduction(thesaurusTraductionsList);
    return nodeThesaurus;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) ArrayList(java.util.ArrayList) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 12 with Languages_iso639

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

the class ThesaurusHelper method getLanguagesOfThesaurus.

/**
 * Retourne la liste des traductions d'un thesaurus sous forme de ArrayList
 * d'Objet Languages_iso639
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public ArrayList<Languages_iso639> getLanguagesOfThesaurus(HikariDataSource ds, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<Languages_iso639> lang = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT DISTINCT" + " languages_iso639.iso639_1, " + " languages_iso639.iso639_2, " + " languages_iso639.english_name, " + " languages_iso639.french_name, " + " thesaurus_label.lang" + " FROM " + " thesaurus_label," + " languages_iso639" + " WHERE" + " thesaurus_label.lang = languages_iso639.iso639_1 AND" + " thesaurus_label.lang = languages_iso639.iso639_1;";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    lang = new ArrayList<>();
                    while (resultSet.next()) {
                        Languages_iso639 languages_iso639 = new Languages_iso639();
                        languages_iso639.setId_iso639_1(resultSet.getString("iso639_1"));
                        languages_iso639.setId_iso639_2(resultSet.getString("iso639_2"));
                        languages_iso639.setFrench_name(resultSet.getString("french_name"));
                        languages_iso639.setFrench_name(resultSet.getString("english_name"));
                        lang.add(languages_iso639);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List Language of thesaurus : " + idThesaurus, sqle);
    }
    return lang;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) 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