use of org.openrdf.rio.rdfxml.RDFXMLWriter in project gocd by gocd.
the class SesameGraph method dump.
public void dump(Writer writer) {
try {
if (contextResource.length == 0) {
RepositoryResult<org.openrdf.model.Resource> results = conn.getContextIDs();
while (results.hasNext()) {
org.openrdf.model.Resource context = results.next();
writer.append("Dumping context:" + context + "\n");
conn.export(new RDFXMLWriter(writer), context);
}
dumpTriplesNotInContext(writer);
} else {
for (int i = 0; i < contextResource.length; i++) {
writer.append("Dumping context:" + contextResource[i].stringValue() + "\n");
conn.export(new RDFXMLWriter(writer), contextResource);
}
}
} catch (Exception e) {
throw new ShineRuntimeException(e);
}
}
use of org.openrdf.rio.rdfxml.RDFXMLWriter in project gocd by gocd.
the class SesameGraph method dumpTriplesNotInContext.
private void dumpTriplesNotInContext(Writer writer) {
try {
writer.append("Statements not in any context: \n");
} catch (IOException e) {
throw new RuntimeException(e);
}
RDFXMLWriter xmlWriter = new RDFXMLWriter(writer);
xmlWriter.startRDF();
try {
RepositoryResult<Statement> result = conn.getStatements(null, null, null, false);
while (result.hasNext()) {
Statement statement = result.next();
if (statement.getContext() == null) {
xmlWriter.handleStatement(statement);
}
}
} catch (RepositoryException | RDFHandlerException e) {
throw new RuntimeException(e);
} finally {
try {
xmlWriter.endRDF();
} catch (RDFHandlerException e) {
throw new RuntimeException(e);
}
}
}
Aggregations