From: Adam Dickmeiss Date: Tue, 3 Sep 2013 13:51:53 +0000 (+0200) Subject: Handle SRU queryType (YAZ 5) X-Git-Tag: v1.3.62~12 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=54c6c2c4fa4378ced846240bea454bc9583f48da;p=metaproxy-moved-to-github.git Handle SRU queryType (YAZ 5) --- diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 06305bb..494a944 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -869,7 +869,13 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( const Z_SRW_searchRetrieveRequest *req ) const { - if (req->query_type == Z_SRW_query_type_cql) + if ( +#ifdef Z_SRW_query_type_cql + req->query_type == Z_SRW_query_type_cql +#else + !strcmp(req->queryType, "cql") +#endif + ) { Z_External *ext = (Z_External *) odr_malloc(odr_en, sizeof(*ext)); @@ -878,22 +884,39 @@ int yf::SRUtoZ3950::Impl::z3950_build_query( ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_CQL; - ext->u.cql = odr_strdup(odr_en, req->query.cql); + ext->u.cql = odr_strdup(odr_en, +#ifdef Z_SRW_query_type_cql + req->query.cql +#else + req->query +#endif + ); z_query->which = Z_Query_type_104; z_query->u.type_104 = ext; return 0; } - if (req->query_type == Z_SRW_query_type_pqf) + if ( +#ifdef Z_SRW_query_type_pqf + req->query_type == Z_SRW_query_type_pqf +#else + !strcmp(req->queryType, "pqf") +#endif + ) { Z_RPNQuery *RPNquery; YAZ_PQF_Parser pqf_parser; pqf_parser = yaz_pqf_create (); - RPNquery = yaz_pqf_parse (pqf_parser, odr_en, req->query.pqf); - + RPNquery = yaz_pqf_parse (pqf_parser, odr_en, +#ifdef Z_SRW_query_type_pqf + req->query.pqf +#else + req->query +#endif + ); yaz_pqf_destroy(pqf_parser); if (!RPNquery) diff --git a/src/sru_util.cpp b/src/sru_util.cpp index 8c10681..da9aaa4 100644 --- a/src/sru_util.cpp +++ b/src/sru_util.cpp @@ -281,6 +281,7 @@ mp_util::check_sru_query_exists(mp::Package &package, Z_SRW_PDU *sru_pdu_res, Z_SRW_searchRetrieveRequest const *sr_req) { +#ifdef Z_SRW_query_type_cql if ((sr_req->query_type == Z_SRW_query_type_cql && !sr_req->query.cql)) { yaz_add_srw_diagnostic(odr_en, @@ -313,6 +314,22 @@ mp_util::check_sru_query_exists(mp::Package &package, "PQF query is empty"); return false; } +#else + if (!sr_req->query) + { + yaz_add_srw_diagnostic(odr_en, + &(sru_pdu_res->u.response->diagnostics), + &(sru_pdu_res->u.response->num_diagnostics), + YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, + "query"); + yaz_add_srw_diagnostic(odr_en, + &(sru_pdu_res->u.response->diagnostics), + &(sru_pdu_res->u.response->num_diagnostics), + YAZ_SRW_QUERY_SYNTAX_ERROR, + "CQL query is empty"); + return false; + } +#endif return true; } @@ -365,6 +382,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu) else os << " -"; +#ifdef Z_SRW_query_type_cql switch (sr->query_type){ case Z_SRW_query_type_cql: os << " CQL"; @@ -380,6 +398,10 @@ std::ostream& std::operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu) os << " " << sr->query.pqf; break; } +#else + os << " " << (sr->queryType ? sr->queryType : "cql") + << " " << sr->query; +#endif } } break;