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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 3 22:21:17 EST 2011


Author: dbs
Date: 2011-03-03 22:21:15 -0500 (Thu, 03 Mar 2011)
New Revision: 19575

Modified:
   branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
   branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
Log:
SRU: Restructure the hash returned from open-ils.supercat.biblio.search_aliases

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, and also enables us to
fix the explain document for SRU for authority records.

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_1/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm	2011-03-04 03:20:46 UTC (rev 19574)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm	2011-03-04 03:21:15 UTC (rev 19575)
@@ -2854,10 +2854,13 @@
     foreach (@$cmsa) {
         if ($_->alias =~ /\./) {
             my ($qualifier, $name) = $_->alias =~ m/^(.+?)\.(.+)$/;
-            push(@{$aliases{$qualifier}}, $name);
+            $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
-            push(@{$aliases{'eg'}}, $_->alias);
+            $aliases{'eg'}{$_->alias}{'index'} = $_->alias;
+            $aliases{'eg'}{$_->alias}{'title'} = $_->alias;
         }
     }
 

Modified: branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-03-04 03:20:46 UTC (rev 19574)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-03-04 03:21:15 UTC (rev 19575)
@@ -147,26 +147,40 @@
         ->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
-    push(@{$qualifier_map{'eg'}}, qw/
-        available
-        ascending
-        descending
-        sort
-        format
-        before
-        after
-        statuses
-        locations
-        site
-        depth
-        lasso
-        offset
-        limit
-        preferred_language
-        preferred_language_weight
-        preferred_language_multiplier
-    /);
+    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")
@@ -1633,97 +1647,16 @@
     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'],
-        },
-);
-
 # Our authority search options are currently pretty impoverished;
 # just right-truncated string match on a few categories, or by
 # ID number
 our %nested_auth_qualifier_map = (
         eg => {
-            id          => ['id', 'Record number'],
-            name        => ['author', 'Personal or corporate author, or meeting name'],
-            title       => ['title', 'Uniform title'],
-            subject     => ['subject', 'Chronological term, topical term, geographic name, or genre/form term'],
-            topic       => ['topic', 'Topical term'],
+            id          => { index => 'id', title => 'Record number'},
+            name        => { index => 'author', title => 'Personal or corporate author, or meeting name'},
+            title       => { index => 'title', title => 'Uniform title'},
+            subject     => { index => 'subject', title => 'Chronological term, topical term, geographic name, or genre/form term'},
+            topic       => { index => 'topic', title => 'Topical term'},
         },
 );
 
@@ -1926,10 +1859,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();
@@ -1970,10 +1902,9 @@
         if ( $qualifier ) {
             my ($qset, $qname) = split(/\./, $qualifier);
 
-            $log->debug("SRU toEvergreenAuth: $qset, $qname   $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}[0]\n");
-
             if ( exists($OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}) ) {
-                $qualifier = $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}[0] || 'author';
+                $qualifier = $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}{'index'} || 'author';
+                $log->debug("SRU toEvergreenAuth: $qset, $qname   $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}{'index'}\n");
             }
         }
         return { qualifier => $qualifier, term => $term };
@@ -2041,19 +1972,7 @@
             $set_node->setAttribute( name => $name );
 
             $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $set_node );
-            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)',
-            );
-
-            for my $index ( @{$index_map->{$name}} ) {
-                my $title = $index;
-                if (exists $attribute_desc{$title}) {
-                    $title = $attribute_desc{$title};
-                }
-
+            for my $index ( sort keys %{$index_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' );
@@ -2066,9 +1985,9 @@
                 $index_node->appendChild( $map_node );
 
                 $index_node->setAttribute( id => "$name.$index" );
-                $title_node->appendText($title);
+                $title_node->appendText($index_map->{$name}{$index}{'title'});
                 $name_node->setAttribute( set => $name );
-                $name_node->appendText($index);
+                $name_node->appendText($index_map->{$name}{$index}{'index'});
 
                 $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $index_node );
             }



More information about the open-ils-commits mailing list