source: trunk/java-client/org/nzdl/gsdl/service/package.html@ 2254

Last change on this file since 2254 was 2163, checked in by bas6, 23 years ago

Tidied up some comments & added package.html to SimpleGraphical Client

  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.16-22 i686) [Netscape]">
6 <title>: Package org.nzdl.gsdl.service</title>
7<!--NewPage-->
8<!-- Generated by javadoc on Thu Mar 08 23:01:13 GMT+13:00 2001 -->
9</head>
10<body bgcolor="#FFFFFF">
11Provides services for java client-side communication
12to a Greenstone Digital Library via CORBA.
13<br>&nbsp;
14<h2>
15Further Requirements</h2>
16
17<ul>
18<li>
19Sun Java 2 version 1.3 (or later)</li>
20
21<li>
22Corbaserver, a server-side application for communicating to a Greenstone
23Digital Library.</li>
24</ul>
25
26<h2>
27Java Interface Data Flows</h2>
28
29<center><img SRC="nzdl-service-package.png" ALT="NZDL Data Flow Diagram" height=280 width=637></center>
30
31<p><br>
32<h2>
33A Typical Query</h2>
34From a users perspective, a typical query may work&nbsp; as follows:
35<ul>
36<li>
37&nbsp;Create instances of the necessary NZDL Java-Client objects:</li>
38
39<ul>
40<li>
41&nbsp; a <b>NzdlQuery</b> object</li>
42
43<li>
44&nbsp; a <b>NzdlRequest </b>object using your <b>NzdlQuery</b> object</li>
45
46<li>
47&nbsp; a <b>NzdlResponse</b> object that will eventually hold response
48data</li>
49
50<li>
51&nbsp; a <b>NzdlService</b> object to service CORBA interface requests
52to
53a Greenstone collection</li>
54</ul>
55
56<li>
57Use the <b>NzdlService</b> object (with collection name and <b>NzdlRequest
58</b>object)
59to query the CORBA interface and place the reply into the <b>NzdlResponse</b>
60object.</li>
61
62<li>
63Create an instance of the <b>NzdlResultSet</b> object. Use <b>NzdlResponse.getResultSet()
64</b>to
65extract response data into the <b>NzdlResultSet</b> object.</li>
66
67<li>
68Use the <b>NzdlResultSet</b> methods to view data such as document IDs</li>
69
70<br>Get documents using <b>NzdlService.getDocument()</b></ul>
71
72<h1>
73Sample Code</h1>
74Below is a trivial example of a client application. For a more elaborate
75example, see <a href="../SimpleClient.html">SimpleClient</a>.
76<p>In order to function, this app needs Corbaserver running on the same
77machine.
78<p><tt>/**</tt>
79<br><tt>* TrivialDemo.java.</tt>
80<br><tt>* A very simple client application that:</tt>
81<br><tt>* - Creates a service object using an Interoperable</tt>
82<br><tt>*&nbsp;&nbsp; Object Reference (IOR) from a file;</tt>
83<br><tt>* - lists all available collections;</tt>
84<br><tt>* - searches "demo" collection for "snail farming";</tt>
85<br><tt>* - prints the number of hits;</tt>
86<br><tt>* - lists first 10 titles found;</tt>
87<br><tt>* - displays the unformatted text of first document found.</tt>
88<br><tt>*/</tt>
89<br><tt>import java.io.*;</tt>
90<br><tt>import java.util.*;</tt>
91<br><tt>import java.lang.*;</tt>
92<br><tt>import org.nzdl.gsdl.service.*; //the java-client stuff</tt>
93<br><tt>import org.nzdl.gsdl.util.NzdlIORs; //for obtaining the IOR</tt>
94<p><tt>public class TrivialDemo {</tt>
95<br><tt>&nbsp; public static void main( String [] args )</tt>
96<br><tt>&nbsp; {</tt>
97<br><tt>&nbsp;&nbsp;&nbsp; String myIorFile = "/tmp/localcorba.objid";</tt>
98<br><tt>&nbsp;&nbsp;&nbsp; String myQueryString = "snail farming";</tt>
99<br><tt>&nbsp;&nbsp;&nbsp; String myCollection = "demo";</tt>
100<p><tt>&nbsp;&nbsp;&nbsp; // Create a Service Object</tt>
101<br><tt>&nbsp;&nbsp;&nbsp; NzdlService myService = NzdlIORs.findIOR(null,
102null,</tt>
103<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
104myIorFile, null);</tt>
105<p><tt>&nbsp;&nbsp;&nbsp; // Use getCollectionSet to obtain List of Collections</tt>
106<br><tt>&nbsp;&nbsp;&nbsp; Set myCollections = myService.getCollectionSet();</tt>
107<p><tt>&nbsp;&nbsp;&nbsp; //Display List of Collections</tt>
108<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe available collections:");</tt>
109<p><tt>&nbsp;&nbsp;&nbsp; for (Iterator i = myCollections.iterator(); i.hasNext();
110)</tt>
111<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
112<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String collName = (String)
113i.next();</tt>
114<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("&nbsp;
115"+ collName);</tt>
116<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
117<p><tt>&nbsp;&nbsp;&nbsp; // Find The Number of documents in my collection</tt>
118<br><tt>&nbsp;&nbsp;&nbsp; NzdlCollectionInfo myInfo = myService.getCollectionInfo(myCollection);</tt>
119<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nNum Of Collection docs
120= "+myInfo.getNumOfDocs());</tt>
121<p><tt>&nbsp;&nbsp;&nbsp; // Create query object</tt>
122<br><tt>&nbsp;&nbsp;&nbsp; NzdlQuery query = new NzdlQuery( myQueryString
123);</tt>
124<p><tt>&nbsp;&nbsp;&nbsp; // Create request object</tt>
125<br><tt>&nbsp;&nbsp;&nbsp; NzdlRequest request = new NzdlRequest( query
126);</tt>
127<p><tt>&nbsp;&nbsp;&nbsp; // create response object</tt>
128<br><tt>&nbsp;&nbsp;&nbsp; NzdlResponse response = new NzdlResponse( );</tt>
129<p><tt>&nbsp;&nbsp;&nbsp; // use service to get response from request to
130myCollection</tt>
131<br><tt>&nbsp;&nbsp;&nbsp; myService.service( myCollection, request, response
132);</tt>
133<p><tt>&nbsp;&nbsp;&nbsp; // use getResultSet to get results from response</tt>
134<br><tt>&nbsp;&nbsp;&nbsp; NzdlResultSet results = response.getResultSet();</tt>
135<p><tt>&nbsp;&nbsp;&nbsp; // getNumOfDocs</tt>
136<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nNumber of hits = "+results.getNumOfDocs());</tt>
137<p><tt>&nbsp;&nbsp;&nbsp; // Use getDocumentIDs to build list of titles
138(defaults: 1 - 10)</tt>
139<br><tt>&nbsp;&nbsp;&nbsp; List docIDs = results.getDocumentIDs();</tt>
140<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe titles:");</tt>
141<br><tt>&nbsp;&nbsp;&nbsp; for (ListIterator i = docIDs.listIterator();
142i.hasNext(); )</tt>
143<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
144<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set metaData</tt>
145<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = myService.getMetaData(
146myCollection,(String)i.next(),"Title");</tt>
147<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterator j = metaData.iterator();</tt>
148<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(j.next());
149//print title metadata</tt>
150<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
151<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe first document returned
152was:");</tt>
153<p><tt>&nbsp;&nbsp;&nbsp; // Print first document returned</tt>
154<br><tt>&nbsp;&nbsp;&nbsp; String myDoc</tt>
155<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = myService.getDocument(myCollection,(String)docIDs.get(0));</tt>
156<br><tt>&nbsp;&nbsp;&nbsp; System.out.println(myDoc);</tt>
157<p><tt>&nbsp;&nbsp;&nbsp; } // end of main</tt>
158<br><tt>} // end of demo class</tt>
159<br>&nbsp;
160</body>
161</html>
Note: See TracBrowser for help on using the repository browser.