joshsh / sesametools

A collection of utilities for use with OpenRDF Sesame (as of recently, Eclipse RDF4J)
Other
50 stars 11 forks source link

RDF List utility class for fetching and putting Lists into Graph's #17

Closed ansell closed 13 years ago

ansell commented 13 years ago

Added an RDF List utility to make it simple to fetch Lists from Graph's and push new lists into graphs, along with a test case.

Also converted the -1, 0 and 1 values in ValueComparator to the constants BEFORE, EQUALS, and AFTER for readability.

joshsh commented 13 years ago

Hi Peter. Good call putting this in SesameTools. I have analogous code in Ripple which this can eventually replace; it will be nice to have list read/write operations which depend on nothing except the Sesame API. One thing I do differently in Ripple, though, is to produce multiple Lists on read. A given resource might not resolve to any List at all, as you note, and it may resolve to multiple Lists (e.g. if there are multiple rdf:first or rdf:rest statements for any node. Forking lists are odd and uncommon, but perfectly permissible as far as RDF semantics are concerned (see http://www.w3.org/TR/rdf-mt/#collections).

In other words, what do you think of getList becoming getLists and returning a Collection of Lists? Do you think that would make the API too confusing? I could contribute code to handle forking, not that it's difficult.

ansell commented 13 years ago

As it also says in the RDF Semantics spec, other systems can impose semantic constraints, and a getList method seems to be the most obvious constraint.

I think it would be useful to keep the single getList method to match the addList method and add another method to get peculiar lists that do not directly correspond to a single (ie, no forking) Java List. A getLists method would still return a collection with the single list as getList for a non-forked and single headed case, so there would be compatibility between the two methods.

In addition, I would prefer two methods so that we can keep exception throwing for people who only expect one list and want to fail quickly if more than one list would be entailed from the RDF Graph.

joshsh commented 13 years ago

Sounds good.