Search in sources :

Example 26 with GroupHelper

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

the class SelectedTerme method majGroup.

/**
 * chargement des groupes d'un concept
 * #MR
 */
private void majGroup() {
    GroupHelper groupHelper = new GroupHelper();
    String labelGroup;
    boolean first = true;
    ArrayList<String> idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), idTheso, idC);
    for (String idGroup : idGroupList) {
        labelGroup = groupHelper.getLexicalValueOfGroup(connect.getPoolConnexion(), idGroup, idTheso, idlangue);
        if (first) {
            microTheso = labelGroup;
            first = false;
        } else
            microTheso += ", " + labelGroup;
        NodeGroupIdLabel nodeGroupIdLabeltmp = new NodeGroupIdLabel();
        nodeGroupIdLabeltmp.setIdGroup(idGroup);
        nodeGroupIdLabeltmp.setLabel(labelGroup);
        nodeGroupIdLabel.add(nodeGroupIdLabeltmp);
    }
}
Also used : NodeGroupIdLabel(mom.trd.opentheso.bdd.helper.nodes.NodeGroupIdLabel) PrefixString(com.k_int.IR.QueryModels.PrefixString) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 27 with GroupHelper

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

the class SelectedTerme method delSpe.

// ancien code qui ne marche pas
/*   
     if(termeGenerique.size() == 1) { // Le concept devient orphelin
     new ConceptHelper().deleteConceptFromTable(connect.getPoolConnexion(), idC, idTheso);
     new OrphanHelper().addNewOrphan(connect.getPoolConnexion(), idC, idTheso);
            
     if(new GroupHelper().isIdOfGroup(connect.getPoolConnexion(), id, idTheso)) {
     new RelationsHelper().setRelationTopConcept(connect.getPoolConnexion(), idC, idTheso, id, false);
     } else {
     new RelationsHelper().deleteRelationBT(connect.getPoolConnexion(), idC, idTheso, id);
     }
            
     termeGenerique = new ArrayList<>();
     }  else {
     // On supprime l'ancien domaines si besoin
     ArrayList<String> groupBT;
     if(type == 2) {
     groupBT = new ArrayList<>();
     groupBT.add(id);
     } else {
     groupBT = new ConceptHelper().getListGroupIdOfConcept(connect.getPoolConnexion(), id, idTheso);
     }
     ArrayList<String> groupCurrent = new ConceptHelper().getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
     ArrayList<String> delGroup = new ArrayList<>();
     for(String s : groupBT) {
     if(groupCurrent.contains(s)) {
     delGroup.add(s);
     }
     }
     delBranchGroup(delGroup, idC);
            
     if(new GroupHelper().isIdOfGroup(connect.getPoolConnexion(), id, idTheso)) {
     new RelationsHelper().setRelationTopConcept(connect.getPoolConnexion(), idC, idTheso, id, false);
     } else {
     new RelationsHelper().deleteRelationBT(connect.getPoolConnexion(), idC, idTheso, id);
     }
            
     termeGenerique = new ArrayList<>();
     majTGen();
     }  
     vue.setAddTGen(false);
        
     }*/
/**
 * Supprime les relations qui lient le concept au Concept père
 *
 * @param id l'identifiant du fils
 * @return true or false
 */
public boolean delSpe(String id) {
    // On regarde si le fils devient orphelin
    ArrayList<Entry<String, String>> sonFathers = new ArrayList<>();
    // On ajoute le domaine
    ArrayList<String> listIdGroup = new ConceptHelper().getListGroupParentIdOfConcept(connect.getPoolConnexion(), id, idTheso);
    HashMap<String, String> tempMap1 = new HashMap<>();
    for (String group : listIdGroup) {
        tempMap1.put(group, new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), group, idTheso, idlangue));
    }
    sonFathers.addAll(tempMap1.entrySet());
    ArrayList<NodeBT> tempBT = new RelationsHelper().getListBT(connect.getPoolConnexion(), id, idTheso, idlangue);
    HashMap<String, String> tempMap2 = new HashMap<>();
    for (NodeBT nbt : tempBT) {
        tempMap2.put(nbt.getIdConcept(), nbt.getTitle());
    }
    sonFathers.addAll(tempMap2.entrySet());
    if (sonFathers.size() <= 1) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            if (!new ConceptHelper().deleteConceptFromTable(conn, id, idTheso, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            if (!new RelationsHelper().deleteRelationBT(conn, id, idTheso, idC, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            if (!new OrphanHelper().addNewOrphan(conn, id, idTheso)) {
                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;
        }
    } else {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            // On supprime l'ancien domaines si besoin
            ArrayList<String> groupCurrent;
            if (type == 1) {
                groupCurrent = new ArrayList<>();
                groupCurrent.add(idC);
            } else {
                groupCurrent = new ConceptHelper().getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
            }
            ArrayList<String> groupNT = new ConceptHelper().getListGroupIdOfConcept(connect.getPoolConnexion(), id, idTheso);
            ArrayList<String> delGroup = new ArrayList<>();
            for (String s : groupCurrent) {
                if (groupNT.contains(s)) {
                    delGroup.add(s);
                }
            }
            if (!delBranchGroup(delGroup, id)) {
                conn.rollback();
                conn.close();
                return false;
            }
            if (type == 1) {
                if (!new RelationsHelper().setRelationTopConcept(conn, id, idTheso, idC, false, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            } else if (!new RelationsHelper().deleteRelationBT(conn, id, idTheso, idC, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            conn.commit();
            conn.close();
            ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
            termesSpecifique = new ArrayList<>();
            HashMap<String, String> tempMap3 = new HashMap<>();
            for (NodeNT nnt : tempNT) {
                tempMap3.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
            }
            termesSpecifique.addAll(tempMap3.entrySet());
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
    return true;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) Entry(java.util.Map.Entry) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 28 with GroupHelper

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

the class SelectedTerme method editGroupName.

/**
 * *************************************** EDITION
 * ****************************************
 */
/**
 * Permet de modifier le nom d'un Group ou sousGroup
 *
 * @param idTheso
 * @param idGroup
 * @param idLangue
 * @param value
 * @return
 * #MR
 */
public boolean editGroupName(String idTheso, String idGroup, String idLangue, String value) {
    GroupHelper groupHelper = new GroupHelper();
    ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
    conceptGroupLabel.setIdthesaurus(idTheso);
    conceptGroupLabel.setIdgroup(idGroup);
    conceptGroupLabel.setLang(idLangue);
    conceptGroupLabel.setLexicalvalue(value);
    // vérification si le Groupe est traduit déjà, on fait un update
    if (groupHelper.isHaveTraduction(connect.getPoolConnexion(), idGroup, idTheso, idLangue)) {
        if (!groupHelper.updateConceptGroupLabel(connect.getPoolConnexion(), conceptGroupLabel, user.getUser().getId())) {
            return false;
        }
    } else {
        if (!groupHelper.addGroupTraduction(connect.getPoolConnexion(), conceptGroupLabel, user.getUser().getId())) {
            return false;
        }
    }
    return true;
}
Also used : ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 29 with GroupHelper

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

the class SelectedTerme method majLangueGroup.

private void majLangueGroup() {
    langues = new ArrayList<>();
    ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idC, idTheso, idlangue);
    HashMap<String, String> tempMapL = new HashMap<>();
    for (NodeGroupTraductions ngt : tempNGT) {
        tempMapL.put(ngt.getIdLang(), ngt.getTitle());
    }
    langues.addAll(tempMapL.entrySet());
}
Also used : HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 30 with GroupHelper

use of mom.trd.opentheso.bdd.helper.GroupHelper 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)

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