use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestEmbeddedFuseki method embedded_07.
// Context path.
@Test
public void embedded_07() {
DatasetGraph dsg = dataset();
int port = FusekiLib.choosePort();
FusekiEmbeddedServer server = FusekiEmbeddedServer.create().setPort(port).setContextPath("/ABC").add("/ds", dsg).build();
server.start();
try {
String x1 = HttpOp.execHttpGetString("http://localhost:" + port + "/ds");
assertNull(x1);
String x2 = HttpOp.execHttpGetString("http://localhost:" + port + "/ABC/ds");
assertNotNull(x2);
} finally {
server.stop();
}
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class CmdUpdate method exec.
@Override
protected final void exec() {
DatasetGraph dataset = modDataset.getDatasetGraph();
if (dataset == null)
dataset = dealWithNoDataset();
if (dataset.getDefaultGraph() == null)
dataset.setDefaultGraph(ModelFactory.createDefaultModel().getGraph());
execUpdate(dataset);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TurtleShell method writeGraphTTL.
/** Write graph in Turtle syntax (or part of TriG). graphName is null for default graph. */
protected void writeGraphTTL(DatasetGraph dsg, Node graphName) {
Graph g = (graphName == null || Quad.isDefaultGraph(graphName)) ? dsg.getDefaultGraph() : dsg.getGraph(graphName);
ShellGraph x = new ShellGraph(g, graphName, dsg);
x.writeGraph();
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class Eval method evalGraph.
static Table evalGraph(OpGraph opGraph, Evaluator evaluator) {
ExecutionContext execCxt = evaluator.getExecContext();
if (!Var.isVar(opGraph.getNode())) {
DatasetGraph dsg = execCxt.getDataset();
Node graphNode = opGraph.getNode();
if (!dsg.containsGraph(graphNode))
return new TableEmpty();
Graph graph = execCxt.getDataset().getGraph(opGraph.getNode());
if (// But contains was true?!!
graph == null)
throw new InternalErrorException("Graph was present, now it's not");
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
return eval(e2, opGraph.getSubOp());
}
// Graph node is a variable.
Var gVar = Var.alloc(opGraph.getNode());
Table current = null;
for (Iterator<Node> iter = execCxt.getDataset().listGraphNodes(); iter.hasNext(); ) {
Node gn = iter.next();
Graph graph = execCxt.getDataset().getGraph(gn);
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
Table tableVarURI = TableFactory.create(gVar, gn);
// Evaluate the pattern, join with this graph node possibility.
// XXX If Var.ANON then no-opt.
Table patternTable = eval(e2, opGraph.getSubOp());
Table stepResult = evaluator.join(patternTable, tableVarURI);
if (current == null)
current = stepResult;
else
current = evaluator.union(current, stepResult);
}
if (current == null)
// Nothing to loop over
return new TableEmpty();
return current;
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class QueryIterGraph method nextStage.
@Override
protected QueryIterator nextStage(Binding outerBinding) {
DatasetGraph ds = getExecContext().getDataset();
// Is this closed?
Iterator<Node> graphNameNodes = makeSources(ds, outerBinding, opGraph.getNode());
// List<Node> x = Iter.toList(graphNameNodes) ;
// graphNameNodes = x.iterator() ;
// System.out.println(x) ;
QueryIterator current = new QueryIterGraphInner(outerBinding, graphNameNodes, opGraph, getExecContext());
return current;
}
Aggregations