Search in sources :

Example 31 with ConceptHelper

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

the class TreeChange method moveConceptTermToConceptTermOtherDomain.

/**
 * moveConceptTermToConceptTermOtherDomain
 *
 * déplacement d'un concept vers un autre domaine
 *
 * @param connect
 * @param originNodeIdConcept
 * @param originNodeIdGroup
 * @param BToriginNode
 * @param targetNodeIdConcept
 * @param targetNodeIdGroupe
 * @param idTheasurus
 * @param idUser
 * @return
 */
public boolean moveConceptTermToConceptTermOtherDomain(Connexion connect, String originNodeIdConcept, String originNodeIdGroup, String BToriginNode, String targetNodeIdConcept, String targetNodeIdGroupe, String idTheasurus, int idUser) {
    ConceptHelper conceptHelper = new ConceptHelper();
    GroupHelper groupHelper = new GroupHelper();
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        // on récupère les identifiants  des BT pour un groupe #jm
        ArrayList<String> listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, originNodeIdGroup, idTheasurus);
        // permet de déplacer une branche simplement, en cas d'erreur, rien n'est écrit
        if (!conceptHelper.moveBranchToConceptOtherGroup(conn, originNodeIdConcept, BToriginNode, targetNodeIdConcept, idTheasurus, idUser)) {
            return false;
        }
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), originNodeIdConcept, idTheasurus, lisIds);
        if (listeIdGroupBT.size() == 1) {
            if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, originNodeIdGroup, idTheasurus)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, targetNodeIdGroupe, idTheasurus);
        if (listeIdGroupBT.isEmpty()) {
            if (!groupHelper.addDomainToBranch(conn, lisIds, targetNodeIdGroupe, idTheasurus, idUser)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        conn.commit();
        conn.close();
    } catch (SQLException e) {
        Logger.getLogger(TreeChange.class.getName()).log(Level.SEVERE, "erreur dans le déplacement de la branche à un domaine différent de l'origine", e);
    }
    return true;
}
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)

Example 32 with ConceptHelper

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

the class TreeChange method getPathFromSelectedConcept.

public ArrayList<String> getPathFromSelectedConcept(Connexion conn, MyTreeNode selectedNode) {
    String id = selectedNode.getIdConcept();
    String theso = selectedNode.getIdTheso();
    GroupHelper gh = new GroupHelper();
    ArrayList<NodeGroup> groups = gh.getListGroupOfConcept(conn.getPoolConnexion(), theso, id, selectedNode.getLangue());
    ConceptHelper ch = new ConceptHelper();
    ArrayList<String> result = new ArrayList<>();
    ArrayList<String> bt = new ArrayList<>();
    ArrayList<String> groupIds = new ArrayList<>();
    for (NodeGroup ng : groups) {
        groupIds.add(ng.getConceptGroup().getIdgroup());
        bt.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), id, ng.getConceptGroup().getIdgroup(), theso));
    }
    result.addAll(bt);
    while (!bt.isEmpty()) {
        ArrayList<String> tmp = new ArrayList<>();
        for (String idBt : bt) {
            for (String idGroup : groupIds) {
                tmp.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), idBt, idGroup, theso));
            }
        }
        bt = new ArrayList<>(tmp);
        result.addAll(bt);
    }
    for (String idGroup : groupIds) {
        String fat = gh.getIdFather(conn.getPoolConnexion(), idGroup, theso);
        result.add(fat);
        while (fat != null && !fat.isEmpty()) {
            fat = gh.getIdFather(conn.getPoolConnexion(), fat, theso);
            result.add(fat);
        }
    }
    result.addAll(groupIds);
    return result;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 33 with ConceptHelper

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

the class TreeChange method moveTopTermToConceptSameDomaine.

/**
 * moveTopTermToConceptSameDomain
 *
 * le top term se déplace dans une hierarchie
 * note : cette fonction est utilisé aussi pour déplacer un top
 * terme en dehors du groupe
 *
 * @param connect
 * @param originNodeIdConcept
 * @param BToriginNode
 * @param originIdDomain
 * @param targetNodeIdConcept
 * @param idThesaurus
 * @param idUser
 * @return
 */
public boolean moveTopTermToConceptSameDomaine(Connexion connect, String originNodeIdConcept, String BToriginNode, String originIdDomain, String targetNodeIdConcept, String idThesaurus, int idUser) {
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        ConceptHelper conceptHelper = new ConceptHelper();
        // au concept la relation TT
        if (!conceptHelper.moveBranchFromMT(conn, originNodeIdConcept, targetNodeIdConcept, originIdDomain, idThesaurus, idUser)) {
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(AutoCompletBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : AutoCompletBean(mom.trd.opentheso.SelectedBeans.AutoCompletBean) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection)

Example 34 with ConceptHelper

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

the class Rest method brancheOfConceptsToSkosFromDate.

/**
 * Fonction qui permet de récupérer les concepts à partir d'une date donnée
 * (modifiés ou crées)
 *
 * @param idConcept
 * @param idThesaurus
 * @return skos
 */
private StringBuffer brancheOfConceptsToSkosFromDate(String idTheso, String date) {
    if (ds == null) {
        return null;
    }
    nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference == null) {
        return null;
    }
    ArrayList<String> tabId;
    ArrayList<ArrayList<String>> multiTabId = new ArrayList<>();
    ConceptHelper conceptHelper = new ConceptHelper();
    tabId = conceptHelper.getConceptsDelta(ds, idTheso, date);
    if (tabId == null) {
        ds.close();
        return null;
    }
    if (tabId.isEmpty()) {
        ds.close();
        return new StringBuffer("");
    }
    multiTabId.add(tabId);
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(nodePreference.getServeurArk());
    exportFromBDD.setServerAdress(nodePreference.getCheminSite());
    exportFromBDD.setNodePreference(nodePreference);
    StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, multiTabId);
    return skos;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 35 with ConceptHelper

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

the class ExportFromBDD method exportConcept.

/**
 * Fonction permettant d'exporter Un concept
 *
 * @param ds
 * @param idThesaurus
 * @param idConcept
 * @return  Le Skos en String
 */
public StringBuffer exportConcept(HikariDataSource ds, String idThesaurus, String idConcept) {
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.setNodePreference(nodePreference);
    writeFileSKOS.writeHeader();
    ConceptHelper conceptHelper = new ConceptHelper();
    NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, isArkActive);
    if (nodeConcept == null)
        return null;
    writeFileSKOS.writeDescriptor(nodeConcept, null);
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper)

Aggregations

ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)125 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)38 SQLException (java.sql.SQLException)36 Connection (java.sql.Connection)29 ArrayList (java.util.ArrayList)28 FacesMessage (javax.faces.application.FacesMessage)23 Concept (mom.trd.opentheso.bdd.datas.Concept)18 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)16 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)16 Term (mom.trd.opentheso.bdd.datas.Term)15 PrefixString (com.k_int.IR.QueryModels.PrefixString)14 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)14 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)13 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)12 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)12 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)12 HashMap (java.util.HashMap)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)9 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)9