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

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

Added overview.html. Added package.html to: getopt, gsdl, ptp, service, util, SimpleGraphicalClient. Added nzdl-service-package.png to service.

  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 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<p><b>See:</b>
14<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><a href="#package_description">Description</a></b>
15<table BORDER CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
16<tr BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
17<td COLSPAN="2"><b><font size=+2>Interface Summary</font></b></td>
18</tr>
19
20<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
21<td WIDTH="15%"><b><i><a href="NzdlService.html">NzdlService</a></i></b></td>
22
23<td>An object that services CORBA client requests to a Greenstone Digital
24Library.</td>
25</tr>
26</table>
27
28<table BORDER CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
29<tr BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
30<td COLSPAN="2"><b><font size=+2>Class Summary</font></b></td>
31</tr>
32
33<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
34<td WIDTH="15%"><b><a href="NzdlCollectionInfo.html">NzdlCollectionInfo</a></b></td>
35
36<td>An object that stores information on a collection.</td>
37</tr>
38
39<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
40<td WIDTH="15%"><b><a href="NzdlQuery.html">NzdlQuery</a></b></td>
41
42<td>NzdlQuery is an object that holds the options for a query and is easily
43configured by the user.</td>
44</tr>
45
46<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
47<td WIDTH="15%"><b><a href="NzdlQueryHit.html">NzdlQueryHit</a></b></td>
48
49<td>Holds a single result from a query.</td>
50</tr>
51
52<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
53<td WIDTH="15%"><b><a href="NzdlRequest.html">NzdlRequest</a></b></td>
54
55<td>An object that holds CORBA request data ready for by servicing by <tt><a href="NzdlService.html">NzdlService</a></tt>.</td>
56</tr>
57
58<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
59<td WIDTH="15%"><b><a href="NzdlResponse.html">NzdlResponse</a></b></td>
60
61<td>An object that holds data from a response after a <tt><a href="NzdlRequest.html">NzdlRequest</a></tt>
62has been serviced by <tt><a href="NzdlService.html">NzdlService</a></tt>.</td>
63</tr>
64
65<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
66<td WIDTH="15%"><b><a href="NzdlResultSet.html">NzdlResultSet</a></b></td>
67
68<td>An object that holds results extracted from a response by <tt><a href="NzdlResponse.html#getResultSet()">NzdlResponse.getResultSet()</a></tt>.</td>
69</tr>
70
71<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
72<td WIDTH="15%"><b><a href="NzdlServiceClient.html">NzdlServiceClient</a></b></td>
73
74<td>Used to implement the <tt><a href="NzdlService.html">NzdlService</a></tt>
75object.</td>
76</tr>
77
78<tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
79<td WIDTH="15%"><b><a href="NzdlServiceServer.html">NzdlServiceServer</a></b></td>
80
81<td>SimpleServer Based on algorithms in ...</td>
82</tr>
83</table>
84
85<p><a NAME="package_description"></a><!-- -->
86<h2>
87Package org.nzdl.gsdl.service Description</h2>
88Provides services for java client-side communication to a Greenstone Digital
89Library via CORBA.
90<br>&nbsp;
91<h2>
92Further Requirements</h2>
93
94<ul>
95<li>
96Sun Java 2 version 1.3 (or later)</li>
97
98<li>
99Corbaserver, a server-side application for communicating to a Greenstone
100Digital Library.</li>
101</ul>
102
103<h2>
104Java Interface Data Flows</h2>
105
106<center><img SRC="nzdl-service-package.png" ALT="NZDL Data Flow Diagram" height=280 width=637></center>
107
108<p><br>
109<h2>
110A Typical Query</h2>
111From a users perspective, a typical query may work&nbsp; as follows:
112<ul>
113<li>
114&nbsp;Create instances of the necessary NZDL Java-Client objects:</li>
115
116<ul>
117<li>
118&nbsp; a <b>NzdlQuery</b> object</li>
119
120<li>
121&nbsp; a <b>NzdlRequest </b>object using your <b>NzdlQuery</b> object</li>
122
123<li>
124&nbsp; a <b>NzdlResponse</b> object that will eventually hold response
125data</li>
126
127<li>
128&nbsp; a <b>NzdlService</b> object to service CORBA interface requests
129to a Greenstone collection</li>
130</ul>
131
132<li>
133Use the <b>NzdlService</b> object (with collection name and <b>NzdlRequest
134</b>object)
135to query the CORBA interface and place the reply into the <b>NzdlResponse</b>
136object.</li>
137
138<li>
139Create an instance of the <b>NzdlResultSet</b> object. Use <b>NzdlResponse.getResultSet()
140</b>to
141extract response data into the <b>NzdlResultSet</b> object.</li>
142
143<li>
144Use the <b>NzdlResultSet</b> methods to view data such as document IDs</li>
145
146<br>Get documents using <b>NzdlService.getDocument()</b></ul>
147<b></b>
148<h1>
149Sample Code</h1>
150<tt>/**</tt>
151<br><tt>* TrivialDemo.java.</tt>
152<br><tt>* A very simple application that:</tt>
153<br><tt>* - reads an Interoperable Object Reference (IOR) from a file;</tt>
154<br><tt>* - lists all available collections;</tt>
155<br><tt>* - searches "demo" collection for "snail farming";</tt>
156<br><tt>* - prints the number of hits;</tt>
157<br><tt>* - lists first 10 titles found;</tt>
158<br><tt>* - displays the unformatted text of first document found.</tt>
159<br><tt>*/</tt>
160<br><tt>import java.io.*;</tt>
161<br><tt>import java.util.*;</tt>
162<br><tt>import java.lang.*;</tt>
163<br><tt>import org.nzdl.gsdl.service.*; //the java-client stuff</tt>
164<p><tt>public class TrivialDemo {</tt>
165<br><tt>&nbsp; public static void main( String [] args )</tt>
166<br><tt>&nbsp; {</tt>
167<br><tt>&nbsp;&nbsp;&nbsp; String myIorFile = "/tmp/localcorba.objid";</tt>
168<br><tt>&nbsp;&nbsp;&nbsp; String myQueryString = "snail farming";</tt>
169<br><tt>&nbsp;&nbsp;&nbsp; String myCollection = "demo";</tt>
170<p><tt>&nbsp;&nbsp;&nbsp; // Use NzdlService to create corba connection</tt>
171<br><tt>&nbsp;&nbsp;&nbsp; NzdlService myService = new NzdlServiceClient</tt>
172<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
173( null, null, getIor(myIorFile) );</tt>
174<p><tt>&nbsp;&nbsp;&nbsp; // Use getCollectionSet to obtain List of Collections</tt>
175<br><tt>&nbsp;&nbsp;&nbsp; Set myCollections = myService.getCollectionSet();</tt>
176<p><tt>&nbsp;&nbsp;&nbsp; //Display List of Collections</tt>
177<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe available collections:");</tt>
178<p><tt>&nbsp;&nbsp;&nbsp; for (Iterator i = myCollections.iterator(); i.hasNext();
179)</tt>
180<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
181<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String collName = (String)
182i.next();</tt>
183<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("&nbsp;
184"+ collName);</tt>
185<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
186<p><tt>&nbsp;&nbsp;&nbsp; // Find The Number of documents in my collection</tt>
187<br><tt>&nbsp;&nbsp;&nbsp; NzdlCollectionInfo myInfo = myService.getCollectionInfo(myCollection);</tt>
188<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nNum Of Collection docs
189= "+myInfo.getNumOfDocs());</tt>
190<br><tt>&nbsp;</tt>
191<br><tt>&nbsp;&nbsp;&nbsp; // Create query object</tt>
192<br><tt>&nbsp;&nbsp;&nbsp; NzdlQuery query = new NzdlQuery( myQueryString
193);</tt><tt></tt>
194<p><tt>&nbsp;&nbsp;&nbsp; // Create request object</tt>
195<br><tt>&nbsp;&nbsp;&nbsp; NzdlRequest request = new NzdlRequest( query
196);</tt><tt></tt>
197<p><tt>&nbsp;&nbsp;&nbsp; // create response object</tt>
198<br><tt>&nbsp;&nbsp;&nbsp; NzdlResponse response = new NzdlResponse( );</tt>
199<br>&nbsp;
200<br><tt>&nbsp;&nbsp;&nbsp; // use service to get response from request
201to myCollection</tt>
202<br><tt>&nbsp;&nbsp;&nbsp; myService.service( myCollection, request, response
203);</tt>
204<p><tt>&nbsp;&nbsp;&nbsp; // use getResultSet to get results from response</tt>
205<br><tt>&nbsp;&nbsp;&nbsp; NzdlResultSet results = response.getResultSet();</tt><tt></tt>
206<p><tt>&nbsp;&nbsp;&nbsp; // getNumOfDocs</tt>
207<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nNumber of hits = "+results.getNumOfDocs());</tt><tt></tt>
208<p><tt>&nbsp;&nbsp;&nbsp; // Use getDocumentIDs to build list of titles
209(defaults: 1 - 10)</tt>
210<br><tt>&nbsp;&nbsp;&nbsp; List docIDs = results.getDocumentIDs();</tt>
211<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe titles:");</tt>
212<br><tt>&nbsp;&nbsp;&nbsp; for (ListIterator i = docIDs.listIterator();
213i.hasNext(); )</tt>
214<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
215<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set metaData</tt>
216<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = myService.getMetaData(
217myCollection,(String)i.next(),"Title");</tt>
218<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterator j = metaData.iterator();</tt>
219<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(j.next());
220//print title metadata</tt>
221<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
222<br><tt>&nbsp;&nbsp;&nbsp; System.out.println("\nThe first document returned
223was:");</tt>
224<p><tt>&nbsp;&nbsp;&nbsp; // Print first document returned</tt>
225<br><tt>&nbsp;&nbsp;&nbsp; String myDoc</tt>
226<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = myService.getDocument(myCollection,(String)docIDs.get(0));</tt>
227<br><tt>&nbsp;&nbsp;&nbsp; System.out.println(myDoc);</tt>
228<p><tt>&nbsp;&nbsp;&nbsp; } // end of main</tt>
229<br>&nbsp;
230<p><tt>&nbsp;&nbsp;&nbsp; // Read the IOR from a file</tt>
231<br><tt>&nbsp;&nbsp;&nbsp; static private String getIor(String sourceOfID)
232{</tt>
233<br><tt>&nbsp;&nbsp;&nbsp; String ior = null;</tt>
234<br><tt>&nbsp;&nbsp;&nbsp; try</tt>
235<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
236<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BufferedReader input</tt>
237<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
238= new BufferedReader(new FileReader(sourceOfID));</tt>
239<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ior = input.readLine();</tt>
240<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
241<br><tt>&nbsp;&nbsp;&nbsp; catch (java.io.IOException e)</tt>
242<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
243<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Error
244reading IOR key:\n" + e);</tt>
245<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.exit(1);</tt>
246<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
247<br><tt>&nbsp;&nbsp;&nbsp; return ior;</tt>
248<br><tt>&nbsp; }&nbsp; //end of getIors</tt><tt></tt>
249<p><tt>} // end of demo class</tt>
250<br>&nbsp;
251</body>
252</html>
Note: See TracBrowser for help on using the repository browser.