Search in sources :

Example 76 with GroupHelper

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

the class TreeChange method moveTopTermToConceptOtherDomaine.

public boolean moveTopTermToConceptOtherDomaine(Connexion connect, String idConceptOrigin, String idBT, String idOriginGroup, String targetidConcept, String targetIGroup, String idThesoSelected, int id) {
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        GroupHelper groupHelper = new GroupHelper();
        ConceptHelper conceptHelper = new ConceptHelper();
        RelationsHelper relationHelper = new RelationsHelper();
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idConceptOrigin, idThesoSelected, lisIds);
        if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, idOriginGroup, idThesoSelected)) {
            conn.rollback();
            conn.close();
            return false;
        }
        if (!groupHelper.addDomainToBranch(conn, lisIds, targetIGroup, idThesoSelected, id)) {
            conn.rollback();
            conn.close();
            return false;
        }
        if (!relationHelper.addRelationBT(conn, idConceptOrigin, idThesoSelected, targetidConcept, id)) {
            conn.rollback();
            conn.close();
            return false;
        }
        if (!relationHelper.deleteRelationTT(conn, idConceptOrigin, idThesoSelected, id)) {
            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) ArrayList(java.util.ArrayList) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 77 with GroupHelper

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

the class TreeChange method moveConceptToGroupOtherDomain.

/**
 * moveConceptToGroupOtherDomain
 *
 * la tête de la branche devient un top term dans un autre groupe
 *
 * @param connect
 * @param originNodeIdConcept
 * @param BToriginNode
 * @param originDomain
 * @param targetNodeIdConcept
 * @param TargetNodeDomaine
 * @param idThesaurus
 * @param idUser
 * @return
 */
public boolean moveConceptToGroupOtherDomain(Connexion connect, String originNodeIdConcept, String BToriginNode, String originDomain, String targetNodeIdConcept, String TargetNodeDomaine, String idThesaurus, int idUser) {
    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();
        // on récupère les identifiants  des BT pour un groupe #jm
        ArrayList<String> listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, originDomain, idThesaurus);
        // au concept la relation TT
        if (!conceptHelper.moveBranchToAnotherMT(conn, originNodeIdConcept, // ancien Group
        BToriginNode, // ancien Group
        originDomain, // nouveau Group
        TargetNodeDomaine, idThesaurus, idUser)) {
            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(), originNodeIdConcept, idThesaurus, lisIds);
        if (listeIdGroupBT.size() == 1) {
            // on supprime l'ancien Groupe de la branche
            if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, originDomain, idThesaurus)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // on ajoute le nouveau domaine à la branche
        listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, TargetNodeDomaine, idThesaurus);
        if (listeIdGroupBT.isEmpty()) {
            if (!groupHelper.addDomainToBranch(conn, lisIds, TargetNodeDomaine, idThesaurus, idUser)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        conn.commit();
        conn.close();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(TreeChange.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
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 78 with GroupHelper

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

the class BackgroundTimeJob method synchroSparql.

private Runnable synchroSparql(int key) {
    SynchroSparql run = new SynchroSparql();
    run.setSparqlStruct(this.SparqlSyn.get(key));
    ArrayList<Languages_iso639> listeLang = new LanguageHelper().getLanguagesOfThesaurus(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeLang> nol = new ArrayList<>();
    for (Languages_iso639 lang : listeLang) {
        NodeLang nd = new NodeLang();
        nd.setValue(lang.getId_iso639_1());
        nd.setCode(lang.getId_iso639_1());
        nol.add(nd);
    }
    run.setListe_lang(nol);
    ArrayList<String> nog = new GroupHelper().getListIdOfGroup(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeGroup> groupes = new ArrayList<>();
    for (String group : nog) {
        NodeGroup ng1 = new NodeGroup();
        ng1.setId_group(group);
        ConceptGroup cg = new ConceptGroup();
        cg.setIdgroup(group);
        ng1.setConceptGroup(cg);
        groupes.add(ng1);
    }
    run.setListe_group(groupes);
    run.setConn(this.connect);
    return run;
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ArrayList(java.util.ArrayList) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) ConceptGroup(mom.trd.opentheso.bdd.datas.ConceptGroup) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 79 with GroupHelper

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

the class ExportFromBDD_Frantiq method exportGroup.

/**
 * Fonction récursive permettant d'exporter le Groupe de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @return
 */
public StringBuffer exportGroup(HikariDataSource ds, String idThesaurus, String idGroup) {
    WriteFileSKOS_Frantiq writeFileSKOS = new WriteFileSKOS_Frantiq();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    // écriture des Domaines et Descripteurs avec traductions
    NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, idGroup, idThesaurus);
    ArrayList<NodeUri> idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idGroup, idThesaurus);
    writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
    // écriture des TopConcepts
    for (NodeUri idOfTopConcept1 : idOfTopConcept) {
        exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
    }
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

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