def METHOD_NAME(self, endpoint):
    query = self._get_base_query()
    for report_filter_context in endpoint.report_context.get('reportFilters'):
        report_filter = self.get_report_filter(report_filter_context)
        query = report_filter.get_filtered_query(query)
    expressions = []
    for column_context in endpoint.report_context.get('columns', []):
        if column_context.get('sort'):
            descending = column_context['sort'] == 'desc'
            prop_name = column_context['name']
            try:
                special_property = SPECIAL_CASE_PROPERTIES_MAP[prop_name]
                query = query.sort(special_property.sort_property,
                                   desc=descending)
            except KeyError:
                query = query.sort_by_case_property(prop_name,
                                                    desc=descending)
        expression_builder = ColumnXpathExpressionBuilder(
            self.request,
            self.domain,
            column_context,
            self.column_filters
        )
        expression = expression_builder.get_expression()
        if expression:
            expressions.append(expression)
    if expressions:
        xpath_final = " and ".join(expressions)
        query = query.xpath_query(self.domain, xpath_final)
    # apply location restriction
    if not self.request.can_access_all_locations:
        query = query_location_restricted_cases(
            query,
            self.request.domain,
            self.request.couch_user,
        )
    return endpoint.get_response(query, CaseDataFormatter)