Search in sources :

Example 46 with ConceptHelper

use of mom.trd.opentheso.bdd.helper.ConceptHelper 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();
        if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso())) {
            // if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) { //pour détecter les noeuds type Group/collecton/MT/Thèmes ...
            // pour group ?
            myTreeNode.setTypeConcept(1);
            // 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());
        } else {
            listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue());
        // 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 la numérotation des sous groupes
        int count = 0;
        // 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.haveSubGroup(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 ***
                 */
                ((MyTreeNode) treeNode2).setPrefix(myTreeNode.getNumerotation());
                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());
                /**
                 *fin code numérotation des sous groupes****
                 */
                new DefaultTreeNode(null, treeNode2);
            }
        /**
         *fin de la partie de code pouvant comporter des éléments inutiles
         */
        }
        /**
         *afin de classer les sous groupes avec la numérotation on trie
         *la liste de treeNode on est obligé de récréer un noeuds MyTreeNode pour
         * chaque treenode de la liste, pour pouvoir l'accrocher à l'arbre
         *
         *#jm
         */
        Collections.sort(listeTreeNode, new TreeNodeComparator());
        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 {
                        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 {
                        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 {
                        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 {
                        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());
        }
    }
}
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) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 47 with ConceptHelper

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

the class SearchBean method researchDeconn.

/**
 * méthode pour la recherceh qui ne passe pas par l'arbre
 */
public void researchDeconn() {
    ConceptHelper ch = new ConceptHelper();
    SearchHelper sh = new SearchHelper();
    if (onlyNote) {
        result1 = new SearchHelper().searchNote(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain);
    } else {
        if (onlyNotation) {
            result1 = new SearchHelper().searchNotation(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup);
        } else {
            result1 = new SearchHelper().searchTerm(connect.getPoolConnexion(), rechercheDeconn, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain, withNote);
        }
    }
    nbRes = result1.size();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper)

Example 48 with ConceptHelper

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

the class SelectedCandidat method newPropCandidat.

/**
 * Ajoute une proposition au candidat courant
 *
 * @param langue
 * @return
 */
public boolean newPropCandidat(String langue) {
    try {
        if (selectedNvx != null) {
            if (!selectedNvx.getIdConcept().isEmpty())
                if (!setLevelInfos(selectedNvx.getIdConcept(), langue))
                    return false;
        } else {
            niveauEdit = "";
        }
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (selectedNvx != null) {
            niveauEdit = selectedNvx.getIdConcept();
        } else {
            niveauEdit = "";
        }
        if (domaineEdit == null) {
            domaineEdit = "";
        }
        if (!new CandidateHelper().addPropositionCandidat_RollBack(conn, selected.getIdConcept(), theUser.getUser().getId(), idTheso, noteEdit, niveauEdit, domaineEdit)) {
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, infoCdt.getNodesUser().get(0).getId());
        infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso));
        modifiedProposition = np.getModified();
        createdProposition = np.getCreated();
        nomsProp = new ArrayList<>();
        for (NodeUser nuse : infoCdt.getNodesUser()) {
            nomsProp.add(nuse.getName());
        }
        note = np.getNote();
        niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
        if (!np.getIdConceptParent().isEmpty()) {
            niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langueTheso) + " (" + np.getIdConceptParent() + ")";
            showGroup(np);
        // domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langueTheso) + " (" + np.getIdGroup() + ")";
        }
        selected.setNbProp(selected.getNbProp() + 1);
        // envoie d'email d'alerte !!
        /*  int minAlert = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso).getNbAlertCdt();
            if (selected.getNbProp() >= minAlert) {
                ArrayList<String> lesMails = new UserHelper().getMailAdmin(connect.getPoolConnexion(), idTheso);
                for (String mail : lesMails) {
                    if (mail != null && !mail.trim().equals("")) {
                        String message =  "Le candidat " + selected.getValue() + " a atteint le seuil d'alerte de " + minAlert + " fois.";
                        envoyerMailAlert(mail, message);
                    }
                }
            }*/
        initNewProposal();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(SelectedCandidat.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) Connection(java.sql.Connection) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 49 with ConceptHelper

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

the class SelectedCandidat method onChange.

/**
 * ************************** MISE A JOUR ****************************
 */
/**
 * Changement de la proposition courrante à la sélection du nom d'un
 * utilisateur dans la table des propositions
 *
 * @param event
 */
public void onChange(TabChangeEvent event) {
    String nom = (String) event.getData();
    for (NodeUser nu : infoCdt.getNodesUser()) {
        if (nom.equals(nu.getName())) {
            NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, nu.getId());
            note = np.getNote();
            modifiedProposition = np.getModified();
            if (!np.getIdConceptParent().isEmpty()) {
                niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langueTheso) + " (" + np.getIdConceptParent() + ")";
                showGroup(np);
            // domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langueTheso) + " (" + np.getIdGroup() + ")";
            }
            break;
        }
    }
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 50 with ConceptHelper

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

the class SelectedTerme method creerTermeSpe.

/**
 * *************************************** CREATION
 * ****************************************
 */
/**
 * Crée un nouveau terme spécifique au terme sélectionné
 *
 * @param selecedTerm
 * @return true or false
 */
public boolean creerTermeSpe(MyTreeNode selecedTerm) {
    ConceptHelper instance = new ConceptHelper();
    if (user.nodePreference == null)
        return false;
    instance.setNodePreference(user.getNodePreference());
    // 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
    if (selecedTerm.isIsSubGroup() || selecedTerm.isIsGroup()) {
        // ici c'est le cas d'un Group ou Sous Group, on crée un TT Top Terme
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdConcept());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        if (instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        ConceptHelper ch = new ConceptHelper();
        ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeConceptTree nct : tempNT) {
            tempMap.put(nct.getIdConcept(), nct.getTitle());
        }
        termesSpecifique.addAll(tempMap.entrySet());
    } else {
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdCurrentGroup());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        // String idTC = idTopConcept;
        String idP = idC;
        if (instance.addConcept(connect.getPoolConnexion(), idP, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        concept.getUserName();
        ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeNT nnt : tempNT) {
            tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
        }
        termesSpecifique.addAll(tempMap.entrySet());
    }
    vue.setAddTSpe(false);
    valueEdit = "";
    return true;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) Term(mom.trd.opentheso.bdd.datas.Term) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) FacesMessage(javax.faces.application.FacesMessage) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Aggregations

ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)125 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)38 SQLException (java.sql.SQLException)36 Connection (java.sql.Connection)29 ArrayList (java.util.ArrayList)28 FacesMessage (javax.faces.application.FacesMessage)23 Concept (mom.trd.opentheso.bdd.datas.Concept)18 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)16 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)16 Term (mom.trd.opentheso.bdd.datas.Term)15 PrefixString (com.k_int.IR.QueryModels.PrefixString)14 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)14 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)13 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)12 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)12 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)12 HashMap (java.util.HashMap)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)9 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)9