X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FValueQuery.java;h=e533ee30f4ee4f521316b56981c8a13f68c4c6af;hb=de8b6e194da6d56c410101d9c72763078b0e8717;hp=b96e13d42fc14d177779ef021564dfb1fdd22fed;hpb=880a8a4927805afbbf47005a807cef3f39406866;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueQuery.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueQuery.java index b96e13d42..e533ee30f 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueQuery.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ValueQuery.java @@ -15,7 +15,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; -final public class ValueQuery extends UnaryQuery> { +final public class ValueQuery extends UnaryQueryP { ValueQuery(final int resource) { super(resource); @@ -25,59 +25,30 @@ final public class ValueQuery extends UnaryQuery> { final public void removeEntry(QueryProcessor provider) { provider.cache.remove(this); } + + @Override + public void compute(ReadGraphImpl graph, InternalProcedure procedure) throws DatabaseException { + computeForEach(graph, id, this, procedure); + } - public static byte[] computeForEach(ReadGraphImpl graph, final int r, final ValueQuery entry, final InternalProcedure procedure) throws DatabaseException { + public static byte[] computeForEach(ReadGraphImpl graph, final int r, final ValueQuery entry, final InternalProcedure procedure_) throws DatabaseException { + + InternalProcedure procedure = entry != null ? entry : procedure_; graph.ensureLoaded(r); byte[] value = graph.getValue(r); - if(entry != null) { - entry.setResult(value); - entry.setReady(); - } - if(procedure != null) { - procedure.execute(graph, value); - } + if(procedure != null) procedure.execute(graph, value); + + if(entry != null && procedure_ != null) entry.performFromCache(graph, procedure_); return value; } - -// public Object compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { -// return computeForEach(graph, id, this, procedure); -// } @Override public String toString() { return "Value[" + id + "]"; } - - @Override - public Object performFromCache(ReadGraphImpl graph, InternalProcedure procedure) throws DatabaseException { - return computeForEach(graph, id, this, procedure); - } - - @Override - public void recompute(ReadGraphImpl graph) throws DatabaseException { - - computeForEach(graph, id, this, new InternalProcedure() { - - @Override - public void execute(ReadGraphImpl graph, byte[] result) { - } - - @Override - public void exception(ReadGraphImpl graph, Throwable t) { - throw new Error("Error in recompute.", t); - } - - }); - - } - - @Override - boolean isImmutable(ReadGraphImpl graph) { - return graph.processor.isImmutable(id); - } }