Search in sources :

Example 6 with NodeThesaurus

use of mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus in project opentheso by miledrousset.

the class ExportFromBDD method exportThesaurusAdvanced.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur en filtrant par langues et domaines choisis
 *
 * @param ds
 * @param idThesaurus
 * @param selectedLanguages
 * @param selectedGroups
 * @param downloadBean
 * @return
 */
public StringBuffer exportThesaurusAdvanced(HikariDataSource ds, String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, DownloadBean downloadBean) {
    /*
         * Ecriture du thésaurus
         */
    this.downloadBean = downloadBean;
    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) {
        for (NodeGroup nodeGroup : selectedGroups) {
            if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
                NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
                idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
                writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, selectedLanguages);
            }
        }
    }
    for (String tabIdGroup1 : tabIdGroup) {
        for (NodeGroup nodeGroup : selectedGroups) {
            if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
                idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
                for (NodeUri idOfTopConcept1 : idOfTopConcept) {
                    exportAllConceptsAdvanced(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS, selectedLanguages);
                }
            }
        }
    }
    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) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 7 with NodeThesaurus

use of mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus in project opentheso by miledrousset.

the class ExportFromBDD method exportGroupsOfThesaurus.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public StringBuffer exportGroupsOfThesaurus(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);
        }
        
        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 : ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 8 with NodeThesaurus

use of mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus 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 9 with NodeThesaurus

use of mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus in project opentheso by miledrousset.

the class ThesaurusHelper method getNodeThesaurus.

/**
 * Permet de retourner un thésaurus par identifiant sous forme de
 * NodeThesaurus avec les traductions
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @return Objet Class Thesaurus
 */
public NodeThesaurus getNodeThesaurus(HikariDataSource ds, String idThesaurus) {
    ArrayList<Languages_iso639> listLangTheso = getLanguagesOfThesaurus(ds, idThesaurus);
    NodeThesaurus nodeThesaurus = new NodeThesaurus();
    ArrayList<Thesaurus> thesaurusTraductionsList = new ArrayList<>();
    for (int i = 0; i < listLangTheso.size(); i++) {
        Thesaurus thesaurus = getThisThesaurus(ds, idThesaurus, listLangTheso.get(i).getId_iso639_1());
        if (thesaurus != null) {
            thesaurusTraductionsList.add(thesaurus);
        }
    }
    nodeThesaurus.setIdThesaurus(idThesaurus);
    nodeThesaurus.setListThesaurusTraduction(thesaurusTraductionsList);
    return nodeThesaurus;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) ArrayList(java.util.ArrayList) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 10 with NodeThesaurus

use of mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus in project opentheso by miledrousset.

the class WriteFileSKOS method writeThesaurus.

public boolean writeThesaurus(NodeThesaurus nodeThesaurus) {
    // Ecriture de la balise de declaration du thesaurus
    String xml = "    <skos:ConceptScheme rdf:about=\"" + URI + "?idt=" + nodeThesaurus.getIdThesaurus() + "\">\n";
    // balises DublinCore pour le libellé du thésaurus
    for (Thesaurus listThesaurusTraduction : nodeThesaurus.getListThesaurusTraduction()) {
        if (!listThesaurusTraduction.getTitle().trim().isEmpty()) {
            xml += "        <skos:prefLabel xml:lang=";
            xml += "\"" + listThesaurusTraduction.getLanguage() + "\">";
            xml += listThesaurusTraduction.getTitle();
            xml += "</skos:prefLabel>";
            xml += "\n";
        }
    }
    skosBuff.append(xml);
    return true;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)

Aggregations

NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)10 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)6 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)5 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)5 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)3 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)3 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)3 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)2 ArrayList (java.util.ArrayList)1 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)1 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)1 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)1