use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport in project opentheso by miledrousset.
the class ExportRdf4jHelper method writeConceptInfo.
private void writeConceptInfo(ConceptHelper conceptHelper, SKOSResource sKOSResource, String idThesaurus, String idOfConceptChildren) {
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idOfConceptChildren, idThesaurus, false);
if (nodeConcept == null) {
return;
}
sKOSResource.setUri(getUri(nodeConcept));
sKOSResource.setProperty(SKOSProperty.Concept);
// prefLabel
for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
}
// altLabel
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
}
ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
addNoteGiven(nodeNotes, sKOSResource);
addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
String notation = nodeConcept.getConcept().getNotation();
String created = nodeConcept.getConcept().getCreated().toString();
String modified = nodeConcept.getConcept().getModified().toString();
if (notation != null && !notation.equals("null")) {
sKOSResource.addNotation(notation);
}
if (created != null) {
sKOSResource.addDate(created, SKOSProperty.created);
}
if (modified != null) {
sKOSResource.addDate(modified, SKOSProperty.modified);
}
sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
sKOSResource.addIdentifier(nodeConcept.getConcept().getIdConcept(), SKOSProperty.identifier);
skosXmlDocument.addconcept(sKOSResource);
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport in project opentheso by miledrousset.
the class ExportRdf4jHelper method addSignleConcept.
public void addSignleConcept(String idThesaurus, String idConcept) {
idTheso = idThesaurus;
ConceptHelper conceptHelper = new ConceptHelper();
SKOSResource sKOSResource = new SKOSResource();
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, false);
if (nodeConcept == null) {
return;
}
// concept.setUri(getUriFromId(idConcept));
sKOSResource.setUri(getUri(nodeConcept));
sKOSResource.setProperty(SKOSProperty.Concept);
// prefLabel
for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
}
// altLabel
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
}
ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
addNoteGiven(nodeNotes, sKOSResource);
addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
String notation = nodeConcept.getConcept().getNotation();
String created = nodeConcept.getConcept().getCreated().toString();
String modified = nodeConcept.getConcept().getModified().toString();
if (notation != null && !notation.equals("null")) {
sKOSResource.addNotation(notation);
}
if (created != null) {
sKOSResource.addDate(created, SKOSProperty.created);
}
if (modified != null) {
sKOSResource.addDate(modified, SKOSProperty.modified);
}
sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
sKOSResource.addIdentifier(idConcept, SKOSProperty.identifier);
skosXmlDocument.addconcept(sKOSResource);
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport 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.concept.NodeConceptExport 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.concept.NodeConceptExport in project opentheso by miledrousset.
the class ConceptHelper method exportAllConcepts.
/**
* Cette fonction permet d'exporter tous les concepts d'un thésaurus et les
* charger dans la classe No
*
* @param ds
* @param idConcept
* @param idThesaurus
* @param nodeConceptExports
* @return
*/
public ArrayList<NodeConceptExport> exportAllConcepts(HikariDataSource ds, String idConcept, String idThesaurus, ArrayList<NodeConceptExport> nodeConceptExports) {
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> listIdsOfConceptChildren = conceptHelper.getListChildrenOfConcept(ds, idConcept, idThesaurus);
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, false);
// / attention il y a un problème ici, il faut vérifier pourquoi nous avons un Concept Null
if (nodeConcept == null || nodeConcept.getConcept() == null) {
System.err.println("Attention Null proche de = : " + idConcept);
return null;
}
nodeConceptExports.add(nodeConcept);
for (String listIdsOfConceptChildren1 : listIdsOfConceptChildren) {
nodeConcept = conceptHelper.getConceptForExport(ds, listIdsOfConceptChildren1, idThesaurus, false);
nodeConceptExports.add(nodeConcept);
if (!nodeConcept.getNodeListOfNT().isEmpty()) {
for (int j = 0; j < nodeConcept.getNodeListOfNT().size(); j++) {
exportAllConcepts(ds, nodeConcept.getNodeListOfNT().get(j).getUri().getIdConcept(), idThesaurus, nodeConceptExports);
}
}
}
return nodeConceptExports;
}
Aggregations