I've created an Objectify implementation of GeocellQueryEngine for my
project. It uses GeocellQuery.baseQuery to specify comma separated
filter conditions and GeocellQuery.parameters as filter values.
Alex, I clicked on "reply to author" for the message
http://groups.google.com/group/javageomodel-discuss/browse_thread/thread/9d85a167e2163e38
just now thinking it was reply to that thread, sorry! :-)
Tested to be working in my own project, so feel free to use it or add
it to this project.
/**
* Objectify implementation for GeocellQueryEngine.
* <p>
* Example:
* <pre>
* // paramList contains values for each filter() condition
* List<Object> paramList = new ArrayList<Object>();
* paramList.add(q);
* paramList.add(q + "\uFFFD");
*
* // comma separated filter() conditions
* GeocellQuery baseQuery = new GeocellQuery("title >=, title
<", paramList);
* GeocellQueryEngine queryEngine = new
ObjectifyGeocellQueryEngine(ofy());
*
* // perform search
* GeocellManager.proximitySearch(
* new Point(lat, lng), maxResults, maxDistance,
* MyEntity.class,
* baseQuery, queryEngine,
GeocellManager.MAX_GEOCELL_RESOLUTION);
* </pre>
*/
public class ObjectifyGeocellQueryEngine implements GeocellQueryEngine
{
private String geocellsProperty;
private Objectify ofy;
public static final String DEFAULT_GEOCELLS_PROPERTY = "geocells";
public ObjectifyGeocellQueryEngine(Objectify ofy) {
this(ofy, DEFAULT_GEOCELLS_PROPERTY);
}
public ObjectifyGeocellQueryEngine(Objectify ofy, String
geocellsProperty) {
this.ofy = ofy;
this.geocellsProperty = geocellsProperty;
}
@Override
public <T> List<T> query(GeocellQuery baseQuery, List<String>
geocells, Class<T> entityClass) {
StringTokenizer st;
int tokenNo = 0;
Query<T> query = ofy.query(entityClass);
if (baseQuery != null) {
st = new StringTokenizer(baseQuery.getBaseQuery(), ",");
while (st.hasMoreTokens()) {
query.filter(st.nextToken(),
baseQuery.getParameters().get(tokenNo++));
}
}
return query.filter(geocellsProperty + " IN",
geocells).list();
}
}
It was developed for ofy3. I would also recommend looking at GAE's new features to see how this can be implemented more effectively if you're starting a new project.