]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/org_lasso_js.pl
revert the too-much-change
[Evergreen.git] / Open-ILS / src / extras / org_lasso_js.pl
1 #!/usr/bin/perl
2 use strict; use warnings;
3
4 # ------------------------------------------------------------
5 # turns the actor.org_lasso table into a js file
6 # ------------------------------------------------------------
7
8 use OpenSRF::System;
9 use OpenILS::Utils::Fieldmapper;
10 use OpenSRF::Utils::SettingsClient;
11 use OpenSRF::Utils::JSON;
12
13 die "usage: perl org_tree_js.pl <bootstrap_config>" unless $ARGV[0];
14 OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
15
16 Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
17
18 # must be loaded after the IDL is parsed
19 require OpenILS::Utils::CStoreEditor;
20
21 # fetch the org_unit's and org_unit_type's
22 my $e = OpenILS::Utils::CStoreEditor->new;
23 my $lassos = $e->request(
24     'open-ils.cstore.direct.actor.org_lasso.search.atomic',
25     {id => {"!=" => undef}},
26     {order_by => {lasso => 'name'}}
27 );
28
29 print
30     "var _lasso = [\n  new lasso(" .
31     join( "),\n  new lasso(", map { OpenSRF::Utils::JSON->perl2JSON( bless($_, 'ARRAY') ) } @$lassos ) .
32     ")\n]; /* Org Search Groups (Lassos) */ \n";
33
34