Search in sources :

Example 11 with StringPlus

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

the class NoteHelper method updateTermNote.

/**
 * Cette fonction permet de mettre à jour une note de Concept
 *
 * @param ds
 * @param idTerm
 * @param idLang
 * @param idThesausus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
public boolean updateTermNote(HikariDataSource ds, String idTerm, String idLang, String idThesausus, String note, String noteTypeCode, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    note = new StringPlus().convertString(note);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "UPDATE note set" + " lexicalvalue = '" + note + "'," + " modified = current_date" + " WHERE lang ='" + idLang + "'" + " AND id_thesaurus = '" + idThesausus + "'" + " AND id_term = '" + idTerm + "'" + " AND notetypecode = '" + noteTypeCode + "'";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while updating Note of Term : " + idTerm, sqle);
    }
    addTermNoteHistorique(ds, idTerm, idLang, idThesausus, note, noteTypeCode, idUser);
    return status;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

Example 12 with StringPlus

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

the class NoteHelper method getListNotesConceptAllLang.

/**
 * Cette focntion permet de retourner la liste des notes pour un concept
 * (type CustomNote, ScopeNote, HistoryNote) avec toutes les langues
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getListNotesConceptAllLang(HikariDataSource ds, String idConcept, String idThesaurus) {
    ArrayList<NodeNote> nodeNotes = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    StringPlus stringPlus = new StringPlus();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT note.id, note.notetypecode," + " note.lexicalvalue, note.created," + " note.modified, note.lang FROM note, note_type" + " WHERE note.notetypecode = note_type.code" + " and note_type.isconcept = true" + " and note.id_concept = '" + idConcept + "'" + " and note.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeNote nodeNote = new NodeNote();
                    nodeNote.setId_concept(idConcept);
                    nodeNote.setId_note(resultSet.getInt("id"));
                    nodeNote.setLang(resultSet.getString("lang"));
                    nodeNote.setLexicalvalue(stringPlus.normalizeStringForXml(resultSet.getString("lexicalvalue")));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    nodeNotes.add(nodeNote);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Notes of Concept : " + idConcept, sqle);
    }
    return nodeNotes;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 13 with StringPlus

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

the class NoteHelper method addTermNoteHistorique.

/**
 * Cette fonction permet d'ajouter l'historique de l'ajout d'une Note à un
 * term insert dans la table Note_hisorique
 *
 * @param ds
 * @param idTerme
 * @param idLang
 * @param idThesausus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
public boolean addTermNoteHistorique(HikariDataSource ds, String idTerme, String idLang, String idThesausus, String note, String noteTypeCode, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    note = new StringPlus().convertString(note);
    try {
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into note_historique " + "(notetypecode, id_thesaurus, id_term, lang, lexicalvalue, id_user)" + " values (" + "'" + noteTypeCode + "'" + ",'" + idThesausus + "'" + ",'" + idTerme + "'" + ",'" + idLang + "'" + ",'" + note + "'" + ",'" + idUser + "')";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        log.error("Error while adding Note historique of term : " + idTerme, 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 14 with StringPlus

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

the class NoteHelper method addConceptNoteHistorique.

/**
 * Cette fonction permet d'ajouter l'historique de l'ajout d'une Note à un
 * concept insert dans la table Note_hisorique
 *
 * @param ds
 * @param idConcept
 * @param idLang
 * @param idThesausus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
public boolean addConceptNoteHistorique(HikariDataSource ds, String idConcept, String idLang, String idThesausus, String note, String noteTypeCode, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    note = new StringPlus().convertString(note);
    try {
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into note_historique " + "(notetypecode, id_thesaurus, id_concept, lang, lexicalvalue, id_user)" + " values (" + "'" + noteTypeCode + "'" + ",'" + idThesausus + "'" + ",'" + idConcept + "'" + ",'" + idLang + "'" + ",'" + note + "'" + ",'" + idUser + "')";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        log.error("Error while adding Note historique of concept : " + idConcept, 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 15 with StringPlus

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

the class NoteHelper method addTermNote.

/**
 * Cette fonction permet d'ajouter une Note à un Term instert dans la table
 * Note
 *
 * @param ds
 * @param idTerm
 * @param idLang
 * @param idThesaurus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
public boolean addTermNote(HikariDataSource ds, String idTerm, String idLang, String idThesaurus, String note, String noteTypeCode, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    note = new StringPlus().convertString(note);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into note " + "(notetypecode, id_thesaurus, id_term, lang, lexicalvalue)" + " values (" + "'" + noteTypeCode + "'" + ",'" + idThesaurus + "'" + ",'" + idTerm + "'" + ",'" + idLang + "'" + ",'" + note + "')";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding Note of Term : " + idTerm, sqle);
    }
    addTermNoteHistorique(ds, idTerm, idLang, idThesaurus, note, noteTypeCode, idUser);
    return status;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

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