use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class SPARQLQueryProcessor method createQueryExecution.
/**
* Create the {@link QueryExecution} for this operation.
* @param action
* @param query
* @param dataset
* @return QueryExecution
*/
protected QueryExecution createQueryExecution(HttpAction action, Query query, DatasetGraph dataset) {
QueryExecDatasetBuilder builder = QueryExec.newBuilder().dataset(dataset).query(query).context(action.getContext());
setTimeouts(builder, action);
QueryExec qExec = builder.build();
return QueryExecutionAdapter.adapt(qExec);
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_extra_params_oldstyle_by_context_1.
// Uses a HttpRequestModifier to check the changes.
@Test
public void service_query_extra_params_oldstyle_by_context_1() {
Map<String, Map<String, List<String>>> testServiceParams = new HashMap<>();
Map<String, List<String>> settings = new HashMap<>();
settings.put("apikey", List.of("BristolCalling"));
testServiceParams.put(SERVICE, settings);
DatasetGraph clientDGS = localDataset();
clientDGS.getContext().set(ARQ.serviceParams, testServiceParams);
AtomicBoolean seen = new AtomicBoolean(false);
HttpRequestModifier inspector = (params, header) -> {
seen.set(params.containsParam("apikey"));
};
logOnlyErrors(Fuseki.class, () -> {
runWithModifier(SERVICE, inspector, () -> {
String queryString = "ASK { SERVICE <" + SERVICE + "> { BIND(now() AS ?now) } }";
try (QueryExec qExec = QueryExec.dataset(clientDGS).query(queryString).build()) {
boolean b = qExec.ask();
assertTrue(b);
}
});
});
assertTrue(seen.get());
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_silent_no_service.
@Test
public void service_query_silent_no_service() {
logOnlyErrors(QueryIterService.class, () -> {
DatasetGraph dsg = env.dsg();
String queryString = "SELECT * { SERVICE SILENT <" + SERVICE + "JUNK> { VALUES ?X { 1 2 } }} ";
try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
try (QueryExec qExec = link.query(queryString)) {
RowSet rs = qExec.select();
assertTrue(rs.hasNext());
Binding binding = rs.next();
assertFalse(rs.hasNext());
assertTrue(binding.isEmpty());
}
}
});
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_extra_params_oldstyle_by_context_2.
// Uses a HttpRequestModifier to check the changes.
@Test
public void service_query_extra_params_oldstyle_by_context_2() {
Map<String, Map<String, List<String>>> testServiceParams = new HashMap<>();
Map<String, List<String>> settings = new HashMap<>();
settings.put("apikey", List.of("BristolCallingToTheFarawayTowns"));
testServiceParams.put(SERVICE, settings);
DatasetGraph clientDGS = localDataset();
clientDGS.getContext().set(ARQ.serviceParams, testServiceParams);
AtomicBoolean seen = new AtomicBoolean(false);
HttpRequestModifier inspector = (params, header) -> {
seen.set(params.containsParam("apikey"));
};
logOnlyErrors(Fuseki.class, () -> {
runWithModifier(SERVICE, inspector, () -> {
String queryString = "ASK { SERVICE <" + SERVICE + "> { BIND(now() AS ?now) } }";
try (QueryExec qExec = QueryExec.dataset(clientDGS).query(queryString).build()) {
boolean b = qExec.ask();
assertTrue(b);
}
});
});
assertTrue(seen.get());
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_bad_no_service.
@Test(expected = QueryExceptionHTTP.class)
public void service_query_bad_no_service() {
DatasetGraph dsg = env.dsg();
dsg.executeWrite(() -> dsg.add(SSE.parseQuad("(_ :s :p :o)")));
// Not a service of the dataset.
String queryString = "SELECT * { SERVICE <" + SERVICE + "/JUNK> { ?s ?p ?o }} ";
// Connect to local, unused, permanently empty dataset
try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
try (QueryExec qExec = link.query(queryString)) {
RowSet rs = qExec.select();
// Should go on execution.
rs.hasNext();
fail("Should not get here");
}
}
}
Aggregations