]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Inherit HandleEventRequest from UnaryRequest to support request caching 52/4352/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 3 Aug 2020 11:13:44 +0000 (14:13 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 3 Aug 2020 11:13:44 +0000 (14:13 +0300)
gitlab #577

Change-Id: I352fff5f444c74006deb774eee8ddd762d90385c

bundles/org.simantics.document.server/src/org/simantics/document/server/request/HandleEventRequest.java

index 606b361b62729ef2f5b74cdb8ad7f379a974049c..4c611a9aab043d749f0be7c4158b0fce95a0da76 100644 (file)
@@ -1,19 +1,17 @@
 package org.simantics.document.server.request;
 
 import org.simantics.db.ReadGraph;
+import org.simantics.db.common.request.UnaryRead;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
-import org.simantics.db.request.Read;
 import org.simantics.document.server.handler.AbstractEventHandler;
 import org.simantics.structural.stubs.StructuralResource2;
 
-public class HandleEventRequest implements Read<AbstractEventHandler> {
-
-    final String id;
+public class HandleEventRequest extends UnaryRead<String, AbstractEventHandler> {
 
     public HandleEventRequest(String id) {
-        this.id = id;
+        super(id);
     }
 
     @Override
@@ -21,7 +19,7 @@ public class HandleEventRequest implements Read<AbstractEventHandler> {
 
         StructuralResource2.getInstance(graph);
 
-        Variable variable = Variables.getPossibleVariable(graph, id);
+        Variable variable = Variables.getPossibleVariable(graph, parameter);
         if(variable == null) return null;
 
 //        System.err.println("EVENT " + variable.getURI(graph));
@@ -29,7 +27,7 @@ public class HandleEventRequest implements Read<AbstractEventHandler> {
         if(handler instanceof AbstractEventHandler)
             return (AbstractEventHandler) handler;
         else
-            throw new DatabaseException("Handler for " + id + " is not instance of AbstractEventHandler (it is instance of " + (handler != null ? handler.getClass() : null) + ")");
+            throw new DatabaseException("Handler for " + parameter + " is not instance of AbstractEventHandler (it is instance of " + (handler != null ? handler.getClass() : null) + ")");
     }
 
 }
\ No newline at end of file