Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public class RepositoryAPI {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. File dataDir = new File("C:\Temp\sesameRepo\KB_Exemplar");
  6. try {
  7. Repository repo = createRepository(dataDir);
  8. addRDFToRepository(repo);
  9. } catch (RepositoryException e) {
  10. e.printStackTrace();
  11. }
  12. }
  13.  
  14. private static Repository createRepository(File dataDir) throws RepositoryException {
  15. Repository repos = new SailRepository(new MemoryStore(dataDir));
  16. repos.initialize();
  17. return repos;
  18. }
  19.  
  20. private static void addRDFToRepository(Repository repo) {
  21. File file = new File("C:\LDMVelocityWork\KB_Quality_Exemplar_BE_Ownership.ttl");
  22. String baseURI = "http://data.jpmchase.net/cib/cia/KBQualityExemplar";
  23. try{
  24. RepositoryConnection con = repo.getConnection();
  25. try{
  26. con.add(file, baseURI, RDFFormat.RDFXML);
  27. } catch (IOException e) {
  28. e.printStackTrace();
  29. }
  30. finally {
  31. con.close();
  32. }
  33. }
  34. catch (OpenRDFException e) {
  35. }
  36. }
  37.  
  38. }
  39.  
  40. File file = new File("C:\LDMVelocityWork\KB_Quality_Exemplar_BE_Ownership.ttl");
  41. String baseURI = "http://data.jpmchase.net/cib/cia/KBQualityExemplar";
  42. try{
  43. RepositoryConnection con = repo.getConnection();
  44. try{
  45. con.add(file, baseURI, RDFFormat.RDFXML);
  46. } catch (IOException e) {
  47. e.printStackTrace();
  48. }
  49. finally {
  50. con.close();
  51. }
  52. }
  53. catch (OpenRDFException e) {
  54. }
  55.  
  56. con.add(file, baseURI, RDFFormat.RDFXML);
  57.  
  58. con.add(file, baseURI, RDFFormat.TURTLE);
  59.  
  60. conn.export(new TurtleWriter());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement