You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/05/22 16:03:27 UTC

[5/5] jena git commit: Add convenience functions to load the data.

Add convenience functions to load the data.

These convenience operations mean the app does not need to write
transaction code for soem "just do it" operations.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/7980d086
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/7980d086
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/7980d086

Branch: refs/heads/master
Commit: 7980d0862a9c1a3df06c4b0f5ed9deb359edf65c
Parents: 1cae3b4
Author: Andy Seaborne <an...@apache.org>
Authored: Mon May 21 18:34:42 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon May 21 18:34:42 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/tdb2/loader/Loader.java     | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/7980d086/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/Loader.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/Loader.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/Loader.java
index e6bd2e0..d4b1e7a 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/Loader.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/Loader.java
@@ -77,4 +77,29 @@ public class Loader {
         DataLoader loader = LoaderFactory.createLoader(dataset, output);
         return loader;
     }
+    
+    /** Load the contents of files or remote web data into a dataset using the basic data loader. */
+    public static void read(DatasetGraph dataset, String...dataURLs) {
+        read(dataset, false, dataURLs);
+    }
+    
+    /** Load the contents of files or remote web data into a dataset using the basic data loader.. */
+    public static void read(DatasetGraph dataset, boolean showProgress, String...dataURLs) {
+        read(dataset, asList(dataURLs), showProgress);
+    }
+
+    /** Load the contents of files or remote web data into a dataset using the basic data loader. */
+    public static void read(DatasetGraph dataset, List<String> dataURLs, boolean showProgress) {
+        MonitorOutput output = showProgress ? LoaderOps.outputToLog() : LoaderOps.nullOutput();
+        DataLoader loader = LoaderFactory.basicLoader(dataset, output);
+        loader.startBulk();
+        try {
+            loader.load(dataURLs);
+            loader.finishBulk();
+        }
+        catch (RuntimeException ex) {
+            loader.finishException(ex);
+            throw ex;
+        }
+    }
 }