1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.api.request.misc;
14 import org.junit.Test;
15 import org.simantics.db.AsyncReadGraph;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.Session;
19 import org.simantics.db.Statement;
20 import org.simantics.db.common.primitiverequest.PossibleStatement;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.procedure.AsyncListener;
23 import org.simantics.db.procedure.SyncListener;
24 import org.simantics.db.testing.base.ExistingDatabaseTest;
25 import org.simantics.layer0.Layer0;
27 public class SyncAsyncSyncTest9 extends ExistingDatabaseTest {
30 public void test() throws Exception {
32 Session session = getSession();
34 session.syncRequest(new TestAsyncReadRequest() {
37 public void run(AsyncReadGraph g) throws Throwable {
39 final Layer0 b = Layer0.getInstance(g);
41 g.forPossibleObject(g.getRootLibrary(), b.InstanceOf, new AsyncListener<Resource>() {
44 public void execute(AsyncReadGraph graph, Resource type) {
46 graph.asyncRequest(new PossibleStatement(type, b.InstanceOf), new SyncListener<Statement>() {
49 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
53 public void execute(ReadGraph graph, Statement result) throws DatabaseException {
57 public boolean isDisposed() {
63 // graph.syncRequest(new ForObjectSet(type, b.Inherits, new SyncSetListener<Resource>() {
66 // public void add(ReadGraph graph, Resource result) throws DatabaseException {
68 // System.out.println(GraphUtils.getReadableName(graph, result));
70 // graph.asyncRequest(new PossibleStatement(result, b.InstanceOf), new SyncListener<Statement>() {
73 // public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
77 // public void execute(ReadGraph graph, Statement result) throws DatabaseException {
81 // public boolean isDisposed() {
90 // public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
95 // public void remove(ReadGraph graph, Resource result) throws DatabaseException {
100 // public boolean isDisposed() {
109 public void exception(AsyncReadGraph graph, Throwable throwable) {
110 throwable.printStackTrace();
115 public boolean isDisposed() {