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);
}
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;
}
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");
}
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();
}
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;
}
Aggregations