Search in sources :

Example 1 with SparqlResult

use of org.nextprot.api.commons.utils.SparqlResult in project nextprot-api by calipho-sib.

the class SparqlServiceImpl method sparqlSelect.

@Override
public SparqlResult sparqlSelect(String sparql, String sparqlEndpointUrl, int timeout, String queryTitle, String testId, ResultsFormat format) {
    SparqlResult result = null;
    try {
        QueryExecution qExec = QueryExecutionFactory.sparqlService(sparqlEndpointUrl, sparql);
        qExec.setTimeout(timeout);
        ResultSet rs = qExec.execSelect();
        result = SparqlUtils.convertResultToFormat(rs, format);
        qExec.close();
    } catch (QueryParseException qe) {
        String msg = ExceptionUtils.fixLineNumberInErrorMessage(qe.getLocalizedMessage());
        throw new NextProtException("Malformed SPARQL: " + msg);
    }
    return result;
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) ResultSet(com.hp.hpl.jena.query.ResultSet) SparqlResult(org.nextprot.api.commons.utils.SparqlResult) QueryExecution(com.hp.hpl.jena.query.QueryExecution) QueryParseException(com.hp.hpl.jena.query.QueryParseException)

Aggregations

QueryExecution (com.hp.hpl.jena.query.QueryExecution)1 QueryParseException (com.hp.hpl.jena.query.QueryParseException)1 ResultSet (com.hp.hpl.jena.query.ResultSet)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 SparqlResult (org.nextprot.api.commons.utils.SparqlResult)1