[open-ils-commits] r19576 - in branches/rel_2_0/Open-ILS/src/perlmods/OpenILS: Application WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 3 23:58:44 EST 2011


Author: dbs
Date: 2011-03-03 23:58:41 -0500 (Thu, 03 Mar 2011)
New Revision: 19576

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
Backport SRU fixes from trunk (r19572, r19573)

Add complete set of Evergreen search aliases and attributes to SRU explain

Original "pull from database" code had limited the search aliases to those
that were qualified; now we pull all of them, and if they are not qualified,
we qualify them as "eg".

In addition, for some of the non-index attributes (sort, direction, site,
available), restore the descriptive title that was previously available.
Slightly longer term we will add a "description" column to
config.metabib_search_alias to store this information. 

By returning explicit index and title elements from the method,
we can backport cleanly to 2.0 and set the stage for pulling the
title element directly from the database in 2.1 and beyond.

In addition, the enriched object enables us to get rid of the
hardcoded nested qualifier map for bibs.

Finally, we also fix the mappings of SRU qualifiers to Evergreen
search aliases (in many cases we had been quietly falling back
to plain kw searches, which was not cool). 


Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2011-03-04 03:21:15 UTC (rev 19575)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2011-03-04 04:58:41 UTC (rev 19576)
@@ -2822,12 +2822,20 @@
 
 	my $cmsa = $_storage->request(
 		'open-ils.cstore.direct.config.metabib_search_alias.search.atomic',
-		{ alias => { like => '%.%'} }
+		{ alias => { '!=' => undef } }
 	)->gather(1);
 
-    foreach my $alias (@$cmsa) {
-        my ($qualifier, $name) = $alias->alias =~ m/^(.+?)\.(.+)$/;
-        push(@{$aliases{$qualifier}}, $name);
+    foreach (@$cmsa) {
+        if ($_->alias =~ /\./) {
+            my ($qualifier, $name) = $_->alias =~ m/^(.+?)\.(.+)$/;
+            $aliases{$qualifier}{$name}{'index'} = $_->alias;
+            # We will add a 'title' property in a subsequent schema
+            $aliases{$qualifier}{$name}{'title'} = $name;
+        } else {
+            # au/kw/se/su/ti go into the default 'eg' qualifier
+            $aliases{'eg'}{$_->alias}{'index'} = $_->alias;
+            $aliases{'eg'}{$_->alias}{'title'} = $_->alias;
+        }
     }
 
     return \%aliases;

Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2011-03-04 03:21:15 UTC (rev 19575)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2011-03-04 04:58:41 UTC (rev 19576)
@@ -147,6 +147,41 @@
         ->request("open-ils.supercat.biblio.search_aliases")
         ->gather(1)};
 
+    my %attribute_desc = (
+        site        => 'Evergreen Site Code (shortname)',
+        sort        => 'Sort on relevance, title, author, pubdate, create_date or edit_date',
+        dir         => 'Sort direction (asc|desc)',
+        available   => 'Filter to available (true|false)',
+    );
+
+    # Append the non-search-alias attributes to the qualifier map
+    foreach ( qw/
+        available
+        ascending
+        descending
+        sort
+        format
+        before
+        after
+        statuses
+        locations
+        site
+        depth
+        lasso
+        offset
+        limit
+        preferred_language
+        preferred_language_weight
+        preferred_language_multiplier
+     /) {
+        $qualifier_map{'eg'}{$_}{'index'} = $_;
+        if (exists $attribute_desc{$_}) {
+            $qualifier_map{'eg'}{$_}{'title'} = $attribute_desc{$_};
+        } else {
+            $qualifier_map{'eg'}{$_}{'title'} = $_;
+        }
+    }
+
 	my $list = $supercat
 		->request("open-ils.supercat.record.formats")
 		->gather(1);
@@ -1612,88 +1647,6 @@
 		srw	=> ''
 );
 
-our %nested_qualifier_map = (
-		eg => {
-			site		=> ['site','Evergreen Site Code (shortname)'],
-			sort		=> ['sort','Sort on relevance, title, author, pubdate, create_date or edit_date'],
-			direction	=> ['dir','Sort direction (asc|desc)'],
-			available	=> ['available','Filter to available (true|false)'],
-			title		=> ['title'],
-			author		=> ['author'],
-			name		=> ['author'],
-			subject		=> ['subject'],
-			keyword		=> ['keyword'],
-			series		=> ['series'],
-		},
-		dc => {
-			title		=> ['title'],
-			creator		=> ['author'],
-			contributor	=> ['author'],
-			publisher	=> ['keyword'],
-			subject		=> ['subject'],
-			identifier	=> ['keyword'],
-			type		=> [undef],
-			format		=> [undef],
-			language	=> ['lang'],
-		},
-		bib => {
-		# Title class:
-	        titleAbbreviated	=> ['title'],
-		    titleUniform		=> ['title'],
-			titleTranslated		=> ['title'],
-	        titleAlternative	=> ['title'],
-		    titleSeries			=> ['series'],
-
-    # Author/Name class:
-			name				=> ['author'],
-			namePersonal		=> ['author'],
-			namePersonalFamily	=> ['author'],
-			namePersonalGiven	=> ['author'],
-			nameCorporate		=> ['author'],
-			nameConference		=> ['author'],
-
-		# Subject class:
-			subjectPlace		=> ['subject'],
-			subjectTitle		=> ['keyword'],
-			subjectName			=> ['subject|name'],
-			subjectOccupation	=> ['keyword'],
-
-    # Keyword class:
-
-    # Dates:
-			dateIssued			=> [undef],
-			dateCreated			=> [undef],
-			dateValid			=> [undef],
-			dateModified		=> [undef],
-			dateCopyright		=> [undef],
-
-    # Genre:
-			genre				=> ['keyword'],
-
-    # Target Audience:
-			audience			=> [undef],
-
-    # Place of Origin:
-			originPlace			=> [undef],
-
-    # Edition
-			edition				=> ['keyword'],
-
-    # Part:
-			volume				=> ['keyword'],
-			issue				=> ['keyword'],
-			startPage			=> ['keyword'],
-			endPage				=> ['keyword'],
-
-    # Issuance:
-			issuance			=> ['keyword'],
-		},
-		srw	=> {
-			serverChoice		=> ['keyword'],
-		},
-);
-
-
 my $base_explain = <<XML;
 <explain
 		id="evergreen-sru-explain-full"
@@ -1860,7 +1813,7 @@
 			$e->findnodes('/z:explain/z:serverInfo/z:port')->shift->appendText( $cgi->server_port );
 			$e->findnodes('/z:explain/z:serverInfo/z:database')->shift->appendText( $url );
 
-			for my $name ( keys %OpenILS::WWW::SuperCat::nested_qualifier_map ) {
+			for my $name ( keys %qualifier_map ) {
 
 				my $identifier = $OpenILS::WWW::SuperCat::qualifier_ids{ $name };
 
@@ -1871,8 +1824,8 @@
 				$set_node->setAttribute( name => $name );
 
 				$e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $set_node );
-
-				for my $index ( @{$qualifier_map{$name} } ) {
+ 
+				for my $index ( sort keys %{$qualifier_map{$name} } ) {
 					my $name_node = $doc->createElementNS( 'http://explain.z3950.org/dtd/2.0/', 'name' );
 
 					my $map_node = $doc->createElementNS( 'http://explain.z3950.org/dtd/2.0/', 'map' );
@@ -1885,9 +1838,9 @@
 					$index_node->appendChild( $map_node );
 
 					$index_node->setAttribute( id => "$name.$index" );
-					$title_node->appendText( $index);
+					$title_node->appendText($qualifier_map{$name}{$index}{'title'});
 					$name_node->setAttribute( set => $name );
-					$name_node->appendText($index);
+					$name_node->appendText($qualifier_map{$name}{$index}{'index'});
 
 					$e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $index_node );
 				}
@@ -1938,10 +1891,9 @@
         if ( $qualifier ) {
 			my ($qset, $qname) = split(/\./, $qualifier);
 
-			$log->debug("SRU toEvergreen: $qset, $qname   $OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}[0]\n");
-
-            if ( exists($OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}) ) {
-                $qualifier = $OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}[0] || 'kw';
+            if ( exists($qualifier_map{$qset}{$qname}) ) {
+                $qualifier = $qualifier_map{$qset}{$qname}{'index'} || 'kw';
+                $log->debug("SRU toEvergreen: $qset, $qname   $qualifier_map{$qset}{$qname}{'index'}\n");
 			}
 
             my @modifiers = $relation->getModifiers();



More information about the open-ils-commits mailing list