Filter API Methods

The Filter API is used for setting, getting, and removing filters.

This page discusses:

setFilters(List filters)

This method sets filters based on a list of dictionary-like objects.

Arguments
  • filters: An array of dictionary-like objects defining filters.
  • filters schema. For more information, see Filters Schema.
Return Value
Returns a list-like object containing all filters defined on the case.
The structure of the filter dictionaries required by this method is the same as the structure of the filter required by the addFilter() method.

addFilter(Dictionary filter)

This method adds a new filter matching a supplied JSON object.

Arguments
  • filter: A dictionary-like object defining a single filter.
  • filter schema. For more information, see Filter Schema.
Return Value
Returns a list-like object containing all filters defined on the case.
parameterID is the id attribute on the parameter objects used by methods in the Parameter API. The @class value ParametricCondition defines filters on parameters.

removeFilter(Dictionary filter)

This method removes a filter matching a specified parameterID and type.

Arguments
  • filter: A dictionary-like object identifying a filter by its type and the ID of the parameter on which it is defined.
  • filter schema. For more information, see Remove Filters Schema.
Return Value
Returns a list-like object containing all filters currently defined on the case.

getFilters()

This method gets filters for the current case.

Arguments
None.
Return Value
A list-like object containing all filter objects as dictionary-like objects.
This method is included alongside the select method because this is the fundamental method defined on the advise case. The select method is a syntactically sugared version of this.

select(Callable selector)

This method selects all filters matching a given selector.

Arguments
selector: A Python callable object.
Return Value
Returns a list-like Python object containing all values matching the selector.
The selector is passed each row in the data set. The filters are formatted as dictionary-like objects. The following example selects all rows for which the column has the type LESS_THAN:
def lessThanTest(filter):
    return filter["type"] == "LESS_THAN"

ltFilters = FilterAPI.select(lessThanTest)

getIterator()

This method gets the ID of an iterator for iterating over the set of all filters.

Arguments
None.
Return Value
Returns a string used to uniquely identify the newly generated iterator.

hasNext(String iteratorId)

This method verifies if the iterator matching the provided ID has a next element.

Arguments
iteratorId: ID string returned by the getIterator() method
Return Value
Returns true if the iterator has at least one more item.

next(String iteratorId)

This method returns the next item in an iterator, if it has a next item.

Arguments
iteratorId: ID string returned by the getIterator() method.
Return Value
Returns a dictionary-like object containing the next item in the iterator.