Changeset 1196 for trunk/grails-app


Ignore:
Timestamp:
Nov 24, 2010, 11:47:41 AM (11 years ago)
Author:
j.saito@…
Message:

Streamlined CommunicationManager? and adjusted it to suit CommunicationManager? in SAM.
Removed horrible debugoutputs from SimpleQueryController?. (Is this used any longer at all??)

Location:
trunk/grails-app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r1195 r1196  
    4949                        CommunicationManager.SAMServerURL = config.modules.sam.url
    5050                        CommunicationManager.DSPServerURL = config.modules.metabolomics.url
    51                         CommunicationManager.registerRestWrapperMethodsSAMtoGSCF()
     51                        CommunicationManager.ServerURL = config.grails.serverURL
     52                        CommunicationManager.registerRestWrapperMethodsFromSAM()
    5253                }
    5354
  • trunk/grails-app/controllers/dbnp/query/SimpleQueryController.groovy

    r959 r1196  
    3535        // Starting simpleQuery flow, initialize variables
    3636        onStart {
    37             println "Starting webflow simpleQuery"
    3837            flow.search_term            = null
    3938            flow.search_sa_compounds    = []
     
    5150                        render(view: "/simpleQuery/mainPage")
    5251
     52
    5353            onRender {
    54               println "Rendering mainPage"
    5554              flow.operators              = ['>', '=', '<']
    5655
    5756              if (!flow.search_sa_compounds) {
    5857                flow.showFirstRowCompounds  = true
    59                 println "showRow true"
    6058              } else {
    6159                flow.showFirstRowCompounds  = false
    62                 println "showRow false"
    6360              }
    6461
     
    6865
    6966            on("search") {
    70               println "Search!"
    7167              if (!params.search_term.trim()) {
    7268                return [:]
     
    8177        searching {
    8278           action {
    83               println "Starting simpleQuery search..."
    8479              def searchResult
    8580              def searchGscfResult
    8681              def searchSamResult   = []
    8782
    88               // TODO: walk parameters, remove empty entries
    89 
    9083              // Map GSCF parameters
    9184              flow.search_term            = params.search_term        // String
     
    9386              // Map SAM parameters
    9487              if (params.sa_compound instanceof String) {
    95                 println "Compounds as String"
    96                 //flow.search_sam = [:]
    9788                flow.search_sa_compounds = []
    9889                flow.search_sa_operators = []
     
    10596                }
    10697              } else {
    107                 println "Compounds as List"
    10898                flow.search_sa_compounds  = params.sa_compound as List
    10999                flow.search_sa_operators  = params.sa_operator as List
     
    114104              try {
    115105                searchGscfResult = searchableService.search(flow.search_term)
    116                 println "RESULT: " + searchGscfResult
    117106              } catch (SearchEngineQueryParseException ex) {
    118107                println ex
     
    124113
    125114              // Search in the SAM module when a compound is entered
    126               // Todo: check whether the module is active and to be used
    127               // ...
    128115              def listSamStudies = []
    129116              def listGscfStudies = []
     
    133120                def resultSAM = [:]
    134121                resultSAM = this.searchSAM(flow.search_sa_compounds, flow.search_sa_operators, flow.search_sa_values)
    135                 println "Sam result: " + resultSAM
    136122                listSamStudies = resultSAM.get('studies')
    137123              }
    138124
    139125             for (i in searchGscfResult.results) {
    140                //def x = i.id
    141126               def objStudy = Study.get(i.id)
    142                println objStudy
    143127               listGscfStudies.add(objStudy.id)
    144128             }
    145129
    146130
    147              println "GSCF studies: " + listGscfStudies
    148              println "Sam studies " + listSamStudies
    149131                                         
    150132             // Merge the results of all searches
    151133             if (listSamStudies.size() > 0) {
    152134               listStudies = listGscfStudies.intersect(listSamStudies)
    153                println "Combined: " + listStudies
    154135             } else {
    155136               if (!flow.search_sa_compounds) {
     
    168149             // Save the results in the flow
    169150             flow.listStudies = listObjStudies
    170              println flow.listStudies
    171151
    172152           }
     
    182162
    183163            onRender {
    184               println "Rendering resultPage"
    185164              flow.page = 2
    186165
     
    196175              flow.search_tt_genepaths    = null
    197176              flow.search_tt_regulations  = null
    198               println "Resetting query flow"
    199177            }.to "query"
    200178
     
    207185 
    208186   static Map searchSAM (List compounds, List operators, List values) {
     187
     188
    209189     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
    234195
    235196       def listStudies = []
     
    245206
    246207     } 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
    250212       def i = 0
    251 
    252213       compounds.each { compound ->
    253          println "SAM Search with " + compound
    254          CommunicationManager.addRestWrapper( 'http://localhost:8182/sam/rest', 'getQueryResult', ['query'] )
    255214         tmpSamResult = CommunicationManager.getQueryResult(compound)
    256          println "tmpsamres: " + tmpSamResult
    257215
    258216         if (i == 0) {
     
    263221           }
    264222         }
    265 
    266223         i++
    267224       }
Note: See TracChangeset for help on using the changeset viewer.