Search in sources :

Example 1 with NodeFusion

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

the class SelectedTerme method majNoticeZ3950.

private void majNoticeZ3950() {
    // ResourceBundle bundlePref = getBundlePref();
    if (user.getNodePreference().isZ3950actif()) {
        try {
            Properties p = new Properties();
            p.put("CollectionDataSourceClassName", "com.k_int.util.Repository.XMLDataSource");
            p.put("RepositoryDataSourceURL", "file:" + user.getNodePreference().getPathNotice1());
            p.put("XSLConverterConfiguratorClassName", "com.k_int.IR.Syntaxes.Conversion.XMLConfigurator");
            p.put("ConvertorConfigFile", user.getNodePreference().getPathNotice2());
            Searchable federated_search_proxy = new HeterogeneousSetOfSearchable();
            federated_search_proxy.init(p);
            try {
                IRQuery e = new IRQuery();
                // e.collections = new Vector<String>();
                e.collections.add(user.getNodePreference().getCollectionAdresse());
                e.hints.put("default_element_set_name", "f");
                e.hints.put("small_set_setname", "f");
                e.hints.put("record_syntax", "unimarc");
                e.query = new PrefixString((new StringBuilder("@attrset bib-1 @attr 1=Koha-Auth-Number \"")).append(AsciiUtils.convertNonAscii("" + idC)).append("\"").toString());
                SearchTask st = federated_search_proxy.createTask(e, null);
                st.evaluate(5000);
                nbNotices = st.getTaskResultSet().getFragmentCount();
                st.destroyTask();
                federated_search_proxy.destroy();
                for (NodeFusion nf : getFusions()) {
                    if (nf.getIdConcept1().equals(idC)) {
                        String idTe = new TermHelper().getIdTermOfConcept(connect.getPoolConnexion(), nf.getIdConcept2(), idTheso);
                        nbNotices += getNotice(idTe);
                    }
                }
            } catch (TimeoutExceededException | SearchException srch_e) {
            // srch_e.printStackTrace();
            }
            urlNotice = user.getNodePreference().getNoticeUrl();
            try {
                // String url_notices = "http://catalogue.frantiq.fr/cgi-bin/koha/opac-search.pl?idx=su%2Cwrdl&q=terme&idx=kw&idx=kw&sort_by=relevance&do=OK";
                urlNotice = urlNotice.replace("terme", URLEncoder.encode("" + idC, user.getNodePreference().getUrlEncode()));
            } catch (UnsupportedEncodingException ex) {
            // Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (Exception e) {
        }
    }
}
Also used : HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) SearchException(com.k_int.IR.SearchException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PrefixString(com.k_int.IR.QueryModels.PrefixString) Properties(java.util.Properties) JsonException(javax.json.JsonException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SearchException(com.k_int.IR.SearchException) SQLException(java.sql.SQLException) MalformedURLException(java.net.MalformedURLException) TimeoutExceededException(com.k_int.IR.TimeoutExceededException) IOException(java.io.IOException) TimeoutExceededException(com.k_int.IR.TimeoutExceededException) SearchTask(com.k_int.IR.SearchTask) NodeFusion(mom.trd.opentheso.bdd.helper.nodes.NodeFusion) PrefixString(com.k_int.IR.QueryModels.PrefixString) Searchable(com.k_int.IR.Searchable) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) IRQuery(com.k_int.IR.IRQuery) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 2 with NodeFusion

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

the class ConceptHelper method getConceptFusion.

public ArrayList<NodeFusion> getConceptFusion(HikariDataSource ds, String idConcept, String idLang, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeFusion> nf = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_concept1, id_concept2 from concept_fusion where" + " concept_fusion.id_thesaurus = '" + idThesaurus + "'" + " AND (concept_fusion.id_concept1 = '" + idConcept + "'" + " OR concept_fusion.id_concept2 = '" + idConcept + "')";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeFusion n = new NodeFusion();
                    n.setIdConcept1(resultSet.getString("id_concept1"));
                    n.setIdConcept2(resultSet.getString("id_concept2"));
                    n.setLexicalValue1(getLexicalValueOfConcept(ds, resultSet.getString("id_concept1"), idThesaurus, idLang));
                    n.setLexicalValue2(getLexicalValueOfConcept(ds, resultSet.getString("id_concept2"), idThesaurus, idLang));
                    nf.add(n);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting fusion of Concept : " + idConcept, sqle);
    }
    return nf;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) NodeFusion(mom.trd.opentheso.bdd.helper.nodes.NodeFusion) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Aggregations

SQLException (java.sql.SQLException)2 NodeFusion (mom.trd.opentheso.bdd.helper.nodes.NodeFusion)2 IRQuery (com.k_int.IR.IRQuery)1 PrefixString (com.k_int.IR.QueryModels.PrefixString)1 SearchException (com.k_int.IR.SearchException)1 SearchTask (com.k_int.IR.SearchTask)1 Searchable (com.k_int.IR.Searchable)1 TimeoutExceededException (com.k_int.IR.TimeoutExceededException)1 HeterogeneousSetOfSearchable (com.k_int.hss.HeterogeneousSetOfSearchable)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 JsonException (javax.json.JsonException)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1