public static Collection<Resource> findByName(ReadGraph graph, Resource model, String name) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(graph);
HashSet<Resource> results = new HashSet<Resource>();
-
+
String search = IndexQueries.quoteTerm(Dependencies.FIELD_NAME, name);
for(Resource resource : findResources(graph, model, search)) {
}
public static Collection<Resource> findByType(ReadGraph graph, Resource model, Resource type) throws DatabaseException {
-
- HashSet<Resource> results = new HashSet<Resource>();
- Layer0 L0 = Layer0.getInstance(graph);
- String typeName = graph.getRelatedValue(type, L0.HasName, Bindings.STRING);
- String search = IndexQueries.quoteTerm(Dependencies.FIELD_TYPES, typeName);
+ HashSet<Resource> 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<Resource> findByTypeAndName(ReadGraph graph, Resource model, Resource type, String name) throws DatabaseException {
-
- Layer0 L0 = Layer0.getInstance(graph);
-
HashSet<Resource> results = new HashSet<Resource>();
- 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;
}