X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexUtils.java;fp=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexUtils.java;h=26a6e68ae9f9378dd4b7a429c7ac2ccdbe317684;hp=8b1a928b353497bbc733c1b89e7831e986659dd7;hb=0935b78fb5a162719de5dab404b7161de2e7e717;hpb=ca59190923cb45fbcde8d18d78c9c1418c1f0471 diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexUtils.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexUtils.java index 8b1a928b3..26a6e68ae 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexUtils.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexUtils.java @@ -1,6 +1,5 @@ package org.simantics.db.indexing; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -21,6 +20,7 @@ import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; import org.simantics.db.indexing.exception.IndexCorruptedException; +import org.simantics.db.layer0.genericrelation.Dependencies; import org.simantics.db.layer0.genericrelation.IndexQueries; import org.simantics.db.layer0.genericrelation.IndexedRelations; import org.simantics.db.layer0.util.Layer0Utils; @@ -92,10 +92,9 @@ public class IndexUtils { Layer0 L0 = Layer0.getInstance(graph); HashSet results = new HashSet(); - String search = "Name:" + name; + String search = IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name); - for(Map entry : find(graph, model, search)) { - Resource resource = (Resource)entry.get("Resource"); + for(Resource resource : findResources(graph, model, search)) { if(name.equals(graph.getPossibleRelatedValue(resource, L0.HasName, Bindings.STRING))) results.add(resource); } return results; @@ -106,10 +105,9 @@ public class IndexUtils { HashSet results = new HashSet(); Layer0 L0 = Layer0.getInstance(graph); String typeName = graph.getRelatedValue(type, L0.HasName, Bindings.STRING); - String search = "Types:" + IndexQueries.quoteTerm(typeName); + String search = IndexQueries.quoteTerm(Dependencies.FIELD_TYPES, typeName); - for(Map entry : find(graph, model, search)) { - Resource resource = (Resource)entry.get("Resource"); + for(Resource resource : findResources(graph, model, search)) { if(graph.isInstanceOf(resource, type)) results.add(resource); } return results; @@ -121,10 +119,10 @@ public class IndexUtils { HashSet results = new HashSet(); String typeName = graph.getRelatedValue(type, L0.HasName, Bindings.STRING); - String search = "Types:" + IndexQueries.quoteTerm(typeName) + " AND Name:" + IndexQueries.quoteTerm(name); + + String search = IndexQueries.and(IndexQueries.quoteTerm(Dependencies.FIELD_TYPES, typeName), IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name)); - for(Map entry : find(graph, model, search)) { - Resource resource = (Resource)entry.get("Resource"); + for(Resource resource : findResources(graph, model, search)) { if(graph.isInstanceOf(resource, type)) results.add(resource); } return results;