Search in sources :

Example 11 with CandidateHelper

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

the class SelectedCandidat method delPropCdt.

/**
 * ************************** SUPPRESSION ****************************
 */
/**
 * Supprime la proposition. Si c'est la dernière, le candidat est
 * intégralement supprimé.
 */
public void delPropCdt() {
    if (infoCdt.getNodesUser().size() == 1) {
        // Suppression du concept
        new CandidateHelper().deleteConceptCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso);
        reInit();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info1")));
    } else {
        // Suppression de la proposition
        new CandidateHelper().deletePropositionCandidat(connect.getPoolConnexion(), selected.getIdConcept(), theUser.getUser().getId(), idTheso);
        infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso));
        nomsProp = new ArrayList<>();
        for (NodeUser nuse : infoCdt.getNodesUser()) {
            nomsProp.add(nuse.getName());
        }
        note = "";
        niveau = "";
        domaine = "";
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info2")));
    }
}
Also used : NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 12 with CandidateHelper

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

the class SelectedCandidat method toInsert.

/**
 * Passe un candidat de son état courant à l'état inséré. Les modifications
 * nécessaires en bases de données sont traitées ici.
 *
 * @return
 */
public boolean toInsert() {
    setPreferences();
    if (selectedNvx == null) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error4")));
        return false;
    }
    niveauEdit = selectedNvx.getIdConcept();
    /*else {
            niveauEdit = null;
        }*/
    /*   if (domaineEdit == null || domaineEdit.trim().equals("")) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error1")));
            return false;
        }*/
    GroupHelper groupHelper = new GroupHelper();
    ArrayList<String> idGroups = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), idTheso, niveauEdit);
    if (tradInsert.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error2")));
        return false;
    }
    if (new TermHelper().isTermExist(connect.getPoolConnexion(), selected.getValue().trim(), idTheso, langueTheso)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error2")));
        return false;
    }
    if (idGroups.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "No Group Error !!"));
        return false;
    }
    HashMap<String, String> trad = new HashMap<>();
    if (tradInsert.contains(langueTheso)) {
        trad.put(langueTheso, selected.getValue());
        tradInsert.remove(langueTheso);
    }
    for (String l : tradInsert) {
        for (NodeTraductionCandidat ntc : infoCdt.getNodeTraductions()) {
            if (l.equals(ntc.getIdLang())) {
                trad.put(l, ntc.getTitle());
            }
        }
    }
    ArrayList<Entry<String, String>> temp = new ArrayList<>(trad.entrySet());
    ConceptHelper instance = new ConceptHelper();
    instance.setNodePreference(user.getNodePreference());
    Concept concept = new Concept();
    concept.setIdGroup(idGroups.get(0));
    concept.setIdThesaurus(idTheso);
    concept.setStatus("D");
    concept.setNotation("");
    String langueTemp = temp.get(0).getKey();
    Term terme = new Term();
    terme.setId_thesaurus(idTheso);
    terme.setLang(temp.get(0).getKey());
    terme.setLexical_value(temp.get(0).getValue());
    temp.remove(0);
    String idc;
    // if (niveauEdit == null || niveauEdit.trim().equals("")) { // Top concept
    // idc = instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, serverAdress, arkActive, theUser.getUser().getId());
    // } else { // concept
    idc = instance.addConcept(connect.getPoolConnexion(), niveauEdit, concept, terme, theUser.getUser().getId());
    // permet d'ajouter les domaines au nouveau concept
    for (String idGroup : idGroups) {
        groupHelper.addConceptGroupConcept(connect.getPoolConnexion(), idGroup, niveauEdit, idTheso);
    }
    if (!temp.isEmpty()) {
        String idt = new TermHelper().getThisTerm(connect.getPoolConnexion(), idc, idTheso, langueTemp).getId_term();
        for (Entry<String, String> e : temp) {
            terme = new Term();
            terme.setId_concept(idc);
            terme.setId_term(idt);
            terme.setId_thesaurus(idTheso);
            terme.setLang(e.getKey());
            terme.setLexical_value(e.getValue());
            new TermHelper().addTraduction(connect.getPoolConnexion(), terme, theUser.getUser().getId());
        }
    }
    CandidateHelper ch = new CandidateHelper();
    ch.updateCandidatStatus(connect.getPoolConnexion(), "i", idTheso, selected.getIdConcept());
    ch.addAdminMessage(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, theUser.getUser().getId(), msgValid);
    // message d'alerte
    /*    ArrayList<NodeUser> contribs = ch.getListUsersOfCandidat(connect.getPoolConnexion(),
            selected.getIdConcept(), idTheso);*/
    /*    for (NodeUser nodeUser : contribs) {
            if (!lesMails.contains(contrib)) {
                lesMails.add(contrib);
            }
        }*/
    /*
        for (NodeUser nodeUser : contribs) {
            if (nodeUser.getMail() != null &&  !nodeUser.getMail().trim().equals("")) {
                String message =  "Votre candidat " + selected.getValue() + " a été intégré au thésaurus par le(a) terminologue : " + theUser.getUser().getName() + ".";
                envoyerMailAlert(nodeUser.getMail(), message);
            }
        } */
    msgValid = "";
    selected.setEtat("i");
    vue.setAddInsertCdt(false);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info6")));
    return true;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) NodeTraductionCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Term(mom.trd.opentheso.bdd.datas.Term) Entry(java.util.Map.Entry) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 13 with CandidateHelper

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

the class SelectedCandidat method newCandidat.

/**
 * ************************** INSERTION ****************************
 */
/**
 * Création d'un nouveau candidat (avec une première proposition)
 *
 * @param theso
 * @param langue
 * @return
 */
public boolean newCandidat(String theso, String langue) {
    if (selectedNvx != null) {
        niveauEdit = selectedNvx.getIdConcept();
    } else {
        niveauEdit = "";
    }
    if (domaineEdit == null) {
        domaineEdit = "";
    }
    Connection conn;
    try {
        conn = connect.getPoolConnexion().getConnection();
        String id_candidat = new CandidateHelper().addCandidat_rollBack(conn, valueEdit, langue, theso, theUser.getUser().getId(), noteEdit, niveauEdit, domaineEdit);
        if (id_candidat == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error-BDD")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedCandidat.class.getName()).log(Level.SEVERE, null, ex);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error-BDD")));
        return false;
    }
    initNewProposal();
    return true;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 14 with CandidateHelper

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

the class SelectedCandidat method editMyProp.

/**
 * Permet d'éditer sa propre proposition
 *
 * @param langue
 */
public void editMyProp(String langue) {
    if (selectedNvx != null) {
        niveauEdit = selectedNvx.getIdConcept();
    } else {
        niveauEdit = "";
    }
    if (domaineEdit == null) {
        domaineEdit = "";
    }
    new CandidateHelper().updatePropositionCandidat(connect.getPoolConnexion(), selected.getIdConcept(), theUser.getUser().getId(), idTheso, noteEdit, niveauEdit, domaineEdit);
    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));
    note = np.getNote();
    niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
    domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langue) + " (" + np.getIdGroup() + ")";
    vue.setEditPropCandidat(false);
    selectedNvx = new NodeAutoCompletion();
    domaineEdit = "";
    niveauEdit = "";
    noteEdit = "";
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info8")));
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 15 with CandidateHelper

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

the class BackgroundTimeJobHelper method selectMessageProposedCdt.

/**
 * selectMessageProposeCdt
 *#JM
 *
 * récupère un corps de message et une liste de destinataire, constuits avec
 * ces valeurs un objet MessageCdt puis le retourne
 *
 * @param idTheso
 * @param d1
 * @param d2
 * @param poolConnexion
 * @return
 */
MessageCdt selectMessageProposedCdt(String idTheso, Date d1, Date d2, HikariDataSource poolConnexion) {
    ArrayList<String> ret = new CandidateHelper().getListOfCdtDuringPeriod(idTheso, d1, d2, poolConnexion);
    ArrayList<String> destinataires = new UserHelper().getMailAdmin(poolConnexion, idTheso);
    ArrayList<String> dest = reduce(destinataires);
    MessageCdt mess = new MessageCdt(ret, dest);
    return mess;
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) 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