cyberborean / rdfbeans

Java persistence with RDF
Other
11 stars 12 forks source link

Make use of RDF4J contexts #20

Open cyberborean opened 7 years ago

cyberborean commented 7 years ago

ATM, all operations on RDFBeans are performed with no associated context, thus the nature of RDF4J as a quad store is ignored.

It should be possible to point RDFBeanManager to use specific context of RDF4J repository, e.g. by using an optional constructor argument.

cyberborean commented 6 years ago

TBD: update Javadoc and tutorial

twallmey commented 5 years ago

Hi! I'm very interested in this new feature. Would it be possible to release a new version that can be downloaded via Maven? A development version would already be fine for me at this moment.

Maybe you could just add a compiled jar file to github?

Cloned source code and compiled jar on my own. So no real need to supply a compiled jar file anymore. Nevertheless, it may be useful for other developers in future as well.

cyberborean commented 5 years ago

Build of the current develop branch is available on OSSRH/snaphots as 2.3-SNAPSHOT

cyberborean commented 5 years ago

In the commit above, the context management API is redesigned in the following way:

RDFBeanManager manager = new RDFBeanManager(repo);

// adds an object to the default context:
manager.add(person); 

// adds an object to another context:
manager.getContext(new URIImpl("urn:uri:context1")).add(person); 

// retrieves an object from default context:
Person person = manager.get(uri, Person.class);

// retrieves an object from specified context:
Person person = manager.getContext(new URIImpl("urn:uri:context1")).get(uri, Person.class);

// creates a proxy stored in the default context
IPerson person = manager.create(uri, IPerson.class);

// creates a proxy stored in another context
IPerson person = manager.getContext(new URIImpl("urn:uri:context1")).create(uri, IPerson.class);
twallmey commented 5 years ago

Hi,

just checked the new version and detected that the following method got lost:

public <T> T create(String id, Class<T> iface, Resource... contexts) throws RDFBeanException, RepositoryException The above method was available within RDFBeanManager but is currently not available in RDFBeanManagerContext. Within the new class it is only the version without the additional context parameter provided:

public <T> T create(String id, Class<T> iface) throws RDFBeanException, RepositoryException {

The same applies analogous for method createAll()

Could you pls. check and (re)add the missing method(s)?

Thanks a lot!

cyberborean commented 5 years ago

In new version, you get a RDFBeanManagerContext instance for specific context and invoke its methods: so no context parameter is needed (see the examples above).

twallmey commented 5 years ago

Thanks for your hint. It is working like a charm.