Search in sources :

Example 11 with GroupHelper

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

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

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

the class ExportFromBDD_Frantiq method exportThesaurus.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public StringBuffer exportThesaurus(HikariDataSource ds, String idThesaurus) {
    /*
         * Ecriture du thésaurus
         */
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
    WriteFileSKOS_Frantiq writeFileSKOS = new WriteFileSKOS_Frantiq();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
    if (idArk == null || idArk.trim().isEmpty()) {
        writeFileSKOS.setURI(serverAdress);
    } else {
        writeFileSKOS.setURI(serverArk);
    }
    // writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
    // thesaurus.description);
    writeFileSKOS.writeThesaurus(nodeThesaurus);
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
    for (String tabIdGroup1 : tabIdGroup) {
        writeFileSKOS.writeTopConcepts(tabIdGroup1);
    }
    writeFileSKOS.writeEndOfMicroThesaurusList();
    // fin du bloc thésaurus et id of TopConcept
    // écriture des Domaines et Descripteurs avec traductions
    ArrayList<NodeUri> idOfTopConcept;
    for (String tabIdGroup1 : tabIdGroup) {
        NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
    }
    for (String tabIdGroup1 : tabIdGroup) {
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        for (NodeUri idOfTopConcept1 : idOfTopConcept) {
            exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
        }
    }
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 14 with GroupHelper

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

the class ExportFromBDD_Frantiq method exportThisGroup.

/**
 * Fonction permettant d'exporter un noeud Groupe (un seul identifiant group)
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @return  Skos
 */
public StringBuffer exportThisGroup(HikariDataSource ds, String idThesaurus, String idGroup) {
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // 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);
    nodeGroupLabel.setIdArk(new GroupHelper().getIdArkOfGroup(ds, idGroup, idThesaurus));
    ArrayList<NodeUri> idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idGroup, idThesaurus);
    writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, null);
    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)

Example 15 with GroupHelper

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

the class SelectedThesaurus method listeDomaine.

/**
 * Récupère la liste des domaines du thésaurus courant
 *
 * @return un tableau de SelectItem contenant les domaine permetant de les
 * afficher dans une liste déroulante
 */
public SelectItem[] listeDomaine() {
    ArrayList<NodeGroup> lesDomaines = new GroupHelper().getListConceptGroup(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
    SelectItem[] laListe = new SelectItem[lesDomaines.size() + 1];
    int i = 1;
    laListe[0] = new SelectItem("", "");
    for (NodeGroup ncg : lesDomaines) {
        laListe[i] = new SelectItem(ncg.getConceptGroup().getIdgroup(), ncg.getLexicalValue() + "(" + ncg.getConceptGroup().getIdgroup() + ")");
        i++;
    }
    return laListe;
}
Also used : SelectItem(javax.faces.model.SelectItem) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

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