Search in sources :

Example 41 with StringPlus

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

the class CandidateHelper method addPropositionCandidat_RollBack.

/**
 * Cette fonction permet de rajouter une proposition de candidat dans la
 * table propositon
 *
 * @param conn
 * @param idConcept
 * @param idUser
 * @param idThesaurus
 * @param note
 * @param idConceptParent
 * @param idGroup
 * @return idConceptCandidat
 */
public boolean addPropositionCandidat_RollBack(Connection conn, String idConcept, int idUser, String idThesaurus, String note, String idConceptParent, String idGroup) {
    note = new StringPlus().convertString(note);
    Statement stmt;
    boolean status = false;
    try {
        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);
                updateDateOfCandidat(conn, idConcept, idThesaurus);
                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)

Example 42 with StringPlus

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

the class CandidateHelper method isCandidatExist_rollBack.

/**
 * Cette fonction permet de savoir si le Candidat existe ou non
 *
 * @param conn
 * @param title
 * @param idThesaurus
 * @param idLang
 * @return boolean
 */
public boolean isCandidatExist_rollBack(Connection conn, String title, String idThesaurus, String idLang) {
    Statement stmt;
    ResultSet resultSet;
    boolean existe = false;
    StringPlus stringPlus = new StringPlus();
    title = stringPlus.addQuotes(title);
    try {
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_term from term_candidat where " + "unaccent_string(lexical_value) ilike " + "unaccent_string('" + title + "')  and lang = '" + idLang + "' and id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    resultSet.next();
                    if (resultSet.getRow() == 0) {
                        existe = false;
                    } else {
                        existe = true;
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
        // conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while asking if Title of Candidat 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) ResultSet(java.sql.ResultSet)

Example 43 with StringPlus

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

the class CandidateHelper method isCandidatExist.

/**
 * Cette fonction permet de savoir si le Candidat existe ou non
 *
 * @param ds
 * @param title
 * @param idThesaurus
 * @param idLang
 * @return boolean
 */
public boolean isCandidatExist(HikariDataSource ds, String title, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    boolean existe = false;
    StringPlus stringPlus = new StringPlus();
    title = stringPlus.addQuotes(title);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_term from term_candidat where " + "unaccent_string(lexical_value) ilike " + "unaccent_string('" + title + "')  and lang = '" + idLang + "' and id_thesaurus = '" + 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 Candidat 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)

Example 44 with StringPlus

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

the class SelectedTerme method ajouterAlignAutoByLot.

/**
 * Permet de creer une alignement, cette funtion s'utilise pour l'alignement
 * par lot l'apelation de la funtion c'est de AlignementParLotBean
 *
 * @param nodeAlignment
 * @return
 */
public boolean ajouterAlignAutoByLot(NodeAlignment nodeAlignment, boolean addDefinition, String id_term) {
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    NoteHelper noteHelper = new NoteHelper();
    if (!alignmentHelper.addNewAlignment(connect.getPoolConnexion(), user.getUser().getId(), nodeAlignment.getConcept_target(), nodeAlignment.getThesaurus_target(), nodeAlignment.getUri_target(), nodeAlignment.getAlignement_id_type(), nodeAlignment.getInternal_id_concept(), idTheso, alignementSource.getId())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Notation Error BDD")));
        return false;
    }
    if (addDefinition) {
        StringPlus stringPlus = new StringPlus();
        String dejaBonString = stringPlus.clearAngles(nodeAlignment.getDef_target());
        if (!noteHelper.addTermNote(connect.getPoolConnexion(), id_term, idlangue, idTheso, dejaBonString, "definition", user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Notation Error BDD")));
            return false;
        }
    }
    messageAlig = alignmentHelper.getMessage();
    return true;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) PrefixString(com.k_int.IR.QueryModels.PrefixString) FacesMessage(javax.faces.application.FacesMessage)

Example 45 with StringPlus

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

the class SelectedThesaurus method creerCandidat.

/**
 * Création d'un nouveau candidat avec vérification de la valeur en entrée
 */
public List<NodeCandidatValue> creerCandidat() {
    if (candidat.getValueEdit() == null || candidat.getValueEdit().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error2")));
    } else if (new CandidateHelper().isCandidatExist(connect.getPoolConnexion(), candidat.getValueEdit(), thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error3")));
        vue.setAddCandidat(false);
        String idCandidat = new CandidateHelper().getIdCandidatFromTitle(connect.getPoolConnexion(), new StringPlus().addQuotes(candidat.getValueEdit().trim()), thesaurus.getId_thesaurus());
        if (idCandidat == null) {
            cleanEditCandidat();
            return null;
        } else {
            candidat.getSelected().setIdConcept(idCandidat);
            vue.setAddPropCandidat(true);
            // creerPropCdt();
            return null;
        }
    } else if (new TermHelper().isTermExist(connect.getPoolConnexion(), candidat.getValueEdit(), thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error4")));
    } else {
        String temp = candidat.getValueEdit();
        if (!candidat.newCandidat(thesaurus.getId_thesaurus(), thesaurus.getLanguage())) {
            return null;
        }
        vue.setAddCandidat(false);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info2.1") + " " + temp + " " + langueBean.getMsg("theso.info2.2")));
    }
    cleanEditCandidat();
    List<NodeCandidatValue> candidats = new ArrayList<>();
    if (thesaurus.getId_thesaurus() != null && thesaurus.getLanguage() != null && connect.getPoolConnexion() != null) {
        candidats = new CandidateHelper().getListCandidatsWaiting(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
    }
    return candidats;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NodeCandidatValue(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue) ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

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