Search in sources :

Example 6 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method getGroupsOfUser.

/**
 * permet de récupérer la liste des groupes/projets d'un utilisateur #MR
 */
private void getGroupsOfUser() {
    UserHelper2 userHelper = new UserHelper2();
    if (user.isIsSuperAdmin()) {
        // l'utilisateur est superAdmin
        listeGroupsOfUser = userHelper.getAllGroups(connect.getPoolConnexion());
        return;
    }
    listeGroupsOfUser = userHelper.getGroupsOfUser(connect.getPoolConnexion(), user.getIdUser());
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2)

Example 7 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method addUserRoleOnGroup.

/**
 * permet d'ajouter un role pour l'utilisateur sur ce groupe
 *
 * @param idUser
 * @param idRole
 * @param idGroup
 * @return
 */
public boolean addUserRoleOnGroup(int idUser, int idRole, int idGroup) {
    if (idRole > 1) {
        if (idGroup == -1 || idGroup == 0) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("profile.needGroupMessage")));
            return false;
        }
    }
    UserHelper2 userHelper = new UserHelper2();
    if (idRole == 1) {
    // cas de changement en superAdmin
    // userHelper.setIsSuperAdmin(conn, idUser, vueListSuperAdmin)
    }
    if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), idUser, idRole, idGroup)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
        return false;
    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.ModifyRoleMessage")));
    nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
    listUsersByGroup();
    listSuperAdmin();
    return true;
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 8 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method addNewRoleOnGroup.

public void addNewRoleOnGroup() {
    UserHelper2 userHelper = new UserHelper2();
    if (groupAdded == null || groupAdded.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Groupe manquant")));
        return;
    }
    int idGroup = Integer.parseInt(groupAdded);
    if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), userSelected, roleAdded, idGroup)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
        return;
    }
    listUsersByGroup();
    listAllGroupUser();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.ModifyRoleMessage")));
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 9 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method getAllProject.

/**
 * permet de récupérer tous les projets pour la gestion
 */
private void getAllProject() {
    UserHelper2 userHelper = new UserHelper2();
    nodeAllProject = userHelper.getAllProject(connect.getPoolConnexion());
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2)

Example 10 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method addUserGroup.

/**
 * permet de créer un groupe/projet
 * @return
 */
public boolean addUserGroup() {
    editPassed = false;
    if (!user.isIsSuperAdmin()) {
        return false;
    }
    if (groupAdded == null) {
        return false;
    }
    if (groupAdded.isEmpty()) {
        return false;
    }
    UserHelper2 userHelper = new UserHelper2();
    if (userHelper.isUserGroupExist(connect.getPoolConnexion(), groupAdded)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Ce projet existe déjà"));
        return false;
    }
    if (!userHelper.createUserGroup(connect.getPoolConnexion(), groupAdded)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Erreur BDD"));
        return false;
    }
    editPassed = true;
    getGroupsOfUser();
    getAllProject();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", "Projet ajouté"));
    PrimeFaces pf = PrimeFaces.current();
    if (pf.isAjaxRequest()) {
        pf.ajax().update("idAddUserGroupDlg");
    }
    return true;
}
Also used : PrimeFaces(org.primefaces.PrimeFaces) UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)48 FacesMessage (javax.faces.application.FacesMessage)19 Connection (java.sql.Connection)9 SQLException (java.sql.SQLException)8 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)6 HikariDataSource (com.zaxxer.hikari.HikariDataSource)5 ConnexionTest (connexion.ConnexionTest)5 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)5 Test (org.junit.Test)5 AccessThesaurusHelper (mom.trd.opentheso.bdd.helper.AccessThesaurusHelper)3 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)3 LinkedHashMap (java.util.LinkedHashMap)2 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)2 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)2 NodeUserRoleGroup (mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup)2 PrimeFaces (org.primefaces.PrimeFaces)2 HashMap (java.util.HashMap)1 PostConstruct (javax.annotation.PostConstruct)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 NodeUser2 (mom.trd.opentheso.bdd.helper.nodes.NodeUser2)1