30
Describing LDP Applications with the Hydra Core Vocabulary Nandana Mihindukulasooriya, and Raúl García-Castro Ontology Engineering Group (OEG) Facultad de Informática Universidad Politécnica de Madrid

Describing LDP Applications with the Hydra Core Vocabulary

Embed Size (px)

Citation preview

Describing LDP Applications with the Hydra Core Vocabulary

Nandana Mihindukulasooriya, and Raúl García-Castro

Ontology Engineering Group (OEG)

Facultad de Informática

Universidad Politécnica de Madrid

2

Linked Data Platform 1.0

Nandana Mihindukulasooriya, OEG

3

An example application

Nandana Mihindukulasooriya, OEG

• An address book – for managing contacts• Contacts

• Create, List, Update, Delete• User

• Retrieve

Alice<<user>>

Alice’s Address Book Alice’s

Contacts

4

Address Book

Nandana Mihindukulasooriya, OEG

Address BookApplication

Address BookClient

5

Domain Model

Nandana Mihindukulasooriya, OEG

AddressBook Contact

•email •fullName•telephone•url

User

•name •title

Schema Restrictions• Data types• Cardinalities

6

LDP Model

Nandana Mihindukulasooriya, OEG

«BasicContainer»AddressBook

/{personId}/contacts/

«LDPResource»Contact

ldp:contains

/{personId}/contacts/{contactId}

«LDPResource»User

/{personId}/

foaf:primaryTopic

vcard:Email

vcard:Voice

rdfs:Resourcevcard:hasURL

xsd:string

vcard:hasEmail

vcard:hasTelephone

vcard:fn

xsd:string

foaf:name

7

Application

Nandana Mihindukulasooriya, OEG

Address BookApplication

Address BookClient

8

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: text/turtle

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtle, application/ld+jsonContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

9

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: text/turtle

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtleContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

supports LDP Basic Container interactions

10

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: text/turtle

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtle, application/ld+jsonContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

supports the mentioned HTTP operations on this resource

11

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: text/turtle

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtle, application/ld+jsonContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

Turtle and JSON-LD media types are accepted on POST

12Nandana Mihindukulasooriya, OEG

http://kristenbloggen.net/wp-content/uploads/good.jpg

13

LDP Container - POST

Nandana Mihindukulasooriya, OEG

POST /nandana/contacts/ HTTP/1.1Host: example.orgSlug: janeLink: <http://www.w3.org/ns/ldp#Resource>; rel='type'Content-Type: text/turtle

@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .

< > a ex:Contact, vcard:Individual; vcard:hasURL <http://example.org/jane#me> ; vcard:hasEmail <mailto:[email protected]>; vcard:fn “Jane Doe"; vcard:hasTelephone [ a vcard:Home, vcard:Voice; vcard:hasValue <tel:+34655555555> ] .

expected Input(vocabulary, cardinalities)

supports Slug header

14

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: text/turtle

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtle, application/ld+jsonAccept-Patch: text/ldpatchContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

Hypermedia controls

15Nandana Mihindukulasooriya, OEG

http://www.teresacommunicates.com/wp-content/uploads/2014/01/i-can-do-this.jpg

16

LDP Container - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: application/vnd.ldp.addressbook+turtle

HTTP/1.1 200 OK Content-Type: application/vnd.ldp.addressbook+turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: application/vnd.ldp.contact+turtle; Accept-Patch: text/ldpatchContent-Length: 250

@prefix ldp: <http://xmlns.com/foaf/0.1/> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

17

LDP Container V1 - GET

Nandana Mihindukulasooriya, OEG

GET /alice/contacts/ HTTP/1.1Host: example.orgAccept: application/vnd.ldp.addressbook.v1+turtle

HTTP/1.1 200 OK Content-Type: application/vnd.ldp.addressbook.v1+turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel='type', <http://www.w3.org/ns/ldp#Resource>; rel='type’ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: application/vnd.ldp.contact.v1+turtle; Accept-Patch: text/ldpatchContent-Length: 250

@prefix ldp: <http://xmlns.com/foaf/0.1/> .@prefix dc: <http://purl.org/dc/terms/> .@prefix dc: <http://example.org/vocab#> .

<http://example.org/contacts/> a ex:AddressBook, ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

18Nandana Mihindukulasooriya, OEG

19

Hydra Core Vocabulary

Nandana Mihindukulasooriya, OEG

20

LDP Container – GET /w Hydra API Link relation

Nandana Mihindukulasooriya, OEG

HTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel=“type”,

<http://www.w3.org/ns/ldp#Resource>; rel=“type”Link: <http://example.com/doc/>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"ETag: W/'123456711'Allow: OPTIONS, HEAD, GET, POSTAccept-Post: text/turtle, application/ld+jsonAccept-Patch: text/ldpatchContent-Length: 250

@prefix ldp: <http://www.w3.org/ns/ldp#> .@prefix dc: <http://purl.org/dc/terms/> .

<http://example.org/contacts/> a ldp:BasicContainer; foaf:primaryTopic <http://example.org/alice>; ldp:contains <bob>, <jim> .

21

API Documentation

Nandana Mihindukulasooriya, OEG

{ "@context": [ "http://www.w3.org/ns/hydra/context.jsonld", {…} ], "@id": "http://example.org/docs/", "@type": "ApiDocumentation", "title": "LDP Address Book API", "entrypoint": "http://example.org/contacts/", "supportedClass": [

{ "@id": "ex:AddressBook", "@type": "hydra:Class", "subClassOf": "ldp:BasicContainer", "label": "An example address book", … },….],

22

API Documentation

Nandana Mihindukulasooriya, OEG

{ "supportedClass": [

{ "@id": "ex:AddressBook", "@type": "hydra:Class", "subClassOf": "ldp:BasicContainer", "label": "An example address book", "supportedOperation": [ { "@id": "_:create_new_contact", "@type": "hydra:Operation", "method": "POST", "label": "creates a new contact in the address book", "description": null, "expects": “ex:Contact", "returns": null, "statusCodes": [ … ] },

23

API Documentation

Nandana Mihindukulasooriya, OEG

{ "supportedClass": [

{ "@id": "ex:AddressBook", "@type": "hydra:Class", "subClassOf": "ldp:BasicContainer", "label": "An example address book", "supportedOperation": [ { "@id": "_:create_new_contact", "@type": "hydra:Operation", "method": "POST", "label": "creates a new contact in the address book", "description": null, "expects": “ex:Contact", "returns": null, "statusCodes": [ … ] },

24

API Documentation

Nandana Mihindukulasooriya, OEG

{ "supportedClass": [ …..

{ "@id": "ex:Contact", "@type": "hydra:Class", "subClassOf": “vcard:Individual", "label": “A contact", " supportedProperty": [ { "property": “vcard:hasEmail", "hydra:title": “Email”, "hydra:description": “Email of the contact", "required": true, "readable": true, "writable": false, },

25

Potential Conflicts

• Similar concepts in LDP and Hydra

• LDP Containers Vs Hydra Collections

• LDP Paging Vs Hydra Paged Collections

Nandana Mihindukulasooriya, OEG

26

Collections vs Containers

Nandana Mihindukulasooriya, OEG

@prefix hydra: <http://www.w3.org/ns/hydra/core#>

<http://example.org/alice/contacts> a hydra:Collection ; hydra:member <http://example.org/alice/contacts/bob>, <http://example.org/alice/contacts/jane> .

• Hydra Collection

• LDP Container

@prefix ldp: <http://www.w3.org/ns/ldp#> .

<http://example.org/alice/contacts> a ldp:BasicContainer ; ldp:contains <http://example.org/alice/contacts/bob>, <http://example.org/alice/contacts/jane> .

27

Hydra collection as an LDP Direct Container

Nandana Mihindukulasooriya, OEG

@prefix hydra: <http://www.w3.org/ns/hydra/core#> .@prefix ldp: <http://www.w3.org/ns/ldp#> .

<http://example.org/alice/contacts> a hydra:Collection, ldp:DirectContainer; ldp:membershipResource <>; ldp:hasMemberRelation hydra:member;

ldp:contains <http://example.org/alice/contacts/bob>,<http://example.org/alice/contacts/jane> ;

hydra:member <http://example.org/alice/contacts/bob>, <http://example.org/alice/contacts/jane> ;

28

LDP Paging

Nandana Mihindukulasooriya, OEG

GET /nandana?page2 HTTP/1.1Host: example.orgAccept: text/turtlePrefer: return=representation; max-triple-count="500"

HTTP/1.1 200 OKContent-Type: text/turtleETag: "_87e52ce291112"Link: <http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#Page>; rel="type"Link: <http://example.org/alice/contacts?p=3>; rel="next"Link: <http://example.org/alice/contacts>; rel="canonical"; etag="_87e5"Link: <http://example.org/alice/contacts?page1>; rel="first"Link: <http://example.org/alice/contacts?p=4>; rel="last"Link: <http://example.org/alice/contacts?page1>; rel="prev"Allow: GET,OPTIONS,HEAD

29

Hydra PagedCollection

Nandana Mihindukulasooriya, OEG

@prefix hydra: <http://www.w3.org/ns/hydra/core#> .@prefix ldp: <http://www.w3.org/ns/ldp#> .

{ "@context": "http://www.w3.org/ns/hydra/context.jsonld", "@id": "http://example.org/alice/contacts?page=3", "@type": "PagedCollection", "totalItems": “50", "itemsPerPage": "10", "firstPage": "http://example.org/alice/contacts?page=1", "nextPage": " http://example.org/alice/contacts?page=4", "previousPage": "http://example.org/alice/contacts?page=2", "lastPage": "http://example.org/alice/contacts?page=5", "member": [ ... the members of this PagedCollection ... ]}

30

Conclusions

• LDP needs mechanisms for vocabulary and affordance discovery

• Hydra Core vocabulary can be used describe LDP application

• Why not just Hydra?

• There are overlaps in some areas

• Overlaps with the W3C RDF Shapes WG

Nandana Mihindukulasooriya, OEG