]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
(refs #5419) Query optimization, updates and other minor tweaks
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 27 Oct 2014 07:15:49 +0000 (07:15 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 27 Oct 2014 07:15:49 +0000 (07:15 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30488 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java

index 5ba169689791bd4340b5e7a32d36c24af544f4a4..986e2cc9453f5919d562a58b8212021c276756fb 100644 (file)
@@ -28,6 +28,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.VariableRead;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.request.ReadExt;\r
+import org.simantics.db.request.RequestFlags;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
@@ -154,18 +156,18 @@ public class VariableRVIUtils {
     }\r
 \r
 \r
-    /**\r
-     * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1]\r
-     * @param graph ReadGraph\r
-     * @param variable Variable for the rvis\r
-     * @return rvis in a map. Keys are numerical formatted array indexes and values are textual.\r
-     * @throws DatabaseException\r
-     */\r
-    public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
-        return graph.syncRequest(new GetActiveRVIs(variable));\r
-    }\r
+//    /**\r
+//     * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1]\r
+//     * @param graph ReadGraph\r
+//     * @param variable Variable for the rvis\r
+//     * @return rvis in a map. Keys are numerical formatted array indexes and values are textual.\r
+//     * @throws DatabaseException\r
+//     */\r
+//    public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
+//        return graph.syncRequest(new GetActiveRVIs(variable));\r
+//    }\r
     \r
-    public static class GetActiveRVIs extends VariableRead<HashMap<String, String>> {\r
+    public static class GetActiveRVIs extends VariableRead<HashMap<String, String>> implements ReadExt {\r
 \r
         public GetActiveRVIs(Variable variable) {\r
             super(variable);\r
@@ -195,6 +197,16 @@ public class VariableRVIUtils {
             }\r
             return rvis;\r
         }\r
+\r
+               @Override\r
+               public boolean isImmutable(ReadGraph graph) throws DatabaseException {\r
+                       return false;\r
+               }\r
+\r
+               @Override\r
+               public int getType() {\r
+                       return RequestFlags.IMMEDIATE_UPDATE;\r
+               }\r
     }\r
 \r
     \r
index b8b06837bb56871ae0ae391a4f597a4af2fc4303..b2c4b7164a0582dcd6c3d030bf4b7652684f1080 100644 (file)
@@ -22,11 +22,12 @@ import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.exception.MissingVariableException;\r
 import org.simantics.db.layer0.util.EvaluatingListener;\r
 import org.simantics.db.layer0.util.EvaluatingListener.Criterion;\r
 import org.simantics.db.layer0.util.EvaluatingListener.Evaluation;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.request.ReadExt;\r
+import org.simantics.db.request.RequestFlags;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.scl.runtime.function.FunctionImpl1;\r
@@ -618,27 +619,42 @@ public class DocumentationUtils {
 \r
     }\r
     \r
-    public static class LastValueIndexed extends BinaryRead<Resource, String, org.simantics.db.layer0.variable.Variable> {\r
+    public static class LastValueIndexed extends BinaryRead<org.simantics.db.layer0.variable.Variable, String, org.simantics.db.layer0.variable.Variable> implements ReadExt {\r
 \r
-        public LastValueIndexed(Resource resource, String path) {\r
-            super(resource, path);\r
+        public LastValueIndexed(org.simantics.db.layer0.variable.Variable run, String path) {\r
+            super(run, path);\r
         }\r
 \r
         @Override\r
         public org.simantics.db.layer0.variable.Variable perform(ReadGraph graph) throws DatabaseException {\r
             \r
-            org.simantics.db.layer0.variable.Variable run = Variables.getVariable(graph, parameter);\r
-            Pair<String, String> nameAndIndices = splitToNameAndIndices(parameter2);\r
-            org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
-            if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2);\r
-            return v;\r
+               try {\r
+                   Pair<String, String> nameAndIndices = splitToNameAndIndices(parameter2);\r
+                   org.simantics.db.layer0.variable.Variable v = parameter.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
+                   //if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2);\r
+                   if(v == null) return null;\r
+                   return v;\r
+               } catch (Throwable e) {\r
+                       throw new DatabaseException(e);\r
+               }\r
         }\r
+\r
+               @Override\r
+               public boolean isImmutable(ReadGraph graph) throws DatabaseException {\r
+                       return false;\r
+               }\r
+\r
+               @Override\r
+               public int getType() {\r
+                       return RequestFlags.IMMEDIATE_UPDATE;\r
+               }\r
+        \r
     }\r
     \r
     \r
     public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
        if(run == null) return null;\r
-       return graph.syncRequest(new LastValueIndexed(run.getRepresents(graph), path));\r
+       return graph.syncRequest(new LastValueIndexed(run, path));\r
     }    \r
     \r
     public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r