X-Git-Url: https://gerrit.simantics.org/r/gitweb?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=8a4a1a13b71c8f7c56003bc2d59babafb85c46ce;hb=a8ea477a16e16f53f2909c58fb88a379b36b3f2c;hp=343623bcfd137f960667e0985cf2f304befc753b;hpb=c10753c13921e63c6bb2cf51335a9c6d402efac5;p=simantics%2Fplatform.git 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 343623bcf..8a4a1a13b 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 @@ -84,7 +84,7 @@ public class IndexUtils { public static Collection findByName(ReadGraph graph, Resource model, String name) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); HashSet results = new HashSet(); - + String search = IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name); for(Resource resource : findResources(graph, model, search)) { @@ -94,29 +94,21 @@ public class IndexUtils { } public static Collection findByType(ReadGraph graph, Resource model, Resource type) throws DatabaseException { - - HashSet results = new HashSet(); - Layer0 L0 = Layer0.getInstance(graph); - String typeName = graph.getRelatedValue(type, L0.HasName, Bindings.STRING); - String search = IndexQueries.quoteTerm(Dependencies.FIELD_TYPES, typeName); + HashSet results = new HashSet<>(); + String search = IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, type); for(Resource resource : findResources(graph, model, search)) { - if(graph.isInstanceOf(resource, type)) results.add(resource); + if(graph.isInstanceOf(resource, type)) results.add(resource); } return results; } public static Collection findByTypeAndName(ReadGraph graph, Resource model, Resource type, String name) throws DatabaseException { - - Layer0 L0 = Layer0.getInstance(graph); - HashSet results = new HashSet(); - String typeName = graph.getRelatedValue(type, L0.HasName, Bindings.STRING); - - String search = IndexQueries.and(IndexQueries.quoteTerm(Dependencies.FIELD_TYPES, typeName), IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name)); + String search = IndexQueries.and(IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, type), IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name)); for(Resource resource : findResources(graph, model, search)) { - if(graph.isInstanceOf(resource, type)) results.add(resource); + if(graph.isInstanceOf(resource, type)) results.add(resource); } return results; }