Search in sources :

Example 16 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction 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)

Example 17 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class TermHelper method getTraductionsOfConcept.

/**
 * Cette fonction permet de retourner les traductions d'un term sauf la
 * langue en cours
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param idLang
 * @return Objet class NodeConceptTree
 */
public ArrayList<NodeTermTraduction> getTraductionsOfConcept(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeTermTraduction> nodeTraductionsList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT term.id_term, term.lexical_value, term.lang FROM" + " term, preferred_term WHERE" + " term.id_term = preferred_term.id_term" + " and preferred_term.id_concept = '" + idConcept + "'" + " and term.lang != '" + idLang + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by term.lexical_value";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    nodeTraductionsList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeTermTraduction nodeTraductions = new NodeTermTraduction();
                        nodeTraductions.setLang(resultSet.getString("lang"));
                        nodeTraductions.setLexicalValue(resultSet.getString("lexical_value"));
                        nodeTraductionsList.add(nodeTraductions);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Traductions of Term  : " + idConcept, sqle);
    }
    return nodeTraductionsList;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)

Example 18 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class TermHelper method getAllTraductionsOfConcept.

/**
 * Cette fonction permet de retourner toutes les traductions d'un concept
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return Objet class NodeConceptTree
 */
public ArrayList<NodeTermTraduction> getAllTraductionsOfConcept(HikariDataSource ds, String idConcept, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeTermTraduction> nodeTraductionsList = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT term.id_term, term.lexical_value, term.lang FROM" + " term, preferred_term WHERE" + " term.id_term = preferred_term.id_term" + " and term.id_thesaurus = preferred_term.id_thesaurus" + " and preferred_term.id_concept = '" + idConcept + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by term.lexical_value";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeTermTraduction nodeTraductions = new NodeTermTraduction();
                    nodeTraductions.setLang(resultSet.getString("lang"));
                    nodeTraductions.setLexicalValue(resultSet.getString("lexical_value"));
                    nodeTraductionsList.add(nodeTraductions);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Traductions of Concept  : " + idConcept, sqle);
    }
    return nodeTraductionsList;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)

Example 19 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class ToolsHelper method GenerateArkIds.

/**
 * Cette fonction permet de regénerer ou générer tous les identifiants Ark
 * du thésaurus
 *
 * @param ds
 * @param idThesaurus
 * @return ArrayList de NodePermute
 */
public boolean GenerateArkIds(HikariDataSource ds, String idThesaurus) {
    ConceptHelper conceptHelper = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    ArrayList<NodeTermTraduction> nodeTermTraductionList;
    // Génération des Id Ark pour les concepts
    ArrayList<String> tabIdConcept = conceptHelper.getAllIdConceptOfThesaurus(ds, idThesaurus);
    String idArk;
    ArkClient ark_Client = new ArkClient();
    ArrayList<DcElement> dcElementsList = new ArrayList<>();
    for (String idConcept : tabIdConcept) {
        dcElementsList.clear();
        nodeTermTraductionList = termHelper.getAllTraductionsOfConcept(ds, idConcept, idThesaurus);
        for (NodeTermTraduction nodeTermTraduction : nodeTermTraductionList) {
            DcElement dcElement = new DcElement();
            // cette fonction permet de remplir la table Permutée
            dcElement.setName("description");
            dcElement.setValue(nodeTermTraduction.getLexicalValue());
            dcElement.setLanguage(nodeTermTraduction.getLang());
            dcElementsList.add(dcElement);
        }
        // String date, String url, String title, String creator, String description, String type
        idArk = ark_Client.getArkId(new FileUtilities().getDate(), "http://pactols.frantiq.fr/" + "?idc=" + idConcept + "&idt=" + idThesaurus, idConcept, "Frantiq", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
        "pcrt");
        conceptHelper.updateArkIdOfConcept(ds, idConcept, idThesaurus, idArk);
    }
    return true;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) ArrayList(java.util.ArrayList) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Aggregations

NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)19 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)11 ArrayList (java.util.ArrayList)10 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)9 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)8 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)7 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 Term (mom.trd.opentheso.bdd.datas.Term)5 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)5 Concept (mom.trd.opentheso.bdd.datas.Concept)4 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)4 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)4 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)4 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)4 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)3 SKOSAnnotation (org.semanticweb.skos.SKOSAnnotation)3 SKOSConcept (org.semanticweb.skos.SKOSConcept)3 PrefixString (com.k_int.IR.QueryModels.PrefixString)2 ResultSet (java.sql.ResultSet)2