[open-ils-commits] r8852 - trunk/Open-ILS/src/perlmods/OpenILS/WWW
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Mar 3 00:13:23 EST 2008
Author: miker
Date: 2008-03-02 23:41:21 -0500 (Sun, 02 Mar 2008)
New Revision: 8852
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
adding relation modifier support and making relations more strictly follow the cql guidlines
Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm 2008-03-01 19:30:51 UTC (rev 8851)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm 2008-03-03 04:41:21 UTC (rev 8852)
@@ -1328,21 +1328,30 @@
my $cql_query = $req->query;
my $search_string = $req->cql->toEvergreen;
+ my $offset = $req->startRecord;
+ $offset-- if ($offset);
+ $offset ||= 0;
+
+ my $limit = $req->maximumRecords;
+ $limit ||= 10;
+
warn "SRU search string [$cql_query] converted to [$search_string]\n";
my $recs = $search->request(
- 'open-ils.search.biblio.multiclass.query' => {} => $search_string
+ 'open-ils.search.biblio.multiclass.query' => {offset => $offset, limit => $limit} => $search_string
)->gather(1);
- $recs = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
+ my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
$resp->addRecord(
SRU::Response::Record->new(
recordSchema => 'info:srw/schema/1/marcxml-v1.1',
recordData => $_->marc
)
- ) for @$recs;
+ ) for @$bre;
+ $resp->numberOfRecords($recs->{count}}
+
print $cgi->header( -type => 'application/xml' );
print entityize($resp->asXML) . "\n";
return Apache2::Const::OK;
@@ -1371,6 +1380,12 @@
our %qualifier_map = (
+ # Som EG qualifiers
+ 'eg.site' => 'site',
+ 'eg.sort' => 'sort',
+ 'eg.direction' => 'dir',
+ 'eg.available' => 'available',
+
# Title class:
'dc.title' => 'title',
'bib.titleabbreviated' => 'title|abbreviated',
@@ -1418,7 +1433,7 @@
'dc.format' => undef,
# Genre:
- 'bib.genre' => undef,
+ 'bib.genre' => 'keyword',
# Target Audience:
'bib.audience' => undef,
@@ -1430,21 +1445,21 @@
'dc.language' => 'lang',
# Edition
- 'bib.edition' => undef,
+ 'bib.edition' => 'keyword',
# Part:
- 'bib.volume' => undef,
- 'bib.issue' => undef,
- 'bib.startpage' => undef,
- 'bib.endpage' => undef,
+ 'bib.volume' => 'keyword',
+ 'bib.issue' => 'keyword',
+ 'bib.startpage' => 'keyword',
+ 'bib.endpage' => 'keyword',
# Issuance:
- 'bib.issuance' => undef,
+ 'bib.issuance' => 'keyword',
);
sub toEvergreen {
my $self = shift;
- my $qualifier = maybeQuote( $self->getQualifier() );
+ my $qualifier = $self->getQualifier();
my $term = $self->getTerm();
my $relation = $self->getRelation();
@@ -1456,22 +1471,27 @@
}
- #my @modifiers = $relation->getModifiers();
+ my @modifiers = $relation->getModifiers();
- #foreach my $m ( @modifiers ) {
- # if( $m->[ 1 ] eq 'fuzzy' ) {
- # $term = "$term~";
- # }
- #}
+ my $base = $relation->getBase();
+ if ( grep { $base eq $_ } qw/= scr exact all/ ) {
- my $base = $relation->getBase();
- if( $base eq '=' ) {
- $base = ':';
+ my $quote_it = 1;
+ foreach my $m ( @modifiers ) {
+ if( grep { $m->[ 1 ] eq $_ } qw/cql.fuzzy cql.stem cql.relevant cql.word/ ) {
+ $quote_it = 0;
+ last;
+ }
+ }
+
+ $quote_it = 0 if ( $base eq 'all' );
+ $term = maybeQuote($term) if $quote_it;
+
} else {
- croak( "Evergreen doesn't support relations other than '='" );
+ croak( "Evergreen doesn't support the $base relations" );
}
- return "$qualifier$base$term";
+ return "$qualifier:$term";
} else {
return "kw:$term";
More information about the open-ils-commits
mailing list