Search in sources :

Example 21 with MyTreeNode

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

the class NewTreeBean method reExpand.

public void reExpand() {
    TreeChange tc = new TreeChange();
    tc.saveExpandedNodes(root);
    this.reInit();
    this.initTree(selectedTerme.getIdTheso(), selectedTerme.getIdlangue());
    ArrayList<String> ids = new ArrayList<>();
    for (TreeNode tn : tc.getExpandedNodes()) {
        ids.add(((MyTreeNode) tn).getIdConcept());
    }
    ids.addAll(tc.getPathFromSelectedConcept(connect, (MyTreeNode) selectedNode));
    ids.add(selectedTerme.getIdC());
    // code pour forcer le depliment de l'arbre
    reExpandNodes(root, ids, selectedTerme.getIdC());
    if (selectedNode == null) {
    // selectedNode = new MyTreeNode(0, "", "", "", "", "", "domaine", "", root);
    }
    // selectedNode.setSelected(false);
    for (TreeNode tn : selectedNodes) {
        tn.setSelected(false);
    }
    selectedNodes = new ArrayList<>();
    ArrayList<String> first = new ArrayList<>();
    first.add(selectedTerme.getIdC());
    ArrayList<ArrayList<String>> paths = new ArrayList<>();
    paths = new ConceptHelper().getPathOfConcept(connect.getPoolConnexion(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), first, paths);
    if (paths != null) {
    // reExpandTree(paths, selectedTerme.getIdTheso(), selectedTerme.getIdlangue(),tc);
    }
}
Also used : TreeChange(mom.trd.opentheso.dragdrop.TreeChange) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) ArrayList(java.util.ArrayList) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 22 with MyTreeNode

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

the class NewTreeBean method changeTerme.

public void changeTerme(String id, int type) {
    selectedNode.setSelected(false);
    for (TreeNode node : selectedNodes) {
        node.setSelected(false);
    }
    String idTC;
    if (((MyTreeNode) selectedNode).isIsGroup() || ((MyTreeNode) selectedNode).isIsSubGroup()) {
        // type == 2) { //On vient d'un domaine
        idTC = id;
    } else {
        idTC = selectedTerme.getIdTopConcept();
    }
    // / ????? à comprendre pourquoi ?????
    if (type == 0) {
        boolean temp = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), id, selectedTerme.getIdTheso()).isTopConcept();
        if (temp) {
            type = 2;
        } else {
            type = 3;
        }
    }
    MyTreeNode mTN = new MyTreeNode(type, id, selectedTerme.getIdTheso(), selectedTerme.getIdlangue(), selectedTerme.getIdDomaine(), selectedTerme.getTypeDomaine(), idTC, null, null, null);
    selectedTerme.majTerme(mTN);
    selectedNode = mTN;
    reExpand();
    vue.setOnglet(0);
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 23 with MyTreeNode

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

the class NewTreeBean method reExpandNodes.

private void reExpandNodes(TreeNode tn, ArrayList<String> ids, String id) {
    for (TreeNode child : tn.getChildren()) {
        if (child == null || ((MyTreeNode) child).getIdConcept() == null)
            continue;
        if (ids.contains(((MyTreeNode) child).getIdConcept())) {
            child.setExpanded(true);
            this.onNodeExpand(child);
            reExpandNodes(child, ids, id);
        }
        if ((((MyTreeNode) child).getIdConcept()).equals(id)) {
            selectedNode = child;
            selectedNode.setSelected(true);
        }
    }
}
Also used : MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 24 with MyTreeNode

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

the class SelectedTerme method majSearch.

public void majSearch() {
    if (nodeSe.isTopConcept()) {
        type = 2;
    } else {
        type = 3;
    }
    MyTreeNode mtn = new MyTreeNode(type, nodeSe.getIdConcept(), nodeSe.getIdThesaurus(), nodeSe.getIdLang(), nodeSe.getIdGroup(), nodeSe.getTypeGroup(), null, null, nodeSe.getLexical_value(), null);
    majTerme(mtn);
}
Also used : MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)

Example 25 with MyTreeNode

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

the class SelectedThesaurus method preRenderView.

/**
 * récupère la variable URL et affiche le terme qu'elle désigne
 */
public void preRenderView() {
    // if the URL is for Concept
    if (idCurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type;
        Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
        if (c.isTopConcept()) {
            type = 2;
        } else {
            type = 3;
        }
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idCurl, idTurl, idLurl, c.getIdGroup(), "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is for Groups
    if (idGurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type = 1;
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is only for thésaurus
    if (idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        /*   if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
                idCurl = null;
                idGurl = null;
                idTurl = null;
                return;
            }*/
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        // MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null);
        // tree.getSelectedTerme().majTerme(mTN);
        // tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
    }
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

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