1)An interesting annotation in Alibaba is the @SPARQL annotation. I guess the only way doing that with PA4RDF is an abstract/concrete class with ARQ query inside ? Is there a way to get the URI of he instance inside it ? (alibaba has the $this used in @SPARQL annotation)
I'm not sure what the SPARQL annotation in Alibaba does but if you are looking to create read only instances against data retrieved from a SPARQL endpoint (i.e. not a local model) then you could do so with the results of a construct query, or you could retrieve the objects and all their properties to insert into a local graph. As long as you have a Jena Resource PA4RDF will work (Note: PA4RDF does not specify that Jena is the RDF provider but the only implementation is on top of Jena -- Other implementations are possible). 2)What about ordoned lists in PA4RDF ? Is Colllection<valueClass> getX() keeps order ? This is a tricky question. Currently PA4RDF only looks at all instances of a property for a resource. So 3 statements with the same Subject and Predicate but different Objects like: R1 P1 "value1" R1 P1 "value2" R1 P1 "value3" Will return the 3 string values. They are returned in the order that the underlying model returns them. So order is not guaranteed by PA4RDF. PA4RDF does not handle rdfs:Container or rdf:List distinctly from any other object type. I have thought about adding special handling and it is possible but I have not had the time to implement it. 3)On this page http://pa4rdf.sourceforge.net/examples/concreteClassSubject.html, is this a mistake ? "Iterator<String> authors = book.getAuthors();" should be "Iterator<String> authors = book.getAuthor();" Right ? Yes, good catch. 4) " as setting the bean properties should be performed inside a transaction and the transaction committed when all the properties have been updated" : I guess you mean model.begin() / model.commit(). Yes model.begin() / model.commit() . The transaction requirements are based on the requirements of the underlying data store. The TDB datastore should use transactions, the in memory one does not require them. Then a last question. Alibaba give ability to manage connection and model. Is the only way to access the same model in the aplication is using a static model (by example initialized when web appli begin ?) Jena with TDB requires access be via a single JVM. So but you can create the model at any time and you can retrieve it at any time from the underlying data store. So you can create an in memory model if you wish and use PA4RDF to read/write objects from/to it, or you can use TDB. Assuming you are using TDB your model has a name. Any thread within the JVM can retrieve the model and apply PA4RDF to it. PA4RDF does not manage the model, it just sits ontop of it to read/write data. 5) The last one : When you say in your introduction : " map a RDF triple (subject, predicate, object) to a Plain Old Java Object (POJO)", this do not say that PA4RDF javabeans can't extends other PA4RDF javabeans ? eg : JbeanUser <- JbeanStrudent Inheritance works. You can extend interfaces or classes so if JbeanUser and jbeanStudent are interfaces or abstract classes or even concrete classes the annotations work as expected. You can merge multiple interfaces together (mixins) as follows: Assume you have interfaces defined for FOAF:person as FoafPerson and http://www.w3.org/2000/10/swap/pim/contact#Person as w3cPerson Assume the model contains a resource <urn:aPerson> which may have attributes of both FOAF and W3C pim. and that resource is in the java code as the variable "personRes". you could create an object as follows: Resource personRes = ..... Object o = entityManager.read( personRes, FoafPerson.class, w3cPerson.class ); The object "o" would be of type FoafPerson but could be cast as a w3cPerson. The first class is the one that is the return type the rest of the classes indicate what other interfaces to add to the implementation. from "o" you can get the resource back using the method getResource() so personRes == o.getResource() this is because all managed entities implement ResourceWrapper. The first argument to EntityManager.read() must be either a Resource or a ResourceWrapper. On Wed, Jan 7, 2015 at 4:36 PM, Nicolas Paris <[email protected]> wrote: > Thanks all ! > > Martynas : I take a look on your application/framework. It means the > VUE is described in RDF as templates, isn'it? I will have to design by > example Quizz etc in RDF ? I guess I need some more hours to decript > how work Graphity, and I will do that when I get bored about > sesame/jena JPA and other reasoners stuff ! > > Ashish : " what benefit do you get converting Javabeans to RDF? " > - jbeans -> RDF : is a way to get data persistance. > - RDF because I need SWRL rule or equivalent on the data (say propose > learning support to student based on rules) > - I need OWL reasonning inferencing too. > => OOP, and javabeans (JPA), is a stable and ubiquitous way to manage > the model of data. In a classical MVC architecture, with JSP and EL, > it's a simple and eprouved way to design a website. > Then thanks to JPA (PA4RDF or Alibaba with sesame), CURL actions will > be OOP. I will work on complex jbeans : QUIZZ and various type of > exercices and need complex object manipulations. > By the way, this do not mean all fonctionnality will be done with JPA. > By example, I will add a SWRL module (based on pellet?), that may > retrieve data with SPARQL, and reason on that statements. > > > Claude : Thanks for quick answer. I am comparing Alibaba > (https://bitbucket.org/openrdf/alibaba/src/master/object-repository/ = > ELMO's successor) VS your PA4RDF. > 1)An interesting annotation in Alibaba is the @SPARQL annotation. I > guess the only way doing that with PA4RDF is an abstract/concrete > class with ARQ query inside ? Is there a way to get the URI of he > instance inside it ? (alibaba has the $this used in @SPARQL > annotation) > 2)What about ordoned lists in PA4RDF ? Is Colllection<valueClass> > getX() keeps order ? Alibaba do not use collection. > 3)On this page > http://pa4rdf.sourceforge.net/examples/concreteClassSubject.html, > is this a mistake ? > "Iterator<String> authors = book.getAuthors();" should be > "Iterator<String> authors = book.getAuthor();" Right ? > 4) " as setting the bean properties should be performed inside a > transaction and the transaction committed when all the properties have > been updated" : I guess you mean model.begin() / model.commit(). Then > a last question. Alibaba give ability to manage connection and model. > Is the only way to access the same model in the aplication is using a > static model (by example initialized when web appli begin ?) > 5) The last one : When you say in your introduction : " map a RDF > triple (subject, predicate, object) to a Plain Old Java Object > (POJO)", this do not say that PA4RDF javabeans can't extends other > PA4RDF javabeans ? eg : JbeanUser <- JbeanStrudent > > > Thanks for answers > > > > Nicolas PARIS > > > 2015-01-07 12:02 GMT+01:00 Claude Warren <[email protected]>: > > I was asked to comment on this thread and so as the developer for PA4RDF > I > > will. > > > > PA4RDF was originally an interface only mapping: Annotated Interface > > directly mapping onto the RDF structure with the Subject of the triples > > being the instance of the interface and various properties of the subject > > mapped to methods. PA4RDF did all the mapping from RDF data types to > Java > > data types and back. It also had a nomenclature to distinguish between > > properties that should be single instance and those that can be multiple > > instance. > > > > The use of Interface only became to unwieldy so it has been extended to > > handle abstract and concrete classes. It still handles all the > conversions > > and ensuring that the property is single instance when required. > > > > It was later extended again to handle triggers (of a sort) wherein > specific > > methods can be called after the getter, setter or remover methods. This > is > > to assist the developer in maintaining internal consistency. > > > > Now as to weather or not it works in the MVC environment. My experience > is > > that it does. That was primarily why I wrote it. I started out by > looking > > at using the standard JPA annotations to read/write the graph but found > > that the impedance mismatch was to great. > > > > PA4RDF does not make copies of the data, it uses the Jena model interface > > directly. Since the Resources in the Model always have access to the > > current state of the model the PA4RDF annotated beans always have access > to > > the current state of the model. They are never disconnected. > (Disconnected > > operation is a planned feature). The lack of disconnection has some > impact > > on program design as setting the bean properties should be performed > inside > > a transaction and the transaction committed when all the properties have > > been updated. > > > > The example cited above ( > > http://pa4rdf.sourceforge.net/examples/concreteClassSubject.html) > handles > > the case where there is no interface to annotate and the developer may be > > plugging PA4RDF into an existing class. > > > > For most projects with simple beans the annotated interface ( > > http://pa4rdf.sourceforge.net/examples/interface.html) is a better > example. > > > > If you have a requirement to process some of the properties before > > returning them (in the PA4RDF examples returning a "cite" for a book, you > > can annotate an abstract class. You could also have the abstract class > > extend an annotated interface and that would work as well). > > > > Finally, the concrete example is also used in cases where you can not > pass > > an abstract class or an interface to some other class. I don't recall > the > > specific case but I do remember encountering the case where I needed the > > ability to create a concrete class as the tool I was using would not > allow > > an Abstract class or Interface to be used). > > > > I think you will find that PA4RDF works well as a replacement for JPA and > > has additional capabilities that exploit the underlying Model. If it > > doesn't I am more than willing to accept code fixes and ideas. Also any > > documentation would be gladly accepted. > > > > Claude Warren > > > > > > > > > > > > On Wed, Jan 7, 2015 at 6:29 AM, Ashish Nijhara <[email protected] > > > > wrote: > > > >> Nicolas: It is important to understand why would you like RDF into > >> JavaBeans. I mean in that case, a regular java application with RDBMS > would > >> also do the job or? So, if you consider for a second, you would have > >> Javabeans being the objects updated by the application, internally you > want > >> to convert them to RDF and store them in a triple store. The > architecture, > >> however correct, sounds clunky unless there is a deep reason to have > such > >> an architecture and not intuitive. > >> > >> I agree with Martynas, RDF opens a lot more possibilities. > >> > >> To answer the questions > >> 1) Are there good practice or some DAO to design ? > >> As mentioned above, what benefit do you get converting Javabeans to > RDF? If > >> no benefit, then stick to one paradigm and keep it simple!! > >> 2) In term of performances, is it better to use ARQ (sparql) OR jena > >> ontologie API ? > >> For getting bulk information out, my experience has been SPARQL is > better. > >> (3) is it a good choice to store all in a triple store ? (versus > >> traditional relational databases) ) > >> Storing things in a triple store is better, in RDBMS you may end up > using > >> Jena SDB to store triples in RDBMS which gets clunky and slow. > >> > >> On Wed, Jan 7, 2015 at 5:53 AM, Martynas Jusevičius < > [email protected] > >> > > >> wrote: > >> > >> > Nicolas: fair enough. However you should know that by simply replacing > >> > the relational DB with a triplestore while using the same > >> > object-oriented programming approach you're not getting even half of > >> > the advantages of semantic technologies. RDF opens possibilities for > >> > new software design patterns. > >> > > >> > On Tue, Jan 6, 2015 at 9:37 PM, Nicolas Paris <[email protected]> > >> wrote: > >> > > Martynas : Thanks for the link. Maybe your solution is excellent, > but > >> > > I don't want to lose me : classical MVC, is a security for me and > the > >> > > project. > >> > > > >> > > Olivier : The Elmo documentation is great. Do you think my > application > >> > > could be done with sesame ? I mean, sesame has a triple store, a > >> > > reasoner, and looks like having a javabeans system much advanced > than > >> > > jena/PA4RDF have ? > >> > > Anyway, jena/PA4RDF can actually do the job ; the documentation for > >> > > PA4RDF is just really poor. > >> > > Nicolas PARIS > >> > > > >> > > > >> > > 2015-01-06 10:48 GMT+01:00 Olivier Rossel <[email protected] > >: > >> > >> Martynas, > >> > >> > >> > >> that is a bit off-topic but maybe you could organize a webinar so > you > >> > >> can show us some features of graphityhq. > >> > >> > >> > >> Nicolas: > >> > >> > >> > >> honestly, i know not very much about PA4RDF, > >> > >> I use Elmo (rebranded as AliBaba) : > >> > >> > >> > > >> > http://sourceforge.net/projects/sesame/files/AliBabaElmo/1.5/openrdf-elmo-1.5.zip/download > >> > >> > >> > >> There is a nice user guide in the zip file, that gives a lot of > >> details > >> > >> about how to annotate beans so the persistence is transparent. > >> > >> I think inheritance is explained too. > >> > >> > >> > >> On Tue, Jan 6, 2015 at 2:29 AM, Martynas Jusevičius > >> > >> <[email protected]> wrote: > >> > >>> Nicolas, > >> > >>> > >> > >>> I suggest you also take a look at Graphity Client: > >> > >>> https://github.com/Graphity/graphity-client > >> > >>> > >> > >>> You don't really need an object layer representing your RDF > classes > >> > >>> above Jena, it is a bottleneck. You can express both the webapp > >> > >>> structure and the instance data as RDF, and define a mapping from > >> HTTP > >> > >>> access to RDF state changes over SPARQL. > >> > >>> > >> > >>> Here's an example of how that structure (sitemap ontology) looks > >> like: > >> > >>> > >> > > >> > http://lists.w3.org/Archives/Public/public-declarative-apps/2015Jan/0000.html > >> > >>> > >> > >>> Here's an example of an editing interface: > >> > >>> > >> > > >> > http://linkeddatahub.com/bibframe/instances?mode=http%3A%2F%2Fgraphity.org%2Fgc%23CreateMode > >> > >>> > >> > >>> Disclaimer: I'm the main developer. > >> > >>> > >> > >>> > >> > >>> Martynas > >> > >>> graphityhq.com > >> > >>> > >> > >>> On Mon, Jan 5, 2015 at 9:07 PM, Nicolas Paris < > [email protected]> > >> > wrote: > >> > >>>> Thanks for answers ! > >> > >>>> > >> > >>>> - About http://callimachusproject.org/ : interesting but I have > to > >> > >>>> create application from scratch, because very specific > >> > >>>> > >> > >>>> - About PA4RDF : It seems very interessant. Any other tutorial, > >> > >>>> related post or tip ? > >> > >>>> Olivier, what do you exactly mean by "a bean <-> graph mapper" ? > >> > >>>> I generate an OWL ontology, that is my structure of data. I will > >> > >>>> modelise beans inspiring this structure. Say owl properties will > be > >> > >>>> java class properties. And RDF class's inheritance will be > mapped to > >> > >>>> java inheritance. Do you agree ? > >> > >>>> However, it appears that the POJO class of PA4RDF limits the > >> > inheritance. > >> > >>>> The example here > >> > >>>> http://pa4rdf.sourceforge.net/examples/concreteClassSubject.html > >> > >>>> could feet with user <- student inheritance ? Or will I have to > >> > >>>> duplicate code for Teacher & Student as they inherite from User ? > >> > >>>> > >> > >>>> Thanks again for this link Olivier ! > >> > >>>> Nicolas PARIS > >> > >>>> > >> > >>>> > >> > >>>> 2015-01-05 15:44 GMT+01:00 Olivier Rossel < > [email protected] > >> >: > >> > >>>>> There was a discussion some weeks ago about PA4RDF. > >> > >>>>> It might be a good starting point, in you think a bean <-> graph > >> > mapper > >> > >>>>> could be useful in your case. > >> > >>>>> > >> > >>>>> Also http://callimachusproject.org/ could be another > interesting > >> > >>>>> project to investigate in your case. > >> > >>>>> > >> > >>>>> On Mon, Jan 5, 2015 at 2:41 PM, Nicolas Paris < > [email protected] > >> > > >> > wrote: > >> > >>>>>> Hello, > >> > >>>>>> > >> > >>>>>> I am creating a web semantic application, were persistant data > is > >> > all > >> > >>>>>> stored in triple store (TDB). > >> > >>>>>> I mean, users(foaf), parameters etc. > >> > >>>>>> This application is an e-learning application, with exercices > >> > >>>>>> proposition based on reasonners. > >> > >>>>>> > >> > >>>>>> I want to use a classic MVC design pattern (jsp / servlets / > >> > javabeans). > >> > >>>>>> So a javabeans user, teacher, and student with heritage. > >> > >>>>>> My naïve aproach would be to initialise jbeans from TDB, using > >> jena > >> > >>>>>> model getInstance etc. Or Sparql Querys with ARQ > >> > >>>>>> and my setters will do both : > >> > >>>>>> - set jbeans propertys > >> > >>>>>> - modify triple (dataset jena setProperty ; dataset commit , > OR > >> > SPARQL querys) > >> > >>>>>> > >> > >>>>>> Example bad pseudo-code: > >> > >>>>>> Class student extends user { > >> > >>>>>> private Integer age; > >> > >>>>>> private Ressource student = myModel.getIndividual( > >> > >>>>>> "http://www.myexample.com/mySchema#student1" ); > >> > >>>>>> > >> > >>>>>> public void setAge(Integer age){ > >> > >>>>>> this.age = age; //modify jbeans property > >> > >>>>>> student.setPropertyValue(" > http://www.myexample.com/mySchema#age > >> > ","1^^integer") > >> > >>>>>> # modify TDB valyue > >> > >>>>>> } > >> > >>>>>> > >> > >>>>>> } > >> > >>>>>> > >> > >>>>>> > >> > >>>>>> 1) Are there good practice or some DAO to design ? > >> > >>>>>> 2) In term of performances, is it better to use ARQ (sparql) OR > >> jena > >> > >>>>>> ontologie API ? > >> > >>>>>> (3) is it a good choice to store all in a triple store ? > (versus > >> > >>>>>> traditional relational databases) ) > >> > >>>>>> > >> > >>>>>> Thanks a lot > >> > >>>>>> > >> > >>>>>> > >> > >>>>>> > >> > >>>>>> Nicolas PARIS > >> > > >> > > > > > > > > -- > > I like: Like Like - The likeliest place on the web > > <http://like-like.xenei.com> > > LinkedIn: http://www.linkedin.com/in/claudewarren > -- I like: Like Like - The likeliest place on the web <http://like-like.xenei.com> LinkedIn: http://www.linkedin.com/in/claudewarren
