Search in sources :

Example 46 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class AlignmentHelper method addNewAlignement2.

/**
 * Cette fonction permet d'ajouter un nouvel alignement sur un thésaurus
 * distant pour ce concept
 *
 * @param ds
 * @param author
 * @param conceptTarget
 * @param thesaurusTarget
 * @param uriTarget
 * @param idTypeAlignment
 * @param idConcept
 * @param idThesaurus
 * @return
 */
private boolean addNewAlignement2(HikariDataSource ds, int author, String conceptTarget, String thesaurusTarget, String uriTarget, int idTypeAlignment, String idConcept, String idThesaurus, int id_alignement_source) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    conceptTarget = new StringPlus().convertString(conceptTarget);
    uriTarget = new StringPlus().convertString(uriTarget);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into alignement " + "(author, concept_target, thesaurus_target," + " uri_target, alignement_id_type," + " internal_id_thesaurus, internal_id_concept," + " id_alignement_source)" + " values (" + author + ",'" + conceptTarget + "'" + ",'" + thesaurusTarget + "'" + ",'" + uriTarget + "'" + "," + idTypeAlignment + ",'" + idThesaurus + "'" + ",'" + idConcept + "'," + id_alignement_source + " )";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding external alignement with target : " + uriTarget, sqle);
    }
    return status;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

Example 47 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class CandidateHelper method updatePropositionCandidat.

/**
 * Cette fonction permet de mettre à jour le commentaire d'un candidat, le
 * niveau et le groupe, cette modification est autorisée par propriétaire.
 *
 * @param ds
 * @param idCandidat
 * @param idUser
 * @param idThesaurus
 * @param note
 * @param idConceptParent
 * @param idGroup
 * @return boolean
 */
public boolean updatePropositionCandidat(HikariDataSource ds, String idCandidat, int idUser, String idThesaurus, String note, String idConceptParent, String idGroup) {
    note = new StringPlus().convertString(note);
    Connection conn;
    Statement stmt;
    boolean etat = false;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Update proposition set" + " note = '" + note + "'," + " concept_parent = '" + idConceptParent + "'," + " id_group = '" + idGroup + "'," + " modified = current_date" + " where id_concept = '" + idCandidat + "'" + " and id_thesaurus = '" + idThesaurus + "'" + " and id_user = " + idUser;
                stmt.executeUpdate(query);
                updateDateOfCandidat(conn, idCandidat, idThesaurus);
                etat = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while updating proposition of candidat  : " + idCandidat, sqle);
    }
    return etat;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

Example 48 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class CandidateHelper method addPropositionCandidat.

/**
 * Cette fonction permet de rajouter une proposition de candidat dans la
 * table propositon
 *
 * @param ds
 * @param idConcept
 * @param idUser
 * @param idThesaurus
 * @param note
 * @param idConceptParent
 * @param idGroup
 * @return idConceptCandidat
 */
public boolean addPropositionCandidat(HikariDataSource ds, String idConcept, int idUser, String idThesaurus, String note, String idConceptParent, String idGroup) {
    note = new StringPlus().convertString(note);
    Connection conn;
    Statement stmt;
    boolean status = false;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into proposition " + "(id_concept, id_user," + " id_thesaurus, note, concept_parent," + " id_group)" + " values (" + "'" + idConcept + "'" + "," + idUser + "" + ",'" + idThesaurus + "'" + ",'" + note + "'" + ",'" + idConceptParent + "'" + ",'" + idGroup + "')";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding Proposition Candidat  : " + idConcept, sqle);
    }
    return status;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

Example 49 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class CandidateHelper method addTermCandidat_RollBack.

/**
 * Cette fonction permet de rajouter un term_candidat
 *
 * @param conn
 * @param lexical_value
 * @param idLang
 * @param idThesaurus
 * @param contributor
 * @return idConceptCandidat
 */
public String addTermCandidat_RollBack(Connection conn, String lexical_value, String idLang, String idThesaurus, int contributor) {
    Statement stmt;
    ResultSet resultSet;
    String idTerm = null;
    lexical_value = new StringPlus().convertString(lexical_value);
    try {
        try {
            stmt = conn.createStatement();
            try {
                String query = "select max(id) from term_candidat";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                resultSet.next();
                int idNumerique = resultSet.getInt(1);
                idTerm = "TC_" + (++idNumerique);
                /**
                 * Ajout des informations dans la table Concept
                 */
                query = "Insert into term_candidat " + "(id_term, lexical_value, lang, " + "id_thesaurus, contributor)" + " values (" + "'" + idTerm + "'" + ",'" + lexical_value + "'" + ",'" + idLang + "'" + ",'" + idThesaurus + "'" + "," + contributor + ")";
                stmt.executeUpdate(query);
            } finally {
                stmt.close();
            }
        } finally {
        // conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding Term_candidat  : " + idTerm, sqle);
        idTerm = null;
    }
    return idTerm;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) ResultSet(java.sql.ResultSet)

Example 50 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class GroupHelper method getAutoCompletionOtherGroup.

/**
 * Cette fonction permet de récupérer la liste des domaines sauf celui en
 * cours pour l'autocomplétion
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @param text
 * @param idLang
 * @return Objet class Concept
 */
public List<NodeAutoCompletion> getAutoCompletionOtherGroup(HikariDataSource ds, String idThesaurus, // le Group à ignorer
String idGroup, String idLang, String text) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    List<NodeAutoCompletion> nodeAutoCompletionList = null;
    text = new StringPlus().convertString(text);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT concept_group_label.idgroup," + " concept_group_label.lexicalvalue FROM concept_group_label" + " WHERE " + " concept_group_label.idthesaurus = '" + idThesaurus + "'" + " AND concept_group_label.lang = '" + idLang + "'" + " AND concept_group_label.idgroup != '" + idGroup + "'" + " AND unaccent_string(concept_group_label.lexicalvalue) ILIKE unaccent_string('" + text + "%')" + " ORDER BY concept_group_label.lexicalvalue ASC LIMIT 20";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                nodeAutoCompletionList = new ArrayList<>();
                while (resultSet.next()) {
                    if (resultSet.getRow() != 0) {
                        NodeAutoCompletion nodeAutoCompletion = new NodeAutoCompletion();
                        nodeAutoCompletion.setIdConcept("");
                        nodeAutoCompletion.setTermLexicalValue("");
                        nodeAutoCompletion.setGroupLexicalValue(resultSet.getString("lexicalvalue"));
                        nodeAutoCompletion.setIdGroup(resultSet.getString("idgroup"));
                        nodeAutoCompletionList.add(nodeAutoCompletion);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List of autocompletion of Text : " + text, sqle);
    }
    return nodeAutoCompletionList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Aggregations

StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)80 SQLException (java.sql.SQLException)63 Statement (java.sql.Statement)63 Connection (java.sql.Connection)56 ResultSet (java.sql.ResultSet)30 PreparedStatement (java.sql.PreparedStatement)19 ArrayList (java.util.ArrayList)12 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)6 NodeSearch (mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)6 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)4 FacesMessage (javax.faces.application.FacesMessage)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)2 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)2 NodePermute (mom.trd.opentheso.bdd.helper.nodes.NodePermute)2 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)2 PrefixString (com.k_int.IR.QueryModels.PrefixString)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 DcElement (fr.mom.arkeo.soap.DcElement)1