]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleNearestOwner.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / PossibleNearestOwner.java
1 package org.simantics.db.common.request;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
6
7 public class PossibleNearestOwner extends ResourceRead2<Resource> {
8
9     public PossibleNearestOwner(Resource resource, Resource type) {
10         super(resource, type);
11     }
12
13     @Override
14     public Resource perform(ReadGraph graph) throws DatabaseException {
15         Resource owner = graph.syncRequest(new PossibleOwner(resource));
16         if(owner == null) return null;
17         if(graph.isInstanceOf(owner, resource2)) return owner;
18         return graph.syncRequest(new PossibleNearestOwner(owner, resource2));
19     }
20     
21 }