use of mom.trd.opentheso.core.exports.tabulate.Alignment in project opentheso by miledrousset.
the class ImportTabuleIntoBDD method insertConcept.
private boolean insertConcept(HikariDataSource ds, TabulateDocument tabulateDocument, String idThesaurus, boolean istopConcept, int idUser) {
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
concept.setIdConcept(tabulateDocument.getId());
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(istopConcept);
concept.setCreated(tabulateDocument.getCreated());
concept.setModified(tabulateDocument.getModified());
// cas de plusieurs Domaines (MT)
if (!tabulateDocument.getInScheme().isEmpty()) {
for (String idGroup : tabulateDocument.getInScheme()) {
concept.setIdGroup(idGroup);
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
} else {
return false;
}
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
ArrayList<NodeTermTraduction> nodeTermTraductionList = new ArrayList<>();
for (Label prefLabel : tabulateDocument.getPrefLabels()) {
NodeTermTraduction nodeTermTraduction = new NodeTermTraduction();
nodeTermTraduction.setLexicalValue(prefLabel.getLabel());
nodeTermTraduction.setLang(prefLabel.getLang());
nodeTermTraductionList.add(nodeTermTraduction);
}
nodeTerm.setNodeTermTraduction(nodeTermTraductionList);
nodeTerm.setIdTerm(tabulateDocument.getId());
nodeTerm.setIdConcept(tabulateDocument.getId());
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm.setCreated(tabulateDocument.getCreated());
nodeTerm.setModified(tabulateDocument.getModified());
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// Enregister les synonymes et traductions (AltLabel)
ArrayList<NodeEM> nodeEMList = new ArrayList<>();
for (Label altLabel : tabulateDocument.getAltLabels()) {
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(altLabel.getLabel());
nodeEM.setLang(altLabel.getLang());
nodeEM.setSource("");
nodeEM.setStatus("USE");
nodeEM.setHiden(false);
nodeEMList.add(nodeEM);
}
Term term = new Term();
for (NodeEM nodeEMList1 : nodeEMList) {
term.setId_concept(tabulateDocument.getId());
term.setId_term(tabulateDocument.getId());
term.setLexical_value(nodeEMList1.getLexical_value());
term.setLang(nodeEMList1.getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMList1.getSource());
term.setStatus(nodeEMList1.getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
// ajouter les notes
NoteHelper noteHelper = new NoteHelper();
for (Note note : tabulateDocument.getDefinition()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "definition", idUser);
}
for (Note note : tabulateDocument.getScopeNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "scopeNote", idUser);
}
for (Note note : tabulateDocument.getHistoryNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "historyNote", idUser);
}
for (Note note : tabulateDocument.getEditorialNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "editorialNote", idUser);
}
// Enregistrer les relations
writeRelationsList(ds, tabulateDocument, idThesaurus, idUser);
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (Alignment alignment : tabulateDocument.getAlignments()) {
if (alignment.getType().equalsIgnoreCase("exactMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 1, tabulateDocument.getId(), idThesaurus, 0);
}
if (alignment.getType().equalsIgnoreCase("closeMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 2, tabulateDocument.getId(), idThesaurus, 0);
}
}
return true;
}
Aggregations