[Pinto] On marshalling collections and the right way to do things

27 views
Skip to first unread message

Ray Rashif

unread,
Mar 20, 2017, 7:07:56 AM3/20/17
to Empire
Hi all

I've been using Pinto for some time now but I'm not really sure if I'm doing things the right way, mainly because I still don't know how to do certain things and need to resort to workarounds.

== Background ==
1. Java/Jersey web application
2. Sesame-compatible triple store
3. For getting a list of things, run SELECT query for returning relevant fields, selectively build the POJO (determining what attributes get set), and return
4. For creating something new, use Pinto, and additionally place the new triples in a named graph
5. For deleting something, delete the named graph
6. For getting a single object, run CONSTRUCT query, get main subject type, use Pinto, return

I am having some prblems with (3) and (4), especially because of nesting of objects that already exist (does not need to be created, they are referenced objects). Consider the example:

House
--| hasMember <Person>
------| hasName <String>
------| hasDependent <Person>
----------| hasName

If I want to return a list of houses and want to include full object details of every house (including Persons who were created in different named graphs), I can't do it, unless I really have a complex SELECT query and accompanying complex processing to recursively set nested objects and propertis. Even if I run a CONSTRUCT query akin to (6), getting the main type will fail because there are multiple different individuals in the results.

I will describe the problm with (4) later, as (3) is a more pressing concern. So once again, in one sentence: I would like to know how I should go about serializing a collection of a thing from a triple store.

Ray Rashif

unread,
Mar 20, 2017, 6:18:31 PM3/20/17
to Empire
I see that https://groups.google.com/forum/#!topic/empire-rdf/kVRvXXwTeuM deals with (3). I now do this:

- Run a very, very big CONSTRUCT query (fields and nested fields replicating the object structure)
- Iterate over the results, fetch all the subject resources that have the given RDF type, put each result statement into a graph
- Iterate over the subject resources and search the graph matching the subject resource, converting each match into an object of the given type

So all in all, this means most of the human labour is in the first step at producing a right CONSTRUCT query for the object in concern. Still, if there is any other way to do this, I'd appreciate some pointers.

Michael Grove

unread,
Mar 21, 2017, 10:27:17 AM3/21/17
to empir...@googlegroups.com
Right, that's the intent. If you need that part to be automatic, then Empire itself might be a better fit for you. Pinto is the internals of the marshalling and unmarshalling of RDF from Empire separated so it can be used for RDF like you'd use Jackson for JSON.

Cheers,

Mike
 

--
You received this message because you are subscribed to the Google Groups "Empire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to empire-rdf+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages