]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleNearestOwner.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / PossibleNearestOwner.java
diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleNearestOwner.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleNearestOwner.java
new file mode 100644 (file)
index 0000000..d2b59d2
--- /dev/null
@@ -0,0 +1,21 @@
+package org.simantics.db.common.request;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class PossibleNearestOwner extends ResourceRead2<Resource> {\r
+\r
+    public PossibleNearestOwner(Resource resource, Resource type) {\r
+        super(resource, type);\r
+    }\r
+\r
+    @Override\r
+    public Resource perform(ReadGraph graph) throws DatabaseException {\r
+       Resource owner = graph.syncRequest(new PossibleOwner(resource));\r
+       if(owner == null) return null;\r
+       if(graph.isInstanceOf(owner, resource2)) return owner;\r
+       return graph.syncRequest(new PossibleNearestOwner(owner, resource2));\r
+    }\r
+    \r
+}
\ No newline at end of file