Search in sources :

Example 1 with NodeCandidatValue

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

the class CandidateHelper method getThisCandidatList.

/**
 * $$$$$$$ deprecated $$$$$$$ Cette fonction permet de récupérer la liste
 * des candidats
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param idLang
 * @return Objet class NodeCandidatValue
 */
public NodeCandidatValue getThisCandidatList(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    NodeCandidatValue nodeCandidatList = null;
    if (isTraductionExistOfCandidat(ds, idConcept, idThesaurus, idLang)) {
        try {
            // Get connection from pool
            conn = ds.getConnection();
            try {
                stmt = conn.createStatement();
                try {
                    String query = "SELECT DISTINCT term_candidat.lexical_value," + " concept_candidat.status FROM" + " term_candidat, concept_term_candidat, concept_candidat" + " WHERE concept_term_candidat.id_term = term_candidat.id_term" + " and concept_term_candidat.id_concept = concept_candidat.id_concept" + " and concept_term_candidat.id_concept ='" + idConcept + "'" + " and term_candidat.lang = '" + idLang + "'" + " and term_candidat.id_thesaurus = '" + idThesaurus + "'" + " order by lexical_value DESC";
                    stmt.executeQuery(query);
                    resultSet = stmt.getResultSet();
                    if (resultSet != null) {
                        while (resultSet.next()) {
                            nodeCandidatList = new NodeCandidatValue();
                            nodeCandidatList.setValue(resultSet.getString("lexical_value"));
                            nodeCandidatList.setIdConcept(idConcept);
                            nodeCandidatList.setEtat(resultSet.getString("status"));
                            nodeCandidatList.setNbProp(getNbPropCandidat(ds, idThesaurus, idConcept));
                        }
                    }
                } finally {
                    stmt.close();
                }
            } finally {
                conn.close();
            }
        } catch (SQLException sqle) {
            // Log exception
            log.error("Error while getting Concept : " + idConcept, sqle);
        }
    } else {
        try {
            // Get connection from pool
            conn = ds.getConnection();
            try {
                stmt = conn.createStatement();
                try {
                    String query = "SELECT concept_candidat.id_concept," + " concept_candidat.status FROM" + " concept_candidat" + " WHERE concept_candidat.id_concept ='" + idConcept + "'" + " and concept_candidat.id_thesaurus = '" + idThesaurus + "'";
                    stmt.executeQuery(query);
                    resultSet = stmt.getResultSet();
                    if (resultSet != null) {
                        while (resultSet.next()) {
                            nodeCandidatList = new NodeCandidatValue();
                            nodeCandidatList.setValue("");
                            nodeCandidatList.setIdConcept(idConcept);
                            nodeCandidatList.setEtat(resultSet.getString("status"));
                            nodeCandidatList.setNbProp(getNbPropCandidat(ds, idThesaurus, idConcept));
                        }
                    }
                } finally {
                    stmt.close();
                }
            } finally {
                conn.close();
            }
        } catch (SQLException sqle) {
            // Log exception
            log.error("Error while getting Concept : " + idConcept, sqle);
        }
    }
    return nodeCandidatList;
}
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)

Example 2 with NodeCandidatValue

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

the class CandidateHelper method getListCandidatsWaiting.

/**
 * Permet de retourner une ArrayList de NodeConceptCandidat par thésaurus,
 * 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 le pool de connexion
 * @param idThesaurus
 * @param idLang
 * @return Objet Class ArrayList NodeCandidatValue
 */
public ArrayList<NodeCandidatValue> getListCandidatsWaiting(HikariDataSource ds, String idThesaurus, String idLang) {
    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 id_concept from concept_candidat where id_thesaurus = '" + idThesaurus + "'" + " and status ='a' order by modified DESC";
                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 3 with NodeCandidatValue

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

the class CandidateHelper method getListCandidatsValidated.

/**
 * Permet de retourner une ArrayList de NodeConceptCandidat par thésaurus,
 * c'est la liste des candidats validé mais pas encore insérré dans les
 * thésaurus (status = v) 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 le pool de connexion
 * @param idThesaurus
 * @param idLang
 * @return Objet Class ArrayList NodeCandidatValue
 */
public ArrayList<NodeCandidatValue> getListCandidatsValidated(HikariDataSource ds, String idThesaurus, String idLang) {
    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 id_concept from concept_candidat where id_thesaurus = '" + idThesaurus + "' and status = 'v' " + "order by modified DESC";
                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("v");
                    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 4 with NodeCandidatValue

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

the class CandidateHelper method getListCandidatsArchives.

/**
 * Permet de retourner une ArrayList de NodeConceptCandidat par thésaurus,
 * c'est la liste des candidats archivés tous les status sauf a et v (a=attente, v=validé)
 * v=validé,i=insérré,r=refusé) 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 le pool de connexion
 * @param idThesaurus
 * @param idLang
 * @return Objet Class ArrayList NodeCandidatValue
 */
public ArrayList<NodeCandidatValue> getListCandidatsArchives(HikariDataSource ds, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeCandidatValue> nodeCandidatLists = null;
    ArrayList tabIdConcept = new ArrayList();
    ArrayList tabStatus = new ArrayList();
    NodeCandidatValue nodeCandidatValue = new NodeCandidatValue();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_concept, status from concept_candidat where id_thesaurus = '" + idThesaurus + "' and status != 'a' and status != 'v'" + " order by modified DESC";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    tabIdConcept.add(resultSet.getString("id_concept"));
                    tabStatus.add(resultSet.getString("status"));
                }
                nodeCandidatLists = new ArrayList<>();
                int i = 0;
                for (Object tabIdConcept1 : tabIdConcept) {
                    nodeCandidatValue = getThisCandidat(ds, tabIdConcept1.toString(), idThesaurus, idLang);
                    if (nodeCandidatValue == null) {
                        return null;
                    }
                    nodeCandidatValue.setEtat(tabStatus.get(i++).toString());
                    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 5 with NodeCandidatValue

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

the class CandidateHelper method getThisCandidat.

/**
 * Cette fonction permet de récupérer un candidat avec sa traduction, sinon,
 * son identifiant
 *
 * @param ds
 * @param idCandidat
 * @param idThesaurus
 * @param idLang
 * @return Objet class NodeCandidatValue
 */
public NodeCandidatValue getThisCandidat(HikariDataSource ds, String idCandidat, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    NodeCandidatValue nodeCandidatList = null;
    // if(isTraductionExistOfCandidat(ds, idConcept, idThesaurus, idLang)) {
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT term_candidat.lexical_value" + " FROM concept_term_candidat, term_candidat" + " WHERE concept_term_candidat.id_term = term_candidat.id_term" + " AND concept_term_candidat.id_concept = '" + idCandidat + "'" + " AND term_candidat.lang = '" + idLang + "'" + " AND term_candidat.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet.next()) {
                    nodeCandidatList = new NodeCandidatValue();
                    nodeCandidatList.setValue(resultSet.getString("lexical_value").trim());
                    nodeCandidatList.setIdConcept(idCandidat);
                } else {
                    nodeCandidatList = new NodeCandidatValue();
                    nodeCandidatList.setValue("");
                    nodeCandidatList.setIdConcept(idCandidat);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Concept : " + idCandidat, sqle);
    }
    /*        }
        else {
            try {
            // Get connection from pool
                conn = ds.getConnection();
                try {
                    stmt = conn.createStatement();
                    try {
                        String query = "SELECT concept_candidat.id_concept,"
                                + " concept_candidat.status FROM"
                                + " concept_candidat" 
                                + " WHERE concept_candidat.id_concept ='" + idConcept +"'"
                                + " and concept_candidat.id_thesaurus = '" + idThesaurus + "'";

                        stmt.executeQuery(query);
                        resultSet = stmt.getResultSet();
                        if (resultSet != null) {
                            while(resultSet.next()) {
                                nodeCandidatList = new NodeCandidatValue();
                                nodeCandidatList.setValue("");
                                nodeCandidatList.setIdConcept(idConcept);
                                nodeCandidatList.setEtat(resultSet.getString("status"));
                                nodeCandidatList.setNbProp(getNbPropCandidat(ds,idThesaurus,idConcept));
                            }
                        }

                    } finally {
                        stmt.close();
                    }
                } finally {
                    conn.close();
                }
            } catch (SQLException sqle) {
                // Log exception
                log.error("Error while getting Concept : " + idConcept, sqle);
            }
            
        }*/
    return nodeCandidatList;
}
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)

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