use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class SelectedThesaurus method getThisTheso.
/**
* *************************************** AUTRE
* ****************************************
*/
/**
* Récupère le thésaurus courant
*
* @return le thésaurus s'il existe, null sinon
*/
public Thesaurus getThisTheso() {
String idTemp = "", lTemp = "";
if (thesaurus == null || thesaurus.getLanguage() == null || thesaurus.getId_thesaurus() == null) {
return null;
}
if (thesaurus.getLanguage() != null) {
lTemp = thesaurus.getLanguage();
}
if (thesaurus.getId_thesaurus() != null) {
idTemp = thesaurus.getId_thesaurus();
}
Thesaurus tempT = new ThesaurusHelper().getThisThesaurus(connect.getPoolConnexion(), idTemp, lTemp);
return tempT;
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class skosExportBean method init.
public void init(String idTheso, String idLang) {
this.idTheso = idTheso;
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
languagesOfTheso = thesaurusHelper.getAllUsedLanguagesOfThesaurusNode(connect.getPoolConnexion(), idTheso);
GroupHelper groupHelper = new GroupHelper();
groupList = groupHelper.getListRootConceptGroup(connect.getPoolConnexion(), idTheso, idLang);
selectedLanguages = new ArrayList<>();
selectedGroups = new ArrayList<>();
selectedLanguages = new ArrayList<>();
for (NodeLang nodeLang : languagesOfTheso) {
selectedLanguages.add(nodeLang);
}
selectedGroups = new ArrayList<>();
for (NodeGroup nodeGroup : groupList) {
selectedGroups.add(nodeGroup);
}
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper 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.ThesaurusHelper in project opentheso by miledrousset.
the class SelectedThesaurus method ajouterTheso.
/**
* Création d'un nouveau thésaurus avec le role
*
* @param idUser
* @param idRole
*/
public void ajouterTheso(int idUser, int idRole) {
if (editTheso.getTitle() == null || editTheso.getTitle().trim().equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
} else {
ThesaurusHelper th = new ThesaurusHelper();
th.setIdentifierType(identifierType);
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
String idThesaurus = th.addThesaurusRollBack(conn, null, arkActive);
if (idThesaurus == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
conn.rollback();
conn.close();
return;
}
if (editTheso.getTitle().isEmpty()) {
thesaurus.setTitle("theso_" + idThesaurus);
}
if (editTheso.getLanguage() == null) {
editTheso.setLanguage(workLanguage);
}
editTheso.setId_thesaurus(idThesaurus);
if (!th.addThesaurusTraductionRollBack(conn, editTheso)) {
conn.rollback();
conn.close();
return;
}
// ajout de role pour le thésaurus à l'utilisateur en cours
UserHelper userHelper = new UserHelper();
if (!userHelper.addRole(conn, idUser, idRole, idThesaurus, "")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
}
maj();
arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
tree.getSelectedTerme().getUser().updateAuthorizedTheso();
vue.setCreat(false);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info1.1") + " " + editTheso.getTitle() + " " + langueBean.getMsg("theso.info1.2")));
// editTheso = new Thesaurus();
}
// tree.getSelectedTerme().getUser().getUser().getId();
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class SelectedThesaurus method supprimerTheso.
/**
* Suppréssion d'un thésaurus
*
* @param id
*/
public void supprimerTheso(String id) {
ThesaurusHelper th = new ThesaurusHelper();
// on vérifie si l'utilisateur n'a plus aucun thésaurus, on garde son dernier role sans thésaurus
// cette action est temporaire le temps de mettre en place une gestion complète des users et des groupes
UserHelper userHelper = new UserHelper();
Connection conn;
try {
conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
if (userHelper.isLastThesoOfUser(connect.getPoolConnexion(), tree.getSelectedTerme().getUser().getUser().getId())) {
if (!userHelper.deleteOnlyTheThesoFromRole(conn, id)) {
conn.rollback();
conn.close();
return;
}
} else {
if (!userHelper.deleteThisRoleForThisThesaurus(conn, tree.getSelectedTerme().getUser().getUser().getId(), id)) {
conn.rollback();
conn.close();
return;
}
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedThesaurus.class.getName()).log(Level.SEVERE, null, ex);
}
ConceptHelper conceptHelper = new ConceptHelper();
conceptHelper.setNodePreference(nodePreference);
conceptHelper.deleteAllIdHandle(connect.getPoolConnexion(), id);
th.deleteThesaurus(connect.getPoolConnexion(), id);
arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", conceptHelper.getMessage()));
}
Aggregations