From c7080d6dc24a69c8ad898129e2699c4eb3dd0e31 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 25 Jan 2006 21:46:55 +0000 Subject: [PATCH 1/1] ranged non-cat types; depth aware full-path (my_orgs) git-svn-id: svn://svn.open-ils.org/ILS/trunk@2840 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/actor.pm | 4 +- .../Application/Storage/Publisher/config.pm | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm index 738649c2cc..8225898acc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm @@ -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 ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/config.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/config.pm index ce5f55d657..08570b4bca 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/config.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/config.pm @@ -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; -- 2.43.2