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;
}
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;
}
Aggregations