From b14b320d852fd1c99e9ac23ef4c62d10fbe6d42e Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 3 Aug 2005 19:52:45 +0000 Subject: [PATCH] super slim version git-svn-id: svn://svn.open-ils.org/ILS/trunk@1605 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/org_tree_js.pl | 62 ++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/extras/org_tree_js.pl b/Open-ILS/src/extras/org_tree_js.pl index 54dc5cef72..d8a7b4f9f9 100644 --- a/Open-ILS/src/extras/org_tree_js.pl +++ b/Open-ILS/src/extras/org_tree_js.pl @@ -4,33 +4,55 @@ use OpenSRF::AppSession; use OpenSRF::System; use JSON; +use OpenILS::Utils::Fieldmapper; + die "usage: perl org_tree_js.pl " unless $ARGV[0]; OpenSRF::System->bootstrap_client(config_file => $ARGV[0]); -my $ses = OpenSRF::AppSession->create("open-ils.actor"); -my $req = $ses->request("open-ils.actor.org_tree.retrieve"); - -my $tree = $req->gather(1); +my $ses = OpenSRF::AppSession->create("open-ils.storage"); +my $tree = $ses->request("open-ils.storage.direct.actor.org_unit.retrieve.all.atomic")->gather(1); +my $types = $ses->request("open-ils.storage.direct.actor.org_unit_type.retrieve.all.atomic")->gather(1); -my $ses2 = OpenSRF::AppSession->create("open-ils.storage"); -my $req2 = $ses2->request("open-ils.storage.direct.actor.org_unit_type.retrieve.all.atomic"); -my $types = $req2->gather(1); - -my $tree_string = JSON->perl2JSON($tree); my $types_string = JSON->perl2JSON($types); - -$tree_string =~ s/\"([0-9]+)\"/$1/g; -$tree_string =~ s/null//g; - -$tree_string =~ s/\"/\\\"/g; $types_string =~ s/\"/\\\"/g; - -$tree_string = "var globalOrgTree = JSON2js(\"$tree_string\");"; -$types_string = "var globalOrgTypes = JSON2js(\"$types_string\");"; - -print "$tree_string\n\n$types_string\n"; +my $pile = "var _l = ["; + +my @array; +for my $o (@$tree) { + my ($i,$t,$p,$n) = ($o->id,$o->ou_type,$o->parent_ou,$o->name); + push @array, "[$i,$t,$p,\"$n\"]"; +} +$pile .= join ',', @array; +$pile .= <disconnect(); -$ses2->disconnect(); -- 2.43.2