There are some interesting issues with persistence annotations in a graph (perhaps I should present a paper/talk on it) and there are 2 distinctly difference approaches between the two PA4RDF versions. The first assumes that the complete graph is available locally (i.e. not on a remote server), the second does not make that assumption but then tries to cache the remote data as it is needed and/or modified so that it can submit proper updates to the remote. There are issues here with anonymous nodes (the Jena implementation provides a way around those). But I am not certain that the implementation is wholly correct.
I was thinking about splitting the project into the annotations and 2 distinct implementations as noted above. I have not had time to work on the project recently, but if you are interested I am certain we could work together to figure out how to make this fly. Claude On Tue, Apr 16, 2019 at 6:23 PM Dan Davis <[email protected]> wrote: > > Claude, > > I've now noticed you are actually the author of PA4RDF, and I'm wondering > what your plans are for releasing a version of PA4RDF that uses Jena 3+. > I would ask in a github issue, but I'm sure you've got one, as there are > snapshots, and it seems better to keep the conversation all together. > > On Mon, Apr 8, 2019 at 1:34 PM Dan Davis <[email protected]> wrote: > > > That is true - I was about to post that PA4RDF seems just what is needed. > > > > It is even possible that your RDF may have more properties than you expose > > at the pojo layer. The examples deal mostly with Data Properties, and no > > query language is mentioned. It is quite possible that this is not a > > deficit of the package, but of the documentation. I also note that the > > latest non-snapshot release is still on Jena 2, but that > > > > https://oss.sonatype.org/content/repositories/snapshots/org/xenei/PA4RDF/2.0-SNAPSHOT/ > > is up to date enough. > > > > On Mon, Apr 8, 2019 at 8:51 AM Claude Warren <[email protected]> wrote: > > > >> PA4RDF is an OGM. It just views the subject of triples as an > >> identifier for one or my POJOs. The properties are mapped to > >> getter/setter methods and the objects are the values. The entity > >> manager manages converting URL objects to POJOs. PA4RDF uses 2 > >> annotations, one to map the POJO to the RDF subject and the other to > >> identify the POJO properties that should be mapped to properties. > >> > >> Claude > >> > >> On Mon, Apr 8, 2019 at 7:00 AM Dan Davis <[email protected]> wrote: > >> > > >> > To me, it seems unfortunate to make the Resource do all the work, and > >> make > >> > it more than the subject of triples. Some labeled property graphs > >> define > >> > an OGM (Object/Graph Mapping). I wonder whether that concept has any > >> > bearing here. > >> > > >> > Anyway, I've wished for an OGM sort of mapping to a POJO for awhile. > >> One > >> > annotation to say its a Jena resource. Another Annotation to say which > >> > method returns its URI, and give an optional prefix. > >> > > >> > Additional annotations to label setters or properties by predicate - > >> this > >> > would not be too bad coupled with org.apache.jena.vocabulary. > >> > > >> > Might need different annotations for object properties and data > >> properties. > >> > > >> > > >> > On Sun, Apr 7, 2019 at 7:54 AM Claude Warren <[email protected]> wrote: > >> > > >> > > Thomas, > >> > > > >> > > I think that PA4RDF does/did what you want to do > >> > > (https://github.com/Claudenw/PA4RDF) Basically, you define > >> FoafPerson > >> > > as an interface and annotate the getX methods to identify the > >> > > properties that identify the value. Something like: > >> > > > >> > > {noformat} > >> > > @Subject(namespace = "http://xmlns.com/foaf/0.1/", > >> > > class="http://xmlns.com/foaf/0.1/FoafPerson") > >> > > public interface FoafPerson { > >> > > > >> > > String getName(); > >> > > @Predicate > >> > > vod setName( String name ); > >> > > boolean hasName(); > >> > > } > >> > > {noformat} > >> > > > >> > > Create an use an entity manager by requesting > >> > > > >> > > {noformat} > >> > > FoafPerson fp = entityManager.read( resource, FoafPerson.class ); > >> > > {noformat} > >> > > > >> > > Will create fp as an instance of FoafPerson backed by the specified > >> > > resource. > >> > > > >> > > PA4RDF used dynamic proxies so it can create objects that are > >> > > combinations of objects. All objects returned implement > >> > > ResourceWrapper so you can allways call fp.getResource() to get the > >> > > resource back from the object. > >> > > > >> > > Claude > >> > > > >> > > Note: If you decide to go this route use the 1.1 version as the > >> > > current head branch is a different implementation and has some > >> > > significant issues. > >> > > > >> > > > >> > > > >> > > On Wed, Apr 3, 2019 at 8:33 AM Thomas Francart > >> > > <[email protected]> wrote: > >> > > > > >> > > > Hello > >> > > > > >> > > > Le mar. 2 avr. 2019 à 21:54, ajs6f <[email protected]> a écrit : > >> > > > > >> > > > > Personality and related types are described briefly here: > >> > > > > > >> > > > > > >> > > > > > >> > > > >> https://jena.apache.org/documentation/notes/jena-internals.html#enhanced-nodes > >> > > > > >> > > > > >> > > > Thanks, this describes what I would like to do : > >> > > > > >> > > > ``` > >> > > > > >> > > > 1. define an interface I for the new enhanced node. (You could > >> use > >> > > just > >> > > > the implementation class, but we've stuck with the interface, > >> because > >> > > there > >> > > > might be different implementations) > >> > > > 2. define the implementation class C. This is just a front for > >> the > >> > > > enhanced node. All the state of C is reflected in the graph > >> (except > >> > > for > >> > > > caching; but beware that the graph can change without notice). > >> > > > 3. define an Implementation class for the factory. This class > >> defines > >> > > > methods canWrap and wrap, which test a node to see if it is > >> allowed to > >> > > > represent I and construct an implementation of Crespectively. > >> > > > 4. Arrange that the personality of the graph maps the class of I > >> to > >> > > the > >> > > > factory. At the moment we do this by using (a copy of) the > >> built-in > >> > > graph > >> > > > personality as the personality for the enhanced graph. > >> > > > > >> > > > ``` > >> > > > > >> > > > > > >> > > > > > >> > > > > I know little about them, but to my understanding, that is not a > >> > > > > well-developed part of Jena and the technical ideas there are not > >> under > >> > > > > active development. You are noticing that when you find the > >> > > constructor odd > >> > > > > and hard to fill; that's in part because it mixes Jena's API > >> (Resource, > >> > > > > Statement, Model, etc.) with its SPI (Node, Triple, Graph, etc.). > >> > > > > > >> > > > > Could you tell us a little more about what you are doing? Why do > >> you > >> > > want > >> > > > > to extend Resource? > >> > > > > > >> > > > > >> > > > I'd like to do : > >> > > > > >> > > > 1. Define an interface that extends Resource : > >> > > > > >> > > > ``` > >> > > > public interface FoafPerson extends Resource { > >> > > > public String getName(); > >> > > > } > >> > > > ``` > >> > > > > >> > > > 2. Define an implementation : > >> > > > > >> > > > ``` > >> > > > public interface FoafPersonImpl implements FoafPerson extends > >> > > ResourceImpl { > >> > > > // constructor : how will this be called ??? > >> > > > public FoafPersonImpl(Node node, EnhGraph graph) { > >> > > > super(node, graph); > >> > > > } > >> > > > > >> > > > @Override > >> > > > public String getName() { > >> > > > return this.getProperty(FOAF.name).getString(); > >> > > > } > >> > > > } > >> > > > ``` > >> > > > > >> > > > 3. Define an Implementation class : > >> > > > > >> > > > ... here, I am lost > >> > > > > >> > > > 4. Maps the class I to the factory : > >> > > > > >> > > > ... here, I am lost > >> > > > > >> > > > 5. Use this; I'd like to be able to do : > >> > > > > >> > > > ``` > >> > > > Model m = ...; > >> > > > Resource r = ...; > >> > > > // obtain a view on the Resource as a Foaf Person : > >> > > > FoafPerson person = r.as(FoafPerson.class); > >> > > > System.out.println(person.getName()); > >> > > > ``` > >> > > > > >> > > > Any help in filling the blanks above would be appreciated ! > >> > > > > >> > > > Thanks > >> > > > Thomas > >> > > > > >> > > > > >> > > > > ajs6f > >> > > > > > >> > > > > > On Apr 2, 2019, at 3:48 PM, Thomas Francart < > >> > > [email protected]> > >> > > > > wrote: > >> > > > > > > >> > > > > > Hello > >> > > > > > > >> > > > > > I would like to declare data structure with an Interface that > >> extends > >> > > > > Jena > >> > > > > > Resource and its implementation that extends Jena ResourceImpl > >> in the > >> > > > > same > >> > > > > > way as > >> > > > > > > >> > > > > > >> > > > >> https://github.com/TopQuadrant/shacl/blob/a3f54abeffc691ff0b15bee7f049741eb6e00878/src/main/java/org/topbraid/shacl/model/SHShape.java > >> > > > > > (interface) and > >> > > > > > > >> > > > > > >> > > > >> https://github.com/TopQuadrant/shacl/blob/a3f54abeffc691ff0b15bee7f049741eb6e00878/src/main/java/org/topbraid/shacl/model/impl/SHShapeImpl.java > >> > > > > > (implementation, which indirectly extends ResourceImpl). > >> > > > > > Is it a common and good practice ? > >> > > > > > > >> > > > > > The constructor of the implementation takes as an input (Node > >> node, > >> > > > > > EnhGraph graph). > >> > > > > > I don't know how to obtain or build these Node and EnhGraph from > >> > > plain > >> > > > > > Resource / Model I am used to. I will be working with memory or > >> > > > > TDB-backed > >> > > > > > Models, if that matters. How can I obtain or build these so > >> that I > >> > > can > >> > > > > call > >> > > > > > the constructor of my data structure extending ResourceImpl, > >> with a > >> > > Node > >> > > > > > and EnhGraph instance ? > >> > > > > > > >> > > > > > I feel this could be related to "Personality<RDFNode>", as can > >> be > >> > > seen at > >> > > > > > > >> > > > > > >> > > > >> https://github.com/TopQuadrant/shacl/blob/76257beb501381542361b52363329999363753ff/src/main/java/org/topbraid/shacl/model/SHFactory.java > >> > > > > , > >> > > > > > where RDF classes URI are associated to the corresponding Java > >> > > classes. > >> > > > > > > >> > > > > > I am lost here, could someone shed some light on this design > >> pattern > >> > > ? > >> > > > > > > >> > > > > > Thanks > >> > > > > > Thomas > >> > > > > > > >> > > > > > -- > >> > > > > > > >> > > > > > *Thomas Francart* -* SPARNA* > >> > > > > > Web de *données* | Architecture de l'*information* | Accès aux > >> > > > > > *connaissances* > >> > > > > > blog : blog.sparna.fr, site : sparna.fr, linkedin : > >> > > > > > fr.linkedin.com/in/thomasfrancart > >> > > > > > tel : +33 (0)6.71.11.25.97, skype : francartthomas > >> > > > > > >> > > > > > >> > > > > >> > > > -- > >> > > > > >> > > > *Thomas Francart* -* SPARNA* > >> > > > Web de *données* | Architecture de l'*information* | Accès aux > >> > > > *connaissances* > >> > > > blog : blog.sparna.fr, site : sparna.fr, linkedin : > >> > > > fr.linkedin.com/in/thomasfrancart > >> > > > tel : +33 (0)6.71.11.25.97, skype : francartthomas > >> > > > >> > > > >> > > > >> > > -- > >> > > I like: Like Like - The likeliest place on the web > >> > > LinkedIn: http://www.linkedin.com/in/claudewarren > >> > > > >> > >> > >> > >> -- > >> I like: Like Like - The likeliest place on the web > >> LinkedIn: http://www.linkedin.com/in/claudewarren > >> > > -- I like: Like Like - The likeliest place on the web LinkedIn: http://www.linkedin.com/in/claudewarren
