...
Create a few sample containers with either a PDF or a text file, or both attached as binaries (the following commands assume you have two files named test.pdf and test.txt in your current working directory; please substitute working filenames as needed):
Code Block |
---|
title | File: objectcontainer-indexing.rdf |
---|
|
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX indexing: <http://fedora.info/definitions/v4/indexing#>
DELETE { }
INSERT {
<> indexing:hasIndexingTransformation "default";
rdf:type indexing:indexable }
WHERE { } |
Code Block |
---|
language | bash |
---|
title | 1a. Creating Sample ObjectsContainers |
---|
|
curl -X PUT "http://localhost:8080/rest/objects/101"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/101"
curl -X PUT -H "Content-type: application/pdf" --data-binary "@test.pdf" "http://localhost:8080/rest/objects/101/master"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/101/master/fcr:metadata"
curl -X PUT "http://localhost:8080/rest/objects/102"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/102"
curl -X PUT -H "Content-type: text/plain" --data-binary "@test.txt" "http://localhost:8080/rest/objects/102/master"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/102/master/fcr:metadata"
curl -X PUT "http://localhost:8080/rest/objects/103"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/103"
curl -X PUT -H "Content-type: application/pdf" --data-binary "@test.pdf" "http://localhost:8080/rest/objects/103/master"
curl -X PUT -H "Content-type: text/plain" --data-binary "@test.txt" "http://localhost:8080/rest/objects/103/text"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/103/master/fcr:metadata"
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "@object-indexing.rdf" "http://localhost:8080/rest/objects/103/text/fcr:metadata" |
...
Code Block |
---|
language | sql |
---|
title | 1b. Selecting Objects Containers With Datastreams Binaries Named "text" |
---|
|
prefix fcrepo: <http://fedora.info/definitions/v4/repository#>
select ?object where {
?ds fcrepo:mixinTypes "fedora:NonRdfSourceDescription" .
?ds fcrepo:hasParent ?object .
filter(str(?ds)=concat(str(?object),'/text/fcr:metadata'))
} |
...
Code Block |
---|
language | sql |
---|
title | 1c. Selecting Objects Containers With PDF DatastreamsBinaries |
---|
|
prefix fcrepo: <http://fedora.info/definitions/v4/repository#>
prefix relation: <http://www.iana.org/assignments/relation/>
select ?object where {
?ds fcrepo:mixinTypes "fedora:NonRdfSourceDescription" .
?ds fcrepo:hasParent ?object .
?ds relation:describes ?content .
?content fcrepo:mimeType "application/pdf"
} |
...
Code Block |
---|
language | bash |
---|
title | 2a. Creating Sample ObjectsContainers |
---|
|
curl -X PUT http://localhost:8080/rest/objects/201
echo "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix index: <http://fedora.info/definitions/v4/indexing#> insert data { <> rdf:type index:indexable . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/201
echo "prefix dc: <http://purl.org/dc/elements/1.1/> insert data { <http://localhost:8080/rest/objects/201> dc:title 'Foo' . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/201 |
...
Code Block |
---|
language | sql |
---|
title | 2b. Selecting Objects Containers With Titles |
---|
|
prefix dc: <http://purl.org/dc/elements/1.1/>
select ?object ?title where { ?object dc:title ?title } |
...
Code Block |
---|
language | bash |
---|
title | 3a. Creating Sample Objects Containers And Collections |
---|
|
curl -X PUT http://localhost:8080/rest/objects/col1
curl -X PUT http://localhost:8080/rest/objects/col2
curl -X PUT http://localhost:8080/rest/objects/col3
curl -X PUT http://localhost:8080/rest/objects/obj1
curl -X PUT http://localhost:8080/rest/objects/obj2
curl -X PUT http://localhost:8080/rest/objects/obj3 |
...
Code Block |
---|
language | bash |
---|
title | 3b. Marking objects containers indexable |
---|
|
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj1
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj2
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj3
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/col1
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/col2
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/col3 |
...
Code Block |
---|
language | bash |
---|
title | 3c. Linking Objects Containers To Collections |
---|
|
echo 'insert data { <http://localhost:8080/rest/objects/obj1> <http://some-vocabulary.org/rels-ext#isMemberOfCollection> <http://localhost:8080/rest/objects/col1> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj1
echo 'insert data { <http://localhost:8080/rest/objects/obj2> <http://some-vocabulary.org/rels-ext#isMemberOfCollection> <http://localhost:8080/rest/objects/col2> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj2
echo 'insert data { <http://localhost:8080/rest/objects/obj3> <http://some-vocabulary.org/rels-ext#isMemberOfCollection> <http://localhost:8080/rest/objects/col3> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj3
|
...
Code Block |
---|
language | sql |
---|
title | 3e. Selecting Objects Containers Directly Linked To A Collection |
---|
|
select ?obj ?col where { ?obj <http://some-vocabulary.org/rels-ext#isMemberOfCollection> ?col } |
...
Code Block |
---|
language | sql |
---|
title | 3f. Select Objects Containers Directly Or Indirectly Linked To A Collection |
---|
|
prefix rels: <http://some-vocabulary.org/rels-ext#>
select ?obj where {
<http://localhost:8080/rest/objects/col1> rels:hasPart* ?col
. ?obj rels:isMemberOfCollection ?col
} |
...
Code Block |
---|
language | bash |
---|
title | 3g. Link Objects Containers To A Project |
---|
|
curl -X PUT http://localhost:8080/rest/objects/proj1
echo "insert data { <> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/indexing#indexable> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/proj1
echo "prefix ex: <http://example.org/> insert data { <http://localhost:8080/rest/objects/obj1> ex:project <http://localhost:8080/rest/objects/proj1> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj1 |
...
Code Block |
---|
language | sql |
---|
title | 3h. Select Objects Containers Linked To A Collection or A Project |
---|
|
prefix rels: <http://some-vocabulary.org/rels-ext#>
prefix ex: <http://example.org/>
select ?obj where {
{ ?obj ex:project <http://localhost:8080/rest/objects/proj1> }
UNION
{ ?obj rels:isMemberOfCollection <http://localhost:8080/rest/objects/col2> }
} |
...
Code Block |
---|
language | sql |
---|
title | 3i. Count the Objects Containers Linked to a Collection or a Project |
---|
|
prefix rels: <http://some-vocabulary.org/rels-ext#>
prefix ex: <http://example.org/>
select (count(distinct ?obj) as ?count) where {
{ ?obj ex:project <http://localhost:8080/rest/objects/proj1> }
UNION
{ ?obj rels:isMemberOfCollection <http://localhost:8080/rest/objects/col2> }
} |
...