simplify KiWiConnection

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

Branch: refs/heads/master
Commit: babe500e5574a828028c06877f038deaa395c6f4
Parents: 2278b3d
Author: Sebastian Schaffert <[email protected]>
Authored: Mon Mar 31 19:08:34 2014 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Mon Mar 31 19:08:34 2014 +0200

----------------------------------------------------------------------
 .../kiwi/loader/generic/KiWiHandler.java        |  2 +-
 .../kiwi/persistence/KiWiConnection.java        | 47 ++++----------------
 .../marmotta/kiwi/sail/KiWiValueFactory.java    |  6 +--
 .../marmotta/kiwi/test/PersistenceTest.java     | 38 ++++++++--------
 .../test/VersioningPersistenceTest.java         | 40 ++++++++---------
 .../LDCachingKiWiPersistenceConnection.java     |  2 +-
 6 files changed, 53 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
 
b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
index 7053502..19b7c85 100644
--- 
a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
+++ 
b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
@@ -446,7 +446,7 @@ public class KiWiHandler implements RDFHandler {
 
 
     protected void storeNode(KiWiNode node) throws SQLException {
-        connection.storeNode(node, false);
+        connection.storeNode(node);
 
         nodes++;
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index 31d3d95..727877a 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -944,16 +944,15 @@ public class KiWiConnection implements AutoCloseable {
      *
      *
      * @param node
-     * @param batch
      * @throws SQLException
      */
-    public synchronized void storeNode(KiWiNode node, boolean batch) throws 
SQLException {
+    public synchronized void storeNode(KiWiNode node) throws SQLException {
 
         // ensure the data type of a literal is persisted first
         if(node instanceof KiWiLiteral) {
             KiWiLiteral literal = (KiWiLiteral)node;
             if(literal.getType() != null && literal.getType().getId() < 0) {
-                storeNode(literal.getType(), batch);
+                storeNode(literal.getType());
             }
         }
 
@@ -973,11 +972,7 @@ public class KiWiConnection implements AutoCloseable {
             insertNode.setString(2,uriResource.stringValue());
             insertNode.setTimestamp(3, new 
Timestamp(uriResource.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
 
         } else if(node instanceof KiWiAnonResource) {
             KiWiAnonResource anonResource = (KiWiAnonResource)node;
@@ -987,11 +982,7 @@ public class KiWiConnection implements AutoCloseable {
             insertNode.setString(2,anonResource.stringValue());
             insertNode.setTimestamp(3, new 
Timestamp(anonResource.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else if(node instanceof KiWiDateLiteral) {
             KiWiDateLiteral dateLiteral = (KiWiDateLiteral)node;
 
@@ -1005,11 +996,7 @@ public class KiWiConnection implements AutoCloseable {
                 throw new IllegalStateException("a date literal must have a 
datatype");
             insertNode.setTimestamp(5, new 
Timestamp(dateLiteral.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else if(node instanceof KiWiIntLiteral) {
             KiWiIntLiteral intLiteral = (KiWiIntLiteral)node;
 
@@ -1024,11 +1011,7 @@ public class KiWiConnection implements AutoCloseable {
                 throw new IllegalStateException("an integer literal must have 
a datatype");
             insertNode.setTimestamp(6, new 
Timestamp(intLiteral.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else if(node instanceof KiWiDoubleLiteral) {
             KiWiDoubleLiteral doubleLiteral = (KiWiDoubleLiteral)node;
 
@@ -1042,11 +1025,7 @@ public class KiWiConnection implements AutoCloseable {
                 throw new IllegalStateException("a double literal must have a 
datatype");
             insertNode.setTimestamp(5, new 
Timestamp(doubleLiteral.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else if(node instanceof KiWiBooleanLiteral) {
             KiWiBooleanLiteral booleanLiteral = (KiWiBooleanLiteral)node;
 
@@ -1060,11 +1039,7 @@ public class KiWiConnection implements AutoCloseable {
                 throw new IllegalStateException("a boolean literal must have a 
datatype");
             insertNode.setTimestamp(5, new 
Timestamp(booleanLiteral.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else if(node instanceof KiWiStringLiteral) {
             KiWiStringLiteral stringLiteral = (KiWiStringLiteral)node;
 
@@ -1106,11 +1081,7 @@ public class KiWiConnection implements AutoCloseable {
             }
             insertNode.setTimestamp(7, new 
Timestamp(stringLiteral.getCreated().getTime()));
 
-            if(batch) {
-                insertNode.addBatch();
-            } else {
-                insertNode.executeUpdate();
-            }
+            insertNode.executeUpdate();
         } else {
             log.warn("unrecognized node type: {}", 
node.getClass().getCanonicalName());
         }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index 74696c5..a7ceaae 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -128,7 +128,7 @@ public class KiWiValueFactory implements ValueFactory {
             if(result == null) {
                 result = new KiWiUriResource(uri);
 
-                connection.storeNode(result, false);
+                connection.storeNode(result);
 
             }
             if(result.getId() < 0) {
@@ -181,7 +181,7 @@ public class KiWiValueFactory implements ValueFactory {
             if(result == null) {
                 result = new KiWiAnonResource(nodeID);
 
-                connection.storeNode(result, false);
+                connection.storeNode(result);
             }
             if(result.getId() < 0) {
                 log.error("node ID is null!");
@@ -396,7 +396,7 @@ public class KiWiValueFactory implements ValueFactory {
             }
 
             if(result.getId() < 0) {
-                connection.storeNode(result, false);
+                connection.storeNode(result);
             }
 
             return result;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
 
b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
index a3aa52a..bdc82f8 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
@@ -104,7 +104,7 @@ public class PersistenceTest {
         try {
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiUriResource uri = new KiWiUriResource("http://localhost/"+ 
RandomStringUtils.randomAlphanumeric(8));
-            connection.storeNode(uri, false);
+            connection.storeNode(uri);
 
             // check if it then has a database ID
             Assert.assertTrue(uri.getId() >= 0);
@@ -181,7 +181,7 @@ public class PersistenceTest {
         try {
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiAnonResource bnode = new 
KiWiAnonResource(RandomStringUtils.randomAlphanumeric(8));
-            connection.storeNode(bnode, false);
+            connection.storeNode(bnode);
 
             // check if it then has a database ID
             Assert.assertTrue(bnode.getId() >= 0);
@@ -256,11 +256,11 @@ public class PersistenceTest {
         KiWiConnection connection = persistence.getConnection();
         try {
             KiWiUriResource   stype   = new 
KiWiUriResource(Namespaces.NS_XSD+"string");
-            connection.storeNode(stype, false);
+            connection.storeNode(stype);
 
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiStringLiteral literal = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(8),null,stype);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -335,11 +335,11 @@ public class PersistenceTest {
         KiWiConnection connection = persistence.getConnection();
         try {
             KiWiUriResource   stype   = new 
KiWiUriResource(getRDFLangStringType());
-            connection.storeNode(stype, false);
+            connection.storeNode(stype);
 
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiStringLiteral literal = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(8), Locale.ENGLISH, 
stype);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -417,7 +417,7 @@ public class PersistenceTest {
 
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiStringLiteral literal = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(8), null, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -499,7 +499,7 @@ public class PersistenceTest {
 
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiStringLiteral literal = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(16384), null, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -586,7 +586,7 @@ public class PersistenceTest {
 
                     // add a new URI to the triple store and check if it 
exists afterwards, before and after commit
             KiWiIntLiteral literal = new KiWiIntLiteral(value, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -691,7 +691,7 @@ public class PersistenceTest {
 
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiDoubleLiteral literal = new KiWiDoubleLiteral(value, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -795,7 +795,7 @@ public class PersistenceTest {
             boolean value = rnd.nextBoolean();
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiBooleanLiteral literal = new KiWiBooleanLiteral(value, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -898,7 +898,7 @@ public class PersistenceTest {
             Date value = new Date();
             // add a new URI to the triple store and check if it exists 
afterwards, before and after commit
             KiWiDateLiteral literal = new KiWiDateLiteral(value, uri);
-            connection.storeNode(literal, false);
+            connection.storeNode(literal);
 
             // check if it then has a database ID
             Assert.assertTrue(literal.getId() >= 0);
@@ -1003,13 +1003,13 @@ public class PersistenceTest {
                 KiWiStringLiteral object_2 = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32),null,stype);
                 KiWiUriResource context  = new 
KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
 
-                connection.storeNode(stype, false);
-                connection.storeNode(subject, false);
-                connection.storeNode(pred_1, false);
-                connection.storeNode(pred_2, false);
-                connection.storeNode(object_1, false);
-                connection.storeNode(object_2, false);
-                connection.storeNode(context, false);
+                connection.storeNode(stype);
+                connection.storeNode(subject);
+                connection.storeNode(pred_1);
+                connection.storeNode(pred_2);
+                connection.storeNode(object_1);
+                connection.storeNode(object_2);
+                connection.storeNode(context);
 
                 KiWiTriple triple1 = new 
KiWiTriple(subject,pred_1,object_1,context);
                 KiWiTriple triple2 = new 
KiWiTriple(subject,pred_2,object_2,context);

http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
 
b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
index 08561bb..1123899 100644
--- 
a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
+++ 
b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
@@ -107,13 +107,13 @@ public class VersioningPersistenceTest {
             KiWiStringLiteral object_2 = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
             KiWiUriResource context  = new 
KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
 
-            connection.storeNode(subject1, false);
-            connection.storeNode(subject2, false);
-            connection.storeNode(pred_1, false);
-            connection.storeNode(pred_2, false);
-            connection.storeNode(object_1, false);
-            connection.storeNode(object_2, false);
-            connection.storeNode(context, false);
+            connection.storeNode(subject1);
+            connection.storeNode(subject2);
+            connection.storeNode(pred_1);
+            connection.storeNode(pred_2);
+            connection.storeNode(object_1);
+            connection.storeNode(object_2);
+            connection.storeNode(context);
 
             KiWiTriple triple1 = new 
KiWiTriple(subject1,pred_1,object_1,context);
             KiWiTriple triple2 = new 
KiWiTriple(subject2,pred_2,object_2,context);
@@ -180,12 +180,12 @@ public class VersioningPersistenceTest {
             KiWiStringLiteral object_2 = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
             KiWiUriResource context  = new 
KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
 
-            connection.storeNode(subject, false);
-            connection.storeNode(pred_1, false);
-            connection.storeNode(pred_2, false);
-            connection.storeNode(object_1, false);
-            connection.storeNode(object_2, false);
-            connection.storeNode(context, false);
+            connection.storeNode(subject);
+            connection.storeNode(pred_1);
+            connection.storeNode(pred_2);
+            connection.storeNode(object_1);
+            connection.storeNode(object_2);
+            connection.storeNode(context);
 
             KiWiTriple triple1 = new 
KiWiTriple(subject,pred_1,object_1,context);
             KiWiTriple triple2 = new 
KiWiTriple(subject,pred_2,object_2,context);
@@ -279,13 +279,13 @@ public class VersioningPersistenceTest {
             KiWiStringLiteral object_2 = new 
KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
             KiWiUriResource context  = new 
KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
 
-            connection.storeNode(subject1, false);
-            connection.storeNode(subject2, false);
-            connection.storeNode(pred_1, false);
-            connection.storeNode(pred_2, false);
-            connection.storeNode(object_1, false);
-            connection.storeNode(object_2, false);
-            connection.storeNode(context, false);
+            connection.storeNode(subject1);
+            connection.storeNode(subject2);
+            connection.storeNode(pred_1);
+            connection.storeNode(pred_2);
+            connection.storeNode(object_1);
+            connection.storeNode(object_2);
+            connection.storeNode(context);
 
             KiWiTriple triple1 = new 
KiWiTriple(subject1,pred_1,object_1,context);
             KiWiTriple triple2 = new 
KiWiTriple(subject2,pred_2,object_2,context);

http://git-wip-us.apache.org/repos/asf/marmotta/blob/babe500e/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/persistence/LDCachingKiWiPersistenceConnection.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/persistence/LDCachingKiWiPersistenceConnection.java
 
b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/persistence/LDCachingKiWiPersistenceConnection.java
index f2d9b47..8f0d592 100644
--- 
a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/persistence/LDCachingKiWiPersistenceConnection.java
+++ 
b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/persistence/LDCachingKiWiPersistenceConnection.java
@@ -336,7 +336,7 @@ public class LDCachingKiWiPersistenceConnection implements 
Closeable {
      * @throws java.sql.SQLException
      */
     public void storeNode(KiWiNode node) throws SQLException {
-        connection.storeNode(node, false);
+        connection.storeNode(node);
     }
 
     /**

Reply via email to