X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=www%2Fz39util.tcl;h=3a2c69482c9a0e243bb1443fa1c46631f31072e6;hb=df7b985601de6c729147a6fd6588adba6f905480;hp=82380f1316a1e7b6fb4c2c0a8cb96fb10b660282;hpb=852b4caac48a2542af95c577dab306db1bda56f1;p=egate.git
diff --git a/www/z39util.tcl b/www/z39util.tcl
index 82380f1..3a2c694 100644
--- a/www/z39util.tcl
+++ b/www/z39util.tcl
@@ -1,5 +1,5 @@
#
-# $Id: z39util.tcl,v 1.6 1995/11/09 15:24:37 adam Exp $
+# $Id: z39util.tcl,v 1.15 1996/01/02 10:52:32 adam Exp $
#
proc saveState {} {
uplevel #0 {
@@ -26,16 +26,29 @@ proc saveState {} {
}
}
-proc search-response {sno} {
+proc search-response {zz} {
global sessionWait
- set status [z39.$sno responseStatus]
+ set status [$zz responseStatus]
if {[lindex $status 0] == "NSD"} {
- z39.$sno nextResultSetPosition 0
+ $zz nextResultSetPosition 0
set code [lindex $status 1]
set msg [lindex $status 2]
set addinfo [lindex $status 3]
- html "
Error NSD$code: $msg: $addinfo
\n"
+ displayError "Diagnostic message" \
+ "$msg: $addinfo
\n(error code $code)"
+ set sessionWait -2
+ } else {
+ set sessionWait 1
+ }
+}
+
+proc scan-response {zz} {
+ global sessionWait
+
+ set status [$zz scanStatus]
+ if {$status == 6} {
+ displayError "Scan fail" ""
set sessionWait -2
} else {
set sessionWait 1
@@ -52,7 +65,7 @@ proc fail-response {} {
set sessionWait -1
}
-proc display-brief {zset no} {
+proc display-brief {zset no tno} {
global env
global setNo
global sessionId
@@ -70,7 +83,7 @@ proc display-brief {zset no} {
if {$type != "DB"} {
return
}
- html "${no} "
+ html "${no}"
set rtype [$zset recordType $no]
if {$rtype == "SUTRS"} {
html [join [$zset getSutrs $no]]
@@ -82,13 +95,13 @@ proc display-brief {zset no} {
set year [lindex [$zset getMarc $no field 260 * c] 0]
} ] } {
html { } $title {} " ${year} "
}
html "
\n"
}
-proc display-raw {zset no} {
+proc display-raw {zset no tno} {
set type [$zset type $no]
if {$type == "SD"} {
set err [lindex [$zset diag $no] 1]
@@ -117,7 +130,7 @@ proc display-raw {zset no} {
set indicator [lindex $line 1]
set fields [lindex $line 2]
set l [string length $indicator]
- html "$tag "
+ html "$tag "
if {$l > 0} {
for {set i 0} {$i < $l} {incr i} {
if {[string index $indicator $i] == " "} {
@@ -127,6 +140,7 @@ proc display-raw {zset no} {
}
}
}
+ html ""
foreach field $fields {
set id [lindex $field 0]
set data [lindex $field 1]
@@ -154,7 +168,7 @@ proc put-marc-contents {cc} {
}
html $cc
if {$ref != ""} {
- html {">} $urltype { reference}
+ html {">} $cc {}
}
}
@@ -224,7 +238,7 @@ proc dl-marc-field-rec {zset no tag lead start stop startid sep} {
}
}
-proc display-full {zset no} {
+proc display-full {zset no tno} {
set type [$zset type $no]
if {$type == "SD"} {
set err [lindex [$zset diag $no] 1]
@@ -269,14 +283,45 @@ proc display-full {zset no} {
dl-marc-field $zset $no 260 * "Publisher" {} " "
dl-marc-field $zset $no 300 * "Physical Description" {} " "
- dl-marc-field $zset $no 500 a "Notes" {} ", "
+ dl-marc-field-rec $zset $no 500 "Notes" "" "
\n" "a" ", "
dl-marc-field-rec $zset $no 510 "References" "" "
\n" "a" ", "
+ dl-marc-field-rec $zset $no 511 "Participant note" "" "
\n" "a" ", "
+
+ dl-marc-field $zset $no 513 a "Report type" {} ", "
+ dl-marc-field $zset $no 513 b "Period covered" {} ", "
+ dl-marc-field-rec $zset $no 515 "Numbering notes" "" "
\n" "a" ", "
+ dl-marc-field-rec $zset $no 516 "Data notes" "" "
\n" "a" ", "
+ dl-marc-field-rec $zset $no 518 "Date/time notes" "" "
\n" "a" ", "
+
dl-marc-field $zset $no 350 a "Price" {} ", "
dl-marc-field $zset $no 362 a "Dates of publication" {} ", "
dl-marc-field $zset $no 850 a "Holdings" {} ", "
+ dl-marc-field-rec $zset $no 270 "Contact name" "" "
\n" p ", "
+ if {0} {
+ set n [dl-marc-field $zset $no 270 p "Contact name" {} ", "]
+ if {$n > 0} {
+ html "\n\n"
+
+ if {0} {
+ dl-marc-field $zset $no 270 a "Street" {} ", "
+ dl-marc-field $zset $no 270 b "City" {} ", "
+ dl-marc-field $zset $no 270 c "State" {} ", "
+ dl-marc-field $zset $no 270 e "Zip code" {} ", "
+ dl-marc-field $zset $no 270 d "Country" {} ", "
+ dl-marc-field $zset $no 270 m "Network address" {} ", "
+ dl-marc-field $zset $no 301 a "Service hours" {} ", "
+ dl-marc-field $zset $no 270 k "Phone" {} ", "
+ dl-marc-field $zset $no 270 l "Fax" {} ", "
+ } else {
+ dl-marc-field $zset $no 270 {[abcedmakl]} "Address" {} "
\n"
+ }
+
+ html "\n
\n"
+ }
+ }
dl-marc-field $zset $no 010 a "LC control number" {} ", "
dl-marc-field $zset $no 010 b "NUCMC control number" {} ", "
dl-marc-field $zset $no 020 a "ISBN" {} ", "
@@ -286,34 +331,61 @@ proc display-full {zset no} {
if {"x$url" != "x"} {
html "URL\n"
if {"x$sp" == "x"} {
- set sp reference
+ set sp $url
}
html {} [join $sp] "\n"
}
- dl-marc-field $zset $no 037 * "Acquisition" {} "
\n"
+ dl-marc-field $zset $no 037 {[abc]} "Acquisition" {} "
\n"
+ dl-marc-field $zset $no 037 {[f6]} "Form of issue" {} "
\n"
+ dl-marc-field $zset $no 537 * "Source of data" {} "
\n"
+ dl-marc-field $zset $no 538 * "System details" {} "
\n"
dl-marc-field $zset $no 787 {[rstw6]} "Related information" {} "
\n"
dl-marc-field $zset $no 001 * "Local control number" {} ", "
html "\n"
}
-proc display-rec {from to dfunc zz} {
+proc display-rec {from to dfunc tno} {
global setNo
- while {$from <= $to} {
- eval "$dfunc $zz.$setNo $from"
- incr from
+ if {$tno > 0} {
+ while {$from <= $to} {
+ eval "$dfunc z39${tno}.${setNo} $from $tno"
+ incr from
+ }
+ } else {
+ while {$from <= $to} {
+ eval "$dfunc z39.${setNo} $from 0"
+ incr from
+ }
+ }
+}
+
+proc build-scan {t ilines} {
+ global targets
+
+ for {set i 1} {$i <= $ilines} {incr i} {
+ set term [wform entry$i]
+ if {$term != ""} {
+ set field [wform menu$i]
+ foreach x [lindex $targets($t) 2] {
+ if {[lindex $x 0] == $field} {
+ set attr [lindex $x 1]
+ }
+ }
+ return [list $term $attr]
+ }
}
+ return ""
}
-proc build-query {t} {
+proc build-query {t ilines} {
global targets
set op {}
set q {}
- for {set i 1} {$i < 4} {incr i} {
- set term1 [wform entry$i]
- regsub {\+} $term1 " " term
+ for {set i 1} {$i <= $ilines} {incr i} {
+ set term [wform entry$i]
if {$term != ""} {
set field [wform menu$i]
foreach x [lindex $targets($t) 2] {
@@ -323,13 +395,13 @@ proc build-query {t} {
}
switch $op {
And
- { set q "@and $q ${attr} \{${term}\}" }
+ { set q "@and $q ${attr} ${term}" }
Or
- { set q "@or $q ${attr} \{${term}\}" }
+ { set q "@or $q ${attr} ${term}" }
{And not}
- { set q "@not $q ${attr} \{${term}\}" }
+ { set q "@not $q ${attr} ${term}" }
{}
- { set q "${attr} \{${term}\}" }
+ { set q "${attr} ${term}" }
}
set op [wform logic$i]
}
@@ -337,92 +409,252 @@ proc build-query {t} {
return $q
}
-proc z39search {setNo piggy} {
+proc z39scan {setNo scanNo tno scanLines scanPos} {
global hist
global sessionWait
+ global targets
- set host $hist($setNo,host)
- if {[catch {z39 failback fail-response}]} {
- ir z39
+ if {$tno > 0} {
+ set zz z39$tno
+ set host $hist($setNo,$tno,host)
+ set idAuth $hist($setNo,$tno,idAuthentication)
+ set database $hist($setNo,$tno,database)
+ set scanAttr $hist($setNo,$tno,scanAttr)
+ set scanTerm $hist($setNo,$tno,$scanNo,scanTerm)
+ } else {
+ set zz z39
+ set host $hist($setNo,host)
+ set idAuth $hist($setNo,idAuthentication)
+ set database $hist($setNo,database)
+ set scanAttr $hist($setNo,scanAttr)
+ set scanTerm $hist($setNo,$scanNo,scanTerm)
+ }
+ if {[catch [list $zz failback fail-response]]} {
+ ir $zz
}
- if {[catch {set oldHost [z39 connect]}]} {
+ if {[catch [list set oldHost [$zz connect]]]} {
set oldHost ""
}
- z39 callback ok-response
- z39 failback fail-response
+ set zs $zz.s$scanNo.$setNo
+ $zz callback ok-response
+ $zz failback fail-response
if {$oldHost != $host} {
- catch {z39 disconnect}
+ catch [list $zz disconnect]
- html "Connecting to target " $host "
\n"
set sessionWait 0
- if {[catch {z39 connect $host}]} {
- html "Cannot connect to target ${host}
\n"
+ if {[catch [list $zz connect $host]]} {
+ displayError "Cannot connect to target" $host
return 0
} elseif {$sessionWait == 0} {
- zwait sessionWait
+ if {[catch {zwait sessionWait 300}]} {
+ $zz disconnect
+ displayError "Cannot connect to target" $host
+ return 0
+ }
if {$sessionWait != 1} {
- html "Cannot connect to target ${host}
\n"
+ displayError "Cannot connect to target" $host
return 0
}
}
- z39 idAuthentication $hist($setNo,idAuthentication)
+ $zz idAuthentication $idAuth
set sessionWait 0
- if {[catch {z39 init}]} {
- html "Cannot initialize with target ${host}
\n"
+ if {[catch {$zz init}]} {
+ displayError "Cannot initialize target" $host
+ $zz disconnect
return 0
}
if {[catch {zwait sessionWait 60}]} {
- html "Cannot initialize with target ${host}
\n"
- z39 disconnect
+ displayError "Cannot initialize target" $host
+ $zz disconnect
return 0
}
if {$sessionWait != "1"} {
- html "Cannot initialize with target ${host}
\n"
- z39 disconnect
+ displayError "Cannot initialize target" $host
+ $zz disconnect
return 0
}
+ if {![$zz initResult]} {
+ set u [$zz userInformationField]
+ $zz disconnect
+ displayError "Cannot initialize target $host" $u
+ return 0
+ }
+ } else {
+ if {![catch [list $zs numberOfTermsRequested 5]]} {
+ return 1
+ }
+ }
+ eval $zz databaseNames $database
+
+ ir-scan $zs $zz
+
+ $zs numberOfTermsRequested $scanLines
+ $zs preferredPositionInResponse $scanPos
+
+ $zz callback [list scan-response $zs]
+
+ set sessionWait 0
+ $zs scan "${scanAttr} ${scanTerm}"
+
+ if {[catch {zwait sessionWait 600}]} {
+ wlog debug "timeout/cancel in scan"
+ displayError "Timeout in scan" {}
+ html "