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];
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/;
}