adding export scripts for MWPL
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 26 Sep 2013 05:32:46 +0000 (22:32 -0700)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 26 Sep 2013 05:32:46 +0000 (22:32 -0700)
marc_export_custom/mwpl-full-export-parallel.sh [new file with mode: 0755]
marc_export_custom/mwpl.ini [new file with mode: 0644]

diff --git a/marc_export_custom/mwpl-full-export-parallel.sh b/marc_export_custom/mwpl-full-export-parallel.sh
new file mode 100755 (executable)
index 0000000..b4ad9ce
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+DIR=$(readlink -f $(dirname $0))
+#cd /srv/openils/bin
+
+PGUSER=evergreen
+PGHOST=db1.sitka.bclibraries.ca
+PSQL="psql -A -t -U $PGUSER -h $PGHOST"
+DATABASE=evergreen
+MWPL_QUERY="select distinct record FROM asset.call_number where owning_lib in (select distinct id from actor.org_unit_descendants(1020)) and not deleted and label != '##URI##';"
+MARC_PARAMS="--config /srv/openils/conf/opensrf_core.xml --location MWPL --timeout 300 --force901 --encoding UTF-8 --quiet"
+MARC_EXPORT_BIN="${DIR}/marc_export_custom"
+MARC_EXPORT="${MARC_EXPORT_BIN} ${MARC_PARAMS}"
+
+[ -z "${T}" ] && T=$(date -u +%Y%m%dT%H%M%SZ)
+[ -z "${OUTDIR}" ] && OUTDIR=$(mktemp --tmpdir -d outlook_export.XXXXXXX)
+
+process_batch() {
+       local f="$1" sql="$2" split_count="$3"
+       if [ ! -f ${OUTDIR}/${f}-${T}.id ]; then
+               echo "Getting IDs"
+               $PSQL -c "$sql" $DATABASE | sort | uniq >${OUTDIR}/${f}-${T}.id
+       fi
+       if [ ! -f ${OUTDIR}/${f}.id.targets ]; then
+               echo "Splitting work"
+               split_suffix ${OUTDIR}/${f}-${T}.id ${OUTDIR}/${f}-${T}-split. .id $split_count
+               echo "Making targets"
+               find ${OUTDIR} -name "${f}-${T}-split.[0-9]*[0-9].id" \
+               | sed 's,.id$,.marc,g' \
+               >${OUTDIR}/${f}.id.targets
+       fi
+
+       make ${MAKEOPTS} -f Makefile-marc_export \
+       MARC_EXPORT_BIN="${MARC_EXPORT_BIN}" \
+       MARC_PARAMS="$MARC_PARAMS --exclusion_ini ${f}.ini" \
+       $(<${OUTDIR}/${f}.id.targets)
+
+       find ${OUTDIR} -name "${f}-${T}-split*.marc" \
+       -exec cat \{} \; \
+       >${OUTDIR}/${f}-${T}.marc
+}
+
+split_suffix() {
+       local input="$1" output_prefix="$2" output_suffix="$3" split_count="$4"
+       split -a 7 -d -C ${split_count} ${input} ${output_prefix}
+       find $(dirname ${output_prefix}) -name "$(basename ${output_prefix})*" -exec mv -f \{\} \{\}${output_suffix} \;
+}
+
+# media for BC ELN post-secondary libraries
+export SPLIT_COUNT=10000
+F=mwpl SQL="$MWPL_QUERY"
+process_batch "$F" "${SQL}" $SPLIT_COUNT
diff --git a/marc_export_custom/mwpl.ini b/marc_export_custom/mwpl.ini
new file mode 100644 (file)
index 0000000..1c268d4
--- /dev/null
@@ -0,0 +1,62 @@
+; The only library we want to include is pathed: SITKA/SPRUCE/MWPL
+
+[SITKA]
+Flags=hidden
+
+; parent_ou=1
+[BBGVL]
+ExcludeEntireOrg=true
+[BBNCLF]
+ExcludeEntireOrg=true
+[BCK]
+ExcludeEntireOrg=true
+[BNCLF]
+ExcludeEntireOrg=true
+[BNELF]
+ExcludeEntireOrg=true
+[GOVLIBS]
+ExcludeEntireOrg=true
+[ISLANDLINK]
+ExcludeEntireOrg=true
+[K12]
+ExcludeEntireOrg=true
+[POSTSECONDARY]
+ExcludeEntireOrg=true
+[SGIC]
+ExcludeEntireOrg=true
+[SPRUCE]
+; included
+[UNFEDERATED]
+ExcludeEntireOrg=true
+
+; parent_ou=1000
+[BOISSEVAIN]
+ExcludeEntireOrg=true
+[MANITOU]
+ExcludeEntireOrg=true
+[MB]
+ExcludeEntireOrg=true
+[MDB]
+ExcludeEntireOrg=true
+[MPLP]
+ExcludeEntireOrg=true
+[MS]
+ExcludeEntireOrg=true
+[MSOG]
+ExcludeEntireOrg=true
+[MSSC]
+ExcludeEntireOrg=true
+[MUCN]
+ExcludeEntireOrg=true
+[MWPL]
+; This is the only library we want!
+Statuses=Discard/Weed
+[SCRL]
+ExcludeEntireOrg=true
+[SIRL]
+ExcludeEntireOrg=true
+[SPECIAL]
+ExcludeEntireOrg=true
+[STEROSE]
+ExcludeEntireOrg=true
+