Search in sources :

Example 11 with NodeNT

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

the class SelectedTerme method creerTermeSpe.

/**
 * Corrigé par M.R. Ajoute une relation terme spécifique au concept courant
 *
 * @param idCNT
 * @return true or false
 */
public boolean creerTermeSpe(String idCNT) {
    ConceptHelper conceptHelper = new ConceptHelper();
    if (new OrphanHelper().isOrphan(connect.getPoolConnexion(), idCNT, idTheso)) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            ArrayList<String> newGroup = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
            for (String s : newGroup) {
                Concept c = new Concept();
                c.setIdConcept(idCNT);
                c.setIdGroup(s);
                c.setIdThesaurus(idTheso);
                c.setStatus("D");
                String idConcept = conceptHelper.addConceptInTable(conn, c, user.getUser().getId());
                // si ça se passe mal, on ajoute rien;
                if (idConcept == null) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            }
            if (!new OrphanHelper().deleteOrphan(conn, idCNT, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
            // On crée les relations
            if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, 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;
        }
    } else if (type == 1) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            if (new ConceptHelper().haveThisGroup(connect.getPoolConnexion(), idCNT, idC, idTheso)) {
                if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            } else {
                ArrayList<String> newGroup = new ArrayList<>();
                newGroup.add(idC);
                if (!addBranchGroup(newGroup, idCNT)) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
                if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, 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);
        }
    } else {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            // On ajoute les nouveaux domaines s'il y en a
            ArrayList<String> groupNT = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idCNT, idTheso);
            ArrayList<String> groupCurrent = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
            ArrayList<String> newGroup = new ArrayList<>();
            for (String s : groupCurrent) {
                if (!groupNT.contains(s)) {
                    newGroup.add(s);
                }
            }
            if (!addBranchGroup(newGroup, idCNT)) {
                conn.rollback();
                conn.close();
                return false;
            }
            // On crée les relations
            if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, 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;
        }
    }
    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);
    return true;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) HashMap(java.util.HashMap) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 12 with NodeNT

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

the class ExportTxtHelper method countIndentation.

/**
 * permet de compter le nombre de décalalge pour chaque type de données
 * concept : pour l'hiérarchie NT : pour le nombre maxi de NT existant dans
 * le thésaurus ou le domaine choisi RT ... UF ....
 *
 * @param idConcept
 * @param indentation
 */
private void countIndentation(String idConcept, String indentation) {
    ArrayList<NodeNT> childList = new RelationsHelper().getListNT(ds, idConcept, idTheso, selectedLang);
    if (childList == null) {
        return;
    }
    // indentation des concepts par hiérarchie
    indentation += "\t";
    int tot = StringUtils.countMatches(indentation, "\t");
    if (tot > indentationConcept) {
        indentationConcept = tot;
    }
    // indentation des NT nombre maxi
    if (selectedOptions.contains("nt")) {
        int totNT = new RelationsHelper().getCountOfNT(ds, idConcept, idTheso);
        if (totNT > indentationNT) {
            indentationNT = totNT;
        }
    }
    // indentation des BT nombre maxi
    if (selectedOptions.contains("bt")) {
        int totBT = new RelationsHelper().getCountOfBT(ds, idConcept, idTheso);
        if (totBT > indentationBT) {
            indentationBT = totBT;
        }
    }
    // indentation des RT nombre maxi
    if (selectedOptions.contains("rt")) {
        int totRT = new RelationsHelper().getCountOfRT(ds, idConcept, idTheso);
        if (totRT > indentationRT) {
            indentationRT = totRT;
        }
    }
    // indentation des UF nombre maxi
    if (selectedOptions.contains("uf")) {
        int totUF = new RelationsHelper().getCountOfUF(ds, idConcept, idTheso, selectedLang);
        if (totUF > indentationUF) {
            indentationUF = totUF;
        }
    }
    // indentation des Groups nombre maxi
    if (selectedOptions.contains("groups")) {
        int totGroup = new GroupHelper().getCountOfGroups(ds, idConcept, idTheso);
        if (totGroup > indentationGroups) {
            indentationGroups = totGroup;
        }
    }
    // indentation traductions
    if (selectedOptions.contains("traductions")) {
        int totTraductions = new TermHelper().getCountOfTraductions(ds, idConcept, idTheso, selectedLang);
        if (totTraductions > indentationTraductions) {
            indentationTraductions = totTraductions;
        }
    }
    // indentation notes
    if (selectedOptions.contains("notes")) {
        int totNotes = new NoteHelper().getCountOfNotes(ds, idConcept, idTheso, selectedLang);
        if (totNotes > indentationNotes) {
            indentationNotes = totNotes;
        }
    }
    for (NodeNT nodeNT : childList) {
        countIndentation(nodeNT.getIdConcept(), indentation);
    }
}
Also used : NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 13 with NodeNT

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

the class ExportTxtHelper method writeConceptRecursive.

/**
 * fonction recursive qui sert a ecrire tout les fils des term
 *
 * @param id
 * @param indentation
 * @param paragraphs
 * @param idToDoc
 */
private void writeConceptRecursive(String idConcept, String indentation) {
    ArrayList<NodeNT> childList = new RelationsHelper().getListNT(ds, idConcept, idTheso, selectedLang);
    if (childList == null) {
        return;
    }
    indentation += "\t";
    for (NodeNT nodeNT : childList) {
        writeConceptsInfo(nodeNT.getIdConcept(), indentation);
        writeConceptRecursive(nodeNT.getIdConcept(), indentation);
    }
}
Also used : NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Aggregations

NodeNT (mom.trd.opentheso.bdd.helper.nodes.NodeNT)13 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)10 PrefixString (com.k_int.IR.QueryModels.PrefixString)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)7 HashMap (java.util.HashMap)5 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 Concept (mom.trd.opentheso.bdd.datas.Concept)4 ArrayList (java.util.ArrayList)3 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)3 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)3 FacesMessage (javax.faces.application.FacesMessage)2 Term (mom.trd.opentheso.bdd.datas.Term)2 OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Entry (java.util.Map.Entry)1 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1