package org.simantics.db.tests.regression.bugs;
import org.junit.Test;
+import org.simantics.db.AsyncReadGraph;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.WriteGraph;
import org.simantics.db.common.primitiverequest.PossibleObject;
-import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.common.request.AsyncReadRequest;
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.SyncListener;
}
}
}
- class Query extends ReadRequest {
+ class Query extends AsyncReadRequest {
@Override
- public void run(ReadGraph g) throws DatabaseException {
- Layer0 l0 = Layer0.getInstance(g);
- for (Resource r : g.getObjects(testRoot, l0.ConsistsOf)) {
- if (DEBUG)
- System.out.println("Resource " + r);
- for (Resource rr : g.getObjects(r, l0.ConsistsOf)) {
-// if (DEBUG)
-// System.out.println("Resource " + rr);
- if (!g.isInstanceOf(rr, type))
- fail("Resource " + rr + " is not instance of type.");
- if (!g.isInstanceOf(rr, l0.Entity))
- fail("Resource " + rr + " is not instance of Entity.");
- if (USE_LISTENER)
- g.forPossibleObject(rr, l0.InstanceOf, new SyncListener<Resource>() {
-
- @Override
- public void execute(ReadGraph graph, Resource resource) throws DatabaseException {
- if (DEBUG_LISTENER)
- System.out.println("change " + resource);
- }
-
- @Override
- public void exception(ReadGraph graph, Throwable t)
- throws DatabaseException {
- t.printStackTrace();
- fail("Listener got exception: " + t);
- }
-
- @Override
- public boolean isDisposed() {
- if (DEBUG_LISTENER)
- System.out.println("Asked if disposed.");
- return true;
- }
- });
- if (USE_LISTENER2) {
- g.forPossibleObject(rr, l0.InstanceOf, new Listener(loopCount, listenerCount));
- }
- if (USE_LISTENER3) {
- g.syncRequest(new PossibleObject(rr, l0.InstanceOf), new Listener(loopCount, listenerCount));
- }
- }
- }
+ public void run(AsyncReadGraph g) {
+ try {
+ Layer0 l0 = Layer0.getInstance(g);
+ for (Resource r : g.getObjects(testRoot, l0.ConsistsOf)) {
+ if (DEBUG)
+ System.out.println("Resource " + r);
+ for (Resource rr : g.getObjects(r, l0.ConsistsOf)) {
+ // if (DEBUG)
+ // System.out.println("Resource " + rr);
+ if (!g.isInstanceOf(rr, type))
+ fail("Resource " + rr + " is not instance of type.");
+ if (!g.isInstanceOf(rr, l0.Entity))
+ fail("Resource " + rr + " is not instance of Entity.");
+ if (USE_LISTENER)
+ g.forPossibleObject(rr, l0.InstanceOf, new SyncListener<Resource>() {
+
+ @Override
+ public void execute(ReadGraph graph, Resource resource) throws DatabaseException {
+ if (DEBUG_LISTENER)
+ System.out.println("change " + resource);
+ }
+
+ @Override
+ public void exception(ReadGraph graph, Throwable t)
+ throws DatabaseException {
+ t.printStackTrace();
+ fail("Listener got exception: " + t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ if (DEBUG_LISTENER)
+ System.out.println("Asked if disposed.");
+ return true;
+ }
+ });
+ if (USE_LISTENER2) {
+ g.forPossibleObject(rr, l0.InstanceOf, new Listener(loopCount, listenerCount));
+ }
+ if (USE_LISTENER3) {
+ g.syncRequest(new PossibleObject(rr, l0.InstanceOf), new Listener(loopCount, listenerCount));
+ }
+ }
+ }
+ } catch (DatabaseException e) {
+ e.printStackTrace();
+ }
}
}
class Listener implements SyncListener<Resource> {