Search in sources :

Example 1 with UserHelper2

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);
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeUserRoleGroup(mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup) UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) LinkedHashMap(java.util.LinkedHashMap) PostConstruct(javax.annotation.PostConstruct)

Example 2 with UserHelper2

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();
}
Also used : SQLException(java.sql.SQLException) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) AccessThesaurusHelper(mom.trd.opentheso.bdd.helper.AccessThesaurusHelper) Connection(java.sql.Connection) UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) FacesMessage(javax.faces.application.FacesMessage) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 3 with UserHelper2

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();
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 4 with UserHelper2

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);
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2)

Example 5 with UserHelper2

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());
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2)

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