Add method for returning valid authority browse axes
authorMike Rylander <mrylander@gmail.com>
Thu, 12 May 2011 14:18:15 +0000 (10:18 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 12 May 2011 14:18:15 +0000 (10:18 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm

index 134ce4e..4ef7e34 100644 (file)
@@ -887,21 +887,36 @@ Returns a list of the requested org-scoped record IDs held
                }
 );
 
+sub grab_authority_browse_axes {
+
+    unless(scalar(keys(%authority_browse_axis_cache))) {
+        my $axes = new_editor->search_authority_browse_axis([
+            { code => { '<>' => undef } },
+            { flesh => 2, flesh_fields => { aba => ['fields'], acsafm => ['bib_fields','sub_entries'] } }
+        ]);
+        $authority_browse_axis_cache{$_->code} = $_ for (@$axes);
+    }
+
+    return [keys %authority_browse_axis_cache];
+}
+__PACKAGE__->register_method(
+       method    => 'grab_authority_browse_axes',
+       api_name  => 'open-ils.supercat.authority.browse_axis_list',
+       api_level => 1,
+       argc      => 0,
+       note      => "Returns a list of valid authority browse/startswith axes"
+);
+
 sub axis_authority_browse {
        my $self = shift;
        my $client = shift;
     my $axis = shift;
 
+    $axis =~ s/^authority\.//;
     $axis =~ s/(\.refs)$//;
     my $refs = $1;
 
-    unless(scalar(keys(%authority_browse_axis_cache))) {
-        my $axes = new_editor->search_authority_browse_axis([
-            { code => { '<>' => undef } },
-            {flesh => 4, flesh_fields => { aba => ['fields'], acsafm => ['sub_entries'] } }
-        ]);
-        $authority_browse_axis_cache{$_->code} = $_ for (@$axes);
-    }
+    return undef unless ( grep { /$axis/ } @{ grab_authority_browse_axes() } );
 
     my @tags;
     for my $f (@{$authority_browse_axis_cache{$axis}->fields}) {
@@ -929,6 +944,8 @@ __PACKAGE__->register_method(
                }
 );
 
+=pod
+
 sub general_authority_browse {
        my $self = shift;
        my $client = shift;
@@ -1055,6 +1072,8 @@ __PACKAGE__->register_method(
                }
 );
 
+=cut
+
 sub authority_tag_sf_browse {
     my $self = shift;
     my $client = shift;
@@ -1448,16 +1467,11 @@ sub axis_authority_startwith {
        my $client = shift;
     my $axis = shift;
 
+    $axis =~ s/^authority\.//;
     $axis =~ s/(\.refs)$//;
     my $refs = $1;
 
-    unless(scalar(keys(%authority_browse_axis_cache))) {
-        my $axes = new_editor->search_authority_browse_axis([
-            { code => { '<>' => undef } },
-            {flesh => 4, flesh_fields => { aba => ['fields'], acsafm => ['sub_entries'] } }
-        ]);
-        $authority_browse_axis_cache{$_->code} = $_ for (@$axes);
-    }
+    return undef unless ( grep { /$axis/ } @{ grab_authority_browse_axes() } );
 
     my @tags;
     for my $f (@{$authority_browse_axis_cache{$axis}->fields}) {
@@ -1485,6 +1499,8 @@ __PACKAGE__->register_method(
                }
 );
 
+=pod
+
 sub general_authority_startwith {
        my $self = shift;
        my $client = shift;
@@ -1611,6 +1627,8 @@ __PACKAGE__->register_method(
                }
 );
 
+=cut
+
 sub authority_tag_sf_startwith {
     my $self = shift;
     my $client = shift;