From 5e793e12d173fe39e975bc5fd6402c7d19bcb140 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 12 Mar 2013 12:13:08 -0400 Subject: [PATCH] Added -s switch to batch-import-xsl scripts to bypass optimize operation. --- harvest/batch-import-xsl.bat | 24 ++++++++++++++++++++++-- harvest/batch-import-xsl.sh | 25 +++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/harvest/batch-import-xsl.bat b/harvest/batch-import-xsl.bat index c057810833c..569d22df3c1 100644 --- a/harvest/batch-import-xsl.bat +++ b/harvest/batch-import-xsl.bat @@ -25,12 +25,28 @@ echo You need to set the VUFIND_HOME environmental variable before running this goto end :vufindhomefound +rem Save script name for message below (otherwise it may get shifted away) +set SCRIPT_NAME=%0 + +rem Set default behavior +set SKIP_OPTIMIZE=0 + +rem Process switches +:switchloop +if "%1"=="-s" goto sswitch +goto switchloopend +:sswitch +set SKIP_OPTIMIZE=1 +shift +goto switchloop +:switchloopend + rem Make sure command line parameter was included: if not "!%2!"=="!!" goto paramsokay echo This script processes a batch of harvested XML records using the specified XSL echo import configuration file. echo. -echo Usage: %0 [harvest subdirectory] [properties file] +echo Usage: %SCRIPT_NAME% [harvest subdirectory] [properties file] echo. echo [harvest subdirectory] is a directory name created by the OAI-PMH harvester. echo This script will search the harvest subdirectories of the directories defined @@ -39,7 +55,10 @@ echo. echo [properties file] is a configuration file found in the import subdirectory of echo either your VUFIND_LOCAL_DIR or VUFIND_HOME directory. echo. -echo Example: %0 oai_source ojs.properties +echo Example: %SCRIPT_NAME% oai_source ojs.properties +echo. +echo Options: +echo -s: Skip optimize operation after importing. goto end :paramsokay @@ -77,6 +96,7 @@ for %%a in (%BASEPATH%\*.xml) do ( rem Optimize the index now that we are done (if necessary): if not "%OPTIMIZE%!"=="1!" goto end +if not "%SKIP_OPTIMIZE%!"=="0!" goto end cd %VUFIND_HOME%\util echo Optimizing index... php optimize.php diff --git a/harvest/batch-import-xsl.sh b/harvest/batch-import-xsl.sh index 3ef97d235ea..00e26cb9a2d 100755 --- a/harvest/batch-import-xsl.sh +++ b/harvest/batch-import-xsl.sh @@ -7,6 +7,21 @@ then exit 1 fi +SKIP_OPTIMIZE=0 + +while getopts ":s" OPT +do + case $OPT in + s) SKIP_OPTIMIZE=1;; + :) + echo "argument to '-$OPTARG' is missing" >&2 + exit -1;; + \?) echo "Unrecognized option '-$OPTARG'" >&2;; + esac +done +# Decrement the argument pointer so it points to next argument +shift $(($OPTIND - 1)) + # Make sure command line parameter was included: if [ -z "$2" ] then @@ -23,6 +38,9 @@ then echo "either your VUFIND_LOCAL_DIR or VUFIND_HOME directory." echo "" echo "Example: `basename $0` oai_source ojs.properties" + echo "" + echo "Options:" + echo "-s: Skip optimize operation after importing." exit 1 fi @@ -59,8 +77,11 @@ do if [ "$?" -eq "0" ] then mv $file $BASEPATH/processed/`basename $file` - # We processed a file, so we need to optimize later on: - OPTIMIZE=1 + # We processed a file and skip is not set, so we need to optimize later on: + if [ "$SKIP_OPTIMIZE" -eq "0" ] + then + OPTIMIZE=1 + fi fi fi done -- GitLab