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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations