use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestItem method _getDefaultGraphURIs.
// ----------------------------------------------------
// ---- Query specific properties
/**
* Get the data file (default graph): maybe unknown if part for the query
* (FROM)
*
* @return List
*/
private List<String> _getDefaultGraphURIs() {
if (!_getAction().isAnon())
// Action is a URI - data had better be in the query itself.
return null;
List<String> l = new ArrayList<>();
ClosableIterator<Statement> cIter = _getAction().listProperties(VocabTestQuery.data);
for (; cIter.hasNext(); ) {
Statement stmt = cIter.next();
String df = stmt.getResource().getURI();
l.add(df);
}
cIter.close();
return l;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class UpdateTest method getDataset.
static Dataset getDataset(Resource r) {
//DataSource ds = DatasetFactory.create() ;
DatasetGraph dsg = DatasetGraphFactory.create();
// Growing. dataset.
Dataset ds = DatasetFactory.wrap(dsg);
List<String> dftData = getAll(r, TestManifestUpdate_11.data);
for (String x : dftData) FileManager.get().readModel(ds.getDefaultModel(), x);
ClosableIterator<Statement> cIter = r.listProperties(TestManifestUpdate_11.graphData);
for (; cIter.hasNext(); ) {
// An graphData entry can be a URI or a [ ut ... ; rdfs:label "foo" ] ;
Statement stmt = cIter.next();
Resource gn = stmt.getResource();
if (gn.isAnon()) {
if (!gn.hasProperty(TestManifestUpdate_11.graph))
System.err.println("No data for graphData");
String fn = gn.getProperty(TestManifestUpdate_11.graph).getResource().getURI();
String name = gn.getProperty(RDFS.label).getString();
Model m = FileManager.get().loadModel(fn);
ds.addNamedModel(name, m);
} else {
String x = gn.getURI();
Model m = FileManager.get().loadModel(x);
ds.addNamedModel(x, m);
}
}
cIter.close();
return ds;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class UpdateTest method getAll.
static List<String> getAll(Resource r, Property p) {
List<String> l = new ArrayList<>();
ClosableIterator<Statement> cIter = r.listProperties(p);
for (; cIter.hasNext(); ) {
Statement stmt = cIter.next();
String df = stmt.getObject().asResource().getURI();
l.add(df);
}
cIter.close();
return l;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestModelEvents method testAddSingleStatements.
public void testAddSingleStatements() {
final Statement S1 = ModelHelper.statement(model, "S P O");
final Statement S2 = ModelHelper.statement(model, "A B C");
Assert.assertFalse(SL.has(new Object[] { "add", S1 }));
model.register(SL);
model.add(S1);
SL.assertHas(new Object[] { "add", S1 });
model.add(S2);
SL.assertHas(new Object[] { "add", S1, "add", S2 });
model.add(S1);
SL.assertHas(new Object[] { "add", S1, "add", S2, "add", S1 });
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestModelEvents method testTwoListeners.
public void testTwoListeners() {
final Statement S = ModelHelper.statement(model, "S P O");
final RecordingModelListener SL1 = new RecordingModelListener();
final RecordingModelListener SL2 = new RecordingModelListener();
model.register(SL1).register(SL2);
model.add(S);
SL2.assertHas(new Object[] { "add", S });
SL1.assertHas(new Object[] { "add", S });
}
Aggregations