]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentFunctionNamingStrategy.java
Index query fixes after commit 5e340942
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / services / CaseInsensitiveComponentFunctionNamingStrategy.java
index ad48d1f2f809ab89e48a545da83ae88f26e094ca..d5a2b92a42306f466bd4d94a2f00dd4de536e0e8 100644 (file)
@@ -27,6 +27,7 @@ import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.common.request.UnaryRead;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.db.layer0.genericrelation.IndexQueries;
 import org.simantics.db.service.GraphChangeListenerSupport;
 import org.simantics.layer0.Layer0;
@@ -45,7 +46,7 @@ import gnu.trove.set.hash.THashSet;
  * 
  * <p>
  * The type of the function is expected to be:
- * <code>ReadGraph => Resource -> String -> Integer -> List&lt;Map&lt;String,Object&gt;&gt;</code>
+ * <code>ReadGraph => Resource -> String -> Integer -> List&lt;Resource&gt;</code>
  * 
  * @author Tuukka Lehtonen
  * 
@@ -135,7 +136,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                        
                     synchronized (this) {
                        
-                        String search = "Name:" + lowercaseName + "*";
+                        String search = IndexQueries.escapeTerm(Dependencies.FIELD_NAME_SEARCH, lowercaseName, true) + "*"; //$NON-NLS-1$
                         @SuppressWarnings("unchecked")
                         List<Resource> components = (List<Resource>) index.apply(graph, indexRoot, search, Integer.MAX_VALUE);
 
@@ -227,7 +228,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
 
         synchronized (this) {
                
-            String search = "Name:" + proposition + "*";
+            String search = Dependencies.FIELD_NAME_SEARCH + ":" + IndexQueries.escape(proposition.toLowerCase(), true) + "*"; //$NON-NLS-1$ //$NON-NLS-2$
             
             Set<String> reserved = graph.syncRequest(new ComponentsRequest(new Tuple4(indexRoot, index, search, getComparator())), TransientCacheAsyncListener.instance());
 
@@ -267,7 +268,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                 if (propositionPreFilter != null)
                     proposition = propositionPreFilter.apply(proposition);
 
-                String search = "Name:" + IndexQueries.quoteTerm( proposition );
+                String search = IndexQueries.quoteTerm(Dependencies.FIELD_NAME_SEARCH, proposition.toLowerCase());
                 @SuppressWarnings("unchecked")
                 List<Resource> components = (List<Resource>) index.apply(graph, indexRoot, search, Integer.MAX_VALUE);