I started a new branch jsonld-java:

https://github.com/apache/incubator-commonsrdf/tree/jsonld-java/jsonld-java

This adds an RDFTermFactory and graph mapping for

https://github.com/jsonld-java/jsonld-java

(I've not done the parser yet - but as you've noticed the Travis
reports I thought to let you know what I'm up to!)


Basically a 
https://github.com/apache/incubator-commonsrdf/blob/jsonld-java/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java

mirrors a RDFDataset in jsonld-java and maps its Quads to Commons RDF
Triples (and vice versa).

As JSON-LD is Quad-based, but Commons RDF don't yet have a Quad or
Dataset interface, it only considers quads in the "@default" graph
(unless the unionGraph boolean is set) as part of the Graph.



It's not a particular efficient memory triple store considering
jsonld-java currently relies heavily on Lists of Maps, but - but I
think this branch is a good way to explore the (de)serializers
interface I started on in the parser-writer-interface branch -- as you
could then use Commons RDF APIs to
create a JsonLdGraph and then serialize it as JSON-LD (or vice versa)
or choose to do further JSON-LD processing (e.g. compacting it in a
particular context).


It also showed me that the unit tests of AbstractGraphTest are up to
the job - e.g. they detected that if I retrieved a Triple with a blank
node and then tried to remove it with graph.remove(Triple), it no
longer matched as I had accidentally double-wrapped the
uniqueReference() on such a round trip between native and Commons RDF
types.

(All tests should now pass - but there's a compiler error with Oracle
JDK 8 on Travis that I don't quite understand)


As the API of jsonld-java is a bit sparse in terms of graph
manipulation this is a bit too low-level integration for my liking -
so if this works it should probably belong better within the
jsonld-java code base - e.g. RDFDataset does not support removal of
quads directly, and I had to do:

https://github.com/apache/incubator-commonsrdf/blob/jsonld-java/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java#L169


This raises good questions about Quads which I think we should also
think about - e.g. if we imply make a Dataset as a subclass of Graph,
and Quad a subclass of Triple,  then does .size() and .contains()
relate to only the default graph or all the quads?

And if I parse a quad-based format like JSON-LD file into a Graph -
should I only get the default graph triples - or should there be a
parser setting to get the union graph?


-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718

Reply via email to