use of org.bedework.caldav.util.filter.FilterBase in project bw-calendar-engine by Bedework.
the class SimpleFilterParser method and.
private FilterBase and(final String name, final FilterBase af, final FilterBase f) {
final FilterBase res;
if (af == null) {
res = f;
} else {
if (af instanceof AndFilter) {
res = af;
} else {
res = new AndFilter();
res.addChild(af);
}
res.addChild(f);
}
if (name != null) {
res.setName(name);
}
return res;
}
use of org.bedework.caldav.util.filter.FilterBase in project bw-calendar-engine by Bedework.
the class SimpleFilterParser method doPropertyComparison.
private boolean doPropertyComparison() throws ParseFailed {
final List<PropertyInfo> pis = getProperty(nextToken("getProperty()"));
final Operator oper = nextOperator();
final FilterBase pfilter = makePropFilter(pis, oper.op);
if (pfilter == null) {
error(new CalFacadeException(CalFacadeException.filterBadProperty, listProps(pis) + " source: " + source));
throw parseResult.fail("Bad property: " + listProps(pis) + " source: " + source);
}
/* If there is a logical operator on the stack top (and/or) then we create
* an anded or ored filter and push that.
*
* Otherwise we just push
*
* WRONG - should be done by doFactor
*/
// if (!topLOp()) {
filterStack.push(pfilter);
return true;
}
use of org.bedework.caldav.util.filter.FilterBase in project bw-calendar-engine by Bedework.
the class SimpleFilterParser method parse.
/**
* Parse the given expression into a filter. The explicitSelection
* flag determines whether or not we skip certain collections. For
* example, we normally skip collections with display off or the
* inbox. If we explicitly selct thos e items however, we want to
* see them.
*
* @param expr the expression
* @param explicitSelection true if we are explicitly selecting a
* path or paths
* @param source Where the expression came from - for errors
* @return ParseResult
*/
public ParseResult parse(final String expr, final boolean explicitSelection, final String source) {
this.explicitSelection = explicitSelection;
this.source = source;
parseResult.ok = true;
try {
if (debug) {
debug("About to parse filter expression: " + expr + " from " + source);
}
currentExpr = expr;
tokenizer = new SfpTokenizer(new StringReader(expr));
doExpr();
if (topLOp()) {
pop();
}
if (!stackEmpty()) {
throw parseResult.fail("Filter syntax: " + "source: " + source);
}
if (filterStack.size() != 1) {
throw parseResult.fail("Filter syntax: " + " source: " + source);
}
final FilterBase f = popFilters();
if (debug) {
debug(f.toString());
}
parseResult.SetFilter(f);
} catch (final ParseFailed ignored) {
// Result set
}
return parseResult;
}
use of org.bedework.caldav.util.filter.FilterBase in project bw-calendar-engine by Bedework.
the class FilterBuilder method makeColFilter.
/* Create a filter for the supplied collection object.
*
* explicitSelection is true if we have a single path and it refers directly
* to the given collection, e.g. /user/xxx/Inbox
*
* This allows us to see the contents of the inbox for example, but not to
* include it when given paths like /user/xxx
*
* pathElement is used to detect loops in the actual path. We fail with an
* exception if we discover a repeated URI in the list.
*/
private CalFilter makeColFilter(final BwCalendar cal, final boolean applyFilter, final boolean explicitSelection, final ArrayList<String> pathElements) throws CalFacadeException {
/* Result of parsing any filter attached to this entity. */
FilterBase fltr = null;
if (applyFilter && (cal.getFilterExpr() != null)) {
fltr = parseExpr(cal);
}
if (cal.getCalType() == BwCalendar.calTypeEventList) {
OrCalFilter ocf = new OrCalFilter();
for (EventListEntry ele : cal.getEventList()) {
HrefFilter hf = new HrefFilter();
hf.href = ele.getHref();
ocf.terms.add(hf);
}
return ocf;
}
/* This covers most - calendar collection, inbox, outbox, external alias etc */
if (cal.getCollectionInfo().onlyCalEntities) {
// Leaf node
if (!explicitSelection && (cal.getCalType() != BwCalendar.calTypeCalendarCollection) && (cal.getCalType() != BwCalendar.calTypeExtSub)) {
return null;
}
EntityCalFilter ecalFilter = new EntityCalFilter();
ecalFilter.cal = cal;
ecalFilter.filter = fltr;
// filterCache.put(calPath, ecalFilter);
return ecalFilter;
}
if (cal.getInternalAlias()) {
BwCalendar target = parser.resolveAlias(cal, false);
if (target == null) {
return null;
}
String path = target.getPath();
if (pathElements.contains(path)) {
throw new CalFacadeSubscriptionLoopException();
}
pathElements.add(path);
return anded(fltr, makeColFilter(target, true, false, pathElements));
}
if (cal.getCalType() == BwCalendar.calTypeFolder) {
return anded(fltr, makeFolderFilter(cal, pathElements));
}
return null;
}
use of org.bedework.caldav.util.filter.FilterBase in project bw-calendar-engine by Bedework.
the class FilterBuilder method dumpChildren.
private void dumpChildren(final Iterator<FilterBase> it, final String curLine) {
if (!it.hasNext()) {
return;
}
FilterBase f = it.next();
if (it.hasNext()) {
dumpChildren(it, curLine + " | ");
}
dump(f, curLine);
}
Aggregations