Skip to content
Snippets Groups Projects
Commit 65468542 authored by sveseli's avatar sveseli
Browse files

catalog updates for regex search

parent ad44e07c
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ class DatasetMongoDbApi(DmMongoDbApi):
if not useExperimentName:
del datasetDict['experimentName']
self.getLogger().debug('Converting dataset dict to regex patterns')
ignoreCase = kwargs.get(self.IGNORE_CASE_KEY, True)
ignoreCase = kwargs.get(self.REGEX_IGNORE_CASE_KEY, True)
queryDict = self.convertStringsToRegex(datasetDict, ignoreCase)
return self.fileMongoDbApi.getExperimentFiles(experimentName, queryDict, returnFieldDict)
......
......@@ -12,7 +12,8 @@ class DmMongoDbApi:
""" Base Mongo DB API class. """
SYSTEM_KEY_LIST = ['_id']
IGNORE_CASE_KEY = '_ignoreCase'
REGEX_IGNORE_KEY_LIST = ['_id']
REGEX_IGNORE_CASE_KEY = '_ignoreCase'
def __init__(self):
self.logger = LoggingManager.getInstance().getLogger(self.__class__.__name__)
......@@ -80,7 +81,7 @@ class DmMongoDbApi:
def convertStringsToRegex(cls, dict, ignoreCase=True):
dict2 = copy.copy(dict)
for (key,value) in dict2.items():
if key in cls.SYSTEM_KEY_LIST:
if key in cls.REGEX_IGNORE_KEY_LIST:
continue
elif type(value) == types.StringType or type(value) == types.UnicodeType:
cls.getLogger().debug('Converting to regex: %s for key %s' % (value,key))
......
......@@ -28,7 +28,7 @@ class FileMongoDbApi(DmMongoDbApi):
def getFiles(self, queryDict={}, returnFieldDict=FileCollection.ALL_FIELDS_DICT, **kwargs):
queryDict2 = self.getMongoDict(queryDict)
self.getLogger().debug('Converting query dict to regex patterns')
ignoreCase = kwargs.get(self.IGNORE_CASE_KEY, True)
ignoreCase = kwargs.get(self.REGEX_IGNORE_CASE_KEY, True)
queryDict2 = self.convertStringsToRegex(queryDict2, ignoreCase)
return self.listToDmObjects(self.fileCollection.findByQueryDict(queryDict2, returnFieldDict), FileMetadata)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment