From 5f5292eb3f4da9cc1622ae7e30a304829ad2c083 Mon Sep 17 00:00:00 2001 From: villberg Date: Mon, 27 Oct 2014 07:15:49 +0000 Subject: [PATCH] (refs #5419) Query optimization, updates and other minor tweaks git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30488 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/adapter/VariableRVIUtils.java | 34 ++++++++++++------ .../sysdyn/utils/DocumentationUtils.java | 36 +++++++++++++------ 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java index 5ba16968..986e2cc9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java @@ -28,6 +28,8 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.request.VariableRead; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; +import org.simantics.db.request.ReadExt; +import org.simantics.db.request.RequestFlags; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.SysdynDataSet; @@ -154,18 +156,18 @@ public class VariableRVIUtils { } - /** - * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1] - * @param graph ReadGraph - * @param variable Variable for the rvis - * @return rvis in a map. Keys are numerical formatted array indexes and values are textual. - * @throws DatabaseException - */ - public static HashMap getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException { - return graph.syncRequest(new GetActiveRVIs(variable)); - } +// /** +// * Returns rvis in a map in format /ModuleInstance/Variable[1] = /ModuleInstance/Variable[index1] +// * @param graph ReadGraph +// * @param variable Variable for the rvis +// * @return rvis in a map. Keys are numerical formatted array indexes and values are textual. +// * @throws DatabaseException +// */ +// public static HashMap getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException { +// return graph.syncRequest(new GetActiveRVIs(variable)); +// } - public static class GetActiveRVIs extends VariableRead> { + public static class GetActiveRVIs extends VariableRead> implements ReadExt { public GetActiveRVIs(Variable variable) { super(variable); @@ -195,6 +197,16 @@ public class VariableRVIUtils { } return rvis; } + + @Override + public boolean isImmutable(ReadGraph graph) throws DatabaseException { + return false; + } + + @Override + public int getType() { + return RequestFlags.IMMEDIATE_UPDATE; + } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java index b8b06837..b2c4b716 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java @@ -22,11 +22,12 @@ import org.simantics.db.common.request.UniqueRead; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.exception.MissingVariableException; import org.simantics.db.layer0.util.EvaluatingListener; import org.simantics.db.layer0.util.EvaluatingListener.Criterion; import org.simantics.db.layer0.util.EvaluatingListener.Evaluation; import org.simantics.db.layer0.variable.Variables; +import org.simantics.db.request.ReadExt; +import org.simantics.db.request.RequestFlags; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; import org.simantics.scl.runtime.function.FunctionImpl1; @@ -618,27 +619,42 @@ public class DocumentationUtils { } - public static class LastValueIndexed extends BinaryRead { + public static class LastValueIndexed extends BinaryRead implements ReadExt { - public LastValueIndexed(Resource resource, String path) { - super(resource, path); + public LastValueIndexed(org.simantics.db.layer0.variable.Variable run, String path) { + super(run, path); } @Override public org.simantics.db.layer0.variable.Variable perform(ReadGraph graph) throws DatabaseException { - org.simantics.db.layer0.variable.Variable run = Variables.getVariable(graph, parameter); - Pair nameAndIndices = splitToNameAndIndices(parameter2); - org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second); - if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2); - return v; + try { + Pair nameAndIndices = splitToNameAndIndices(parameter2); + org.simantics.db.layer0.variable.Variable v = parameter.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second); + //if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2); + if(v == null) return null; + return v; + } catch (Throwable e) { + throw new DatabaseException(e); + } } + + @Override + public boolean isImmutable(ReadGraph graph) throws DatabaseException { + return false; + } + + @Override + public int getType() { + return RequestFlags.IMMEDIATE_UPDATE; + } + } public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException { if(run == null) return null; - return graph.syncRequest(new LastValueIndexed(run.getRepresents(graph), path)); + return graph.syncRequest(new LastValueIndexed(run, path)); } public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException { -- 2.47.1