[open-ils-commits] r8629 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 5 10:28:19 EST 2008
Author: erickson
Date: 2008-02-05 10:00:00 -0500 (Tue, 05 Feb 2008)
New Revision: 8629
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added org descendant/ancestor/full_path utility methods
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-02-05 14:59:55 UTC (rev 8628)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-02-05 15:00:00 UTC (rev 8629)
@@ -1314,27 +1314,13 @@
# each work org at that depth.
my ($org_type) = grep { $_->id == $high_org->ou_type } @$org_types;
my $org_depth = $org_type->depth;
+
for my $org (@$work_orgs) {
+
$logger->debug("work org looking at $org");
+ my $org_list = $self->get_org_full_path($org, $org_depth);
- # retrieve sorted list of ancestors and descendants for this work_ou
- my $org_list = $e->json_query({
- select => {
- aou => [{
- transform => 'actor.org_unit_full_path',
- column => 'id',
- result_field => 'id',
- params => [$org_depth]
- }]
- },
- from => 'aou',
- where => {id=>$org}
- });
-
- # go through the list until we find the org at the correct depth
- my @org_list;
- push(@org_list, $_->{id}) for @$org_list;
- for my $sub_org (@org_list) {
+ for my $sub_org (@$org_list) {
$logger->debug("work org looking at sub-org $sub_org");
my $org_unit = $self->find_org($org_tree, $sub_org);
my ($ou_type) = grep { $_->id == $org_unit->ou_type } @$org_types;
@@ -1393,6 +1379,70 @@
return $tree;
}
+sub get_org_descendants {
+ my($self, $org_id, $depth) = @_;
+ $depth ||= 0;
+ my $org_list = new_editor()->json_query(
+ select => {
+ aou => [{
+ transform => 'actor.org_unit_descendants',
+ column => 'id',
+ result_field => 'id',
+ params => [$depth]
+ }],
+ from => 'aou',
+ where => {id => $org_id}
+ }
+ );
+ my @orgs;
+ push(@orgs, $_->{id}) for $org_list;
+ return \@orgs;
+}
+
+sub get_org_ancestors {
+ my($self, $org_id, $depth) = @_;
+ $depth ||= 0;
+
+ my $org_list = new_editor()->json_query(
+ select => {
+ aou => [{
+ transform => 'actor.org_unit_ancestors',
+ column => 'id',
+ result_field => 'id',
+ params => [$depth]
+ }],
+ from => 'aou',
+ where => {id => $org_id}
+ }
+ );
+
+ my @orgs;
+ push(@orgs, $_->{id}) for $org_list;
+ return \@orgs;
+}
+
+sub get_org_full_path {
+ my($self, $org_id, $depth) = @_;
+ $depth ||= 0;
+
+ my $org_list = new_editor()->json_query(
+ select => {
+ aou => [{
+ transform => 'actor.org_unit_full_path',
+ column => 'id',
+ result_field => 'id',
+ params => [$depth]
+ }],
+ from => 'aou',
+ where => {id => $org_id}
+ }
+ );
+
+ my @orgs;
+ push(@orgs, $_->{id}) for $org_list;
+ return \@orgs;
+}
+
1;
More information about the open-ils-commits
mailing list