# Path: data_catalog/metadata_entry.py
# CERBERUS_SCHEMA = {
#     CATEGORY_FIELD: {'required': True, 'type': 'string'},
#     CREATION_TIME_FIELD: {'required': False, 'type': 'string'},
#     'dataSample': {'required': True, 'type': 'string'},
#     'format': {'required': True, 'type': 'string'},
#     IS_PUBLIC_FIELD: {'required': True, 'type': 'boolean'},
#     ORG_UUID_FIELD: {'required': True, 'type': 'string'},
#     'recordCount': {'required': True, 'type': 'integer'},
#     'size': {'required': True, 'type': 'integer'},
#     'sourceUri': {'required': True, 'type': 'string'},
#     TARGET_URI_FIELD: {'required': True, 'type': 'string'},
#     TITLE_FIELD: {'required': True, 'type': 'string'}}
# 
# ORG_UUID_FIELD = 'orgUUID'
# 
# CREATION_TIME_FIELD = 'creationTime'
# 
# IS_PUBLIC_FIELD = 'isPublic'


import json
import logging
from data_catalog.metadata_entry import (CERBERUS_SCHEMA, ORG_UUID_FIELD, CREATION_TIME_FIELD,
                                         IS_PUBLIC_FIELD)
        to an ElasticSearch filter.
        """

        def create_normal_filter(values):
            values = [str(value).lower() for value in values]
            if len(values) == 1:
                return {'term': {filter_type: values[0]}}
            else:
                return {'terms': {filter_type: values}}

        def create_time_filter(values):
            time_range = {}
            if len(values) != 2:
                self._log_and_raise_invalid_query('There should be exactly two time range values.')

            if values[0] != -1:
                time_range['from'] = values[0]
            if values[1] != -1:
                time_range['to'] = values[1]
            return {
                'range': {
                    CREATION_TIME_FIELD: time_range
                }
            }

        if not filter_values:
            return None
        elif not isinstance(filter_values, list):
            self._log_and_raise_invalid_query("Filter values aren't a list.")


# Path: data_catalog/metadata_entry.py
# CERBERUS_SCHEMA = {
#     CATEGORY_FIELD: {'required': True, 'type': 'string'},
#     CREATION_TIME_FIELD: {'required': False, 'type': 'string'},
#     'dataSample': {'required': True, 'type': 'string'},
#     'format': {'required': True, 'type': 'string'},
#     IS_PUBLIC_FIELD: {'required': True, 'type': 'boolean'},
#     ORG_UUID_FIELD: {'required': True, 'type': 'string'},
#     'recordCount': {'required': True, 'type': 'integer'},
#     'size': {'required': True, 'type': 'integer'},
#     'sourceUri': {'required': True, 'type': 'string'},
#     TARGET_URI_FIELD: {'required': True, 'type': 'string'},
#     TITLE_FIELD: {'required': True, 'type': 'string'}}
# 
# ORG_UUID_FIELD = 'orgUUID'
# 
# CREATION_TIME_FIELD = 'creationTime'
# 
# IS_PUBLIC_FIELD = 'isPublic'


# Path: data_catalog/query_translation.py
import json
import logging
from data_catalog.metadata_entry import (CERBERUS_SCHEMA, ORG_UUID_FIELD, CREATION_TIME_FIELD,
                                         IS_PUBLIC_FIELD)

        to an ElasticSearch filter.
        """

        def create_normal_filter(values):
            values = [str(value).lower() for value in values]
            if len(values) == 1:
                return {'term': {filter_type: values[0]}}
            else:
                return {'terms': {filter_type: values}}

        def create_time_filter(values):
            time_range = {}
            if len(values) != 2:
                self._log_and_raise_invalid_query('There should be exactly two time range values.')

            if values[0] != -1:
                time_range['from'] = values[0]
            if values[1] != -1:
                time_range['to'] = values[1]
            return {
                'range': {
                    CREATION_TIME_FIELD: time_range
                }
            }

        if not filter_values:
            return None
        elif not isinstance(filter_values, list):
            self._log_and_raise_invalid_query("Filter values aren't a list.")


        if filter_type != CREATION_TIME_FIELD: