transactional Sesame sync
This commit is contained in:
parent
79f0c67ce8
commit
609b18b940
1 changed files with 29 additions and 29 deletions
|
@ -27,7 +27,9 @@ public class SesameSyncUtils {
|
||||||
Repository myRepository = new HTTPRepository(serverURI, repositoryId);
|
Repository myRepository = new HTTPRepository(serverURI, repositoryId);
|
||||||
myRepository.initialize();
|
myRepository.initialize();
|
||||||
RepositoryConnection myConn = myRepository.getConnection();
|
RepositoryConnection myConn = myRepository.getConnection();
|
||||||
System.out.println(myConn.size()+" statements in remote Sesame");
|
|
||||||
|
myConn.setAutoCommit(false);
|
||||||
|
try {
|
||||||
|
|
||||||
Resource contextRes = (contextId != null)
|
Resource contextRes = (contextId != null)
|
||||||
? new URIImpl(contextId) : null ;
|
? new URIImpl(contextId) : null ;
|
||||||
|
@ -38,29 +40,27 @@ public class SesameSyncUtils {
|
||||||
myConn.clear();
|
myConn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Cleared");
|
|
||||||
System.out.println(myConn.size());
|
|
||||||
|
|
||||||
PipedInputStream in = new PipedInputStream();
|
PipedInputStream in = new PipedInputStream();
|
||||||
PipedOutputStream out = new PipedOutputStream(in);
|
PipedOutputStream out = new PipedOutputStream(in);
|
||||||
try {
|
try {
|
||||||
new Thread((new JenaOutputter(jenaModel, out))).start();
|
new Thread((new JenaOutputter(jenaModel, out))).start();
|
||||||
if (contextRes != null) {
|
if (contextRes != null) {
|
||||||
myConn.add(in, null, RDFFormat.NTRIPLES, contextRes);
|
myConn.add(in,"http://example.org/base/", RDFFormat.NTRIPLES, contextRes);
|
||||||
} else {
|
} else {
|
||||||
myConn.add(in, null, RDFFormat.NTRIPLES);
|
myConn.add(in,"http://example.org/base/", RDFFormat.NTRIPLES);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Jena model added");
|
|
||||||
System.out.println(myConn.size());
|
|
||||||
|
|
||||||
myConn.commit();
|
myConn.commit();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
myConn.rollback();
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
myConn.close();
|
myConn.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue