HydraCG / Specifications

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

Add support for allowed literals and allowed individuals #82

Open dschulten opened 9 years ago

dschulten commented 9 years ago

Currently there is no way in hydra to express a fixed number of possible values.

There seem to be no other established vocabularies which allow us to do so. At some point the RDF Shape WG shall provide a comprehensive way to express this and other constraints which then would supersede this proposal., But I think we need this earlier and I hope that hydra can provide valuable input to the Resource Shape WG by introducing such a facility which also integrates well with json-ld.

Proposal: Have the following new properties and classes.

FIrst, hydra:allowedIndividual for enum values or other individuals with optional localized hydra:title to solve the value vs. caption problem.

* hydra:allowedIndividual :range hydra:AllowedIndividual - to hold the allowed individuals
  * hydra:AllowedIndividual - wrapper for allowed individuals with localized title
  * hydra:individual :domain hydra:AllowedIndividual - allowed URI values for a supported property

The :individual is for allowed values which are URIs, it should be used to apply @type:@vocab in the context. Sample usage below. Client has requested Italian. The other language constructs of json-ld would work, too, see sample jsonld playgrounds below.

{
  "@context": {
      "@vocab": "http://schema.org/",
      "hydra": "http://www.w3.org/ns/hydra/core#",
      "hydra:individual": {
        "@type": "@vocab"
      }
  }
  ...
  "hydra:supportedProperty": [
      {
      "hydra:property": "eventStatus",
      "hydra:allowedIndividual": [
        {
          "hydra:individual": "EventCancelled",
          "hydra:title": "manifestazione annullata"
        },
        {
          "hydra:individual": "EventPostponed",
          "hydra:title": "manifestazione rinviata"
        } 
      ]
    }
  ]
}  

Second, hydra:allowedLiteral is for scalar values like strings or numbers.

* hydra:allowedLiteral - allowed literal values for a supported property

Finally, by dereferencing hydra:allowedResource the client can get a Collection or PagedCollection of allowed individuals which may have a search property in turn. This would be useful in case the number of allowed individuals is too large for :allowedIndividual.

* hydra:allowedResource - Resource or IriTemplate to retrieve allowedIndividuals

Also see http://tinyurl.com/qz85ep6 for a real-life JSON-LD playground example of allowedIndividual vs. allowedLiteral. On http://tinyurl.com/om7fsqc one can see a language map. On http://tinyurl.com/px4aj75 one can see an illustration for allowedResource with IriTemplate.

RubenVerborgh commented 9 years ago

Isn't that part of ontological modelling, and thus part of the property?

PS What is the Hydra mailing list thread for this?

dschulten commented 9 years ago

Hi Ruben,

I do not think the ontological model of a property covers it. On the one hand, sometimes not all possible values are predefined, but they may be extensible by individuals from other vocabs, see the usage of goodrelations enums from schema.org. On the other hand, while a value might occur on a class in general, it might not be suitable in a particular context. If you think rdfs:range, it is not about value constraints but inference, so it doesn't enumerate possible values at all (I've learned that much by now). Or do you have something else in mind?

I'll add the corresponding mailing list thread url later, it is there, albeit somewhat nested.

Cheers, Dietrich

---- Ruben Verborgh schrieb ----

Isn't that part of ontological modelling, and thus part of the property?

PS What is the Hydra mailing list thread for this?

— Reply to this email directly or view it on GitHub.

RubenVerborgh commented 9 years ago

I replied on-list.

alien-mcl commented 5 years ago

I think @RubenVerborgh is right and allowed individuals in most cases are topic for modelling. I can see at least two options here:

In both cases, it doesn't have anything to do with hydra itself - it is enabled for structure and their properties description with supportedProperty predicate.

Yet, I can see one more situation - imagine a form i.e. for adding products to the shop. In a field for category, I'd like to to have a pointer (i.e. IRI templated link) that should pull categories for that very field (which would take into account current product details). This is not a topic for modelling and I do not see a clear way of doing it with hydra yet. Any ideas for that one?

alien-mcl commented 5 years ago

Another example would be an issue tracker and a form of a new issue with possibility of assigning users to it - I'd like to have an link given to a place that would pull a list of suitable users (i.e. in context of the current project a new issue is related to). I do not see any quick resolution in hydra as it is now. Possibly new vocabulary element would be necessary to cover this scenario - any ideas?