Search in sources :

Example 1 with NodeTab2Levels

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

the class WriteAltLabel method AddAltLabelByGroup.

public void AddAltLabelByGroup(HikariDataSource ds, String idTheso, String idGroup, String idLang) {
    boolean passed = false;
    // ConceptHelper conceptHelper = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    NoteHelper noteHelper = new NoteHelper();
    // ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    ArrayList<NodeEM> nodeEMs;
    ArrayList<NodeTab2Levels> nodeConceptTermId = termHelper.getAllIdOfNonPreferredTermsByGroup(ds, idTheso, idGroup);
    Term term;
    ArrayList<NodeNote> nodeNotes;
    for (NodeTab2Levels nodeTab2Levels : nodeConceptTermId) {
        nodeEMs = termHelper.getNonPreferredTerms(ds, nodeTab2Levels.getIdTerm(), idTheso, idLang);
        if (!nodeEMs.isEmpty()) {
            term = termHelper.getThisTerm(ds, nodeTab2Levels.getIdConcept(), idTheso, idLang);
            nodeNotes = noteHelper.getListNotesTerm(ds, nodeTab2Levels.getIdTerm(), idTheso, idLang);
            // écriture dans le fichier
            stringBuilder.append(nodeTab2Levels.getIdConcept());
            stringBuilder.append("\t");
            stringBuilder.append(term.getLexical_value());
            stringBuilder.append("\t");
            for (NodeEM nodeEM : nodeEMs) {
                if (passed) {
                    stringBuilder.append("##");
                }
                stringBuilder.append(nodeEM.getLexical_value());
                passed = true;
            }
            passed = false;
            stringBuilder.append("\t");
            for (NodeNote nodeNote : nodeNotes) {
                if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                    if (passed) {
                        stringBuilder.append("##");
                    }
                    stringBuilder.append(nodeNote.getLexicalvalue());
                    passed = true;
                }
            }
            stringBuilder.append("\n");
        }
        passed = false;
    }
// System.out.println(stringBuilder.toString());
}
Also used : NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) Term(mom.trd.opentheso.bdd.datas.Term) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 2 with NodeTab2Levels

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

the class TermHelper method getAllIdOfNonPreferredTerms.

/**
 * Cette fonction permet de récupérer la liste de idTermes des
 * NonPreferredTerm (synonymes) pour un Thésaurus
 *
 * @param ds
 * @param idThesaurus
 * @return ArrayList (idConcept, idTerm)
 */
public ArrayList<NodeTab2Levels> getAllIdOfNonPreferredTerms(HikariDataSource ds, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeTab2Levels> tabIdNonPreferredTerm = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT DISTINCT preferred_term.id_concept," + " preferred_term.id_term FROM" + " non_preferred_term, preferred_term WHERE" + " preferred_term.id_term = non_preferred_term.id_term AND" + " preferred_term.id_thesaurus = non_preferred_term.id_thesaurus" + " and non_preferred_term.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeTab2Levels nodeTab2Levels = new NodeTab2Levels();
                    nodeTab2Levels.setIdConcept(resultSet.getString("id_concept"));
                    nodeTab2Levels.setIdTerm(resultSet.getString("id_term"));
                    tabIdNonPreferredTerm.add(nodeTab2Levels);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Id of NonPreferedTerm of Thesaurus : " + idThesaurus, sqle);
    }
    return tabIdNonPreferredTerm;
}
Also used : NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Example 3 with NodeTab2Levels

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

the class SearchHelper method generatePermutedTable.

/**
 * Cette fonction permet de générer la table Permuted d'après les tables
 * PreferredTerm et NonPreferredTerm
 *
 * @param ds
 * @param idThesaurus
 * @return ArrayList de NodePermute
 */
public boolean generatePermutedTable(HikariDataSource ds, String idThesaurus) {
    ConceptHelper conceptHelper = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    ArrayList<NodeTermTraduction> nodeTermTraductionList;
    ArrayList<NodeEM> nodeEMList;
    // suppression des données de la table Permuted pour un thésaurus
    termHelper.deletePermutedTable(ds, idThesaurus);
    // Génération des Termes Préférés (PreferredTerm)
    ArrayList<String> tabIdConcept = conceptHelper.getAllIdConceptOfThesaurus(ds, idThesaurus);
    for (String idConcept : tabIdConcept) {
        nodeTermTraductionList = termHelper.getAllTraductionsOfConcept(ds, idConcept, idThesaurus);
        for (NodeTermTraduction nodeTermTraduction : nodeTermTraductionList) {
            // cette fonction permet de remplir la table Permutée
            termHelper.splitConceptForPermute(ds, idConcept, new ConceptHelper().getGroupIdOfConcept(ds, idConcept, idThesaurus), idThesaurus, nodeTermTraduction.getLang(), nodeTermTraduction.getLexicalValue());
        }
    }
    // Génération des Termes Synonymes (NonPreferredTerm)
    ArrayList<NodeTab2Levels> tabIdNonPreferredTerm = termHelper.getAllIdOfNonPreferredTerms(ds, idThesaurus);
    for (NodeTab2Levels nodeTab2Levels : tabIdNonPreferredTerm) {
        nodeEMList = termHelper.getAllNonPreferredTerms(ds, nodeTab2Levels.getIdTerm(), idThesaurus);
        for (NodeEM nodeEM : nodeEMList) {
            // cette fonction permet de remplir la table Permutée
            termHelper.splitConceptForNonPermuted(ds, nodeTab2Levels.getIdConcept(), new ConceptHelper().getGroupIdOfConcept(ds, nodeTab2Levels.getIdConcept(), idThesaurus), idThesaurus, nodeEM.getLang(), nodeEM.getLexical_value());
        }
    }
    return true;
}
Also used : NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 4 with NodeTab2Levels

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

the class GetAltLabelTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    HikariDataSource conn = openConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    String idGroup = "6";
    boolean passed = false;
    // ConceptHelper conceptHelper = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    NoteHelper noteHelper = new NoteHelper();
    // ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    StringBuilder file = new StringBuilder();
    ArrayList<NodeEM> nodeEMs;
    ArrayList<NodeTab2Levels> nodeConceptTermId = termHelper.getAllIdOfNonPreferredTermsByGroup(conn, idTheso, idGroup);
    Term term;
    ArrayList<NodeNote> nodeNotes;
    file.append("Id_concept");
    file.append("\t");
    file.append("prefLabel");
    file.append("\t");
    file.append("altLabel");
    file.append("\t");
    file.append("définition");
    file.append("\n");
    for (NodeTab2Levels nodeTab2Levels : nodeConceptTermId) {
        nodeEMs = termHelper.getNonPreferredTerms(conn, nodeTab2Levels.getIdTerm(), idTheso, idLang);
        if (!nodeEMs.isEmpty()) {
            term = termHelper.getThisTerm(conn, nodeTab2Levels.getIdConcept(), idTheso, idLang);
            nodeNotes = noteHelper.getListNotesTerm(conn, nodeTab2Levels.getIdTerm(), idTheso, idLang);
            // écriture dans le fichier
            file.append(nodeTab2Levels.getIdConcept());
            file.append("\t");
            file.append(term.getLexical_value());
            file.append("\t");
            for (NodeEM nodeEM : nodeEMs) {
                if (passed) {
                    file.append("##");
                }
                file.append(nodeEM.getLexical_value());
                passed = true;
            }
            file.append("\t");
            for (NodeNote nodeNote : nodeNotes) {
                if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                    file.append(nodeNote.getLexicalvalue());
                }
            }
            file.append("\n");
        }
        passed = false;
    }
    System.out.println(file.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) Term(mom.trd.opentheso.bdd.datas.Term) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 5 with NodeTab2Levels

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

the class TermHelper method getAllIdOfNonPreferredTermsByGroup.

/**
 * Cette fonction permet de récupérer la liste de idTermes des
 * NonPreferredTerm (synonymes) pour un Thésaurus en filtrant par Group
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @return ArrayList (idConcept, idTerm)
 */
public ArrayList<NodeTab2Levels> getAllIdOfNonPreferredTermsByGroup(HikariDataSource ds, String idThesaurus, String idGroup) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeTab2Levels> tabIdNonPreferredTerm = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT DISTINCT preferred_term.id_concept," + " preferred_term.id_term FROM" + " non_preferred_term, preferred_term, concept_group_concept WHERE" + " preferred_term.id_term = non_preferred_term.id_term AND" + " concept_group_concept.idconcept = preferred_term.id_concept AND" + " concept_group_concept.idthesaurus = preferred_term.id_thesaurus AND" + " preferred_term.id_thesaurus = non_preferred_term.id_thesaurus" + " and non_preferred_term.id_thesaurus = '" + idThesaurus + "' AND" + " concept_group_concept.idgroup = '" + idGroup + "' order by id_concept ASC";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeTab2Levels nodeTab2Levels = new NodeTab2Levels();
                    nodeTab2Levels.setIdConcept(resultSet.getString("id_concept"));
                    nodeTab2Levels.setIdTerm(resultSet.getString("id_term"));
                    tabIdNonPreferredTerm.add(nodeTab2Levels);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Id of NonPreferedTerm of Thesaurus : " + idThesaurus, sqle);
    }
    return tabIdNonPreferredTerm;
}
Also used : NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Aggregations

NodeTab2Levels (mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels)5 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)3 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 ArrayList (java.util.ArrayList)2 Term (mom.trd.opentheso.bdd.datas.Term)2 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)2 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)2 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)1