Merge commit '55ca14c'
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / QueryDebugImpl.java
1 package fi.vtt.simantics.procore.internal;\r
2 \r
3 import java.util.HashSet;\r
4 import java.util.Set;\r
5 \r
6 import org.simantics.db.impl.query.CacheEntry;\r
7 import org.simantics.db.impl.query.CacheEntryBase;\r
8 import org.simantics.db.impl.service.QueryDebug;\r
9 import org.simantics.db.request.AsyncMultiRead;\r
10 import org.simantics.db.request.AsyncRead;\r
11 import org.simantics.db.request.MultiRead;\r
12 import org.simantics.db.request.Read;\r
13 \r
14 public class QueryDebugImpl implements QueryDebug {\r
15         \r
16         final private SessionImplSocket session;\r
17         \r
18         QueryDebugImpl(SessionImplSocket session) {\r
19                 this.session = session;\r
20         }\r
21 \r
22     @Override\r
23     public Set<CacheEntry> getParents(AsyncRead request) {\r
24         HashSet<CacheEntry> result = new HashSet<CacheEntry>();\r
25         CacheEntryBase entry = session.queryProvider2.asyncReadMap.get(request);\r
26         if(entry != null) {\r
27             for(CacheEntry parent : entry.getParents(session.queryProvider2)) result.add(parent);\r
28         }\r
29         return result;\r
30     }\r
31 \r
32     @Override\r
33     public Set<CacheEntry> getParents(AsyncMultiRead request) {\r
34         HashSet<CacheEntry> result = new HashSet<CacheEntry>();\r
35         CacheEntryBase entry = session.queryProvider2.asyncMultiReadMap.get(request);\r
36         if(entry != null) {\r
37             for(CacheEntry parent : entry.getParents(session.queryProvider2)) result.add(parent);\r
38         }\r
39         return result;\r
40     }\r
41 \r
42     @Override\r
43     public Set<CacheEntry> getParents(Read request) {\r
44         HashSet<CacheEntry> result = new HashSet<CacheEntry>();\r
45         CacheEntryBase entry = session.queryProvider2.readMap.get(request);\r
46         if(entry != null) {\r
47             for(CacheEntry parent : entry.getParents(session.queryProvider2)) result.add(parent);\r
48         }\r
49         return result;\r
50     }\r
51 \r
52     @Override\r
53     public Set<CacheEntry> getParents(MultiRead request) {\r
54         HashSet<CacheEntry> result = new HashSet<CacheEntry>();\r
55         CacheEntryBase entry = session.queryProvider2.multiReadMap.get(request);\r
56         if(entry != null) {\r
57             for(CacheEntry parent : entry.getParents(session.queryProvider2)) result.add(parent);\r
58         }\r
59         return result;\r
60     }\r
61 \r
62 }\r