package org.simantics.db.indexing;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
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;
Layer0 L0 = Layer0.getInstance(graph);
HashSet<Resource> results = new HashSet<Resource>();
- String search = "Name:" + name;
+ String search = IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name);
- for(Map<String, Object> 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;
HashSet<Resource> results = new HashSet<Resource>();
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<String, Object> 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;
HashSet<Resource> results = new HashSet<Resource>();
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<String, Object> 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;