filters
Package¶
chain
¶
The following are the categories that will be available for filters in the UI. In case of adding a new category, the first input ‘model.DataType.subject’ is the field from the model that will be used , display represents the way this field will be visible in the UI to the user, operations mark all the possible operations that can be done on that field (so far supported are: “==”, “!=”, “<”, “>”, “in”, “not in”). Type represents the type of input that is expected. So far string, date and list are supported.
In order to define a default filter, from the adapter interface add:
'conditions': FilterChain(fields= [FilterChain.datatype + ".subject", FilterChain.datatype + ".some_attribute",
values= [["John Doe", "JohnDoe1"], "Some Attr Value"], operations= ["in", "=="])
- class tvb.core.entities.filters.chain.FilterChain(display_name='', fields=None, values=None, operations=None, operator_between_fields='and')[source]¶
Bases:
object
Class used to filter tables displayed in UI, based on few criteria. Initialize filter with a list of fields, and corresponding values.
- algorithm = '$$ALGORITHM_INPUT$$'¶
- algorithm_category = '$$ALGORITHM_CATEGORY_INPUT$$'¶
- algorithm_category_replacement = 'AlgorithmCategory'¶
- algorithm_replacement = 'Algorithm'¶
- datatype = '$$DATATYPE_INPUT$$'¶
- datatype_replacement = 'DataType'¶
- get_python_filter_equivalent(datatype_to_check=None)[source]¶
Python evaluate of the filter against a current given DataType Check a filter instance next to a given input.
- Parameters:
datatype_to_check – the dataType to be checked against this filter instance
- Returns:
true if input passed false if input failed
- get_sql_filter_equivalent(datatype_to_check='DataType', operation_to_check='Operation', algorithm_to_check='Algorithm', algocategory_to_check='AlgorithmCategory')[source]¶
Returns the computed SQL string from the given filter. The method may return None if the filter is None or the fields of the filter are not set.
The input to this method should be a string representing the name under which the variable you want to be filtered was binded in the callers namespace. e.g.
- def foo(var_to_filter, filter_entity):
filter_entity.get_sql_filter_equivalent(‘var_to_filter’)
- operation = '$$OPERATION_INPUT$$'¶
- operation_replacement = 'Operation'¶
exceptions
¶
- exception tvb.core.entities.filters.exceptions.InvalidFilterChainInput(message)[source]¶
Bases:
TVBException
Exception raised if a input that does not match the declared filter is passed as input.
- exception tvb.core.entities.filters.exceptions.InvalidFilterEntity(message)[source]¶
Bases:
TVBException
Exception raised if a filter entity has contradicting values for operations and values. for example: in None, not in 1
factory
¶
- class tvb.core.entities.filters.factory.StaticFiltersFactory[source]¶
Bases:
object
Factory class to build lists with static used filters through the application.
- FULL_VIEW = 'Full view'¶
- RELEVANT_VIEW = 'Relevant view'¶