Re: SPARQL Query not working

2015-09-02 Thread Andy Doddington
No code attached?

—

On 2 Sep 2015, at 04:16, Jenny Jin  wrote:

Hello,

I am trying to run a SPARQL query on Eclipse using Jena.
I followed an online tutorial to set everything up.
When I run the program, I'm getting a list of "null"s as a result.
Could you help me with this? Am I doing something wrong?

I am attaching my code.
Thank you for your time.

-Jenny Jin



Re: What is the error in code

2015-08-21 Thread Andy Doddington
Then I think you must have changed your code. The original code does not show 
any space between
the “?y” and the “WHERE” - which was the cause of the problem. However, you now 
have a space
there.

Is this code still generating the error message about ”xWHERE?

Andy D
———

On 21 Aug 2015, at 10:29, kumar rohit kumar.en...@gmail.com wrote:

I did with System.out.print(querystring) and the output is:

PREFIX ss:http://www.semanticweb.orgSELECT ?y  WHERE  { ?y ss:hasson
ss:zia }

On Fri, Aug 21, 2015 at 9:59 AM, Lorenz Bühmann 
buehm...@informatik.uni-leipzig.de wrote:

 Hello Kumar,
 
 why don't you print the query string in Java first to the console using
 System.out.println(queryString); ? Then you will see how your concatenated
 string looks like and that there is a missing space after ?y resp. before
 WHERE.
 
 Kind regards,
 Lorenz
 
 Thank you the syntax error removes but it gives me error xWHERE.. I know
 very minor mistake but not sure where it is.
 
 __
 *String querystring=PREFIX ss:http://www.semanticweb.org
 http://www.semanticweb.org +SELECT ?y +*
 * WHERE { +  ?y ss:hasson ss:zia  + };*
 
 
 ___
 
 On Thu, Aug 20, 2015 at 9:48 PM, Andy Seaborne a...@apache.org wrote:
 
 On 20/08/15 21:19, aj...@virginia.edu wrote:
 
 This may or may not be the entire problem, but in the line:
 
 String querystring=PREFIX ss:http://www.semanticweb.org; +SELECT ?x
 
 + WHERE { + ?x ss:hasson ss:zia + };
 
 you opened the angle-brackets around your namespace without closing
 them.
 
 Exactly.
 
 Exception in thread main com.hp.hpl.jena.query.QueryParseException:
 Encountered at line 1, column 11.
 
 
 Put some newlines into the string!
 
 ... and then the next error is at SELECT ?x + WHERE whch is
 SELECT ?xWHERE {
 
 i.e a variable called xWHERE
 
 
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Aug 20, 2015, at 4:15 PM, kumar rohit kumar.en...@gmail.com wrote:
 
 import java.io.InputStream;
 
 import com.hp.hpl.jena.ontology.OntDocumentManager;
 import com.hp.hpl.jena.ontology.OntModel;
 import com.hp.hpl.jena.ontology.OntModelSpec;
 import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.query.QueryExecution;
 import com.hp.hpl.jena.query.QueryExecutionFactory;
 import com.hp.hpl.jena.query.QueryFactory;
 import com.hp.hpl.jena.query.ResultSet;
 import com.hp.hpl.jena.query.ResultSetFormatter;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import com.hp.hpl.jena.util.FileManager;
 
 
 public class famtree {
 static final String inputfile =(C://Users//asad
 ali//Desktop//Project//protege//relation.owl);
 
 public static void main(String[] args) {
 OntDocumentManager mgr=new OntDocumentManager();
 
 OntModelSpec spec=new OntModelSpec(OntModelSpec.OWL_DL_MEM);
 
 spec.setDocumentManager(mgr);
 
 OntModel m = ModelFactory.createOntologyModel(spec,null);
 
 InputStream in=FileManager.get().open(inputfile);
 if (in==null)
 {
 throw new IllegalArgumentException(File + inputfile + not found);
 }
 m.read(in,);
 
 String querystring=PREFIX ss:http://www.semanticweb.org; +SELECT
 ?x
 +
 WHERE { + ?x ss:hasson ss:zia + };
 
 Query query=QueryFactory.create(querystring);
 
 QueryExecution qe = QueryExecutionFactory.create(query, m);
 
 ResultSet results = qe.execSelect();
 
 ResultSetFormatter.out(System.out, results, query);
 
 qe.close();
 }
 }
 
 The following error displays in Eclipse
 ___
 
 Exception in thread main com.hp.hpl.jena.query.QueryParseException:
 Encountered at line 1, column 11.
 Was expecting:
 IRIref ...
 
 at
 
 
 com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:102)
 at
 
 com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
 at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
 at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
 at familytree.famtree.main(famtree.java:37)
 
 
 --
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web research center
 
 



Re: Can I save an in-memory Jena Model to a remote Fuseki-managed database?

2015-08-19 Thread Andy Doddington
That’s great - in the end I solved the problem by adding the line:

/$/** = anon

to the shiva.ini file.

Many thanks for all your help (and patience).

Andy D


On 18 Aug 2015, at 22:45, Andy Seaborne a...@apache.org wrote:

Out of the box, the UI only responds to the localhost. If you access it
from a different machine, or (unfortunately) the same machine but its
external IP address, the Fuseki refuses access to the JSON calls driving
the interface. You can change the default to a user/password.

https://jena.apache.org/documentation/fuseki2/fuseki-security.html

   Andy

On Tue, 18 Aug 2015 17:48 Andy Doddington andy.dodding...@gmail.com wrote:

 Hah! I hadn’t configured a dataset. Now rectified by setting the
 config.ttl to be one of the templates provided
 as part of the build.
 
 Curiously though, although I can see this when I run a browser locally on
 the server, and set the url to localhost:3030,
 I don't see any datasets listed when I explicitly specify the ip address,
 nor when I try to access it from any other box.
 
 I realise that I’ve gone *wy* off topic now, so unless the answer is
 obvious, don't feel the need to address this new
 issue. I’ll try searching in the fuseki knowledge base. Oh and btw: I
 don’t have any firewall set up, afaik (although
 if I did, I’d expect this to block the entire fuseki site, rather than
 just the dataset listings.
 
 Sheeesh, this is tiring :-/
 
 Andy D
 
 —
 
 On 18 Aug 2015, at 12:11, Andy Seaborne a...@apache.org wrote:
 
 The dataset (not the graph)  needs to exist before the operation is
 attempted.  e.g. via the UI, or via startup with --update /ds for a name
 of ds.
 
 http://foobar:3030/myDatasetName/data
 
 /myDatasetName --  dataset name - must exist
 /myDatasetName/data -- service endpoint for GSP on that dataset (thats'
 the default name
 
 and update must enabled.  How are you running the server?
 
 
 
Andy
 
 On 18/08/15 11:49, Andy Doddington wrote:
 You’ll think me very dense, but how do I specify the dataset name? When
 I specify the dummy URL that
 you suggest (I don’t care what the dataset is called at the moment) I
 get:
 
  Exception in thread main
 org.apache.jena.atlas.web.HttpException: 404 - Not Found
 
 I feel I’m missing some trivial step here, but don’t know what it is :-(
 
 Andy D
 ——
 
 On 18 Aug 2015, at 09:36, Andy Seaborne a...@apache.org wrote:
 
 Wrong URL: It will be something like
 
  http://foobar:3030/myDatasetName/data
 
 which is the service endpoint for the Graph Store protocol by default.
 (It needs a config file to change it - the UI puts it there automatically)
 where the query one is http://foobar:3030/myDatasetName/query and the
 SPARQL Update one is http://foobar:3030/myDatasetName/update.
 
 myDatasetName is whatever you you decided to call it.
 
 ((
 What you have actually done is POSTed to the web pages serving part of
 the UI at index.html.  It just returns the web page.  if anything POSTs to
 an HTML page, the content is thrown away (AFAIK true for all webservers).
 ))
 
  Andy
 
 
 On 18/08/15 09:17, Andy Doddington wrote:
 OK, I’ve created the model, which I can successfully print out using
 'model.write(System.out, RDF/XML-ABBREV”);'
 
 However, when I use your code below, and do an acc.put(model) I find
 that there is nothing on the server, even though
 no errors are indicated.
 
 The URL that I am using for the createHTTP request is the URL of my
 Fuseki server: http://foobar:3030”, which I
 am inspecting using the built in web-based browser.
 
 At the risk of stretching your patience, can you explain what I’m doing
 wrong? Given that there are no errors, I would
 have expected the model to appear somewhere or other :-/ If I specify
 an invalid URL (e.g. incorrect port) then
 I get an error, which seems to indicate that the code is actually
 talking to the server.
 
 Thanks,
 
 Andy D.
 
 
 On 17 Aug 2015, at 20:19, Andy Seaborne a...@apache.org wrote:
 
 DatasetAccessor
 
 This is the API to the SPARQL Graph Store Protocol.
 
 Model model = ...
 DatasetAccessor acc = DatasetAccessorFactory.createHTTP
 (http://.../datasets/data;) ;
 acc.add(model) ; // adds to existign data, if any.
 
 or
 
 acc.putModel(model) -- which overwrites existing data
 
 On 17/08/15 20:11, aj...@virginia.edu wrote:
 There may be a better answer for this, but at the very least, you can
 serialize your triples/quads and use SPARQL Update to send them to your
 Fuseki instance.
 
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Aug 17, 2015, at 3:08 PM, Andy Doddington 
 andy.dodding...@gmail.com wrote:
 
 
 On 17 Aug 2015, at 19:50, Andy Doddington 
 andy.dodding...@googlemail.com wrote:
 
 Hoping the subject makes my query clear - since I am a total newbie
 in this area.
 
 I have created a tiny model, using ModelFactory.createDefaultModel()
 to  create my initially empty model,
 which I then populate manually.
 
 So

Re: Can I save an in-memory Jena Model to a remote Fuseki-managed database?

2015-08-18 Thread Andy Doddington
You’ll think me very dense, but how do I specify the dataset name? When I 
specify the dummy URL that
you suggest (I don’t care what the dataset is called at the moment) I get:

Exception in thread main org.apache.jena.atlas.web.HttpException: 404 
- Not Found

I feel I’m missing some trivial step here, but don’t know what it is :-(

Andy D
——

On 18 Aug 2015, at 09:36, Andy Seaborne a...@apache.org wrote:

Wrong URL: It will be something like

  http://foobar:3030/myDatasetName/data

which is the service endpoint for the Graph Store protocol by default. (It 
needs a config file to change it - the UI puts it there automatically) where 
the query one is http://foobar:3030/myDatasetName/query and the SPARQL Update 
one is http://foobar:3030/myDatasetName/update.

myDatasetName is whatever you you decided to call it.

((
What you have actually done is POSTed to the web pages serving part of the UI 
at index.html.  It just returns the web page.  if anything POSTs to an HTML 
page, the content is thrown away (AFAIK true for all webservers).
))

Andy


On 18/08/15 09:17, Andy Doddington wrote:
 OK, I’ve created the model, which I can successfully print out using 
 'model.write(System.out, RDF/XML-ABBREV”);'
 
 However, when I use your code below, and do an acc.put(model) I find that 
 there is nothing on the server, even though
 no errors are indicated.
 
 The URL that I am using for the createHTTP request is the URL of my Fuseki 
 server: http://foobar:3030”, which I
 am inspecting using the built in web-based browser.
 
 At the risk of stretching your patience, can you explain what I’m doing 
 wrong? Given that there are no errors, I would
 have expected the model to appear somewhere or other :-/ If I specify an 
 invalid URL (e.g. incorrect port) then
 I get an error, which seems to indicate that the code is actually talking to 
 the server.
 
 Thanks,
 
   Andy D.
 
 
 On 17 Aug 2015, at 20:19, Andy Seaborne a...@apache.org wrote:
 
 DatasetAccessor
 
 This is the API to the SPARQL Graph Store Protocol.
 
 Model model = ...
 DatasetAccessor acc = DatasetAccessorFactory.createHTTP
   (http://.../datasets/data;) ;
 acc.add(model) ; // adds to existign data, if any.
 
 or
 
 acc.putModel(model) -- which overwrites existing data
 
 On 17/08/15 20:11, aj...@virginia.edu wrote:
 There may be a better answer for this, but at the very least, you can 
 serialize your triples/quads and use SPARQL Update to send them to your 
 Fuseki instance.
 
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Aug 17, 2015, at 3:08 PM, Andy Doddington andy.dodding...@gmail.com 
 wrote:
 
 
 On 17 Aug 2015, at 19:50, Andy Doddington andy.dodding...@googlemail.com 
 wrote:
 
 Hoping the subject makes my query clear - since I am a total newbie in this 
 area.
 
 I have created a tiny model, using ModelFactory.createDefaultModel() to  
 create my initially empty model,
 which I then populate manually.
 
 So, having done this, is there any way that I can persist this to a Fuseki 
 database running on a remote server?
 
 Thanks for any help,
 
 Andy D
 
 
 
 
 




Re: Can I save an in-memory Jena Model to a remote Fuseki-managed database?

2015-08-18 Thread Andy Doddington
OK, I’ve created the model, which I can successfully print out using 
'model.write(System.out, RDF/XML-ABBREV”);'

However, when I use your code below, and do an acc.put(model) I find that there 
is nothing on the server, even though
no errors are indicated.

The URL that I am using for the createHTTP request is the URL of my Fuseki 
server: http://foobar:3030”, which I
am inspecting using the built in web-based browser.

At the risk of stretching your patience, can you explain what I’m doing wrong? 
Given that there are no errors, I would
have expected the model to appear somewhere or other :-/ If I specify an 
invalid URL (e.g. incorrect port) then
I get an error, which seems to indicate that the code is actually talking to 
the server.

Thanks,

Andy D.


On 17 Aug 2015, at 20:19, Andy Seaborne a...@apache.org wrote:

DatasetAccessor

This is the API to the SPARQL Graph Store Protocol.

Model model = ...
DatasetAccessor acc = DatasetAccessorFactory.createHTTP
(http://.../datasets/data;) ;
acc.add(model) ; // adds to existign data, if any.

or

acc.putModel(model) -- which overwrites existing data

On 17/08/15 20:11, aj...@virginia.edu wrote:
 There may be a better answer for this, but at the very least, you can 
 serialize your triples/quads and use SPARQL Update to send them to your 
 Fuseki instance.
 
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Aug 17, 2015, at 3:08 PM, Andy Doddington andy.dodding...@gmail.com 
 wrote:
 
 
 On 17 Aug 2015, at 19:50, Andy Doddington andy.dodding...@googlemail.com 
 wrote:
 
 Hoping the subject makes my query clear - since I am a total newbie in this 
 area.
 
 I have created a tiny model, using ModelFactory.createDefaultModel() to  
 create my initially empty model,
 which I then populate manually.
 
 So, having done this, is there any way that I can persist this to a Fuseki 
 database running on a remote server?
 
 Thanks for any help,
 
  Andy D
 
 





Re: Can I save an in-memory Jena Model to a remote Fuseki-managed database?

2015-08-18 Thread Andy Doddington
Hah! I hadn’t configured a dataset. Now rectified by setting the config.ttl to 
be one of the templates provided
as part of the build.

Curiously though, although I can see this when I run a browser locally on the 
server, and set the url to localhost:3030,
I don't see any datasets listed when I explicitly specify the ip address, nor 
when I try to access it from any other box.

I realise that I’ve gone *wy* off topic now, so unless the answer is 
obvious, don't feel the need to address this new
issue. I’ll try searching in the fuseki knowledge base. Oh and btw: I don’t 
have any firewall set up, afaik (although
if I did, I’d expect this to block the entire fuseki site, rather than just the 
dataset listings.

Sheeesh, this is tiring :-/

Andy D

—

On 18 Aug 2015, at 12:11, Andy Seaborne a...@apache.org wrote:

The dataset (not the graph)  needs to exist before the operation is attempted.  
e.g. via the UI, or via startup with --update /ds for a name of ds.

http://foobar:3030/myDatasetName/data

/myDatasetName --  dataset name - must exist
/myDatasetName/data -- service endpoint for GSP on that dataset (thats' the 
default name

and update must enabled.  How are you running the server?



Andy

On 18/08/15 11:49, Andy Doddington wrote:
 You’ll think me very dense, but how do I specify the dataset name? When I 
 specify the dummy URL that
 you suggest (I don’t care what the dataset is called at the moment) I get:
 
   Exception in thread main org.apache.jena.atlas.web.HttpException: 404 
 - Not Found
 
 I feel I’m missing some trivial step here, but don’t know what it is :-(
 
 Andy D
 ——
 
 On 18 Aug 2015, at 09:36, Andy Seaborne a...@apache.org wrote:
 
 Wrong URL: It will be something like
 
   http://foobar:3030/myDatasetName/data
 
 which is the service endpoint for the Graph Store protocol by default. (It 
 needs a config file to change it - the UI puts it there automatically) where 
 the query one is http://foobar:3030/myDatasetName/query and the SPARQL Update 
 one is http://foobar:3030/myDatasetName/update.
 
 myDatasetName is whatever you you decided to call it.
 
 ((
 What you have actually done is POSTed to the web pages serving part of the UI 
 at index.html.  It just returns the web page.  if anything POSTs to an HTML 
 page, the content is thrown away (AFAIK true for all webservers).
 ))
 
   Andy
 
 
 On 18/08/15 09:17, Andy Doddington wrote:
 OK, I’ve created the model, which I can successfully print out using 
 'model.write(System.out, RDF/XML-ABBREV”);'
 
 However, when I use your code below, and do an acc.put(model) I find that 
 there is nothing on the server, even though
 no errors are indicated.
 
 The URL that I am using for the createHTTP request is the URL of my Fuseki 
 server: http://foobar:3030”, which I
 am inspecting using the built in web-based browser.
 
 At the risk of stretching your patience, can you explain what I’m doing 
 wrong? Given that there are no errors, I would
 have expected the model to appear somewhere or other :-/ If I specify an 
 invalid URL (e.g. incorrect port) then
 I get an error, which seems to indicate that the code is actually talking to 
 the server.
 
 Thanks,
 
  Andy D.
 
 
 On 17 Aug 2015, at 20:19, Andy Seaborne a...@apache.org wrote:
 
 DatasetAccessor
 
 This is the API to the SPARQL Graph Store Protocol.
 
 Model model = ...
 DatasetAccessor acc = DatasetAccessorFactory.createHTTP
  (http://.../datasets/data;) ;
 acc.add(model) ; // adds to existign data, if any.
 
 or
 
 acc.putModel(model) -- which overwrites existing data
 
 On 17/08/15 20:11, aj...@virginia.edu wrote:
 There may be a better answer for this, but at the very least, you can 
 serialize your triples/quads and use SPARQL Update to send them to your 
 Fuseki instance.
 
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Aug 17, 2015, at 3:08 PM, Andy Doddington andy.dodding...@gmail.com 
 wrote:
 
 
 On 17 Aug 2015, at 19:50, Andy Doddington andy.dodding...@googlemail.com 
 wrote:
 
 Hoping the subject makes my query clear - since I am a total newbie in 
 this area.
 
 I have created a tiny model, using ModelFactory.createDefaultModel() to  
 create my initially empty model,
 which I then populate manually.
 
 So, having done this, is there any way that I can persist this to a Fuseki 
 database running on a remote server?
 
 Thanks for any help,
 
Andy D