You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Thomas Francart <th...@sparna.fr> on 2019/04/02 19:48:06 UTC

Getting EnhGraph / ModelCom from Resource / Model ?

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

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by ajs6f <aj...@apache.org>.
I suppose one answer is that you can get a Node from FrontsNode::asNode (Resource < RDFNode < FrontsNode) and a Graph from RDFNode.getModel()::getGraph (Model < ModelGraphInterface). I'm not entirely sure what to do to build a EnhGraph. And that's as much as I know about this stuff.

The only mention of the ideas in that document in our site I recall is in:

https://lists.apache.org/thread.html/ee76112a3c2de79e092100c4a66897f290410d02df080cca92f324ab@%3Cusers.jena.apache.org%3E <https://lists.apache.org/thread.html/ee76112a3c2de79e092100c4a66897f290410d02df080cca92f324ab@%3Cusers.jena.apache.org%3E>

where Chris Dollin gives a bit of history. Perhaps some of the committers with more experience could describe it better? Do we have good examples of that machinery in use?

ajs6f

> On Apr 3, 2019, at 3:32 AM, Thomas Francart <th...@sparna.fr> wrote:
> 
> Hello
> 
> Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <th...@sparna.fr>
>> 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


Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Claude Warren <cl...@xenei.com>.
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 <da...@gmail.com> 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 <da...@gmail.com> 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 <cl...@xenei.com> 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 <da...@gmail.com> 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 <cl...@xenei.com> 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
> >> > > <th...@sparna.fr> wrote:
> >> > > >
> >> > > > Hello
> >> > > >
> >> > > > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
> >> > > thomas.francart@sparna.fr>
> >> > > > > 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

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Dan Davis <da...@gmail.com>.
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 <da...@gmail.com> 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 <cl...@xenei.com> 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 <da...@gmail.com> 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 <cl...@xenei.com> 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
>> > > <th...@sparna.fr> wrote:
>> > > >
>> > > > Hello
>> > > >
>> > > > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
>> > > thomas.francart@sparna.fr>
>> > > > > 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
>>
>

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Zachary Whitley <za...@gmail.com>.
Added PA4RDF to https://github.com/semantalytics/awesome-semantic-web

On Mon, Apr 8, 2019 at 1:35 PM Dan Davis <da...@gmail.com> 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 <cl...@xenei.com> 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 <da...@gmail.com> 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 <cl...@xenei.com> 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
> > > > <th...@sparna.fr> wrote:
> > > > >
> > > > > Hello
> > > > >
> > > > > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
> > > > thomas.francart@sparna.fr>
> > > > > > 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
> >
>

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Dan Davis <da...@gmail.com>.
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 <cl...@xenei.com> 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 <da...@gmail.com> 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 <cl...@xenei.com> 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
> > > <th...@sparna.fr> wrote:
> > > >
> > > > Hello
> > > >
> > > > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
> > > thomas.francart@sparna.fr>
> > > > > 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
>

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Claude Warren <cl...@xenei.com>.
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 <da...@gmail.com> 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 <cl...@xenei.com> 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
> > <th...@sparna.fr> wrote:
> > >
> > > Hello
> > >
> > > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
> > thomas.francart@sparna.fr>
> > > > 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

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Dan Davis <da...@gmail.com>.
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 <cl...@xenei.com> 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
> <th...@sparna.fr> wrote:
> >
> > Hello
> >
> > Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <
> thomas.francart@sparna.fr>
> > > 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
>

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Claude Warren <cl...@xenei.com>.
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
<th...@sparna.fr> wrote:
>
> Hello
>
> Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <th...@sparna.fr>
> > 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

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by Thomas Francart <th...@sparna.fr>.
Hello

Le mar. 2 avr. 2019 à 21:54, ajs6f <aj...@apache.org> 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 <th...@sparna.fr>
> 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

Re: Getting EnhGraph / ModelCom from Resource / Model ?

Posted by ajs6f <aj...@apache.org>.
Personality and related types are described briefly here:

https://jena.apache.org/documentation/notes/jena-internals.html#enhanced-nodes

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? 

ajs6f

> On Apr 2, 2019, at 3:48 PM, Thomas Francart <th...@sparna.fr> 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