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