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