use of mom.trd.opentheso.bdd.helper.LanguageHelper in project opentheso by miledrousset.
the class SelectedThesaurus method StartDefaultThesauriTree.
/**
* Met à jour le thésaurus courant lors d'un changement de thésaurus
*/
public void StartDefaultThesauriTree() {
tree.getSelectedTerme().getUser().setIdTheso(thesaurus.getId_thesaurus());
if (connect.getPoolConnexion() == null) {
System.err.println("!!!!! Opentheso n'a pas pu se connecter à la base de données 2!!!!!!! ");
return;
}
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
statBean.reInit();
uTree.reInit();
if (selectedTerme != null) {
selectedTerme.initTerme();
}
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
if (thesaurusHelper.isThesaurusExiste(connect.getPoolConnexion(), defaultThesaurusId)) {
thesaurus = thesaurusHelper.getThisThesaurus(connect.getPoolConnexion(), defaultThesaurusId, workLanguage);
if (thesaurus == null) {
return;
}
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
uTree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
candidat.maj(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
vue.setCreat(false);
nodePreference = tree.getSelectedTerme().getUser().getThesaurusPreferences(thesaurus.getId_thesaurus(), workLanguage);
tree.setIdThesoSelected(thesaurus.getId_thesaurus());
tree.setDefaultLanguage(thesaurus.getLanguage());
}
user.initUserNodePref(thesaurus.getId_thesaurus());
majPref();
}
use of mom.trd.opentheso.bdd.helper.LanguageHelper in project opentheso by miledrousset.
the class SelectedThesaurus method maj.
/**
* ************************************ MISE A JOUR
* *************************************
*/
/**
* Met à jour le thésaurus courant lors d'un changement de thésaurus
*/
public void maj() {
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
statBean.reInit();
ThesaurusHelper th = new ThesaurusHelper();
nodePreference = tree.getSelectedTerme().getUser().getThesaurusPreferences(thesaurus.getId_thesaurus(), workLanguage);
if (th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang()) != null) {
thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang());
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
tree.setIdThesoSelected(thesaurus.getId_thesaurus());
tree.setDefaultLanguage(thesaurus.getLanguage());
} else {
thesaurus.setLanguage("");
}
uTree.reInit();
uTree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
candidat.maj(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
if (tree != null) {
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
}
vue.setCreat(false);
// #jm pour la page de statistiques
vue.setStatTheso(false);
// idem
vue.setStatCpt(false);
majPref();
if (selectedTerme != null) {
selectedTerme.initTerme();
}
tree.getSelectedTerme().getUser().setIdTheso(thesaurus.getId_thesaurus());
if ((user.getUser().getName() != null) && (user.isIsHaveWriteToCurrentThesaurus())) {
String message = "drag & dop activé !";
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("", "info : " + message));
}
}
use of mom.trd.opentheso.bdd.helper.LanguageHelper 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.helper.LanguageHelper 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()));
}
use of mom.trd.opentheso.bdd.helper.LanguageHelper 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;
}
}
Aggregations