-
Notifications
You must be signed in to change notification settings - Fork 0
/
proc_etd_backlog
103 lines (78 loc) · 2.61 KB
/
proc_etd_backlog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/ksh
# local Voyager env variables
. /opt/local/bin/vger_getenv
# variables to execute java
JAVA=/usr/local/bin/java
JAVADIR=/opt/local/java
PROPFILE=${JAVADIR}/etds.props
DB=ucladb
BASEDIR=/m1/voyager/ucladb/local/cat/etds
READ_BASE=etds_backlog
READ_SCHEMA=ucla_preaddb
WRITE_BASE=proc_backlog
WRITE_SCHEMA=vger_support
READ_SQL=${BASEDIR}/${READ_BASE}
WRITE_SQL=${BASEDIR}/${WRITE_BASE}
RECORDLIST=${READ_SQL}.out
EMBARGO_LEVEL=${1}
FAKE_BIB=-1
# setting lang spec to get UTF 8 output
LC_CTYPE=en_US.UTF-8
export LC_CTYPE
# clear out old xml files
rm -f ${BASEDIR}/*.xml
# Get list of record ids
/opt/local/bin/vger_sqlplus_run ${READ_SCHEMA} ${READ_SQL} ${EMBARGO_LEVEL}
# Each line consists of a bib id, a colon and a ProQuest id
sed 's/:/ /' ${RECORDLIST} | while read BIB_ID PROQ_ID
do
ID_FILE=${BASEDIR}/${BIB_ID}.id
MRC_FILE=${BASEDIR}/${PROQ_ID}.mrc
XML_FILE=${BASEDIR}/working/${PROQ_ID}.mrc.xml
echo ${BIB_ID} > ${ID_FILE}
# generate the marc file
${VGER_BASE}/${DB}/sbin/Pmarcexport \
-o${MRC_FILE} \
-rB \
-mM \
-t${ID_FILE} \
-q
# convert raw marc to xml
${JAVA} -cp ${JAVADIR}/marc4j.jar:${JAVADIR}/marcxml.jar \
gov.loc.marcxml.MARC2MARC21slim ${MRC_FILE} ${XML_FILE}
# Get all files from this directory, then put one file into it
BASEDIR_REMOTE=/graddiv/${PROQ_ID}
# Since we have a key on the SFTP server, we don't need our password here
# Also preserve timestamps
(
echo "get -p $BASEDIR_REMOTE/* $BASEDIR/working"
echo "put -p $XML_FILE $BASEDIR_REMOTE"
echo "exit"
) | sftp -b - [email protected]
# write the merritt erc metadata file
if [ ${BIB_ID} -ne ${FAKE_BIB} ]; then
${BASEDIR}/write_erc ${BIB_ID}
else
#new app to write erc from xml metadata
${JAVA} -cp ${JAVADIR}/backLog.jar backlog.WrteErcFile ${BASEDIR}/working ${PROQ_ID}
fi
#new app to modify xml metadata file
${JAVA} -cp ${JAVADIR}/backLog.jar backlog.UpdateEtdMeta ${BASEDIR}/working ${PROQ_ID} ${EMBARGO_LEVEL}
# make zip container for merritt
ZIP_FILE=${BASEDIR}/${PROQ_ID}.zip
zip -jqr ${ZIP_FILE} ${BASEDIR}/working/*
# send to merritt
/opt/local/bin/curl -k -u uclalib:fr9Stucl \
-F "file=@${ZIP_FILE}" \
-F "type=container" \
-F "submitter=uclalib" \
-F "responseForm=xml" \
-F "profile=ucla_lib_etd_content" \
https://merritt.cdlib.org/object/ingest > ${BASEDIR}/${PROQ_ID}.reply.xml
# clean up
rm -f ${ID_FILE} ${MRC_FILE} ${ZIP_FILE}
rm -fr ${BASEDIR}/working/*
#mark ETD as processed in db
/opt/local/bin/vger_sqlplus_run ${WRITE_SCHEMA} ${WRITE_SQL} ${PROQ_ID}
done
rm -f ${RECORDLIST}