use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class NewRestJson method openConnexionPool.
private HikariDataSource openConnexionPool(Properties properties) {
HikariConfig config = new HikariConfig();
config.setMinimumIdle(Integer.parseInt(properties.getProperty("minimumIdle")));
config.setMaximumPoolSize(Integer.parseInt(properties.getProperty("setMaximumPoolSize")));
config.setAutoCommit(true);
config.setIdleTimeout(Integer.parseInt(properties.getProperty("idleTimeout")));
config.setConnectionTimeout(Integer.parseInt(properties.getProperty("connectionTimeout")));
config.setConnectionTestQuery(properties.getProperty("connectionTestQuery"));
config.setDataSourceClassName(properties.getProperty("dataSourceClassName"));
config.addDataSourceProperty("user", properties.getProperty("dataSource.user"));
config.addDataSourceProperty("password", properties.getProperty("dataSource.password"));
config.addDataSourceProperty("databaseName", properties.getProperty("dataSource.databaseName"));
config.addDataSourceProperty("serverName", properties.getProperty("dataSource.serverName"));
config.addDataSourceProperty("portNumber", properties.getProperty("dataSource.serverPort"));
HikariDataSource poolConnexion1 = new HikariDataSource(config);
try {
Connection conn = poolConnexion1.getConnection();
if (conn == null) {
return null;
}
conn.close();
} catch (SQLException ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getClass().getName(), ex.getMessage());
FacesContext.getCurrentInstance().addMessage(null, message);
poolConnexion1.close();
return null;
}
return poolConnexion1;
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class SelectedTerme method creerTermeSpe.
/**
* *************************************** CREATION
* ****************************************
*/
/**
* Crée un nouveau terme spécifique au terme sélectionné
*
* @param selecedTerm
* @return true or false
*/
public boolean creerTermeSpe(MyTreeNode selecedTerm) {
ConceptHelper instance = new ConceptHelper();
if (user.nodePreference == null)
return false;
instance.setNodePreference(user.getNodePreference());
// 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
if (selecedTerm.isIsSubGroup() || selecedTerm.isIsGroup()) {
// ici c'est le cas d'un Group ou Sous Group, on crée un TT Top Terme
Concept concept = new Concept();
concept.setIdGroup(selecedTerm.getIdConcept());
concept.setIdThesaurus(idTheso);
concept.setStatus("D");
concept.setNotation("");
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(idlangue);
terme.setLexical_value(valueEdit);
terme.setSource("");
terme.setStatus("");
if (instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, user.getUser().getId()) == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
return false;
}
// instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
ConceptHelper ch = new ConceptHelper();
ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue);
termesSpecifique = new ArrayList<>();
HashMap<String, String> tempMap = new HashMap<>();
for (NodeConceptTree nct : tempNT) {
tempMap.put(nct.getIdConcept(), nct.getTitle());
}
termesSpecifique.addAll(tempMap.entrySet());
} else {
Concept concept = new Concept();
concept.setIdGroup(selecedTerm.getIdCurrentGroup());
concept.setIdThesaurus(idTheso);
concept.setStatus("D");
concept.setNotation("");
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(idlangue);
terme.setLexical_value(valueEdit);
terme.setSource("");
terme.setStatus("");
// String idTC = idTopConcept;
String idP = idC;
if (instance.addConcept(connect.getPoolConnexion(), idP, concept, terme, user.getUser().getId()) == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
return false;
}
// instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
concept.getUserName();
ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
termesSpecifique = new ArrayList<>();
HashMap<String, String> tempMap = new HashMap<>();
for (NodeNT nnt : tempNT) {
tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
}
termesSpecifique.addAll(tempMap.entrySet());
}
vue.setAddTSpe(false);
valueEdit = "";
return true;
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class SelectedTerme method editNoteHisto.
/**
* Crée ou modifie la note historique du terme courant
*/
public void editNoteHisto() {
int idUser = user.getUser().getId();
if (noteHistorique.isEmpty()) {
deleteThisNoteOfConcept("note");
return;
}
if (new NoteHelper().isNoteExistOfTerm(connect.getPoolConnexion(), idT, idTheso, idlangue, "historyNote")) {
new NoteHelper().updateTermNote(connect.getPoolConnexion(), idT, idlangue, idTheso, noteHistorique, "historyNote", idUser);
} else {
new NoteHelper().addTermNote(connect.getPoolConnexion(), idT, idlangue, idTheso, noteHistorique, "historyNote", idUser);
}
majNotes();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info12")));
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class SelectedTerme method addTermeGeneOtherGroup.
/**
* Ajoute une relation terme générique au concept courant
*
* @param idConcept
* @param idGroup
* @param idNewConceptBT
* @return true or false
*/
public boolean addTermeGeneOtherGroup(String idConcept, String idGroup, String idNewConceptBT) {
ConceptHelper conceptHelper = new ConceptHelper();
RelationsHelper relationsHelper = new RelationsHelper();
GroupHelper groupHelper = new GroupHelper();
String idNewGroup = conceptHelper.getGroupIdOfConcept(connect.getPoolConnexion(), idNewConceptBT, idTheso);
if (idNewGroup == null) {
return false;
}
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
if (termeGenerique.isEmpty()) {
// c'était un orphelin
if (!new OrphanHelper().deleteOrphan(conn, idConcept, idTheso)) {
conn.rollback();
conn.close();
return false;
}
}
// On ajoute la realtion BT au concept
if (!relationsHelper.addRelationBT(conn, idConcept, idTheso, idNewConceptBT, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
// on récupère les Ids des concepts à modifier
ArrayList<String> lisIds = new ArrayList<>();
lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idConcept, idTheso, lisIds);
// on ajoute le nouveau domaine à la branche
if (!groupHelper.addDomainToBranch(conn, lisIds, idNewGroup, idTheso, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
conn.rollback();
conn.close();
return false;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
termeGenerique = new ArrayList<>();
majTGen();
return true;
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class SelectedTerme method deleteThisNoteOfConcept.
/**
* Cette fonction permet de supprimer une note suivant son type
*
* @param noteTypeCode
*/
public void deleteThisNoteOfConcept(String noteTypeCode) {
int idUser = user.getUser().getId();
new NoteHelper().deletethisNoteOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue, noteTypeCode);
majNotes();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info13")));
}
Aggregations