]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java
Optimized EntityInstances and ModelingUtils.search*Shallow queries
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / ModelingUtils.java
index 511eeb3fa0e41fb0894b866d293cc330812c3923..2afdac9927aea060858b0b30f3a30c3d59ddaf87 100644 (file)
@@ -91,6 +91,7 @@ import org.simantics.db.layer0.adapter.CopyHandler;
 import org.simantics.db.layer0.adapter.GenericRelationIndex;
 import org.simantics.db.layer0.adapter.Instances;
 import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;
+import org.simantics.db.layer0.adapter.impl.EntityInstances.QueryIndex;
 import org.simantics.db.layer0.adapter.impl.ImportAdvisorFactory;
 import org.simantics.db.layer0.genericrelation.IndexedRelations;
 import org.simantics.db.layer0.migration.MigrationUtils;
@@ -704,7 +705,7 @@ public class ModelingUtils {
     }
 
     public static List<Resource> searchByTypeShallow(ReadGraph graph, Resource model, Resource type) throws DatabaseException {
-        return filterByIndexRoot(graph, model, searchByType(graph, model, type));
+        return graph.syncRequest(new QueryIndex(model, type, ""), TransientCacheListener.<List<Resource>>instance());
     }
 
     public static List<Resource> searchByType(ReadGraph graph, Resource model, Resource type) throws DatabaseException {
@@ -721,7 +722,7 @@ public class ModelingUtils {
     }
 
     public static List<Resource> searchByQueryShallow(ReadGraph graph, Resource model, String query) throws DatabaseException {
-        return filterByIndexRoot(graph, model, searchByQuery(graph, model, query));
+        return graph.syncRequest(new QueryIndex(model, Layer0.getInstance(graph).Entity, query), TransientCacheListener.<List<Resource>>instance());
     }
 
     public static List<Resource> searchByQuery(ReadGraph graph, Resource model, String query) throws DatabaseException {
@@ -774,7 +775,7 @@ public class ModelingUtils {
     }
 
     public static List<Resource> searchByTypeAndNameShallow(ReadGraph graph, Resource model, Resource type, String name) throws DatabaseException {
-        return filterByIndexRoot(graph, model, searchByTypeAndName(graph, model, type, name));
+        return graph.syncRequest(new QueryIndex(model, type, name), TransientCacheListener.<List<Resource>>instance());
     }
 
        /**