use of mom.trd.opentheso.bdd.helper.nodes.NodeNT in project opentheso by miledrousset.
the class SelectedTerme method creerTermeSpe.
/**
* Corrigé par M.R. Ajoute une relation terme spécifique au concept courant
*
* @param idCNT
* @return true or false
*/
public boolean creerTermeSpe(String idCNT) {
ConceptHelper conceptHelper = new ConceptHelper();
if (new OrphanHelper().isOrphan(connect.getPoolConnexion(), idCNT, idTheso)) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
ArrayList<String> newGroup = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
for (String s : newGroup) {
Concept c = new Concept();
c.setIdConcept(idCNT);
c.setIdGroup(s);
c.setIdThesaurus(idTheso);
c.setStatus("D");
String idConcept = conceptHelper.addConceptInTable(conn, c, user.getUser().getId());
// si ça se passe mal, on ajoute rien;
if (idConcept == null) {
conn.rollback();
conn.close();
return false;
}
}
if (!new OrphanHelper().deleteOrphan(conn, idCNT, idTheso)) {
conn.rollback();
conn.close();
return false;
}
// On crée les relations
if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
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;
}
} else if (type == 1) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
if (new ConceptHelper().haveThisGroup(connect.getPoolConnexion(), idCNT, idC, idTheso)) {
if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
} else {
ArrayList<String> newGroup = new ArrayList<>();
newGroup.add(idC);
if (!addBranchGroup(newGroup, idCNT)) {
conn.rollback();
conn.close();
return false;
}
if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
// On ajoute les nouveaux domaines s'il y en a
ArrayList<String> groupNT = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idCNT, idTheso);
ArrayList<String> groupCurrent = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
ArrayList<String> newGroup = new ArrayList<>();
for (String s : groupCurrent) {
if (!groupNT.contains(s)) {
newGroup.add(s);
}
}
if (!addBranchGroup(newGroup, idCNT)) {
conn.rollback();
conn.close();
return false;
}
// On crée les relations
if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
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;
}
}
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);
return true;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeNT in project opentheso by miledrousset.
the class ExportTxtHelper method countIndentation.
/**
* permet de compter le nombre de décalalge pour chaque type de données
* concept : pour l'hiérarchie NT : pour le nombre maxi de NT existant dans
* le thésaurus ou le domaine choisi RT ... UF ....
*
* @param idConcept
* @param indentation
*/
private void countIndentation(String idConcept, String indentation) {
ArrayList<NodeNT> childList = new RelationsHelper().getListNT(ds, idConcept, idTheso, selectedLang);
if (childList == null) {
return;
}
// indentation des concepts par hiérarchie
indentation += "\t";
int tot = StringUtils.countMatches(indentation, "\t");
if (tot > indentationConcept) {
indentationConcept = tot;
}
// indentation des NT nombre maxi
if (selectedOptions.contains("nt")) {
int totNT = new RelationsHelper().getCountOfNT(ds, idConcept, idTheso);
if (totNT > indentationNT) {
indentationNT = totNT;
}
}
// indentation des BT nombre maxi
if (selectedOptions.contains("bt")) {
int totBT = new RelationsHelper().getCountOfBT(ds, idConcept, idTheso);
if (totBT > indentationBT) {
indentationBT = totBT;
}
}
// indentation des RT nombre maxi
if (selectedOptions.contains("rt")) {
int totRT = new RelationsHelper().getCountOfRT(ds, idConcept, idTheso);
if (totRT > indentationRT) {
indentationRT = totRT;
}
}
// indentation des UF nombre maxi
if (selectedOptions.contains("uf")) {
int totUF = new RelationsHelper().getCountOfUF(ds, idConcept, idTheso, selectedLang);
if (totUF > indentationUF) {
indentationUF = totUF;
}
}
// indentation des Groups nombre maxi
if (selectedOptions.contains("groups")) {
int totGroup = new GroupHelper().getCountOfGroups(ds, idConcept, idTheso);
if (totGroup > indentationGroups) {
indentationGroups = totGroup;
}
}
// indentation traductions
if (selectedOptions.contains("traductions")) {
int totTraductions = new TermHelper().getCountOfTraductions(ds, idConcept, idTheso, selectedLang);
if (totTraductions > indentationTraductions) {
indentationTraductions = totTraductions;
}
}
// indentation notes
if (selectedOptions.contains("notes")) {
int totNotes = new NoteHelper().getCountOfNotes(ds, idConcept, idTheso, selectedLang);
if (totNotes > indentationNotes) {
indentationNotes = totNotes;
}
}
for (NodeNT nodeNT : childList) {
countIndentation(nodeNT.getIdConcept(), indentation);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeNT in project opentheso by miledrousset.
the class ExportTxtHelper method writeConceptRecursive.
/**
* fonction recursive qui sert a ecrire tout les fils des term
*
* @param id
* @param indentation
* @param paragraphs
* @param idToDoc
*/
private void writeConceptRecursive(String idConcept, String indentation) {
ArrayList<NodeNT> childList = new RelationsHelper().getListNT(ds, idConcept, idTheso, selectedLang);
if (childList == null) {
return;
}
indentation += "\t";
for (NodeNT nodeNT : childList) {
writeConceptsInfo(nodeNT.getIdConcept(), indentation);
writeConceptRecursive(nodeNT.getIdConcept(), indentation);
}
}
Aggregations