diff --git a/grails-app/controllers/au/org/ala/alerts/AdminController.groovy b/grails-app/controllers/au/org/ala/alerts/AdminController.groovy index 6c37901c..6bdc0ce7 100644 --- a/grails-app/controllers/au/org/ala/alerts/AdminController.groovy +++ b/grails-app/controllers/au/org/ala/alerts/AdminController.groovy @@ -85,7 +85,7 @@ class AdminController { @Transactional def fixupBiocacheQueries() { def toUpdate = [] - Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc').each { + Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=first_loaded_date&dir=desc').each { it.queryPathForUI = it.queryPath.substring(3) toUpdate << it } @@ -93,7 +93,7 @@ class AdminController { toUpdate.clear() - Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=user_assertions:*&fq=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc').each { + Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=user_assertions:*&fq=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=last_assertion_date&dir=desc').each { it.queryPathForUI = it.queryPath.substring(3) toUpdate << it } @@ -101,7 +101,7 @@ class AdminController { toUpdate.clear() - Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc').each { + Query.findAllByQueryPathForUI('/occurrences/search?q=*:*&fq=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=last_assertion_date&dir=desc').each { it.queryPathForUI = it.queryPath.substring(3) toUpdate << it } diff --git a/grails-app/init/au/org/ala/alerts/BootStrap.groovy b/grails-app/init/au/org/ala/alerts/BootStrap.groovy index b24f0be9..b6ce6c97 100644 --- a/grails-app/init/au/org/ala/alerts/BootStrap.groovy +++ b/grails-app/init/au/org/ala/alerts/BootStrap.groovy @@ -63,8 +63,8 @@ class BootStrap { name: title, updateMessage: 'annotations.update.message', description: descr, - queryPath: '/occurrences/search?fq=user_assertions:*&q=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?fq=user_assertions:*&q=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc', + queryPath: '/occurrences/search?fq=user_assertions:*&q=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?fq=user_assertions:*&q=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=last_assertion_date&dir=desc', dateFormat: """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate: '/email/annotations', recordJsonPath: '\$.occurrences[*]', @@ -84,8 +84,8 @@ class BootStrap { resourceName: grailsApplication.config.mail.details.defaultResourceName, updateMessage: 'more.records.update.message', description: descr, - queryPath: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=first_loaded_date&dir=desc', dateFormat: """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate: '/email/biocache', recordJsonPath: '\$.occurrences[*]', @@ -105,8 +105,8 @@ class BootStrap { resourceName: grailsApplication.config.mail.details.defaultResourceName, updateMessage: 'more.images.update.message', description: descr, - queryPath: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&fq=multimedia:Image&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&fq=multimedia:Image', + queryPath: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=first_loaded_date&dir=desc&fq=multimedia:Image&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=first_loaded_date&dir=desc&fq=multimedia:Image', dateFormat: """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate: '/email/biocache', fireWhenNotZero: true, @@ -128,8 +128,8 @@ class BootStrap { resourceName: grailsApplication.config.mail.details.defaultResourceName, updateMessage: 'more.cs.update.message', description: descr, - queryPath: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc', + queryPath: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc', dateFormat: """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate: '/email/biocache', fireWhenNotZero: true, @@ -151,8 +151,8 @@ class BootStrap { resourceName: grailsApplication.config.mail.details.defaultResourceName, updateMessage: 'more.cs.images.update.message', description: descr, - queryPath: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record&fq=multimedia:Image', - queryPathForUI: '/occurrences/search?q=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&fq=multimedia:Image', + queryPath: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record&fq=multimedia:Image', + queryPathForUI: '/occurrences/search?q=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&fq=data_resource_uid:dr364&sort=first_loaded_date&dir=desc&fq=multimedia:Image', dateFormat: """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate: '/email/biocache', recordJsonPath: '\$.occurrences[*]', diff --git a/grails-app/services/au/org/ala/alerts/QueryService.groovy b/grails-app/services/au/org/ala/alerts/QueryService.groovy index 14798388..375c76fd 100644 --- a/grails-app/services/au/org/ala/alerts/QueryService.groovy +++ b/grails-app/services/au/org/ala/alerts/QueryService.groovy @@ -196,8 +196,8 @@ class QueryService { name : messageSource.getMessage("query.service.occurrences.name", [queryDisplayName] as Object[], siteLocale), updateMessage : messageSource.getMessage("query.service.occurrences.update.msg", [queryDisplayName] as Object[], siteLocale), description : messageSource.getMessage("query.service.occurrences.desc", [queryDisplayName] as Object[], siteLocale), - queryPath : biocacheWebserviceQueryPath + '&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: biocacheUIQueryPath + '&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath : biocacheWebserviceQueryPath + '&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: biocacheUIQueryPath + '&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -215,8 +215,8 @@ class QueryService { name : messageSource.getMessage("query.service.annotations.name", [queryDisplayName] as Object[], siteLocale), updateMessage : messageSource.getMessage("query.service.annotations.update.msg", [queryDisplayName] as Object[], siteLocale), description : messageSource.getMessage("query.service.annotations.desc", [queryDisplayName] as Object[], siteLocale), - queryPath : biocacheWebserviceQueryPath + '&fq=(user_assertions:50005%20OR%20user_assertions:50003%20OR%20user_assertions:50002)&fq=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: biocacheUIQueryPath + '&fq=(user_assertions:50005%20OR%20user_assertions:50003%20OR%20user_assertions:50002)&fq=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc', + queryPath : biocacheWebserviceQueryPath + '&fq=(user_assertions:50005%20OR%20user_assertions:50003%20OR%20user_assertions:50002)&fq=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: biocacheUIQueryPath + '&fq=(user_assertions:50005%20OR%20user_assertions:50003%20OR%20user_assertions:50002)&fq=last_assertion_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+last_assertion_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -252,8 +252,8 @@ class QueryService { resourceName : grailsApplication.config.mail.details.defaultResourceName, updateMessage : messageSource.getMessage("query.service.occurrences.update.msg", [taxonName] as Object[], siteLocale), description : messageSource.getMessage("query.service.occurrences.desc", [taxonName] as Object[], siteLocale), - queryPath : '/occurrences/taxon/' + taxonGuid + '?fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/taxa/' + taxonGuid + '?fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath : '/occurrences/taxon/' + taxonGuid + '?fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/taxa/' + taxonGuid + '?fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -270,8 +270,8 @@ class QueryService { resourceName : grailsApplication.config.mail.details.defaultResourceName, updateMessage : messageSource.getMessage("query.service.occurrences.recorded.update.msg", [taxonName, regionName] as Object[], siteLocale), description : messageSource.getMessage("query.service.occurrences.recorded.desc", [taxonName, regionName] as Object[], siteLocale), - queryPath : '/occurrences/taxon/' + taxonGuid + '?fq=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/taxa/' + taxonGuid + '?fq=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath : '/occurrences/taxon/' + taxonGuid + '?fq=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/taxa/' + taxonGuid + '?fq=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -288,8 +288,8 @@ class QueryService { resourceName : grailsApplication.config.mail.details.defaultResourceName, updateMessage : messageSource.getMessage("query.service.occurrences.recorded.update.msg", [speciesGroup, regionName] as Object[], siteLocale), description : messageSource.getMessage("query.service.occurrences.recorded.desc", [speciesGroup, regionName] as Object[], siteLocale), - queryPath : '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=species_group:' + speciesGroup + '&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?q=' + layerId + ':"' + regionName.encodeAsURL() + '"&fq=species_group:' + speciesGroup + '&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath : '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=species_group:' + speciesGroup + '&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?q=' + layerId + ':"' + regionName.encodeAsURL() + '"&fq=species_group:' + speciesGroup + '&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -306,8 +306,8 @@ class QueryService { resourceName : grailsApplication.config.mail.details.defaultResourceName, updateMessage : messageSource.getMessage("query.service.occurrences.update.msg", [regionName] as Object[], siteLocale), description : messageSource.getMessage("query.service.occurrences.desc", [regionName] as Object[], siteLocale), - queryPath : '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', - queryPathForUI: '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc', + queryPath : '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc&pageSize=20&facets=basis_of_record', + queryPathForUI: '/occurrences/search?q=' + layerId + ':%22' + regionName.encodeAsURL() + '%22&fq=first_loaded_date:' + '[___DATEPARAM___ TO *]'.encodeAsURL() + '&sort=+first_loaded_date&dir=desc', dateFormat : """yyyy-MM-dd'T'HH:mm:ss'Z'""", emailTemplate : '/email/biocache', recordJsonPath: '\$.occurrences', @@ -346,9 +346,9 @@ class QueryService { def sList = getSpeciesListName(listid) String speciesListName = sList.name //differentiate non-authoritative / authoritative list - String queryPathForUITemplate = grailsApplication.config.getProperty("biosecurity.query.template.nonAuthoritativeList", String, "/occurrences/search?q=species_list:___LISTIDPARAM___&fq=decade:2020&fq=country:Australia&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=occurrence_date:[___LASTYEARPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&disableAllQualityFilters=true") + String queryPathForUITemplate = grailsApplication.config.getProperty("biosecurity.query.template.nonAuthoritativeList", String, "/occurrences/search?q=species_list:___LISTIDPARAM___&fq=decade:2020&fq=country:Australia&fq=first_loaded_date:" + "[___DATEPARAM___ TO *]".encodeAsURL() + "&fq=occurrence_date:" + "[___LASTYEARPARAM___ TO *]".encodeAsURL() + "&sort=first_loaded_date&dir=desc&disableAllQualityFilters=true") if (sList.isAuthoritative) { - queryPathForUITemplate = grailsApplication.config.getProperty("biosecurity.query.template.authoritativeList", String, "/occurrences/search?q=species_list_uid:___LISTIDPARAM___&fq=decade:2020&fq=country:Australia&fq=first_loaded_date:[___DATEPARAM___%20TO%20*]&fq=occurrence_date:[___LASTYEARPARAM___%20TO%20*]&sort=first_loaded_date&dir=desc&disableAllQualityFilters=true") + queryPathForUITemplate = grailsApplication.config.getProperty("biosecurity.query.template.authoritativeList", String, "/occurrences/search?q=species_list_uid:___LISTIDPARAM___&fq=decade:2020&fq=country:Australia&fq=first_loaded_date:" + "[___DATEPARAM___ TO *]".encodeAsURL() + "&fq=occurrence_date:" + "[___LASTYEARPARAM___ TO *]".encodeAsURL() + "&sort=first_loaded_date&dir=desc&disableAllQualityFilters=true") } String queryPathForUI = queryPathForUITemplate.replaceAll("___LISTIDPARAM___", listid)