Search in sources :

Example 16 with NodeGroup

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

the class NewTreeBean method getGroupAndSubGroup.

/**
 * *********************************fin des fonctions drag drop
 * ******************************************
 * **********************************************************************
 */
/**
 *****fonction de contrôle de l'arbre
 *    /**********************************************************************
 */
/**
 * @param lang
 */
public void getGroupAndSubGroup(String lang) {
    this.groupIds = new ArrayList<>();
    this.groupLexicalValues = new ArrayList<>();
    ArrayList<NodeGroup> ncg = new GroupHelper().getListRootConceptGroup(connect.getPoolConnexion(), idThesoSelected, lang);
    for (NodeGroup ng : ncg) {
        this.groupIds.add(ng.getConceptGroup().getIdgroup());
        this.groupLexicalValues.add(ng.getLexicalValue() + " (" + ng.getConceptGroup().getIdgroup() + ")");
    }
}
Also used : GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 17 with NodeGroup

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

Example 18 with NodeGroup

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup 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);
    }
}
Also used : DefaultTreeNode(org.primefaces.model.DefaultTreeNode) 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) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 19 with NodeGroup

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

the class SelectedThesaurus method addGroup.

/**
 * Création d'un domaine avec mise à jour dans l'arbre
 *
 * @param codeTypeGroup
 * @param titleGroup
 * @return
 */
// private String typeDom;
public String addGroup(String codeTypeGroup, String titleGroup) {
    String idGroup = null;
    if (titleGroup.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error7")));
    } else {
        nodeCG.setLexicalValue(titleGroup);
        nodeCG.setIdLang(thesaurus.getLanguage());
        nodeCG.getConceptGroup().setIdthesaurus(thesaurus.getId_thesaurus());
        /*
            if(typeDom == null || typeDom.equals("")){
                 typeDom = getTypeDomainePere();
                 haveFather = true;
            }
            

            if (typeDom != null && haveFather) {
                nodeCG.getConceptGroup().setIdtypecode(typeDom);
            } else {
                nodeCG.getConceptGroup().setIdtypecode(codeTypeGroup);

            }*/
        if (codeTypeGroup.isEmpty()) {
            codeTypeGroup = "MT";
        }
        nodeCG.getConceptGroup().setIdtypecode(codeTypeGroup);
        GroupHelper cgh = new GroupHelper();
        int idUser = tree.getSelectedTerme().getUser().getUser().getId();
        idGroup = cgh.addGroup(connect.getPoolConnexion(), nodeCG, cheminSite, arkActive, idUser);
        nodeCG = new NodeGroup();
        vue.setSelectedActionDom(PropertiesNames.noActionDom);
        tree.reInit();
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", titleGroup + " " + langueBean.getMsg("theso.info1.2")));
    }
    return idGroup;
}
Also used : FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 20 with NodeGroup

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

the class StatBean method getGroupFromThesaurus.

/**
 * #JM
 * Méthode pour avoir les grouep d'un thésaurus
 * @param idTheso
 * @param langue
 */
public void getGroupFromThesaurus(String idTheso, String langue) {
    ArrayList<NodeGroup> ngs = new GroupHelper().getListConceptGroup(connect.getPoolConnexion(), idTheso, langue);
    statGroup = new ArrayList<>();
    for (NodeGroup ng : ngs) {
        this.statGroup.add(ng.getLexicalValue() + "(" + ng.getConceptGroup().getIdgroup() + ")");
    }
}
Also used : GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Aggregations

NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)29 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)18 ArrayList (java.util.ArrayList)8 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 SQLException (java.sql.SQLException)7 Statement (java.sql.Statement)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)5 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)4 ConceptGroup (mom.trd.opentheso.bdd.datas.ConceptGroup)3 StatisticHelper (mom.trd.opentheso.bdd.helper.StatisticHelper)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)2 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)2 TreeNode (org.primefaces.model.TreeNode)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 FacesMessage (javax.faces.application.FacesMessage)1