]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentationUtils.java
Improvements to Lucene indexing
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / TGRepresentationUtils.java
index ffa39974315a1a06b50c57aada1816ae2677130e..f02b8eb9e29252d2cc36c86ad12d77883db0b495 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.db.layer0.util;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.simantics.datatypes.literal.GUID;
 import org.simantics.db.ReadGraph;
@@ -22,10 +23,13 @@ import org.simantics.db.Statement;
 import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.impl.EntityInstances.QueryIndex;
-import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
+import org.simantics.db.layer0.genericrelation.IndexQueries;
+import org.simantics.db.layer0.util.ConsistsOfProcess.ConsistsOfProcessEntry;
 import org.simantics.db.layer0.util.DomainProcessor3.ExclusionDecision;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function1;
+import org.simantics.utils.datastructures.Pair;
 
 /**
  * @author Antti Villberg
@@ -38,7 +42,7 @@ public class TGRepresentationUtils {
         Layer0 L0 = Layer0.getInstance(graph);
         GUID guid = graph.getPossibleRelatedValue(source, L0.identifier, GUID.BINDING);
         if(guid != null) {
-            List<Resource> exist = graph.syncRequest(new QueryIndex(targetIndex, L0.Entity, "GUID:" + guid.indexString()));
+            List<Resource> exist = graph.syncRequest(new QueryIndex(targetIndex, L0.Entity, "GUID:" + IndexQueries.quoteTerm(guid.indexString())));
             return !exist.isEmpty();
         }
         return false;
@@ -63,8 +67,9 @@ public class TGRepresentationUtils {
                         return new GUIDExclusionFunction(graph);
 
                     // The root is OK - check everything beneath
-                    List<InternalEntry> entries = ConsistsOfProcess.walk(graph, null, Collections.singleton(r), Collections.emptySet(), true); 
-                    for(InternalEntry entry : entries) {
+                    Pair<List<ConsistsOfProcessEntry>,Set<Resource>> pair = ConsistsOfProcess.walk(graph, Collections.singleton(SeedSpec.internal(r)), true); 
+                    List<ConsistsOfProcessEntry> entries = pair.first;
+                    for(ConsistsOfProcessEntry entry : entries) {
                         if(findByIdentifier(graph, targetRoot, entry.resource))
                             return new GUIDExclusionFunction(graph);
                     }