Search in sources :

Example 51 with StringPlus

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

the class GroupHelper method getAutoCompletionGroup.

/**
 * Cette fonction permet de récupérer la liste des domaines pour
 * l'autocomplétion
 *
 * @param ds
 * @param idThesaurus
 * @param text
 * @param idLang
 * @return Objet class Concept
 */
public List<NodeAutoCompletion> getAutoCompletionGroup(HikariDataSource ds, String idThesaurus, 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 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)

Example 52 with StringPlus

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

the class GroupHelper method addGroupTraductionHistorique.

/**
 * Cette fonction permet de rajouter une traduction de domaine en historique
 *
 * @param ds
 * @param conceptGroupLabel
 * @param idUser
 * @return
 */
public boolean addGroupTraductionHistorique(HikariDataSource ds, ConceptGroupLabel conceptGroupLabel, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    conceptGroupLabel.setLexicalvalue(new StringPlus().convertString(conceptGroupLabel.getLexicalvalue()));
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into concept_group_label_historique " + "(lexicalvalue,lang, idthesaurus, idgroup, id_user)" + "values (" + "'" + conceptGroupLabel.getLexicalvalue() + "'" + ",'" + conceptGroupLabel.getLang() + "'" + ",'" + conceptGroupLabel.getIdthesaurus() + "'" + ",'" + conceptGroupLabel.getIdgroup() + "'" + ",'" + idUser + "'" + ")";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding traduction to ConceptGroupLabel : " + conceptGroupLabel.getIdgroup(), 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 53 with StringPlus

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

the class GroupHelper method addGroupHistorique.

/**
 * Cette fonction permet d'ajouter un group (MT, domaine etc..) avec le
 * libellé dans l'historique
 *
 * @param ds
 * @param nodeConceptGroup
 * @param urlSite
 * @param idArk
 * @param idUser
 * @param idConceptGroup
 * @return
 */
public int addGroupHistorique(HikariDataSource ds, NodeGroup nodeConceptGroup, String urlSite, String idArk, int idUser, String idConceptGroup) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    nodeConceptGroup.setLexicalValue(new StringPlus().convertString(nodeConceptGroup.getLexicalValue()));
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into concept_group_historique " + "(idgroup, id_ark, idthesaurus, idtypecode, idparentgroup, notation, idconcept, id_user)" + "values (" + "'" + idConceptGroup + "'" + ",'" + idArk + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdthesaurus() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdtypecode() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdparentgroup() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getNotation() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdconcept() + "'" + ",'" + idUser + "'" + ")";
                stmt.executeUpdate(query);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding ConceptGroup : " + nodeConceptGroup.getConceptGroup().getId(), sqle);
    }
    return nodeConceptGroup.getConceptGroup().getId();
}
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)

Example 54 with StringPlus

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

the class GroupHelper method updateConceptGroupLabel.

/**
 * Permet de mettre à jour un Domaine suivant un identifiant un thésaurus et
 * une langue donnés
 *
 * @param ds
 * @param conceptGroupLabel
 * @param idUser
 * @return true or false
 */
public boolean updateConceptGroupLabel(HikariDataSource ds, ConceptGroupLabel conceptGroupLabel, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    conceptGroupLabel.setLexicalvalue(new StringPlus().convertString(conceptGroupLabel.getLexicalvalue()));
    /**
     * On met à jour tous les chmamps saufs l'idThesaurus, la date de
     * creation en utilisant et la langue
     */
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "UPDATE concept_group_label " + "set lexicalvalue='" + conceptGroupLabel.getLexicalvalue() + "'," + " modified = current_date" + " WHERE lang ='" + conceptGroupLabel.getLang() + "'" + " AND idthesaurus='" + conceptGroupLabel.getIdthesaurus() + "'" + " AND idgroup ='" + conceptGroupLabel.getIdgroup() + "'";
                stmt.executeUpdate(query);
                status = true;
                addGroupTraductionHistorique(ds, conceptGroupLabel, idUser);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while updating ConceptGroupLable : " + conceptGroupLabel.getLexicalvalue() + " lang = " + conceptGroupLabel.getLang(), 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 55 with StringPlus

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

the class GroupHelper method isDomainExist.

/**
 * Cette fonction permet de savoir si le Domaine existe dans cette langue
 *
 * @param ds
 * @param title
 * @param idThesaurus
 * @param idLang
 * @return boolean
 */
public boolean isDomainExist(HikariDataSource ds, String title, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    boolean existe = false;
    title = new StringPlus().convertString(title);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select idgroup from concept_group_label where " + "unaccent_string(lexicalvalue) ilike " + "unaccent_string('" + title + "')  and lang = '" + idLang + "' and idthesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet.next()) {
                    existe = resultSet.getRow() != 0;
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while asking if Title of Term exist : " + title, sqle);
    }
    return existe;
}
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)

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