2 openisis - an open implementation of the ISIS database
3 Version 0.8.x (microversion see file Version)
4 Copyright (C) 2001-2002 by Erik Grziwotz, erik@openisis.org
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 This software is dedicated to the memory of Eckart Dietrich.
22 This software is inspired by (but contains no code of) the iAPI
23 Copyright (C) 2000 by Robert Janusz, rj@jezuici.krakow.pl.
24 See iAPI.txt for what it contains.
27 import="org.openisis.*,java.io.IOException,java.util.*,java.net.URLEncoder"
28 contentType="text/html; charset=iso-8859-1"
30 static final String ID = "$Id: idm.jsp,v 1.4 2002/12/13 21:30:27 kripke Exp $";
31 static final String EMPTY = "";
33 static String dberr = EMPTY;
34 static String me = "idm";
37 String[] args = new String[] { "-v", "info", "-encoding", "Cp850" };
38 db = Db.open( "/var/db/idm/doku", args );
39 } catch (IOException e) {
44 static String NV ( String x ) { return null==x ? EMPTY : x; }
45 static int ROWS = 10; // number of rows to show at once
46 static int TERMS = 50; // number of terms to show at once
53 "Autor(en)", "author", // 100
54 "weitere Personen", "other contributors", // 101
55 "Körperschaft als Hrsg.", "corporate body as editor", // 200
56 "weitere Körperschaften", "other corporate bodies", // 201
57 "Titel ohne Autorennennung", "title (without indiv. author)", // 301
58 "Titel mit Autor", "title (with author)", // 302
59 "Erscheinungsvermerk", "publisher: name and place", // 430
60 "Erscheinungsjahr", "year of publication", // 435
61 "Erscheinungsland", "country of publication", // 28
62 "Ges.Titel/Ser.Titel/Bandnr.", "series title", // 450
63 "Schlagworte", "keywords", // 800
64 "Dokument Nr.", "no of document", // 18
66 "Universitätseinrichtung (10):", EMPTY,
67 "Projekt (12):", EMPTY,
68 "Erfassungsdatum (16):", EMPTY,
69 "Dokumententyp (22):", EMPTY,
70 "Physikalische Form (24):", EMPTY,
71 "Sprache des Dokumentes (26):", EMPTY,
72 "Physische Form (440):", EMPTY,
73 "Quelle (Zeitschrift) (480):", EMPTY,
74 "Quelle (Monographie) (490):", EMPTY,
76 "Abstract (900):", EMPTY,
80 "Dokumentations-Datenbank des IDM der Universität Bielefeld",
81 "documentation database of the IDM at the university of Bielefeld",
83 "English", "Deutsch", //54
86 "allen Feldern", "all fields", //60
91 "zurücksetzen","reset",
93 "Vorname","Given name",
94 "Institut","Institution",
97 "Land","Country", // 80
98 "Postleitzahl","Zip code",
100 "Abschicken", "Submit",
105 "Indexeinträge beginnend mit", "terms starting with ",
106 "neue Suche", "new Query",
108 "<h4>Willkommen bei der Dokumentations-Datenbank des\n"
109 +" IDM der Universität Bielefeld</h4>\n"
110 +" Sie können bis zu drei Suchbegriffe verknüpfen.\n"
111 +" Jeder Suchbegriff kann auf ein Feld eingeschränkt werden.<br>\n"
112 +" Die ?-Funktion zeigt Ihnen alle Suchbegriffe,\n"
113 +" die mit dem Feldinhalt beginnen, ggf. auf mehreren Seiten.\n"
114 +" Diese Werte können per Klick übernommen werden.<br><br>\n"
115 +" Mit 'Suchen' wird die Anfrage ausgelöst.\n"
116 +" Es werden jeweils "+ROWS+" Sätze angezeigt.<br><br>\n"
117 +" Kopien von Titeln können gegen Kostenerstattung bestellt werden.<br>\n"
118 +" <h4>Suchtipps</h4>\n"
119 +" Für Prefixsuche beenden Sie den Begriff mit * oder $.<br>\n"
120 +" Die Suche wird auf jeweils 1000 Treffer eingeschränkt.\n"
121 +" Bei sehr häufigen Suchbegriffen, etwa 'a$', gibt es in jedem Satz\n"
122 +" mehrere Treffer, sodass weniger als 1000 Sätze gefunden werden.<br>\n"
124 +" Eine engere Suche, etwa durch Einschränkung auf ein Feld,\n"
125 +" kann in einem solchen Fall u.U. mehr Sätze finden!<br>\n"
126 +" Verwenden Sie bei mehreren Begriffen den präzisesten zuerst.<br>\n"
128 +" <h4>Cookies</h4>\n"
129 +" Die Funktion ist stark beeinträchtigt,\n"
130 +" falls Sie das Session-Cookie ablehnen.<br>\n"
131 +" Ein Session-Cookie wird nicht auf Ihrer Festplatte gespeichert,\n"
132 +" sondern verschwindet beim Schließen des Browsers.\n"
136 "<h4>welcome to the documentation database of the"
137 +" IDM at the university of Bielefeld</h4>"
138 +" Up to three search terms may be combined.\n"
139 +" Each term can be restricted to a specific database field.<br>\n"
140 +" Use the ? beneath a field to display all entries in the index\n"
141 +" starting with the currently entered term.\n"
142 +" Click them for use in your query.<br><br>\n"
143 +" The 'search' button starts the query.\n"
144 +" Up to "+ROWS+" records are displayed at once.<br><br>\n"
145 +" You can order copies of each article for a nominal fee.<br>\n"
146 +" <h4>search tips</h4>\n"
147 +" Use a trailing * or $ to search by prefix.<br>\n"
148 +" The query will be restricted to 1000 hits.\n"
149 +" Very frequent terms like 'a$' will have several hits within\n"
150 +" each record, giving less than 1000 records total.<br>\n"
151 +" Restricting the query, e.g. by choosing a database field,\n"
152 +" may thus find more records!<br>\n"
153 +" When combining multiple terms, use the most specific one first\n"
154 +" for best results.<br>\n"
156 +" <h4>Cookies</h4>\n"
157 +" This page will not work properly,\n"
158 +" if you do not accept the session cookie.<br>\n"
159 +" This is not stored on your hard disc,\n"
160 +" but deleted after you quit your browser.\n"
162 "entfernen", "remove",
165 "bitte füllen Sie die markierten Felder aus",
166 "please fill in all marked fields",
168 "Ihre Bestellung wurde abgeschickt. Vielen Dank",
169 "Your order has been submitted. Thank you",
170 "Ihre Bestellung konnte leider nicht abgeschickt werden."
171 +" Bitte versuchen Sie es später",
172 "Your order could not be submitted. Please try again later",
174 static final String[] ORDER = {
175 "Xlastname", "firstname", "institution", "Xstreet",
176 "Xcity", "country", "Xzip", "mail", "phone",
178 static final int[] ORDERT = { 70,72,74,76, 78,80,82,104,106 };
180 // check button value independet of language used
181 static boolean chkbutton ( int n, String param ) {
182 return t[n].equals( param ) || t[n+1].equals( param );
184 static int chkint ( int min, int max, int def, String param ) {
185 if ( null != param ) try {
186 int j = Integer.parseInt(param);
187 if ( min <= j && j <= max )
189 } catch (Exception e) {
194 static final int OP_AND = 0;
195 static final int OP_OR = 1;
196 static final int OP_NOT = 2;
197 static final char[] OP = { '*', '+', '^' };
199 static final String ORDERMAIL = "idmdoku@openisis.org";
200 static final String[] MAILHEADERS = {
202 Mail.FROM, "Online-Katalog <server@openisis.org>",
203 Mail.SUBJECT, "online Bestellung",
206 static final int LINES = 3;
209 int l; // lang, 0 or 1
212 int view; // last seen view
213 int idx; // field to save index into
221 String[] t = new String[LINES];
222 String[] o = new String[ORDER.length]; // order data
223 int[] f = new int[LINES]; // 0 or 1+index of selected tag
224 int[] op = new int[LINES];
231 for ( int i=0; i<LINES; i++ )
235 public String mkqry ()
237 StringBuffer q = new StringBuffer();
239 for ( int i=0; i<LINES; i++ ) {
245 q.append(' ').append(OP[op[i]]).append(' ');
247 boolean blank = 0 <= v.indexOf(' ');
250 if ( '*' == v.charAt(l-1) )
251 q.append( v.substring(0,l-1) ).append('$');
256 if ( 0 < f[i] && f[i] <= tag.length )
257 q.append('/').append(tag[f[i]-1]);
259 return qry = q.toString();
264 static final int DO_HELP = 0; // default: display help
265 static final int DO_QUERY = 1; // new search
266 static final int DO_QUERYN = 2; // next results
267 static final int DO_INDEX = 3; // display index
268 static final int DO_INDEXN = 4; // next index terms
269 static final int DO_ORDER = 5; // display order form
270 static final int DO_ORDERS = 6; // submit order form
271 static final int DO_LANG = 7; // toggle language
272 static final int DO_BLANK = 8; // empty search
274 // views: what to display
275 static final int VW_HELP = 0; // default: display help
276 static final int VW_QUERY = 1; // query results
277 static final int VW_INDEX = 2; // index terms
278 static final int VW_ORDER = 3; // order form
283 s = (Ses) session.getAttribute( me );
284 } catch ( Exception e ) { s = null; }
286 session.setAttribute( me, s = new Ses() );
291 // figure out, what to do
292 String wants = request.getParameter( "do" );
293 if ( chkbutton( 52, wants ) )
295 else if ( chkbutton( 54, wants ) )
297 else if ( "order".equals( wants ) )
299 else if ( chkbutton( 86, wants ) )
301 else if ( "more".equals( wants ) )
303 else if ( "new".equals( wants ) )
305 else if ( null != request.getParameter( "off" ) )
307 else // check "index" buttons i0, i1 ...
308 for ( int i=0; i<LINES; i++ )
309 if ( chkbutton( 56, request.getParameter("i"+i) ) ) {
315 // save common form data
316 for ( int i=0; i<LINES; i++ ) {
318 s.f[i] = chkint( 0, tag.length, s.f[i], request.getParameter( "f"+i ) );
319 s.op[i] = chkint( 0, OP.length-1, s.op[i], request.getParameter( "op"+i ) );
320 if ( null != (p = request.getParameter( "t"+i )) )
322 if ( DO_HELP == task && chkbutton( 56, request.getParameter("i"+i) ) ) {
327 s.rows = chkint( 1, 5*ROWS, s.rows, request.getParameter( "rows" ) );
328 s.off = chkint( 0, s.len-1, s.off, request.getParameter( "off" ) );
329 for ( int i=0; i<ORDER.length; i++ ) {
330 String v = request.getParameter( ORDER[i] );
337 for ( int i=0; i<LINES; i++ ) {
338 s.f[i] = s.op[i] = 0;
348 long then = System.currentTimeMillis();
349 s.set = db.search( s.mkqry(), Db.QRY_SIMPLE );
350 long now = System.currentTimeMillis();
351 s.len = null == s.set ? 0 : s.set.length;
353 s.msec = (int)(now - then);
358 String term = s.t[ s.idx ];
360 if ( 0 == term.length() ) {
365 if ( term.endsWith("*") || term.endsWith("$") )
366 term=term.substring(0,term.length()-1);
367 s.i = db.terms( s.term = term );
372 s.l = 1 - s.l; // don't change view
375 String id = request.getParameter("id");
377 if ( null == s.orders )
378 s.orders = new ArrayList();
379 boolean isnew = true;
380 for ( int i=0; i<s.orders.size(); i++ ) {
381 String[] o = (String[])s.orders.get(i);
382 if ( id.equals( o[0] ) ) {
388 s.orders.add( new String[] {
389 id, NV(request.getParameter("ti")) } );
391 if ( null != s.orders ) {
392 int sz = s.orders.size()-1;
393 int rm = chkint( 0, sz, -1, request.getParameter("rm") );
395 s.orders.remove( rm );
400 if ( null == s.orders )
404 if ( null == s.orders ) {
408 StringBuffer o = new StringBuffer();
410 for ( ; i<ORDER.length; i++ ) {
414 if ( 0 == v.length() && 'X' == ORDER[i].charAt(0) ) {
415 order = t[108+s.l]; // required field missing
419 o.append( t[ORDERT[i]] ).append( ": " ).append( v ).append( '\n' );
421 if ( ORDER.length == i ) { // survived
422 o.append( "\nbestellt:\n\n" );
423 for ( i=0; i<s.orders.size(); i++ ) {
424 String[] p = (String[])s.orders.get(i);
425 o.append( p[0] ).append( ": " ).append( p[1] ).append( '\n' );
428 (new Mail.Smtp( ORDERMAIL )).put(
429 Mail.message( MAILHEADERS, o.toString() )
431 order = o.append("\n\n").append(t[110+s.l]).toString();
433 } catch (Exception e) {
434 order = o.append("\n\n")
437 .append( "</h2>\n<!--" )
438 .append( e.getMessage() )
446 int maxrow = s.off + s.rows;
447 if ( maxrow >= s.len )
452 <title><%=t[50+s.l]%></title>
453 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
454 <meta name="description" content="">
455 <meta http-equiv="Cache-Control" content="no-cache">
456 <meta http-equiv="Pragmas" content="no-cache">
457 <meta http-equiv="Robots" content="index,nofollow">
458 <link href="http://purl.org/dc" rel="schema.DC">
459 <meta name="DC.Title" content="IDM - documentation database">
460 <meta name="DC.Subject" content="">
461 <meta name="DC.Description" content="">
462 <meta name="DC.Creator" content="idm openisis">
463 <meta name="DC.Publisher" content="University of Bielefeld">
464 <meta name="DC.Date" content="2002-11-30" scheme="W3CDTF">
465 <meta name="DC.Type" content="Text" scheme="DCMIType">
466 <meta name="DC.Format" content="text/html">
467 <meta name="DC.Identifier" content="http://openisis.org/openisis/idm">
468 <link href="http://www.uni-bielefeld.de/icons/uni-logo-icon-16.png" type="image/png" rel="icon">
469 <link href="http://www.uni-bielefeld.de/css/unistandard.css" type="text/css" rel="stylesheet">
471 <style TYPE="text/css">
473 font-family: Verdana, Arial, Helvetica, Geneva, sans-serif;
479 <body bgcolor="#ffffff">
480 <!-- heading table: useless but nice ;) -->
481 <table width="100%" cols="1" cellpadding="0" border="0" cellspacing="0">
484 <a href="http://www.uni-bielefeld.de/idm/service/dokument.html">
485 <img src="/img/idm/service.gif" width="472" height="34"
486 alt="service" border="0">
488 <a href="http://www.uni-bielefeld.de/">
489 <img src="/img/idm/siegel.gif" width="27" height="27"
490 vspace="10" hspace="0"
491 alt="Universität Bielefeld" border="0">
497 <img src="/img/idm/1pixgrau.gif" width="575"
498 vspace="0" hspace="0" height="3"
499 alt="=================================================">
503 <td width="470" height="25" bgcolor="#9DCCE6">
504 <a href="http://www.uni-bielefeld.de/idm/service/dokument.html">
505 <b> <%=t[50+s.l]%></b>
511 <!-- form table: either query or order form -->
512 <form action="<%=me%>" method="GET">
514 if ( DO_ORDER == task ) {
516 <table width="575" cellpadding="0" border="0" cellspacing="0">
518 for ( int i=0; i<ORDER.length; i++ ) {
519 String lbl = t[ORDERT[i]+s.l], nm = ORDER[i];
520 String req = 'X' == nm.charAt(0) ? "*" : "";
521 String v = null == s.o[i] ? "" : Field.html(s.o[i]);
523 <tr><td><%=lbl%></td>
524 <td><input name="<%=nm%>" value="<%=v%>" size="40"><%=req%></td><tr>
527 for(int i=0;i<s.orders.size();i++) {
528 String[] o = (String[])s.orders.get(i);
531 <td><%=Field.html(o[0])%></td>
532 <td><%=Field.html(o[1])%>
533 (<a class="intern" href="<%=me%>?do=order&rm=<%=i%>"><%=t[102+s.l]%></a>)
540 <td colspan="2" align="center">
541 <img src="/img/idm/1pixgrau.gif" width="575"
542 vspace="0" hspace="0" height="1"
543 alt="-------------------------------------------------">
547 <input type="submit" name="do" value="<%=t[86+s.l]%>">
551 <table width="100%" cols="3" cellpadding="0" border="0" cellspacing="0">
553 for ( int l=0; l<LINES; l++ ) {
555 <tr valign="top" height="33">
558 if ( 0 < l ) for ( int o=0; o<OP.length; o++ ) {
559 String checked = o == s.op[l] ? " checked" : "";
561 <input type="radio" name="op<%=l%>"<%=checked%> value="<%=o%>"/>
568 <input type="text" name="t<%=l%>" size="24"
569 value="<%=Field.html(s.t[l])%>"/>
570 <input type="submit" name="i<%=l%>"
571 value="<%=t[56+s.l]%>"/>
574 in <select name="f<%=l%>" size=1>
575 <option value="0"<%=(0==s.f[l])?" selected":""%>
576 ><%=t[60+s.l]%></option>
578 for(int i=0; i<tag.length;i++) {
580 <option value="<%=i+1%>"<%=(i+1==s.f[l])?" selected":""%>
581 ><%=t[2*i+s.l]%></option>
593 <td colspan="3" align="center" valign="center" height="7">
594 <img src="/img/idm/1pixgrau.gif" width="575"
595 vspace="3" hspace="0" height="1"
596 alt="-------------------------------------------------">
601 <!-- <%= dberr %> -->
602 <input type="submit" name="do" value="<%=t[52+s.l]%>"/>
603 <input type="reset" name="reset" value="<%=t[68+s.l] %>"/>
605 <input type="text" name="rows" size="2" value="<%=s.rows%>"/> rows at once
607 <input type="submit" name="do" value="<%=t[54+s.l]%>"/>
611 if ( VW_QUERY == s.view && 0 < s.len ) {
613 int boff = s.off-s.rows;
614 if ( boff < 0 ) boff = 0;
616 <a class="intern" href="<%=me%>?off=<%=boff%>">
617 <b><<</b><%=t[88+s.l]%> <%=boff+1%>
618 <%=t[90+s.l]%> <%=boff+s.rows%></a>
621 if ( maxrow < s.len ) {
622 int nmax = maxrow+s.rows;
626 <a class="intern" href="<%=me%>?off=<%=maxrow%>">
627 <%=t[88+s.l]%> <%=maxrow+1%>
628 <%=t[90+s.l]%> <%=nmax%><b>>></b></a>
634 <a class="intern" href="<%=me%>?do=new"><%=t[98+s.l]%></a>
637 <!-- switch view: help, query, index or order -->
649 0 <%=t[88+s.l]%> <%=t[94+s.l]%> '<%=s.qry%>'
653 <h4> <%=t[88+s.l]%> <%=s.off+1%>
654 <%=t[90+s.l]%> <%=maxrow%>
655 <%=t[92+s.l]%> <%=s.len%>
656 <%=t[94+s.l]%> '<%=s.qry%>' </h4>
658 <%-- start output --%>
659 <table cols="2" width="100%">
661 for ( int i=s.off; i<maxrow; i++ ) {
662 Rec r = db.readRow( s.set[i] );
663 if ( null == r ) continue;
665 <tr><td colspan="2"><hr></td></tr>
667 for ( int j=0; j<tag.length; j++ ) {
669 "<tr><td valign=\"top\" width=\"150\">"+t[2*j+s.l]
670 +"</td><td valign=\"top\">",
671 null, // cond,repeated prefix
672 tag[j], Db.MDL|Db.PS|Db.HTI, 0, 0, // tag and mode, len, off
673 ";<br>","</td></tr>")
676 String ti = r.v("",301,Db.MDL, 0, 0,"");
677 if ( null == ti || 0 == ti.length() )
678 ti = r.v("",302,Db.MDL, 0, 0,"");
679 String link = me+"?do=order"
680 + "&id=" + URLEncoder.encode( r.v("",18,Db.MDL, 0, 0,"") )
681 + "&ti=" + URLEncoder.encode( ti );
683 <tr><td colspan="2" align="right">
684 <a class="intern" href="<%=link%>"><b>>></b> <%=t[84+s.l]%></a>
692 break; // case VW_QUERY
695 <h4><%=t[96+s.l]%> '<%=Field.html(s.term)%>'</h4>
697 if ( null == s.i || ! s.i.hasNext() ) {
700 while ( 0 < i-- && s.i.hasNext() ) {
701 String ix = (String)s.i.next();
702 if ( 0 == ix.length() ) continue;
703 String u = URLEncoder.encode( ix );
705 <a class="intern" href="<%=me%>?t<%=s.idx%>=<%=u%>"><%=Field.html(ix)%></a><br>
708 if ( 0 > i ) { // more
711 <a class="intern" href="<%=me%>?do=more"><b>>></b> <%=t[58+s.l]%></a><br>
717 break; // case VW_INDEX