1 # $Id: Fetch.pm,v 1.14 2006-11-03 13:37:33 mike Exp $
3 # See the "Main" test package for documentation
5 package ZOOM::IRSpy::Test::Record::Fetch;
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
19 # Here I want to get a use attribute from the session, which we've
20 # managed to search for in the Search/Bib1 or Search/Dan1 tests.
21 # But how? So far we search for title: 1=4
22 $conn->irspy_search_pqf("\@attr 1=4 mineral", {}, {},
23 ZOOM::Event::RECV_SEARCH, \&completed_search,
24 exception => \&error);
28 sub completed_search {
29 my($conn, $task, $udata, $event) = @_;
31 my $n = $task->{rs}->size();
32 $conn->log("irspy_test", "Fetch test search found $n records");
33 return ZOOM::IRSpy::Status::TEST_SKIPPED if $n == 0;
56 #@syntax = qw(grs-1 sutrs usmarc xml); # simplify for debugging
57 foreach my $syntax (@syntax) {
58 $conn->irspy_rs_record($task->{rs}, 0,
59 { syntax => $syntax },
60 { start => 0, count => 1,
61 preferredRecordSyntax => $syntax },
62 ZOOM::Event::RECV_RECORD, \&record,
63 exception => \&error);
66 return ZOOM::IRSpy::Status::TASK_DONE;
71 my($conn, $task, $test_args, $event) = @_;
72 my $syn = $test_args->{'syntax'};
75 # Due to a bug in ZOOM-C (as of YAZ 2.1.38 of 31st October 2006),
76 # diagnostics in Present responses are not reported, so that we
77 # always end up in this callback rather than in error() where we
78 # should be. Luckily, we can test whether the retrieval really
79 # did work by rendering the record, which will yield an undefined
80 # result if the fetch failed.
81 my $record = _fetch_record($rs, 0, $syn);
82 my $text = $record->render();
84 $conn->log("irspy_test", "Successfully retrieved a $syn record");
86 print STDERR "Hits: ", $rs->size(), "\n";
87 print STDERR "Syntax: ", $syn, "\n";
91 $conn->log("irspy_test", "Retrieval of $syn record failed: ",
92 "exception unavailable");
95 $conn->record()->store_result('record_fetch',
97 'ok' => defined $text ? 1 : 0);
99 return ZOOM::IRSpy::Status::TASK_DONE;
104 my($rs, $index0, $syntax) = @_;
106 my $oldSyntax = $rs->option(preferredRecordSyntax => $syntax);
107 my $record = $rs->record(0);
108 $oldSyntax = "" if !defined $oldSyntax;
109 $rs->option(preferredRecordSyntax => $oldSyntax);
116 my($conn, $task, $test_args, $exception) = @_;
117 my $syn = $test_args->{'syntax'};
119 $conn->log("irspy_test", "Retrieval of $syn record failed: ", $exception);
120 $conn->record()->store_result('record_fetch',
123 return ZOOM::IRSpy::Status::TASK_DONE;