]> gerrit.simantics Code Review - simantics/platform.git/blob - db/impl/ForEachObjectProcedure.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / db / impl / ForEachObjectProcedure.java
1 package org.simantics.db.impl;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.RelationInfo;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.impl.query.QueryProcessor;
8 import org.simantics.db.procedure.SyncMultiProcedure;
9
10 public final class ForEachObjectProcedure implements SyncMultiProcedure<Resource> {
11
12         public final int predicateKey;
13         public final int[] clusterKey;
14         public final int[] predicateReference;
15         public final RelationInfo info;
16         public final QueryProcessor processor;
17         public final ClusterI.CompleteTypeEnum completeType;
18         private final SyncMultiProcedure<Resource> user;
19         
20         public ForEachObjectProcedure(int predicateKey, RelationInfo info, QueryProcessor processor, SyncMultiProcedure<Resource> user) {
21                 this.predicateKey = predicateKey;
22                 this.completeType = ClusterTraitsBase.getCompleteTypeFromResourceKey(predicateKey); 
23                 this.info = info;
24                 this.user = user;
25                 this.processor = processor;
26                 this.clusterKey = new int[32*8];
27                 this.predicateReference = new int[32*8];
28         }
29         
30         @Override
31         public void execute(ReadGraph graph, Resource result) throws DatabaseException {
32                 user.execute(graph, result);
33         }
34
35         @Override
36         public void finished(ReadGraph graph) throws DatabaseException {
37                 user.finished(graph);
38         }
39
40         @Override
41         public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
42                 user.exception(graph, throwable);
43         }
44         
45 }