view 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 source

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);
	}
}