Search in sources :

Example 36 with GroupHelper

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

the class AutoCompletBean method moveBrancheToGroupOfOtherGroup.

// ///////
// // Other Group
// ///////
/**
 * Déplace la branche vers la racine d'un autre Group
 * (Groupe/Domaine/Collection), la tete de la branche devient un TT
 * (TopTerme)
 *
 * @return
 */
public boolean moveBrancheToGroupOfOtherGroup() {
    // terme.getIdC = le concept sélectionné
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        /*    if (selectedAtt == null || selectedAtt.getIdGroup().equals("")) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error1")));
                return false;
            }*/
        ConceptHelper conceptHelper = new ConceptHelper();
        GroupHelper groupHelper = new GroupHelper();
        // au concept la relation TT
        if (!conceptHelper.moveBranchToAnotherMT(conn, terme.getIdC(), // ancien Group
        idOld, // ancien Group
        terme.getIdDomaine(), // nouveau Group
        selectedAtt.getIdGroup(), terme.getIdTheso(), terme.getUser().getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso(), lisIds);
        // on supprime l'ancien Groupe de la branche
        if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, terme.getIdDomaine(), terme.getIdTheso())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        // on ajoute le nouveau domaine à la branche
        if (!groupHelper.setDomainToBranch(conn, lisIds, selectedAtt.getIdGroup(), terme.getIdTheso())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("autoComp.info2")));
        tree.reInit();
        tree.reExpand();
        selectedAtt = new NodeAutoCompletion();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(AutoCompletBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) FacesMessage(javax.faces.application.FacesMessage) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 37 with GroupHelper

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

the class AutoCompletBean method moveBrancheFromDomainToConceptOtherGroup.

/**
 * Déplace la branche du thésaurus, d'un domaine à un concept d'un autre
 * Group
 *
 * @return
 */
public boolean moveBrancheFromDomainToConceptOtherGroup() {
    if (selectedAtt == null || selectedAtt.getIdConcept().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error1")));
        return false;
    }
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        ConceptHelper conceptHelper = new ConceptHelper();
        GroupHelper groupHelper = new GroupHelper();
        // au concept la relation TT
        if (!conceptHelper.moveBranchFromMT(conn, terme.getIdC(), selectedAtt.getIdConcept(), terme.getIdDomaine(), terme.getIdTheso(), terme.getUser().getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso(), lisIds);
        // on supprime l'ancien Groupe de la branche
        ArrayList<String> domsOld = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso());
        for (String domsOld1 : domsOld) {
            if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, domsOld1, terme.getIdTheso())) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // on ajoute le nouveau domaine à la branche
        ArrayList<String> domsNew = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), selectedAtt.getIdConcept(), terme.getIdTheso());
        for (String domsNew1 : domsNew) {
            if (!groupHelper.setDomainToBranch(conn, lisIds, domsNew1, terme.getIdTheso())) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
                conn.rollback();
                conn.close();
                return false;
            }
        }
        conn.commit();
        conn.close();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("autoComp.info2")));
        tree.reInit();
        tree.reExpand();
        selectedAtt = new NodeAutoCompletion();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(AutoCompletBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 38 with GroupHelper

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

the class AutoCompletBean method moveBranchFromOrphinToConcept.

// ////////////////////////////////////
// ////////////////////////////////////
// / partie pour les orphelins ////////
// ////////////////////////////////////
// ////////////////////////////////////
/**
 * Permet de déplacer une branche des orphelins vers un vers un concept
 * uniquement
 *
 * @return
 */
public boolean moveBranchFromOrphinToConcept() {
    // List selectedNode (c'est le noeud complet sélectionné)
    if (selectedAtt == null || selectedAtt.getIdConcept().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error1")));
        return false;
    }
    ConceptHelper conceptHelper = new ConceptHelper();
    GroupHelper groupHelper = new GroupHelper();
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        // permet de déplacer une branche simplement, en cas d'erreur, rien n'est écrit
        if (!conceptHelper.moveBranchToConceptOtherGroup(conn, terme.getIdC(), idOld, selectedAtt.getIdConcept(), terme.getIdTheso(), terme.getUser().getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            return false;
        }
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso(), lisIds);
        // on supprime l'ancien Groupe de la branche
        ArrayList<String> domsOld = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso());
        for (String domsOld1 : domsOld) {
            if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, domsOld1, terme.getIdTheso())) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // on ajoute le nouveau domaine à la branche
        ArrayList<String> domsNew = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), selectedAtt.getIdConcept(), terme.getIdTheso());
        for (String domsNew1 : domsNew) {
            if (!groupHelper.setDomainToBranch(conn, lisIds, domsNew1, terme.getIdTheso())) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
                conn.rollback();
                conn.close();
                return false;
            }
        }
        OrphanHelper orphanHelper = new OrphanHelper();
        if (!orphanHelper.deleteOrphanBranch2(conn, terme.getIdC(), terme.getIdTheso(), terme.getUser().getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("autoComp.info2")));
        tree.reInit();
        tree.reExpand();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(AutoCompletBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 39 with GroupHelper

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

the class HistoriqueBean method load.

public void load(String idThesaurus, String idConcept, String idTerm, String lang) {
    if (typeHisto == 0 && dateHisto != null) {
        conceptHisto = new ConceptHelper().getConceptHisoriqueFromDate(connect.getPoolConnexion(), idConcept, idThesaurus, dateHisto);
        groupHisto = new GroupHelper().getGroupHistoriqueFromDate(connect.getPoolConnexion(), idConcept, idThesaurus, dateHisto);
        noteHisto = new NoteHelper().getNoteHistoriqueFromDate(connect.getPoolConnexion(), idConcept, idThesaurus, idTerm, lang, dateHisto);
        relationHisto = new RelationsHelper().getRelationHistoriqueFromDate(connect.getPoolConnexion(), idConcept, idThesaurus, dateHisto, lang);
        nonPrefTermHisto = new TermHelper().getNonPreferredTermsHistoriqueFromDate(connect.getPoolConnexion(), idTerm, idThesaurus, lang, dateHisto);
        termHisto = new TermHelper().getTermsHistoriqueFromDate(connect.getPoolConnexion(), idTerm, idThesaurus, lang, dateHisto);
    } else if (typeHisto == 1) {
        conceptHisto = new ConceptHelper().getConceptHisoriqueAll(connect.getPoolConnexion(), idConcept, idThesaurus);
        groupHisto = new GroupHelper().getGroupHistoriqueAll(connect.getPoolConnexion(), idConcept, idThesaurus);
        noteHisto = new NoteHelper().getNoteHistoriqueAll(connect.getPoolConnexion(), idConcept, idThesaurus, idTerm, lang);
        relationHisto = new RelationsHelper().getRelationHistoriqueAll(connect.getPoolConnexion(), idConcept, idThesaurus, lang);
        nonPrefTermHisto = new TermHelper().getNonPreferredTermsHistoriqueAll(connect.getPoolConnexion(), idTerm, idThesaurus, lang);
        termHisto = new TermHelper().getTermsHistoriqueAll(connect.getPoolConnexion(), idTerm, idThesaurus, lang);
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 40 with GroupHelper

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

the class NewTreeBean method changeGroupType.

public void changeGroupType(String type) {
    MyTreeNode myTN = (MyTreeNode) this.selectedNode;
    if (!myTN.isIsGroup() && !myTN.isIsSubGroup()) {
        // normalement impossible
        return;
    }
    if (myTN.getTypeDomaine().equals(type)) {
        return;
    } else {
        myTN.setTypeDomaine(type);
        GroupHelper gh = new GroupHelper();
        gh.updateTypeGroup(this.connect.getPoolConnexion(), type, idThesoSelected, myTN.getIdConcept());
        ConceptHelper ch = new ConceptHelper();
        this.onNodeExpand(myTN);
        for (TreeNode sbn : myTN.getChildren()) {
            if (((MyTreeNode) sbn).isIsSubGroup())
                changeGroupType(type, sbn);
        }
    }
    reInit();
    this.initTree(idThesoSelected, myTN.getLangue());
    reExpand();
}
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) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Aggregations

GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)79 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)38 ArrayList (java.util.ArrayList)22 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)18 SQLException (java.sql.SQLException)16 Connection (java.sql.Connection)14 FacesMessage (javax.faces.application.FacesMessage)13 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)8 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)8 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)8 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)8 PrefixString (com.k_int.IR.QueryModels.PrefixString)7 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)6 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)6 HashMap (java.util.HashMap)5 Concept (mom.trd.opentheso.bdd.datas.Concept)5 OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)5 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)5