Search in sources :

Example 1 with NodeTraductionCandidat

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

the class SelectedThesaurus method creerTradCdt.

public void creerTradCdt() {
    if (candidat.getValueEdit() == null || candidat.getValueEdit().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error5")));
    } else {
        for (NodeTraductionCandidat nt : candidat.getInfoCdt().getNodeTraductions()) {
            if (nt.getIdLang().trim().equals(candidat.getLangueEdit().trim())) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error6")));
                return;
            }
        }
        String temp = candidat.getValueEdit();
        if (!candidat.newTradCdt(thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
            return;
        }
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info4.1") + " " + temp + " " + langueBean.getMsg("theso.info4.2")));
    }
    candidat.setValueEdit("");
    candidat.setLangueEdit("");
}
Also used : NodeTraductionCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat) FacesMessage(javax.faces.application.FacesMessage)

Example 2 with NodeTraductionCandidat

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

the class CandidateHelper method getNodeTraductionCandidat.

/**
 * Permet de retourner une ArrayList de nodeTraductionCandidat par thésaurus
 *
 * @param ds le pool de connexion
 * @param idConcept
 * @param idThesaurus
 * @param idLang
 * @return Objet Class ArrayList nodeTraductionCandidat
 */
public ArrayList<NodeTraductionCandidat> getNodeTraductionCandidat(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeTraductionCandidat> nodeTraductionCandidatList = null;
    String idTermCandidat = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                idTermCandidat = getIdTermOfConceptCandidat(ds, idConcept, idThesaurus);
                String query = "SELECT term_candidat.lexical_value, term_candidat.lang," + " users.username, users.id_user" + " FROM users, term_candidat WHERE" + " term_candidat.contributor = users.id_user" + " and term_candidat.lang != '" + idLang + "'" + " and term_candidat.id_thesaurus = '" + idThesaurus + "'" + " and term_candidat.id_term = '" + idTermCandidat + "'" + " order by users.username ASC";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    nodeTraductionCandidatList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeTraductionCandidat nodeTraductionCandidat = new NodeTraductionCandidat();
                        nodeTraductionCandidat.setIdLang(resultSet.getString("lang"));
                        nodeTraductionCandidat.setTitle(resultSet.getString("lexical_value"));
                        nodeTraductionCandidat.setUseId(resultSet.getInt("id_user"));
                        nodeTraductionCandidat.setUser(resultSet.getString("username"));
                        nodeTraductionCandidatList.add(nodeTraductionCandidat);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Traductions of Candidat : " + idConcept, sqle);
    }
    return nodeTraductionCandidatList;
}
Also used : NodeTraductionCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 3 with NodeTraductionCandidat

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

the class SelectedCandidat method delTradCdt.

/**
 * Supprime la traduction séléctionnée
 *
 * @param langue
 */
public void delTradCdt(String langue) {
    new CandidateHelper().deleteTraductionTermCandidat(connect.getPoolConnexion(), selected.getIdConcept(), langue, idTheso, theUser.getUser().getId());
    for (NodeTraductionCandidat nt : infoCdt.getNodeTraductions()) {
        if (nt.getIdLang().equals(langue)) {
            infoCdt.getNodeTraductions().remove(nt);
        }
    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info3")));
}
Also used : NodeTraductionCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 4 with NodeTraductionCandidat

use of mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat 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)

Aggregations

NodeTraductionCandidat (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat)4 FacesMessage (javax.faces.application.FacesMessage)3 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)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 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1