Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
title2a. Creating Sample Objects
curl -X POST 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
languagebash
title3a. Creating Sample Objects And Collections
curl -X POST http://localhost:8080/rest/objects/col1
curl -X POST http://localhost:8080/rest/objects/col2
curl -X POST http://localhost:8080/rest/objects/col3
curl -X POST http://localhost:8080/rest/objects/obj1
curl -X POST http://localhost:8080/rest/objects/obj2
curl -X POST http://localhost:8080/rest/objects/obj3

Mark the objects indexable:

Code Block
languagebash
title3b. Marking objects indexable
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/obj1
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/obj2
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/obj3

...

Code Block
languagebash
title3b3c. Linking Objects To Collections
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:

Code Block
languagebash
title3c3d. Linking 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

...

Code Block
languagesql
title3d3e. Selecting Objects Directly Linked To A Collection
select ?obj ?col where { ?obj <http://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> ?col }

...

Code Block
languagesql
title3d3f. Select Objects Directly Or Indirectly Linked To A Collection
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 }
}

...

obj
<http://localhost:8080/rest/objects/obj1>
<http://localhost:8080/rest/objects/obj2>
<http://localhost:8080/rest/objects/obj3>

Also link an object to a project:

Code Block
languagebash
title3g. Select Objects Directly Or Indirectly Linked To A Collection
curl -X POST http://localhost:8080/rest/objects/proj1
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/proj1
echo 'prefix ex: <http://example.org/> insert data { <http://localhost:8080/rest/obj1> ex:project <http://localhost:8080/rest/proj1> . }" \
| curl -X PATCH --upload-file - http://localhost:8080/rest/obj1

Find objects in a collection or linked to a project:

Code Block
languagesql
title3h. Select Objects Linked To A Collection or A Project
prefix rels: <http://fedora.info/definitions/v4/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> }
 }
Expected Results
obj
<http://localhost:8080/rest/objects/obj1>
<http://localhost:8080/rest/objects/obj2>

Count objects instead of listing them:

Code Block
languagesql
title3i. Count the Objects Linked to a Collection or a Project
prefix rels: <http://fedora.info/definitions/v4/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> }
}
Expected Results
count
"2"^^<http://www.w3.org/2001/XMLSchema#integer>