use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class DatasetFactory method assemble.
/**
* Assemble a dataset from the model
*
* @param model
* @return Dataset
*/
public static Dataset assemble(Model model) {
Objects.requireNonNull(model, "model can not be null");
Resource r = GraphUtils.findRootByType(model, DatasetAssembler.getType());
if (r == null)
throw new ARQException("No root found for type <" + DatasetAssembler.getType() + ">");
return assemble(r);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class DescribeBNodeClosure method describe.
// Check all named graphs
@Override
public void describe(Resource r) {
// Default model.
Closure.closure(otherModel(r, dataset.getDefaultModel()), false, acc);
// Find all the named graphs in which this resource
// occurs as a subject. Faster than iterating in the
// names of graphs in the case of very large numbers
// of graphs, few of which contain the resource, in
// some kind of persistent storage.
QuerySolutionMap qsm = new QuerySolutionMap();
qsm.add("s", r);
QueryExecution qExec = QueryExecutionFactory.create(query, dataset, qsm);
ResultSet rs = qExec.execSelect();
for (; rs.hasNext(); ) {
QuerySolution qs = rs.next();
String gName = qs.getResource("g").getURI();
Model model = dataset.getNamedModel(gName);
Resource r2 = otherModel(r, model);
Closure.closure(r2, false, acc);
}
// // Named graphs
// for ( Iterator<String> iter = dataset.listNames() ; iter.hasNext() ; )
// {
// String name = iter.next();
// Model model = dataset.getNamedModel(name) ;
// Resource r2 = otherModel(r, model) ;
// Closure.closure(r2, false, acc) ;
// }
Closure.closure(r, false, acc);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestAssemblerGroup method testPassesSelfIn.
public void testPassesSelfIn() {
final AssemblerGroup group = AssemblerGroup.create();
final Object result = new Object();
Assembler fake = new AssemblerBase() {
@Override
public Object open(Assembler a, Resource root, Mode irrelevant) {
assertSame("nested call should pass in assembler group:", group, a);
return result;
}
};
group.implementWith(JA.Object, fake);
assertSame(result, group.open(resourceInModel("x rdf:type ja:Object")));
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestFileManagerAssembler method testCreatesFileManagerWIthHandlers.
/**
Can't just test for equality of locators list, since locators don't support
equality. Weak hack: check that the sizes are the same. TODO improve.
*/
public void testCreatesFileManagerWIthHandlers() {
Resource root = resourceInModel("f rdf:type ja:FileManager");
Assembler a = new FileManagerAssembler();
FileManager f = (FileManager) a.open(null, root);
List<Locator> wanted = IteratorCollection.iteratorToList(standardLocators());
List<Locator> obtained = IteratorCollection.iteratorToList(f.locators());
assertEquals(wanted.size(), obtained.size());
assertEquals(wanted, obtained);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestFileManagerAssembler method testCreatesFileManager.
public void testCreatesFileManager() {
Resource root = resourceInModel("r rdf:type ja:FileManager");
Assembler a = new FileManagerAssembler();
Object x = a.open(root);
assertInstanceOf(FileManager.class, x);
}
Aggregations