RE: relate a Collection and a PagedCollection

On 1 Okt 2014 at 13:56, ☮ elf Pavlik ☮ wrote:
> On 04/25/2014 07:29 PM, Markus Lanthaler wrote:
>> On Friday, April 25, 2014 6:34 PM, Ruben Verborgh wrote:
>>>> To illustrate, we might return something like the following:
>>>> 
>>>> </collection> a hydra:PagedCollection;
>>>>  hydra:member <1>, <2>, ...;
>>>>  hydra:nextPage </collection?page=2>;
>>>>  hydra:pageOf </collection#dataset> .
>>>> <collection#dataset> a hydra:Collection;
>>>>  hydra:totalItems 243;
>>>>  hydra:itemsPerPage 10;
>>>>  hydra:firstPage </collection>;
>>>>  hydra:lastPage </collection?page=24> .
>>>>
>>>> I think this is pretty close to what you originally proposed. This does
>>>> allow for a certain
>>> amount of semantic purity, but practically doesn't do more for me than
>>> just collapsing the dataset properties down to the PagedCollection (or
>>> CollectionPage, if you
>> prefer).
>> 
>> Yeah. I agree. Let me convert this to JSON-LD because I think that will be
>> easier for a lot of people on this list to understand and evaluate. Here's
>> Gregg's Turtle converted 1:1, the first page is the "central" resource:
>> 
>>   {
>>     "@id": "/collection",
>>     "@type": "Page(dCollection)",
>>     "member": [ "1", "2", "..." ],
>>     "nextPage": /collection?page=2",
>>     "pageOf": {
>>       "@id": "/collection#dataset",
>>       "@type": "Collection",
>>       "totalItems": 243,
>>       "itemsPerPage": 10,
>>       "firstPage": "/collection",
>>       "lastPage": "/collection?page=24"
>>     }
>>   }
>> This has the advantage that the representations of all pages would look more
>> or less the same. The downside is, that you would have to link to
>> /collection#dataset instead of just /collection. So it would be
>> 
>>   {
>>     "@id": "markus",
>>     "knows": "/friend-collection#dataset"
>>   }
>> An alternative serialization could put the collection itself at the center
>> (please note that I changed the resource identifiers):
>> 
>>   {
>>     "@id": "/collection",
>>     "@type": "Collection",
>>     "totalItems": 243,
>>     "itemsPerPage": 10,
>>     "firstPage": {
>>       "@id": "/collection#page",
>>       "@type": "Page(dCollection)",
>>       "member": [ "1", "2", "..." ],
>>       "nextPage": /collection?page=2",
>>       "pageOf": "/collection"
>>     },
>>     "lastPage": "/collection?page=24"
>>   }
>> The disadvantage here is that while it looks nice for the first page, it
>> kind of breaks down for all other pages.
> 
> how about:
> 
> * PagedCollection SHOULD embed it's first Page
> 
>    {
>      "@id": "/collection",
>      "@type": "PagedCollection",
>      "totalItems": 243,
>      "itemsPerPage": 10,
>      "firstPage": {
>        "@id": "/collection?page=1",
>        "@type": "Page",
>        "member": [ "1", "2", "..." ],
>        "nextPage": /collection?page=2",
>        "pageOf": "/collection"
>      },
>      "lastPage": "/collection?page=24"
>    }
> * Page SHOULD embed PagedCollection it belongs to
> 
>    {
>      "@id": "/collection?page=1",
>      "@type": "Page",
>      "member": [ "1", "2", "..." ],
>      "nextPage": /collection?page=2",
>      "pageOf": {
>        "@id": "/collection",
>        "@type": "PagedCollection",
>        "totalItems": 243,
>        "firstPage": "/collection?page=2",
>        "lastPage": "/collection?page=24"
>        "itemsPerPage": 10
>      }
>    }
>
> using PagedCollection (subclasOf: Collection) for fristPage and itemsPerPage

This is certainly an option as well but it has the same "issue" as the one I outlined above. The structure etc. changes quite a bit when you go from non-paged collection to a paged collection. In HTML, Atom, and most JSON-based Web APIs I've seen the structure stays exactly the same... only "next", "last" etc. links are added.

Let's try to finish the IriTemplate design first (I'll re-read the discussions we had and send out a mail tonight or tomorrow) and then address paged collections. How does that sound?


Cheers,
Markus


--
Markus Lanthaler
@markuslanthaler

Received on Thursday, 2 October 2014 11:44:15 UTC