Search in sources :

Example 71 with GroupHelper

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

the class ExportFromBDD 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 writeFileSKOS = new WriteFileSKOS();
    // 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, idThesaurus);
    }
    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, null);
    }
    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 72 with GroupHelper

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

the class ExportFromBDD 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 writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.setNodePreference(nodePreference);
    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, null);
    // é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)

Example 73 with GroupHelper

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

the class ExportFromBDD 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 74 with GroupHelper

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

the class TreeChange method moveSubGroupToSubGroupDomain.

/**
 * moveSubGroupToSubGroupDomain
 *
 * déplace un sousgroupe vers un autre sous groupe
 * note: c'est la seul façon de déplacer un sous groupe
 *
 * @param connect
 * @param originNodeIdConcept
 * @param BToriginNode
 * @param originIdDomain
 * @param type
 * @param targetNodeIdConcept
 * @param idThesaurus
 * @param idUser : paramètre non usité (pour une utilisation ultérieur)
 * @return
 */
public boolean moveSubGroupToSubGroupDomain(Connexion connect, String originNodeIdConcept, String BToriginNode, String originIdDomain, String type, String targetNodeIdConcept, String idThesaurus, int idUser) {
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        GroupHelper groupHelper = new GroupHelper();
        if (!groupHelper.moveSubGroupToSubGroup(conn, originNodeIdConcept, targetNodeIdConcept, BToriginNode, type, 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) SQLException(java.sql.SQLException) Connection(java.sql.Connection) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 75 with GroupHelper

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

the class TreeChange method moveTopTermToOtherDomaine.

public boolean moveTopTermToOtherDomaine(Connexion connect, String originNodeIdConcept, String originIdDomain, String targetNodeIdDomain, String idThesaurus, int idUser) {
    GroupHelper groupHelper = new GroupHelper();
    ConceptHelper conceptHelper = new ConceptHelper();
    // on récupère les Ids des concepts à modifier
    ArrayList<String> lisIds = new ArrayList<>();
    lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), originNodeIdConcept, idThesaurus, lisIds);
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        /*on  modifie le domaine */
        if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, originIdDomain, idThesaurus)) {
            conn.rollback();
            conn.close();
            return false;
        }
        if (!groupHelper.addDomainToBranch(conn, lisIds, targetNodeIdDomain, 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) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) 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