Mercurial > repos > mikel-egana-aranguren > sparql_galaxy
annotate src/es/cbgp/galaxy/sparql/jena/OntologyManager.java @ 2:b8bf1af83841 draft
Paste query added, query engine improved, examples added
author | Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Wed, 04 Dec 2013 08:17:00 +0100 |
parents | 137f9a4a6337 |
children |
rev | line source |
---|---|
0
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
1 package es.cbgp.galaxy.sparql.jena; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
2 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
3 import java.io.File; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
4 |
2
b8bf1af83841
Paste query added, query engine improved, examples added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
0
diff
changeset
|
5 import com.hp.hpl.jena.rdf.model.Model; |
0
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
6 import com.hp.hpl.jena.rdf.model.ModelFactory; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
7 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
8 public class OntologyManager { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
9 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
10 private String ontFile; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
11 private String sparqlFile; |
2
b8bf1af83841
Paste query added, query engine improved, examples added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
0
diff
changeset
|
12 private Model model; |
0
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
13 private SPARQLQueryEngine sqe; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
14 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
15 public OntologyManager(String of, String sf) throws Exception { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
16 this.ontFile = of; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
17 this.sparqlFile = sf; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
18 init(); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
19 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
20 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
21 private void init() throws Exception { |
2
b8bf1af83841
Paste query added, query engine improved, examples added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
0
diff
changeset
|
22 this.model = ModelFactory.createDefaultModel(); |
0
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
23 this.model.read(new File(ontFile).toURI().toString()); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
24 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
25 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
26 public void executeQuery() throws Exception { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
27 this.sqe = new SPARQLQueryEngine(model); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
28 this.sqe.setQueryFile(sparqlFile); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
29 String ret = sqe.executeQuery(); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
30 System.out.println(ret); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
31 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
32 } |