<%--
openisis - an open implementation of the ISIS database
Version 0.8.x (microversion see file Version)
Copyright (C) 2001-2002 by Erik Grziwotz, erik@openisis.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
This software is dedicated to the memory of Eckart Dietrich.
This software is inspired by (but contains no code of) the iAPI
Copyright (C) 2000 by Robert Janusz, rj@jezuici.krakow.pl.
See iAPI.txt for what it contains.
EOH
--%><%@page
import="org.openisis.*,java.io.IOException,java.util.*,java.net.URLEncoder"
contentType="text/html; charset=iso-8859-1"
%><%!
static final String ID = "$Id: idm.jsp,v 1.4 2002/12/13 21:30:27 kripke Exp $";
static final String EMPTY = "";
static Db db;
static String dberr = EMPTY;
static String me = "idm";
static {
try {
String[] args = new String[] { "-v", "info", "-encoding", "Cp850" };
db = Db.open( "/var/db/idm/doku", args );
} catch (IOException e) {
e.printStackTrace();
dberr = e.toString();
}
};
static String NV ( String x ) { return null==x ? EMPTY : x; }
static int ROWS = 10; // number of rows to show at once
static int TERMS = 50; // number of terms to show at once
static int[] tag = {
100, 101, 200, 201,
301, 302, 430, 435,
28, 450, 800, 18
};
static String[] t = {
"Autor(en)", "author", // 100
"weitere Personen", "other contributors", // 101
"Körperschaft als Hrsg.", "corporate body as editor", // 200
"weitere Körperschaften", "other corporate bodies", // 201
"Titel ohne Autorennennung", "title (without indiv. author)", // 301
"Titel mit Autor", "title (with author)", // 302
"Erscheinungsvermerk", "publisher: name and place", // 430
"Erscheinungsjahr", "year of publication", // 435
"Erscheinungsland", "country of publication", // 28
"Ges.Titel/Ser.Titel/Bandnr.", "series title", // 450
"Schlagworte", "keywords", // 800
"Dokument Nr.", "no of document", // 18
// unused fields:
"Universitätseinrichtung (10):", EMPTY,
"Projekt (12):", EMPTY,
"Erfassungsdatum (16):", EMPTY,
"Dokumententyp (22):", EMPTY,
"Physikalische Form (24):", EMPTY,
"Sprache des Dokumentes (26):", EMPTY,
"Physische Form (440):", EMPTY,
"Quelle (Zeitschrift) (480):", EMPTY,
"Quelle (Monographie) (490):", EMPTY,
"ISBN (600):", EMPTY,
"Abstract (900):", EMPTY,
EMPTY, EMPTY,
EMPTY, EMPTY,
// 50: other texts
"Dokumentations-Datenbank des IDM der Universität Bielefeld",
"documentation database of the IDM at the university of Bielefeld",
"Suchen", "search",
"English", "Deutsch", //54
"?", "?",
"weiter", "more",
"allen Feldern", "all fields", //60
// the ops
"und","and",
"oder","or",
"ohne","without",
"zurücksetzen","reset",
"Name","Surname",//70
"Vorname","Given name",
"Institut","Institution",
"Strasse","Street",
"Ort","City",
"Land","Country", // 80
"Postleitzahl","Zip code",
"Bestellen", "order",
"Abschicken", "Submit",
"Einträge", "rows",
"bis", "to", // 90
"von", "of",
"für", "for",
"Indexeinträge beginnend mit", "terms starting with ",
"neue Suche", "new Query",
// 100: hilfe
"<h4>Willkommen bei der Dokumentations-Datenbank des\n"
+" IDM der Universität Bielefeld</h4>\n"
+" Sie können bis zu drei Suchbegriffe verknüpfen.\n"
+" Jeder Suchbegriff kann auf ein Feld eingeschränkt werden.<br>\n"
+" Die ?-Funktion zeigt Ihnen alle Suchbegriffe,\n"
+" die mit dem Feldinhalt beginnen, ggf. auf mehreren Seiten.\n"
+" Diese Werte können per Klick übernommen werden.<br><br>\n"
+" Mit 'Suchen' wird die Anfrage ausgelöst.\n"
+" Es werden jeweils "+ROWS+" Sätze angezeigt.<br><br>\n"
+" Kopien von Titeln können gegen Kostenerstattung bestellt werden.<br>\n"
+" <h4>Suchtipps</h4>\n"
+" Für Prefixsuche beenden Sie den Begriff mit * oder $.<br>\n"
+" Die Suche wird auf jeweils 1000 Treffer eingeschränkt.\n"
+" Bei sehr häufigen Suchbegriffen, etwa 'a$', gibt es in jedem Satz\n"
+" mehrere Treffer, sodass weniger als 1000 Sätze gefunden werden.<br>\n"
+" \n"
+" Eine engere Suche, etwa durch Einschränkung auf ein Feld,\n"
+" kann in einem solchen Fall u.U. mehr Sätze finden!<br>\n"
+" Verwenden Sie bei mehreren Begriffen den präzisesten zuerst.<br>\n"
+" \n"
+" <h4>Cookies</h4>\n"
+" Die Funktion ist stark beeinträchtigt,\n"
+" falls Sie das Session-Cookie ablehnen.<br>\n"
+" Ein Session-Cookie wird nicht auf Ihrer Festplatte gespeichert,\n"
+" sondern verschwindet beim Schließen des Browsers.\n"
+" \n"
,
// 101: help
"<h4>welcome to the documentation database of the"
+" IDM at the university of Bielefeld</h4>"
+" Up to three search terms may be combined.\n"
+" Each term can be restricted to a specific database field.<br>\n"
+" Use the ? beneath a field to display all entries in the index\n"
+" starting with the currently entered term.\n"
+" Click them for use in your query.<br><br>\n"
+" The 'search' button starts the query.\n"
+" Up to "+ROWS+" records are displayed at once.<br><br>\n"
+" You can order copies of each article for a nominal fee.<br>\n"
+" <h4>search tips</h4>\n"
+" Use a trailing * or $ to search by prefix.<br>\n"
+" The query will be restricted to 1000 hits.\n"
+" Very frequent terms like 'a$' will have several hits within\n"
+" each record, giving less than 1000 records total.<br>\n"
+" Restricting the query, e.g. by choosing a database field,\n"
+" may thus find more records!<br>\n"
+" When combining multiple terms, use the most specific one first\n"
+" for best results.<br>\n"
+" \n"
+" <h4>Cookies</h4>\n"
+" This page will not work properly,\n"
+" if you do not accept the session cookie.<br>\n"
+" This is not stored on your hard disc,\n"
+" but deleted after you quit your browser.\n"
,
"entfernen", "remove",
"E-Mail", "e mail",
"Telefon", "phone",
"bitte füllen Sie die markierten Felder aus",
"please fill in all marked fields",
// 110
"Ihre Bestellung wurde abgeschickt. Vielen Dank",
"Your order has been submitted. Thank you",
"Ihre Bestellung konnte leider nicht abgeschickt werden."
+" Bitte versuchen Sie es später",
"Your order could not be submitted. Please try again later",
};
static final String[] ORDER = {
"Xlastname", "firstname", "institution", "Xstreet",
"Xcity", "country", "Xzip", "mail", "phone",
};
static final int[] ORDERT = { 70,72,74,76, 78,80,82,104,106 };
// check button value independet of language used
static boolean chkbutton ( int n, String param ) {
return t[n].equals( param ) || t[n+1].equals( param );
}
static int chkint ( int min, int max, int def, String param ) {
if ( null != param ) try {
int j = Integer.parseInt(param);
if ( min <= j && j <= max )
return j;
} catch (Exception e) {
}
return def;
}
static final int OP_AND = 0;
static final int OP_OR = 1;
static final int OP_NOT = 2;
static final char[] OP = { '*', '+', '^' };
static final String ORDERMAIL = "idmdoku@openisis.org";
static final String[] MAILHEADERS = {
Mail.TO, ORDERMAIL,
Mail.FROM, "Online-Katalog <server@openisis.org>",
Mail.SUBJECT, "online Bestellung",
};
static final int LINES = 3;
static class Ses {
int l; // lang, 0 or 1
int off = 0;
int rows = ROWS;
int view; // last seen view
int idx; // field to save index into
int msec; //
String qry;
int[] set;
int len;
// form content:
String[] t = new String[LINES];
String[] o = new String[ORDER.length]; // order data
int[] f = new int[LINES]; // 0 or 1+index of selected tag
int[] op = new int[LINES];
Iterator i;
String term = EMPTY;
ArrayList orders;
public Ses () {
for ( int i=0; i<LINES; i++ )
t[i] = EMPTY;
}
public String mkqry ()
{
StringBuffer q = new StringBuffer();
boolean had = false;
for ( int i=0; i<LINES; i++ ) {
String v = t[i];
int l = v.length();
if ( 0 == l )
continue;
if ( had )
q.append(' ').append(OP[op[i]]).append(' ');
had = true;
boolean blank = 0 <= v.indexOf(' ');
if ( blank )
q.append('"');
if ( '*' == v.charAt(l-1) )
q.append( v.substring(0,l-1) ).append('$');
else
q.append( v );
if ( blank )
q.append('"');
if ( 0 < f[i] && f[i] <= tag.length )
q.append('/').append(tag[f[i]-1]);
}
return qry = q.toString();
} // mkqry
};
// tasks: what to do
static final int DO_HELP = 0; // default: display help
static final int DO_QUERY = 1; // new search
static final int DO_QUERYN = 2; // next results
static final int DO_INDEX = 3; // display index
static final int DO_INDEXN = 4; // next index terms
static final int DO_ORDER = 5; // display order form
static final int DO_ORDERS = 6; // submit order form
static final int DO_LANG = 7; // toggle language
static final int DO_BLANK = 8; // empty search
// views: what to display
static final int VW_HELP = 0; // default: display help
static final int VW_QUERY = 1; // query results
static final int VW_INDEX = 2; // index terms
static final int VW_ORDER = 3; // order form
%><%
Ses s;
try {
s = (Ses) session.getAttribute( me );
} catch ( Exception e ) { s = null; }
if ( null == s )
session.setAttribute( me, s = new Ses() );
int task = DO_HELP;
String order = null;
// figure out, what to do
String wants = request.getParameter( "do" );
if ( chkbutton( 52, wants ) )
task = DO_QUERY;
else if ( chkbutton( 54, wants ) )
task = DO_LANG;
else if ( "order".equals( wants ) )
task = DO_ORDER;
else if ( chkbutton( 86, wants ) )
task = DO_ORDERS;
else if ( "more".equals( wants ) )
task = DO_INDEXN;
else if ( "new".equals( wants ) )
task = DO_BLANK;
else if ( null != request.getParameter( "off" ) )
task = DO_QUERYN;
else // check "index" buttons i0, i1 ...
for ( int i=0; i<LINES; i++ )
if ( chkbutton( 56, request.getParameter("i"+i) ) ) {
task = DO_INDEX;
s.idx = i;
break;
}
// save common form data
for ( int i=0; i<LINES; i++ ) {
String p;
s.f[i] = chkint( 0, tag.length, s.f[i], request.getParameter( "f"+i ) );
s.op[i] = chkint( 0, OP.length-1, s.op[i], request.getParameter( "op"+i ) );
if ( null != (p = request.getParameter( "t"+i )) )
s.t[i] = p.trim();
if ( DO_HELP == task && chkbutton( 56, request.getParameter("i"+i) ) ) {
task = DO_INDEX;
s.idx = i;
}
}
s.rows = chkint( 1, 5*ROWS, s.rows, request.getParameter( "rows" ) );
s.off = chkint( 0, s.len-1, s.off, request.getParameter( "off" ) );
for ( int i=0; i<ORDER.length; i++ ) {
String v = request.getParameter( ORDER[i] );
if ( null != v )
s.o[i] = v;
}
switch ( task ) {
case DO_BLANK:
for ( int i=0; i<LINES; i++ ) {
s.f[i] = s.op[i] = 0;
s.t[i] = EMPTY;
}
s.len = 0;
s.i = null;
s.set = null;
case DO_HELP:
s.view = VW_HELP;
break;
case DO_QUERY:
long then = System.currentTimeMillis();
s.set = db.search( s.mkqry(), Db.QRY_SIMPLE );
long now = System.currentTimeMillis();
s.len = null == s.set ? 0 : s.set.length;
s.off = 0;
s.msec = (int)(now - then);
case DO_QUERYN:
s.view = VW_QUERY;
break;
case DO_INDEX:
String term = s.t[ s.idx ];
/*
if ( 0 == term.length() ) {
s.view = VW_HELP;
break;
}
*/
if ( term.endsWith("*") || term.endsWith("$") )
term=term.substring(0,term.length()-1);
s.i = db.terms( s.term = term );
case DO_INDEXN:
s.view = VW_INDEX;
break;
case DO_LANG:
s.l = 1 - s.l; // don't change view
break;
case DO_ORDER:
String id = request.getParameter("id");
if ( null != id ) {
if ( null == s.orders )
s.orders = new ArrayList();
boolean isnew = true;
for ( int i=0; i<s.orders.size(); i++ ) {
String[] o = (String[])s.orders.get(i);
if ( id.equals( o[0] ) ) {
isnew = false;
break;
}
}
if ( isnew )
s.orders.add( new String[] {
id, NV(request.getParameter("ti")) } );
}
if ( null != s.orders ) {
int sz = s.orders.size()-1;
int rm = chkint( 0, sz, -1, request.getParameter("rm") );
if ( 0 <= rm ) {
s.orders.remove( rm );
if ( 0 == sz )
s.orders = null;
}
}
if ( null == s.orders )
task = DO_HELP;
break;
case DO_ORDERS:
if ( null == s.orders ) {
task = DO_HELP;
break;
}
StringBuffer o = new StringBuffer();
int i = 0;
for ( ; i<ORDER.length; i++ ) {
String v = s.o[i];
if ( null == v )
v = EMPTY;
if ( 0 == v.length() && 'X' == ORDER[i].charAt(0) ) {
order = t[108+s.l]; // required field missing
task = DO_ORDER;
break;
}
o.append( t[ORDERT[i]] ).append( ": " ).append( v ).append( '\n' );
}
if ( ORDER.length == i ) { // survived
o.append( "\nbestellt:\n\n" );
for ( i=0; i<s.orders.size(); i++ ) {
String[] p = (String[])s.orders.get(i);
o.append( p[0] ).append( ": " ).append( p[1] ).append( '\n' );
}
try {
(new Mail.Smtp( ORDERMAIL )).put(
Mail.message( MAILHEADERS, o.toString() )
);
order = o.append("\n\n").append(t[110+s.l]).toString();
s.orders = null;
} catch (Exception e) {
order = o.append("\n\n")
.append( "<h2>" )
.append(t[112+s.l])
.append( "</h2>\n<!--" )
.append( e.getMessage() )
.append( "-->\n" )
.toString();
task = DO_ORDER;
}
}
s.view = VW_ORDER;
}
int maxrow = s.off + s.rows;
if ( maxrow >= s.len )
maxrow = s.len;
%><html>
<head>
<title><%=t[50+s.l]%></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragmas" content="no-cache">
<meta http-equiv="Robots" content="index,nofollow">
<link href="http://purl.org/dc" rel="schema.DC">
<meta name="DC.Title" content="IDM - documentation database">
<meta name="DC.Subject" content="">
<meta name="DC.Description" content="">
<meta name="DC.Creator" content="idm openisis">
<meta name="DC.Publisher" content="University of Bielefeld">
<meta name="DC.Date" content="2002-11-30" scheme="W3CDTF">
<meta name="DC.Type" content="Text" scheme="DCMIType">
<meta name="DC.Format" content="text/html">
<meta name="DC.Identifier" content="http://openisis.org/openisis/idm">
<link href="http://www.uni-bielefeld.de/icons/uni-logo-icon-16.png" type="image/png" rel="icon">
<link href="http://www.uni-bielefeld.de/css/unistandard.css" type="text/css" rel="stylesheet">
<!--
<style TYPE="text/css">
td {
font-family: Verdana, Arial, Helvetica, Geneva, sans-serif;
font-size: 12px
}
</style>
-->
</head>
<body bgcolor="#ffffff">
<!-- heading table: useless but nice ;) -->
<table width="100%" cols="1" cellpadding="0" border="0" cellspacing="0">
<tr>
<td align="center">
<a href="http://www.uni-bielefeld.de/idm/service/dokument.html">
<img src="/img/idm/service.gif" width="472" height="34"
alt="service" border="0">
</a>
<a href="http://www.uni-bielefeld.de/">
<img src="/img/idm/siegel.gif" width="27" height="27"
vspace="10" hspace="0"
alt="Universität Bielefeld" border="0">
</a>
</td>
</tr>
<tr>
<td align="center">
<img src="/img/idm/1pixgrau.gif" width="575"
vspace="0" hspace="0" height="3"
alt="=================================================">
<br></td>
</tr>
<tr>
<td width="470" height="25" bgcolor="#9DCCE6">
<a href="http://www.uni-bielefeld.de/idm/service/dokument.html">
<b> <%=t[50+s.l]%></b>
</a>
</td>
</tr>
</table>
<!-- form table: either query or order form -->
<form action="<%=me%>" method="GET">
<%
if ( DO_ORDER == task ) {
%>
<table width="575" cellpadding="0" border="0" cellspacing="0">
<%
for ( int i=0; i<ORDER.length; i++ ) {
String lbl = t[ORDERT[i]+s.l], nm = ORDER[i];
String req = 'X' == nm.charAt(0) ? "*" : "";
String v = null == s.o[i] ? "" : Field.html(s.o[i]);
%>
<tr><td><%=lbl%></td>
<td><input name="<%=nm%>" value="<%=v%>" size="40"><%=req%></td><tr>
<%
}
for(int i=0;i<s.orders.size();i++) {
String[] o = (String[])s.orders.get(i);
%>
<tr>
<td><%=Field.html(o[0])%></td>
<td><%=Field.html(o[1])%>
(<a class="intern" href="<%=me%>?do=order&rm=<%=i%>"><%=t[102+s.l]%></a>)
</td>
</tr>
<%
}
%>
<tr>
<td colspan="2" align="center">
<img src="/img/idm/1pixgrau.gif" width="575"
vspace="0" hspace="0" height="1"
alt="-------------------------------------------------">
<br></td>
</tr>
</table>
<input type="submit" name="do" value="<%=t[86+s.l]%>">
<%
} else {
%>
<table width="100%" cols="3" cellpadding="0" border="0" cellspacing="0">
<%
for ( int l=0; l<LINES; l++ ) {
%>
<tr valign="top" height="33">
<td>
<%
if ( 0 < l ) for ( int o=0; o<OP.length; o++ ) {
String checked = o == s.op[l] ? " checked" : "";
%>
<input type="radio" name="op<%=l%>"<%=checked%> value="<%=o%>"/>
<%=t[62+2*o+s.l] %>
<%
} // for ops
%>
</td>
<td>
<input type="text" name="t<%=l%>" size="24"
value="<%=Field.html(s.t[l])%>"/>
<input type="submit" name="i<%=l%>"
value="<%=t[56+s.l]%>"/>
</td>
<td align="left">
in <select name="f<%=l%>" size=1>
<option value="0"<%=(0==s.f[l])?" selected":""%>
><%=t[60+s.l]%></option>
<%
for(int i=0; i<tag.length;i++) {
%>
<option value="<%=i+1%>"<%=(i+1==s.f[l])?" selected":""%>
><%=t[2*i+s.l]%></option>
<%
} // for fields
%>
</select>
</td>
</tr>
<%
} // for lines
%>
<tr>
<td colspan="3" align="center" valign="center" height="7">
<img src="/img/idm/1pixgrau.gif" width="575"
vspace="3" hspace="0" height="1"
alt="-------------------------------------------------">
<br></td>
</tr>
</table>
<!-- <%= dberr %> -->
<input type="submit" name="do" value="<%=t[52+s.l]%>"/>
<input type="reset" name="reset" value="<%=t[68+s.l] %>"/>
<%--
<input type="text" name="rows" size="2" value="<%=s.rows%>"/> rows at once
--%>
<input type="submit" name="do" value="<%=t[54+s.l]%>"/>
<%
} // query form
if ( VW_QUERY == s.view && 0 < s.len ) {
if ( 0 < s.off ) {
int boff = s.off-s.rows;
if ( boff < 0 ) boff = 0;
%>
<a class="intern" href="<%=me%>?off=<%=boff%>">
<b><<</b><%=t[88+s.l]%> <%=boff+1%>
<%=t[90+s.l]%> <%=boff+s.rows%></a>
<%
}
if ( maxrow < s.len ) {
int nmax = maxrow+s.rows;
if ( nmax > s.len )
nmax = s.len;
%>
<a class="intern" href="<%=me%>?off=<%=maxrow%>">
<%=t[88+s.l]%> <%=maxrow+1%>
<%=t[90+s.l]%> <%=nmax%><b>>></b></a>
<%
}
}
%>
<a class="intern" href="<%=me%>?do=new"><%=t[98+s.l]%></a>
</form>
<hr>
<!-- switch view: help, query, index or order -->
<%
switch ( s.view ) {
default:
case VW_HELP:
%>
<%=t[100+s.l]%>
<%
break;
case VW_QUERY:
if ( 0 == s.len ) {
%>
0 <%=t[88+s.l]%> <%=t[94+s.l]%> '<%=s.qry%>'
<%
} else {
%>
<h4> <%=t[88+s.l]%> <%=s.off+1%>
<%=t[90+s.l]%> <%=maxrow%>
<%=t[92+s.l]%> <%=s.len%>
<%=t[94+s.l]%> '<%=s.qry%>' </h4>
<%-- start output --%>
<table cols="2" width="100%">
<%
for ( int i=s.off; i<maxrow; i++ ) {
Rec r = db.readRow( s.set[i] );
if ( null == r ) continue;
%>
<tr><td colspan="2"><hr></td></tr>
<%
for ( int j=0; j<tag.length; j++ ) {
out.println( r.v(
"<tr><td valign=\"top\" width=\"150\">"+t[2*j+s.l]
+"</td><td valign=\"top\">",
null, // cond,repeated prefix
tag[j], Db.MDL|Db.PS|Db.HTI, 0, 0, // tag and mode, len, off
";<br>","</td></tr>")
);
}
String ti = r.v("",301,Db.MDL, 0, 0,"");
if ( null == ti || 0 == ti.length() )
ti = r.v("",302,Db.MDL, 0, 0,"");
String link = me+"?do=order"
+ "&id=" + URLEncoder.encode( r.v("",18,Db.MDL, 0, 0,"") )
+ "&ti=" + URLEncoder.encode( ti );
%>
<tr><td colspan="2" align="right">
<a class="intern" href="<%=link%>"><b>>></b> <%=t[84+s.l]%></a>
</td></tr>
<%
}
%>
</table>
<%
}
break; // case VW_QUERY
case VW_INDEX:
%>
<h4><%=t[96+s.l]%> '<%=Field.html(s.term)%>'</h4>
<%
if ( null == s.i || ! s.i.hasNext() ) {
} else {
int i = TERMS;
while ( 0 < i-- && s.i.hasNext() ) {
String ix = (String)s.i.next();
if ( 0 == ix.length() ) continue;
String u = URLEncoder.encode( ix );
%>
<a class="intern" href="<%=me%>?t<%=s.idx%>=<%=u%>"><%=Field.html(ix)%></a><br>
<%
}
if ( 0 > i ) { // more
%>
<p align = "right">
<a class="intern" href="<%=me%>?do=more"><b>>></b> <%=t[58+s.l]%></a><br>
</p>
<%
} else
s.i = null;
}
break; // case VW_INDEX
case VW_ORDER:
%>
<pre>
<%= order %>
</pre>
<%
} // switch
%>
<!-- <%= ID %> -->
</body></html>