use of org.primefaces.model.DefaultTreeNode 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 **
*/
} 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 org.primefaces.model.DefaultTreeNode in project opentheso by miledrousset.
the class NewTreeBean method reExpandChild.
private void reExpandChild(ArrayList<String> listeId, TreeNode node, int cpt) {
if (!node.isExpanded()) {
ArrayList<NodeConceptTree> listeConcept;
ArrayList<NodeConceptTree> listeSubGroup = new ArrayList<>();
ArrayList<String> idGroupList;
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
int type = 3;
if (node.getChildCount() == 1) {
node.getChildren().remove(0);
}
MyTreeNode myTreeNode = (MyTreeNode) node;
String idConcept = myTreeNode.getIdConcept();
if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso())) {
// pour group ?
myTreeNode.setTypeConcept(1);
myTreeNode.setIsGroup(true);
listeSubGroup = groupHelper.getRelationGroupOf(connect.getPoolConnexion(), idConcept, 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(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue(), isSortByNotation);
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue(), isSortByNotation);
// myTreeNode.setIsTopConcept(true);
}
TreeNode treeNode = null;
String value = "";
String idTC = "";
String icon;
boolean isTopTerm;
/**
* Ajout des Groupes (MT, C, G, T ..)
*/
for (NodeConceptTree nodeConceptTreeGroup : listeSubGroup) {
value = nodeConceptTreeGroup.getTitle();
if (groupHelper.isHaveSubGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept()) || nodeConceptTreeGroup.isHaveChildren()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
treeNode = new MyTreeNode(1, nodeConceptTreeGroup.getIdConcept(), myTreeNode.getIdTheso(), myTreeNode.getLangue(), myTreeNode.getIdCurrentGroup(), myTreeNode.getTypeDomaine(), idTC, icon, value, myTreeNode);
((MyTreeNode) treeNode).setIsSubGroup(true);
((MyTreeNode) treeNode).setIdCurrentGroup(nodeConceptTreeGroup.getIdConcept());
new DefaultTreeNode("fake", treeNode);
if (listeId.contains(((MyTreeNode) treeNode).getIdConcept())) {
((MyTreeNode) treeNode).setExpanded(true);
}
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
treeNode.setSelected(false);
reExpandChild(listeId, treeNode, cpt + 1);
} else {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
}
}
}
}
// Ajout dans l'arbre
for (NodeConceptTree nodeConceptTree : listeConcept) {
isTopTerm = false;
if (conceptHelper.haveChildren(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept()) || nodeConceptTree.isHaveChildren()) {
icon = "dossier";
if (nodeConceptTree.isIsGroup()) {
icon = "domaine";
// String type = getTypeOfGroup(typeCode);
} else if (nodeConceptTree.isIsSubGroup()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
}
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) node).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept() != null) {
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
}
treeNode = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) node).getIdTheso(), ((MyTreeNode) node).getLangue(), ((MyTreeNode) node).getIdCurrentGroup(), ((MyTreeNode) node).getTypeDomaine(), idTC, icon, value, node);
if (isTopTerm) {
((MyTreeNode) treeNode).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode).setOtherGroup(idGroupList);
new DefaultTreeNode("fake", treeNode);
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
treeNode.setSelected(false);
reExpandChild(listeId, treeNode, cpt + 1);
} else {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
}
}
} else {
icon = "fichier";
if (nodeConceptTree.isIsTopTerm()) {
// Création de topConcepts
idTC = nodeConceptTree.getIdConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
isTopTerm = true;
} else {
// Création de concepts
idTC = ((MyTreeNode) node).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
treeNode = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) node).getIdTheso(), ((MyTreeNode) node).getLangue(), ((MyTreeNode) node).getIdCurrentGroup(), ((MyTreeNode) node).getTypeDomaine(), idTC, icon, value, node);
if (isTopTerm) {
((MyTreeNode) treeNode).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode).setOtherGroup(idGroupList);
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
} else {
treeNode.setSelected(false);
}
}
}
node.setExpanded(true);
} else {
List<TreeNode> children = node.getChildren();
for (TreeNode mtn : children) {
if (listeId.get(cpt).equals(((MyTreeNode) mtn).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
mtn.setSelected(false);
reExpandChild(listeId, mtn, cpt + 1);
} else {
mtn.setSelected(true);
selectedNode = mtn;
selectedNodes.add(mtn);
}
}
}
}
}
use of org.primefaces.model.DefaultTreeNode in project opentheso by miledrousset.
the class SelectedTerme method reInitTerme.
/**
* Vide toutes les informations du terme
*/
public void reInitTerme() {
root = (TreeNode) new DefaultTreeNode("Root", null);
nom = "";
nomEdit = "";
termeGenerique = new ArrayList<>();
termesSpecifique = new ArrayList<>();
termesAssocies = new ArrayList<>();
termesSynonymesE = new ArrayList<>();
termesSynonymesP = new ArrayList<>();
langues = new ArrayList<>();
images = new ArrayList<>();
align = new ArrayList<>();
idT = "";
idC = null;
status = "";
notation = "";
idTheso = "";
idlangue = "";
idDomaine = "";
idTopConcept = "";
nbNotices = 0;
urlNotice = "";
microTheso = "";
dateC = "";
dateM = "";
idArk = "";
idHandle = "";
type = 1;
valueEdit = "";
langueEdit = "";
statutEdit = "";
nodeSe = new NodeSearch();
nodeGroupIdLabel = new ArrayList<>();
}
use of org.primefaces.model.DefaultTreeNode 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();
// cas d'un Groupe ou sous-Groupe
if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) {
// if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso())) {
// if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) { //pour détecter les noeuds type Group/collecton/MT/Thèmes ...
// TypeConcept(1);//pour group ?
myTreeNode.setIsGroup(true);
// 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(), isSortByNotation);
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue(), isSortByNotation);
// 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 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.isHaveSubGroup(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 ***
*/
String prefix = groupHelper.getNotationOfGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdConcept(), nodeConceptTreeGroup.getIdThesaurus());
// ((MyTreeNode) treeNode2).setPrefix(myTreeNode.getNumerotation());
((MyTreeNode) treeNode2).setPrefix(prefix);
/*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());
((MyTreeNode) treeNode2).setData(prefix + " " + 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
*/
}
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 {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} 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 {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} 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 {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} 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 {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} 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());
}
}
}
use of org.primefaces.model.DefaultTreeNode in project opentheso by miledrousset.
the class NewTreeBean method initTree.
public void initTree(String idTheso, String langue) {
if (idTheso == null)
return;
// idThesoSelected = idTheso;
// defaultLanguage = langue;
root = (TreeNode) new DefaultTreeNode("Root", null);
// 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;
}
GroupHelper groupHelper = new GroupHelper();
List<NodeGroup> racineNode = new GroupHelper().getListRootConceptGroup(connect.getPoolConnexion(), idTheso, langue);
// 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 le préfix (Notation) des groupes pour permettre le tri *****************
*/
String prefix = groupHelper.getNotationOfGroup(connect.getPoolConnexion(), nodegroup.getConceptGroup().getIdgroup(), nodegroup.getConceptGroup().getIdthesaurus());
// ici c'est un groupe donc pas de suffix
((MyTreeNode) dynamicTreeNode).setPrefix(prefix);
// ((MyTreeNode) dynamicTreeNode).getNumerotation() + " " + dynamicTreeNode.getData());
((MyTreeNode) dynamicTreeNode).setData(prefix + " " + dynamicTreeNode.getData());
/**
* ***fin de code pour le prefix des groupes *********
*/
// new DefaultTreeNode("facette", dynamicTreeNode);
listeNode.add((MyTreeNode) dynamicTreeNode);
}
}
/*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 **
*/
}
Aggregations