annotate src/es/cbgp/galaxy/sparql/jena/OntologyManager.java @ 0:137f9a4a6337 draft

First version to init the repo, still README etc to add but it works
author mikel-egana-aranguren
date Thu, 25 Oct 2012 12:17:40 -0400
parents
children b8bf1af83841
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
137f9a4a6337 First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff changeset
5 import com.hp.hpl.jena.ontology.OntModel;
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;
137f9a4a6337 First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff changeset
12 private OntModel model;
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 {
137f9a4a6337 First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff changeset
22 this.model = ModelFactory.createOntologyModel();
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 }