You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Nouwt, B. (Barry)" <ba...@tno.nl.INVALID> on 2019/09/26 09:05:26 UTC
[UnionModel] question about unexpected behaviour
Hi all,
I am trying to get the Apache Jena UnionModel working for my scenario, but I keep encountering unexpected behavior. I’ve set up a minimal, free-standing example on github in this repository (clone the git repo, configure Maven in your IDE and execute the main() method, I.e. it probably does not run from the .jar):
https://github.com/barrynl/jena-example
I have two questions related to this example:
My first question is related to empty graphs in Jena Fuseki. If I load the conf.ttl (from the git repo above) at startup in Apache Jena Fuseki without the dummy data in the two named graphs, the two graphs seem to disappear (I think this does not happen in my Java Example). I read somewhere that empty graphs are automatically deleted in Fuseki to prevent old graphs from showing up in the Fuseki interface. For my use case I would like to configure two (possibly empty at first) named graphs via a conf.ttl and be able to store data in them afterwards. Is this possible?
My second question is about the demonstraded behaviour of the Java example in the git repository above. I load a dataset with a UnionModel from a conf.ttl file and insert new data in it via SPARQL. Although the new data shows up in the select query, it does not show up in either of the two names graphs the UnionModel consists of. My question is: where is this data stored if not in one of the names graphs? (If I inspect the UnionModel via a debugger, the inserted data DOES show up in the correct named graph)
Hopefully someone can shed some light on this behaviour. Thanks in advance!
Regards, Barry
This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.
Re: [UnionModel] question about unexpected behaviour
Posted by Claude Warren <cl...@xenei.com>.
Barry,
You could create a union graph that is used for an InfModel. Not sure why
you want a UnionGraph but ...
I think you want to start with a TDB Model and wrap that as a SecuredModel
(See comments in permissions re: SecuredModel vs SecuredGraph)
Using a SecuredModel as the basis for an InfModel is probably not what you
want to do. The InfModel will create new triples based on the data it
reads from the underlying graph. Different users will have different
security model results (there really is not a language to describe this).
So the inference engine for the first user will be correct for that user,
but if the second user is a user with less access the inference engine will
contain reasoned triples that the second user should not see because they
can not see the underlying data.
One way you might resolve this is to make the InfModel a secured model and
perform checks based on the reasoning you add. This is not a space I have
explored so I fear you are on your own here. However, there were a couple
of papers about 4 years ago concerning different approaches to securing
graphs. There might be something in there about how to do this in a way
that will actually work.
On the other hand, if you have a limited number of groups (N) you could use
the SecuredModel to drive N different datasets in Fuseki and let Fuseki
determine which graph(s) a user can see. In this case you would have N
InfModels running against the same underlying TDB model. Each InfModel
would write its derived data to its own graph. This solution will have
problem if you need to update the underlying TDB model.
While I don't have time to properly investigate this question, if you want
to explore it I would be happy to provide pointers and perhaps we can
develop an extension to work with the InfModel.
Claude
On Mon, Sep 30, 2019 at 3:52 PM Nouwt, B. (Barry)
<ba...@tno.nl.invalid> wrote:
> Hi Claude,
>
> Thanks for your analysis! It was (of course) not my intention to get a
> dataset with 4 graphs 😊, but is sure explains the strange behavior.
>
> I wanted to replicate the behavior of defaultUnionGraph option that is
> available in TDB. The reason I cannot use TDB's defaultUnionGraph option,
> is because in that case I do not have access to the actual default graph
> object. I need this object, because I want to wrap it with a SecuredModel
> and an InfModel.
>
> So, I want to combine the defaultUnionGraph behavior of TDB and the
> SecuredModel with a custom SecurityEvaluator from Jena Permissions and the
> InfModel with the GenericRuleReasoner. This was my attempt at doing so, but
> apparently it does not work. Do you think it is possible to construct such
> a dataset via an Assembler .ttl file?
>
> Regards, Barry
>
> -----Original Message-----
> From: Claude Warren <cl...@xenei.com>
> Sent: maandag 30 september 2019 16:33
> To: users@jena.apache.org
> Subject: Re: [UnionModel] question about unexpected behaviour
>
> Barry,
>
> You create a dataset that is comprised of the following:
>
> defaultGraph -> unionModel
> namedGraph(https://www.tno.nl/agrifood/graph/pizza/data)
> namedGraph(https://www.tno.nl/agrifood/graph/pizza/onto)
> <https://www.tno.nl/agrifood/graph/pizza/onto>
>
>
> https://www.tno.nl/agrifood/graph/pizza/data is loaded from
> file:src/main/resources/dummy1.ttl
> https://www.tno.nl/agrifood/graph/pizza/onto is loaded from
> file:src/main/resources/dummy2.ttl
>
> defaultGraph is the union of two graphs
> defaultGraph.root is loaded from file:src/main/resources/dummy1.ttl
> defaultGraph.sub1 is loaded from file:src/main/resources/dummy2.ttl
>
> writing triples into the dataset will write to the defaultGraph. The
> defaultGraph being a uniongraph will write to the first graph
> (default.Graph.root). While they are initialized with the same data
> (file:src/main/resources/dummy1.ttl), this is not the same as the
> https://www.tno.nl/agrifood/graph/pizza/data named graph.
>
> Your example basically has 4 graphs, 2 in defaultGraph and 2 named graphs.
>
> Claude
>
> On Fri, Sep 27, 2019 at 3:57 PM Nouwt, B. (Barry)
> <ba...@tno.nl.invalid> wrote:
>
> > Hi Claude, thanks for the explanation: from the dataset-as-quads
> > perspective it does indeed sound logical that empty graphs do not exist.
> >
> > Regarding your second answer, I've added some additional information
> > below (i.e. these can also be found on the github repo:
> > https://github.com/barrynl/jena-example). The SPARQL is executed on
> > the dataset described by the conf.ttl below. It does not have a GRAPH
> > specified in the query and it would indeed go into the default graph,
> > which is a UnionModel of the two in-memory named graphs. Of which the
> > rootGraph should store this new data. The details of how I inspect the
> > different graphs can be found in the Java code in the link above. If
> > you run this example and inspect the output log and 'dataset' variable
> > (and the inner models and
> > graphs) with a debugger, the data sometimes shows up and sometimes
> doesn't.
> > I am trying to understand why... Any more ideas?
> >
> > Regards, Barry
> >
> > ---------------------------------------- SPARQL
> > ----------------------------------------
> > INSERT DATA {
> > :test rdf:type pizza:Pizza .
> > :test pizza:hasCountryOfOrigin <
> > http://192.168.99.100/pizza/Italy> .
> > :test pizza:hasBase
> > <http://192.168.99.100/pizza/23_base>
> > .
> > :test pizza:hasSpiciness <
> > http://192.168.99.100/pizza/23_flauw> .
> > :test pizza:hasTopping :18-Tomaat .
> > :test pizza:hasTopping :18-mozzerella .
> > :test pizza:hasTopping :18-rundergehakt .
> > }
> >
> > ---------------------------------------- conf.ttl
> > ----------------------------------------
> >
> > @prefix : <#> .
> > @prefix fuseki: <http://jena.apache.org/fuseki#<
> > http://jena.apache.org/fuseki>> .
> > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#<
> > http://www.w3.org/1999/02/22-rdf-syntax-ns>> .
> > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#<
> > http://www.w3.org/2000/01/rdf-schema>> .
> > @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#<
> > http://jena.hpl.hp.com/2005/11/Assembler>> .
> > @prefix xsd: <http://www.w3.org/2001/XMLSchema#<
> > http://www.w3.org/2001/XMLSchema>> .
> >
> > :service1 rdf:type fuseki:Service ;
> > fuseki:name "test" ;
> > fuseki:serviceQuery "query" ; # SPARQL query service
> > fuseki:serviceUpdate "update" ;
> > fuseki:serviceUpload "upload" ; # Non-SPARQL upload service
> > fuseki:serviceReadWriteGraphStore "data" ; # SPARQL Graph
> > store protocol (read and write)
> > # A separate read-only graph store endpoint:
> > fuseki:serviceReadGraphStore "get" ; # SPARQL Graph store
> > protocol (read only)
> > fuseki:dataset :dataset .
> >
> > :dataset rdf:type ja:RDFDataset ;
> > ja:defaultGraph :unionModel ;
> > ja:namedGraph
> > [ ja:graphName <
> https://www.tno.nl/agrifood/graph/pizza/data>
> > ;
> > ja:graph :itemGraph ] ;
> > ja:namedGraph
> > [ ja:graphName <
> https://www.tno.nl/agrifood/graph/pizza/onto>
> > ;
> > ja:graph :ontoGraph ]
> > .
> >
> > :unionModel rdf:type ja:UnionModel ;
> > ja:rootModel :itemGraph ;
> > ja:subModel :ontoGraph .
> >
> > :itemGraph rdf:type ja:MemoryModel ;
> > ja:content [ ja:externalContent
> > <file:src/main/resources/dummy1.ttl> ] .
> >
> > :ontoGraph rdf:type ja:MemoryModel ;
> > ja:content [ ja:externalContent
> > <file:src/main/resources/dummy2.ttl> ] .
> >
> >
> >
> >
> > -----Original Message-----
> > From: Claude Warren <cl...@xenei.com>
> > Sent: donderdag 26 september 2019 12:10
> > To: users@jena.apache.org
> > Subject: Re: [UnionModel] question about unexpected behaviour
> >
> > Empty graphs in Fuseki simply don't exist. They no more exist than a
> > predicate that has not been used. Named graphs only come into
> > existence when there is at least one triple added to it. If you think
> > about datasets as collections of quads (<g> <s> <p> <o>) then you can
> > see that the dataset can only locate graphs that have data. The only
> > other option is that an infinite number of graphs exist, in which case
> > listing all the graphs would be impossible. I am sure there is a deep
> > philosophical discussion here but the Jena rule is that if the graph
> does not have data it does not exist.
> >
> > As for your second question, you did not give an example of how you
> > inserted the data. If you did not provide a graph name to insert into
> > then the data would go into the default graph named
> "urn:x-arq:DefaultGraph"
> > (defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI). If you
> > did provide the graph name then the data would be inserted into that
> > graph as your debugging shows. When you say it does not exist in the
> > graph are you referring to on disk? How did you write the data back
> > out? The UnionModel depends on the underlying models to preserve
> > their data. If those models are in-memory models then they will not
> > be written back to disk, if they are TDB models (or other similar auto
> > storing models) then they should be written back to the underlying
> > storage. This assumes that all transactions and other issues are
> correctly handled.
> >
> > Claude
> >
> >
> >
> > On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry)
> > <ba...@tno.nl.invalid> wrote:
> >
> > > Hi all,
> > >
> > > I am trying to get the Apache Jena UnionModel working for my
> > > scenario, but I keep encountering unexpected behavior. I've set up a
> > > minimal, free-standing example on github in this repository (clone
> > > the git repo, configure Maven in your IDE and execute the main()
> method, I.e.
> > > it probably does not run from the .jar):
> > >
> > > https://github.com/barrynl/jena-example
> > >
> > >
> > >
> > > I have two questions related to this example:
> > >
> > > My first question is related to empty graphs in Jena Fuseki. If I
> > > load the conf.ttl (from the git repo above) at startup in Apache
> > > Jena Fuseki without the dummy data in the two named graphs, the two
> > > graphs seem to disappear (I think this does not happen in my Java
> > > Example). I read somewhere that empty graphs are automatically
> > > deleted in Fuseki to prevent old graphs from showing up in the
> > > Fuseki interface. For my use case I would like to configure two
> > > (possibly empty at first) named graphs via a conf.ttl and be able to
> > > store data in them afterwards. Is
> > this possible?
> > >
> > > My second question is about the demonstraded behaviour of the Java
> > > example in the git repository above. I load a dataset with a
> > > UnionModel from a conf.ttl file and insert new data in it via SPARQL.
> > > Although the new data shows up in the select query, it does not show
> > > up in either of the two names graphs the UnionModel consists of. My
> > > question is: where is this data stored if not in one of the names
> > > graphs? (If I inspect the UnionModel via a debugger, the inserted
> > > data DOES show up in the correct named graph)
> > >
> > > Hopefully someone can shed some light on this behaviour. Thanks in
> > advance!
> > >
> > > Regards, Barry
> > > This message may contain information that is not intended for you.
> > > If you are not the addressee or if this message was sent to you by
> > > mistake, you are requested to inform the sender and delete the
> > > message. TNO accepts no liability for the content of this e-mail,
> > > for the manner in which you use it and for damage of any kind
> > > resulting from the risks inherent to the electronic transmission of
> messages.
> > >
> >
> >
> > --
> > 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
>
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren
RE: [UnionModel] question about unexpected behaviour
Posted by "Nouwt, B. (Barry)" <ba...@tno.nl.INVALID>.
Hi Claude,
Thanks for your analysis! It was (of course) not my intention to get a dataset with 4 graphs 😊, but is sure explains the strange behavior.
I wanted to replicate the behavior of defaultUnionGraph option that is available in TDB. The reason I cannot use TDB's defaultUnionGraph option, is because in that case I do not have access to the actual default graph object. I need this object, because I want to wrap it with a SecuredModel and an InfModel.
So, I want to combine the defaultUnionGraph behavior of TDB and the SecuredModel with a custom SecurityEvaluator from Jena Permissions and the InfModel with the GenericRuleReasoner. This was my attempt at doing so, but apparently it does not work. Do you think it is possible to construct such a dataset via an Assembler .ttl file?
Regards, Barry
-----Original Message-----
From: Claude Warren <cl...@xenei.com>
Sent: maandag 30 september 2019 16:33
To: users@jena.apache.org
Subject: Re: [UnionModel] question about unexpected behaviour
Barry,
You create a dataset that is comprised of the following:
defaultGraph -> unionModel
namedGraph(https://www.tno.nl/agrifood/graph/pizza/data)
namedGraph(https://www.tno.nl/agrifood/graph/pizza/onto)
<https://www.tno.nl/agrifood/graph/pizza/onto>
https://www.tno.nl/agrifood/graph/pizza/data is loaded from file:src/main/resources/dummy1.ttl
https://www.tno.nl/agrifood/graph/pizza/onto is loaded from file:src/main/resources/dummy2.ttl
defaultGraph is the union of two graphs
defaultGraph.root is loaded from file:src/main/resources/dummy1.ttl
defaultGraph.sub1 is loaded from file:src/main/resources/dummy2.ttl
writing triples into the dataset will write to the defaultGraph. The defaultGraph being a uniongraph will write to the first graph (default.Graph.root). While they are initialized with the same data (file:src/main/resources/dummy1.ttl), this is not the same as the https://www.tno.nl/agrifood/graph/pizza/data named graph.
Your example basically has 4 graphs, 2 in defaultGraph and 2 named graphs.
Claude
On Fri, Sep 27, 2019 at 3:57 PM Nouwt, B. (Barry) <ba...@tno.nl.invalid> wrote:
> Hi Claude, thanks for the explanation: from the dataset-as-quads
> perspective it does indeed sound logical that empty graphs do not exist.
>
> Regarding your second answer, I've added some additional information
> below (i.e. these can also be found on the github repo:
> https://github.com/barrynl/jena-example). The SPARQL is executed on
> the dataset described by the conf.ttl below. It does not have a GRAPH
> specified in the query and it would indeed go into the default graph,
> which is a UnionModel of the two in-memory named graphs. Of which the
> rootGraph should store this new data. The details of how I inspect the
> different graphs can be found in the Java code in the link above. If
> you run this example and inspect the output log and 'dataset' variable
> (and the inner models and
> graphs) with a debugger, the data sometimes shows up and sometimes doesn't.
> I am trying to understand why... Any more ideas?
>
> Regards, Barry
>
> ---------------------------------------- SPARQL
> ----------------------------------------
> INSERT DATA {
> :test rdf:type pizza:Pizza .
> :test pizza:hasCountryOfOrigin <
> http://192.168.99.100/pizza/Italy> .
> :test pizza:hasBase
> <http://192.168.99.100/pizza/23_base>
> .
> :test pizza:hasSpiciness <
> http://192.168.99.100/pizza/23_flauw> .
> :test pizza:hasTopping :18-Tomaat .
> :test pizza:hasTopping :18-mozzerella .
> :test pizza:hasTopping :18-rundergehakt .
> }
>
> ---------------------------------------- conf.ttl
> ----------------------------------------
>
> @prefix : <#> .
> @prefix fuseki: <http://jena.apache.org/fuseki#<
> http://jena.apache.org/fuseki>> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#<
> http://www.w3.org/1999/02/22-rdf-syntax-ns>> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#<
> http://www.w3.org/2000/01/rdf-schema>> .
> @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#<
> http://jena.hpl.hp.com/2005/11/Assembler>> .
> @prefix xsd: <http://www.w3.org/2001/XMLSchema#<
> http://www.w3.org/2001/XMLSchema>> .
>
> :service1 rdf:type fuseki:Service ;
> fuseki:name "test" ;
> fuseki:serviceQuery "query" ; # SPARQL query service
> fuseki:serviceUpdate "update" ;
> fuseki:serviceUpload "upload" ; # Non-SPARQL upload service
> fuseki:serviceReadWriteGraphStore "data" ; # SPARQL Graph
> store protocol (read and write)
> # A separate read-only graph store endpoint:
> fuseki:serviceReadGraphStore "get" ; # SPARQL Graph store
> protocol (read only)
> fuseki:dataset :dataset .
>
> :dataset rdf:type ja:RDFDataset ;
> ja:defaultGraph :unionModel ;
> ja:namedGraph
> [ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/data>
> ;
> ja:graph :itemGraph ] ;
> ja:namedGraph
> [ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/onto>
> ;
> ja:graph :ontoGraph ]
> .
>
> :unionModel rdf:type ja:UnionModel ;
> ja:rootModel :itemGraph ;
> ja:subModel :ontoGraph .
>
> :itemGraph rdf:type ja:MemoryModel ;
> ja:content [ ja:externalContent
> <file:src/main/resources/dummy1.ttl> ] .
>
> :ontoGraph rdf:type ja:MemoryModel ;
> ja:content [ ja:externalContent
> <file:src/main/resources/dummy2.ttl> ] .
>
>
>
>
> -----Original Message-----
> From: Claude Warren <cl...@xenei.com>
> Sent: donderdag 26 september 2019 12:10
> To: users@jena.apache.org
> Subject: Re: [UnionModel] question about unexpected behaviour
>
> Empty graphs in Fuseki simply don't exist. They no more exist than a
> predicate that has not been used. Named graphs only come into
> existence when there is at least one triple added to it. If you think
> about datasets as collections of quads (<g> <s> <p> <o>) then you can
> see that the dataset can only locate graphs that have data. The only
> other option is that an infinite number of graphs exist, in which case
> listing all the graphs would be impossible. I am sure there is a deep
> philosophical discussion here but the Jena rule is that if the graph does not have data it does not exist.
>
> As for your second question, you did not give an example of how you
> inserted the data. If you did not provide a graph name to insert into
> then the data would go into the default graph named "urn:x-arq:DefaultGraph"
> (defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI). If you
> did provide the graph name then the data would be inserted into that
> graph as your debugging shows. When you say it does not exist in the
> graph are you referring to on disk? How did you write the data back
> out? The UnionModel depends on the underlying models to preserve
> their data. If those models are in-memory models then they will not
> be written back to disk, if they are TDB models (or other similar auto
> storing models) then they should be written back to the underlying
> storage. This assumes that all transactions and other issues are correctly handled.
>
> Claude
>
>
>
> On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry)
> <ba...@tno.nl.invalid> wrote:
>
> > Hi all,
> >
> > I am trying to get the Apache Jena UnionModel working for my
> > scenario, but I keep encountering unexpected behavior. I've set up a
> > minimal, free-standing example on github in this repository (clone
> > the git repo, configure Maven in your IDE and execute the main() method, I.e.
> > it probably does not run from the .jar):
> >
> > https://github.com/barrynl/jena-example
> >
> >
> >
> > I have two questions related to this example:
> >
> > My first question is related to empty graphs in Jena Fuseki. If I
> > load the conf.ttl (from the git repo above) at startup in Apache
> > Jena Fuseki without the dummy data in the two named graphs, the two
> > graphs seem to disappear (I think this does not happen in my Java
> > Example). I read somewhere that empty graphs are automatically
> > deleted in Fuseki to prevent old graphs from showing up in the
> > Fuseki interface. For my use case I would like to configure two
> > (possibly empty at first) named graphs via a conf.ttl and be able to
> > store data in them afterwards. Is
> this possible?
> >
> > My second question is about the demonstraded behaviour of the Java
> > example in the git repository above. I load a dataset with a
> > UnionModel from a conf.ttl file and insert new data in it via SPARQL.
> > Although the new data shows up in the select query, it does not show
> > up in either of the two names graphs the UnionModel consists of. My
> > question is: where is this data stored if not in one of the names
> > graphs? (If I inspect the UnionModel via a debugger, the inserted
> > data DOES show up in the correct named graph)
> >
> > Hopefully someone can shed some light on this behaviour. Thanks in
> advance!
> >
> > Regards, Barry
> > This message may contain information that is not intended for you.
> > If you are not the addressee or if this message was sent to you by
> > mistake, you are requested to inform the sender and delete the
> > message. TNO accepts no liability for the content of this e-mail,
> > for the manner in which you use it and for damage of any kind
> > resulting from the risks inherent to the electronic transmission of messages.
> >
>
>
> --
> 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
Re: [UnionModel] question about unexpected behaviour
Posted by Claude Warren <cl...@xenei.com>.
Barry,
You create a dataset that is comprised of the following:
defaultGraph -> unionModel
namedGraph(https://www.tno.nl/agrifood/graph/pizza/data)
namedGraph(https://www.tno.nl/agrifood/graph/pizza/onto)
<https://www.tno.nl/agrifood/graph/pizza/onto>
https://www.tno.nl/agrifood/graph/pizza/data is loaded from
file:src/main/resources/dummy1.ttl
https://www.tno.nl/agrifood/graph/pizza/onto is loaded from
file:src/main/resources/dummy2.ttl
defaultGraph is the union of two graphs
defaultGraph.root is loaded from file:src/main/resources/dummy1.ttl
defaultGraph.sub1 is loaded from file:src/main/resources/dummy2.ttl
writing triples into the dataset will write to the defaultGraph. The
defaultGraph being a uniongraph will write to the first graph
(default.Graph.root). While they are initialized with the same data
(file:src/main/resources/dummy1.ttl), this is not the same as the
https://www.tno.nl/agrifood/graph/pizza/data named graph.
Your example basically has 4 graphs, 2 in defaultGraph and 2 named graphs.
Claude
On Fri, Sep 27, 2019 at 3:57 PM Nouwt, B. (Barry)
<ba...@tno.nl.invalid> wrote:
> Hi Claude, thanks for the explanation: from the dataset-as-quads
> perspective it does indeed sound logical that empty graphs do not exist.
>
> Regarding your second answer, I've added some additional information below
> (i.e. these can also be found on the github repo:
> https://github.com/barrynl/jena-example). The SPARQL is executed on the
> dataset described by the conf.ttl below. It does not have a GRAPH specified
> in the query and it would indeed go into the default graph, which is a
> UnionModel of the two in-memory named graphs. Of which the rootGraph should
> store this new data. The details of how I inspect the different graphs can
> be found in the Java code in the link above. If you run this example and
> inspect the output log and 'dataset' variable (and the inner models and
> graphs) with a debugger, the data sometimes shows up and sometimes doesn't.
> I am trying to understand why... Any more ideas?
>
> Regards, Barry
>
> ---------------------------------------- SPARQL
> ----------------------------------------
> INSERT DATA {
> :test rdf:type pizza:Pizza .
> :test pizza:hasCountryOfOrigin <
> http://192.168.99.100/pizza/Italy> .
> :test pizza:hasBase <http://192.168.99.100/pizza/23_base>
> .
> :test pizza:hasSpiciness <
> http://192.168.99.100/pizza/23_flauw> .
> :test pizza:hasTopping :18-Tomaat .
> :test pizza:hasTopping :18-mozzerella .
> :test pizza:hasTopping :18-rundergehakt .
> }
>
> ---------------------------------------- conf.ttl
> ----------------------------------------
>
> @prefix : <#> .
> @prefix fuseki: <http://jena.apache.org/fuseki#<
> http://jena.apache.org/fuseki>> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#<
> http://www.w3.org/1999/02/22-rdf-syntax-ns>> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#<
> http://www.w3.org/2000/01/rdf-schema>> .
> @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#<
> http://jena.hpl.hp.com/2005/11/Assembler>> .
> @prefix xsd: <http://www.w3.org/2001/XMLSchema#<
> http://www.w3.org/2001/XMLSchema>> .
>
> :service1 rdf:type fuseki:Service ;
> fuseki:name "test" ;
> fuseki:serviceQuery "query" ; # SPARQL query service
> fuseki:serviceUpdate "update" ;
> fuseki:serviceUpload "upload" ; # Non-SPARQL upload service
> fuseki:serviceReadWriteGraphStore "data" ; # SPARQL Graph store
> protocol (read and write)
> # A separate read-only graph store endpoint:
> fuseki:serviceReadGraphStore "get" ; # SPARQL Graph store protocol
> (read only)
> fuseki:dataset :dataset .
>
> :dataset rdf:type ja:RDFDataset ;
> ja:defaultGraph :unionModel ;
> ja:namedGraph
> [ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/data>
> ;
> ja:graph :itemGraph ] ;
> ja:namedGraph
> [ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/onto>
> ;
> ja:graph :ontoGraph ]
> .
>
> :unionModel rdf:type ja:UnionModel ;
> ja:rootModel :itemGraph ;
> ja:subModel :ontoGraph .
>
> :itemGraph rdf:type ja:MemoryModel ;
> ja:content [ ja:externalContent
> <file:src/main/resources/dummy1.ttl> ] .
>
> :ontoGraph rdf:type ja:MemoryModel ;
> ja:content [ ja:externalContent
> <file:src/main/resources/dummy2.ttl> ] .
>
>
>
>
> -----Original Message-----
> From: Claude Warren <cl...@xenei.com>
> Sent: donderdag 26 september 2019 12:10
> To: users@jena.apache.org
> Subject: Re: [UnionModel] question about unexpected behaviour
>
> Empty graphs in Fuseki simply don't exist. They no more exist than a
> predicate that has not been used. Named graphs only come into existence
> when there is at least one triple added to it. If you think about datasets
> as collections of quads (<g> <s> <p> <o>) then you can see that the dataset
> can only locate graphs that have data. The only other option is that an
> infinite number of graphs exist, in which case listing all the graphs would
> be impossible. I am sure there is a deep philosophical discussion here but
> the Jena rule is that if the graph does not have data it does not exist.
>
> As for your second question, you did not give an example of how you
> inserted the data. If you did not provide a graph name to insert into then
> the data would go into the default graph named "urn:x-arq:DefaultGraph"
> (defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI). If you did
> provide the graph name then the data would be inserted into that graph as
> your debugging shows. When you say it does not exist in the graph are you
> referring to on disk? How did you write the data back out? The UnionModel
> depends on the underlying models to preserve their data. If those models
> are in-memory models then they will not be written back to disk, if they
> are TDB models (or other similar auto storing models) then they should be
> written back to the underlying storage. This assumes that all transactions
> and other issues are correctly handled.
>
> Claude
>
>
>
> On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry)
> <ba...@tno.nl.invalid> wrote:
>
> > Hi all,
> >
> > I am trying to get the Apache Jena UnionModel working for my scenario,
> > but I keep encountering unexpected behavior. I've set up a minimal,
> > free-standing example on github in this repository (clone the git
> > repo, configure Maven in your IDE and execute the main() method, I.e.
> > it probably does not run from the .jar):
> >
> > https://github.com/barrynl/jena-example
> >
> >
> >
> > I have two questions related to this example:
> >
> > My first question is related to empty graphs in Jena Fuseki. If I load
> > the conf.ttl (from the git repo above) at startup in Apache Jena
> > Fuseki without the dummy data in the two named graphs, the two graphs
> > seem to disappear (I think this does not happen in my Java Example). I
> > read somewhere that empty graphs are automatically deleted in Fuseki
> > to prevent old graphs from showing up in the Fuseki interface. For my
> > use case I would like to configure two (possibly empty at first) named
> > graphs via a conf.ttl and be able to store data in them afterwards. Is
> this possible?
> >
> > My second question is about the demonstraded behaviour of the Java
> > example in the git repository above. I load a dataset with a
> > UnionModel from a conf.ttl file and insert new data in it via SPARQL.
> > Although the new data shows up in the select query, it does not show
> > up in either of the two names graphs the UnionModel consists of. My
> > question is: where is this data stored if not in one of the names
> > graphs? (If I inspect the UnionModel via a debugger, the inserted data
> > DOES show up in the correct named graph)
> >
> > Hopefully someone can shed some light on this behaviour. Thanks in
> advance!
> >
> > Regards, Barry
> > This message may contain information that is not intended for you. If
> > you are not the addressee or if this message was sent to you by
> > mistake, you are requested to inform the sender and delete the
> > message. TNO accepts no liability for the content of this e-mail, for
> > the manner in which you use it and for damage of any kind resulting
> > from the risks inherent to the electronic transmission of messages.
> >
>
>
> --
> 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
RE: [UnionModel] question about unexpected behaviour
Posted by "Nouwt, B. (Barry)" <ba...@tno.nl.INVALID>.
Hi Claude, thanks for the explanation: from the dataset-as-quads perspective it does indeed sound logical that empty graphs do not exist.
Regarding your second answer, I've added some additional information below (i.e. these can also be found on the github repo: https://github.com/barrynl/jena-example). The SPARQL is executed on the dataset described by the conf.ttl below. It does not have a GRAPH specified in the query and it would indeed go into the default graph, which is a UnionModel of the two in-memory named graphs. Of which the rootGraph should store this new data. The details of how I inspect the different graphs can be found in the Java code in the link above. If you run this example and inspect the output log and 'dataset' variable (and the inner models and graphs) with a debugger, the data sometimes shows up and sometimes doesn't. I am trying to understand why... Any more ideas?
Regards, Barry
---------------------------------------- SPARQL ----------------------------------------
INSERT DATA {
:test rdf:type pizza:Pizza .
:test pizza:hasCountryOfOrigin <http://192.168.99.100/pizza/Italy> .
:test pizza:hasBase <http://192.168.99.100/pizza/23_base> .
:test pizza:hasSpiciness <http://192.168.99.100/pizza/23_flauw> .
:test pizza:hasTopping :18-Tomaat .
:test pizza:hasTopping :18-mozzerella .
:test pizza:hasTopping :18-rundergehakt .
}
---------------------------------------- conf.ttl ----------------------------------------
@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#<http://jena.apache.org/fuseki>> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns>> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#<http://www.w3.org/2000/01/rdf-schema>> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#<http://jena.hpl.hp.com/2005/11/Assembler>> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#<http://www.w3.org/2001/XMLSchema>> .
:service1 rdf:type fuseki:Service ;
fuseki:name "test" ;
fuseki:serviceQuery "query" ; # SPARQL query service
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ; # Non-SPARQL upload service
fuseki:serviceReadWriteGraphStore "data" ; # SPARQL Graph store protocol (read and write)
# A separate read-only graph store endpoint:
fuseki:serviceReadGraphStore "get" ; # SPARQL Graph store protocol (read only)
fuseki:dataset :dataset .
:dataset rdf:type ja:RDFDataset ;
ja:defaultGraph :unionModel ;
ja:namedGraph
[ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/data> ;
ja:graph :itemGraph ] ;
ja:namedGraph
[ ja:graphName <https://www.tno.nl/agrifood/graph/pizza/onto> ;
ja:graph :ontoGraph ]
.
:unionModel rdf:type ja:UnionModel ;
ja:rootModel :itemGraph ;
ja:subModel :ontoGraph .
:itemGraph rdf:type ja:MemoryModel ;
ja:content [ ja:externalContent <file:src/main/resources/dummy1.ttl> ] .
:ontoGraph rdf:type ja:MemoryModel ;
ja:content [ ja:externalContent <file:src/main/resources/dummy2.ttl> ] .
-----Original Message-----
From: Claude Warren <cl...@xenei.com>
Sent: donderdag 26 september 2019 12:10
To: users@jena.apache.org
Subject: Re: [UnionModel] question about unexpected behaviour
Empty graphs in Fuseki simply don't exist. They no more exist than a predicate that has not been used. Named graphs only come into existence when there is at least one triple added to it. If you think about datasets as collections of quads (<g> <s> <p> <o>) then you can see that the dataset can only locate graphs that have data. The only other option is that an infinite number of graphs exist, in which case listing all the graphs would be impossible. I am sure there is a deep philosophical discussion here but the Jena rule is that if the graph does not have data it does not exist.
As for your second question, you did not give an example of how you inserted the data. If you did not provide a graph name to insert into then the data would go into the default graph named "urn:x-arq:DefaultGraph"
(defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI). If you did provide the graph name then the data would be inserted into that graph as your debugging shows. When you say it does not exist in the graph are you referring to on disk? How did you write the data back out? The UnionModel depends on the underlying models to preserve their data. If those models are in-memory models then they will not be written back to disk, if they are TDB models (or other similar auto storing models) then they should be written back to the underlying storage. This assumes that all transactions and other issues are correctly handled.
Claude
On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry) <ba...@tno.nl.invalid> wrote:
> Hi all,
>
> I am trying to get the Apache Jena UnionModel working for my scenario,
> but I keep encountering unexpected behavior. I've set up a minimal,
> free-standing example on github in this repository (clone the git
> repo, configure Maven in your IDE and execute the main() method, I.e.
> it probably does not run from the .jar):
>
> https://github.com/barrynl/jena-example
>
>
>
> I have two questions related to this example:
>
> My first question is related to empty graphs in Jena Fuseki. If I load
> the conf.ttl (from the git repo above) at startup in Apache Jena
> Fuseki without the dummy data in the two named graphs, the two graphs
> seem to disappear (I think this does not happen in my Java Example). I
> read somewhere that empty graphs are automatically deleted in Fuseki
> to prevent old graphs from showing up in the Fuseki interface. For my
> use case I would like to configure two (possibly empty at first) named
> graphs via a conf.ttl and be able to store data in them afterwards. Is this possible?
>
> My second question is about the demonstraded behaviour of the Java
> example in the git repository above. I load a dataset with a
> UnionModel from a conf.ttl file and insert new data in it via SPARQL.
> Although the new data shows up in the select query, it does not show
> up in either of the two names graphs the UnionModel consists of. My
> question is: where is this data stored if not in one of the names
> graphs? (If I inspect the UnionModel via a debugger, the inserted data
> DOES show up in the correct named graph)
>
> Hopefully someone can shed some light on this behaviour. Thanks in advance!
>
> Regards, Barry
> This message may contain information that is not intended for you. If
> you are not the addressee or if this message was sent to you by
> mistake, you are requested to inform the sender and delete the
> message. TNO accepts no liability for the content of this e-mail, for
> the manner in which you use it and for damage of any kind resulting
> from the risks inherent to the electronic transmission of messages.
>
--
I like: Like Like - The likeliest place on the web <http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren
Re: [UnionModel] question about unexpected behaviour
Posted by Claude Warren <cl...@xenei.com>.
Empty graphs in Fuseki simply don't exist. They no more exist than a
predicate that has not been used. Named graphs only come into existence
when there is at least one triple added to it. If you think about datasets
as collections of quads (<g> <s> <p> <o>) then you can see that the dataset
can only locate graphs that have data. The only other option is that an
infinite number of graphs exist, in which case listing all the graphs would
be impossible. I am sure there is a deep philosophical discussion here but
the Jena rule is that if the graph does not have data it does not exist.
As for your second question, you did not give an example of how you
inserted the data. If you did not provide a graph name to insert into then
the data would go into the default graph named "urn:x-arq:DefaultGraph"
(defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI). If you did
provide the graph name then the data would be inserted into that graph as
your debugging shows. When you say it does not exist in the graph are you
referring to on disk? How did you write the data back out? The UnionModel
depends on the underlying models to preserve their data. If those models
are in-memory models then they will not be written back to disk, if they
are TDB models (or other similar auto storing models) then they should be
written back to the underlying storage. This assumes that all transactions
and other issues are correctly handled.
Claude
On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry)
<ba...@tno.nl.invalid> wrote:
> Hi all,
>
> I am trying to get the Apache Jena UnionModel working for my scenario, but
> I keep encountering unexpected behavior. I’ve set up a minimal,
> free-standing example on github in this repository (clone the git repo,
> configure Maven in your IDE and execute the main() method, I.e. it probably
> does not run from the .jar):
>
> https://github.com/barrynl/jena-example
>
>
>
> I have two questions related to this example:
>
> My first question is related to empty graphs in Jena Fuseki. If I load the
> conf.ttl (from the git repo above) at startup in Apache Jena Fuseki without
> the dummy data in the two named graphs, the two graphs seem to disappear (I
> think this does not happen in my Java Example). I read somewhere that empty
> graphs are automatically deleted in Fuseki to prevent old graphs from
> showing up in the Fuseki interface. For my use case I would like to
> configure two (possibly empty at first) named graphs via a conf.ttl and be
> able to store data in them afterwards. Is this possible?
>
> My second question is about the demonstraded behaviour of the Java example
> in the git repository above. I load a dataset with a UnionModel from a
> conf.ttl file and insert new data in it via SPARQL. Although the new data
> shows up in the select query, it does not show up in either of the two
> names graphs the UnionModel consists of. My question is: where is this data
> stored if not in one of the names graphs? (If I inspect the UnionModel via
> a debugger, the inserted data DOES show up in the correct named graph)
>
> Hopefully someone can shed some light on this behaviour. Thanks in advance!
>
> Regards, Barry
> This message may contain information that is not intended for you. If you
> are not the addressee or if this message was sent to you by mistake, you
> are requested to inform the sender and delete the message. TNO accepts no
> liability for the content of this e-mail, for the manner in which you use
> it and for damage of any kind resulting from the risks inherent to the
> electronic transmission of messages.
>
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren