Search in sources :

Example 1 with Alignment

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;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeTerm(mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm) ArrayList(java.util.ArrayList) Label(mom.trd.opentheso.core.exports.tabulate.Label) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) Term(mom.trd.opentheso.bdd.datas.Term) NodeTerm(mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) Alignment(mom.trd.opentheso.core.exports.tabulate.Alignment) Note(mom.trd.opentheso.core.exports.tabulate.Note) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

ArrayList (java.util.ArrayList)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)1 Term (mom.trd.opentheso.bdd.datas.Term)1 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)1 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)1 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)1 Alignment (mom.trd.opentheso.core.exports.tabulate.Alignment)1 Label (mom.trd.opentheso.core.exports.tabulate.Label)1 Note (mom.trd.opentheso.core.exports.tabulate.Note)1