use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class EditionBean method init.
@PostConstruct
public void init() {
editTheso = new Thesaurus();
userRoleGroups = new LinkedHashMap();
ArrayList<NodeUserRoleGroup> nodeUserRoleGroups = new UserHelper2().getUserRoleGroup(connect.getPoolConnexion(), currentUser.getUser().getIdUser());
for (NodeUserRoleGroup nodeUserRoleGroup : nodeUserRoleGroups) {
if (nodeUserRoleGroup.getIdRole() < 3) {
userRoleGroups.put("" + nodeUserRoleGroup.getIdGroup(), nodeUserRoleGroup.getGroupName());
selectedUserGroup = "" + nodeUserRoleGroup.getIdGroup();
}
}
vue.setCreat(false);
vue.setTrad(false);
vue.setEdit(false);
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class EditionBean method ajouterTheso.
/**
* Création d'un nouveau thésaurus avec l'ajout du théso dans le groupe de l'utilisateur en cours
*/
public void ajouterTheso() {
NodePreference nodePreference = roleOnThesoBean.getNodePreference();
boolean arkActive = false;
String urlSite = "";
String workLanguage;
String idThesoNew = null;
if (!currentUser.getUser().isIsSuperAdmin()) {
if (selectedUserGroup == null || selectedUserGroup.isEmpty()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "pas de Groupe sélectionné"));
return;
}
}
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();
if (nodePreference == null) {
// numérique
th.setIdentifierType("2");
workLanguage = connect.getWorkLanguage();
} else {
th.setIdentifierType("" + nodePreference.getIdentifierType());
arkActive = nodePreference.isUseArk();
urlSite = nodePreference.getCheminSite();
workLanguage = nodePreference.getSourceLang();
nodePreference.setPreferredName(editTheso.getTitle().trim());
}
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
idThesoNew = th.addThesaurusRollBack(conn, urlSite, arkActive);
if (idThesoNew == 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()) {
editTheso.setTitle("theso_" + idThesoNew);
}
if (editTheso.getLanguage() == null) {
editTheso.setLanguage(workLanguage);
}
editTheso.setId_thesaurus(idThesoNew);
if (!th.addThesaurusTraductionRollBack(conn, editTheso)) {
conn.rollback();
conn.close();
return;
}
// ajout de role pour le thésaurus à l'utilisateur en cours
UserHelper2 userHelper = new UserHelper2();
if (!currentUser.getUser().isIsSuperAdmin()) {
if (!userHelper.addThesoToGroup(conn, idThesoNew, Integer.parseInt(selectedUserGroup))) {
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();
// appliquer les préférences du Domaine au nouveau thésaurus
if (nodePreference != null) {
if (!new PreferencesHelper().addPreference(connect.getPoolConnexion(), nodePreference, idThesoNew)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
}
} catch (SQLException ex) {
log.error("Error while adding traductions of thésaurus ", 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")));
setVisibility(idThesoNew, isPrivate);
editTheso = new Thesaurus();
}
// tree.getSelectedTerme().getUser().getUser().getId();
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method delUser.
/**
* permet de supprimer un utilisateur
* @param idUser
*/
public void delUser(int idUser) {
UserHelper2 userHelper = new UserHelper2();
if (!userHelper.deleteUser(connect.getPoolConnexion(), idUser)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info2")));
listUsersByGroup();
if (user.isIsSuperAdmin())
listSuperAdmin();
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method setUserRoleOnThisGroup.
/**
* setting du role de l'utilisateur sur le group séléctionné
*
* #MR
*
* @return
*/
private void setUserRoleOnThisGroup() {
if (selectedGroup == null) {
return;
}
if (selectedGroup.isEmpty()) {
return;
}
int idGroup = Integer.parseInt(selectedGroup);
UserHelper2 userHelper = new UserHelper2();
if (user.isIsSuperAdmin()) {
// l'utilisateur est superAdmin
nodeUserRoleSuperAdmin = userHelper.getUserRoleForSuperAdmin(connect.getPoolConnexion());
return;
}
nodeUserRoleOnThisGroup = userHelper.getUserRoleOnThisGroup(connect.getPoolConnexion(), user.getIdUser(), idGroup);
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method listSuperAdmin.
private void listSuperAdmin() {
UserHelper2 userHelper = new UserHelper2();
listeUserSuperAdmin = userHelper.getListOfSuperAdmin(connect.getPoolConnexion());
}
Aggregations