Search in sources :

Example 16 with NodeNote

use of mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote in project opentheso by miledrousset.

the class NoteHelper method getNoteHistoriqueAll.

/**
 * Cette focntion permet de retourner la liste de l'historique des notes
 * pour un concept (type CustomNote, ScopeNote, HistoryNote)
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param idTerm
 * @param idLang
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getNoteHistoriqueAll(HikariDataSource ds, String idConcept, String idThesaurus, String idTerm, String idLang) {
    ArrayList<NodeNote> nodeNotes = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT id, notetypecode, lexicalvalue, modified, username FROM note_historique, users" + " WHERE id_thesaurus = '" + idThesaurus + "'" + " and lang ='" + idLang + "'" + " and (id_concept = '" + idConcept + "' OR id_term = '" + idTerm + "' )" + " and note_historique.id_user=users.id_user" + " order by modified DESC";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeNote nodeNote = new NodeNote();
                    nodeNote.setId_concept(idConcept);
                    nodeNote.setId_term(idTerm);
                    nodeNote.setId_note(resultSet.getInt("id"));
                    nodeNote.setLang(idLang);
                    nodeNote.setLexicalvalue(resultSet.getString("lexicalvalue"));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    nodeNote.setIdUser(resultSet.getString("username"));
                    nodeNotes.add(nodeNote);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting all historique Notes of Concept : " + idConcept, sqle);
    }
    return nodeNotes;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 17 with NodeNote

use of mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote in project opentheso by miledrousset.

the class NoteHelper method getListNotesTerm2.

/**
 * pour pouvoir obtener une list des Notes a partir du idTerm
 * sans conter avec le language
 * @param ds
 * @param idTerm
 * @param idThesaurus
 * @return
 */
public ArrayList<NodeNote> getListNotesTerm2(HikariDataSource ds, String idTerm, String idThesaurus) {
    ArrayList<NodeNote> nodeNotes = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT note.id, note.lang, note.notetypecode," + " note.lexicalvalue, note.created," + " note.modified FROM note, note_type" + " WHERE note.notetypecode = note_type.code" + " and note_type.isterm = true" + " and note.id_term = '" + idTerm + "'" + " and note.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeNote nodeNote = new NodeNote();
                    nodeNote.setId_term(idTerm);
                    nodeNote.setId_note(resultSet.getInt("id"));
                    nodeNote.setLexicalvalue(resultSet.getString("lexicalvalue"));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    nodeNote.setLang(resultSet.getString("lang"));
                    nodeNotes.add(nodeNote);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Notes of Term : " + idTerm, sqle);
    }
    return nodeNotes;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 18 with NodeNote

use of mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote in project opentheso by miledrousset.

the class WriteFileSKOS method writeDescriptor.

/**
 * Cette fonction permet d'exporter un Concept au format SKOS, Si
 * l'identifiant Ark existe, on l'exporte comme URI, sinon, on utilise
 * l'adresse URI du Site par defaut.
 *
 * @param nodeConceptExport
 * @param selectedLanguages
 *
 * @return true ou false
 */
public boolean writeDescriptor(NodeConceptExport nodeConceptExport, List<NodeLang> selectedLanguages) {
    /*
        // test pour savoir si le concept n'a pas de PrefLabel dans cette langue, il sera ignoré
        boolean havePrefLabel = false;
        if(selectedLanguages != null) {
            for (int i = 0; i < nodeConceptExport.getNodeTermTraductions().size(); i++) {
                for (NodeLang selectedLanguage : selectedLanguages) {
                    if (nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase(
                            selectedLanguage.getCode())) {
                        havePrefLabel = true;
                    }
                }
            }
            if(!havePrefLabel) return true; // on ignore le concept
        }*/
    SKOSResource concept = new SKOSResource(getUri(nodeConceptExport));
    if (nodeConceptExport == null) {
        return true;
    }
    if (nodeConceptExport.getNodeTermTraductions() == null) {
        return true;
    }
    for (int i = 0; i < nodeConceptExport.getNodeTermTraductions().size(); i++) {
        if (selectedLanguages != null) {
            // if(nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase("fr"))
            for (NodeLang selectedLanguage : selectedLanguages) {
                if (nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase(selectedLanguage.getCode())) {
                    concept.addLabel(nodeConceptExport.getNodeTermTraductions().get(i).getLexicalValue(), nodeConceptExport.getNodeTermTraductions().get(i).getLang(), SKOSProperty.prefLabel);
                }
            }
        } else {
            concept.addLabel(nodeConceptExport.getNodeTermTraductions().get(i).getLexicalValue(), nodeConceptExport.getNodeTermTraductions().get(i).getLang(), SKOSProperty.prefLabel);
        }
    }
    concept.addDate(nodeConceptExport.getConcept().getCreated().toString(), SKOSProperty.created);
    concept.addDate(nodeConceptExport.getConcept().getModified().toString(), SKOSProperty.modified);
    if (!nodeConceptExport.getConcept().getNotation().isEmpty()) {
        concept.addNotation(nodeConceptExport.getConcept().getNotation(), SKOSProperty.notation);
    }
    if (!nodeConceptExport.getConcept().getIdConcept().isEmpty()) {
        concept.addIdentifier(nodeConceptExport.getConcept().getIdConcept(), SKOSProperty.identifier);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListIdsOfConceptGroup().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfConceptGroup().get(i), SKOSProperty.inScheme);
        concept.addRelation(getRelationUri_inScheme(nodeConceptExport.getNodeListIdsOfConceptGroup().get(i), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.inScheme);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListOfBT().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfBT().get(i), SKOSProperty.broader);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListOfBT().get(i).getUri(), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.broader);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListOfNT().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfNT().get(i), SKOSProperty.narrower);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListOfNT().get(i).getUri(), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.narrower);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListIdsOfRT().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfRT().get(i), SKOSProperty.related);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListIdsOfRT().get(i).getUri(), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.related);
    }
    for (int i = 0; i < nodeConceptExport.getNodeEM().size(); i++) {
        if (nodeConceptExport.getNodeEM().get(i).isHiden()) {
            concept.addLabel(nodeConceptExport.getNodeEM().get(i).getLexical_value(), nodeConceptExport.getNodeEM().get(i).getLang(), SKOSProperty.hiddenLabel);
        } else {
            concept.addLabel(nodeConceptExport.getNodeEM().get(i).getLexical_value(), nodeConceptExport.getNodeEM().get(i).getLang(), SKOSProperty.altLabel);
        }
    }
    for (NodeAlignment alignment : nodeConceptExport.getNodeAlignmentsList()) {
        // alignement exactMatch
        if (alignment.getAlignement_id_type() == 1) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.exactMatch);
        }
        // alignement closeMatch
        if (alignment.getAlignement_id_type() == 2) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.closeMatch);
        }
        // alignement broadMatch
        if (alignment.getAlignement_id_type() == 3) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.broadMatch);
        }
        // alignement relatedMatch
        if (alignment.getAlignement_id_type() == 4) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.relatedMatch);
        }
        // alignement narrowMatch
        if (alignment.getAlignement_id_type() == 5) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.narrowMatch);
        }
    }
    for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
        if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.historyNote);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.editorialNote);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.definition);
        }
    }
    for (NodeNote nodeNote : nodeConceptExport.getNodeNoteConcept()) {
        if (nodeNote.getNotetypecode().equalsIgnoreCase("note")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.note);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.scopeNote);
        }
    }
    if (nodeConceptExport.getNodeGps() != null) {
        concept.addSkosGps(nodeConceptExport.getNodeGps().getLatitude(), SKOSProperty.latitude);
        concept.addSkosGps(nodeConceptExport.getNodeGps().getLongitude(), SKOSProperty.longitude);
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) SKOSResource(skos.SKOSResource) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 19 with NodeNote

use of mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote in project opentheso by miledrousset.

the class SelectedTerme method majNotes.

private void majNotes() {
    // NodeNote contient la note avec le type de note, il faut filtrer pour trouver la bonne note
    // For Concept : customnote ; scopeNote ; historyNote
    // For Term : definition; editorialNote; historyNote;
    initNotes();
    nodeNoteTermList = new NoteHelper().getListNotesTerm(connect.getPoolConnexion(), idT, idTheso, idlangue);
    for (NodeNote nodeNoteList1 : nodeNoteTermList) {
        if (nodeNoteList1 != null) {
            // cas d'une noteEditoriale
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("editorialNote")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    noteEditoriale = nodeNoteList1.getLexicalvalue();
                }
            }
            // cas de definitionNote
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("definition")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    definition = nodeNoteList1.getLexicalvalue();
                }
            }
            // cas de HistoryNote
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("historyNote")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    noteHistorique = nodeNoteList1.getLexicalvalue();
                }
            }
        }
    }
    nodeNoteConceptList = new NoteHelper().getListNotesConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
    for (NodeNote nodeNoteList1 : nodeNoteConceptList) {
        if (nodeNoteList1 != null) {
            // cas de Note d'application
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("scopeNote")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    noteApplication = nodeNoteList1.getLexicalvalue();
                }
            }
            // cas de HistoryNote
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("historyNote")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    noteHistorique = nodeNoteList1.getLexicalvalue();
                }
            }
            // cas de Note
            if (nodeNoteList1.getNotetypecode().equalsIgnoreCase("note")) {
                if (nodeNoteList1.getLexicalvalue() != null) {
                    note = nodeNoteList1.getLexicalvalue();
                }
            }
        }
    }
}
Also used : NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 20 with NodeNote

use of mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote in project opentheso by miledrousset.

the class NoteHelper method getListNotesConcept2.

/**
 * pour pouvoir obtener une list des Notes a partir du idConcept
 * sans conter avec le language
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return
 */
public ArrayList<NodeNote> getListNotesConcept2(HikariDataSource ds, String idConcept, String idThesaurus) {
    ArrayList<NodeNote> nodeNotes = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT note.id, note.lang, note.notetypecode," + " note.lexicalvalue, note.created," + " note.modified FROM note, note_type" + " WHERE note.notetypecode = note_type.code" + " and note_type.isconcept = true" + " and note.id_concept = '" + idConcept + "'" + " and note.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeNote nodeNote = new NodeNote();
                    nodeNote.setId_concept(idConcept);
                    nodeNote.setId_note(resultSet.getInt("id"));
                    nodeNote.setLexicalvalue(resultSet.getString("lexicalvalue"));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    nodeNote.setLang(resultSet.getString("lang"));
                    nodeNotes.add(nodeNote);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Notes of Concept : " + idConcept, sqle);
    }
    return nodeNotes;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Aggregations

NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)34 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)17 ArrayList (java.util.ArrayList)14 SQLException (java.sql.SQLException)12 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)12 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)12 Connection (java.sql.Connection)11 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)11 Term (mom.trd.opentheso.bdd.datas.Term)10 Concept (mom.trd.opentheso.bdd.datas.Concept)9 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)9 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)9 ResultSet (java.sql.ResultSet)8 Statement (java.sql.Statement)8 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)8 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)7 SKOSMapping (skos.SKOSMapping)5 SKOSTopConcept (skos.SKOSTopConcept)5 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)4 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)4