marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject git commit: applied same fix to reasoning
Date Thu, 16 May 2013 15:16:45 GMT
Updated Branches:
  refs/heads/develop 6db1be5bb -> ccbd35865


applied same fix to reasoning


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

Branch: refs/heads/develop
Commit: ccbd358654e29c67069300f82cf38bb23ddfdbd6
Parents: 6db1be5
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Thu May 16 17:16:18 2013 +0200
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Thu May 16 17:16:18 2013 +0200

----------------------------------------------------------------------
 .../reasoner/services/ReasoningSailProvider.java   |   56 ++++++++++++---
 1 files changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ccbd3586/platform/marmotta-reasoner/src/main/java/org/apache/marmotta/platform/reasoner/services/ReasoningSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-reasoner/src/main/java/org/apache/marmotta/platform/reasoner/services/ReasoningSailProvider.java
b/platform/marmotta-reasoner/src/main/java/org/apache/marmotta/platform/reasoner/services/ReasoningSailProvider.java
index 52dd024..085bf43 100644
--- a/platform/marmotta-reasoner/src/main/java/org/apache/marmotta/platform/reasoner/services/ReasoningSailProvider.java
+++ b/platform/marmotta-reasoner/src/main/java/org/apache/marmotta/platform/reasoner/services/ReasoningSailProvider.java
@@ -99,6 +99,10 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
     public void configurationChanged(@Observes ConfigurationChangedEvent e) {
         if(e.containsChangedKey(REASONING_ENABLED)) {
             sesameService.restart();
+
+            if(!isEnabled()) {
+                sail = null;
+            }
         } else if(e.containsChangedKeyWithPrefix("reasoning")) {
             ReasoningConfiguration config = sail.getConfig();
             config.setBatchSize(configurationService.getIntConfiguration("reasoning.batchsize",1000));
@@ -124,7 +128,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.apache.marmotta.kiwi.reasoner.parser.ParseException in case the program
cannot be parsed
      */
     public void addProgram(String name, InputStream data) throws IOException, SailException,
ParseException {
-        sail.addProgram(name, data);
+        if(isEnabled()) {
+            sail.addProgram(name, data);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -140,7 +148,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.openrdf.sail.SailException  in case the program already exists
      */
     public void addProgram(Program program) throws SailException {
-        sail.addProgram(program);
+        if(isEnabled()) {
+            sail.addProgram(program);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -153,7 +165,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.openrdf.sail.SailException
      */
     public void deleteProgram(String name) throws SailException {
-        sail.deleteProgram(name);
+        if(isEnabled()) {
+            sail.deleteProgram(name);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -165,7 +181,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.openrdf.sail.SailException  in case an error occurs
      */
     public Program getProgram(String name) throws SailException {
-        return sail.getProgram(name);
+        if(isEnabled()) {
+            return sail.getProgram(name);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -174,14 +194,20 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @return
      */
     public CloseableIteration<Program, SailException> listPrograms() throws SailException
{
-        return sail.listPrograms();
+        if(isEnabled()) {
+            return sail.listPrograms();
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
      * Clean all inferred triples and re-run all reasoning rules.
      */
     public void reRunPrograms() {
-        sail.reRunPrograms();
+        if(isEnabled()) {
+            sail.reRunPrograms();
+        }
     }
 
     /**
@@ -195,7 +221,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.apache.marmotta.kiwi.reasoner.parser.ParseException in case the program
cannot be parsed
      */
     public void updateProgram(String name, InputStream data) throws IOException, SailException,
ParseException {
-        sail.updateProgram(name, data);
+        if(isEnabled()) {
+            sail.updateProgram(name, data);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -207,7 +237,11 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.openrdf.sail.SailException in case a database error occurs
      */
     public void updateProgram(Program program) throws SailException {
-        sail.updateProgram(program);
+        if(isEnabled()) {
+            sail.updateProgram(program);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 
     /**
@@ -218,6 +252,10 @@ public class ReasoningSailProvider implements TransactionalSailProvider
{
      * @throws org.openrdf.sail.SailException
      */
     public CloseableIteration<Justification, SailException> justify(long tripleId)
throws SailException {
-        return sail.justify(tripleId);
+        if(isEnabled()) {
+            return sail.justify(tripleId);
+        } else {
+            throw new SailException("reasoning is disabled");
+        }
     }
 }


Mime
View raw message