[open-ils-commits] r9994 - in branches/rel_1_2/Open-ILS/src: .
extras
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 8 13:28:14 EDT 2008
Author: dbs
Date: 2008-07-08 13:28:12 -0400 (Tue, 08 Jul 2008)
New Revision: 9994
Added:
branches/rel_1_2/Open-ILS/src/extras/org_tree_proximity.pl
Modified:
branches/rel_1_2/Open-ILS/src/Makefile
branches/rel_1_2/Open-ILS/src/extras/autogen.sh
Log:
Forward port r9993 from rel_1_2_2:
* Add a -u flag to autogen.sh to update org_unit proximity
* Make autogen.sh guess at the location of opensrf_core.xml if no args are passed at the command line
Modified: branches/rel_1_2/Open-ILS/src/Makefile
===================================================================
--- branches/rel_1_2/Open-ILS/src/Makefile 2008-07-08 17:26:49 UTC (rev 9993)
+++ branches/rel_1_2/Open-ILS/src/Makefile 2008-07-08 17:28:12 UTC (rev 9994)
@@ -100,6 +100,7 @@
cp extras/fieldmapper.pl $(BINDIR)
cp extras/org_tree_js.pl $(BINDIR)
cp extras/org_tree_html_options.pl $(BINDIR)
+ cp extras/org_tree_proximity.pl $(BINDIR)
cp extras/autogen.sh $(BINDIR)
cp support-scripts/offline-blocked-list.pl $(BINDIR) # this should probably be somewhere else
# -----------------------------------------------------------------------------------
Modified: branches/rel_1_2/Open-ILS/src/extras/autogen.sh
===================================================================
--- branches/rel_1_2/Open-ILS/src/extras/autogen.sh 2008-07-08 17:26:49 UTC (rev 9993)
+++ branches/rel_1_2/Open-ILS/src/extras/autogen.sh 2008-07-08 17:28:12 UTC (rev 9994)
@@ -1,6 +1,49 @@
#!/bin/bash
+# -----------------------------------------------------------------------
+# Copyright (C) 2005-2008 Georgia Public Library Service
+# Bill Erickson <billserickson at gmail.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# -----------------------------------------------------------------------
+
# vim:noet:ts=4
+# ---------------------------------------------------------------------------
+# Make sure we're running as the correct user
+# ---------------------------------------------------------------------------
+[ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
+
+function usage {
+ echo "";
+ echo "usage: $0 [-u] -c <c_config>";
+ echo "";
+ echo "Mandatory parameters:";
+ echo -e " -c\t\tfull path to C configuration file (opensrf_core.xml)";
+ echo "";
+ echo "Optional parameters:";
+ echo -e " -u\t\tupdate proximity of library sites in organization tree";
+ echo -e " \t\t(this is expensive for a large organization tree)";
+ echo "";
+ echo "Examples:";
+ echo "";
+ echo " Update organization tree:";
+ echo " $0 -c /openils/conf/opensrf_core.xml";
+ echo " $0 /openils/conf/opensrf_core.xml";
+ echo "";
+ echo " Update organization tree and refresh proximity:";
+ echo " $0 -u -c /openils/conf/opensrf_core.xml";
+ echo "";
+ exit;
+}
+
(
BASEDIR=${0%/*}
@@ -13,8 +56,19 @@
CONFIG="$1";
-[ -z "$CONFIG" ] && echo "usage: $0 <bootstrap_config>" && exit;
+# ---------------------------------------------------------------------------
+# Load the command line options and set the global vars
+# ---------------------------------------------------------------------------
+while getopts "c:u h" flag; do
+ case $flag in
+ "c") CONFIG="$OPTARG";;
+ "u") PROXIMITY="REFRESH";;
+ "h") usage;;
+ esac;
+done
+[ -z "$CONFIG" ] && usage;
+
JSDIR="/openils/var/web/opac/common/js/";
SLIMPACDIR="/openils/var/web/opac/extras/slimpac/";
@@ -30,6 +84,13 @@
echo "Updating OrgTree HTML";
perl org_tree_html_options.pl "$CONFIG" "$SLIMPACDIR/lib_list.inc";
+if [ "$PROXIMITY" ]
+then
+ echo "Refreshing proximity of org units";
+ perl org_tree_proximity.pl "$CONFIG";
+fi
+
+echo "";
echo "Done";
)
Copied: branches/rel_1_2/Open-ILS/src/extras/org_tree_proximity.pl (from rev 9993, branches/rel_1_2_2/Open-ILS/src/extras/org_tree_proximity.pl)
===================================================================
--- branches/rel_1_2/Open-ILS/src/extras/org_tree_proximity.pl (rev 0)
+++ branches/rel_1_2/Open-ILS/src/extras/org_tree_proximity.pl 2008-07-08 17:28:12 UTC (rev 9994)
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+# -----------------------------------------------------------------------
+# Copyright (C) 2008 Laurentian University
+# Dan Scott <dscott at laurentian.ca>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# -----------------------------------------------------------------------
+
+# calculate the proximity of organizations in the organization tree
+
+# vim:noet:ts=4:sw=4
+
+use OpenSRF::AppSession;
+use OpenSRF::System;
+use OpenILS::Utils::Fieldmapper;
+use OpenSRF::Utils::SettingsClient;
+
+die "usage: perl org_tree_proximity.pl <bootstrap_config>" unless $ARGV[0];
+OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
+
+Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
+
+my $ses = OpenSRF::AppSession->create("open-ils.storage");
+my $result = $ses->request("open-ils.storage.actor.org_unit.refresh_proximity");
+
+if ($result) {
+ print "Successfully updated the organization proximity";
+} else {
+ print "Failed to update the organiziation proximity";
+}
+
+$ses->disconnect();
More information about the open-ils-commits
mailing list