New ZOOM option schema.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Nov 2001 08:24:05 +0000 (08:24 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Nov 2001 08:24:05 +0000 (08:24 +0000)
CHANGELOG
doc/zoom.xml
zoom/zoom-c.c
zoom/zoomtst4.c

index 2e286f7..4279066 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@ Possible compatibility problems with earlier versions marked with '*'.
 
 --- 1.8.4 2001/XX/XX
 
+New ZOOM option, schema, that specifies shema OID for retrieval.
+
 New CCL feature. Qualifiers can be aliases for one or more
 other qualifiers (if more than one is given, OR is used).
 
index d2c561c..63bff81 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $Id: zoom.xml,v 1.13 2001-11-22 09:45:31 adam Exp $ -->
+<!-- $Id: zoom.xml,v 1.14 2001-11-30 08:24:06 adam Exp $ -->
  <chapter id="zoom"><title>Building clients with ZOOM</title>
   
   <para>
         <literal>USMARC</literal>, <literal>SUTRS</literal>, etc.
        </entry><entry>none</entry></row>
       <row><entry>
+        schema</entry><entry>Schema for retrieval, such as
+        <literal>Gils-schema</literal>, <literal>Geo-schema</literal>, etc.
+       </entry><entry>none</entry></row>
+      <row><entry>
         smallSetUpperBound</entry><entry>If hits is less than or equal to this
         value, then target will return all records using small element set name
        </entry><entry>0</entry></row>
index d801960..862811b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoom-c.c,v 1.13 2001-11-28 23:00:19 adam Exp $
+ * $Id: zoom-c.c,v 1.14 2001-11-30 08:24:06 adam Exp $
  *
  * ZOOM layer for C, connections, result sets, queries.
  */
@@ -370,7 +370,7 @@ ZOOM_resultset ZOOM_connection_search(ZOOM_connection c, ZOOM_query q)
     cp = ZOOM_options_get (r->options, "setname");
     if (cp)
         r->setname = xstrdup (cp);
-
+    
     r->connection = c;
 
     r->next = c->resultsets;
@@ -440,6 +440,7 @@ static void ZOOM_resultset_retrieve (ZOOM_resultset r,
 {
     ZOOM_task task;
     ZOOM_connection c;
+    const char *cp;
 
     if (!r)
        return;
@@ -659,6 +660,7 @@ static int ZOOM_connection_send_search (ZOOM_connection c)
     const char *elementSetName;
     const char *smallSetElementSetName;
     const char *mediumSetElementSetName;
+    const char *schema;
 
     assert (c->tasks);
     assert (c->tasks->which == ZOOM_TASK_SEARCH);
@@ -671,6 +673,8 @@ static int ZOOM_connection_send_search (ZOOM_connection c)
        ZOOM_options_get (r->options, "smallSetElementSetName");
     mediumSetElementSetName =
        ZOOM_options_get (r->options, "mediumSetElementSetName");
+    schema =
+       ZOOM_options_get (r->options, "schema");
 
     if (!smallSetElementSetName)
        smallSetElementSetName = elementSetName;
@@ -701,7 +705,7 @@ static int ZOOM_connection_send_search (ZOOM_connection c)
        *search_req->mediumSetPresentNumber = mspn;
     }
     else if (r->start == 0 && r->count > 0
-            && r->piggyback && !r->r_sort_spec)
+            && r->piggyback && !r->r_sort_spec && !schema)
     {
        /* Regular piggyback - do it unless we're going to do sort */
        *search_req->largeSetLowerBound = 2000000000;
@@ -1108,6 +1112,8 @@ static int send_present (ZOOM_connection c)
        ZOOM_options_get (c->options, "preferredRecordSyntax");
     const char *element =
        ZOOM_options_get (c->options, "elementSetName");
+    const char *schema =
+       ZOOM_options_get (c->options, "schema");
     ZOOM_resultset  resultset;
 
     if (!c->tasks)
@@ -1156,7 +1162,48 @@ static int send_present (ZOOM_connection c)
        req->preferredRecordSyntax =
            yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
 
-    if (element && *element)
+    if (schema && *schema)
+    {
+       Z_RecordComposition *compo = odr_malloc (c->odr_out, sizeof(*compo));
+
+        req->recordComposition = compo;
+        compo->which = Z_RecordComp_complex;
+        compo->u.complex = (Z_CompSpec *)
+            odr_malloc(c->odr_out, sizeof(*compo->u.complex));
+        compo->u.complex->selectAlternativeSyntax = (bool_t *) 
+            odr_malloc(c->odr_out, sizeof(bool_t));
+        *compo->u.complex->selectAlternativeSyntax = 0;
+
+        compo->u.complex->generic = (Z_Specification *)
+            odr_malloc(c->odr_out, sizeof(*compo->u.complex->generic));
+
+        compo->u.complex->generic->schema = (Odr_oid *)
+            yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, schema);
+
+        if (!compo->u.complex->generic->schema)
+        {
+            /* OID wasn't a schema! Try record syntax instead. */
+
+            compo->u.complex->generic->schema = (Odr_oid *)
+                yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, schema);
+        }
+        if (element && *element)
+        {
+            compo->u.complex->generic->elementSpec = (Z_ElementSpec *)
+                odr_malloc(c->odr_out, sizeof(Z_ElementSpec));
+            compo->u.complex->generic->elementSpec->which =
+                Z_ElementSpec_elementSetName;
+            compo->u.complex->generic->elementSpec->u.elementSetName =
+                odr_strdup (c->odr_out, element);
+        }
+        else
+            compo->u.complex->generic->elementSpec = 0;
+        compo->u.complex->num_dbSpecific = 0;
+        compo->u.complex->dbSpecific = 0;
+        compo->u.complex->num_recordSyntax = 0;
+        compo->u.complex->recordSyntax = 0;
+    }
+    else if (element && *element)
     {
        Z_ElementSetNames *esn = odr_malloc (c->odr_out, sizeof(*esn));
        Z_RecordComposition *compo = odr_malloc (c->odr_out, sizeof(*compo));
index a2eb137..7be0b96 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst4.c,v 1.6 2001-11-22 09:45:31 adam Exp $
+ * $Id: zoomtst4.c,v 1.7 2001-11-30 08:24:06 adam Exp $
  *
  * Asynchronous multi-target going through proxy doing search and retrieve
  * using present.
@@ -42,6 +42,8 @@ int main(int argc, char **argv)
     /* get 20 (at most) records from offset 5 */
     ZOOM_options_set (o, "start", "5");
     ZOOM_options_set (o, "count", "20");
+    ZOOM_options_set (o, "schema", "gils-schema");
+    ZOOM_options_set (o, "elementSetName", "F");
 
     /* set proxy */
     ZOOM_options_set (o, "proxy", argv[1]);