1 # This tests the main searches specified The Bath Profile, Release 2.0,
2 # http://www.collectionscanada.gc.ca/bath/tp-bath2-e.htm
3 # Specifically section 5.A.0 ("Functional Area A: Level 0 Basic
4 # Bibliographic Search and Retrieval") and its subsections:
5 # http://www.collectionscanada.gc.ca/bath/tp-bath2.7-e.htm#a
6 # And section 5.A.1 ("Functional Area A: Level 1 Bibliographic Search
7 # and Retrieval") and subsections 14 (Standard Identifier Search) and
8 # 15 (Date of Publication Search):
9 # http://www.collectionscanada.gc.ca/bath/tp-bath2.10-e.htm#b
11 # The Bath Level 0 searches have different access-points, but share:
12 # Relation (2) 3 equal
13 # Position (3) 3 any position in field
14 # Structure (4) 2 word
15 # Truncation (5) 100 do not truncate
16 # Completeness (6) 1 incomplete subfield
17 # But Seb's bug report at:
18 # http://bugzilla.indexdata.dk/show_bug.cgi?id=3352#c0
19 # wants use to use s=al t=r,l, where "s" is structure (4) and "al" is
20 # AND-list, which apparently sends NO structure attribute; and "t" is
21 # truncation (5) and "r,l" is right-and-left truncation.
23 # AND-listing (and selection of word or phrase-structure) is now
24 # invoked in the Toroid, when the list of attributes is emitted; we
25 # test for we can't test for 5=100 here, as the Bath Profile says to
26 # do, and rather optimistically use that as justification for emitting
27 # t=l,r in the Toroid (which means that individual queries can request
28 # either left- or right-truncation using "?".
30 # Finally, we also make a test for "X-isbn", an ISBN number search,
31 # which is not actually in the Bath Profile. This gives us something
32 # to back down to when the more general Standard Identifier search
35 package ZOOM::IRSpy::Test::Search::Bath;
41 use ZOOM::IRSpy::Test;
42 our @ISA = qw(ZOOM::IRSpy::Test);
44 use ZOOM::IRSpy::Utils qw(isodate);
48 # Name => use, rel, pos, str, tru, com
49 [ author => 1003, 3, 3, 2, 100, 1 ], # 5.A.0.1
50 [ title => 4, 3, 3, 2, 100, 1 ], # 5.A.0.2
51 [ subject => 21, 3, 3, 2, 100, 1 ], # 5.A.0.3
52 [ any => 1016, 3, 3, 2, 100, 1 ], # 5.A.0.4
53 [ ident => 1007, 3, 1, 1, 100, 1 ], # 5.A.1.14
54 [ date => 31, 3, 1, 4, 100, 1 ], # 5.A.1.15
55 [ "X-isbn"=> 7, 3, 1, 1, 100, 1 ], # Not in Bath Profile
57 # Use attribute only -- fallbacks for when True Bath queries fail
59 [ "X-author1003" => 1003 ],
60 [ "X-author1004" => 1004 ],
62 [ "X-subject" => 21 ],
63 [ "X-any1016" => 1016 ],
64 [ "X-any1017" => 1017 ],
65 [ "X-any1035" => 1035 ],
74 start_search($conn, 0);
79 my($conn, $qindex) = @_;
81 return ZOOM::IRSpy::Status::TEST_GOOD
82 if $qindex >= @bath_queries;
84 my $ref = $bath_queries[$qindex];
85 my($name, @attrs) = @$ref;
88 foreach my $i (1 .. @$ref) {
89 $query = "\@attr $i=" . $ref->[$i] . " " . $query
90 if defined $ref->[$i];
93 $conn->irspy_search_pqf($query, { qindex => $qindex }, {},
94 ZOOM::Event::ZEND, \&search_complete,
95 "exception", \&search_complete);
96 return ZOOM::IRSpy::Status::TASK_DONE;
100 sub search_complete {
101 my($conn, $task, $udata, $event) = @_;
102 my $ok = ref $event && $event->isa("ZOOM::Exception") ? 0 : 1;
104 my $qindex = $udata->{qindex};
105 my $ref = $bath_queries[$qindex];
108 my $n = $task->{rs}->size();
110 $conn->log("irspy_test", "bath search #$qindex ('$name') ",
111 $ok ? ("found $n record", $n==1 ? "" : "s") :
112 "had error: $event");
114 my $rec = $conn->record();
115 $rec->append_entry("irspy:status",
116 "<irspy:search_bath name='$name' ok='$ok'>" .
117 isodate(time()) . "</irspy:search_bath>");
119 return start_search($conn, $qindex+1);