ranged non-cat types; depth aware full-path (my_orgs)
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Jan 2006 21:46:55 +0000 (21:46 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Jan 2006 21:46:55 +0000 (21:46 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2840 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/config.pm

index 738649c..8225898 100644 (file)
@@ -257,13 +257,15 @@ sub org_unit_full_path {
        my $self = shift;
        my $client = shift;
        my $id = shift;
+       my $depth = shift;
 
        return undef unless ($id);
 
        my $func = 'actor.org_unit_full_path(?)';
+       my $func = 'actor.org_unit_full_path(?,?)' if defined($depth);
 
        my $sth = actor::org_unit->db_Main->prepare_cached("SELECT * FROM $func");
-       $sth->execute(''.$id);
+       $sth->execute($id, $depth);
 
        $client->respond( $_->to_fieldmapper ) for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
 
index ce5f55d..08570b4 100644 (file)
@@ -71,4 +71,67 @@ __PACKAGE__->register_method(
        stream          => 1,
 );
 
+sub config_non_cat {
+       my $self = shift;
+       my $client = shift;
+
+       for my $rec ( config::non_cataloged_type->retrieve_all ) {
+               $client->respond( $rec->to_fieldmapper );
+       }
+
+       return undef;
+}
+__PACKAGE__->register_method(
+       method          => 'config_non_cat',
+       api_name        => 'open-ils.storage.direct.config.non_cataloged_type.retrieve.all',
+       argc            => 0,
+       stream          => 1,
+);
+
+
+# XXX arg, with the descendancy SPs...
+sub ranged_config_non_cat {
+       my $self = shift;
+       my $client = shift;
+       my @binds = @_;
+
+       my $ctable = config::non_cataloged_type->table;
+
+       my $descendants = defined($binds[1]) ?
+               "actor.org_unit_full_path(?, ?)" :
+               "actor.org_unit_full_path(?)" ;
+
+
+       my $sql = <<"   SQL";
+               SELECT  DISTINCT c.*
+                 FROM  $ctable c
+                       JOIN $descendants d
+                               ON (d.id = c.owning_lib)
+       SQL
+
+       my $sth = config::non_cataloged_type->db_Main->prepare($sql);
+       $sth->execute(@binds);
+
+       while ( my $rec = $sth->fetchrow_hashref ) {
+
+               my $cnct = new Fieldmapper::config::non_cataloged_type;
+               $cnct->name($rec->{name});
+               $cnct->owning_lib($rec->{owning_lib});
+               $cnct->id($rec->{id});
+
+               $client->respond( $cnct );
+       }
+
+       return undef;
+}
+__PACKAGE__->register_method(
+       method          => 'ranged_config_non_cat',
+       api_name        => 'open-ils.storage.ranged.config.non_cataloged_type.retrieve',
+       argc            => 1,
+       stream          => 1,
+       notes           => <<"  NOTES",
+               Returns 
+       NOTES
+);
+
 1;