Merge branch 'master' of git+ssh://git.sitka.bclibraries.ca/sitka/sitka-tools
authorJames Fournie <jfournie@sitka.bclibraries.ca>
Fri, 4 May 2012 18:01:24 +0000 (11:01 -0700)
committerJames Fournie <jfournie@sitka.bclibraries.ca>
Fri, 4 May 2012 18:01:24 +0000 (11:01 -0700)
marc_export_custom/bc_eln_media.ini
marc_export_custom/bc_eln_serials.ini
marc_export_custom/sitka-full-export-bslw.sh [new file with mode: 0755]
marc_import_overdrive/overdrive-ingest-db-func.sql

index 381fe90..d1ee18c 100644 (file)
@@ -36,3 +36,7 @@ OnlyIncludeLocations=16mm film,CD-ROM,DVD,DVD magazine,Sound Effect\, ExCat CD\,
 
 [BCREK]
 OnlyIncludeCircMods=dvd,video,videos,video-cassette
+
+; Pending specification from NVIT as to what to include in the Outlook data
+;[BMN]
+;[BMNB]
index 6a99478..a7d1955 100644 (file)
@@ -36,3 +36,7 @@ OnlyIncludeLocations=Magazine,DVD magazine,Special Collections - Magazines - Lib
 
 [BCREK]
 OnlyIncludeCircMods=magazine
+
+; Pending specification from NVIT as to what to include in the Outlook data
+;[BMN]
+;[BMNB]
diff --git a/marc_export_custom/sitka-full-export-bslw.sh b/marc_export_custom/sitka-full-export-bslw.sh
new file mode 100755 (executable)
index 0000000..c317a8f
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+DIR=`dirname $0`
+#cd /srv/openils/bin
+
+PGUSER=evergreen
+PGHOST=db1.sitka.bclibraries.ca
+PSQL="psql -A -t -U $PGUSER -h $PGHOST"
+DATABASE=evergreen
+FULL_QUERY="select id from biblio.record_entry where not deleted"
+TNRD_QUERY="select distinct record FROM asset.call_number where owning_lib in (select distinct id from actor.org_unit_descendants(50)) and not deleted;"
+MARC_PARAMS="--config /srv/openils/conf/opensrf_core.xml --timeout 300 --force901 --encoding UTF-8"
+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 backstage_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" \
+       $(<${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} \;
+}
+
+# TNRD dump
+export SPLIT_COUNT=10000
+F=tnrd SQL="$TNRD_QUERY"
+process_batch "$F" "${SQL}" $SPLIT_COUNT
+
+export SPLIT_COUNT=100000
+# full dump for all libraries
+F=sitka_full_backstage SQL="$FULL_QUERY"
+process_batch "$F" "${SQL}" $SPLIT_COUNT
+
index 632f296..0f95708 100755 (executable)
@@ -82,15 +82,68 @@ BEGIN
        -- from actor.org_unit_setting b join actor.org_unit a on (a.id = b.org_unit) where b.name = 'sitka.overdrive_setting' and b.value = true
        -- something like that
 
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'BBGVL'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'BBNCLF'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'BCK'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'BNCLF'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'BNELF'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'ISLANDLINK'::TEXT) INTO marcxml;
-       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, 'UNFEDERATED'::TEXT) INTO marcxml;
+       SELECT sitka.overdrive_bc_add_uri_field(marcxml::TEXT, tcnprefix::TEXT, urlprefix::TEXT, urlcaption::TEXT, shortname::TEXT) FROM sitka.bc_overdrive_subscribers INTO marcxml;
 
     UPDATE biblio.record_entry set marc = marcxml WHERE id = rid;
        return true;
 END;
 $$ LANGUAGE PLPGSQL;
+
+CREATE TABLE sitka.bc_overdrive_subscribers (shortname TEXT);
+INSERT INTO sitka.bc_overdrive_subscribers VALUES
+('BB'),
+('BNV'),
+('BMV'),
+('BVA'),
+('BPE'),
+('BCOQ'),
+('BNW'),
+('BSUR'),
+('BNVD'),
+('BBI'),
+('BSQ'),
+('BW'),
+('BRI'),
+('BABF'),
+('BLP'),
+('BGIBSE'),
+('BPMP'),
+('BMB'),
+('BVDH'),
+('BFSJA'),
+('BPG'),
+('BWLCR'),
+('BMK'),
+('BGSI'),
+('BCR'),
+('BVI'),
+('BS'),
+('BFN'),
+('BPRDP'),
+('BTA'),
+('BNA'),
+('BF'),
+('BH'),
+('BSPA'),
+('BHA'),
+('BTR'),
+('BHH'),
+('BPR'),
+('BCHE'),
+('BKASL'),
+('BFSJ'),
+('BR'),
+('BFBV'),
+('BKI'),
+('BCD'),
+('BIN'),
+('BGF'),
+('BSA'),
+('BNE'),
+('BT'),
+('BTE'),
+('BCRE'),
+('BKO'),
+('BP'),
+('BKCT'),
+('BNVI');