LP1874897 Staff catalog honors classification scheme
authorBill Erickson <berickxx@gmail.com>
Fri, 24 Apr 2020 20:09:57 +0000 (16:09 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 20 Jul 2020 20:56:11 +0000 (16:56 -0400)
Use the org unit setting "cat.default_classification_scheme" to
determine which scheme to use when extracting the bib-level call number
for display in the Angular staff catalog.

This also modifies the API to look the value up so future calls to the
API will Just Work (and it's one less bit of data the browser has to
retrieve).

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm

index 83d66c0..d29c4bd 100644 (file)
@@ -108,13 +108,10 @@ export class BibRecordSummary {
             return Promise.resolve(this.bibCallNumber);
         }
 
-        // TODO labelClass = cat.default_classification_scheme YAOUS
-        const labelClass = 1;
-
         return this.net.request(
             'open-ils.cat',
             'open-ils.cat.biblio.record.marc_cn.retrieve',
-            this.id, labelClass
+            this.id, null, this.orgId
         ).toPromise().then(cnArray => {
             if (cnArray && cnArray.length > 0) {
                 const key1 = Object.keys(cnArray[0])[0];
index 4c4d977..9f413b0 100644 (file)
@@ -500,24 +500,34 @@ __PACKAGE__->register_method(
         params => [
             {desc => 'Record ID', type => 'number'},
             {desc => '(Optional) Classification scheme ID', type => 'number'},
+            {desc => '(Optional) Context org unit ID for default classification lookup', type => 'number'},
         ]
     },
     return => {desc => 'Hash of candidate call numbers identified by tag' }
 );
 
 sub biblio_record_marc_cn {
-    my( $self, $client, $id, $class ) = @_;
+    my( $self, $client, $id, $class, $ctx_org_id ) = @_;
 
     my $e = new_editor();
-    my $marc = $e->retrieve_biblio_record_entry($id)->marc;
+    my $bre = $e->retrieve_biblio_record_entry($id);
+    my $marc = $bre->marc;
 
     my $doc = XML::LibXML->new->parse_string($marc);
     $doc->documentElement->setNamespace( "http://www.loc.gov/MARC21/slim", "marc", 1 );
 
+    if (!$class) {
+        my $ctx_org = $ctx_org_id || $bre->owner || $U->get_org_tree->id; # root org
+        $class = $U->ou_ancestor_setting_value(
+            $ctx_org, 'cat.default_classification_scheme', $e);
+    }
+
     my @fields;
     my @res;
     if ($class) {
-        @fields = split(/,/, $e->retrieve_asset_call_number_class($class)->field);
+        # be sure the class ID provided exists.
+        my $cn_class = $e->retrieve_asset_call_number_class($class) or return $e->event;
+        @fields = split(/,/, $cn_class->field);
     } else {
         @fields = qw/050ab 055ab 060ab 070ab 080ab 082ab 086ab 088ab 090 092 096 098 099/;
     }