Search in sources :

Example 1 with SearchException

use of com.k_int.IR.SearchException in project opentheso by miledrousset.

the class TestRecursive method totalOfNotices.

private int totalOfNotices(ArrayList<String> lisIds) {
    int total = 0;
    Properties p = new Properties();
    p.put("CollectionDataSourceClassName", "com.k_int.util.Repository.XMLDataSource");
    p.put("RepositoryDataSourceURL", "file:" + "/Users/Miled/NetBeansProjects/opentheso/src/main/webapp/repositories.xml");
    p.put("XSLConverterConfiguratorClassName", "com.k_int.IR.Syntaxes.Conversion.XMLConfigurator");
    p.put("ConvertorConfigFile", "/Users/Miled/NetBeansProjects/opentheso/src/main/webapp/SchemaMappings.xml");
    Searchable federated_search_proxy = new HeterogeneousSetOfSearchable();
    federated_search_proxy.init(p);
    try {
        IRQuery e = new IRQuery();
        // e.collections = new Vector<String>();
        e.collections.add("KOHA/biblios");
        e.hints.put("default_element_set_name", "f");
        e.hints.put("small_set_setname", "f");
        e.hints.put("record_syntax", "unimarc");
        for (String idConcept : lisIds) {
            e.query = new PrefixString((new StringBuilder("@attrset bib-1 @attr 1=Koha-Auth-Number \"")).append(AsciiUtils.convertNonAscii("" + idConcept)).append("\"").toString());
            SearchTask st = federated_search_proxy.createTask(e, null);
            st.evaluate(5000);
            total = total + st.getTaskResultSet().getFragmentCount();
        }
    } catch (TimeoutExceededException | SearchException srch_e) {
        srch_e.printStackTrace();
    }
    return total;
}
Also used : TimeoutExceededException(com.k_int.IR.TimeoutExceededException) SearchTask(com.k_int.IR.SearchTask) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) PrefixString(com.k_int.IR.QueryModels.PrefixString) SearchException(com.k_int.IR.SearchException) PrefixString(com.k_int.IR.QueryModels.PrefixString) Properties(java.util.Properties) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) Searchable(com.k_int.IR.Searchable) IRQuery(com.k_int.IR.IRQuery)

Example 2 with SearchException

use of com.k_int.IR.SearchException 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 3 with SearchException

use of com.k_int.IR.SearchException in project opentheso by miledrousset.

the class SelectedTerme method getNbNoticesOfBranch.

public String getNbNoticesOfBranch() {
    // ResourceBundle bundlePref = getBundlePref();
    int total = 0;
    if (totalNoticesOfBranch.isEmpty()) {
        if (user.getNodePreference().isZ3950actif()) {
            ConceptHelper conceptHelper = new ConceptHelper();
            ArrayList<String> lisIds = new ArrayList();
            lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idC, idTheso, lisIds);
            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");
                for (String idConcept : lisIds) {
                    e.query = new PrefixString((new StringBuilder("@attrset bib-1 @attr 1=Koha-Auth-Number \"")).append(AsciiUtils.convertNonAscii("" + idConcept)).append("\"").toString());
                    SearchTask st = federated_search_proxy.createTask(e, null);
                    st.evaluate(5000);
                    total = total + st.getTaskResultSet().getFragmentCount();
                    st.destroyTask();
                }
                federated_search_proxy.destroy();
            } catch (TimeoutExceededException | SearchException srch_e) {
                srch_e.printStackTrace();
            }
            totalNoticesOfBranch = "" + total;
        }
    }
    return totalNoticesOfBranch;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) SearchException(com.k_int.IR.SearchException) PrefixString(com.k_int.IR.QueryModels.PrefixString) Properties(java.util.Properties) TimeoutExceededException(com.k_int.IR.TimeoutExceededException) SearchTask(com.k_int.IR.SearchTask) 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)

Example 4 with SearchException

use of com.k_int.IR.SearchException in project opentheso by miledrousset.

the class SelectedTerme method getNotice.

/**
 * *
 * Fin des nouvelles fonctions
 */
/**
 * ************************************ GETTERS SETTERS
 * *************************************
 */
/**
 * Retourne le nombre de notice pour un terme passé en paramètre
 *
 * @param idTe
 */
private int getNotice(String idTe) {
    // ResourceBundle bundlePref = getBundlePref();
    int nbNoticesT = 0;
    if (user.getNodePreference().isZ3950actif()) {
        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("" + idTe)).append("\"").toString());
            SearchTask st = federated_search_proxy.createTask(e, null);
            st.evaluate(5000);
            nbNoticesT = st.getTaskResultSet().getFragmentCount();
            st.destroyTask();
            federated_search_proxy.destroy();
        } catch (TimeoutExceededException | SearchException srch_e) {
            srch_e.printStackTrace();
        }
    }
    return nbNoticesT;
}
Also used : TimeoutExceededException(com.k_int.IR.TimeoutExceededException) SearchTask(com.k_int.IR.SearchTask) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) PrefixString(com.k_int.IR.QueryModels.PrefixString) SearchException(com.k_int.IR.SearchException) Properties(java.util.Properties) Searchable(com.k_int.IR.Searchable) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) IRQuery(com.k_int.IR.IRQuery)

Example 5 with SearchException

use of com.k_int.IR.SearchException in project opentheso by miledrousset.

the class ExportTxtHelper method totalOfNotices.

/**
 * fonction temporaire qui ne marche qu'avec Koha
 */
private int totalOfNotices(String idConcept) {
    int tot = 0;
    if (nodePreference == null) {
        return 0;
    }
    if (nodePreference.isZ3950actif()) {
        Properties p = new Properties();
        p.put("CollectionDataSourceClassName", "com.k_int.util.Repository.XMLDataSource");
        p.put("RepositoryDataSourceURL", "file:" + nodePreference.getPathNotice1());
        p.put("XSLConverterConfiguratorClassName", "com.k_int.IR.Syntaxes.Conversion.XMLConfigurator");
        p.put("ConvertorConfigFile", nodePreference.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("KOHA/biblios");
            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("" + idConcept)).append("\"").toString());
            SearchTask st = federated_search_proxy.createTask(e, null);
            st.evaluate(5000);
            tot = st.getTaskResultSet().getFragmentCount();
            st.destroyTask();
            federated_search_proxy.destroy();
        } catch (TimeoutExceededException | SearchException srch_e) {
        // srch_e.printStackTrace();
        }
    }
    return tot;
}
Also used : TimeoutExceededException(com.k_int.IR.TimeoutExceededException) SearchTask(com.k_int.IR.SearchTask) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) PrefixString(com.k_int.IR.QueryModels.PrefixString) SearchException(com.k_int.IR.SearchException) Properties(java.util.Properties) HeterogeneousSetOfSearchable(com.k_int.hss.HeterogeneousSetOfSearchable) Searchable(com.k_int.IR.Searchable) IRQuery(com.k_int.IR.IRQuery)

Aggregations

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