Search in sources :

Example 6 with NodeUser

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

the class loginFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse resp = (HttpServletResponse) response;
    CurrentUser session = (CurrentUser) req.getSession().getAttribute("user1");
    String url = req.getRequestURI();
    Connexion conn = (Connexion) request.getServletContext().getAttribute("poolConnexion");
    HikariDataSource hds;
    if (url.contains("install.xhtml") || url.contains("no_connection")) {
        chain.doFilter(request, response);
        return;
    } else {
        if (conn != null) {
            hds = (HikariDataSource) conn.getPoolConnexion();
            if (hds == null) {
                resp.sendRedirect("./admin/no_connection.xhtml");
                return;
            }
        }
        if (conn == null) {
            resp.sendRedirect("./admin/no_connection.xhtml");
            return;
        }
    }
    /* if(req.getRequestedSessionId()==null || !req.isRequestedSessionIdValid()){
            req.getSession(true);
            resp.sendRedirect("/index.xhtml");
       
        }*/
    if (session != null) {
        // resp.sendRedirect("./install.xhtml");
        if (session.getConnect().getPoolConnexion() == null) {
            return;
        }
    }
    if (url.contains("deco.xhtml")) {
        CurrentUser temp = (CurrentUser) req.getSession().getAttribute("user1");
        temp.setUser(new NodeUser());
        temp.setIsLogged(false);
        req.getSession().setAttribute("user1", temp);
        ((SelectedCandidat) req.getSession().getAttribute("selectedCandidat")).reInit();
        // req.getServletContext().getContextPath());
        resp.sendRedirect("./index.xhtml");
    } else if (session == null || !session.isLogged()) {
        if (url.contains("conf.xhtml") || url.contains("gestCandidat.xhtml") || url.contains("edition.xhtml") || url.contains("statistic.xhtml")) {
            resp.sendRedirect(req.getServletContext().getContextPath());
        } else {
            chain.doFilter(request, response);
        }
    } else {
        if (url.contains("connect.xhtml")) {
            resp.sendRedirect(req.getServletContext().getContextPath());
        } else {
            chain.doFilter(request, response);
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HikariDataSource(com.zaxxer.hikari.HikariDataSource) CurrentUser(mom.trd.opentheso.SelectedBeans.CurrentUser) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) SelectedCandidat(mom.trd.opentheso.SelectedBeans.SelectedCandidat) HttpServletResponse(javax.servlet.http.HttpServletResponse) Connexion(mom.trd.opentheso.bdd.helper.Connexion)

Example 7 with NodeUser

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

the class CandidateHelper method getListUsersOfCandidat.

/**
 * Permet de retourner une ArrayList de NodeUser par thésaurus et Concept
 * c'est la liste des personnes qui ont déposé ce candidat
 *
 * @param ds le pool de connexion
 * @param idConcept
 * @param idThesaurus
 * @return Objet Class ArrayList NodeUSer
 */
public ArrayList<NodeUser> getListUsersOfCandidat(HikariDataSource ds, String idConcept, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeUser> nodeUserList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT users.username, users.id_user, users.mail," + " proposition.modified" + " FROM proposition, users WHERE" + " proposition.id_user = users.id_user" + " and proposition.id_concept = '" + idConcept + "'" + " and proposition.id_thesaurus = '" + idThesaurus + "'" + " order By proposition.modified DESC;";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    nodeUserList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeUser nodeUser = new NodeUser();
                        nodeUser.setId(resultSet.getInt("id_user"));
                        nodeUser.setName(resultSet.getString("username"));
                        nodeUser.setMail(resultSet.getString("mail"));
                        nodeUserList.add(nodeUser);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List of nodeUsersCandidat of ConceptCandidat : " + idConcept, sqle);
    }
    return nodeUserList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 8 with NodeUser

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

the class SelectedCandidat method newPropCandidat.

/**
 * Ajoute une proposition au candidat courant
 *
 * @param langue
 * @return
 */
public boolean newPropCandidat(String langue) {
    try {
        if (selectedNvx != null) {
            if (!selectedNvx.getIdConcept().isEmpty())
                if (!setLevelInfos(selectedNvx.getIdConcept(), langue))
                    return false;
        } else {
            niveauEdit = "";
        }
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (selectedNvx != null) {
            niveauEdit = selectedNvx.getIdConcept();
        } else {
            niveauEdit = "";
        }
        if (domaineEdit == null) {
            domaineEdit = "";
        }
        if (!new CandidateHelper().addPropositionCandidat_RollBack(conn, selected.getIdConcept(), theUser.getUser().getId(), idTheso, noteEdit, niveauEdit, domaineEdit)) {
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, infoCdt.getNodesUser().get(0).getId());
        infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso));
        modifiedProposition = np.getModified();
        createdProposition = np.getCreated();
        nomsProp = new ArrayList<>();
        for (NodeUser nuse : infoCdt.getNodesUser()) {
            nomsProp.add(nuse.getName());
        }
        note = np.getNote();
        niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
        if (!np.getIdConceptParent().isEmpty()) {
            niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langueTheso) + " (" + np.getIdConceptParent() + ")";
            showGroup(np);
        // domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langueTheso) + " (" + np.getIdGroup() + ")";
        }
        selected.setNbProp(selected.getNbProp() + 1);
        // envoie d'email d'alerte !!
        /*  int minAlert = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso).getNbAlertCdt();
            if (selected.getNbProp() >= minAlert) {
                ArrayList<String> lesMails = new UserHelper().getMailAdmin(connect.getPoolConnexion(), idTheso);
                for (String mail : lesMails) {
                    if (mail != null && !mail.trim().equals("")) {
                        String message =  "Le candidat " + selected.getValue() + " a atteint le seuil d'alerte de " + minAlert + " fois.";
                        envoyerMailAlert(mail, message);
                    }
                }
            }*/
        initNewProposal();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(SelectedCandidat.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) Connection(java.sql.Connection) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 9 with NodeUser

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

the class SelectedCandidat method onChange.

/**
 * ************************** MISE A JOUR ****************************
 */
/**
 * Changement de la proposition courrante à la sélection du nom d'un
 * utilisateur dans la table des propositions
 *
 * @param event
 */
public void onChange(TabChangeEvent event) {
    String nom = (String) event.getData();
    for (NodeUser nu : infoCdt.getNodesUser()) {
        if (nom.equals(nu.getName())) {
            NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, nu.getId());
            note = np.getNote();
            modifiedProposition = np.getModified();
            if (!np.getIdConceptParent().isEmpty()) {
                niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langueTheso) + " (" + np.getIdConceptParent() + ")";
                showGroup(np);
            // domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langueTheso) + " (" + np.getIdGroup() + ")";
            }
            break;
        }
    }
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 10 with NodeUser

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

the class SelectedCandidat method toRefus.

/**
 * Passe un candidat de son état courant à l'état refusé. Un mail est envoyé
 * aux contributeurs si l'option d'envoi de mail est activée
 */
public void toRefus() {
    CandidateHelper ch = new CandidateHelper();
    ch.updateCandidatStatus(connect.getPoolConnexion(), "r", idTheso, selected.getIdConcept());
    ch.addAdminMessage(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, theUser.getUser().getId(), msgValid);
    // gestion message
    selected.setEtat("r");
    // envoie d'email d'alerte !!
    ArrayList<NodeUser> contribs = ch.getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso);
    /*
        for (NodeUser nodeUser : contribs) {
            if (nodeUser.getMail() != null && !nodeUser.getMail().trim().equals("")) {
                String message = "Le candidat " + selected.getValue() + " a été refusé par le(a) terminologue : " + theUser.getUser().getName() + ".";
                message = message + "\n avec le message suivant : " + msgValid + ".";
                envoyerMailAlert(nodeUser.getMail(), message);
            }

        }*/
    msgValid = "";
    vue.setAddValidCdt(false);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info5")));
}
Also used : NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Aggregations

NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)16 SQLException (java.sql.SQLException)9 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 Statement (java.sql.Statement)7 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)6 FacesMessage (javax.faces.application.FacesMessage)5 ArrayList (java.util.ArrayList)3 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)3 NodeProposition (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition)3 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 CurrentUser (mom.trd.opentheso.SelectedBeans.CurrentUser)1 SelectedCandidat (mom.trd.opentheso.SelectedBeans.SelectedCandidat)1 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)1 Connexion (mom.trd.opentheso.bdd.helper.Connexion)1