Search in sources :

Example 1 with NodeThesaurus

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

the class ExportRdf4jHelper method addThesaurus.

public void addThesaurus(String idThesaurus, List<NodeLang> selectedLanguages) {
    nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
    String uri = getUriFromId(nodeThesaurus.getIdThesaurus());
    SKOSResource conceptScheme = new SKOSResource(uri, SKOSProperty.ConceptScheme);
    idTheso = nodeThesaurus.getIdThesaurus();
    String creator;
    String contributor;
    String title;
    String language;
    for (Thesaurus thesaurus : nodeThesaurus.getListThesaurusTraduction()) {
        boolean isInSelectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(thesaurus.getLanguage())) {
                isInSelectedLanguages = true;
                break;
            }
        }
        if (!isInSelectedLanguages) {
            break;
        }
        creator = thesaurus.getCreator();
        contributor = thesaurus.getContributor();
        title = thesaurus.getTitle();
        language = thesaurus.getLanguage();
        /*[...]*/
        if (creator != null && !creator.equalsIgnoreCase("null")) {
            conceptScheme.addCreator(creator, SKOSProperty.creator);
        }
        if (contributor != null && !contributor.equalsIgnoreCase("null")) {
            conceptScheme.addCreator(creator, SKOSProperty.contributor);
        }
        if (title != null && language != null) {
            conceptScheme.addLabel(title, language, SKOSProperty.prefLabel);
        }
        // dates
        String created = thesaurus.getCreated().toString();
        String modified = thesaurus.getModified().toString();
        if (created != null) {
            conceptScheme.addDate(created, SKOSProperty.created);
        }
        if (modified != null) {
            conceptScheme.addDate(modified, SKOSProperty.modified);
        }
    }
    skosXmlDocument.setConceptScheme(conceptScheme);
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang)

Example 2 with NodeThesaurus

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

the class ExportTxtHelper method exportToTxtCsv.

/**
 * permet de préparer le thésaurus au format tabulé. Les données sont
 * écrites dans des variables type StringBuffer suivant les options
 * sélectionnées dans le tableau String[] selectedOptions
 *
 * @return
 */
public boolean exportToTxtCsv() {
    txtBuff = new StringBuffer();
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idTheso);
    if (nodeThesaurus == null) {
        return false;
    }
    // on écrit le label du thésaurus
    // writeHeader(nodeThesaurus);
    // écriture des groupes
    GroupHelper groupHelper = new GroupHelper();
    NodeGroup nodeGroup;
    for (NodeGroup selectedGroup : selectedGroups) {
        nodeGroup = groupHelper.getThisConceptGroup(ds, selectedGroup.getConceptGroup().getIdgroup(), idTheso, selectedLang);
        // writeGroup(nodeGroup);
        // écriture récursive des concepts
        writeConcepts(nodeGroup.getConceptGroup().getIdgroup());
    }
    return true;
}
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) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 3 with NodeThesaurus

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

the class ExportTxtHelper method writeHeader.

/**
 * permet d'acrire le titre du thésaurus
 *
 * @return
 */
private void writeHeader(NodeThesaurus nodeThesaurus) {
    for (Thesaurus thesaurus : nodeThesaurus.getListThesaurusTraduction()) {
        if (thesaurus.getLanguage().equalsIgnoreCase(selectedLang)) {
            txtBuff.append(thesaurus.getTitle());
            txtBuff.append(" (");
            txtBuff.append(idTheso);
            txtBuff.append(" )");
        }
    }
    txtBuff.append("\n");
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)

Example 4 with NodeThesaurus

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

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

the class WriteFileSKOS_Frantiq 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 += "        <dc:title xml:lang=";
            xml += "\"" + listThesaurusTraduction.getLanguage() + "\">";
            xml += listThesaurusTraduction.getTitle();
            xml += "</dc:title>";
            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