This feature is unreleased, and only available by downloading and building Fedora 4 from Github.
This page provides detailed steps for creating repository content via the REST API, and SPARQL queries to demonstrate that content in the triplestore. Much more information about the REST API is available at: REST API and Another Take on the REST API.
1. Finding Objects by Datastream Name or MIME Type
Create a few sample objects with either a PDF or a text file, or both attached as datastreams (these commands assume you have two files named test.pdf and test.txt in your current working directory, please substitute working filenames as needed):
curl -X POST http://localhost:8080/rest/objects/101?mixin=fedora:object curl -X POST -H "Content-type: application/pdf" --data-binary @test.pdf \ http://localhost:8080/rest/objects/101/master/fcr:content curl -X POST http://localhost:8080/rest/objects/102?mixin=fedora:object curl -X POST -H "Content-type: text/plain" --data-binary @test.txt \ http://localhost:8080/rest/objects/102/master/fcr:content curl -X POST http://localhost:8080/rest/objects/103?mixin=fedora:object curl -X POST -H "Content-type: application/pdf" --data-binary @test.pdf \ http://localhost:8080/rest/objects/103/master/fcr:content curl -X POST -H "Content-type: text/plain" --data-binary @test.txt \ http://localhost:8080/rest/objects/103/text/fcr:content
Find objects with a datastream named "text":
prefix fcrepo: <http://fedora.info/definitions/v4/repository#> select ?object where { ?ds fcrepo:mixinTypes "fedora:datastream" . ?ds fcrepo:hasParent ?object . filter(str(?ds)=concat(str(?object),'/text')) }
Expected Results
object |
---|
<http://localhost:8080/rest/objects/103> |
Find objects with a PDF datastream:
prefix fcrepo: <http://fedora.info/definitions/v4/repository#> select ?object where { ?ds fcrepo:mixinTypes "fedora:datastream" . ?ds fcrepo:hasParent ?object . ?ds fcrepo:hasContent ?content . ?content fcrepo:mimeType "application/pdf" }
Expected Results
object |
---|
<http://localhost:8080/rest/objects/101> |
<http://localhost:8080/rest/objects/103> |
2. Attach metadata properties directly to objects
Create an object and attach the dc:title property:
curl -X POST http://localhost:8080/rest/objects/201?mixin=fedora:object echo "prefix dc: <http://purl.org/dc/terms/> insert data { <http://localhost:8080/rest/objects/201> dc:title 'Foo' . }" \ | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/201
Find objects with titles:
prefix dc: <http://purl.org/dc/terms/> select ?object ?title where { ?object dc:title ?title }
Expected Results
object | title |
---|---|
<http://localhost:8080/rest/objects/201> | "Foo" |
Find Objects By Collection Membership
Create three objects and three collections:
curl -X POST http://localhost:8080/rest/objects/col1?mixin=fedora:object curl -X POST http://localhost:8080/rest/objects/col2?mixin=fedora:object curl -X POST http://localhost:8080/rest/objects/col3?mixin=fedora:object curl -X POST http://localhost:8080/rest/objects/obj1?mixin=fedora:object curl -X POST http://localhost:8080/rest/objects/obj2?mixin=fedora:object curl -X POST http://localhost:8080/rest/objects/obj3?mixin=fedora:object
Link each object to a collection:
echo 'insert data { <http://localhost:8080/rest/objects/obj1> <http://fedora.info/definitions/v4/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://fedora.info/definitions/v4/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://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> <http://localhost:8080/rest/objects/col3> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/obj3
Link the collections in a hierarchy:
echo 'insert data { <http://localhost:8080/rest/objects/col1> <http://fedora.info/definitions/v4/rels-ext#hasPart> <http://localhost:8080/rest/objects/col2> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/col1 echo 'insert data { <http://localhost:8080/rest/objects/col2> <http://fedora.info/definitions/v4/rels-ext#hasPart> <http://localhost:8080/rest/objects/col3> . }' | curl -X PATCH --upload-file - http://localhost:8080/rest/objects/col2
Find objects directly attached to a collection:
select ?obj ?col where { ?obj <http://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> ?col }
Expected Results
obj | col |
---|---|
<http://localhost:8080/rest/objects/obj1> | <http://localhost:8080/rest/objects/col1> |
<http://localhost:8080/rest/objects/obj2> | <http://localhost:8080/rest/objects/col2> |
<http://localhost:8080/rest/objects/obj3> | <http://localhost:8080/rest/objects/col3> |
Find objects directly or indirectly attached (down to the third level):
prefix rels: <http://fedora.info/definitions/v4/rels-ext#> select ?obj where { { ?obj rels:isMemberOfCollection <http://localhost:8080/rest/objects/col1> } UNION { ?obj rels:isMemberOfCollection ?c . <http://localhost:8080/rest/objects/col1> rels:hasPart ?c } UNION { ?obj rels:isMemberOfCollection ?c . <http://localhost:8080/rest/objects/col1> rels:hasPart ?c1 . ?c1 rels:hasPart ?c } }
Expected Results
obj |
---|
<http://localhost:8080/rest/objects/obj1> |