-
Notifications
You must be signed in to change notification settings - Fork 0
/
flat-pcdm-create.sh
executable file
·57 lines (43 loc) · 3.07 KB
/
flat-pcdm-create.sh
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
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-collection.ttl $FEDORA_BASE/flatpcdm > /dev/null
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-indirect-to-parent.ttl $FEDORA_BASE/flatpcdm/members/ > /dev/null
curl -is -X PUT $FEDORA_BASE/flatpcdmobjects > /dev/null
START=`date +%s`
COUNT=${START_COUNT:-0}
OBJECTS=${NUM_OBJS:-1000}
OBJECTS=$((OBJECTS + COUNT))
echo -n "FLAT-PCDM CREATE $COUNT $OBJECTS "
while [ $COUNT -lt $OBJECTS ]; do
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-object.ttl $FEDORA_BASE/flatpcdmobjects/obj$COUNT/ > /dev/null
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-indirect-to-parent.ttl $FEDORA_BASE/flatpcdmobjects/obj$COUNT/members/ > /dev/null
# Attach proxy to add aggregate to collection
echo "
@prefix ore: <http://www.openarchives.org/ore/terms/>
<> ore:proxyFor </fcrepo/rest/flatpcdmobjects/obj$COUNT/> ;
ore:proxyIn </fcrepo/rest/flatpcdm/> .
" | curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @- $FEDORA_BASE/flatpcdm/members/objProxy$COUNT > /dev/null
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-object.ttl $FEDORA_BASE/flatpcdmobjects/file0_$COUNT/ > /dev/null
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/pcdm-object.ttl $FEDORA_BASE/flatpcdmobjects/file1_$COUNT/ > /dev/null
# Create the proxies for individual objects
echo "@prefix ore: <http://www.openarchives.org/ore/terms/>
<> ore:proxyFor </fcrepo/rest/flatpcdmobjects/file0_$COUNT/> ;
ore:proxyIn </fcrepo/rest/flatpcdmobjects/obj$COUNT> .
" | curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @- $FEDORA_BASE/flatpcdmobjects/obj$COUNT/members/file0Proxy > /dev/null
echo "@prefix ore: <http://www.openarchives.org/ore/terms/>
<> ore:proxyFor </fcrepo/rest/flatpcdmobjects/file1_$COUNT/> ;
ore:proxyIn </fcrepo/rest/flatpcdmobjects/obj$COUNT> .
" | curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @- $FEDORA_BASE/flatpcdmobjects/obj$COUNT/members/file1Proxy > /dev/null
# Establish the files
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/direct-has-file.ru $FEDORA_BASE/flatpcdmobjects/file0_$COUNT/files/ > /dev/null
curl -is -X PUT $FEDORA_BASE/flatpcdmobjects/file0_$COUNT/files/data-file > /dev/null
curl -is -X PATCH -H "Content-Type: application/sparql-update" --data-binary @original-file.ru $FEDORA_BASE/flatpcdmobjects/file0_$COUNT/files/data-file/fcr:metadata > /dev/null
curl -is -X PUT -H "Content-Type: text/turtle" --data-binary @$DIR/direct-has-file.ru $FEDORA_BASE/flatpcdmobjects/file1_$COUNT/files/ > /dev/null
curl -is -X PUT $FEDORA_BASE/flatpcdmobjects/file1_$COUNT/files/data-file > /dev/null
curl -is -X PATCH -H "Content-Type: application/sparql-update" --data-binary @original-file.ru $FEDORA_BASE/flatpcdmobjects/file1_$COUNT/files/data-file/fcr:metadata > /dev/null
# echo "$COUNT"
COUNT=$(( COUNT + 1 ))
done
END=`date +%s`
TOTAL=$(( $END - $START ))
echo "$TOTAL"