use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractTestUpdateGraph method testInsert2.
@Test
public void testInsert2() {
DatasetGraph gStore = getEmptyDatasetGraph();
UpdateModify insert = new UpdateModify();
insert.getInsertAcc().addTriple(triple1);
UpdateAction.execute(insert, gStore);
assertTrue(graphContains(gStore.getDefaultGraph(), triple1));
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class REST_Quads method doPostTriplesGSP.
protected void doPostTriplesGSP(HttpAction action, Lang lang) {
action.beginWrite();
try {
DatasetGraph dsg = action.getActiveDSG();
//log.info(format("[%d] ** Content-length: %d", action.id, action.request.getContentLength())) ;
String name = action.request.getRequestURL().toString();
if (!name.endsWith("/"))
name = name + "/";
name = name + (++counter);
Node gn = NodeFactory.createURI(name);
Graph g = dsg.getGraph(gn);
RDFDataMgr.read(g, action.request.getInputStream(), name, lang);
log.info(format("[%d] Location: %s", action.id, name));
action.response.setHeader("Location", name);
action.commit();
successCreated(action);
} catch (IOException ex) {
action.abort();
} finally {
action.endWrite();
}
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class REST_Quads method doPostQuads.
protected void doPostQuads(HttpAction action, Lang lang) {
action.beginWrite();
try {
String name = action.request.getRequestURL().toString();
DatasetGraph dsg = action.getActiveDSG();
RDFDataMgr.read(dsg, action.request.getInputStream(), name, lang);
action.commit();
success(action);
} catch (IOException ex) {
action.abort();
} finally {
action.endWrite();
}
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class QueryExecutionFactory method make.
protected static QueryExecution make(Query query, Dataset dataset, Context context) {
query.setResultVars();
if (context == null)
// .copy done in QueryExecutionBase -> Context.setupContext.
context = ARQ.getContext();
DatasetGraph dsg = null;
if (dataset != null)
dsg = dataset.asDatasetGraph();
QueryEngineFactory f = findFactory(query, dsg, context);
if (f == null) {
Log.warn(QueryExecutionFactory.class, "Failed to find a QueryEngineFactory");
return null;
}
return new QueryExecutionBase(query, dataset, context, f);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestAPI method testARQConstructQuad_Prefix.
// Allow duplicated template quads in execConstructQuads()
@Test
public void testARQConstructQuad_Prefix() {
String queryString = "PREFIX : <http://example/ns#> CONSTRUCT { GRAPH :g1 { ?s :p ?o} } WHERE { ?s ?p ?o }";
Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
QueryExecution qExec = QueryExecutionFactory.create(q, d);
Iterator<Quad> quads = qExec.execConstructQuads();
DatasetGraph result = DatasetGraphFactory.create();
long count = 0;
while (quads.hasNext()) {
count++;
Quad qd = quads.next();
result.add(qd);
}
DatasetGraph expected = DatasetGraphFactory.create();
expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode());
assertEquals(1, count);
assertTrue(IsoMatcher.isomorphic(expected, result));
}
Aggregations