Class SimpleFilterParser

java.lang.Object
org.bedework.calfacade.filter.SimpleFilterParser
All Implemented Interfaces:
org.bedework.util.logging.Logged

public abstract class SimpleFilterParser extends Object implements 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
  • Constructor Details

    • SimpleFilterParser

      public SimpleFilterParser()
  • Method Details

    • getCollection

      public abstract BwCalendar getCollection(String path) throws CalFacadeException
      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 - collection
      resolveSubAlias - - if true and the alias points to an alias, resolve down to a non-alias.
      Returns:
      BwCalendar
      Throws:
      CalFacadeException - on error
    • getChildren

      public abstract Collection<BwCalendar> getChildren(BwCalendar col) throws CalFacadeException
      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

      public abstract BwCategory getCategoryByName(String name) throws CalFacadeException
      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

      public abstract BwView getView(String path) throws CalFacadeException
      Get the view given the path.
      Parameters:
      path - for view
      Returns:
      view or null
      Throws:
      CalFacadeException - on error
    • decomposeVirtualPath

      public abstract Collection<BwCalendar> decomposeVirtualPath(String vpath) throws CalFacadeException
      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

      public abstract SimpleFilterParser getParser()
      Returns:
      a parser so we can parse out sub-filters
    • parse

      public SimpleFilterParser.ParseResult parse(String expr, boolean explicitSelection, String source)
      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 expression
      explicitSelection - true if we are explicitly selecting a path or paths
      source - Where the expression came from - for errors
      Returns:
      ParseResult
    • parseSort

      public SimpleFilterParser.ParseResult parseSort(String sexpr)
      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:
      getLogger in interface org.bedework.util.logging.Logged