Created
July 25, 2016 20:55
-
-
Save awoods/2f790d6b0e089ef04a352d87dfd7cc3c to your computer and use it in GitHub Desktop.
Modeling membership with ldp:isMemberOfRelation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE=http://localhost:8080/fcrepo/rest/$RANDOM | |
COL=$BASE/memberCollection | |
curl -X PUT $BASE/objects && echo | |
# create a collection | |
curl -X PUT $COL && echo | |
# create indirect container for members | |
curl -X PUT -H "Content-Type: text/turtle" -d " | |
@prefix ore: <http://www.openarchives.org/ore/terms/> . | |
@prefix ldp: <http://www.w3.org/ns/ldp#> . | |
@prefix pcdm: <http://pcdm.org/models#> . | |
<> a ldp:IndirectContainer ; | |
ldp:isMemberOfRelation pcdm:memberOf ; | |
ldp:insertedContentRelation ore:proxyFor ; | |
ldp:membershipResource <$COL> ." $COL/members && echo | |
N=0 | |
MAX=10000 | |
while [ $N -lt $MAX ]; do | |
# create an object | |
OBJ=`curl -s -X POST -H "Content-Type: application/sparql-update" -d " | |
prefix dc: <http://purl.org/dc/elements/1.1/> | |
insert { <> dc:title \"this is object # $N\" } where { }" $BASE/objects` | |
# add membership proxy | |
curl -s -X POST -H "Content-type: application/sparql-update" -d " | |
prefix ore: <http://www.openarchives.org/ore/terms/> | |
insert { | |
<> a ore:Proxy ; | |
ore:proxyFor <$OBJ> ; | |
ore:proxyIn <$COL> . } | |
where { }" $COL/members > /dev/null | |
N=$(( $N + 1 )) | |
if [ $(( $N % 500 )) == 0 ]; then | |
echo $N objects | |
fi | |
done | |
echo retrieving $COL | |
time -p curl -H "Accept: application/n-triples" $COL > 10k-members.nt | |
grep -c hasMember 10k-members.nt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment