Search in sources :

Example 31 with UserHelper2

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

the class CurrentUser2 method updateUser.

/**
 * permet de mettre les préférences d'un utilisateur (alertes, activé ..
 */
public void updateUser() {
    UserHelper2 userHelper = new UserHelper2();
    // boolean isSuperAdmin = false;
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        /*        if (roleAdded == 1) {
                isSuperAdmin = true;
                // on supprime les roles sur les groupes
                if (!userHelper.deleteRolesOfUser(conn, userEdit.getIdUser())) {
                    conn.rollback();
                    conn.close();
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
                    return;
                }
            }*/
        if (!userHelper.updateUser(conn, userEdit.getIdUser(), userEdit.isIsActive(), userEdit.isIsAlertMail())) {
            conn.rollback();
            conn.close();
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
            return;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(CurrentUser2.class.getName()).log(Level.SEVERE, null, ex);
        return;
    }
    roleAdded = -1;
    listUsersByGroup();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info4")));
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 32 with UserHelper2

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

the class CurrentUser2 method updateMail.

/**
 * permet de changer l'adress mail de l'utilisateur
 */
public void updateMail() {
    if (mailAdded == null || mailAdded.equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error6")));
    } else if (!mailAdded.contains("@") || mailAdded.lastIndexOf(".") < mailAdded.indexOf("@")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error7")));
    } else if (new UserHelper2().isUserMailExist(connect.getPoolConnexion(), mailAdded)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error8")));
    } else {
        new UserHelper2().updateMail(connect.getPoolConnexion(), user.getIdUser(), mailAdded);
        user.setMail(mailAdded);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info5")));
    }
    mailAdded = "";
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 33 with UserHelper2

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

the class CurrentUser2 method delUserRoleOnGroup.

/**
 * permet de supprimer le role de l'utilisateur sur ce groupe
 *
 * @param idUser
 * @param idGroup
 */
public void delUserRoleOnGroup(int idUser, int idGroup) {
    UserHelper2 userHelper = new UserHelper2();
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (!userHelper.deleteRoleOnGroup(conn, idUser, idGroup)) {
            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();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.deleteRoleMessage")));
        nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
        listUsersByGroup();
        listAllGroupUser();
    } catch (SQLException ex) {
        Logger.getLogger(CurrentUser2.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 34 with UserHelper2

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

the class CurrentUser2 method updateUserRoleOnGroup.

/**
 * permet de modifier le role d'un utilisateur sur un groupe
 *
 * @param idUser
 * @param idRole
 * @param idGroup
 */
public void updateUserRoleOnGroup(int idUser, int idRole, int idGroup) {
    if (idGroup == -1 || idGroup == 0) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("profile.needGroupMessage")));
        return;
    }
    UserHelper2 userHelper = new UserHelper2();
    if (!userHelper.updateUserRoleOnGroup(connect.getPoolConnexion(), idUser, idRole, idGroup)) {
        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("profile.ModifyRoleMessage")));
    nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
    listUsersByGroup();
    listAllGroupUser();
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 35 with UserHelper2

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

the class CurrentUser2 method renameUserGroup.

// //////////////////////////////////////////////////////////////////
// ////// fonctions pour la gestion des projets/groupes /////////////
// //////////////////////////////////////////////////////////////////
/**
 * permet de renommer un groupe/projet
 * @return
 */
public boolean renameUserGroup() {
    editPassed = false;
    if (!user.isIsSuperAdmin()) {
        return false;
    }
    if (nodeUserGroupEdit == null) {
        return false;
    }
    if (nodeUserGroupEdit.getGroupName().isEmpty()) {
        return false;
    }
    UserHelper2 userHelper = new UserHelper2();
    if (userHelper.isUserGroupExist(connect.getPoolConnexion(), nodeUserGroupEdit.getGroupName().trim())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Ce projet existe déjà"));
        return false;
    }
    if (!userHelper.updateProject(connect.getPoolConnexion(), nodeUserGroupEdit.getGroupName(), nodeUserGroupEdit.getIdGroup())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Modification refusée: ", nodeUserGroupEdit.getGroupName()));
    } else {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Modification réussie: ", nodeUserGroupEdit.getGroupName()));
    }
    editPassed = true;
    getGroupsOfUser();
    getAllProject();
    PrimeFaces pf = PrimeFaces.current();
    if (pf.isAjaxRequest()) {
        pf.ajax().update("idEditUserGroupDlg");
    }
    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