use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ExportRdf4jHelper method addConcept.
public void addConcept(String idThesaurus, DownloadBean downloadBean, List<NodeLang> selectedLanguages) {
// récupération de tous les concepts
for (NodeUri nodeTT1 : nodeTTs) {
SKOSResource sKOSResource = new SKOSResource();
sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.topConceptOf);
// fils top concept
addFilsConceptRecursif(idThesaurus, nodeTT1.getIdConcept(), sKOSResource, downloadBean, selectedLanguages);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ExportTabulateHelper method writeConcepts.
private boolean writeConcepts() {
ArrayList<NodeConceptExport> nodeConceptExports = thesaurusDatas.getNodeConceptExports();
boolean first = true;
ArrayList<NodeNote> nodeNoteDefinition = new ArrayList<>();
ArrayList<NodeNote> nodeNoteScope = new ArrayList<>();
ArrayList<NodeNote> nodeNoteHistory = new ArrayList<>();
ArrayList<NodeNote> nodeNoteEditorial = new ArrayList<>();
ArrayList<String> listLangues = new ArrayList<>();
for (NodeLang selectedLanguage : selectedLanguages) {
listLangues.add(selectedLanguage.getCode());
}
for (NodeConceptExport nodeConceptExport : nodeConceptExports) {
nodeNoteDefinition.clear();
nodeNoteScope.clear();
nodeNoteHistory.clear();
nodeNoteEditorial.clear();
// id
tabulateBuff.append(nodeConceptExport.getConcept().getIdConcept());
tabulateBuff.append(";");
// idArk
if (nodeConceptExport.getConcept().getIdArk() == null) {
tabulateBuff.append("");
} else {
tabulateBuff.append(nodeConceptExport.getConcept().getIdArk());
}
tabulateBuff.append(";");
// type
if (nodeConceptExport.getConcept().isTopConcept()) {
tabulateBuff.append("TT");
} else {
tabulateBuff.append("DE");
}
tabulateBuff.append(";");
// preflabel
for (NodeTermTraduction nodeTermTraduction : nodeConceptExport.getNodeTermTraductions()) {
if (listLangues.contains(nodeTermTraduction.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeTermTraduction.getLexicalValue());
tabulateBuff.append("::");
tabulateBuff.append(nodeTermTraduction.getLang());
first = false;
}
}
tabulateBuff.append(";");
// altLabel
first = true;
for (NodeEM nodeEM : nodeConceptExport.getNodeEM()) {
if (listLangues.contains(nodeEM.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeEM.getLexical_value());
tabulateBuff.append("::");
tabulateBuff.append(nodeEM.getLang());
first = false;
}
}
tabulateBuff.append(";");
// inScheme
first = true;
for (NodeUri nodeUri : nodeConceptExport.getNodeListIdsOfConceptGroup()) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeUri.getIdConcept());
first = false;
}
tabulateBuff.append(";");
// broader
first = true;
for (NodeHieraRelation node : nodeConceptExport.getNodeListOfBT()) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(node.getUri().getIdConcept());
first = false;
}
tabulateBuff.append(";");
// narrower
first = true;
for (NodeHieraRelation node : nodeConceptExport.getNodeListOfNT()) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(node.getUri().getIdConcept());
first = false;
}
tabulateBuff.append(";");
// related
first = true;
for (NodeHieraRelation nodeUri : nodeConceptExport.getNodeListIdsOfRT()) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeUri.getUri().getIdConcept());
first = false;
}
tabulateBuff.append(";");
// alignment
first = true;
for (NodeAlignment nodeAlignment : nodeConceptExport.getNodeAlignmentsList()) {
if (!first) {
tabulateBuff.append("##");
}
if (nodeAlignment.getAlignement_id_type() == 1) {
tabulateBuff.append("exactMatch::");
tabulateBuff.append(nodeAlignment.getUri_target());
}
if (nodeAlignment.getAlignement_id_type() == 2) {
tabulateBuff.append("closeMatch::");
tabulateBuff.append(nodeAlignment.getUri_target());
}
first = false;
}
tabulateBuff.append(";");
// types : definition; editorialNote; historyNote ; scopeNote
for (NodeNote nodeNote : nodeConceptExport.getNodeNoteConcept()) {
nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
nodeNoteDefinition.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
nodeNoteEditorial.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
nodeNoteHistory.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
nodeNoteScope.add(nodeNote);
}
}
// types : definition; editorialNote; historyNote ; scopeNote
for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
nodeNoteDefinition.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
nodeNoteEditorial.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
nodeNoteHistory.add(nodeNote);
}
if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
nodeNoteScope.add(nodeNote);
}
}
// definition
first = true;
for (NodeNote nodeNote : nodeNoteDefinition) {
if (listLangues.contains(nodeNote.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeNote.getLexicalvalue());
tabulateBuff.append("::");
tabulateBuff.append(nodeNote.getLang());
first = false;
}
}
tabulateBuff.append(";");
// scopeNote
first = true;
for (NodeNote nodeNote : nodeNoteScope) {
if (listLangues.contains(nodeNote.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeNote.getLexicalvalue());
tabulateBuff.append("::");
tabulateBuff.append(nodeNote.getLang());
first = false;
}
}
tabulateBuff.append(";");
// historyNote
first = true;
for (NodeNote nodeNote : nodeNoteHistory) {
if (listLangues.contains(nodeNote.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeNote.getLexicalvalue());
tabulateBuff.append("::");
tabulateBuff.append(nodeNote.getLang());
first = false;
}
}
tabulateBuff.append(";");
// editorialNote
first = true;
for (NodeNote nodeNote : nodeNoteEditorial) {
if (listLangues.contains(nodeNote.getLang())) {
if (!first) {
tabulateBuff.append("##");
}
tabulateBuff.append(nodeNote.getLexicalvalue());
tabulateBuff.append("::");
tabulateBuff.append(nodeNote.getLang());
first = false;
}
}
tabulateBuff.append(";");
// dates
tabulateBuff.append(nodeConceptExport.getConcept().getCreated());
tabulateBuff.append(";");
tabulateBuff.append(nodeConceptExport.getConcept().getModified());
tabulateBuff.append("\n");
first = true;
}
return true;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ConceptHelper method getConceptForExport.
/**
* Cette fonction permet de récupérer toutes les informations concernant un
* Concept par son id et son thésaurus et la langue On récupère aussi les
* IdArk si Ark est actif
*
* @param ds
* @param idConcept
* @param idThesaurus
* @param isArkActive
* @return Objet class NodeConcept
*/
public NodeConceptExport getConceptForExport(HikariDataSource ds, String idConcept, String idThesaurus, boolean isArkActive) {
NodeConceptExport nodeConceptExport = new NodeConceptExport();
// récupération des BT
RelationsHelper relationsHelper = new RelationsHelper();
ArrayList<NodeHieraRelation> nodeListOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
nodeConceptExport.setNodeListOfBT(nodeListOfBT_Ark);
// récupération du Concept
Concept concept = getThisConcept(ds, idConcept, idThesaurus);
/**
* Attention si on passe par le null, ca veut dire qu'il y a une
* incohérence dans la base à corriger !!!!!
*/
if (concept == null) {
return null;
}
nodeConceptExport.setConcept(concept);
AlignmentHelper alignmentHelper = new AlignmentHelper();
ArrayList<NodeAlignment> nodeAlignmentList = alignmentHelper.getAllAlignmentOfConcept(ds, idConcept, idThesaurus);
nodeConceptExport.setNodeAlignmentsList(nodeAlignmentList);
// récupération des termes spécifiques
ArrayList<NodeHieraRelation> nodeListIdsOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
nodeConceptExport.setNodeListOfNT(nodeListIdsOfNT_Ark);
// récupération des termes associés
ArrayList<NodeHieraRelation> nodeListIdsOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
nodeConceptExport.setNodeListIdsOfRT(nodeListIdsOfRT_Ark);
// récupération des Non Prefered Term
nodeConceptExport.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
// récupération des traductions
nodeConceptExport.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
// récupération des Groupes ou domaines
ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
nodeConceptExport.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
// récupération des notes du Terme
String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
nodeConceptExport.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
// récupération des Notes du Concept
nodeConceptExport.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
// récupération des coordonnées GPS
GpsHelper gpsHelper = new GpsHelper();
NodeGps nodeGps = gpsHelper.getCoordinate(ds, idConcept, idThesaurus);
if (nodeGps != null) {
nodeConceptExport.setNodeGps(nodeGps);
}
return nodeConceptExport;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ExportFromBDD method exportBranchOfConcept.
/**
* Fonction permet d'exporter une branche complète d'un thésaurus
* en partant de n'importe quel concept, mais pas d'un Domaine
* @param ds
* @param idConcept
* @param idThesaurus
* @return
*/
public StringBuffer exportBranchOfConcept(HikariDataSource ds, String idThesaurus, String idConcept) {
WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
// inititialisation des URI
writeFileSKOS.setServerArk(serverArk);
writeFileSKOS.setServerAdress(serverAdress);
writeFileSKOS.setNodePreference(nodePreference);
writeFileSKOS.writeHeader();
NodeUri nodeUri = new NodeUri();
nodeUri.setIdConcept(idConcept);
exportAllConcepts(ds, nodeUri.getIdConcept(), idThesaurus, writeFileSKOS);
writeFileSKOS.endSkos();
return writeFileSKOS.getSkosBuff();
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri 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();
}
Aggregations