LP#1879335: (follow-up) improve extraction of thesaurus
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 9 Sep 2020 18:57:47 +0000 (14:57 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 11 Sep 2020 13:58:54 +0000 (09:58 -0400)
Use the stored procedure authority.extract_thesaurus(), which knows
how to grab the thesaurus from the 040 when necessary.

This also renames the "Thesaurus" column in the display grid to
"Thesaurus (Short Code)", which corresponds to the 008 thesarus
position, and "Thesaurus Code" to "Thesaurus"

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm

index 0b548a5..6dc79b5 100644 (file)
@@ -77,8 +77,8 @@
     [cellTemplate]="headingTemplate"></eg-grid-column>
   <eg-grid-column name="control_set" path="authority.control_set.name" 
     label="Control Set" i18n-label flex="1"></eg-grid-column>
-  <eg-grid-column name="thesaurus" label="Thesaurus" i18n-label flex="1"></eg-grid-column>
-  <eg-grid-column name="thesaurus_code" label="Thesaurus Code" 
+  <eg-grid-column name="thesaurus" label="Thesaurus (Short Code)" i18n-label flex="1"></eg-grid-column>
+  <eg-grid-column name="thesaurus_code" label="Thesaurus"
     i18n-label flex="1"></eg-grid-column>
   <eg-grid-column name="creator" label="Creator" i18n-label
     path="authority.creator.usrname" flex="1"></eg-grid-column>
index 47c52b4..2778912 100644 (file)
@@ -412,18 +412,17 @@ sub authority_main_entry {
         my $field_008 = $marc->field('008');
         if ($field_008) {
 
-            # Extract the 1-char thesaurus code from the 008.
-            my $thes = substr($field_008->data, 11, 1);
+            my $extract_thesaurus_query = {
+                from => [ 'authority.extract_thesaurus' => $rec->marc ]
+            };
+            my $thes = $e->json_query($extract_thesaurus_query)->[0]->{'authority.extract_thesaurus'};
 
             if (defined $thes) {
-                $response->{thesaurus} = $thes;
+                $response->{thesaurus_code} = $thes;
+                my $thesaurus = $e->search_authority_thesaurus(
+                    {code => $thes})->[0];
 
-                if ($thes ne 'z') { # 'z' ('Other') maps to many entries
-                    my $thesaurus = $e->search_authority_thesaurus(
-                        {short_code => $thes})->[0];
-
-                    $response->{thesaurus_code} = $thesaurus->code if $thesaurus;
-                }
+                $response->{thesaurus} = $thesaurus->short_code if $thesaurus;
             }
         }