view src/es/cbgp/galaxy/sparql/jena/OntologyManager.java @ 1:117a4b4c002d draft

Added README but installation procedure not tested yet, pushed for backup
author Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Thu, 25 Oct 2012 18:35:25 +0200
parents 137f9a4a6337
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);
	}
}