int *error,
char **addinfo,
ODR odr);
+
+
+ void prepare_elements(BackendPtr b,
+ Odr_oid *preferredRecordSyntax,
+ const char *element_set_name,
+ bool &enable_pz2_retrieval,
+ bool &enable_pz2_transform,
+ bool &assume_marc8_charset);
+
Z_Records *get_records(Odr_int start,
Odr_int number_to_present,
int *error,
b->set_option("apdulog", "1");
if (sptr->piggyback)
- b->set_option("count", "10");
+ b->set_option("count", "1"); /* some SRU servers INSIST on getting
+ maximumRecords > 0 */
b->set_option("piggyback", sptr->piggyback ? "1" : "0");
std::string authentication = sptr->authentication;
return b;
}
-Z_Records *yf::Zoom::Frontend::get_records(Odr_int start,
- Odr_int number_to_present,
- int *error,
- char **addinfo,
- Odr_int *number_of_records_returned,
- ODR odr,
- BackendPtr b,
- Odr_oid *preferredRecordSyntax,
- const char *element_set_name)
-{
- *number_of_records_returned = 0;
- Z_Records *records = 0;
- bool enable_pz2_retrieval = false; // whether target profile is used
- bool enable_pz2_transform = false; // whether XSLT is used as well
- bool assume_marc8_charset = false;
-
- if (start < 0 || number_to_present <= 0)
- return records;
-
- if (number_to_present > 10000)
- number_to_present = 10000;
-
- ZOOM_record *recs = (ZOOM_record *)
- odr_malloc(odr, (size_t) number_to_present * sizeof(*recs));
+void yf::Zoom::Frontend::prepare_elements(BackendPtr b,
+ Odr_oid *preferredRecordSyntax,
+ const char *element_set_name,
+ bool &enable_pz2_retrieval,
+ bool &enable_pz2_transform,
+ bool &assume_marc8_charset)
+{
char oid_name_str[OID_STR_MAX];
const char *syntax_name = 0;
if (enable_pz2_retrieval)
{
- if (b->sptr->request_syntax.length())
+ std::string configured_request_syntax = b->sptr->request_syntax;
+ if (configured_request_syntax.length())
{
- syntax_name = b->sptr->request_syntax.c_str();
+ syntax_name = configured_request_syntax.c_str();
const Odr_oid *syntax_oid =
yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, syntax_name);
if (!oid_oidcmp(syntax_oid, yaz_oid_recsyn_usmarc)
syntax_name =
yaz_oid_to_string_buf(preferredRecordSyntax, 0, oid_name_str);
+ if (b->sptr->sru.length())
+ syntax_name = "XML";
+
b->set_option("preferredRecordSyntax", syntax_name);
if (enable_pz2_retrieval)
b->set_option("elementSetName", element_set_name);
+}
+
+Z_Records *yf::Zoom::Frontend::get_records(Odr_int start,
+ Odr_int number_to_present,
+ int *error,
+ char **addinfo,
+ Odr_int *number_of_records_returned,
+ ODR odr,
+ BackendPtr b,
+ Odr_oid *preferredRecordSyntax,
+ const char *element_set_name)
+{
+ *number_of_records_returned = 0;
+ Z_Records *records = 0;
+ bool enable_pz2_retrieval = false; // whether target profile is used
+ bool enable_pz2_transform = false; // whether XSLT is used as well
+ bool assume_marc8_charset = false;
+
+ prepare_elements(b, preferredRecordSyntax,
+ element_set_name,
+ enable_pz2_retrieval,
+ enable_pz2_transform,
+ assume_marc8_charset);
+
+ if (start < 0 || number_to_present <=0)
+ return records;
+
+ if (number_to_present > 10000)
+ number_to_present = 10000;
+
+ ZOOM_record *recs = (ZOOM_record *)
+ odr_malloc(odr, (size_t) number_to_present * sizeof(*recs));
+
b->present(start, number_to_present, recs, error, addinfo, odr);
int i = 0;
}
return records;
}
-
+
struct cql_node *yf::Zoom::Impl::convert_cql_fields(struct cql_node *cn,
ODR odr)
{
b->set_option("setname", "default");
+ bool enable_pz2_retrieval = false;
+ bool enable_pz2_transform = false;
+ bool assume_marc8_charset = false;
+ prepare_elements(b, sr->preferredRecordSyntax, 0 /*element_set_name */,
+ enable_pz2_retrieval,
+ enable_pz2_transform,
+ assume_marc8_charset);
+
Odr_int hits = 0;
Z_Query *query = sr->query;
WRBUF ccl_wrbuf = 0;