Search in sources :

Example 1 with MyTreeNode

use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.

the class SelectedThesaurus method changeTermeTrad.

/**
 * Met à jour le thésaurus courant, l'arbre et le terme courant lors de la
 * sélection de la traduction d'un terme dans le gestionnaire de thésaurus
 *
 * @param id
 * @param l
 * @param type
 */
public void changeTermeTrad(String id, String l, int type) {
    MyTreeNode mTN = new MyTreeNode(type, id, tree.getSelectedTerme().getIdTheso(), l, tree.getSelectedTerme().getIdDomaine(), tree.getSelectedTerme().getTypeDomaine(), tree.getSelectedTerme().getIdTopConcept(), null, null, null);
    tree.getSelectedTerme().majTerme(mTN);
    thesaurus = new ThesaurusHelper().getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), l);
    // tree.reInit();
    tree.reExpand();
    vue.setOnglet(0);
}
Also used : ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 2 with MyTreeNode

use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.

the class UnderTree method onNodeExpand.

/**
 ************************** ACTIONS TREE ***************************
 */
/**
 * Expension de l'abre sur un seul noeud (ouvert manuellement)
 * @param event Le noeud ouvert
 */
public void onNodeExpand(NodeExpandEvent event) {
    String theso = ((MyTreeNode) event.getTreeNode()).getIdTheso();
    String lang = ((MyTreeNode) event.getTreeNode()).getLangue();
    // Récupération des facettes
    ArrayList<Integer> listIdFacet = new FacetHelper().getIdFacetUnderConcept(connect.getPoolConnexion(), ((MyTreeNode) event.getTreeNode()).getIdConcept(), theso);
    ArrayList<NodeFacet> listFacet = new ArrayList<>();
    for (Integer id : listIdFacet) {
        NodeFacet nf = new FacetHelper().getThisFacet(connect.getPoolConnexion(), id, theso, lang);
        listFacet.add(nf);
    }
    // <Retirer noeuds fictifs>
    if (event.getTreeNode().getChildCount() == 1) {
        event.getTreeNode().getChildren().remove(0);
    }
    // Récupération et insertion des facettes avec leurs concepts
    for (NodeFacet nf : listFacet) {
        new MyTreeNode(1, String.valueOf(nf.getIdFacet()), theso, lang, "", "", "", "facette", nf.getLexicalValue() + "(" + String.valueOf(nf.getIdFacet()) + ")", event.getTreeNode());
        ArrayList<String> listIdC = new FacetHelper().getIdConceptsOfFacet(connect.getPoolConnexion(), nf.getIdFacet(), theso);
        ArrayList<NodeConceptTree> liste = new ArrayList<>();
        for (String id : listIdC) {
            String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), id, theso, lang).getLexical_value();
            NodeConceptTree nct = new NodeConceptTree();
            nct.setHaveChildren(false);
            nct.setIdConcept(id);
            nct.setIdLang(lang);
            nct.setIdThesaurus(theso);
            nct.setTitle(value);
            liste.add(nct);
        }
        // Ajout dans l'arbre
        for (NodeConceptTree nct : liste) {
            new MyTreeNode(3, nct.getIdConcept(), theso, lang, "", "", "", "fichier", nct.getTitle() + "(" + nct.getIdConcept() + ")", event.getTreeNode());
        }
    }
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) ArrayList(java.util.ArrayList) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 3 with MyTreeNode

use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode 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);
    }
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 4 with MyTreeNode

use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode 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);
                }
            }
        }
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) ArrayList(java.util.ArrayList) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 5 with MyTreeNode

use of mom.trd.opentheso.bdd.helper.nodes.MyTreeNode in project opentheso by miledrousset.

the class NewTreeBean method renameWithoutControl.

/**
 * Fonction qui permet de modifier le nom d'un concept avec un autre en
 * doublon (action autorisée après validation de l'utilisateur)
 */
public void renameWithoutControl() {
    if (selectedTerme.getIdT() != null && !selectedTerme.getIdT().equals("")) {
        selectedTerme.editTerme(1);
    } else {
        // le terme n'existe pas encore
        if (!selectedTerme.editTerme(2)) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            selectedTerme.setNomEdit(selectedTerme.getNom());
            return;
        }
    }
    if (selectedNode != null) {
        // ((MyTreeNode) selectedNode).setData(temp + " (Id_" + selectedTerme.getIdC() + ")");
        ((MyTreeNode) selectedNode).setData(selectedTerme.getNom());
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", selectedTerme.getNom() + " " + langueBean.getMsg("tree.info2")));
        selectedTerme.setNomEdit(selectedTerme.getNom());
    }
    selectedTerme.setSelectedTermComp(new NodeAutoCompletion());
}
Also used : MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) FacesMessage(javax.faces.application.FacesMessage) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Aggregations

MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)25 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)12 TreeNode (org.primefaces.model.TreeNode)11 ArrayList (java.util.ArrayList)9 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)9 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)9 NodeConceptTree (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree)6 FacetHelper (mom.trd.opentheso.bdd.helper.FacetHelper)4 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)4 PrefixString (com.k_int.IR.QueryModels.PrefixString)3 FacesMessage (javax.faces.application.FacesMessage)3 Concept (mom.trd.opentheso.bdd.datas.Concept)2 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)2 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)2 NodeFacet (mom.trd.opentheso.bdd.helper.nodes.NodeFacet)2 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)2 StructIdBroaderTerm (mom.trd.opentheso.dragdrop.StructIdBroaderTerm)2 TreeChange (mom.trd.opentheso.dragdrop.TreeChange)2 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)1 Term (mom.trd.opentheso.bdd.datas.Term)1