Skip to content

Commit

Permalink
Update Hydra Core Vocabulary to the new pagination design
Browse files Browse the repository at this point in the history
This closes #42.
  • Loading branch information
lanthaler committed Oct 28, 2015
1 parent 8b3e7f6 commit 225aa51
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 60 deletions.
82 changes: 41 additions & 41 deletions spec/latest/core/core.jsonld
Expand Up @@ -39,13 +39,13 @@
"member": { "@id": "hydra:member", "@type": "@id" },
"search": "hydra:search",
"freetextQuery": "hydra:freetextQuery",
"PagedCollection": "hydra:PagedCollection",
"view": { "@id": "hydra:view", "@type": "@id" },
"PartialCollectionView": "hydra:PartialCollectionView",
"totalItems": "hydra:totalItems",
"itemsPerPage": "hydra:itemsPerPage",
"firstPage": { "@id": "hydra:firstPage", "@type": "@id" },
"lastPage": { "@id": "hydra:lastPage", "@type": "@id" },
"nextPage": { "@id": "hydra:nextPage", "@type": "@id" },
"previousPage": { "@id": "hydra:previousPage", "@type": "@id" },
"first": { "@id": "hydra:first", "@type": "@id" },
"last": { "@id": "hydra:last", "@type": "@id" },
"next": { "@id": "hydra:next", "@type": "@id" },
"previous": { "@id": "hydra:previous", "@type": "@id" },
"Link": "hydra:Link",
"TemplatedLink": "hydra:TemplatedLink",
"IriTemplate": "hydra:IriTemplate",
Expand Down Expand Up @@ -336,72 +336,72 @@
"vs:term_status": "testing"
},
{
"@id": "hydra:PagedCollection",
"@id": "hydra:view",
"@type": "hydra:Link",
"label": "view",
"comment": "A specific view of a resource.",
"domain": "hydra:Resource",
"range": "hydra:Resource",
"vs:term_status": "testing"
},
{
"@id": "hydra:PartialCollectionView",
"@type": "hydra:Class",
"subClassOf": "hydra:Collection",
"label": "PagedCollection",
"comment": "A PagedCollection is a subclass of Collection with the only difference that its members are sorted and only a subset of all members are returned in a single PagedCollection. To get the other members, the nextPage/previousPage properties have to be used.",
"subClassOf": "hydra:Resource",
"label": "PartialCollectionView",
"comment": "A PartialCollectionView describes a partial view of a Collection. Multiple PartialCollectionViews can be connected with the the next/previous properties to allow a client to retrieve all members of the collection.",
"vs:term_status": "testing"
},
{
"@id": "hydra:totalItems",
"@type": "rdf:Property",
"label": "total items",
"comment": "The total number of items referenced by a collection or a set of interlinked PagedCollections.",
"comment": "The total number of items referenced by a collection.",
"domain": "hydra:Collection",
"range": "xsd:integer",
"vs:term_status": "testing"
},
{
"@id": "hydra:itemsPerPage",
"@type": "rdf:Property",
"label": "items per page",
"comment": "The maximum number of items referenced by each single PagedCollection in a set of interlinked PagedCollections.",
"domain": "hydra:PagedCollection",
"range": "xsd:integer",
"vs:term_status": "testing"
},
{
"@id": "hydra:firstPage",
"@id": "hydra:first",
"@type": "hydra:Link",
"label": "first page",
"comment": "The first page of an interlinked set of PagedCollections",
"domain": "hydra:PagedCollection",
"range": "hydra:PagedCollection",
"label": "first",
"comment": "The first resource of an interlinked set of resources.",
"domain": "hydra:Resource",
"range": "hydra:Resource",
"vs:term_status": "testing"
},
{
"@id": "hydra:lastPage",
"@id": "hydra:last",
"@type": "hydra:Link",
"label": "last page",
"comment": "The last page of an interlinked set of PagedCollections",
"domain": "hydra:PagedCollection",
"range": "hydra:PagedCollection",
"label": "last",
"comment": "The last resource of an interlinked set of resources.",
"domain": "hydra:Resource",
"range": "hydra:Resource",
"vs:term_status": "testing"
},
{
"@id": "hydra:nextPage",
"@id": "hydra:next",
"@type": "hydra:Link",
"label": "next page",
"comment": "The page following the current instance in an interlinked set of PagedCollections",
"domain": "hydra:PagedCollection",
"range": "hydra:PagedCollection",
"label": "next",
"comment": "The resource following the current instance in an interlinked set of resources.",
"domain": "hydra:Resource",
"range": "hydra:Resource",
"vs:term_status": "testing"
},
{
"@id": "hydra:previousPage",
"@id": "hydra:previous",
"@type": "hydra:Link",
"label": "previous page",
"comment": "The page preceding the current instance in an interlinked set of PagedCollections",
"domain": "hydra:PagedCollection",
"range": "hydra:PagedCollection",
"label": "previous",
"comment": "The resource preceding the current instance in an interlinked set of resources.",
"domain": "hydra:Resource",
"range": "hydra:Resource",
"vs:term_status": "testing"
},
{
"@id": "hydra:search",
"@type": "hydra:TemplatedLink",
"label": "search",
"comment": "A IRI template that can be used to query a collection",
"comment": "A IRI template that can be used to query a collection.",
"range": "hydra:IriTemplate",
"vs:term_status": "testing"
},
Expand Down
42 changes: 23 additions & 19 deletions spec/latest/core/index.html
Expand Up @@ -647,7 +647,7 @@ <h3>Collections</h3>
a set of somehow related resources. Results of a search query or
entries of an address book are just two examples. To simplify such
use cases, Hydra defines the two classes <i>hydra:Collection</i> and
<i>hydra:PagedCollection</i>.</p>
<i>hydra:PartialCollectionView</i>.</p>

<p>A <i>hydra:Collection</i> can be used to reference a set of resources
as follows:</p>
Expand All @@ -659,6 +659,7 @@ <h3>Collections</h3>
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://api.example.com/an-issue/comments",
****"@type": "Collection"****,
****"totalItems": "4980"****,
****"member"****: [
{
"@id": "/comments/429"
Expand All @@ -681,35 +682,38 @@ <h3>Collections</h3>

<p>Since collections may become very large, Web APIs often chose to
split a collection into multiple pages. In Hydra, that can be achieved
with a <i>hydra:PagedCollection</i>. In addition to the
<i>member</i> property, a <i>PagedCollection</i> may also include
links to the <i>firstPage</i>, <i>nextPage</i>, <i>previousPage</i>,
or <i>lastPage</i> as well as information about the
<i>itemsPerPage</i> and the <i>totalItems</i> as shown in the
following example.</p>
with a <i>hydra:PartialCollectionView</i>. It describes a specific
view on the collection which represents only a subset of the collection's
members. A <i>PartialCollectionView</i> may contain links to the
the <i>first</i>, <i>next</i>, <i>previous</i>, and <i>last</i>
<i>PartialCollectionView</i> which allows a client to find all members
of a <i>Collection</i>.</p>

<pre class="example" data-transform="updateExample"
title="A Hydra PagedCollection splites a collection into multiple pages">
title="A Hydra PartialCollectionView splits a collection into multiple views">
<!--
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://api.example.com/an-issue/comments?page=3",
****"@type": "PagedCollection"****,
****"totalItems": "4980"****,
****"itemsPerPage": "10"****,
****"firstPage": "/an-issue/comments?page=1"****,
****"nextPage": "/an-issue/comments?page=4"****,
****"previousPage": "/an-issue/comments?page=2"****,
****"lastPage": "/an-issue/comments?page=498"****,
"@id": "http://api.example.com/an-issue/comments",
"@type": "Collection",
"totalItems": "4980",
"member": [
####... the members of this PagedCollection ...####
]
####... a subset of the members of the Collection ...####
],
****"view"****: {
"@id": "http://api.example.com/an-issue/comments?page=3",
****"@type": "PartialCollectionView"****,
****"first": "/an-issue/comments?page=1"****,
****"next": "/an-issue/comments?page=4"****,
****"previous": "/an-issue/comments?page=2"****,
****"last": "/an-issue/comments?page=498"****
}
}
-->
</pre>

<p class="issue">Say that all these properties are optional? What about
<i>firstPage</i> and, more interestingly, <i>lastPage</i>?</p>
<i>first</i> and, perhaps more interestingly, <i>last</i>?</p>
</section>

<section>
Expand Down
Binary file modified spec/latest/core/vocabulary.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 225aa51

Please sign in to comment.