# Path: ac_mediator/exceptions.py
# class ACFieldTranslateException(ACException):
#     pass
# 
# class ACException(Exception):
#     msg = None
#     status = None
# 
#     def __init__(self, msg=None, status=None):
# 
#         # Set defaults (if not set in subclass)
#         if self.msg is None:
#             self.msg = ""
#         if self.status is None:
#             self.msg = -1
# 
#         # Override with arguments (if any)
#         if msg is not None:
#             self.msg = msg
#         if status is not None:
#             self.status = status
# 
#     def __repr__(self):
#         return self.msg
# 
# class ACFilterParsingException(ACException):
#     pass
# 
# Path: services/acservice/utils.py
# def parse_filter(filter_string):
#     """
#     Parse a filter string using the 'filterExpr' grammar defined above.
#     This function returns a pyparsing.ParseResults object that should be further
#     processed with the build_filter_string method of a ACServiceTextSearchMixin instance.
#     """
#     return filterExpr.parseString(filter_string, parseAll=True)


from ac_mediator.exceptions import ACFieldTranslateException, ACException, ACFilterParsingException
from services.acservice.constants import *
from services.acservice.utils import parse_filter
import pyparsing
        self.implemented_components.append(SEARCH_TEXT_COMPONENT)
        self.translate_filter_methods_registry = dict()
        for method_name in dir(self):
            method = getattr(self, method_name)
            if hasattr(method, '_translates_filter_for_field_name'):
                self.translate_filter_methods_registry[method._translates_filter_for_field_name] = method

    def describe_textsearch(self):
        """
        Returns structured representation of component capabilities
        :return: tuple with (component name, dictionary with component capabilities)
        """
        return SEARCH_TEXT_COMPONENT, {
            SUPPORTED_FIELDS_DESCRIPTION_KEYWORD: self.get_supported_fields(),
            SUPPORTED_FILTERS_DESCRIPTION_KEYWORD: self.get_supported_filters(),
            SUPPORTED_SORT_OPTIONS_DESCRIPTION_KEYWORD: self.get_supported_sorting_criteria(),
        }

    def get_supported_sorting_criteria(self):
        """
        Checks which AudioCommons sorting criteria are supported by the third party service.
        These are the fields that raise an exception when calling 'process_s_query_parameter' with
        'raise_exception_if_unsupported' set to True.
        :return: list of available AudioCommons sorting criteria
        """
        supported_criteria = list()
        for option in SORT_OPTIONS:
            try:
                self.process_s_query_parameter(option, desc=True, raise_exception_if_unsupported=True)
                supported_criteria.append('-{0}'.format(option))

# Path: ac_mediator/exceptions.py
# class ACFieldTranslateException(ACException):
#     pass
# 
# class ACException(Exception):
#     msg = None
#     status = None
# 
#     def __init__(self, msg=None, status=None):
# 
#         # Set defaults (if not set in subclass)
#         if self.msg is None:
#             self.msg = ""
#         if self.status is None:
#             self.msg = -1
# 
#         # Override with arguments (if any)
#         if msg is not None:
#             self.msg = msg
#         if status is not None:
#             self.status = status
# 
#     def __repr__(self):
#         return self.msg
# 
# class ACFilterParsingException(ACException):
#     pass
# 
# Path: services/acservice/utils.py
# def parse_filter(filter_string):
#     """
#     Parse a filter string using the 'filterExpr' grammar defined above.
#     This function returns a pyparsing.ParseResults object that should be further
#     processed with the build_filter_string method of a ACServiceTextSearchMixin instance.
#     """
#     return filterExpr.parseString(filter_string, parseAll=True)


# Path: services/acservice/search.py
from ac_mediator.exceptions import ACFieldTranslateException, ACException, ACFilterParsingException
from services.acservice.constants import *
from services.acservice.utils import parse_filter
import pyparsing

        self.implemented_components.append(SEARCH_TEXT_COMPONENT)
        self.translate_filter_methods_registry = dict()
        for method_name in dir(self):
            method = getattr(self, method_name)
            if hasattr(method, '_translates_filter_for_field_name'):
                self.translate_filter_methods_registry[method._translates_filter_for_field_name] = method

    def describe_textsearch(self):
        """
        Returns structured representation of component capabilities
        :return: tuple with (component name, dictionary with component capabilities)
        """
        return SEARCH_TEXT_COMPONENT, {
            SUPPORTED_FIELDS_DESCRIPTION_KEYWORD: self.get_supported_fields(),
            SUPPORTED_FILTERS_DESCRIPTION_KEYWORD: self.get_supported_filters(),
            SUPPORTED_SORT_OPTIONS_DESCRIPTION_KEYWORD: self.get_supported_sorting_criteria(),
        }

    def get_supported_sorting_criteria(self):
        """
        Checks which AudioCommons sorting criteria are supported by the third party service.
        These are the fields that raise an exception when calling 'process_s_query_parameter' with
        'raise_exception_if_unsupported' set to True.
        :return: list of available AudioCommons sorting criteria
        """
        supported_criteria = list()
        for option in SORT_OPTIONS:
            try:
                self.process_s_query_parameter(option, desc=True, raise_exception_if_unsupported=True)
                supported_criteria.append('-{0}'.format(option))

            except ACException: