use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.
the class NewTreeBean method renameGroup.
public boolean renameGroup() {
MyTreeNode myTreeNode = (MyTreeNode) selectedNode;
String valueEdit = selectedTerme.getNomEdit().trim();
if (valueEdit.isEmpty()) {
return false;
}
// si c'est la même valeur, on fait rien
if (selectedTerme.getNom().trim().equals(valueEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error2")));
// selectedTerme.setNomEdit(selectedTerme.getNom());
return false;
}
// vérification si le Groupe à ajouter existe déjà
if (new GroupHelper().isDomainExist(connect.getPoolConnexion(), valueEdit, myTreeNode.getIdTheso(), myTreeNode.getLangue())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error6")));
return false;
}
if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) {
if (!selectedTerme.editGroupName(myTreeNode.getIdTheso(), myTreeNode.getIdConcept(), myTreeNode.getLangue(), valueEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "erreur BDD"));
// selectedTerme.setNomEdit(selectedTerme.getNom());
return false;
}
myTreeNode.setData(valueEdit);
selectedTerme.setNom(valueEdit);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", valueEdit + " " + langueBean.getMsg("tree.info2")));
return true;
}
return false;
}
use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.
the class NewTreeBean method loadOrphan.
public void loadOrphan(String idTheso, String langue) {
String typeNode, value = "";
/*
this.typeMot = type;
this.idMot = id;
this.idTheso = idT;
this.langue = l;
this.idDomaine = idD;
this.typeDomaine = typeDomaine;
this.idTopConcept = idTC;
*/
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, null, idTheso, langue, null, null, null, "orphan", langueBean.getMsg("index.orphans"), root);
orphans = new OrphanHelper().getListOrphanId(connect.getPoolConnexion(), idTheso);
for (String idC : orphans) {
if (new ConceptHelper().haveChildren(connect.getPoolConnexion(), idTheso, idC)) {
typeNode = "dossier";
} else {
typeNode = "fichier";
}
Term term = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, langue);
if (term != null) {
value = term.getLexical_value() + " (id_" + idC + ")";
Concept temp = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idC, idTheso);
MyTreeNode mtn = new MyTreeNode(3, idC, idTheso, langue, "Orphan", null, null, typeNode, value, dynamicTreeNode);
if (typeNode.equals("dossier")) {
new DefaultTreeNode("fake", mtn);
}
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.
the class NewTreeBean method reExpandTree.
/**
* Expansion automatique de la racine
*
* @param listeId
* @param idTheso
* @param langue
*/
private void reExpandTree(ArrayList<ArrayList<String>> listeId, String idTheso, String langue, TreeChange tc) {
// if(selectedNodes.isEmpty()){
// idem
ArrayList<MyTreeNode> listeNode = new ArrayList<>();
if (root.getChildCount() == 0) {
// On recrée la racine
List<NodeGroup> racineNode = new GroupHelper().getListRootConceptGroup(connect.getPoolConnexion(), idTheso, langue);
Collections.sort(racineNode);
for (NodeGroup nodegroup : racineNode) {
TreeNode dynamicTreeNode;
String typeCode = nodegroup.getConceptGroup().getIdtypecode();
String type = getTypeOfGroup(typeCode);
// intégration des groupes
if (nodegroup.getLexicalValue().trim().isEmpty()) {
dynamicTreeNode = (TreeNode) new MyTreeNode(1, nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getIdLang(), nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdtypecode(), null, type, nodegroup.getConceptGroup().getIdgroup(), root);
((MyTreeNode) dynamicTreeNode).setIsGroup(true);
new DefaultTreeNode("fake", dynamicTreeNode);
} else {
dynamicTreeNode = (TreeNode) new MyTreeNode(1, nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getIdLang(), nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdtypecode(), null, type, nodegroup.getLexicalValue(), null);
((MyTreeNode) dynamicTreeNode).setIsGroup(true);
/**
**code pour la numérotation des groupes *****************
*/
GroupHelper groupHelper = new GroupHelper();
String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getConceptGroup().getIdgroup());
// ici c'est un groupe donc pas de suffix
((MyTreeNode) dynamicTreeNode).setPrefix(suffix);
((MyTreeNode) dynamicTreeNode).setData(((MyTreeNode) dynamicTreeNode).getNumerotation() + " " + dynamicTreeNode.getData());
/**
***fin de code pour la numérotation des groupes *********
*/
listeNode.add((MyTreeNode) dynamicTreeNode);
}
}
/**
*ici on trie la liste des groupes d après le champ data**
*/
Collections.sort(listeNode, new TreeNodeComparator());
/*et on l'ajoute au root **/
// on récupère les noeuds qui étaient étendus
ArrayList idToExpand = new ArrayList<>();
for (TreeNode tn : tc.getExpandedNodes()) {
idToExpand.add(((MyTreeNode) tn).getIdConcept());
}
for (MyTreeNode mtn : listeNode) {
MyTreeNode tmp = new MyTreeNode(1, mtn.getIdConcept(), mtn.getIdTheso(), mtn.getLangue(), mtn.getIdConcept(), mtn.getTypeDomaine(), mtn.getIdTopConcept(), mtn.getType(), mtn.getData(), root);
tmp.setPrefix(mtn.getPrefix());
tmp.setSuffix(mtn.getSuffix());
tmp.setIsGroup(true);
new DefaultTreeNode(null, tmp);
if (idToExpand.contains(mtn.getIdConcept())) {
mtn.setExpanded(true);
this.onNodeExpand(mtn);
}
}
/**
*fin **
*/
loadOrphan(idTheso, langue);
// loadOrphan(idTheso, langue);
for (TreeNode tn : root.getChildren()) {
if (tn.getType().equals("orphan")) {
for (TreeNode tn2 : tn.getChildren()) {
for (ArrayList<String> tabId : listeId) {
if (tabId.size() == 2 && tabId.get(1).equals(((MyTreeNode) tn2).getIdConcept())) {
tn2.setSelected(true);
selectedNode = tn2;
selectedNodes.add(tn2);
} else {
if (tabId.get(1).equals(((MyTreeNode) tn2).getIdConcept())) {
reExpandChild(tabId, (MyTreeNode) tn2, 2);
}
}
}
}
}
}
} else {
List<TreeNode> racineNode = root.getChildren();
for (TreeNode dynamicTreeNode : racineNode) {
if (!dynamicTreeNode.getType().equals("orphan")) {
for (ArrayList<String> tabId : listeId) {
// Si c'est le , on étend
if (tabId.size() > 1 && tabId.get(0) != null) {
if (tabId.get(0).equals(((MyTreeNode) dynamicTreeNode).getIdCurrentGroup())) {
reExpandChild(tabId, (MyTreeNode) dynamicTreeNode, 1);
}
} else {
if (tabId.get(1).equals(((MyTreeNode) dynamicTreeNode).getIdCurrentGroup())) {
dynamicTreeNode.setSelected(true);
selectedNode = dynamicTreeNode;
selectedNodes.add(dynamicTreeNode);
} else {
dynamicTreeNode.setSelected(false);
}
}
}
} else {
for (TreeNode tn2 : dynamicTreeNode.getChildren()) {
for (ArrayList<String> tabId : listeId) {
if (tabId.size() == 2 && tabId.get(1).equals(((MyTreeNode) tn2).getIdConcept())) {
tn2.setSelected(true);
selectedNode = tn2;
selectedNodes.add(tn2);
} else {
if (tabId.get(1).equals(((MyTreeNode) tn2).getIdConcept())) {
reExpandChild(tabId, (MyTreeNode) tn2, 2);
}
}
}
}
}
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.
the class NewTreeBean method initTree.
public void initTree(String idTheso, String langue) {
// idThesoSelected = idTheso;
// defaultLanguage = langue;
root = (TreeNode) new DefaultTreeNode("Root", null);
// attribut pour la numérotation des groupes
int count = 1;
// idem
ArrayList<MyTreeNode> listeNode = new ArrayList<>();
if (connect.getPoolConnexion() == null) {
System.err.println("Opentheso n'a pas pu se connecter à la base de données");
return;
}
List<NodeGroup> racineNode = new GroupHelper().getListRootConceptGroup(connect.getPoolConnexion(), idTheso, langue);
Collections.sort(racineNode);
// Les premiers noeuds de l'arbre sont de type Groupe (isGroup = true)
for (NodeGroup nodegroup : racineNode) {
String typeCode = nodegroup.getConceptGroup().getIdtypecode();
String type = getTypeOfGroup(typeCode);
if (nodegroup.getLexicalValue().trim().isEmpty()) {
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getIdLang(), nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdtypecode(), null, type, nodegroup.getConceptGroup().getIdgroup(), root);
((MyTreeNode) dynamicTreeNode).setIsGroup(true);
new DefaultTreeNode("facette", dynamicTreeNode);
} else {
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getIdLang(), nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdtypecode(), null, type, nodegroup.getLexicalValue(), null);
((MyTreeNode) dynamicTreeNode).setIsGroup(true);
/**
**code pour la numérotation des groupes *****************
*/
GroupHelper groupHelper = new GroupHelper();
String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getConceptGroup().getIdgroup());
if (suffix.equalsIgnoreCase("0") || suffix.equalsIgnoreCase("00")) {
suffix = "" + count;
count++;
groupHelper.saveSuffixFromNode(connect.getPoolConnexion(), nodegroup.getConceptGroup().getIdthesaurus(), nodegroup.getConceptGroup().getIdgroup(), suffix);
}
// ici c'est un groupe donc pas de suffix
((MyTreeNode) dynamicTreeNode).setPrefix(suffix);
((MyTreeNode) dynamicTreeNode).setData(((MyTreeNode) dynamicTreeNode).getNumerotation() + " " + dynamicTreeNode.getData());
/**
***fin de code pour la numérotation des groupes *********
*/
new DefaultTreeNode("facette", dynamicTreeNode);
listeNode.add((MyTreeNode) dynamicTreeNode);
}
}
/**
*ici on trie la liste des groupes d après le champ data**
*/
Collections.sort(listeNode, new TreeNodeComparator());
/*et on l'ajoute au root **/
for (MyTreeNode mtn : listeNode) {
MyTreeNode tmp = new MyTreeNode(1, mtn.getIdConcept(), mtn.getIdTheso(), mtn.getLangue(), mtn.getIdConcept(), mtn.getTypeDomaine(), mtn.getIdTopConcept(), mtn.getType(), mtn.getData(), root);
tmp.setPrefix(mtn.getPrefix());
tmp.setSuffix(mtn.getSuffix());
tmp.setIsGroup(true);
new DefaultTreeNode(null, tmp);
}
/**
*fin **
*/
if (idTheso != null) {
loadOrphan(idTheso, langue);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.
the class NewTreeBean method onNodeExpand.
public void onNodeExpand(TreeNode treeNode) {
if (!treeNode.getType().equals("orphan")) {
ArrayList<NodeConceptTree> listeSubGroup = new ArrayList<>();
ArrayList<NodeConceptTree> listeConcept;
ArrayList<String> idGroupList;
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
int type = 3;
boolean isTopTerm;
// <Retirer noeuds fictifs>
if (treeNode.getChildCount() == 1) {
treeNode.getChildren().remove(0);
}
MyTreeNode myTreeNode = (MyTreeNode) treeNode;
// id du concept ou group sélectionné qu'il faut déployer
String idSelectedNode = myTreeNode.getIdConcept();
if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso())) {
// if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) { //pour détecter les noeuds type Group/collecton/MT/Thèmes ...
// pour group ?
myTreeNode.setTypeConcept(1);
// myTreeNode.setIsGroup(true);
// on récupère la liste des sous_groupes (s'il y en a)
listeSubGroup = groupHelper.getRelationGroupOf(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue());
if (listeSubGroup == null) {
listeSubGroup = new ArrayList<>();
}
// pour récupérer les concepts mélangés avec les Sous_Groupes
listeConcept = conceptHelper.getListTopConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue());
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue());
// myTreeNode.setIsTopConcept(true);
}
MyTreeNode treeNode2 = null;
// 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
// myTreeNode.isIsGroup() myTreeNode.isIsSubGroup()
//
String value = "";
String idTC = "";
String icon;
/**
* Ajout des sous_Groupes (MT, C, G, T ..)
*/
// attribut pour la numérotation des sous groupes
int count = 0;
// attribut pour le trie
ArrayList<MyTreeNode> listeTreeNode = new ArrayList<>();
/*la partie de code suivant peut comporter des éléments inutiles**/
for (NodeConceptTree nodeConceptTreeGroup : listeSubGroup) {
treeNode2 = null;
value = nodeConceptTreeGroup.getTitle();
if (groupHelper.haveSubGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept()) || nodeConceptTreeGroup.isHaveChildren()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
treeNode2 = new MyTreeNode(1, nodeConceptTreeGroup.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), nodeConceptTreeGroup.getIdConcept(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, null);
((MyTreeNode) treeNode2).setIsSubGroup(true);
listeTreeNode.add(treeNode2);
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
/**
*code poour la numérotation des sous groupes ***
*/
((MyTreeNode) treeNode2).setPrefix(myTreeNode.getNumerotation());
String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept());
count += 5;
// a priori par défaut un getInt renvoit 0 si champ vide (cf groupHelper.getSuffixFromNode)
if (suffix.equalsIgnoreCase("0") || suffix.equalsIgnoreCase("00")) {
if (10 <= count) {
suffix = "" + count;
} else {
suffix = "0" + count;
}
groupHelper.saveSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept(), suffix);
}
if (suffix.length() < 2)
suffix = "0" + suffix;
((MyTreeNode) treeNode2).setSuffix(suffix);
((MyTreeNode) treeNode2).setData(((MyTreeNode) treeNode2).getNumerotation() + " " + treeNode2.getData());
/**
*fin code numérotation des sous groupes****
*/
new DefaultTreeNode(null, treeNode2);
}
/**
*fin de la partie de code pouvant comporter des éléments inutiles
*/
}
/**
*afin de classer les sous groupes avec la numérotation on trie
*la liste de treeNode on est obligé de récréer un noeuds MyTreeNode pour
* chaque treenode de la liste, pour pouvoir l'accrocher à l'arbre
*
*#jm
*/
Collections.sort(listeTreeNode, new TreeNodeComparator());
for (MyTreeNode mtn : listeTreeNode) {
MyTreeNode tmp = new MyTreeNode(1, mtn.getIdConcept(), mtn.getIdTheso(), mtn.getLangue(), mtn.getIdConcept(), mtn.getTypeDomaine(), mtn.getIdTopConcept(), mtn.getType(), mtn.getData(), treeNode);
tmp.setPrefix(mtn.getPrefix());
tmp.setSuffix(mtn.getSuffix());
tmp.setIdParent(myTreeNode.getIdConcept());
tmp.setIsSubGroup(true);
new DefaultTreeNode(null, tmp);
}
// Ajout dans l'arbre des concepts
for (NodeConceptTree nodeConceptTree : listeConcept) {
isTopTerm = false;
treeNode2 = null;
if (conceptHelper.haveChildren(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept()) || nodeConceptTree.isHaveChildren()) {
icon = "dossier";
if (nodeConceptTree.isIsTopTerm()) {
// Création de topConcepts
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
idTC = value;
isTopTerm = true;
} else {
// Création de concepts
idTC = ((MyTreeNode) treeNode).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept() != null) {
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
}
treeNode2 = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), ((MyTreeNode) treeNode).getIdCurrentGroup(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, treeNode);
if (isTopTerm) {
((MyTreeNode) treeNode2).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode2).setOtherGroup(idGroupList);
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
new DefaultTreeNode(null, treeNode2);
} else {
icon = "fichier";
// if (type == 2) { //Création des topConcepts
if (nodeConceptTree.isIsTopTerm()) {
// cas de TT
// type=2;
idTC = nodeConceptTree.getIdConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
isTopTerm = true;
} else {
// Création de concepts
// type=3;
idTC = ((MyTreeNode) treeNode).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
treeNode2 = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), ((MyTreeNode) treeNode).getIdCurrentGroup(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, treeNode);
if (isTopTerm) {
((MyTreeNode) treeNode2).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode2).setOtherGroup(idGroupList);
}
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
}
}
}
Aggregations