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