Search in sources :

Example 56 with StringPlus

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

the class GroupHelper method addGroup.

/**
 * Cette fonction permet d'ajouter un group (MT, domaine etc..) avec le
 * libellé
 *
 * @param ds
 * @param nodeConceptGroup
 * @param urlSite
 * @param isArkActive
 * @param idUser
 * @return
 */
public String addGroup(HikariDataSource ds, NodeGroup nodeConceptGroup, String urlSite, boolean isArkActive, int idUser) {
    // "ark:/66666/srvq9a5Ll41sk";
    String idConceptGroup = "";
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    nodeConceptGroup.setLexicalValue(new StringPlus().convertString(nodeConceptGroup.getLexicalValue()));
    if (nodeConceptGroup.getConceptGroup().getNotation() == null) {
        nodeConceptGroup.getConceptGroup().setNotation("");
    }
    // à faire
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select max(id) from concept_group";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                resultSet.next();
                int idNumeriqueGroup = resultSet.getInt(1);
                idConceptGroup = nodeConceptGroup.getConceptGroup().getIdtypecode() + ++idNumeriqueGroup;
                /**
                 * récupération du code Ark via WebServices
                 */
                String idArk = "";
                if (isArkActive) {
                    ArrayList<DcElement> dcElementsList = new ArrayList<>();
                    ArkClient ark_Client = new ArkClient();
                    idArk = ark_Client.getArkId(new FileUtilities().getDate(), urlSite + "?idg=" + idConceptGroup + "&idt=" + nodeConceptGroup.getConceptGroup().getIdthesaurus(), "", "", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
                    "pcrt");
                }
                /**
                 * Ajout des informations dans la table de ConceptGroup
                 */
                query = "Insert into concept_group values (" + "'" + idConceptGroup + "'" + ",'" + idArk + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdthesaurus() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdtypecode() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getNotation() + "'" + ")";
                stmt.executeUpdate(query);
                ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
                conceptGroupLabel.setIdgroup(idConceptGroup);
                conceptGroupLabel.setIdthesaurus(nodeConceptGroup.getConceptGroup().getIdthesaurus());
                conceptGroupLabel.setLang(nodeConceptGroup.getIdLang());
                conceptGroupLabel.setLexicalvalue(nodeConceptGroup.getLexicalValue());
                addGroupTraduction(ds, conceptGroupLabel, idUser);
                addGroupHistorique(ds, nodeConceptGroup, urlSite, idArk, idUser, idConceptGroup);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding ConceptGroup : " + idConceptGroup, sqle);
    }
    return idConceptGroup;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) ResultSet(java.sql.ResultSet) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Example 57 with StringPlus

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

the class GroupHelper method addGroupTraduction.

/**
 * Cette fonction permet de rajouter une traduction de domaine
 *
 * @param ds
 * @param conceptGroupLabel
 * @param idUser
 * @return
 */
public boolean addGroupTraduction(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 " + "(lexicalvalue, created, modified,lang, idthesaurus, idgroup)" + "values (" + "'" + conceptGroupLabel.getLexicalvalue() + "'" + ",current_date" + ",current_date" + ",'" + conceptGroupLabel.getLang() + "'" + ",'" + conceptGroupLabel.getIdthesaurus() + "'" + ",'" + 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 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 58 with StringPlus

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

the class NoteHelper method addConceptNoteRollback.

/**
 * Cette fonction permet d'ajouter une Note à un concept instert dans la
 * table Note
 *
 * @param ds
 * @param idConcept
 * @param idLang
 * @param idThesausus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
private boolean addConceptNoteRollback(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 {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into note " + "(notetypecode, id_thesaurus, id_concept, lang, lexicalvalue)" + " values (" + "'" + noteTypeCode + "'" + ",'" + idThesausus + "'" + ",'" + idConcept + "'" + ",'" + 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 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 59 with StringPlus

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

the class NoteHelper method updateConceptNote.

/**
 * Cette fonction permet de mettre à jour une note de Concept
 *
 * @param ds
 * @param idConcept
 * @param idLang
 * @param idThesaurus
 * @param note
 * @param noteTypeCode
 * @param idUser
 * @return
 */
public boolean updateConceptNote(HikariDataSource ds, String idConcept, 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 = "UPDATE note set" + " lexicalvalue = '" + note + "'," + " modified = current_date" + " WHERE lang ='" + idLang + "'" + " AND id_thesaurus = '" + idThesaurus + "'" + " AND id_concept = '" + idConcept + "'" + " 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 Concept : " + idConcept, sqle);
    }
    addConceptNoteHistorique(ds, idConcept, 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)

Example 60 with StringPlus

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

the class NoteHelper method getListNotesTermAllLang.

/**
 * Cette focntion permet de retourner la liste des notes pour un Term(type
 * HistoryNote, Definition, EditotrialNote) dans toutes les langues
 *
 * @param ds
 * @param idThesaurus
 * @param idTerm
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getListNotesTermAllLang(HikariDataSource ds, String idTerm, 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.isterm = true" + " and note.id_term = '" + idTerm + "'" + " and note.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeNote nodeNote = new NodeNote();
                    nodeNote.setId_term(idTerm);
                    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 Term : " + idTerm, 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)

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