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