Search in sources :

Example 11 with NodeNote

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

the class ExportTxtHelper method writeConceptsInfo.

/**
 * Permet d'écrire les concepts en bouclant par récursivité pour définir les
 * niveaux
 *
 * @return
 */
private void writeConceptsInfo(String idConcept, String indentation) {
    ConceptHelper conceptHelper = new ConceptHelper();
    NodeConcept nodeConcept = conceptHelper.getConcept(ds, idConcept, idTheso, selectedLang);
    StringPlus stringPlus = new StringPlus();
    boolean first = true;
    if (nodeConcept == null) {
        return;
    }
    // id numérique séquentiel
    txtBuff.append(++number);
    txtBuff.append("\t");
    // Id_concept
    txtBuff.append(idConcept);
    txtBuff.append("\t");
    // on écrit le Term_concept
    txtBuff.append(indentation);
    if (nodeConcept.getTerm().getLexical_value().isEmpty()) {
        txtBuff.append("(");
        txtBuff.append(idConcept);
        txtBuff.append(")");
    } else {
        txtBuff.append(nodeConcept.getTerm().getLexical_value());
    }
    int tot = StringUtils.countMatches(indentation, "\t");
    if (tot < indentationConcept) {
        addTabulate(indentationConcept - (tot + 1));
    }
    if (selectedOptions.contains("occ")) {
        // on écrit les occurences
        txtBuff.append("\t");
        txtBuff.append(totalOfNotices(idConcept));
    }
    first = true;
    if (selectedOptions.contains("nt")) {
        // on écrit la relation NT
        if (!nodeConcept.getNodeNT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeNT nodeNT : nodeConcept.getNodeNT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("NT: ");
                txtBuff.append(nodeNT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeNT().size() < indentationNT) {
            addTabulate(indentationNT - nodeConcept.getNodeNT().size());
        }
    }
    first = true;
    // on écrit la relation UF
    if (selectedOptions.contains("uf")) {
        if (!nodeConcept.getNodeEM().isEmpty()) {
            txtBuff.append("\t");
            for (NodeEM nodeEm : nodeConcept.getNodeEM()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("UF: ");
                txtBuff.append(nodeEm.getLexical_value());
                first = false;
            }
        }
        if (nodeConcept.getNodeEM().size() < indentationUF) {
            addTabulate(indentationUF - nodeConcept.getNodeEM().size());
        }
    }
    first = true;
    if (selectedOptions.contains("bt")) {
        // on écrit la relation TG
        if (!nodeConcept.getNodeBT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("BT: ");
                txtBuff.append(nodeBT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeBT().size() < indentationBT) {
            addTabulate(indentationBT - nodeConcept.getNodeBT().size());
        }
    }
    first = true;
    // on écrit la relation RT
    if (selectedOptions.contains("rt")) {
        if (!nodeConcept.getNodeRT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeRT nodeRT : nodeConcept.getNodeRT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("RT: ");
                txtBuff.append(nodeRT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeRT().size() < indentationRT) {
            addTabulate(indentationRT - nodeConcept.getNodeRT().size());
        }
    }
    first = true;
    // on écrit les Groupes
    if (selectedOptions.contains("groups")) {
        if (!nodeConcept.getNodeConceptGroup().isEmpty()) {
            txtBuff.append("\t");
            for (NodeGroup nodeGroup : nodeConcept.getNodeConceptGroup()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("MT: ");
                txtBuff.append(nodeGroup.getLexicalValue());
                first = false;
            }
        }
        if (nodeConcept.getNodeConceptGroup().size() < indentationGroups) {
            addTabulate(indentationGroups - nodeConcept.getNodeConceptGroup().size());
        }
    }
    first = true;
    // on écrit les traductions
    if (selectedOptions.contains("traductions")) {
        if (!nodeConcept.getNodeTermTraductions().isEmpty()) {
            txtBuff.append("\t");
            for (NodeTermTraduction nodeTermTraduction : nodeConcept.getNodeTermTraductions()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("Tr: ");
                txtBuff.append(nodeTermTraduction.getLexicalValue());
                txtBuff.append("(");
                txtBuff.append(nodeTermTraduction.getLang());
                txtBuff.append(")");
                first = false;
            }
        }
        if (nodeConcept.getNodeTermTraductions().size() < indentationTraductions) {
            addTabulate(indentationTraductions - nodeConcept.getNodeTermTraductions().size());
        }
    }
    first = true;
    // on écrit les notes de type Term
    if (selectedOptions.contains("notes")) {
        if ((!nodeConcept.getNodeNotesTerm().isEmpty()) || (!nodeConcept.getNodeNotesConcept().isEmpty())) {
            txtBuff.append("\t");
            for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteT: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
            for (NodeNote nodeNote : nodeConcept.getNodeNotesConcept()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteC: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
        }
        if (nodeConcept.getNodeNotesTerm().size() < indentationNotes) {
            addTabulate(indentationNotes - (nodeConcept.getNodeNotesConcept().size() + nodeConcept.getNodeNotesTerm().size()));
        }
    }
    txtBuff.append("\n");
}
Also used : NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) NodeRT(mom.trd.opentheso.bdd.helper.nodes.NodeRT) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 12 with NodeNote

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

the class CompareConceptTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    ConnexionTest connexionTest = new ConnexionTest();
    HikariDataSource conn = connexionTest.getConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    String idGroup = "6";
    ConceptHelper conceptHelper = new ConceptHelper();
    StringPlus stringPlus = new StringPlus();
    NodeConcept nodeConcept;
    SearchHelper searchHelper = new SearchHelper();
    ArrayList<NodeSearch> nodeSearchs;
    StringBuilder stringBuilder = new StringBuilder();
    // lecture du fichier tabulé /Users/Miled/
    String path = "/Users/Miled/Desktop/inist.csv";
    FileInputStream file = readFile(path);
    if (file == null)
        return;
    String line;
    String lineTmp;
    String[] lineOrigine;
    boolean first = true;
    stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
    BufferedReader bf = new BufferedReader(new InputStreamReader(file));
    try {
        while ((line = bf.readLine()) != null) {
            lineOrigine = line.split("\t");
            if (lineOrigine.length < 2)
                continue;
            lineTmp = removeStopWords(lineOrigine[1]);
            nodeSearchs = searchHelper.searchTerm(conn, lineTmp, idLang, idTheso, idGroup, 2, false);
            stringBuilder.append(lineOrigine[0]);
            stringBuilder.append("\t");
            stringBuilder.append(lineOrigine[1]);
            // stringBuilder.append(" #### ");
            stringBuilder.append("\t");
            first = true;
            for (NodeSearch nodeSearch : nodeSearchs) {
                if (!first) {
                    // stringBuilder.append(" $$$$ ");
                    stringBuilder.append("\n");
                    stringBuilder.append("\t");
                    stringBuilder.append("\t");
                }
                stringBuilder.append(nodeSearch.getLexical_value());
                stringBuilder.append("\t");
                stringBuilder.append(nodeSearch.getIdConcept());
                // récupération des données d'un Concept
                nodeConcept = conceptHelper.getConcept(conn, nodeSearch.getIdConcept(), idTheso, idLang);
                // URL
                stringBuilder.append("\t");
                if (nodeConcept.getConcept().getIdArk() != null || !nodeConcept.getConcept().getIdArk().isEmpty()) {
                    stringBuilder.append("http://ark.frantiq.fr/ark:/");
                    stringBuilder.append(nodeConcept.getConcept().getIdArk());
                }
                // définition
                stringBuilder.append("\t");
                for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                    if (nodeNote.getNotetypecode().equalsIgnoreCase("definition"))
                        stringBuilder.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                }
                // BT
                stringBuilder.append("\t");
                for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                    stringBuilder.append(nodeBT.getTitle());
                }
                // UF
                stringBuilder.append("\t");
                for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
                    stringBuilder.append(nodeEM.getLexical_value());
                }
                first = false;
            }
            System.out.println(stringBuilder.toString());
            stringBuilder.delete(0, stringBuilder.capacity());
        }
    } catch (IOException ex) {
        Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    // ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    // StringBuilder file = new StringBuilder();
    /*  ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurusByGroup(conn, idTheso, idGroup);
        
        
        for (String idConcept : allIds) {

            nodeConcept = conceptHelper.getConcept(conn, idConcept, idTheso, idLang);
            System.out.println("idConcept = " + idConcept + "  " + nodeConcept.getTerm().getLexical_value());
            
        }*/
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConnexionTest(connexion.ConnexionTest) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) InputStreamReader(java.io.InputStreamReader) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) IOException(java.io.IOException) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper) FileInputStream(java.io.FileInputStream) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) BufferedReader(java.io.BufferedReader) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 13 with NodeNote

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

the class NoteHelper method getListNotesConcept.

/**
 * Cette focntion permet de retourner la liste des notes pour un concept
 * (type CustomNote, ScopeNote, HistoryNote)
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param idLang
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getListNotesConcept(HikariDataSource ds, String idConcept, String idThesaurus, 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 note.id, 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.lang ='" + idLang + "'" + " 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.setLang(idLang);
                    nodeNote.setLexicalvalue(resultSet.getString("lexicalvalue"));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    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)

Example 14 with NodeNote

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

the class NoteHelper method getListNotesTerm.

/**
 * Cette focntion permet de retourner la liste des notes pour un Term(type
 * HistoryNote, Definition, EditotrialNote)
 *
 * @param ds
 * @param idThesaurus
 * @param idTerm
 * @param idLang
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getListNotesTerm(HikariDataSource ds, String idTerm, String idThesaurus, 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 note.id, 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.lang ='" + idLang + "'" + " 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.setLang(idLang);
                    nodeNote.setLexicalvalue(resultSet.getString("lexicalvalue"));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    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 15 with NodeNote

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

the class NoteHelper method getListNotesConceptAllLang.

/**
 * Cette focntion permet de retourner la liste des notes pour un concept
 * (type CustomNote, ScopeNote, HistoryNote) avec toutes les langues
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return ArrayList des notes sous forme de Class NodeNote
 */
public ArrayList<NodeNote> getListNotesConceptAllLang(HikariDataSource ds, String idConcept, String idThesaurus) {
    ArrayList<NodeNote> nodeNotes = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    StringPlus stringPlus = new StringPlus();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT note.id, note.notetypecode," + " note.lexicalvalue, note.created," + " note.modified, note.lang 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.setLang(resultSet.getString("lang"));
                    nodeNote.setLexicalvalue(stringPlus.normalizeStringForXml(resultSet.getString("lexicalvalue")));
                    nodeNote.setModified(resultSet.getDate("modified"));
                    nodeNote.setCreated(resultSet.getDate("created"));
                    nodeNote.setNotetypecode(resultSet.getString("notetypecode"));
                    nodeNotes.add(nodeNote);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Notes of Concept : " + idConcept, sqle);
    }
    return nodeNotes;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) 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