Trace back RDF containers in SPARQL

2015-05-06 Thread Laurent Rucquoy
Hello,

I have container resources which I want to retrieve from one of their
elements.
Here is an RDF/XML part of my data:


rdf:Description rdf:about=
http://www.telemis.com/CalculationResult/9e892a88-7257-4af3-881d-2eb304437546

rdf:type rdf:resource=http://www.telemis.com/CalculationResult/
TM:uid rdf:datatype=http://www.w3.org/2001/XMLSchema#string
9e892a88-7257-4af3-881d-2eb304437546/TM:uid
...
/rdf:Description

rdf:Description rdf:nodeID=A525
rdf:type rdf:resource=http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq/
rdf:_1 rdf:resource=
http://www.telemis.com/CalculationResult/9e892a88-7257-4af3-881d-2eb304437546
/
rdf:_2 rdf:resource=
http://www.telemis.com/CalculationResult/9e892a88-7257-4af3-881d-45208e34af13
/
/rdf:Description

rdf:Description rdf:about=
http://www.telemis.com/CalculationResultCollection/a7d808d7-7689-4dfb-82c4-b0763f0dcd34

rdf:type rdf:resource=http://www.telemis.com/CalculationResultCollection
/
TM:uid rdf:datatype=http://www.w3.org/2001/XMLSchema#string
a7d808d7-7689-4dfb-82c4-b0763f0dcd34/TM:uid
TM:listCalculationResult rdf:nodeID=A525/
/rdf:Description


The representation of this context could be:

(CalculationResultCollection)
--listCalculationResult--
(seq-blank-node)
+--(rdf:_1)--(CalculationResult1)
+--(rdf:_2)--(CalculationResult2)
+--...

I've a SPARQL query which gives me a set of CalculationResult nodes.
My question is: by which SPARQL query can I trace back to the
CalculationResultCollection containing resource(s) ?

Here is the SPARQL query which gives me a set of CalculationResult nodes:

PREFIX : http://www.telemis.com/
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#

SELECT ?calculationResult
WHERE {
?calculationData a :CalculationData ;
:value 0^^xsd:string .
?seqCalculationDataCollection ?seqCalculationDataCollectionIndex
?calculationData .
?calculationDataCollection a :CalculationDataCollection ;
:listCalculationData ?seqCalculationDataCollection .
?calculationResult a :CalculationResult ;
:calculationDataCollection ?calculationDataCollection .
}

I tried to complete my WHERE clause with statements like I did to trace
back to ?calculationDataCollection from ?calculationData but I cannot get
the wanted result because the system freezes. Note that the SPARQL query
here above returns good results.

Is there a better practice to do that with acceptable performances ?

Thank you in advance for your help.



-- 
*Laurent Rucquoy*
RD Engineer

laurent.rucq...@telemis.com
Tel: +32 (0) 10 48 00 27
Fax: +32 (0) 10 48 00 20

Telemis
Avenue Athéna 2
1348 Louvain-la-Neuve
Belgium
www.telemis.com
*Extending Human Life*

Au delà du Pacs...Découvrez le Macs
https://drive.google.com/a/telemis.com/file/d/0B8xEcRPFLfNdRmFRMlRSZ0k5djA/view?usp=sharing
 sur le stand Telemis #118 du 4. - 6 Juin - Centre des congrès de Bâle !


Re: Special chars don't work with Fuseki as Tomcat Webapp

2015-05-06 Thread Osma Suominen

Hi Christian!

I've had similar problems in the past, not with Fuseki, but other Tomcat 
webapps. How about setting the URIEncoding=UTF-8 parameter on the 
Connector in server.xml?


If that doesn't help, you can try the other tips on this page:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8

-Osma

06.05.2015, 19:03, Christian Schwaderer kirjoitti:

Dear all,

I run a small PHP application for which I'd like to use some RDF data with 
Fuseki. To deploy Fuseki as a webapplication wrapped in Tomcat would best fit 
into my server architecture.

However, I've encountered a problem with this kind of design: If a SPARQL query contains 
special chars like the German umlaut (Ä,Ö,Ü,ß and so on, probably other chars 
not in ANSI standard are also affected), it won't work with Fuseki as a Tomcat 
application.

Consider the following sample data:
subject predicate Bär .
and this query:
SELECT * WHERE { ?s ?p Bär . }

It works absolutely fine
a) within the Fuseki web interface
b) when called from a PHP application if Fuseki is started via the command line 
(on Windows 7 64-bit). (I'm using the arc2 library in PHP for SPARQL requests.)

But it won't work when called from PHP if Fuseki is wrapped inside Tomcat.

I'm quite sure this is an encoding problem somewhere. But is there anything I 
can do here?

Thanks in advance and best regards
Christian





--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Teollisuuskatu 23)


Re: Fuseki as Web Application read configuration file

2015-05-06 Thread Andy Seaborne

On 06/05/15 19:03, Christian Schwaderer wrote:

Hi,

thanks for the answer!

The full config file looks like so:

@prefix :# .
@prefix fuseki:  http://jena.apache.org/fuseki# .
@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@prefix rdfs:http://www.w3.org/2000/01/rdf-schema# .
@prefix ja:  http://jena.hpl.hp.com/2005/11/Assembler# .

[] rdf:type fuseki:Server ;

   ja:context [ ja:cxtName arq:queryTimeout ;  ja:cxtValue 4000 ] ;

.

(Comments removed)

Yes, I created the dataset with the UI. How can I remove the dataset timeout 
setting?


There is a bit more in:
http://mail-archives.apache.org/mod_mbox/jena-users/201504.mbox/%3C5533D97F.20406%40apache.org%3E

but the workaround is:

The directory run/system_files has a copy of the file.  This is not the
file the server works off (that's in the database).

0/ Stop the server

1/ If you have only one dataset, copy that file to
run/configuration/mydatabase.ttl (any fresh base name, must end ttl).

2/ Edit the run/configuration file to remove the line:

 ja:context [ ja:cxtName arq:queryTimeout ;  ja:cxtValue 3000 ] ;

or set it to whatever you want.

3/ Delete the system database

4/ Restart the server

Andy



Best,
Christian



Date: Wed, 6 May 2015 18:52:10 +0100
From: a...@apache.org
To: users@jena.apache.org
Subject: Re: Fuseki as Web Application read configuration file

On 06/05/15 18:44, Christian Schwaderer wrote:

Hi again,

I'm almost done setting up Fuseki as Tomcat web application. Still, there is 
another problem: How can I make sure that Fuseki reads its configuration file?

I want to set a timeout (4sec) and thus, I've added the line
ja:context [ ja:cxtName arq:queryTimeout ; ja:cxtValue 4000 ] ;

in the file /etc/fuseki/config.ttl

But it doesn't work. Fuseki still executes queries taking about 20 seconds.
I've also copied the file config.ttl to /etc/fuseki/configuration - but to no 
avail.

Thanks in advance and best regards
Christian




Hi Christian,

What's the full config file? One thing to be aware of is that it is not
set on the datatset as the more specific setting overrides the server
wide setting.

If the TDB database was created via the UI, unfortunately there is a bug
in the template for created TDB databases and it puts in a timout. It
can be removed; the server needs to be restarted.

Andy







Special chars don't work with Fuseki as Tomcat Webapp

2015-05-06 Thread Christian Schwaderer
Dear all,

I run a small PHP application for which I'd like to use some RDF data with 
Fuseki. To deploy Fuseki as a webapplication wrapped in Tomcat would best fit 
into my server architecture.

However, I've encountered a problem with this kind of design: If a SPARQL query 
contains special chars like the German umlaut (Ä,Ö,Ü,ß and so on, probably 
other chars not in ANSI standard are also affected), it won't work with Fuseki 
as a Tomcat application.

Consider the following sample data:
subject predicate Bär .
and this query:
SELECT * WHERE { ?s ?p Bär . }

It works absolutely fine
a) within the Fuseki web interface
b) when called from a PHP application if Fuseki is started via the command line 
(on Windows 7 64-bit). (I'm using the arc2 library in PHP for SPARQL requests.) 

But it won't work when called from PHP if Fuseki is wrapped inside Tomcat.

I'm quite sure this is an encoding problem somewhere. But is there anything I 
can do here?

Thanks in advance and best regards
Christian
  

Re: possibly a problem with fuseki caching

2015-05-06 Thread Andy Seaborne
PS What is your system setup?  32 or 64 bit java?  (caching works 
differently btween those two).  It won't work in either case bu tfor 
different reasons (the index caches are probably shared via memory 
mapped fiels on 64 bit - not on 32 bit - there is also a large in-JVM, 
not shared, cache for the node table)


Andy

On 06/05/15 11:09, Andy Seaborne wrote:

Hi Morten,

The way TDB works, only one application can have the database files at
he same time.  I suspect that the checking TDB performs (you get an
error if multiple access is deteched) is being defeated by running two
webapps in the same, but partition, glassfish instance.  The test, IIRC,
is same process id, which it is for two instances in glassfish.

TDB uses a number of statics to manage shared access to the database.
TDBFactory returns the same database for a location every time.  But if
a class is loaded twice by different classloaders, there are different
statics.

The way to update a database is through the web facing side with SPARQL
Update or the SPARQL Graph Store protocol.  Can your updating .war send
requests to Fuseki?

A more complicated setup would be to have one .war to do all the TDB
access and have a special Fuseki service that knows to send requests to
that 3rd DB-manager .war.  That would take new code.

 Andy

On 05/05/15 20:58, Yarc Yarc wrote:

Hello,

I'm trying to use fuseki for querying live data managed by a web
application. This generally works, but I seem to have a caching problem
with my fuseki. This is the setup;

a. I'm running the fuseki.war over glassfish 4 configured with a dataset
fethced from a TDB file system folder for persistence. That works well it
seems. Data is read from the TDB folder and I can query over port 3030.

b. I have another .war application running in the same glassfish
instance.
This .war uses the same TDB folder for persistence. The application
queries
and updates the TDB folder. The data is persistent in that if I undeploy
the application and redeploy the data is still there.

Now, if the application in b. inserts new data, then this is not
reflected
in the fuseki application (a). If I, however, undeploy and redeploy
fuseki.war then the new data from b. is there.

My initial hypothesis is that fuseki uses a cache at some level, so
that if
the underlying TDB file store changes, it is not picked up. Is this a
reasonable hypothesis?

If so, is there some way I might circumvent this behaviour - i.e. can I
enforce a TDB sync before each query in Fuseki somehow?

If not, then I'm probably confused and I'm asking for a friendly hint on
where I go wrong.

I have read the caching and synchronization section in the
documentation (
https://jena.apache.org/documentation/tdb/java_api.html), generally
googled
this issue (e.g. fuseki cache or share TDB store) and I'm aware of
the
single-jvm constraints on TDB (
https://jena.apache.org/documentation/tdb/tdb_transactions.html) as
well as
a suggested pattern of letting all other clients of a TDB store go
through
fuseki if I understand it correctly (
http://answers.semanticweb.com/questions/28629/sharing-jena-tdb-data-store).



Any and all help is appreciated.

:-)

M.

-- a few excerpts on how b. relates to TDB, commits and the dataset
-

I create my dataset like this:

dataset = TDBFactory.createDataset(datasetdir);

Before each sparql insert I do

dataset.begin(ReadWrite.WRITE);

After each sparql insert I do

try {
dataset.commit();
} catch {
...} finally {
dataset.end();
}







Fuseki as Web Application read configuration file

2015-05-06 Thread Christian Schwaderer
Hi again,

I'm almost done setting up Fuseki as Tomcat web application. Still, there is 
another problem: How can I make sure that Fuseki reads its configuration file?

I want to set a timeout (4sec) and thus, I've added the line
  ja:context [ ja:cxtName arq:queryTimeout ;  ja:cxtValue 4000 ] ;

in the file /etc/fuseki/config.ttl

But it doesn't work. Fuseki still executes queries taking about 20 seconds.
I've also copied the file config.ttl to /etc/fuseki/configuration - but to no 
avail.

Thanks in advance and best regards
Christian
  

RE: Fuseki as Web Application read configuration file

2015-05-06 Thread Christian Schwaderer
Hi,

thanks for the answer!

The full config file looks like so:

@prefix :    # .
@prefix fuseki:  http://jena.apache.org/fuseki# .
@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@prefix rdfs:    http://www.w3.org/2000/01/rdf-schema# .
@prefix ja:  http://jena.hpl.hp.com/2005/11/Assembler# .

[] rdf:type fuseki:Server ;

  ja:context [ ja:cxtName arq:queryTimeout ;  ja:cxtValue 4000 ] ;

   .

(Comments removed)

Yes, I created the dataset with the UI. How can I remove the dataset timeout 
setting?

Best,
Christian


 Date: Wed, 6 May 2015 18:52:10 +0100
 From: a...@apache.org
 To: users@jena.apache.org
 Subject: Re: Fuseki as Web Application read configuration file

 On 06/05/15 18:44, Christian Schwaderer wrote:
 Hi again,

 I'm almost done setting up Fuseki as Tomcat web application. Still, there is 
 another problem: How can I make sure that Fuseki reads its configuration 
 file?

 I want to set a timeout (4sec) and thus, I've added the line
 ja:context [ ja:cxtName arq:queryTimeout ; ja:cxtValue 4000 ] ;

 in the file /etc/fuseki/config.ttl

 But it doesn't work. Fuseki still executes queries taking about 20 seconds.
 I've also copied the file config.ttl to /etc/fuseki/configuration - but to 
 no avail.

 Thanks in advance and best regards
 Christian



 Hi Christian,

 What's the full config file? One thing to be aware of is that it is not
 set on the datatset as the more specific setting overrides the server
 wide setting.

 If the TDB database was created via the UI, unfortunately there is a bug
 in the template for created TDB databases and it puts in a timout. It
 can be removed; the server needs to be restarted.

 Andy
  

Re: Fuseki as Web Application read configuration file

2015-05-06 Thread Andy Seaborne

On 06/05/15 18:44, Christian Schwaderer wrote:

Hi again,

I'm almost done setting up Fuseki as Tomcat web application. Still, there is 
another problem: How can I make sure that Fuseki reads its configuration file?

I want to set a timeout (4sec) and thus, I've added the line
   ja:context [ ja:cxtName arq:queryTimeout ;  ja:cxtValue 4000 ] ;

in the file /etc/fuseki/config.ttl

But it doesn't work. Fuseki still executes queries taking about 20 seconds.
I've also copied the file config.ttl to /etc/fuseki/configuration - but to no 
avail.

Thanks in advance and best regards
Christian




Hi Christian,

What's the full config file? One thing to be aware of is that it is not 
set on the datatset as the more specific setting overrides the server 
wide setting.


If the TDB database was created via the UI, unfortunately there is a bug 
in the template for created TDB databases and it puts in a timout.  It 
can be removed; the server needs to be restarted.


Andy


RE: Special chars don't work with Fuseki as Tomcat Webapp

2015-05-06 Thread Christian Schwaderer
Thank you very much! That did the trick!


 Date: Wed, 6 May 2015 19:15:12 +0300
 From: osma.suomi...@helsinki.fi
 To: users@jena.apache.org
 Subject: Re: Special chars don't work with Fuseki as Tomcat Webapp

 Hi Christian!

 I've had similar problems in the past, not with Fuseki, but other Tomcat
 webapps. How about setting the URIEncoding=UTF-8 parameter on the
 Connector in server.xml?

 If that doesn't help, you can try the other tips on this page:
 http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8

 -Osma

 06.05.2015, 19:03, Christian Schwaderer kirjoitti:
 Dear all,

 I run a small PHP application for which I'd like to use some RDF data with 
 Fuseki. To deploy Fuseki as a webapplication wrapped in Tomcat would best 
 fit into my server architecture.

 However, I've encountered a problem with this kind of design: If a SPARQL 
 query contains special chars like the German umlaut (Ä,Ö,Ü,ß and so on, 
 probably other chars not in ANSI standard are also affected), it won't work 
 with Fuseki as a Tomcat application.

 Consider the following sample data:
 subject predicate Bär .
 and this query:
 SELECT * WHERE { ?s ?p Bär . }

 It works absolutely fine
 a) within the Fuseki web interface
 b) when called from a PHP application if Fuseki is started via the command 
 line (on Windows 7 64-bit). (I'm using the arc2 library in PHP for SPARQL 
 requests.)

 But it won't work when called from PHP if Fuseki is wrapped inside Tomcat.

 I'm quite sure this is an encoding problem somewhere. But is there anything 
 I can do here?

 Thanks in advance and best regards
 Christian




 --
 Osma Suominen
 D.Sc. (Tech), Information Systems Specialist
 National Library of Finland
 P.O. Box 26 (Teollisuuskatu 23)