use of org.primefaces.model.TreeNode in project opentheso by miledrousset.
the class NewTreeBean method reExpandNodes.
private void reExpandNodes(TreeNode root, TreeChange tc) {
for (TreeNode tn : root.getChildren()) {
if (tc.getExpandedNodes().contains(tn)) {
tn.setExpanded(true);
this.onNodeExpand(tn);
reExpandNodes(tn, tc);
}
}
}
use of org.primefaces.model.TreeNode in project opentheso by miledrousset.
the class TreeChange method saveExpandedNodes.
/**
* saveExpandedNodes
* méthode qui parcourt un arbre treeNode pour sauvegarder les neoud
* étendus dans une arrayList expandedNodes
* @param root
*/
public void saveExpandedNodes(TreeNode root) {
for (TreeNode tn : root.getChildren()) {
if (tn.isExpanded()) {
this.expandedNodes.add(tn);
saveExpandedNodes(tn);
}
}
}
use of org.primefaces.model.TreeNode in project opentheso by miledrousset.
the class UnderTree method initTree.
/**
* Récupère les facettes pour remplir la racine de l'arbre selon la langue et le thésaurus sélectionnés
* @param idTheso
* @param langue
*/
public void initTree(String idTheso, String langue) {
List<NodeConceptTree> racineNode = new FacetHelper().getIdParentOfFacet(connect.getPoolConnexion(), idTheso, langue);
for (NodeConceptTree nct : racineNode) {
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, nct.getIdConcept(), idTheso, langue, "", "", "", "dossier", nct.getTitle() + "(" + nct.getIdConcept() + ")", root);
new DefaultTreeNode("fake", dynamicTreeNode);
}
}
use of org.primefaces.model.TreeNode 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());
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue());
// 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.haveSubGroup(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);
/**
*code poour la numérotation des sous groupes ***
*/
((MyTreeNode) treeNode).setPrefix(((MyTreeNode) node).getNumerotation());
String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept());
if (suffix.length() < 2)
suffix = "0" + suffix;
((MyTreeNode) treeNode).setSuffix(suffix);
((MyTreeNode) treeNode).setData(((MyTreeNode) treeNode).getNumerotation() + " " + treeNode.getData());
/**
*fin code numérotation des sous groupes****
*/
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.TreeNode 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);
}
}
}
}
Aggregations