use of org.apache.jena.riot.Lang.NQUADS in project jena by apache.
the class TestInMemDatasetAssembler method directDataLinkToQuads.
@Test
public void directDataLinkToQuads() throws IOException {
// first make a file of quads to load later
final Model model = createDefaultModel();
final Path quads = createTempFile("quadExample", ".nq");
final Resource quadsURI = model.createResource(quads.toFile().toURI().toString());
final Resource simpleExample = model.createResource("test:simpleExample");
simpleExample.addProperty(type, DatasetAssemblerVocab.tDatasetTxnMem);
simpleExample.addProperty(data, quadsURI);
final DatasetGraph dsg = createTxnMem().asDatasetGraph();
model.listStatements().mapWith(Statement::asTriple).mapWith(t -> new Quad(quadsURI.asNode(), t)).forEachRemaining(dsg::add);
try (OutputStream out = new FileOutputStream(quads.toFile())) {
write(out, dsg, NQUADS);
}
final Dataset dataset = assemble(simpleExample);
final Model assembledDefaultModel = dataset.getDefaultModel();
final Model assembledNamedModel = dataset.getNamedModel(quadsURI.getURI());
assertTrue(assembledDefaultModel.isEmpty());
assertTrue(assembledNamedModel.contains(assembledNamedModel.createStatement(simpleExample, data, quadsURI)));
}
Aggregations