Filter filter;
if (beforeDeadlineOnly) {
long current = new Date().getTime();
if (EventCategory.getAllEventCategory().equals(category) || "".equals(category)) {
Query filterQuery = new TermRangeQuery("DEADLINE-TIME", TimeUtil.getTimeString(current), TimeUtil.getTimeString(Long.MAX_VALUE), true, true);
filter = new QueryWrapperFilter(filterQuery);
} else {
if (!EventCategory.isValidCategoryName(category)) {
throw new IllegalArgumentException("Unknown category");
}
BooleanQuery filterQuery = new BooleanQuery();
filterQuery.add(new BooleanClause(new TermQuery(new Term("CATEGORY", category)), Occur.MUST));
filterQuery.add(new BooleanClause(new TermRangeQuery("DEADLINE-TIME", TimeUtil.getTimeString(current), TimeUtil.getTimeString(Long.MAX_VALUE), true, true), Occur.MUST));
filter = new QueryWrapperFilter(filterQuery);
}
} else {
if (EventCategory.getAllEventCategory().equals(category) || "".equals(category)) {
filter = null;
// filter = new QueryWrapperFilter(new MatchAllDocsQuery());
} else {
if (!EventCategory.isValidCategoryName(category)) {
throw new IllegalArgumentException("Unknown category");
}
filter = new QueryWrapperFilter(new TermQuery(new Term("CATEGORY", category)));
}
}
// TODO: このへんの定数なんとかするべき。いろんなところに散らばっていて使いにくい。