Claudenw / PA4RDF

functionality on top of an RDF store while accounting for and exploiting the fundamental differences between graph storage and relational storage. PA4RDF introduces three (3) annotations that map a RDF triple (subject, predicate, object) to a Plain Old Java Object (POJO) using Java's dynamic proxy capabilities.
12 stars 0 forks source link

Be able to get the uri within the object #1

Closed parisni closed 9 years ago

parisni commented 9 years ago

Hello Claude,

I wonder if it would be possible to get the pojo uri from an instance. Eg:

 Model model = ModelFactory.createModel();
 EntityManager entityManager = EntityManagerFactory.getEntityManager();
 Resource r = model.createResource( "http://example.com/mylibrary/book1" );
 Book book = EntityManager.read( r, Book.class );
 System.out.println("my uri is : %s",String.format(book.getUri());
// prints http://example.com/mylibrary/book1

In my use case (I serialyse your pojos as json), the uri could be used as unique id (or the instance identifier).

Thanks for all,

Claudenw commented 9 years ago

i am writing this while on holiday but as i recall the returned object implements ResourceWrapper. if your interface extends that it makes it easy to call get GetResource().getUri(). if you dont implement ResourceWrapper you can cast your object to a ResourceWriter and then call getResource()

Claude On Sep 2, 2015 6:27 p.m., "Paris Nicolas" notifications@github.com wrote:

Hello Claude,

I wonder if it would be possible to get the pojo uri from an instance. Eg:

Model model = ModelFactory.createModel(); EntityManager entityManager = EntityManagerFactory.getEntityManager(); Resource r = model.createResource( "http://example.com/mylibrary/book1" ); Book book = EntityManager.read( r, Book.class ); System.out.println("my uri is : %s",String.format(book.getUri()); // prints http://example.com/mylibrary/book1

In my use case (I serialyse your pojos as json), the uri could be used as unique id (or the instance identifier).

Thanks for all,

— Reply to this email directly or view it on GitHub https://github.com/Claudenw/PA4RDF/issues/1.

parisni commented 9 years ago

Sorry for having disturbed holiday, and thanks for the tip !

Claudenw commented 9 years ago

Did that solve your problem? Were you able to use either solution?

Claude

On Fri, Sep 4, 2015 at 6:28 PM, Paris Nicolas notifications@github.com wrote:

Sorry for having disturbed holiday, and thanks for the tip !

— Reply to this email directly or view it on GitHub https://github.com/Claudenw/PA4RDF/issues/1#issuecomment-137799266.

I like: Like Like - The likeliest place on the web http://like-like.xenei.com LinkedIn: http://www.linkedin.com/in/claudewarren

parisni commented 9 years ago

Yes, it solved the problem in a clean way thanks again

Claudenw commented 9 years ago

Issue resolved with use of ResourceWrapper interface as described in comment stack.