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.

add_condition(field_name, operation_string, value)[source]

Append to the list of conditions.

algorithm = '$$ALGORITHM_INPUT$$'
algorithm_category = '$$ALGORITHM_CATEGORY_INPUT$$'
algorithm_category_replacement = 'AlgorithmCategory'
algorithm_replacement = 'Algorithm'
datatype = '$$DATATYPE_INPUT$$'
datatype_replacement = 'DataType'
classmethod from_json(input_dict)[source]

From a JSON dictionary create a filter instance.

classmethod get_filters_for_type(data_name)[source]

Return the list of filters to appear in UI.

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'
to_json()[source]

Return a dictionary representation of the filter, to be used when needed.

class tvb.core.entities.filters.chain.UIFilter(linked_elem_name, linked_elem_field, linked_elem_parent_name=None, linked_elem_parent_option=None)[source]

Bases: object

Helper class for the UI filters.

to_dict()[source]

Prepare for passing in UI

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'
static build_datatype_filters(selected='Relevant view', single_filter=None)[source]

Return all visibility filters for data structure page, or only one filter.

static build_operations_filters(simulation_algorithm, logged_user_id)[source]
Returns:

list of filters that can be applied on Project View Operations page.