private static Dataset formDataset(Dataset dataset, DatasetGraph datasetGraph) { if ( dataset != null ) return dataset; if ( datasetGraph != null ) return DatasetFactory.wrap(datasetGraph); return null; }
/** * Wrap a {@link DatasetGraph} to make a dataset * * @param dataset DatasetGraph * @return Dataset * @deprecated Use {@link #wrap} */ @Deprecated public static Dataset create(DatasetGraph dataset) { return wrap(dataset); }
/** Create or connect to a TDB2-backed dataset */ public static Dataset connectDataset(Location location) { DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(location) ; return DatasetFactory.wrap(dsg) ; }
public Dataset getDataset() { if ( dsg == null ) return null ; return DatasetFactory.wrap(dsg) ; }
public static Dataset create(Store store) { DatasetGraph dsg = createDatasetGraph(store) ; return DatasetFactory.wrap(dsg) ; }
/** * Execute a query, expecting the result to be one row, one column. Return * that one RDFNode */ public static RDFNode getExactlyOne(String qs, Model model) { return getExactlyOne(qs, DatasetFactory.wrap(model)) ; }
/** Create a QueryExecution to execute over the Model, * given some initial values of variables. * * @param query Query * @param model Target of the query * @param initialBinding Any initial binding of variables * @return QueryExecution */ static public QueryExecution create(Query query, Model model, QuerySolution initialBinding) { checkArg(model) ; return create(query, DatasetFactory.wrap(model), initialBinding) ; }
/** * Return a {@link DatasetGraph} with added data access control. * Use of the original {@code DatasetGraph} is not controlled. */ public static Dataset controlledDataset(Dataset dsBase, AuthorizationService reg) { DatasetGraph dsg = controlledDataset(dsBase.asDatasetGraph(), reg); return DatasetFactory.wrap(dsg); }
/** Create a text-indexed dataset, optionally allowing the text index to be closed if the Dataset is */ public static Dataset create(Dataset base, TextIndex textIndex, boolean closeIndexOnDSGClose, TextDocProducer producer) { DatasetGraph dsg = base.asDatasetGraph() ; dsg = create(dsg, textIndex, closeIndexOnDSGClose, producer) ; return DatasetFactory.wrap(dsg) ; }
/** Create a text-indexed dataset */ public static Dataset create(Dataset base, SpatialIndex textIndex) { DatasetGraph dsg = base.asDatasetGraph() ; dsg = create(dsg, textIndex) ; return DatasetFactory.wrap(dsg) ; }
/** Create a text-indexed dataset, optionally allowing the text index to be closed if the Dataset is */ public static Dataset create(Dataset base, TextIndex textIndex, boolean closeIndexOnDSGClose) { DatasetGraph dsg = base.asDatasetGraph() ; dsg = create(dsg, textIndex, closeIndexOnDSGClose) ; return DatasetFactory.wrap(dsg) ; }
public Dataset createDataset() { if ( dsg != null ) throw new TDBTestException("dataset already in use") ; dsg = TDBFactory.createDatasetGraph(loc) ; return DatasetFactory.wrap(dsg) ; }
protected static QueryExecution make(Query query, Model model) { Dataset dataset = DatasetFactory.wrap(model); Graph g = unwrap(model.getGraph()); if ( g instanceof GraphView ) { GraphView gv = (GraphView)g; // Copy context of the storage dataset to the wrapper dataset. dataset.getContext().putAll(gv.getDataset().getContext()); } return make(query, dataset); }
public static int count(String queryStr, DatasetGraph dsg) { int counter = 0 ; Query query = QueryFactory.create(queryStr, Syntax.syntaxARQ) ; try (QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(dsg))) { ResultSet rs = qExec.execSelect() ; for ( ; rs.hasNext() ; ) { rs.nextBinding() ; counter++ ; } return counter ; } }
private static void test(Query query, double expected, DatasetGraph dsg) { try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(dsg)) ) { Literal literal = qExec.execSelect().next().getLiteral("X") ; double result = literal.getDouble() ; assertEquals(expected, result, 0.001); } }
private void test(String queryString, String jsonExpected) { Query query = QueryFactory.create(queryString, Syntax.syntaxARQ); DatasetGraph dsg = new DatasetGraphZero(); Dataset ds = DatasetFactory.wrap(dsg); try ( QueryExecution qExec = QueryExecutionFactory.create(query, ds) ) { JsonValue jvGot = qExec.execJson() ; JsonValue jvExpected = JSON.parseAny(jsonExpected) ; assertEquals(jvExpected, jvGot); } } }
private void testErr(String qsAgg, DatasetGraph ds, Syntax syntax) { Query query = buildGroupBy(qsAgg, syntax) ; try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) { ResultSet rs = qExec.execSelect() ; assertTrue(rs.getResultVars().contains("X")) ; Binding b = rs.nextBinding() ; assertFalse(b.contains(Var.alloc("X"))) ; } }
private void testEmptyNoGroupBy(String qsAgg, DatasetGraph ds, Syntax syntax) { Query query = buildNoGroupBy(qsAgg, syntax) ; try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) { ResultSet rs = qExec.execSelect() ; assertTrue(rs.hasNext()) ; assertTrue(rs.getResultVars().contains("X")) ; Binding b = rs.nextBinding() ; assertFalse(b.contains(Var.alloc("X"))) ; } }
public void setup() { DatasetGraph dsg = TDBFactory.createDatasetGraph(); dsg.getContext().set(TDB.symUnionDefaultGraph, true); Dataset myDataset = DatasetFactory.wrap(dsg); baseModel = myDataset.getNamedModel("http://example.com/baseModel"); baseModel = QueryEngineTest.populateModel(baseModel); dftModel = Factory.getInstance(eval, "http://example.com/securedModel", baseModel); dataset = DatasetFactory.create(); dataset.setDefaultModel(dftModel); }
@Override protected Dataset createDataset() { DatasetGraph dsg = DatasetGraphFactory.create() ; dsg.addGraph(NodeFactory.createURI(graph1), GraphFactory.createDefaultGraph()) ; dsg.addGraph(NodeFactory.createURI(graph2), GraphFactory.createDefaultGraph()) ; dsg.addGraph(NodeFactory.createURI(graph3), GraphFactory.createDefaultGraph()) ; return DatasetFactory.wrap(dsg) ; }