use of mom.trd.opentheso.bdd.helper.nodes.NodeEM in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeConceptAfterGroup.
private void writeConceptAfterGroup(SKOSResource resource, String idGroup, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
String idC = getId(resource.getUri());
concept.setIdConcept(idC);
// concept.setCreated(null);
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(false);
concept.setIdGroup(idGroup);
concept = addDates(resource.getDateList(), concept, dateFormat);
if (idGroup.trim().isEmpty())
return;
conceptHelper.insertConceptInTable(ds, concept, idUser);
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
nodeTerm.setNodeTermTraduction(getTraductionConcept(resource.getLabelsList()));
nodeTerm.setIdTerm(idC);
nodeTerm.setIdConcept(idC);
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm = addDatesTerm(resource.getDateList(), nodeTerm, dateFormat);
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// ajouter les notes
ArrayList<NodeNote> nodeNoteList = addNotes(resource.getDocumentationsList());
NoteHelper noteHelper = new NoteHelper();
for (NodeNote nodeNoteList1 : nodeNoteList) {
if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("definition")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
// Enregistrer les relations
writeRelationsList(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
ArrayList<SKOSMapping> sKOSMappings = resource.getMappings();
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (SKOSMapping sKOSMapping : sKOSMappings) {
if (sKOSMapping.getProperty() == SKOSProperty.exactMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 1, concept.getIdConcept(), idThesaurus, 0);
}
if (sKOSMapping.getProperty() == SKOSProperty.closeMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 2, concept.getIdConcept(), idThesaurus, 0);
}
}
// Ajouter l'id du concept importé pour l'aligner avec le thésaurus source
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI de la source
resource.getUri(), // sKOSMapping.getTargetUri(), // URI
1, concept.getIdConcept(), idThesaurus, 0);
// Enregister les synonymes et traductions
ArrayList<NodeEM> nodeEMs = writeLabelsList(ds, resource.getLabelsList());
Term term = new Term();
for (int i = 0; i < nodeEMs.size(); i++) {
term.setId_concept(concept.getIdConcept());
term.setId_term(nodeTerm.getIdTerm());
term.setLexical_value(nodeEMs.get(i).getLexical_value());
term.setLang(nodeEMs.get(i).getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMs.get(i).getSource());
term.setStatus(nodeEMs.get(i).getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeEM in project opentheso by miledrousset.
the class WriteSkosBDD method writeConcept.
public void writeConcept(SKOSResource resource, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
// ajout du concept dans la base
// boolean isTopConcept = isTopConcept(getId(resource.getUri()));
boolean isTopConcept = isTopConceptByRelation(resource.getRelationsList());
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
String id = getId(getId(resource.getUri()));
if (id == null) {
System.out.println("identifiant null : " + resource.getUri());
}
concept.setIdConcept(getId(getId(resource.getUri())));
// concept.setCreated(null);
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(isTopConcept);
concept = addDates(resource.getDateList(), concept, dateFormat);
ArrayList<String> idGroup = getGroups(resource.getRelationsList());
if (!idGroup.isEmpty()) {
for (String idGroup1 : idGroup) {
concept.setIdGroup(getId(idGroup1));
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
}
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
nodeTerm.setNodeTermTraduction(getTraductionConcept(resource.getLabelsList()));
String id_term = getId(getId(resource.getUri()));
if (id_term == null) {
System.out.println("identifiant null : " + resource.getUri());
}
nodeTerm.setIdTerm(getId(getId(resource.getUri())));
nodeTerm.setIdConcept(getId(resource.getUri()));
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm = addDatesTerm(resource.getDateList(), nodeTerm, dateFormat);
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// ajouter les notes
ArrayList<NodeNote> nodeNoteList = addNotes(resource.getDocumentationsList());
NoteHelper noteHelper = new NoteHelper();
for (NodeNote nodeNoteList1 : nodeNoteList) {
if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("definition")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
// Enregistrer les relations
if (isTopConcept) {
writeRelationsListTopConcept(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
} else {
writeRelationsList(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
}
ArrayList<SKOSMapping> sKOSMappings = resource.getMappings();
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (SKOSMapping sKOSMapping : sKOSMappings) {
if (sKOSMapping.getProperty() == SKOSProperty.exactMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 1, concept.getIdConcept(), idThesaurus, 0);
}
if (sKOSMapping.getProperty() == SKOSProperty.closeMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 2, concept.getIdConcept(), idThesaurus, 0);
}
}
// Enregister les synonymes et traductions
ArrayList<NodeEM> nodeEMs = writeLabelsList(ds, resource.getLabelsList());
Term term = new Term();
for (int i = 0; i < nodeEMs.size(); i++) {
term.setId_concept(concept.getIdConcept());
term.setId_term(nodeTerm.getIdTerm());
term.setLexical_value(nodeEMs.get(i).getLexical_value());
term.setLang(nodeEMs.get(i).getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMs.get(i).getSource());
term.setStatus(nodeEMs.get(i).getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeEM in project opentheso by miledrousset.
the class ImportRdf4jHelper method finalizeAddConceptStruct.
private void finalizeAddConceptStruct(AddConceptsStruct acs) throws SQLException {
acs.termHelper.insertTerm(ds, acs.nodeTerm, idUser);
RelationsHelper relationsHelper = new RelationsHelper();
for (HierarchicalRelationship hierarchicalRelationship : acs.hierarchicalRelationships) {
if (!relationsHelper.insertHierarchicalRelation(ds, hierarchicalRelationship.getIdConcept1(), hierarchicalRelationship.getIdThesaurus(), hierarchicalRelationship.getRole(), hierarchicalRelationship.getIdConcept2())) {
// System.out.println("Erreur sur la relation = " + acs.concept.getIdConcept() + " ## " + hierarchicalRelationship.getRole());
message.append(System.getProperty("line.separator"));
message.append("Erreur sur la relation = ");
message.append(acs.concept.getIdConcept());
message.append(" ## ");
message.append(hierarchicalRelationship.getRole());
}
}
// For Term : definition; editorialNote; historyNote;
for (NodeNote nodeNoteList1 : acs.nodeNotes) {
if (nodeNoteList1.getNotetypecode().equals("customnote") || nodeNoteList1.getNotetypecode().equals("scopeNote") || nodeNoteList1.getNotetypecode().equals("historyNote") || nodeNoteList1.getNotetypecode().equals("note")) {
acs.noteHelper.addConceptNote(ds, acs.concept.getIdConcept(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().equals("definition") || nodeNoteList1.getNotetypecode().equals("editorialNote")) {
acs.noteHelper.addTermNote(ds, acs.nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
for (NodeAlignment nodeAlignment : acs.nodeAlignments) {
acs.alignmentHelper.addNewAlignment(ds, nodeAlignment);
}
for (NodeEM nodeEMList1 : acs.nodeEMList) {
acs.term.setId_concept(acs.concept.getIdConcept());
acs.term.setId_term(acs.nodeTerm.getIdTerm());
acs.term.setLexical_value(nodeEMList1.getLexical_value());
acs.term.setLang(nodeEMList1.getLang());
acs.term.setId_thesaurus(thesaurus.getId_thesaurus());
acs.term.setSource(nodeEMList1.getSource());
acs.term.setStatus(nodeEMList1.getStatus());
acs.termHelper.addNonPreferredTerm(ds, acs.term, idUser);
}
if (acs.nodeGps.getLatitude() != null && acs.nodeGps.getLongitude() != null) {
// insertion des données GPS
acs.gpsHelper.insertCoordonees(ds, acs.concept.getIdConcept(), thesaurus.getId_thesaurus(), acs.nodeGps.getLatitude(), acs.nodeGps.getLongitude());
}
for (String idTopConcept1 : idTopConcept) {
if (!acs.conceptHelper.setTopConcept(ds, idTopConcept1, thesaurus.getId_thesaurus())) {
// erreur;
}
}
// initialisation des variables
acs.concept = new Concept();
acs.nodeTerm = new NodeTerm();
acs.nodeTermTraductionList = new ArrayList<>();
acs.nodeEMList = new ArrayList<>();
acs.nodeNotes = new ArrayList<>();
acs.nodeAlignments = new ArrayList<>();
acs.hierarchicalRelationships = new ArrayList<>();
acs.idGrps = new ArrayList<>();
acs.isTopConcept = false;
acs.nodeGps = new NodeGps();
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeEM in project opentheso by miledrousset.
the class WriteAltLabel method AddAltLabelByGroup.
public void AddAltLabelByGroup(HikariDataSource ds, String idTheso, String idGroup, String idLang) {
boolean passed = false;
// ConceptHelper conceptHelper = new ConceptHelper();
TermHelper termHelper = new TermHelper();
NoteHelper noteHelper = new NoteHelper();
// ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
ArrayList<NodeEM> nodeEMs;
ArrayList<NodeTab2Levels> nodeConceptTermId = termHelper.getAllIdOfNonPreferredTermsByGroup(ds, idTheso, idGroup);
Term term;
ArrayList<NodeNote> nodeNotes;
for (NodeTab2Levels nodeTab2Levels : nodeConceptTermId) {
nodeEMs = termHelper.getNonPreferredTerms(ds, nodeTab2Levels.getIdTerm(), idTheso, idLang);
if (!nodeEMs.isEmpty()) {
term = termHelper.getThisTerm(ds, nodeTab2Levels.getIdConcept(), idTheso, idLang);
nodeNotes = noteHelper.getListNotesTerm(ds, nodeTab2Levels.getIdTerm(), idTheso, idLang);
// écriture dans le fichier
stringBuilder.append(nodeTab2Levels.getIdConcept());
stringBuilder.append("\t");
stringBuilder.append(term.getLexical_value());
stringBuilder.append("\t");
for (NodeEM nodeEM : nodeEMs) {
if (passed) {
stringBuilder.append("##");
}
stringBuilder.append(nodeEM.getLexical_value());
passed = true;
}
passed = false;
stringBuilder.append("\t");
for (NodeNote nodeNote : nodeNotes) {
if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
if (passed) {
stringBuilder.append("##");
}
stringBuilder.append(nodeNote.getLexicalvalue());
passed = true;
}
}
stringBuilder.append("\n");
}
passed = false;
}
// System.out.println(stringBuilder.toString());
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeEM 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;
}
Aggregations