Provides services for java client-side communication to a Greenstone Digital Library via CORBA.
 

Further Requirements

Java Interface Data Flows

NZDL Data Flow Diagram


A Typical Query

From a users perspective, a typical query may work  as follows:

Sample Code

Below is a trivial example of a client application. For a more elaborate example, see SimpleClient.

In order to function, this app needs Corbaserver running on the same machine.
 

/**
* TrivialDemo.java.
* A very simple client application that:
* - Creates a service object using an Interoperable
*   Object Reference (IOR) from a file;
* - lists all available collections;
* - searches "demo" collection for "snail farming";
* - prints the number of hits;
* - lists first 10 titles found;
* - displays the unformatted text of first document found.
*/
import java.io.*;
import java.util.*;
import java.lang.*;
import org.nzdl.gsdl.service.*; //the java-client stuff
import org.nzdl.gsdl.util.NzdlServiceFactory

public class TrivialDemo {
  public static void main( String [] args )
  {
    String myQueryString = "snail farming";
    String myCollection = "demo";

    // Create a Service Object
    NzdlService myService = NzdlServiceFactory.CreateNzdlService(args,
                      System.getProperties(), null, null, null);

    // Use getCollectionSet to obtain List of Collections
    Set myCollections = myService.getCollectionSet();

    //Display List of Collections
    System.out.println("\nThe available collections:");

    for (Iterator i = myCollections.iterator(); i.hasNext(); )
    {
        String collName = (String) i.next();
        System.out.println("  "+ collName);
    }

    // Create query object
    NzdlQuery query = new NzdlQuery( myQueryString );

    // Create request object
    NzdlRequest request = new NzdlRequest( query );

    // create response object
    NzdlResponse response = new NzdlResponse( );

    // use service to get response from request to myCollection
    myService.service( myCollection, request, response );

    // use getResultSet to get results from response
    NzdlResultSet results = response.getResultSet();

    // getNumOfDocs
    System.out.println("\nNumber of hits = "+results.getNumOfDocs());

    // Use getDocumentIDs to build list of titles (defaults: 1 - 10)
    List docIDs = results.getDocumentIDs();
    System.out.println("\nThe titles:");
    for (ListIterator i = docIDs.listIterator(); i.hasNext(); )
    {
        Set metaData
        = myService.getMetaData( myCollection,(String)i.next(),"Title");
        Iterator j = metaData.iterator();
        System.out.println(j.next()); //print title metadata
    }
    System.out.println("\nThe first document returned was:");

    // Print first document returned
    String myDoc
        = myService.getDocument(myCollection,(String)docIDs.get(0));
    System.out.println(myDoc);

    } // end of main
} // end of demo class