Search in sources :

Example 11 with SparqlFieldQuery

use of org.apache.stanbol.entityhub.query.sparql.SparqlFieldQuery in project stanbol by apache.

the class LarqSearcher method findEntities.

@Override
public final QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
    final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
    query.setSparqlEndpointType(SparqlEndpointTypeEnum.LARQ);
    String sparqlQuery = query.toSparqlSelect(false);
    InputStream in = sendSparqlRequest(getQueryUri(), sparqlQuery, SparqlSearcher.DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
    //Move to util class!
    final List<String> entities = extractEntitiesFromJsonResult(in, query.getRootVariableName());
    return new QueryResultListImpl<String>(query, entities.iterator(), String.class);
}
Also used : InputStream(java.io.InputStream) SparqlFieldQuery(org.apache.stanbol.entityhub.query.sparql.SparqlFieldQuery) QueryResultListImpl(org.apache.stanbol.entityhub.core.query.QueryResultListImpl)

Aggregations

SparqlFieldQuery (org.apache.stanbol.entityhub.query.sparql.SparqlFieldQuery)11 InputStream (java.io.InputStream)6 QueryResultListImpl (org.apache.stanbol.entityhub.core.query.QueryResultListImpl)4 Graph (org.apache.clerezza.commons.rdf.Graph)3 IRI (org.apache.clerezza.commons.rdf.IRI)3 IndexedGraph (org.apache.stanbol.commons.indexedgraph.IndexedGraph)3 RdfQueryResultList (org.apache.stanbol.entityhub.query.clerezza.RdfQueryResultList)3 YardException (org.apache.stanbol.entityhub.servicesapi.yard.YardException)3 Value (org.openrdf.model.Value)3 BindingSet (org.openrdf.query.BindingSet)3 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)3 TupleQueryResult (org.openrdf.query.TupleQueryResult)3 RepositoryConnection (org.openrdf.repository.RepositoryConnection)3 RepositoryException (org.openrdf.repository.RepositoryException)3 RdfRepresentation (org.apache.stanbol.entityhub.model.sesame.RdfRepresentation)2 RdfValueFactory (org.apache.stanbol.entityhub.model.sesame.RdfValueFactory)2 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)2 TextConstraint (org.apache.stanbol.entityhub.servicesapi.query.TextConstraint)2 Model (org.openrdf.model.Model)2 URI (org.openrdf.model.URI)2