2 # turns the orgTree and orgTypes into js files
4 use OpenSRF::AppSession;
7 use OpenILS::Utils::Fieldmapper;
9 die "usage: perl org_tree_js.pl <bootstrap_config>" unless $ARGV[0];
10 OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
12 my $ses = OpenSRF::AppSession->create("open-ils.storage");
13 my $tree = $ses->request("open-ils.storage.direct.actor.org_unit.retrieve.all.atomic")->gather(1);
14 my $types = $ses->request("open-ils.storage.direct.actor.org_unit_type.retrieve.all.atomic")->gather(1);
16 my $types_string = JSON->perl2JSON($types);
17 $types_string =~ s/\"/\\\"/g;
19 my $pile = "var _l = [";
23 my ($i,$t,$p,$n) = ($o->id,$o->ou_type,$o->parent_ou,$o->name);
24 push @array, "[$i,$t,$p,\"$n\"]";
26 $pile .= join ',', @array;
31 $pile .= "var globalOrgTypes = JSON2js(\"$types_string\");";