use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractDatasetGraphTests method create_1.
@Test
public void create_1() {
DatasetGraph dsg = emptyDataset();
assertNotNull(dsg);
assertNotNull(dsg.getDefaultGraph());
assertTrue(dsg.getDefaultGraph().isEmpty());
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractDatasetGraphTests method graph_01.
// Graph centric operations
@Test
public void graph_01() {
DatasetGraph dsg = emptyDataset();
assertNotNull(dsg);
Node g = NodeFactory.createURI("g");
Triple t = SSE.parseTriple("(<s> <p> <o>)");
dsg.getGraph(g).add(t);
assertTrue(dsg.getGraph(g).contains(t));
Quad quad = SSE.parseQuad("(quad <g> <s> <p> <o>)");
Iterator<Quad> iter = dsg.find(null, null, null, null);
assertTrue(iter.hasNext());
Quad quad2 = iter.next();
assertFalse(iter.hasNext());
assertEquals(quad, quad2);
assertTrue(dsg.getDefaultGraph().isEmpty());
assertFalse(dsg.getGraph(NodeFactory.createURI("g")).isEmpty());
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class update method execUpdate.
// Subclass for specialised commands making common updates more convenient
@Override
protected void execUpdate(DatasetGraph graphStore) {
if (requestFiles.size() == 0 && getPositional().size() == 0)
throw new CmdException("Nothing to do");
Transactional transactional = (graphStore.supportsTransactionAbort()) ? graphStore : new TransactionalNull();
for (String filename : requestFiles) {
try {
transactional.begin(ReadWrite.WRITE);
execOneFile(filename, graphStore);
transactional.commit();
} catch (Throwable ex) {
try {
transactional.abort();
} catch (Exception ex2) {
}
throw ex;
} finally {
transactional.end();
}
}
for (String requestString : super.getPositional()) {
String requestString2 = indirect(requestString);
Txn.executeWrite(transactional, () -> execOne(requestString2, graphStore));
}
if (!(transactional instanceof DatasetGraph))
SystemARQ.sync(graphStore);
if (dump)
RDFDataMgr.write(System.out, graphStore, Lang.NQUADS);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class sse_query method exec.
@Override
protected void exec() {
Op op = modAlgebra.getOp();
if (op == null) {
System.err.println("No query expression to execute");
throw new TerminationException(9);
}
Dataset dataset = modDataset.getDataset();
// Check there is a dataset.
if (dataset == null)
dataset = DatasetFactory.createGeneral();
modTime.startTimer();
DatasetGraph dsg = dataset.asDatasetGraph();
if (printOp || printPlan) {
if (printOp) {
divider();
IndentedWriter out = new IndentedWriter(System.out, true);
op.output(out);
out.flush();
}
if (printPlan) {
QueryIterator qIter = Algebra.exec(op, dsg);
Plan plan = new PlanOp(op, null, qIter);
divider();
IndentedWriter out = new IndentedWriter(System.out, false);
plan.output(out);
out.flush();
}
//return ;
}
// Do not optimize. Execute as-is.
QueryExecUtils.execute(op, dsg, modResults.getResultsFormat());
long time = modTime.endTimer();
if (modTime.timingEnabled())
System.out.println("Time: " + modTime.timeStr(time));
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestDatasetOps method gsp_x_ct.
private void gsp_x_ct(String urlDataset, String acceptheader, String contentTypeResponse) {
HttpEntity e = datasetToHttpEntity(data);
HttpOp.execHttpPut(urlDataset(), e);
// Do manually so the test can validate the expected ContentType
try (TypedInputStream in = HttpOp.execHttpGet(urlDataset, acceptheader)) {
assertEqualsIgnoreCase(contentTypeResponse, in.getContentType());
Lang lang = RDFLanguages.contentTypeToLang(in.getContentType());
DatasetGraph dsg = DatasetGraphFactory.create();
StreamRDF dest = StreamRDFLib.dataset(dsg);
RDFParser.source(in).lang(lang).parse(dest);
}
}
Aggregations