use of mom.trd.opentheso.bdd.helper.nodes.NodeRT in project opentheso by miledrousset.
the class NewTreeBean method fusionConcept.
/**
* Fusionne les concepts avec mise à jour dans l'abre
*/
public void fusionConcept() {
if (selectedTerme.getConceptFusionId().equals(selectedTerme.getIdC())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error"), langueBean.getMsg("error")));
selectedTerme.setConceptFusionId(null);
selectedTerme.setConceptFusionAlign(null);
selectedTerme.setConceptFusionNodeRT(null);
} else {
int idUser = selectedTerme.getUser().getUser().getId();
for (NodeRT rt : selectedTerme.getConceptFusionNodeRT()) {
HierarchicalRelationship hr = new HierarchicalRelationship(rt.getIdConcept(), selectedTerme.getConceptFusionId(), selectedTerme.getIdTheso(), "RT");
new ConceptHelper().addAssociativeRelation(connect.getPoolConnexion(), hr, idUser);
}
for (NodeAlignment na : selectedTerme.getConceptFusionAlign()) {
new AlignmentHelper().addNewAlignment(connect.getPoolConnexion(), idUser, na.getConcept_target(), na.getThesaurus_target(), na.getUri_target(), na.getAlignement_id_type(), selectedTerme.getConceptFusionId(), selectedTerme.getIdTheso(), 0);
}
new ConceptHelper().addConceptFusion(connect.getPoolConnexion(), selectedTerme.getConceptFusionId(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), idUser);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("tree.info6")));
reInit();
reExpand();
}
selectedTerme.setSelectedTermComp(new NodeAutoCompletion());
vue.setAddTInfo(0);
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeRT in project opentheso by miledrousset.
the class ExportTxtHelper method writeConceptsInfo.
/**
* Permet d'écrire les concepts en bouclant par récursivité pour définir les
* niveaux
*
* @return
*/
private void writeConceptsInfo(String idConcept, String indentation) {
ConceptHelper conceptHelper = new ConceptHelper();
NodeConcept nodeConcept = conceptHelper.getConcept(ds, idConcept, idTheso, selectedLang);
StringPlus stringPlus = new StringPlus();
boolean first = true;
if (nodeConcept == null) {
return;
}
// id numérique séquentiel
txtBuff.append(++number);
txtBuff.append("\t");
// Id_concept
txtBuff.append(idConcept);
txtBuff.append("\t");
// on écrit le Term_concept
txtBuff.append(indentation);
if (nodeConcept.getTerm().getLexical_value().isEmpty()) {
txtBuff.append("(");
txtBuff.append(idConcept);
txtBuff.append(")");
} else {
txtBuff.append(nodeConcept.getTerm().getLexical_value());
}
int tot = StringUtils.countMatches(indentation, "\t");
if (tot < indentationConcept) {
addTabulate(indentationConcept - (tot + 1));
}
if (selectedOptions.contains("occ")) {
// on écrit les occurences
txtBuff.append("\t");
txtBuff.append(totalOfNotices(idConcept));
}
first = true;
if (selectedOptions.contains("nt")) {
// on écrit la relation NT
if (!nodeConcept.getNodeNT().isEmpty()) {
txtBuff.append("\t");
for (NodeNT nodeNT : nodeConcept.getNodeNT()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("NT: ");
txtBuff.append(nodeNT.getTitle());
first = false;
}
}
if (nodeConcept.getNodeNT().size() < indentationNT) {
addTabulate(indentationNT - nodeConcept.getNodeNT().size());
}
}
first = true;
// on écrit la relation UF
if (selectedOptions.contains("uf")) {
if (!nodeConcept.getNodeEM().isEmpty()) {
txtBuff.append("\t");
for (NodeEM nodeEm : nodeConcept.getNodeEM()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("UF: ");
txtBuff.append(nodeEm.getLexical_value());
first = false;
}
}
if (nodeConcept.getNodeEM().size() < indentationUF) {
addTabulate(indentationUF - nodeConcept.getNodeEM().size());
}
}
first = true;
if (selectedOptions.contains("bt")) {
// on écrit la relation TG
if (!nodeConcept.getNodeBT().isEmpty()) {
txtBuff.append("\t");
for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("BT: ");
txtBuff.append(nodeBT.getTitle());
first = false;
}
}
if (nodeConcept.getNodeBT().size() < indentationBT) {
addTabulate(indentationBT - nodeConcept.getNodeBT().size());
}
}
first = true;
// on écrit la relation RT
if (selectedOptions.contains("rt")) {
if (!nodeConcept.getNodeRT().isEmpty()) {
txtBuff.append("\t");
for (NodeRT nodeRT : nodeConcept.getNodeRT()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("RT: ");
txtBuff.append(nodeRT.getTitle());
first = false;
}
}
if (nodeConcept.getNodeRT().size() < indentationRT) {
addTabulate(indentationRT - nodeConcept.getNodeRT().size());
}
}
first = true;
// on écrit les Groupes
if (selectedOptions.contains("groups")) {
if (!nodeConcept.getNodeConceptGroup().isEmpty()) {
txtBuff.append("\t");
for (NodeGroup nodeGroup : nodeConcept.getNodeConceptGroup()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("MT: ");
txtBuff.append(nodeGroup.getLexicalValue());
first = false;
}
}
if (nodeConcept.getNodeConceptGroup().size() < indentationGroups) {
addTabulate(indentationGroups - nodeConcept.getNodeConceptGroup().size());
}
}
first = true;
// on écrit les traductions
if (selectedOptions.contains("traductions")) {
if (!nodeConcept.getNodeTermTraductions().isEmpty()) {
txtBuff.append("\t");
for (NodeTermTraduction nodeTermTraduction : nodeConcept.getNodeTermTraductions()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("Tr: ");
txtBuff.append(nodeTermTraduction.getLexicalValue());
txtBuff.append("(");
txtBuff.append(nodeTermTraduction.getLang());
txtBuff.append(")");
first = false;
}
}
if (nodeConcept.getNodeTermTraductions().size() < indentationTraductions) {
addTabulate(indentationTraductions - nodeConcept.getNodeTermTraductions().size());
}
}
first = true;
// on écrit les notes de type Term
if (selectedOptions.contains("notes")) {
if ((!nodeConcept.getNodeNotesTerm().isEmpty()) || (!nodeConcept.getNodeNotesConcept().isEmpty())) {
txtBuff.append("\t");
for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("noteT: ");
txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
first = false;
}
for (NodeNote nodeNote : nodeConcept.getNodeNotesConcept()) {
if (!first)
txtBuff.append("\t");
// txtBuff.append("noteC: ");
txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
first = false;
}
}
if (nodeConcept.getNodeNotesTerm().size() < indentationNotes) {
addTabulate(indentationNotes - (nodeConcept.getNodeNotesConcept().size() + nodeConcept.getNodeNotesTerm().size()));
}
}
txtBuff.append("\n");
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeRT in project opentheso by miledrousset.
the class SelectedTerme method majTAsso.
private void majTAsso() {
termesAssocies = new ArrayList<>();
ArrayList<NodeRT> tempRT = new RelationsHelper().getListRT(connect.getPoolConnexion(), idC, idTheso, idlangue);
HashMap<String, String> tempMap = new HashMap<>();
for (NodeRT nrt : tempRT) {
if (nrt.getStatus().equals("hidden")) {
if (nrt.getTitle().isEmpty())
tempMap.put(nrt.getIdConcept(), "<del>" + nrt.getIdConcept() + " (" + nrt.getRole() + ")" + "</del>");
else
tempMap.put(nrt.getIdConcept(), "<del>" + nrt.getTitle() + " (" + nrt.getRole() + ")" + "</del>");
} else {
if (nrt.getTitle().isEmpty())
tempMap.put(nrt.getIdConcept(), nrt.getIdConcept() + " (" + nrt.getRole() + ")");
else
tempMap.put(nrt.getIdConcept(), nrt.getTitle() + " (" + nrt.getRole() + ")");
}
}
termesAssocies.addAll(tempMap.entrySet());
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeRT in project opentheso by miledrousset.
the class SelectedTerme method creerTermeAsso.
/**
* Ajoute une relation terme associé au concept courant
*
* @param idC2 le concept associé
*/
public void creerTermeAsso(String idC2) {
HierarchicalRelationship hr = new HierarchicalRelationship();
hr.setIdConcept1(idC);
hr.setIdConcept2(idC2);
hr.setIdThesaurus(idTheso);
hr.setRole("RT");
new ConceptHelper().addAssociativeRelation(connect.getPoolConnexion(), hr, user.getUser().getId());
ArrayList<NodeRT> tempRT = new RelationsHelper().getListRT(connect.getPoolConnexion(), idC, idTheso, idlangue);
termesAssocies = new ArrayList<>();
HashMap<String, String> tempMap = new HashMap<>();
for (NodeRT nrt : tempRT) {
tempMap.put(nrt.getIdConcept(), nrt.getTitle() + " (" + nrt.getRole() + ")");
}
termesAssocies.addAll(tempMap.entrySet());
vue.setAddTAsso(0);
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeRT in project opentheso by miledrousset.
the class RelationsHelper method getListRT.
/**
* Cette fonction permet de récupérer les termes associés d'un concept
*
* @param ds
* @param idConcept
* @param idThesaurus
* @param idLang
* @return Objet class Concept
*/
public ArrayList<NodeRT> getListRT(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeRT> nodeListRT = null;
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "select id_concept2,role, status from hierarchical_relationship, concept" + " where hierarchical_relationship.id_thesaurus = '" + idThesaurus + "'" + " and hierarchical_relationship.id_concept2 = concept.id_concept" + " and id_concept1 = '" + idConcept + "'" + " and (role = '" + "RT" + "'" + " or role = 'RHP' or role = 'RPO')";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet != null) {
nodeListRT = new ArrayList<>();
while (resultSet.next()) {
NodeRT nodeRT = new NodeRT();
nodeRT.setIdConcept(resultSet.getString("id_concept2"));
nodeRT.setStatus(resultSet.getString("status"));
nodeRT.setRole(resultSet.getString("role"));
nodeListRT.add(nodeRT);
}
}
for (NodeRT nodeRT : nodeListRT) {
query = "SELECT term.lexical_value FROM" + " term, preferred_term WHERE" + " term.id_term = preferred_term.id_term" + " and preferred_term.id_concept = '" + nodeRT.getIdConcept() + "'" + " and term.lang = '" + idLang + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by upper(unaccent_string(term.lexical_value))";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet != null) {
resultSet.next();
if (resultSet.getRow() == 0) {
nodeRT.setTitle("");
} else {
nodeRT.setTitle(resultSet.getString("lexical_value"));
}
}
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting RT of Concept : " + idConcept, sqle);
}
return nodeListRT;
}
Aggregations