Package org.bedework.calfacade.filter
Class SimpleFilterParser
java.lang.Object
org.bedework.calfacade.filter.SimpleFilterParser
- All Implemented Interfaces:
org.bedework.util.logging.Logged
This is a simple filter parser to allow us to embed filter expressions in the
request stream. This is not implemented the correct way - we need a grammar
and allow for some greater complexity, however...
The expressions have very few token types, "(", ")", "&", "|", "=", "!=", ", ", "<", ">", word, number and string value.
The word specifies a property.
For example
entity_type="event" & owner="abcd" & (category="lecture" | category="music")
The entity_type term must be first.
This class is serially reusable but NOT thread-safe
- Author:
- Mike Douglass
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Collection<BwCalendar>decomposeVirtualPath(String vpath) A virtual path might be for example "/user/adgrp_Eng/Lectures/Lectures" which has two two components "/user/adgrp_Eng/Lectures" and "Lectures"abstract BwCategorygetCategoryByName(String name) An unsatisfactory approach - we'll special case categories for the moment to see if this works.abstract org.bedework.util.misc.response.GetEntityResponse<BwCategory>getCategoryByUid(String uid) A slightly better approach - we'll special case categories for the moment to see if this works.abstract Collection<BwCalendar>getChildren(BwCalendar col) Returns children of the given collection to which the current user has some access.abstract BwCalendargetCollection(String path) org.bedework.util.logging.BwLoggerabstract SimpleFilterParserabstract BwViewGet the view given the path.Parse the given expression into a filter.Parse a comma list of sort terms.abstract BwCalendarresolveAlias(BwCalendar val, boolean resolveSubAlias) Attempt to get collection referenced by the alias.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, trace, warn
-
Constructor Details
-
SimpleFilterParser
public SimpleFilterParser()
-
-
Method Details
-
getCollection
- Parameters:
path- of collection- Returns:
- collection object or null.
- Throws:
CalFacadeException- on error
-
resolveAlias
public abstract BwCalendar resolveAlias(BwCalendar val, boolean resolveSubAlias) throws CalFacadeException Attempt to get collection referenced by the alias. For an internal alias the result will also be set in the aliasTarget property of the parameter.- Parameters:
val- collectionresolveSubAlias- - if true and the alias points to an alias, resolve down to a non-alias.- Returns:
- BwCalendar
- Throws:
CalFacadeException- on error
-
getChildren
Returns children of the given collection to which the current user has some access.- Parameters:
col- parent collection- Returns:
- Collection of BwCalendar
- Throws:
CalFacadeException- on error
-
getCategoryByName
An unsatisfactory approach - we'll special case categories for the moment to see if this works. When using these filters we need to search for a category being a member of the set of categories for the event.This only works if the current user is the owner of the named category - at least with my current implementation.
- Parameters:
name- of category- Returns:
- category entity or null.
- Throws:
CalFacadeException- on error
-
getCategoryByUid
public abstract org.bedework.util.misc.response.GetEntityResponse<BwCategory> getCategoryByUid(String uid) A slightly better approach - we'll special case categories for the moment to see if this works. When using these filters we need to search for a category being a member of the set of categories for the event.method takes the uid of the category and is used by the
catuid=(uid1,uid2,uid3)
construct where the list members must ALL be present.- Parameters:
uid- of the category- Returns:
- status and possible category entity.
-
getView
Get the view given the path.- Parameters:
path- for view- Returns:
- view or null
- Throws:
CalFacadeException- on error
-
decomposeVirtualPath
A virtual path might be for example "/user/adgrp_Eng/Lectures/Lectures" which has two two components- "/user/adgrp_Eng/Lectures" and
- "Lectures"
"/user/adgrp_Eng/Lectures" is a real path which is an alias to "/public/aliases/Lectures" which is a folder containing the alias "/public/aliases/Lectures/Lectures" which is aliased to the single calendar.
- Parameters:
vpath- the virtual path- Returns:
- collection of collection objects - null for bad vpath
- Throws:
CalFacadeException- on error
-
getParser
- Returns:
- a parser so we can parse out sub-filters
-
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.- Parameters:
expr- the expressionexplicitSelection- true if we are explicitly selecting a path or pathssource- Where the expression came from - for errors- Returns:
- ParseResult
-
parseSort
Parse a comma list of sort terms. Each term is a property name optionally followed by ":" then the terms "ASC" or "DESC". The default is descending.The property name is either a valid bedework property or the word "RELEVANCE" - which is the default
- Parameters:
sexpr- - search expression- Returns:
- list of terms in order of application. Empty for no sort terms.
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-