HydraCG / Specifications

Specifications created by the Hydra W3C Community Group
Other
138 stars 26 forks source link

Added support for strongly typed collections #240

Closed alien-mcl closed 1 year ago

alien-mcl commented 3 years ago

Summary

This pull request add some changes to the spec that should enable hydra powered APIs to describe strongly typed collections.

More details

There is an issue #233 that should be addressed by this pull request. While the changes are somehow small in numbers, there is another possibly a breaking change as one of the terms has it's domain changed.

tpluscode commented 3 years ago

Something just occurred to me. I think it we should add a paragraph describing that an instance of a strongly type can have its own member assertions. In that scenario all those assertions should be combined, right?

tpluscode commented 2 years ago

Ah, and one more, similar case. We should clarify the behaviour when there are multiple (sub)classes which may have member assertions. I'd say that clients and server should walk up the rdfs:subClassOf hierarchy and combine them all.

To sum up with an example

:ArticleCollection
  rdfs:subClassOf hydra:Collection ;
  hydra:memberAssertion [
    hydra:property rdf:type ;
    hydra:object :Article ;
  ] ;
.

:DraftArticleCollection
  rdfs:subClassOf :ArticleCollection ;
  hydra:memberAssertion [
    hydra:property :status ;
    hydra:object :Draft ;
  ] ;
.

:KarolsDraftsCollection
  rdfs:subClassOf :DraftArticleCollection ;
  hydra:memberAssertion [
    hydra:property acl:owner ;
    hydra:object </person/Karol> ;
  ] ;
.

</person/Karol/drafts> a :KarolsDraftsCollection .

By combining all the member assertions above we could generate a query like below to find all members of the resource </person/Karol/drafts>.


SELECT ?member {
  </person/Karol/drafts> hydra:member ?member .

  # asserted by :ArticleCollection 
  ?member a :Article .

  # asserted by :DraftArticleCollection
  ?member :status :Draft .

  # asserted by :KarolsDraftsCollection
  ?member acl:owner </person/Karol> .
}
alien-mcl commented 2 years ago

I've added both paragraphs, but I think clients should not be overweighed with such a complex tasks as class hierarchy traversing.

alien-mcl commented 2 years ago

@tpluscode could you please review changes you've requested? I've got another bunch of changes made on this branch I'd like to proceed with (brand new diagram and made the terms stable rather than testing)