See:
Description
Interface Summary | |
NzdlService | An object that services CORBA client requests to a Greenstone Digital Library. |
Class Summary | |
NzdlCollectionInfo | An object that stores information on a collection. |
NzdlQuery | NzdlQuery is an object that holds the options for a query and is easily configured by the user. |
NzdlQueryHit | Holds a single result from a query. |
NzdlRequest | An object that holds CORBA request data ready for by servicing by NzdlService. |
NzdlResponse | An object that holds data from a response after a NzdlRequest has been serviced by NzdlService. |
NzdlResultSet | An object that holds results extracted from a response by NzdlResponse.getResultSet(). |
NzdlServiceClient | Used to implement the NzdlService object. |
NzdlServiceServer | SimpleServer Based on algorithms in ... |
public class TrivialDemo {
public static void main( String [] args )
{
String myIorFile = "/tmp/localcorba.objid";
String myQueryString = "snail farming";
String myCollection = "demo";
// Use NzdlService to create corba connection
NzdlService myService = new NzdlServiceClient
( null, null, getIor(myIorFile) );
// 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);
}
// Find The Number of documents in my collection
NzdlCollectionInfo myInfo = myService.getCollectionInfo(myCollection);
System.out.println("\nNum Of Collection docs
= "+myInfo.getNumOfDocs());
// 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
// Read the IOR from a file
static private String getIor(String sourceOfID)
{
String ior = null;
try
{
BufferedReader input
= new BufferedReader(new FileReader(sourceOfID));
ior = input.readLine();
}
catch (java.io.IOException e)
{
System.err.println("Error
reading IOR key:\n" + e);
System.exit(1);
}
return ior;
} //end of getIors
} // end of demo class