]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/request/misc/SyncAsyncSyncTest9.java
4d6b1fb46bab7e51732b3b55639c37343edf1270
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / request / misc / SyncAsyncSyncTest9.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.tests.api.request.misc;
13
14 import org.junit.Test;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.Session;
18 import org.simantics.db.Statement;
19 import org.simantics.db.common.primitiverequest.PossibleStatement;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.db.procedure.SyncListener;
22 import org.simantics.db.testing.base.ExistingDatabaseTest;
23 import org.simantics.layer0.Layer0;
24
25 public class SyncAsyncSyncTest9 extends ExistingDatabaseTest {
26         
27         @Test
28         public void test() throws Exception {
29                 
30                 Session session = getSession();
31                 
32         session.syncRequest(new TestReadRequest() {
33
34             @Override
35             public void run(ReadGraph g) throws DatabaseException {
36
37                 final Layer0 b = Layer0.getInstance(g);
38
39                 g.forPossibleObject(g.getRootLibrary(), b.InstanceOf, new SyncListener<Resource>() {
40
41                     @Override
42                     public void execute(ReadGraph graph, Resource type) throws DatabaseException {
43
44                         graph.asyncRequest(new PossibleStatement(type, b.InstanceOf), new SyncListener<Statement>() {
45
46                             @Override
47                             public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
48                             }
49
50                             @Override
51                             public void execute(ReadGraph graph, Statement result) throws DatabaseException {
52                             }
53
54                             @Override
55                             public boolean isDisposed() {
56                                 return false;
57                             }
58                             
59                         });
60
61 //                        graph.syncRequest(new ForObjectSet(type, b.Inherits, new SyncSetListener<Resource>() {
62 //
63 //                            @Override
64 //                            public void add(ReadGraph graph, Resource result) throws DatabaseException {
65 //                                
66 //                                System.out.println(GraphUtils.getReadableName(graph, result));
67 //                                
68 //                                graph.asyncRequest(new PossibleStatement(result, b.InstanceOf), new SyncListener<Statement>() {
69 //
70 //                                    @Override
71 //                                    public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
72 //                                    }
73 //
74 //                                    @Override
75 //                                    public void execute(ReadGraph graph, Statement result) throws DatabaseException {
76 //                                    }
77 //
78 //                                    @Override
79 //                                    public boolean isDisposed() {
80 //                                        return false;
81 //                                    }
82 //                                    
83 //                                });
84 //                                
85 //                            }
86 //
87 //                            @Override
88 //                            public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
89 //                                assert(false);
90 //                            }
91 //
92 //                            @Override
93 //                            public void remove(ReadGraph graph, Resource result) throws DatabaseException {
94 //                                assert(false);
95 //                            }
96 //
97 //                            @Override
98 //                            public boolean isDisposed() {
99 //                                return false;
100 //                            }
101 //                            
102 //                        }));
103                         
104                     }
105
106                     @Override
107                     public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
108                         throwable.printStackTrace();
109                         assert(false);
110                     }
111
112                     @Override
113                     public boolean isDisposed() {
114                         return false;
115                     }
116                     
117                 });
118                 
119             }
120             
121         });
122         
123         }
124
125 }