[open-ils-commits] r19564 - in trunk/Open-ILS/src/perlmods/lib/OpenILS: Application WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 3 00:44:36 EST 2011


Author: dbs
Date: 2011-03-03 00:44:33 -0500 (Thu, 03 Mar 2011)
New Revision: 19564

Modified:
   trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
   trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
Log:
Draw SRU search indexes from config.metabib_search_alias

We had hardcoded search indexes for SRU, but thanks to the work
of Mike Rylander, it is fairly easy to remove that brittle code
and replace it with code that polls the contents of
config.metabib_search_alias and dumps it into the explain document.


Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm	2011-03-03 05:43:25 UTC (rev 19563)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm	2011-03-03 05:44:33 UTC (rev 19564)
@@ -346,7 +346,7 @@
 		  params   =>
 		  	[
 				{ name => 'label',
-				  desc => 'The target call number lable',
+				  desc => 'The target call number label',
 				  type => 'string' },
 				{ name => 'org_unit',
 				  desc => 'The org unit shortname (or "-" or undef for global) to browse',
@@ -469,7 +469,7 @@
 		  params   =>
 		  	[
 				{ name => 'label',
-				  desc => 'The target call number lable',
+				  desc => 'The target call number label',
 				  type => 'string' },
 				{ name => 'org_unit',
 				  desc => 'The org unit shortname (or "-" or undef for global) to browse',
@@ -2841,6 +2841,41 @@
 		}
 );
 
+sub return_bib_search_aliases {
+    my %aliases;
+
+	my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+
+	my $cmsa = $_storage->request(
+		'open-ils.cstore.direct.config.metabib_search_alias.search.atomic',
+		{ alias => { like => '%.%'} }
+	)->gather(1);
+
+    foreach my $alias (@$cmsa) {
+        my ($qualifier, $name) = $alias->alias =~ m/^(.+?)\.(.+)$/;
+        push(@{$aliases{$qualifier}}, $name);
+    }
+
+    return \%aliases;
+}
+
+__PACKAGE__->register_method(
+	method    => 'return_bib_search_aliases',
+	api_name  => 'open-ils.supercat.biblio.search_aliases',
+	api_level => 1,
+	argc      => 0,
+	signature =>
+		{ desc     => <<"		  DESC",
+Returns the set of qualified search aliases in the system
+		  DESC
+		  params   => [ ],
+		  'return' =>
+		  	{ desc => 'Hash of qualified search aliases',
+			  type => 'object' }
+		}
+);
+
+
 package OpenILS::Application::SuperCat::unAPI;
 use base qw/OpenILS::Application::SuperCat/;
 

Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-03-03 05:43:25 UTC (rev 19563)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-03-03 05:44:33 UTC (rev 19564)
@@ -34,7 +34,7 @@
 my $U = 'OpenILS::Application::AppUtils';
 
 # set the bootstrap config when this module is loaded
-my ($bootstrap, $supercat, $actor, $parser, $search, $xslt, $cn_browse_xslt, %browse_types);
+my ($bootstrap, $supercat, $actor, $parser, $search, $xslt, $cn_browse_xslt, %browse_types, %qualifier_map);
 
 $browse_types{call_number}{xml} = sub {
     my $tree = shift;
@@ -143,6 +143,10 @@
 
     $cn_browse_xslt = $xslt->parse_stylesheet( $cn_browse_xslt );
 
+    %qualifier_map = %{$supercat
+        ->request("open-ils.supercat.biblio.search_aliases")
+        ->gather(1)};
+
     my $list = $supercat
         ->request("open-ils.supercat.record.formats")
         ->gather(1);
@@ -1601,91 +1605,6 @@
     return Apache2::Const::OK;
 }
 
-our %qualifier_map = (
-
-    # Some EG qualifiers
-    'eg.site'               => 'site',
-    'eg.sort'               => 'sort',
-    'eg.direction'          => 'dir',
-    'eg.available'          => 'available',
-
-    # Title class:
-    'eg.title'              => 'title',
-    'dc.title'              => 'title',
-    'bib.titleabbreviated'  => 'title|abbreviated',
-    'bib.titleuniform'      => 'title|uniform',
-    'bib.titletranslated'   => 'title|translated',
-    'bib.titlealternative'  => 'title',
-    'bib.titleseries'       => 'series',
-    'eg.series'             => 'title',
-
-    # Author/Name class:
-    'eg.author'             => 'author',
-    'eg.name'               => 'author',
-    'creator'               => 'author',
-    'dc.creator'            => 'author',
-    'dc.contributer'        => 'author',
-    'dc.publisher'          => 'keyword',
-    'bib.name'              => 'author',
-    'bib.namepersonal'      => 'author|personal',
-    'bib.namepersonalfamily'=> 'author|personal',
-    'bib.namepersonalgiven' => 'author|personal',
-    'bib.namecorporate'     => 'author|corporate',
-    'bib.nameconference'    => 'author|conference',
-
-    # Subject class:
-    'eg.subject'            => 'subject',
-    'dc.subject'            => 'subject',
-    'bib.subjectplace'      => 'subject|geographic',
-    'bib.subjecttitle'      => 'keyword',
-    'bib.subjectname'       => 'subject|name',
-    'bib.subjectoccupation' => 'keyword',
-
-    # Keyword class:
-    'eg.keyword'            => 'keyword',
-    'srw.serverchoice'      => 'keyword',
-
-    # Identifiers:
-    'dc.identifier'         => 'keyword',
-
-    # Dates:
-    'bib.dateissued'        => undef,
-    'bib.datecreated'       => undef,
-    'bib.datevalid'         => undef,
-    'bib.datemodified'      => undef,
-    'bib.datecopyright'     => undef,
-
-    # Resource Type:
-    'dc.type'               => undef,
-
-    # Format:
-    'dc.format'             => undef,
-
-    # Genre:
-    'bib.genre'             => 'keyword',
-
-    # Target Audience:
-    'bib.audience'          => undef,
-
-    # Place of Origin:
-    'bib.originplace'       => undef,
-
-    # Language
-    'dc.language'           => 'lang',
-
-    # Edition
-    'bib.edition'           => 'keyword',
-
-    # Part:
-    'bib.volume'            => 'keyword',
-    'bib.issue'             => 'keyword',
-    'bib.startpage'         => 'keyword',
-    'bib.endpage'           => 'keyword',
-
-    # Issuance:
-    'bib.issuance'          => 'keyword',
-);
-
 our %qualifier_ids = (
     eg  => 'http://open-ils.org/spec/SRU/context-set/evergreen/v1',
     dc  => 'info:srw/cql-context-set/1/dc-v1.1',
@@ -2101,8 +2020,7 @@
 
             $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $set_node );
 
-            for my $index ( keys %{ $qualifier_map->{$name} } ) {
-                my $desc = $qualifier_map->{$name}{$index}[1] || $index;
+            for my $index ( @{$qualifier_map{$name}} ) {
 
                 my $name_node = $doc->createElementNS( 'http://explain.z3950.org/dtd/2.0/', 'name' );
 
@@ -2115,10 +2033,10 @@
                 $index_node->appendChild( $title_node );
                 $index_node->appendChild( $map_node );
 
-                $index_node->setAttribute( id => $name . '.' . $index );
-                $title_node->appendText( $desc );
+                $index_node->setAttribute( id => "$name.$index" );
+                $title_node->appendText( $index);
                 $name_node->setAttribute( set => $name );
-                $name_node->appendText($index );
+                $name_node->appendText($index);
 
                 $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $index_node );
             }



More information about the open-ils-commits mailing list