X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FRelationInfoQuery.java;h=b0a2a1198e2dd304692717b1329ff5a5d7678796;hb=8b6de499c9c1bad0e72631719fd165ce39d6ad56;hp=d55768aaa1a04cea220b146882cdf614e0353fd9;hpb=3850fec72035293b9a4ede780d01aedc5fbc9056;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/RelationInfoQuery.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/RelationInfoQuery.java index d55768aaa..b0a2a1198 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/RelationInfoQuery.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/RelationInfoQuery.java @@ -17,7 +17,7 @@ import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; import org.simantics.db.request.RequestFlags; -final public class RelationInfoQuery extends UnaryQuery> { +final public class RelationInfoQuery extends UnaryQueryP { RelationInfoQuery(final int resource) { super(resource); @@ -28,50 +28,48 @@ final public class RelationInfoQuery extends UnaryQuery proc) throws DatabaseException { + private static void computeAssertions(ReadGraphImpl graph, int r, final boolean isFinal, final boolean isFunctional, RelationInfoQuery parent, final InternalProcedure procedure) throws DatabaseException { QueryProcessor processor = graph.processor; final int isUsedInAssertion = processor.getHasPredicateInverse(); assert(isUsedInAssertion != 0); - QueryCache.runnerDirectObjects(graph, r, isUsedInAssertion, entry, null, new IntProcedure() { + QueryCache.runnerDirectObjects(graph, r, isUsedInAssertion, parent, null, new IntProcedure() { boolean done = false; @Override public void execute(ReadGraphImpl graph, int i) throws DatabaseException { + if(done) return; done = true; RelationInfo result = new RelationInfo(r, isFunctional, isFinal, true); - if(entry != null) entry.setResult(result); - proc.execute(graph, result); + procedure.execute(graph, result); } @Override public void finished(ReadGraphImpl graph) throws DatabaseException { - if(!done) { - done = true; - RelationInfo result = new RelationInfo(r, isFunctional, isFinal, false); - if(entry != null) entry.setResult(result); - proc.execute(graph, result); - } + if(done) return; + done = true; + RelationInfo result = new RelationInfo(r, isFunctional, isFinal, false); + procedure.execute(graph, result); } @Override public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException { - if(!done) { - done = true; - DatabaseException e = new DatabaseException("Internal error in RelationInfoQuery"); - if(entry != null) entry.except(e); - proc.exception(graph, e); - } + if(done) return; + done = true; + DatabaseException e = new DatabaseException("Internal error in RelationInfoQuery"); + procedure.exception(graph, e); } }); } - public static void computeForEach(ReadGraphImpl graph, int r, RelationInfoQuery entry, InternalProcedure procedure) throws DatabaseException { + public static void computeForEach(ReadGraphImpl graph, int r, RelationInfoQuery entry, InternalProcedure procedure_) throws DatabaseException { + + InternalProcedure procedure = entry != null ? entry : procedure_; QueryProcessor provider = graph.processor; @@ -82,77 +80,30 @@ final public class RelationInfoQuery extends UnaryQuery procedure) throws DatabaseException { + public void compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { computeForEach(graph, id, this, procedure); - return getResult(); } @Override public String toString() { return "RelationInfoQuery[" + id + "]"; } - -// public void addOrSet(ReadGraphImpl graph, final RelationInfo result, final QueryProcessor provider) { -// -// assert(isPending()); -// -// synchronized(this) { -// -// setResult(result); -// setReady(); -// -// } -// -// } @Override public void setResult(Object result) { super.setResult(result); - if(!(result instanceof RelationInfo) && !(result == NO_RESULT)) - System.err.println("foo"); setReady(); } - - @Override - public Object performFromCache(ReadGraphImpl graph, InternalProcedure procedure) throws DatabaseException { - - assert(isReady()); - - if(handleException(graph, procedure)) return EXCEPTED; - - RelationInfo result = getResult(); - - procedure.execute(graph, result); - - return result; - - } @Override public int type() { return RequestFlags.IMMEDIATE_UPDATE; } - - @Override - public void recompute(ReadGraphImpl graph) throws DatabaseException { - - compute(graph, new InternalProcedure() { - - @Override - public void execute(ReadGraphImpl graph, RelationInfo result) { - } - - @Override - public void exception(ReadGraphImpl graph, Throwable t) { - throw new Error("Error in recompute.", t); - } - - }); - - } }