Versions Compared

Key

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

...

Panel
titleBGColorgray
titleBook - Create DirectContainer

Here we will begin to walk through the mechanics of creating the structures that will facilitate creation of the book and its pages.


First, create the top-level "objects/" pcdm:Object, which is also an ldp:BasicContainer.

Code Block
curl -i -XPUT -H"Content-Type: text/turtle" --data-binary @pcdm-object.ttl localhost:8080/rest/objects/

Where "pcdm-object.ttl" follows:

Code Block
titlepcdm-object.ttl
@prefix pcdm: <http://pcdm.org/models#>
 
<> a pcdm:Object .

Second, create the nested "raven/" pcdm:Object, which is also another ldp:BasicContainer.

Code Block
curl -i -XPUT -H"Content-Type: text/turtle" --data-binary @pcdm-object.ttl localhost:8080/rest/objects/raven/

Lastly, create an ldp:DirectContainer, "pages/" that will facilitate the establishment of relationships between "raven/" and its constituent pages.

Code Block
curl -i -XPUT -H"Content-Type: text/turtle" --data-binary @ldp-direct.ttl localhost:8080/rest/objects/raven/pages/

Where "ldp-direct.ttl" follows:

Code Block
titleldp-direct.ttl
@prefix ldp: <http://www.w3.org/ns/ldp#>
@prefix pcdm: <http://pcdm.org/models#>

<> a ldp:DirectContainer, pcdm:Object ;
  ldp:membershipResource </rest/objects/raven/> ;
  ldp:hasMemberRelation pcdm:hasMember .

An ldp:DirectContaner is an LDP construct that activates the creation of certain RDF triples when a new resource is added as a child of this container.
Specifically, when an new resources is added inside of the "pages/" DirectContainer, a new triple on the ldp:membershipResource ("raven/") will be created with the predicate defined by the ldp:hasMemberRelation property ("pcdm:hasMember") and a subject that is a reference to the new resource.

We will see this in action next!

...

Panel
titleBGColorgray
titleCover - Create DirectContainer

In the same way that we used an ldp:DirectContainer to facilitate the auto-generation of triples linking "raven/" to each of the pages, now use the same pattern to auto-generate the creation of triples that link each page pcdm:Object to its their various file representations.

Image Added
To begin with, create an ldp:DirectContainer, "files/", which is also a pcdm:Object, as a child of "cover/" as follows:

Code Block
curl -i -XPUT -H"Content-Type: text/turtle" --data-binary @ldp-cover-direct.ttl localhost:8080/rest/objects/raven/pages/cover/files/

Where "ldp-cover-direct.ttl" follows:

Code Block
titleldp-cover-direct.ttl
@prefix ldp: <http://www.w3.org/ns/ldp#>
@prefix pcdm: <http://pcdm.org/models#>

<> a ldp:DirectContainer, pcdm:Object ;
  ldp:membershipResource </rest/objects/raven/pages/cover/> ;
  ldp:hasMemberRelation pcdm:hasMember . pcdm:hasFile .

Now, any new resource that is added as a child of the DirectContainer "files/" will cause the auto-generation of a new triple on "cover/" that has a predicate of pcdm:hasFile and an object of the new resource.

Panel
titleBGColorgray
titleCover - Create Files

Once again, we demonstrate the use of LDP in creating PCDM relationships simply as a result of repository interactions.

Image Added
Add two pcdm:File resources to the DirectContainer, "files/" as follows:

Code Block
curl -i -XPUT -H"Content-Type: image/jpeg" --data-binary @cover.jpg localhost:8080/rest/objects/raven/pages/cover/files/cover.jpg

Where "cover.jpg" is attached.

If you perform a subsequent HTTP HEAD on this new resource, you will see there is a "Link" header of rel="describedby". Update the RDF metadata of the ldp:NonRdfSource to specify that the resource is a pcdm:File, as follows:

Code Block
curl -i -XPATCH -H"Content-Type: application/sparql-update" --data-binary @pcdm-file.ru localhost:8080/rest/objects/raven/pages/cover/files/cover.jpg/fcr:metadata

Where "pcdm-file.ru" follows:

Code Block
titlepcdm-file.ru
 PREFIX pcdm: <http://pcdm.org/models#>
INSERT {
  <> a pcdm:File
} WHERE {
}

Repeat for the attached TIFF, cover.tif

Code Block
curl -i -XPUT -H"Content-Type: image/tiff" --data-binary @cover.tif localhost:8080/rest/objects/raven/pages/cover/files/cover.tif
curl -i -XPATCH -H"Content-Type: application/sparql-update" --data-binary @pcdm-file.ru localhost:8080/rest/objects/raven/pages/cover/files/cover.tif/fcr:metadata

After creating the two "cover" resources, an HTTP GET on "cover/" will include the two new triples:

No Format
<http://localhost:8080/rest/objects/raven/pages/cover/> pcdm:hasFile <http://localhost:8080/rest/objects/raven/pages/cover/files/cover.jpg> 
<http://localhost:8080/rest/objects/raven/pages/cover/> pcdm:hasFile <http://localhost:8080/rest/objects/raven/pages/cover/files/cover.tif>

Once again,

  • the subject of the triple comes from the "ldp:membershipResource" defined on "files/"
  • the predicate of the triple comes from the "ldp:hasMemberRelation" defined on "files/", and
  • the object of the triple is the new resource ("cover.jpg" or "cover.tif") that was added to the ldp:DirectContainer ("files/")
Panel
titleBGColorgray
title2: Final State - Collection

 

...