From 67459c0c7fe8f64726f48705e59c425684803f12 Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 8 Jul 2008 17:28:12 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@9994 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/Makefile | 1 + Open-ILS/src/extras/autogen.sh | 63 ++++++++++++++++++++++++++++++- Open-ILS/src/extras/org_tree_proximity.pl | 40 ++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/extras/org_tree_proximity.pl diff --git a/Open-ILS/src/Makefile b/Open-ILS/src/Makefile index 76c9b5367d..6584bd2753 100644 --- a/Open-ILS/src/Makefile +++ b/Open-ILS/src/Makefile @@ -100,6 +100,7 @@ autojs-install: 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 # ----------------------------------------------------------------------------------- diff --git a/Open-ILS/src/extras/autogen.sh b/Open-ILS/src/extras/autogen.sh index 8804b2b693..798c168bcf 100755 --- a/Open-ILS/src/extras/autogen.sh +++ b/Open-ILS/src/extras/autogen.sh @@ -1,6 +1,49 @@ #!/bin/bash +# ----------------------------------------------------------------------- +# Copyright (C) 2005-2008 Georgia Public Library Service +# Bill Erickson +# +# 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 "; + 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,7 +56,18 @@ cd "$BASEDIR" CONFIG="$1"; -[ -z "$CONFIG" ] && echo "usage: $0 " && 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 @@ perl org_tree_js.pl "$CONFIG" > "$JSDIR/OrgTree.js"; 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"; ) diff --git a/Open-ILS/src/extras/org_tree_proximity.pl b/Open-ILS/src/extras/org_tree_proximity.pl new file mode 100644 index 0000000000..97a435f505 --- /dev/null +++ b/Open-ILS/src/extras/org_tree_proximity.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# ----------------------------------------------------------------------- +# Copyright (C) 2008 Laurentian University +# Dan Scott +# +# 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 " 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(); -- 2.11.0