Search in sources :

Example 1 with OrphanHelper

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

the class NewTreeBean method loadOrphan.

public void loadOrphan(String idTheso, String langue) {
    String typeNode, value = "";
    /*
        this.typeMot = type;
      this.idMot = id;
      this.idTheso = idT;
      this.langue = l;
      this.idDomaine = idD;
      this.typeDomaine = typeDomaine; 
      this.idTopConcept = idTC;
         */
    TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, null, idTheso, langue, null, null, null, "orphan", langueBean.getMsg("index.orphans"), root);
    orphans = new OrphanHelper().getListOrphanId(connect.getPoolConnexion(), idTheso);
    for (String idC : orphans) {
        if (new ConceptHelper().haveChildren(connect.getPoolConnexion(), idTheso, idC)) {
            typeNode = "dossier";
        } else {
            typeNode = "fichier";
        }
        Term term = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, langue);
        if (term != null) {
            value = term.getLexical_value() + " (id_" + idC + ")";
            Concept temp = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idC, idTheso);
            MyTreeNode mtn = new MyTreeNode(3, idC, idTheso, langue, "Orphan", null, null, typeNode, value, dynamicTreeNode);
            if (typeNode.equals("dossier")) {
                new DefaultTreeNode("fake", mtn);
            }
        }
    }
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) Concept(mom.trd.opentheso.bdd.datas.Concept) 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) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) Term(mom.trd.opentheso.bdd.datas.Term) StructIdBroaderTerm(mom.trd.opentheso.dragdrop.StructIdBroaderTerm) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 2 with OrphanHelper

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

the class SelectedTerme method delGene.

/**
 * Supprime la relation hiérarchique qui lie le terme courant à son père
 *
 * @param id l'identifiant du père
 * @return true or false
 */
public boolean delGene(String id) {
    // id est l'identifiant du concept à qui on doit supprimer la relation BT
    boolean TGisDomaine = false;
    if (idDomaine.equals(id)) {
        // cas où le générique est un domaine // donc le concept est un TT
        TGisDomaine = true;
    }
    // premier cas, si la branche n'a qu'un BT, alors elle devient orpheline
    if (termeGenerique.size() == 1) {
        // Le concept devient orphelin
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            /*   if (!new ConceptHelper().deleteConceptFromTable(conn, idC, idTheso, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }*/
            if (!new OrphanHelper().addNewOrphan(conn, idC, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
            if (new GroupHelper().isIdOfGroup(connect.getPoolConnexion(), id, idTheso)) {
                if (!new RelationsHelper().setRelationTopConcept(conn, idC, idTheso, id, false, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            } else // on coupe la branche de son BT
            if (!new RelationsHelper().deleteRelationBT(conn, idC, idTheso, id, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            conn.commit();
            conn.close();
            termeGenerique = new ArrayList<>();
            vue.setAddTGen(0);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
    // deuxième cas où la branche a plusieurs termes générique
    if (termeGenerique.size() > 1) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            if (TGisDomaine) {
                if (!new RelationsHelper().deleteRelationTT(conn, idC, idTheso, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            } else if (!new RelationsHelper().deleteRelationBT(conn, idC, idTheso, id, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            conn.commit();
            conn.close();
            termeGenerique = new ArrayList<>();
            majTGen();
            vue.setAddTGen(0);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
    // troisième cas, si la branche est à deplacer dans un nouveau domaine, alors il faut lui rajouter ce nouveau domaine.
    return false;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 3 with OrphanHelper

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

the class SelectedTerme method addTermeGene.

/**
 * Ajoute une relation terme générique au concept courant
 *
 * @param idNT
 * @param idBT
 * @return true or false
 */
public boolean addTermeGene(String idNT, String idBT) {
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (termeGenerique.isEmpty()) {
            // c'était un orphelin
            if (!new OrphanHelper().deleteOrphan(conn, idNT, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // On ajoute la realtion BT au concept
        if (!new RelationsHelper().addRelationBT(conn, idNT, idTheso, idBT, user.getUser().getId())) {
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    termeGenerique = new ArrayList<>();
    majTGen();
    vue.setAddTGen(0);
    return true;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 4 with OrphanHelper

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

the class SelectedTerme method addTermeGeneOtherGroup.

/**
 * Ajoute une relation terme générique au concept courant
 *
 * @param idConcept
 * @param idGroup
 * @param idNewConceptBT
 * @return true or false
 */
public boolean addTermeGeneOtherGroup(String idConcept, String idGroup, String idNewConceptBT) {
    ConceptHelper conceptHelper = new ConceptHelper();
    RelationsHelper relationsHelper = new RelationsHelper();
    GroupHelper groupHelper = new GroupHelper();
    String idNewGroup = conceptHelper.getGroupIdOfConcept(connect.getPoolConnexion(), idNewConceptBT, idTheso);
    if (idNewGroup == null) {
        return false;
    }
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (termeGenerique.isEmpty()) {
            // c'était un orphelin
            if (!new OrphanHelper().deleteOrphan(conn, idConcept, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // On ajoute la realtion BT au concept
        if (!relationsHelper.addRelationBT(conn, idConcept, idTheso, idNewConceptBT, user.getUser().getId())) {
            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(), idConcept, idTheso, lisIds);
        // on ajoute le nouveau domaine à la branche
        if (!groupHelper.addDomainToBranch(conn, lisIds, idNewGroup, idTheso, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    termeGenerique = new ArrayList<>();
    majTGen();
    return true;
}
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) PrefixString(com.k_int.IR.QueryModels.PrefixString) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 5 with OrphanHelper

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

the class AutoCompletBean method moveBrancheFromOrphinToGroup.

// ///////
// // 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 moveBrancheFromOrphinToGroup() {
    // 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().getIdUser())) {
            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 = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso());
        // 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;
        }
        OrphanHelper orphanHelper = new OrphanHelper();
        if (!orphanHelper.deleteOrphanBranch2(conn, terme.getIdC(), terme.getIdTheso(), terme.getUser().getUser().getIdUser())) {
            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 : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) FacesMessage(javax.faces.application.FacesMessage) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Aggregations

OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)8 Connection (java.sql.Connection)7 SQLException (java.sql.SQLException)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)6 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)5 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)5 PrefixString (com.k_int.IR.QueryModels.PrefixString)3 ArrayList (java.util.ArrayList)3 FacesMessage (javax.faces.application.FacesMessage)3 HttpURLConnection (java.net.HttpURLConnection)2 JsonString (javax.json.JsonString)2 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)2 Concept (mom.trd.opentheso.bdd.datas.Concept)2 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Term (mom.trd.opentheso.bdd.datas.Term)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)1 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)1 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)1