Guest User

Untitled

a guest
Oct 30th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.66 KB | None | 0 0
  1.     def advancedSearch = {
  2.         def modelSearch = []
  3.         def annotationSearch = []
  4.         def publicationSearch = []
  5.         def personSearch = []
  6.         if (params.containsKey("search-model")) {
  7.             params.each { key, value ->
  8.                 if (key.startsWith("search-model-options-")) {
  9.                     modelSearch << ["${value}": params[key.replace("options", "field")]]
  10.                 }
  11.             }
  12.         }
  13.         if (params.containsKey("search-annotation")) {
  14.             params.each { key, value ->
  15.                 if (key.startsWith("search-annotation-options-")) {
  16.                     annotationSearch << ["${value}": params[key.replace("options", "field")]]
  17.                 }
  18.             }
  19.         }
  20.         if (params.containsKey("search-publication")) {
  21.             params.each { key, value ->
  22.                 if (key.startsWith("search-publication-options-")) {
  23.                     publicationSearch << ["${value}": params[key.replace("options", "field")]]
  24.                 }
  25.             }
  26.         }
  27.         if (params.containsKey("search-person")) {
  28.             params.each { key, value ->
  29.                 if (key.startsWith("search-person-options-")) {
  30.                     personSearch << ["${value}": params[key.replace("options", "field")]]
  31.                 }
  32.             }
  33.         }
  34.  
  35.         def query = [modelSearch: modelSearch, annotationSearch: annotationSearch, publicationSearch: publicationSearch, personSearch: personSearch]
  36.         println query
  37.         def results = modelSearchService.advancedSearch(0, 10, true, ModelListSorting.ID, query)
  38.         println results
  39.         render results as JSON
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment