Closed mb21 closed 10 years ago
Hi Mauro,
This isn’t really the right place to discuss this (it would be better to discuss it on our mailing list) but the answer is simple:
vocab:EntryPoint/issues is a hydra:Link, i.e., a property whose value is a dereferenceable resource (or in other words, a URL). rdfs:range does not define the type of vocab:EntryPoint/issues but the type of values thereof. In this case it tells you that all values of vocab:EntryPoint/issues are instances of hydra:Collection.
If [issues is both Link and Collection, it] would tie in with the fact that the domain of hydra:supportedOperation seems to include both hydra:Class and hydra:Link, which I find rather confusing as well. It's not intuitive to me why operations can be defined on links.
Just as with classes, the operations defined with hydra:supportedOperation don't apply on the class/link itself but on instances of that class/values (or targets) of that link. So if you have
MyClass rdf:type hydra:Class MyClass hydra:supportedOperation o1
then o1 applies to all resources ?x that are
?x rdf:type MyClass
Similarly, for links
myLink rdf:type hydra:Link myLink hydra:supportedOperation o2
the operation o2 applies to all resources ?y if they are used with that link (regardless of what ?? is)
?? myLink ?y
For example in Example 10 in the spec. When I do a POST with a new comment to /comments, I'm not creating the link /comments, instead I'm adding a new instance of a class that happens to be returned when following the link.
Right. As outlined above the operation doesn't apply to the link property but to /comments, which is also why you post to /comments instead of /vocab
Hi Markus,
Oh, thanks a lot for your explanation! That makes sense. So the operations listed in hydra:supportedOperation
apply either to the target of the link, or the instances of the class respectively.
I think I got confused because of the JSON-LD @type
property. Did I get this correctly now?
In addition to the usage of "@type": "@"id"
, the @type
keyword can also be used to specify the node type of the object. Specifying node types cannot be done in the context.
{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://manu.sporny.org/me",
"@type": "schema:Person", ← Means that <http://manu.sporny.org/me> has rdf:type schema:Person
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
}
@type
can even be used in a third way: to specify the value type of literals, like the values of "name" and "modified". And specifying value types can be done either in the context or inline:
{
"@context": {
"name": {
"@id": "http://schema.org/name",
"@type": "http://www.w3.org/2001/XMLSchema#string" ← define value type in context
},
"modified": {
"@id": "http://purl.org/dc/terms/modified"
}
},
"@id": "http://manu.sporny.org/me",
"name": "Manu Sporny",
"modified": {
"@type": "http://www.w3.org/2001/XMLSchema#dateTime", ← can also define value type inline
"@value": "2010-05-29T14:17:39+02:00" ← and then the value itself
}
}
I think I got confused because of the JSON-LD @type property. Did I get this correctly now?
Yep.
Great! :) Finally: is the intended usage, that I might have a vocab:User
be both a hydra:Class
and a schema:Person
? Or would you recommend setting up a mapping from the user herself to her representation as a hydra:Class
?
btw, I wrote up this small JSON-LD tutorial to spell some things out for me, might help other people as well... (corrections?)
After some cleanup, the result of
is:
But within
you find:
So is
vocab:EntryPoint/issues
really both, ahydra:Collection
and ahydra:Link
?If it is, that would tie in with the fact that the domain of
hydra:supportedOperation
seems to include bothhydra:Class
andhydra:Link
, which I find rather confusing as well. It's not intuitive to me why operations can be defined on links. For example in Example 10 in the spec. When I do aPOST
with a new comment to/comments
, I'm not creating the link/comments
, instead I'm adding a new instance of a class that happens to be returned when following the link.