]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependencyResources.java
AsyncBarrier.dec runs into refcounting problem
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / genericrelation / DependencyResources.java
index 1702af0f38e6182832673997ab7b55588ae5f335..a2059a6ad27264b02381a3b4400d18f7ed5a5401 100644 (file)
@@ -13,13 +13,14 @@ package org.simantics.db.layer0.genericrelation;
 
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.db.common.utils.Logger;
+import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.GenericRelationIndex;
 import org.simantics.db.service.QueryControl;
 import org.simantics.operation.Layer0X;
 import org.simantics.scl.runtime.function.FunctionImpl4;
 import org.simantics.scl.runtime.function.UnsaturatedFunction2;
+import org.slf4j.LoggerFactory;
 
 /**
  * dependencyResources:
@@ -30,6 +31,8 @@ import org.simantics.scl.runtime.function.UnsaturatedFunction2;
  */
 public class DependencyResources extends FunctionImpl4<ReadGraph, Resource, String, Integer, Object> {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DependencyResources.class);
+
     protected Resource getIndexRelation(ReadGraph graph) {
         return Layer0X.getInstance(graph).DependenciesRelation;
     }
@@ -61,10 +64,15 @@ public class DependencyResources extends FunctionImpl4<ReadGraph, Resource, Stri
             final int maxResults = _maxResults != null ? _maxResults : Integer.MAX_VALUE;
             
             QueryControl qc = graph.getService(QueryControl.class);
-            return index.queryResources(qc.getIndependentGraph(graph), query, getBindingPattern(), new Object[] { model }, maxResults);
+            return qc.syncRequestIndependent(graph, new UniqueRead<Object>() {
+                @Override
+                public Object perform(ReadGraph graph) throws DatabaseException {
+                    return index.queryResources(graph, query, getBindingPattern(), new Object[] { model }, maxResults);
+                }
+            });
             
         } catch (DatabaseException e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("Error while performing index query", e);
             return null;
         }
     }