Swirrl / tripod

ActiveModel-style Ruby ORM for RDF Linked Data. Works with SPARQL 1.1 HTTP endpoints.
MIT License
58 stars 14 forks source link

Criteria option for links #18

Open fonji opened 11 years ago

fonji commented 11 years ago

Hello, me again!

I'd like to have a criteria option for the links. To understand why: I have disorders in classifications. Disorders are in a multi-tree and in multiple classifications. So every disorder has a SKOS:inScheme for each corresponding classification and a SKOS:broader for each of its parents.

I need to get the top-level disorders of a classification. For the moment, I have no other way to define this in the repository than "it's the disorders in this classification without a broader element". (ultimately it might even be worse than that as the disorder might have broader elements only in other classifications... but let's keep it kinda simple for now.) This results with this criteria:

Disorder.where("?uri <#{RDF::SKOS.inScheme}> <#{uri}>").where("FILTER(NOT EXISTS { ?uri <#{RDF::SKOS.broader}> ?node })").resources

I'd like to do this within a linked_from... I'm not sure that it's such a good idea as it would be (almost) impossible to check / ensure the condition when items are added to the collection. It might still be nice for read-only purposes. And I'm allowed to dream. But I'll understand if you refuse this issue :)