Search in sources :

Example 11 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper 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 12 with RelationsHelper

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

the class SelectedTerme method majTGen.

private void majTGen() {
    termeGenerique = new ArrayList<>();
    /*// On ajoute le domaine
        ArrayList<String> listIdGroup = new ConceptHelper().getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
        HashMap<String, String> tempMap = new HashMap<>();
        for (String group : listIdGroup) {
            tempMap.put(group, new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), group, idTheso, idlangue));
        }
        termeGenerique.addAll(tempMap.entrySet());*/
    ArrayList<NodeBT> tempBT = new RelationsHelper().getListBT(connect.getPoolConnexion(), idC, idTheso, idlangue);
    for (NodeBT nbt : tempBT) {
        HashMap<String, String> tempMap2 = new HashMap<>();
        if (nbt.getStatus().equals("hidden")) {
            if (nbt.getTitle().isEmpty())
                tempMap2.put(nbt.getIdConcept(), "<del>" + nbt.getIdConcept() + " (" + nbt.getRole() + ")" + "</del>");
            else
                tempMap2.put(nbt.getIdConcept(), "<del>" + nbt.getTitle() + " (" + nbt.getRole() + ")" + "</del>");
        } else {
            if (nbt.getTitle().isEmpty())
                tempMap2.put(nbt.getIdConcept(), nbt.getIdConcept() + " (" + nbt.getRole() + ")");
            else
                tempMap2.put(nbt.getIdConcept(), nbt.getTitle() + " (" + nbt.getRole() + ")");
        }
        termeGenerique.addAll(tempMap2.entrySet());
    }
}
Also used : NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 13 with RelationsHelper

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

the class SelectedTerme method majTSpeConceptOrder.

public void majTSpeConceptOrder() {
    termesSpecifique = new ArrayList<>();
    ArrayList<NodeNT> tempNT = new RelationsHelper().getListNTOrderByDate(connect.getPoolConnexion(), idC, idTheso, idlangue);
    writeTermesSpecifique(tempNT);
}
Also used : NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 14 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper 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 15 with RelationsHelper

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

the class NewTreeBean method onDragDrop.

/**
 * *******************fonctions drag drop #JM*****************************
 */
/**
 * ***********************************************************************
 */
/**
 * Fonction pour récupérer l'éveneme drag drop de l'arbre
 *
 * @param event
 */
public void onDragDrop(TreeDragDropEvent event) {
    MyTreeNode dragNode = (MyTreeNode) event.getDragNode();
    MyTreeNode dropNode = (MyTreeNode) event.getDropNode();
    idsBT = new ArrayList<>();
    idsBTRemoveNode = new ArrayList<>();
    TreeChange treeChange = new TreeChange();
    // int dropIndex = event.getDropIndex();
    this.draggedNode = dragNode;
    this.parentId = dragNode.getIdParent();
    this.droppedNode = dropNode;
    ArrayList<String> idsbt = null;
    RelationsHelper relationsHelper = new RelationsHelper();
    ConceptHelper conceptHelper = new ConceptHelper();
    GroupHelper groupHelper = new GroupHelper();
    if (dragNode.isIsTopConcept()) {
        idsbt = dragNode.getOtherGroup();
    } else {
        idsbt = relationsHelper.getListIdOfBT(connect.getPoolConnexion(), dragNode.getIdConcept(), idThesoSelected);
    }
    ArrayList<StructIdBroaderTerm> sibt = new ArrayList<>();
    for (String id : idsbt) {
        StructIdBroaderTerm elem = new StructIdBroaderTerm();
        String idLang = (selectedTerme.getIdlangue().isEmpty()) ? defaultLanguage : selectedTerme.getIdlangue();
        String idGroup = conceptHelper.getGroupIdOfConcept(connect.getPoolConnexion(), id, idThesoSelected);
        String lexicalValue = conceptHelper.getLexicalValueOfConcept(connect.getPoolConnexion(), id, idThesoSelected, idLang);
        String lexicalValueGroup = groupHelper.getLexicalValueOfGroup(connect.getPoolConnexion(), idGroup, idThesoSelected, idLang);
        elem.setIdBroaderTerm(id);
        elem.setIdGroupBroaderTerm(idGroup);
        elem.setLexicalValueTerm(lexicalValue);
        elem.setLexicalValueGroup(lexicalValueGroup);
        sibt.add(elem);
    }
    idsBT.addAll(sibt);
    if ("fichier".equals(event.getDropNode().getType())) {
        treeChange.changeLeafToDirectory(event.getDragNode(), event.getDropNode());
    }
    if (!"fichier".equals(event.getDropNode().getType()) && !"dossier".equals(event.getDropNode().getType())) {
        treeChange.changeToGroupChild(event.getDragNode(), event.getDropNode());
    }
    treeChange.saveExpandedNodes(root);
}
Also used : TreeChange(mom.trd.opentheso.dragdrop.TreeChange) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) StructIdBroaderTerm(mom.trd.opentheso.dragdrop.StructIdBroaderTerm) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Aggregations

RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)26 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)14 PrefixString (com.k_int.IR.QueryModels.PrefixString)11 NodeNT (mom.trd.opentheso.bdd.helper.nodes.NodeNT)10 SQLException (java.sql.SQLException)8 HashMap (java.util.HashMap)8 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)8 Connection (java.sql.Connection)7 Concept (mom.trd.opentheso.bdd.datas.Concept)7 ArrayList (java.util.ArrayList)5 FacesMessage (javax.faces.application.FacesMessage)5 OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)5 Term (mom.trd.opentheso.bdd.datas.Term)4 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)4 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)4 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)4 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)3 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)3 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)3 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)2