Re: Use variable in SPARQL query

2016-11-02 Thread Lorenz Buehmann

On 02.11.2016 15:05, tina sani wrote:
> The value of employee is either Manager or Technical. When user enter
> Manager, I want the query to show instances of Manager class and when
> Technical, it will show instances of Technical class.

That is not a useful answer to my response.Please learn to provide
detailed information. What is the concrete value?

Is it the String "Manager"? Like

String employee = "Manager";

If so, your SPARQL query expects the URI of a class, do you understand
what I mean?

"Manager" is not a URI. And as I said, if you have the URI, you need to
put this in between '<' and '>'

> And yes, I have used all the prefixes with full URI in my query.
I don't understand what you're saying here. Either you use full URIs or
you use prefixed URIs and add the prefixes in the beginning of the
SPARQL query.
>
> On Wed, Nov 2, 2016 at 1:02 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> WHAT is a concrete value of the variable 'employee'?
>>
>> And, full  URIs have to be put between '<' and '>'
>>
>>> Lorenz, this does not work for me:
>>>
>>> Select * where{?emp rdf:type "+employee+"}";
>>>
>>> employee variable is : String employee; have values Manager or Technical
>>> depend on user input.
>>>
>>> On Wed, Nov 2, 2016 at 10:48 AM, Lorenz B. <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 It should be clear that String concatenation calls the toString() method
 of your object. We don't know how this is implemented in your code
>> though.
> Will simply putting a variable inside a query work?
>
> {?emp rdf:type "+employee+"}";
>
> On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni 
 wrote:
>> Hi Tina,
>>
>> You can have your query stored in a composed java string (e.g. String
 query
>> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
>>
>> Hope that helps
>> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
>>
>>> Hello.
>>>
>>> How can I use a Java variable in the SPARQL query.
>>> ?emp rdf:type ?SomeVariable
>>>
>>> I want rdf:type of Managers and Technicals while these two
>> values(Managers
>>> and Technicals) are in my Java variable: employee.
>>>
>>> So I need something like:
>>>
>>> ?emp rdf:type "employee"
>>>
>>> Regards
>>>
 --
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web research center


>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>



Re: Placement of VALUES block affects performance in 3.1.1

2016-11-02 Thread Osma Suominen

02.11.2016, 13:08, Osma Suominen wrote:


It's possible that a MINUS expression could be used instead of FILTER
NOT EXISTS and perform better. I will have to test this. But other than
switching to MINUS, I can't think of any way to express this constraint
on collections without using some kind of double negation.


I played with MINUS, but it was no better than FILTER NOT EXISTS.


Osma - could you please try putting the VALUES in each arm of the UNION
which gets you to something like the first example.


I will try this as well.


This helped - a lot. The query time is practically the same now as it 
was with Jena 3.1.0. Thanks!


The original query, though, has four UNION branches. It seems a bit 
stupid to put the same VALUES statement (which may have 20 URIs or more) 
in each of those arms, but I will do that if it's the only way to get 
good performance with 3.1.1.


-Osma

--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suomi...@helsinki.fi
http://www.nationallibrary.fi


RE: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread omar.khan
Rob - I restarted and tried much of the below , but same behavior - Ramesh has 
just responded with a question here at the bottom of the thread:

https://developer.jboss.org/thread/272656

-Original Message-
From: Rob Vesse [mailto:rve...@dotnetrdf.org] 
Sent: Wednesday, November 02, 2016 11:16 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

One possibility is that there is JAR/class caching going on. You may need to 
completely remove your application from JBoss and then redeploy it as the fact 
that you still see this behaviour implies that you still aren’t getting the 
correct services files from the JAR files. Restart of the container/JVM may 
also be necessary

 Note that if you choose to use the individual driver JAR files then you would 
need to also add all the dependencies explicitly as that could also lead to 
missing classes and initialisations

Rob

On 02/11/2016 13:19, "omar.k...@wellsfargo.com"  
wrote:

Rob/Andy - thanks!

I'm not sure if I made this clear ... My query does work fine as long as I 
don't include "FILTER"; I'm able to get back a select ?s ?p ?o {?s ?p ?o} with 
no issues from the driver

I did just try the latest snapshot bundle jar, unfortunately...  If I 
include FILTER regex(?var,"value")
I still get:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.jena.sparql.expr.NodeValue

I don't believe Teiid is doing any repackaging, and I'm also confused if I 
include the individual jar files it won't work .. 

 Anything else I could try to troubleshoot this?  I'm at a loss


-Original Message-
From: Rob Vesse [mailto:rve...@dotnetrdf.org] 
Sent: Wednesday, November 02, 2016 6:00 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

They seem to be conflating two different things here

 We do use and support Standard JDBC Driver initialisation. We also use the 
same underlying Java mechanism i.e. ServiceLoader to initialise Jena itself. 
Our JDBC driver initialisation invokes our Jena initialisation. So as far as 
we’re concerned we are not doing anything wrong:


https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java#L178


https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java#L95


https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java#L90

As Andy has pointed out there was a bug in how the bundle JAR with all the 
drivers was being created which meant that Jena initialisation wasn’t happening 
properly because the composites services file for Jena initialisers wasn’t 
being created properly. If you use the latest 3.1.1-SNAPSHOT builds then this 
is resolved.

lists.apache.org provides a much more modern interface to our mailing lists

Rob

On 02/11/2016 03:10, "omar.k...@wellsfargo.com"  
wrote:

Hi Andy - further info from Ramesh ; thanks for your patience  - he was 
having access accessing /reading MarkMail - so I'm relaying (original from 
bottom of https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism 
with standard JDBC4 ServiceLoader mechanism like 

https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class 
possibly in a "static block" call ARQ.init() that will initialize every time 
one uses their JDBC driver. "
 
-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> Thanks Andy!
>
> Question - who is responsible for loading the JDBC driver, and how 
does one load it?
>
> I'm not clear on exact details on how to get it to work. I reached 
out to the Teiid team, and Ramesh has a question for you .
>
> Can you look at the bottom of this thread for the question from 
Ramesh?
>
> https://developer.jboss.org/thread/272656

Firstly - I didn't write and don't use jena-jdbc so my level of 
expertise is limited.  The initialization of Jena in shaded jars is something 
that has come up before.

It looks like the problem is at the Jena initialization step, not the 
loading the JDBC driver. That's supposed to be automatic and is - the crash 

Re: [ANNOUNCE] Lorenz Buehmann elected as Committer

2016-11-02 Thread javed khan
Accept warm congratulation from my side also Lorenz.

On Wed, Nov 2, 2016 at 4:28 PM, A. Soroka  wrote:

> Congratulations, Lorenz!
>
> Thank you for all the work you are putting in to help people.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Nov 2, 2016, at 6:19 AM, Rob Vesse  wrote:
> >
> > All
> >
> >
> >
> > The Apache Jena PMC have inivited Lorenz Buehmann to become a committer
> and we are pleased to announce that he has accepted
> >
> >
> >
> > We have recognised Lorenz for sterling work he does in answering user
> questions and participating in discussions on the mailing lists. He is
> always courteous and polite in his responses even when dealing with
> questions that may not warrant that politeness. Answering questions and
> sharing knowledge are an important part of building a healthy community and
> it can often be a time-consuming task so the more people who are willing to
> help out the easier it is to share that load.
> >
> >
> >
> > Being a committer also enables easier contribution to the project since
> there is no need to go via the patch submission process. This should enable
> better productivity.  Lorenz works regularly with Jena in his day job and
> hopes in time to be able to contribute some of that work that is generally
> applicable back to the community.
> >
> >
> >
> > Committer is also an intermediate step to becoming of the project
> management committee who are tasked with managing the project on the half
> of the Apache software foundation. If you would like to learn more please
> see http://apache.org/foundation/how-it-works.html#roles
> >
> >
> >
> > Please join us in welcoming Lorenz as a committer.
> >
> >
> >
> > Regards,
> >
> >
> >
> > Rob Vesse
> >
>
>


Re: [ANNOUNCE] Lorenz Buehmann elected as Committer

2016-11-02 Thread tina sani
Congrats Lorenz.

On Wed, Nov 2, 2016 at 4:31 PM, David Moss  wrote:

>
>  Congratulations, Lorenz!
> Thanks for putting in the effort.
> DM
>
>
>


Re: Use variable in SPARQL query

2016-11-02 Thread tina sani
The value of employee is either Manager or Technical. When user enter
Manager, I want the query to show instances of Manager class and when
Technical, it will show instances of Technical class.
And yes, I have used all the prefixes with full URI in my query.

On Wed, Nov 2, 2016 at 1:02 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> WHAT is a concrete value of the variable 'employee'?
>
> And, full  URIs have to be put between '<' and '>'
>
> > Lorenz, this does not work for me:
> >
> > Select * where{?emp rdf:type "+employee+"}";
> >
> > employee variable is : String employee; have values Manager or Technical
> > depend on user input.
> >
> > On Wed, Nov 2, 2016 at 10:48 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> It should be clear that String concatenation calls the toString() method
> >> of your object. We don't know how this is implemented in your code
> though.
> >>
> >>> Will simply putting a variable inside a query work?
> >>>
> >>> {?emp rdf:type "+employee+"}";
> >>>
> >>> On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni 
> >> wrote:
>  Hi Tina,
> 
>  You can have your query stored in a composed java string (e.g. String
> >> query
>  = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
> 
>  Hope that helps
>  Le 1 nov. 2016 17:02, "tina sani"  a écrit :
> 
> > Hello.
> >
> > How can I use a Java variable in the SPARQL query.
> > ?emp rdf:type ?SomeVariable
> >
> > I want rdf:type of Managers and Technicals while these two
>  values(Managers
> > and Technicals) are in my Java variable: employee.
> >
> > So I need something like:
> >
> > ?emp rdf:type "employee"
> >
> > Regards
> >
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


RE: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread omar.khan
Andy thanks! I'm hoping Ramesh will be able to answer some of this  

I’m not sure where I actually would make the code call for the below , because 
from what I'm seeing - there is only driver configuration and no place to 
insert code in Teiid, but I'm probably mistaken.
-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Wednesday, November 02, 2016 9:42 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

The FILTER requires value processing - which is NodeValue - otherwise your 
query does not need it.

NodeValue calls "JenaSystem.init()" when the class is loaded so that suggests 
that full initialization has not happened.

Try putting this code before doing anything related to jena including touching 
a JDBC URL.

   InitJenaCore.init();
   RIOT.init();
   ARQ.init();

This is not the right way to do initialization but it will work because it is 
hardcoding what should happen.

Can you get more of the stacktraces? Where in NodeValue is there an exception 
causing NoClassDefFoundError? (Java does not make this easy)

Andy

On 02/11/16 13:19, omar.k...@wellsfargo.com wrote:
> Rob/Andy - thanks!
>
> I'm not sure if I made this clear ... My query does work fine as long 
> as I don't include "FILTER"; I'm able to get back a select ?s ?p ?o 
> {?s ?p ?o} with no issues from the driver
>
> I did just try the latest snapshot bundle jar, unfortunately...  If I 
> include FILTER regex(?var,"value") I still get:
> Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
> org.apache.jena.sparql.expr.NodeValue
>
> I don't believe Teiid is doing any repackaging, and I'm also confused if I 
> include the individual jar files it won't work ..
>
>  Anything else I could try to troubleshoot this?  I'm at a loss
>
>
> -Original Message-
> From: Rob Vesse [mailto:rve...@dotnetrdf.org]
> Sent: Wednesday, November 02, 2016 6:00 AM
> To: users@jena.apache.org
> Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror
>
> They seem to be conflating two different things here
>
>  We do use and support Standard JDBC Driver initialisation. We also use the 
> same underlying Java mechanism i.e. ServiceLoader to initialise Jena itself. 
> Our JDBC driver initialisation invokes our Jena initialisation. So as far as 
> we’re concerned we are not doing anything wrong:
>
> https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-
> remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.
> java#L178
>
> https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-
> tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java#L95
>
> https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-
> mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java#L90
>
> As Andy has pointed out there was a bug in how the bundle JAR with all the 
> drivers was being created which meant that Jena initialisation wasn’t 
> happening properly because the composites services file for Jena initialisers 
> wasn’t being created properly. If you use the latest 3.1.1-SNAPSHOT builds 
> then this is resolved.
>
> lists.apache.org provides a much more modern interface to our mailing 
> lists
>
> Rob
>
> On 02/11/2016 03:10, "omar.k...@wellsfargo.com"  
> wrote:
>
> Hi Andy - further info from Ramesh ; thanks for your patience  - he was 
> having access accessing /reading MarkMail - so I'm relaying (original from 
> bottom of https://developer.jboss.org/thread/272656) :
>
> "Basically what they need to do, replace their ServiceLoader mechanism 
> with standard JDBC4 ServiceLoader mechanism like
> 
> https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
>  That will register their Driver class, and in their driver class 
> possibly in a "static block" call ARQ.init() that will initialize every time 
> one uses their JDBC driver. "
>
> -Original Message-
> From: Andy Seaborne [mailto:a...@apache.org]
> Sent: Tuesday, November 01, 2016 12:10 PM
> To: users@jena.apache.org
> Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror
>
>
>
> On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> > Thanks Andy!
> >
> > Question - who is responsible for loading the JDBC driver, and how does 
> one load it?
> >
> > I'm not clear on exact details on how to get it to work. I reached out 
> to the Teiid team, and Ramesh has a question for you .
> >
> > Can you look at the bottom of this thread for the question from Ramesh?
> >
> > https://developer.jboss.org/thread/272656
>
> Firstly - I didn't write and don't use jena-jdbc so my level of expertise 
> is limited.  The initialization of Jena in shaded jars is something that has 
> come up before.
>
> It looks like the problem is at the Jena initialization step, not the 
> loading the JDBC driver. That's supposed to be 

Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread Andy Seaborne
The FILTER requires value processing - which is NodeValue - otherwise 
your query does not need it.


NodeValue calls "JenaSystem.init()" when the class is loaded so that 
suggests that full initialization has not happened.


Try putting this code before doing anything related to jena including 
touching a JDBC URL.


  InitJenaCore.init();
  RIOT.init();
  ARQ.init();

This is not the right way to do initialization but it will work because 
it is hardcoding what should happen.


Can you get more of the stacktraces? Where in NodeValue is there an 
exception causing NoClassDefFoundError? (Java does not make this easy)


Andy

On 02/11/16 13:19, omar.k...@wellsfargo.com wrote:

Rob/Andy - thanks!

I'm not sure if I made this clear ... My query does work fine as long as I don't include 
"FILTER"; I'm able to get back a select ?s ?p ?o {?s ?p ?o} with no issues from 
the driver

I did just try the latest snapshot bundle jar, unfortunately...  If I include FILTER 
regex(?var,"value")
I still get:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.jena.sparql.expr.NodeValue

I don't believe Teiid is doing any repackaging, and I'm also confused if I 
include the individual jar files it won't work ..

 Anything else I could try to troubleshoot this?  I'm at a loss


-Original Message-
From: Rob Vesse [mailto:rve...@dotnetrdf.org]
Sent: Wednesday, November 02, 2016 6:00 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

They seem to be conflating two different things here

 We do use and support Standard JDBC Driver initialisation. We also use the 
same underlying Java mechanism i.e. ServiceLoader to initialise Jena itself. 
Our JDBC driver initialisation invokes our Jena initialisation. So as far as 
we’re concerned we are not doing anything wrong:

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java#L178

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java#L95

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java#L90

As Andy has pointed out there was a bug in how the bundle JAR with all the 
drivers was being created which meant that Jena initialisation wasn’t happening 
properly because the composites services file for Jena initialisers wasn’t 
being created properly. If you use the latest 3.1.1-SNAPSHOT builds then this 
is resolved.

lists.apache.org provides a much more modern interface to our mailing lists

Rob

On 02/11/2016 03:10, "omar.k...@wellsfargo.com"  
wrote:

Hi Andy - further info from Ramesh ; thanks for your patience  - he was 
having access accessing /reading MarkMail - so I'm relaying (original from 
bottom of https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism with 
standard JDBC4 ServiceLoader mechanism like

https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class possibly in a 
"static block" call ARQ.init() that will initialize every time one uses their JDBC 
driver. "

-Original Message-
From: Andy Seaborne [mailto:a...@apache.org]
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> Thanks Andy!
>
> Question - who is responsible for loading the JDBC driver, and how does 
one load it?
>
> I'm not clear on exact details on how to get it to work. I reached out to 
the Teiid team, and Ramesh has a question for you .
>
> Can you look at the bottom of this thread for the question from Ramesh?
>
> https://developer.jboss.org/thread/272656

Firstly - I didn't write and don't use jena-jdbc so my level of expertise 
is limited.  The initialization of Jena in shaded jars is something that has 
come up before.

It looks like the problem is at the Jena initialization step, not the 
loading the JDBC driver. That's supposed to be automatic and is - the crash 
happens because the initialization is incomplete or is happening in the wrong 
order because the normal sequence isn't happening.

In yoru code, if you can, call ARQ.init() before anything else.  Calling it 
repeatedly is safe and cheap.

Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver to 
load.  Standard way for Java.

Andy


>
>
> -Original Message-
> From: Andy Seaborne [mailto:a...@apache.org]
> Sent: Tuesday, November 01, 2016 5:49 AM
> To: users@jena.apache.org
> 

Re: Tools for browsing and editing RDF data

2016-11-02 Thread David Moss

Protégé can do that.

http://protege.stanford.edu/

DM


On 2/11/16, 10:51 pm, "Mikael Pesonen"  wrote:


Hi,

I'm having trouble to find tools which a non-SPARQL person could use for 
editing and viewing any kind of semantic data on Jena triplestore. For 
example we have metadata describing files and people using Dublin Core 
and FOAF ontologies, and we would to edit that metadata.

I guess such a system would need some kind of templates to define the 
underlying SPARQL queries. For example what set of triplets is a record 
(a set of data that is selected for editing), which fields of a record 
can be modified or deleted and so on. Field types, class hierarchies etc 
could be read from ontology schemas.

Hope there exist such a system.

BR,
Mikael Pesonen

-- 
www.lingsoft.fi

Speech Applications - Language Management - Translation - Reader's and 
Writer's Tools - Text Tools - E-books and M-books

Mikael Pesonen
System Engineer

e-mail: mikael.peso...@lingsoft.fi
Tel. +358 2 279 3300

Time zone: GMT+2

Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND

Turku Office
Linnankatu 10 A
FI-20100 Turku
FINLAND






RE: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread omar.khan
Rob/Andy - thanks!

I'm not sure if I made this clear ... My query does work fine as long as I 
don't include "FILTER"; I'm able to get back a select ?s ?p ?o {?s ?p ?o} with 
no issues from the driver

I did just try the latest snapshot bundle jar, unfortunately...  If I include 
FILTER regex(?var,"value")
I still get:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.jena.sparql.expr.NodeValue

I don't believe Teiid is doing any repackaging, and I'm also confused if I 
include the individual jar files it won't work .. 

 Anything else I could try to troubleshoot this?  I'm at a loss


-Original Message-
From: Rob Vesse [mailto:rve...@dotnetrdf.org] 
Sent: Wednesday, November 02, 2016 6:00 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

They seem to be conflating two different things here

 We do use and support Standard JDBC Driver initialisation. We also use the 
same underlying Java mechanism i.e. ServiceLoader to initialise Jena itself. 
Our JDBC driver initialisation invokes our Jena initialisation. So as far as 
we’re concerned we are not doing anything wrong:

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java#L178

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java#L95

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java#L90

As Andy has pointed out there was a bug in how the bundle JAR with all the 
drivers was being created which meant that Jena initialisation wasn’t happening 
properly because the composites services file for Jena initialisers wasn’t 
being created properly. If you use the latest 3.1.1-SNAPSHOT builds then this 
is resolved.

lists.apache.org provides a much more modern interface to our mailing lists

Rob

On 02/11/2016 03:10, "omar.k...@wellsfargo.com"  
wrote:

Hi Andy - further info from Ramesh ; thanks for your patience  - he was 
having access accessing /reading MarkMail - so I'm relaying (original from 
bottom of https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism with 
standard JDBC4 ServiceLoader mechanism like 

https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class possibly 
in a "static block" call ARQ.init() that will initialize every time one uses 
their JDBC driver. "
 
-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> Thanks Andy!
>
> Question - who is responsible for loading the JDBC driver, and how does 
one load it?
>
> I'm not clear on exact details on how to get it to work. I reached out to 
the Teiid team, and Ramesh has a question for you .
>
> Can you look at the bottom of this thread for the question from Ramesh?
>
> https://developer.jboss.org/thread/272656

Firstly - I didn't write and don't use jena-jdbc so my level of expertise 
is limited.  The initialization of Jena in shaded jars is something that has 
come up before.

It looks like the problem is at the Jena initialization step, not the 
loading the JDBC driver. That's supposed to be automatic and is - the crash 
happens because the initialization is incomplete or is happening in the wrong 
order because the normal sequence isn't happening.

In yoru code, if you can, call ARQ.init() before anything else.  Calling it 
repeatedly is safe and cheap.

Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver to 
load.  Standard way for Java.

Andy


>
>
> -Original Message-
> From: Andy Seaborne [mailto:a...@apache.org]
> Sent: Tuesday, November 01, 2016 5:49 AM
> To: users@jena.apache.org
> Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror
>
>
>> I checked and the jena-jdbc-driver-bundle does not set up the 
>> ServiceLoader services correctly.  We'll fix that.
>
> jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a 
development with it in.
>
>  Andy
>
>>
>> But I don't immediately see why using the jars directly does not 
>> work, but that's due to my lack of knowledge about Teiid and JBoss.
>>
>> Is there any repackaging going on?
>>
>> Andy
>







Tools for browsing and editing RDF data

2016-11-02 Thread Mikael Pesonen


Hi,

I'm having trouble to find tools which a non-SPARQL person could use for 
editing and viewing any kind of semantic data on Jena triplestore. For 
example we have metadata describing files and people using Dublin Core 
and FOAF ontologies, and we would to edit that metadata.


I guess such a system would need some kind of templates to define the 
underlying SPARQL queries. For example what set of triplets is a record 
(a set of data that is selected for editing), which fields of a record 
can be modified or deleted and so on. Field types, class hierarchies etc 
could be read from ontology schemas.


Hope there exist such a system.

BR,
Mikael Pesonen

--
www.lingsoft.fi

Speech Applications - Language Management - Translation - Reader's and Writer's 
Tools - Text Tools - E-books and M-books

Mikael Pesonen
System Engineer

e-mail: mikael.peso...@lingsoft.fi
Tel. +358 2 279 3300

Time zone: GMT+2

Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND

Turku Office
Linnankatu 10 A
FI-20100 Turku
FINLAND



Re: Placement of VALUES block affects performance in 3.1.1

2016-11-02 Thread Osma Suominen

Hi Andy!

Thanks a lot for looking into this and your very clear explanation.

01.11.2016, 21:12, Andy Seaborne wrote:

It has always been inside-out then optimized to use stream based index
joins.

However in this case "inside out" is confusing because the query has a
double negation of FILTER NOT EXIST.


Right. Let me explain why the query does this.

The query (or actually a longer variant thereof) is used in the Skosmos 
application to generate a list of search results. At the time this query 
is used the application already has a (possibly long) list of the SKOS 
concept URIs it wants to display. This query is used to look up 
additional information about those concepts.


Instead of performing a separate query for each concept URI, a single 
query with a VALUES block containing up to 20 concept URIs is used. So 
in this case, the VALUES is used thinking of it as a sort of for-each 
loop. A single query for 20 concepts is faster than performing 20 
queries for individual concepts - at least it used to be.


The reason for the double negation is this:

For each concept X, we want to display the SKOS Collections in which 
concept X is a member, but only if the collection consists only of 
siblings of X (i.e. sharing at least one broader concept with X).
In practice, this has to be turned around into a double negation: for 
each collection, check that it doesn't include a concept that doesn't 
share any parent with X.


It's possible that a MINUS expression could be used instead of FILTER 
NOT EXISTS and perform better. I will have to test this. But other than 
switching to MINUS, I can't think of any way to express this constraint 
on collections without using some kind of double negation.



At 3.1.1 (JENA-1171), EXISTS are analysed whereas previous they were
skipped which could lead to wrong answers.

Osma - could you please try putting the VALUES in each arm of the UNION
which gets you to something like the first example.


I will try this as well.


It can be pushed in because:

join(A, union(B,C)) == union(join(A,B), join(A,C))

now if A is an complex expression, that is a bad idea (probably).

If A is a small VALUES block then it makes sense.  It isn't done though.


Ok. So a potential future optimization perhaps.

-Osma

--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suomi...@helsinki.fi
http://www.nationallibrary.fi


Re: Use variable in SPARQL query

2016-11-02 Thread Lorenz B.
WHAT is a concrete value of the variable 'employee'?

And, full  URIs have to be put between '<' and '>'

> Lorenz, this does not work for me:
>
> Select * where{?emp rdf:type "+employee+"}";
>
> employee variable is : String employee; have values Manager or Technical
> depend on user input.
>
> On Wed, Nov 2, 2016 at 10:48 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> It should be clear that String concatenation calls the toString() method
>> of your object. We don't know how this is implemented in your code though.
>>
>>> Will simply putting a variable inside a query work?
>>>
>>> {?emp rdf:type "+employee+"}";
>>>
>>> On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni 
>> wrote:
 Hi Tina,

 You can have your query stored in a composed java string (e.g. String
>> query
 = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"

 Hope that helps
 Le 1 nov. 2016 17:02, "tina sani"  a écrit :

> Hello.
>
> How can I use a Java variable in the SPARQL query.
> ?emp rdf:type ?SomeVariable
>
> I want rdf:type of Managers and Technicals while these two
 values(Managers
> and Technicals) are in my Java variable: employee.
>
> So I need something like:
>
> ?emp rdf:type "employee"
>
> Regards
>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: Use variable in SPARQL query

2016-11-02 Thread tina sani
Lorenz, this does not work for me:

Select * where{?emp rdf:type "+employee+"}";

employee variable is : String employee; have values Manager or Technical
depend on user input.

On Wed, Nov 2, 2016 at 10:48 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> It should be clear that String concatenation calls the toString() method
> of your object. We don't know how this is implemented in your code though.
>
> > Will simply putting a variable inside a query work?
> >
> > {?emp rdf:type "+employee+"}";
> >
> > On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni 
> wrote:
> >
> >> Hi Tina,
> >>
> >> You can have your query stored in a composed java string (e.g. String
> query
> >> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
> >>
> >> Hope that helps
> >> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
> >>
> >>> Hello.
> >>>
> >>> How can I use a Java variable in the SPARQL query.
> >>> ?emp rdf:type ?SomeVariable
> >>>
> >>> I want rdf:type of Managers and Technicals while these two
> >> values(Managers
> >>> and Technicals) are in my Java variable: employee.
> >>>
> >>> So I need something like:
> >>>
> >>> ?emp rdf:type "employee"
> >>>
> >>> Regards
> >>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


[ANNOUNCE] Lorenz Buehmann elected as Committer

2016-11-02 Thread Rob Vesse
All

 

The Apache Jena PMC have inivited Lorenz Buehmann to become a committer and we 
are pleased to announce that he has accepted

 

We have recognised Lorenz for sterling work he does in answering user questions 
and participating in discussions on the mailing lists. He is always courteous 
and polite in his responses even when dealing with questions that may not 
warrant that politeness. Answering questions and sharing knowledge are an 
important part of building a healthy community and it can often be a 
time-consuming task so the more people who are willing to help out the easier 
it is to share that load.

 

Being a committer also enables easier contribution to the project since there 
is no need to go via the patch submission process. This should enable better 
productivity.  Lorenz works regularly with Jena in his day job and hopes in 
time to be able to contribute some of that work that is generally applicable 
back to the community.

 

Committer is also an intermediate step to becoming of the project management 
committee who are tasked with managing the project on the half of the Apache 
software foundation. If you would like to learn more please see 
http://apache.org/foundation/how-it-works.html#roles

 

Please join us in welcoming Lorenz as a committer.

 

Regards,

 

Rob Vesse



Re: Placement of VALUES block affects performance in 3.1.1

2016-11-02 Thread Andy Seaborne



On 01/11/16 22:40, james anderson wrote:

good evening;


On 2016-11-01, at 20:12, Andy Seaborne  wrote:



On 01/11/16 12:38, Osma Suominen wrote:

Hi,
[about a query which exercises the interaction between a values clause and 
statement pattern at locations relatively remote in the query. ]


[ the question leads to a point about the scope of the respective ?uri 
variables, ]

The issue is [*], using the variable ?uri again inside an OPTIONAL.

It is possible that ?uri will range over more than the VALUES setting and 
affect the OPTIONAL yet the inner EXISTS usage does not set ?uri and it is not 
propagated to be joined with the set value.

[…]

[ … and to one about algebraic equivalence among expressions and the consequent 
latitude to relocate the values clause.]

It can be pushed in because:

join(A, union(B,C)) == union(join(A,B), join(A,C))

now if A is an complex expression, that is a bad idea (probably).

If A is a small VALUES block then it makes sense.  It isn't done though.



both of which are significant, but remain side matters to the principal issue, 
which concerns a reasonable expectation - despite that it may be subject to 
revision, that the values clause introduces bindings with indefinite scope.[1]


The performance issue is that

{ P1 OPTIONAL{P2} VALUES } != { VALUES P1 OPTIONAL{P2} }
but is instead:
{ P1 OPTIONAL{P2} VALUES } == { VALUES...{} { P1 OPTIONAL{P2} } }

but in this data it gets the same answers (presumably) and rather faster.

This is not really about EXISTS at all.  Other {P} will have the same 
effect.


The programming notion of scope is only an analogy for query languages. 
In a query language, same scope means same reference - ie. equivalence. 
"Same scope" in a query language means equality-inner-join at some later 
point to test they are the same value. Equating variables from 
sub-pattern evaluation is like SQL "natural join".


The optimizer is finding situations when equality can be executed as 
equivalence (c.f. index join).


In ARQ execution, variables are transformed by renaming apart early in 
optimization making static scoping a non-issue for the rule based 
optimizations.


Andy



as sparql plays in increasingly significant role in service implementations, 
library-level support for query parameters[2] needs to give way to 
protocol-level mechanisms,[3] whereby the language semantics needs more 
attention than it has yet received.
both immediately federated request combinations and request chains which are 
mediated by a third service need to  propagate intermediate solution sets 
across requests.
the use case behind this question is one example.

the implementations for elementary variables[3] do not provide sufficient 
capacity - not to mention the deficiencies of their substitution models.
the sparql federated query recommendation suggests a role which the values 
clause might play,[4] but does not provide an exact interpretation.

has jena’s community given this topic any thought?

best regards, from berlin,
- - -
[1] : 
http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node43.html#SECTION0070
[2] : 
https://jena.apache.org/documentation/query/parameterized-sparql-strings.html
[3] : http://docs.rdf4j.org/rest-api/#_repository_queries
[4] : http://www.w3.org/TR/sparql11-federated-query/#values


---
james anderson | ja...@dydra.com | http://dydra.com








Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread Rob Vesse
They seem to be conflating two different things here

 We do use and support Standard JDBC Driver initialisation. We also use the 
same underlying Java mechanism i.e. ServiceLoader to initialise Jena itself. 
Our JDBC driver initialisation invokes our Jena initialisation. So as far as 
we’re concerned we are not doing anything wrong:

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java#L178

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java#L95

https://github.com/apache/jena/blob/master/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java#L90

As Andy has pointed out there was a bug in how the bundle JAR with all the 
drivers was being created which meant that Jena initialisation wasn’t happening 
properly because the composites services file for Jena initialisers wasn’t 
being created properly. If you use the latest 3.1.1-SNAPSHOT builds then this 
is resolved.

lists.apache.org provides a much more modern interface to our mailing lists

Rob

On 02/11/2016 03:10, "omar.k...@wellsfargo.com"  
wrote:

Hi Andy - further info from Ramesh ; thanks for your patience  - he was 
having access accessing /reading MarkMail - so I'm relaying (original from 
bottom of https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism with 
standard JDBC4 ServiceLoader mechanism like 

https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class possibly 
in a "static block" call ARQ.init() that will initialize every time one uses 
their JDBC driver. "
 
-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> Thanks Andy!
>
> Question - who is responsible for loading the JDBC driver, and how does 
one load it?
>
> I'm not clear on exact details on how to get it to work. I reached out to 
the Teiid team, and Ramesh has a question for you .
>
> Can you look at the bottom of this thread for the question from Ramesh?
>
> https://developer.jboss.org/thread/272656

Firstly - I didn't write and don't use jena-jdbc so my level of expertise 
is limited.  The initialization of Jena in shaded jars is something that has 
come up before.

It looks like the problem is at the Jena initialization step, not the 
loading the JDBC driver. That's supposed to be automatic and is - the crash 
happens because the initialization is incomplete or is happening in the wrong 
order because the normal sequence isn't happening.

In yoru code, if you can, call ARQ.init() before anything else.  Calling it 
repeatedly is safe and cheap.

Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver to 
load.  Standard way for Java.

Andy


>
>
> -Original Message-
> From: Andy Seaborne [mailto:a...@apache.org]
> Sent: Tuesday, November 01, 2016 5:49 AM
> To: users@jena.apache.org
> Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror
>
>
>> I checked and the jena-jdbc-driver-bundle does not set up the 
>> ServiceLoader services correctly.  We'll fix that.
>
> jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a 
development with it in.
>
>  Andy
>
>>
>> But I don't immediately see why using the jars directly does not 
>> work, but that's due to my lack of knowledge about Teiid and JBoss.
>>
>> Is there any repackaging going on?
>>
>> Andy
>







Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-02 Thread Andy Seaborne



On 02/11/16 03:10, omar.k...@wellsfargo.com wrote:

Hi Andy - further info from Ramesh ; thanks for your patience  - he was having 
access accessing /reading MarkMail - so I'm relaying (original from bottom of 
https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism with 
standard JDBC4 ServiceLoader mechanism like
https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class possibly in a "static 
block" call ARQ.init() that will initialize every time one uses their JDBC driver. "


Yes - that is what the jena-jdbc does in jena-jdbc-driver-remote and 
also jena-jdbc-bundle-driver. The latter had a problem (JENA-1255) which 
is fixed but you report it happening with jena-jdbc-driver-remote and a 
list of jars.


If the jars are used as jars, no repacking then all the service files 
will be present and, subject to classlaoder weirdness, it is the test 
form in Jena development.


What is not clear from your messages is why when using the dependency 
'jena-jdbc-driver-remote' directly, you get the same error.



jena-core, jena-arq have

META-INF/service/org.apache.jena.system.JenaSubsystemLifecycle

files

--

Caused by: java.sql.SQLException: Not a valid SPARQL query/update
   at 
org.apache.jena.jdbc.statements.JenaStatement.execute(JenaStatement.java:273)


  Jena JDBC code is running so driver found 
presumably.
   at 
org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:182)
   at 
org.teiid.translator.jdbc.JDBCDirectQueryExecution.execute(JDBCDirectQueryExecution.java:83)

   ... 17 more


Then there is an attempt to parse a query that fails because jena is 
partially initialized.  This is not the driver.


The question is why Jena is partially initialized.

In building your application,  what does this do:




  









does this get repacked into a combined jar or war file?  I don't know 
JBoss let alone Teiid.


If so, that step has to correctly combine services files for:

META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle

and it should contain at least:

org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
org.apache.jena.system.InitJenaCore

(order does not matter)



Or try the latest development jena-jdbc-bundle-driver snapshot build.

Andy



-Original Message-
From: Andy Seaborne [mailto:a...@apache.org]
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:

Thanks Andy!

Question - who is responsible for loading the JDBC driver, and how does one 
load it?

I'm not clear on exact details on how to get it to work. I reached out to the 
Teiid team, and Ramesh has a question for you .

Can you look at the bottom of this thread for the question from Ramesh?

https://developer.jboss.org/thread/272656


Firstly - I didn't write and don't use jena-jdbc so my level of expertise is 
limited.  The initialization of Jena in shaded jars is something that has come 
up before.

It looks like the problem is at the Jena initialization step, not the loading 
the JDBC driver. That's supposed to be automatic and is - the crash happens 
because the initialization is incomplete or is happening in the wrong order 
because the normal sequence isn't happening.

In yoru code, if you can, call ARQ.init() before anything else.  Calling it 
repeatedly is safe and cheap.

Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver to 
load.  Standard way for Java.

Andy





-Original Message-
From: Andy Seaborne [mailto:a...@apache.org]
Sent: Tuesday, November 01, 2016 5:49 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



I checked and the jena-jdbc-driver-bundle does not set up the
ServiceLoader services correctly.  We'll fix that.


jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a development 
with it in.

 Andy



But I don't immediately see why using the jars directly does not
work, but that's due to my lack of knowledge about Teiid and JBoss.

Is there any repackaging going on?

Andy




Re: Handling named graphs in Jena.

2016-11-02 Thread Andy Seaborne



On 02/11/16 02:28, Jason Koh wrote:

Thanks for the answers! It solved the error. But I got a followup
question...

After constructing a named graph with the previous code, I tried to SELECT
all the triples in the graph by the following query, and it gives nothing...

/
String selectQueryStr = "SELECT ?s ?p ?o where{GRAPH {?s
?p ?o}}";
Query selectQuery = QueryFactory.create(selectQueryStr, Syntax.syntaxARQ);
QueryExecution sqe = QueryExecutionFactory.create(selectQuery,
 resultModel);
ResultSet resultset = sqe.execSelect();
//

And I found
1) resultset is empty
2) The model generated by CONSTRUCT query is empty. (Only prefixes are
stored.)

Hope I can get another chance to get answers.


1/ CONSTRUCT QUAD returns a dataset. The code above queries 
"resultModel" the thing being queried ("resultModel" in both this 
message and your initial one) which does not change in a query.


2/ You are querying a model so only the default graph has any data in it.

SELECT * { {?s ?p ?o} UNION { GRAPH ?g { ?s ?p ?o } } }


If you want to change the target,
you need SPARQL UPDATE.

If you want to query the result of the CONSTRUCT quads,
you want something like:

# email 1:
Model model = ModelFactory.createDefaultModel();
String queryStr ="CONSTRUCT {GRAPH  {  .} }
WHERE{}";
Query query = QueryFactory.create(queryStr);
QueryExecution qe1 = QueryExecutionFactory.create(query,  resultModel);

Dataset dataset = qe.execConstructDataset();
 ^^^

// Query resulting dataset
QueryExecution qe2 = QueryExecutionFactory.create(query2, dataset);
   ^^


In SPARQL Update there is also

   COPY DEFAULT TO GRAPH  ;

and

String queryStr ="CONSTRUCT {GRAPH  {  .} }
WHERE{}";

in terms of update is

INSERT DATA {GRAPH  {  .} }

Be careful about the lack of trailing / on .

Andy



Thanks a lot!



With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh

On Tue, Nov 1, 2016 at 5:34 PM, Martynas Jusevičius 
wrote:


1. You haven't followed the example. You are missing Syntax.syntaxARQ
in QueryFactory.create(), I guess this makes a difference since
CONSTRUCT with quads is not standard SPARQL.

2. Because INSERT is an update and not a query? Se UpdateFactory:
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/update/
UpdateFactory.html

On Wed, Nov 2, 2016 at 1:30 AM, Jason Koh  wrote:

 Dear all,

This might be due to my lack of knowledge on SPARQL syntax.

1.
I try to construct a named graph via SPARQL query, but it fails.
so What I did is like following
///
Model model = ModelFactory.createDefaultModel();
String queryStr ="CONSTRUCT {GRAPH  { 

.} }

WHERE{}";
Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create(query,  resultModel);
/

It fails at the third line while it is parsing with this error message:
Exception in thread "main" org.apache.jena.query.QueryParseException:
Encountered " "graph" "GRAPH "" at line 1, column 335.

I am thinking that I am following
https://jena.apache.org/documentation/query/construct-quad.html

correctly.


Could you tell me the problem in the query?


2.
Actually I rather want to use INSERT instead of CONSTRUCT, but

QueryFactory

cannot parse INSERT. Why is that?

Thanks!


With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh






Re: Use variable in SPARQL query

2016-11-02 Thread Lorenz B.
It should be clear that String concatenation calls the toString() method
of your object. We don't know how this is implemented in your code though.

> Will simply putting a variable inside a query work?
>
> {?emp rdf:type "+employee+"}";
>
> On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni  wrote:
>
>> Hi Tina,
>>
>> You can have your query stored in a composed java string (e.g. String query
>> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
>>
>> Hope that helps
>> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
>>
>>> Hello.
>>>
>>> How can I use a Java variable in the SPARQL query.
>>> ?emp rdf:type ?SomeVariable
>>>
>>> I want rdf:type of Managers and Technicals while these two
>> values(Managers
>>> and Technicals) are in my Java variable: employee.
>>>
>>> So I need something like:
>>>
>>> ?emp rdf:type "employee"
>>>
>>> Regards
>>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center