Changeset 1196 for trunk/grails-app/controllers
- Timestamp:
- Nov 24, 2010, 11:47:41 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/query/SimpleQueryController.groovy
r959 r1196 35 35 // Starting simpleQuery flow, initialize variables 36 36 onStart { 37 println "Starting webflow simpleQuery"38 37 flow.search_term = null 39 38 flow.search_sa_compounds = [] … … 51 50 render(view: "/simpleQuery/mainPage") 52 51 52 53 53 onRender { 54 println "Rendering mainPage"55 54 flow.operators = ['>', '=', '<'] 56 55 57 56 if (!flow.search_sa_compounds) { 58 57 flow.showFirstRowCompounds = true 59 println "showRow true"60 58 } else { 61 59 flow.showFirstRowCompounds = false 62 println "showRow false"63 60 } 64 61 … … 68 65 69 66 on("search") { 70 println "Search!"71 67 if (!params.search_term.trim()) { 72 68 return [:] … … 81 77 searching { 82 78 action { 83 println "Starting simpleQuery search..."84 79 def searchResult 85 80 def searchGscfResult 86 81 def searchSamResult = [] 87 82 88 // TODO: walk parameters, remove empty entries89 90 83 // Map GSCF parameters 91 84 flow.search_term = params.search_term // String … … 93 86 // Map SAM parameters 94 87 if (params.sa_compound instanceof String) { 95 println "Compounds as String"96 //flow.search_sam = [:]97 88 flow.search_sa_compounds = [] 98 89 flow.search_sa_operators = [] … … 105 96 } 106 97 } else { 107 println "Compounds as List"108 98 flow.search_sa_compounds = params.sa_compound as List 109 99 flow.search_sa_operators = params.sa_operator as List … … 114 104 try { 115 105 searchGscfResult = searchableService.search(flow.search_term) 116 println "RESULT: " + searchGscfResult117 106 } catch (SearchEngineQueryParseException ex) { 118 107 println ex … … 124 113 125 114 // Search in the SAM module when a compound is entered 126 // Todo: check whether the module is active and to be used127 // ...128 115 def listSamStudies = [] 129 116 def listGscfStudies = [] … … 133 120 def resultSAM = [:] 134 121 resultSAM = this.searchSAM(flow.search_sa_compounds, flow.search_sa_operators, flow.search_sa_values) 135 println "Sam result: " + resultSAM136 122 listSamStudies = resultSAM.get('studies') 137 123 } 138 124 139 125 for (i in searchGscfResult.results) { 140 //def x = i.id141 126 def objStudy = Study.get(i.id) 142 println objStudy143 127 listGscfStudies.add(objStudy.id) 144 128 } 145 129 146 130 147 println "GSCF studies: " + listGscfStudies148 println "Sam studies " + listSamStudies149 131 150 132 // Merge the results of all searches 151 133 if (listSamStudies.size() > 0) { 152 134 listStudies = listGscfStudies.intersect(listSamStudies) 153 println "Combined: " + listStudies154 135 } else { 155 136 if (!flow.search_sa_compounds) { … … 168 149 // Save the results in the flow 169 150 flow.listStudies = listObjStudies 170 println flow.listStudies171 151 172 152 } … … 182 162 183 163 onRender { 184 println "Rendering resultPage"185 164 flow.page = 2 186 165 … … 196 175 flow.search_tt_genepaths = null 197 176 flow.search_tt_regulations = null 198 println "Resetting query flow"199 177 }.to "query" 200 178 … … 207 185 208 186 static Map searchSAM (List compounds, List operators, List values) { 187 188 209 189 if (compounds.size() == 1) { 210 println "Single SAM call" 211 def mapSamResult = [:] 212 213 //def listAssays = [3, 1] 214 //mapSamResult.put("assays", listAssays) 215 //println "CommMngr result: " + mapSamResult 216 217 CommunicationManager.addRestWrapper( 'http://localhost:8182/sam/rest', 'getQueryResult', ['query'] ) 218 mapSamResult = CommunicationManager.getQueryResult( compounds.get(0) ) 219 println "SAM REST query: " + compounds.get(0) 220 println "SAM REST result: " + mapSamResult 221 222 // mapSamResult = CommunicationManager.getQueryResult(compounds.get(0), operators.get(0), values.get(0)) 223 224 //objAssay = objAssay.get(i) 225 //println "Assay: " + objAssay 226 227 /* 228 for (i in mapSamResult.assays) { 229 //def listStudies = Study.findAll("from Study as s where s.assays.id = " + i) 230 def listStudies = Study.findAll("from Study as s where exists (from Assay as a where a.id = s.assays and a.id = ${i})") 231 println "Studies found: " + listStudies 232 } 233 */ 190 def tmpResult = CommunicationManager.getQueryResult( compounds.get(0) ) 191 def studies = tmpResult.studiesIds.collect{ Study.findByCode(it) } 192 def assays = tmpResult.assays.collect { [it, Assay.findByExternalAssayID( it.externalAssayID ) ] } 193 def mapSamResult = [studies:studies, assays:assays] 194 234 195 235 196 def listStudies = [] … … 245 206 246 207 } else { 247 println "Multiple SAM calls" 248 def tmpSamResult = [:] 249 def mapSamResult = [assays:[]] 208 def tmpResult = CommunicationManager.getQueryResult( compounds.get(0) ) 209 def studies = tmpResult.studiesIds.collect{ Study.findByCode(it) } 210 def mapSamResult = [studies:studies, assays:[]] 211 250 212 def i = 0 251 252 213 compounds.each { compound -> 253 println "SAM Search with " + compound254 CommunicationManager.addRestWrapper( 'http://localhost:8182/sam/rest', 'getQueryResult', ['query'] )255 214 tmpSamResult = CommunicationManager.getQueryResult(compound) 256 println "tmpsamres: " + tmpSamResult257 215 258 216 if (i == 0) { … … 263 221 } 264 222 } 265 266 223 i++ 267 224 }
Note: See TracChangeset
for help on using the changeset viewer.