Search in sources :

Example 1 with CandidateHelper

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

the class ExportCandidats method exportCandidatsToCSV.

@Test
public void exportCandidatsToCSV() {
    ConnexionTest connexionTest = new ConnexionTest();
    HikariDataSource conn = connexionTest.getConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    ArrayList<String> tabIdCandidats;
    boolean passed = false;
    StringBuilder file = new StringBuilder();
    CandidateHelper candidateHelper = new CandidateHelper();
    tabIdCandidats = candidateHelper.getAllCandidatId(conn, idTheso);
    if (tabIdCandidats != null) {
        if (!tabIdCandidats.isEmpty()) {
            file.append("id_candidat");
            file.append("\t");
            file.append("titre");
            file.append("\t");
            file.append("langue");
            file.append("\t");
            file.append("notes contributeurs");
            file.append("\t");
            file.append("status");
            file.append("\t");
            file.append("message de l'administrateur");
            file.append("\t");
            file.append("id_concept");
            file.append("\t");
            file.append("date création");
            file.append("\t");
            file.append("date modification");
            file.append("\n");
            for (String tabIdCandidat : tabIdCandidats) {
                file.append(tabIdCandidat);
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\t");
                file.append(" ");
                file.append("\n");
            }
        }
    }
    System.out.println(file.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConnexionTest(connexion.ConnexionTest) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper) ConnexionTest(connexion.ConnexionTest) Test(org.junit.Test)

Example 2 with CandidateHelper

use of mom.trd.opentheso.bdd.helper.CandidateHelper 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 3 with CandidateHelper

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

the class SelectedCandidat method initEditProp.

public void initEditProp() {
    NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, theUser.getUser().getId());
    noteEdit = np.getNote();
    niveauEdit = np.getIdConceptParent();
    domaineEdit = np.getIdGroup();
    vue.setEditPropCandidat(true);
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 4 with CandidateHelper

use of mom.trd.opentheso.bdd.helper.CandidateHelper 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 5 with CandidateHelper

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

the class SelectedCandidat method editMyCandidat.

/**
 * Permet de modifier un candidat, ce qui implique que personne n'a encore
 * fait de proposition dessus et que c'est le contributor qui le modifit.
 */
public void editMyCandidat() {
    if (valueEdit.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error3")));
    } else {
        new CandidateHelper().updateMotCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, valueEdit);
        selected.setValue(valueEdit);
        valueEdit = "";
        vue.setEditCandidat(false);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info7")));
    }
}
Also used : FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Aggregations

CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)16 FacesMessage (javax.faces.application.FacesMessage)10 NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)6 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)5 NodeProposition (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition)5 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)2 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)2 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)2 NodeTraductionCandidat (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1 Term (mom.trd.opentheso.bdd.datas.Term)1 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)1 NodeCandidatValue (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue)1