Search in sources :

Example 6 with NodeCandidatValue

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

the class SelectedCandidat method initSelectedCandidat.

@PostConstruct
public void initSelectedCandidat() {
    selected = new NodeCandidatValue();
    selected.setEtat("");
    selected.setIdConcept("");
    selected.setValue("");
    selected.setNbProp(0);
    infoCdt = new NodeCandidat();
    infoCdt.setNodesUser(new ArrayList<>());
    infoCdt.setNodeTraductions(new ArrayList<>());
    selectedNvx = new NodeAutoCompletion();
    tradInsert = new ArrayList<>();
    setPreferences();
    nomsProp = new ArrayList<>();
}
Also used : NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) NodeCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidat) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion) PostConstruct(javax.annotation.PostConstruct)

Example 7 with NodeCandidatValue

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

the class SelectedCandidat method reInit.

/**
 * Réinitialise le candidat (tout est vide)
 */
public void reInit() {
    selected = new NodeCandidatValue();
    selected.setEtat("");
    selected.setIdConcept("");
    selected.setValue("");
    selected.setNbProp(0);
    infoCdt = new NodeCandidat();
    infoCdt.setNodesUser(new ArrayList<>());
    infoCdt.setNodeTraductions(new ArrayList<>());
    selectedNvx = new NodeAutoCompletion();
    note = "";
    niveau = "";
    domaine = "";
    nomsProp = new ArrayList<>();
}
Also used : NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) NodeCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidat) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 8 with NodeCandidatValue

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

the class SelectedThesaurus method creerCandidat.

/**
 * Création d'un nouveau candidat avec vérification de la valeur en entrée
 */
public List<NodeCandidatValue> creerCandidat() {
    if (candidat.getValueEdit() == null || candidat.getValueEdit().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error2")));
    } else if (new CandidateHelper().isCandidatExist(connect.getPoolConnexion(), candidat.getValueEdit(), thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error3")));
        vue.setAddCandidat(false);
        String idCandidat = new CandidateHelper().getIdCandidatFromTitle(connect.getPoolConnexion(), new StringPlus().addQuotes(candidat.getValueEdit().trim()), thesaurus.getId_thesaurus());
        if (idCandidat == null) {
            cleanEditCandidat();
            return null;
        } else {
            candidat.getSelected().setIdConcept(idCandidat);
            vue.setAddPropCandidat(true);
            // creerPropCdt();
            return null;
        }
    } else if (new TermHelper().isTermExist(connect.getPoolConnexion(), candidat.getValueEdit(), thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error4")));
    } else {
        String temp = candidat.getValueEdit();
        if (!candidat.newCandidat(thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
            return null;
        }
        vue.setAddCandidat(false);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info2.1") + " " + temp + " " + langueBean.getMsg("theso.info2.2")));
    }
    cleanEditCandidat();
    List<NodeCandidatValue> candidats = new ArrayList<>();
    if (thesaurus.getId_thesaurus() != null && thesaurus.getLanguage() != null && connect.getPoolConnexion() != null) {
        candidats = new CandidateHelper().getListCandidatsWaiting(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
    }
    return candidats;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 9 with NodeCandidatValue

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

the class CandidateHelper method getListMyCandidatsWait.

/**
 * Permet de retourner une ArrayList de NodeConceptCandidat par thésaurus et
 * par id_user c'est la liste des candidats en attente (status = a) Si le
 * Candidat n'est pas traduit dans la langue en cours, on récupère
 * l'identifiant pour l'afficher à la place
 *
 * @param ds
 * @param idThesaurus
 * @param idLang
 * @param id_user
 * @return
 */
public ArrayList<NodeCandidatValue> getListMyCandidatsWait(HikariDataSource ds, String idThesaurus, String idLang, Integer id_user) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeCandidatValue> nodeCandidatLists = null;
    ArrayList tabIdConcept = new ArrayList();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select concept_candidat.id_concept from concept_candidat, proposition" + " where concept_candidat.id_concept = proposition.id_concept and" + " concept_candidat.id_thesaurus= proposition.id_thesaurus" + " and proposition.id_user =" + id_user + " and proposition.id_thesaurus ='" + idThesaurus + "' and concept_candidat.status='a'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    tabIdConcept.add(resultSet.getString("id_concept"));
                }
                nodeCandidatLists = new ArrayList<>();
                for (Object tabIdConcept1 : tabIdConcept) {
                    NodeCandidatValue nodeCandidatValue;
                    nodeCandidatValue = getThisCandidat(ds, tabIdConcept1.toString(), idThesaurus, idLang);
                    if (nodeCandidatValue == null) {
                        return null;
                    }
                    nodeCandidatValue.setEtat("a");
                    nodeCandidatValue.setNbProp(getNbPropCandidat(ds, idThesaurus, tabIdConcept1.toString()));
                    nodeCandidatLists.add(nodeCandidatValue);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List Group or Domain of thesaurus : " + idThesaurus, sqle);
    }
    return nodeCandidatLists;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) ArrayList(java.util.ArrayList)

Example 10 with NodeCandidatValue

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

the class SearchCandidatBean method getTextSearchIn.

private List<NodeCandidatValue> getTextSearchIn(List<NodeCandidatValue> candidats, String textSearch) {
    textSearch = (textSearch.isEmpty() ? "" : textSearch);
    List<NodeCandidatValue> ret = new ArrayList<>();
    for (NodeCandidatValue cdt : candidats) {
        if (cdt.getValue().matches(".*" + textSearch + ".*")) {
            ret.add(cdt);
        }
    }
    return ret;
}
Also used : NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) ArrayList(java.util.ArrayList)

Aggregations

NodeCandidatValue (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue)10 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 Statement (java.sql.Statement)6 ArrayList (java.util.ArrayList)6 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)2 NodeCandidat (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidat)2 PostConstruct (javax.annotation.PostConstruct)1 FacesMessage (javax.faces.application.FacesMessage)1 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)1