Mercurial > repos > mikel-egana-aranguren > sparql_galaxy
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/es/cbgp/galaxy/sparql/jena/OntologyManager.java Thu Oct 25 12:17:40 2012 -0400 @@ -0,0 +1,32 @@ +package es.cbgp.galaxy.sparql.jena; + +import java.io.File; + +import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.rdf.model.ModelFactory; + +public class OntologyManager { + + private String ontFile; + private String sparqlFile; + private OntModel model; + private SPARQLQueryEngine sqe; + + public OntologyManager(String of, String sf) throws Exception { + this.ontFile = of; + this.sparqlFile = sf; + init(); + } + + private void init() throws Exception { + this.model = ModelFactory.createOntologyModel(); + this.model.read(new File(ontFile).toURI().toString()); + } + + public void executeQuery() throws Exception { + this.sqe = new SPARQLQueryEngine(model); + this.sqe.setQueryFile(sparqlFile); + String ret = sqe.executeQuery(); + System.out.println(ret); + } +}