Changeset 773 for trunk/src


Ignore:
Timestamp:
Aug 4, 2010, 2:59:30 PM (13 years ago)
Author:
jahn
Message:

Added rest method for querying measurement values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/groovy/dbnp/rest/common/CommunicationManager.groovy

    r755 r773  
    5757        def url = RestServerURL + '/' + resource
    5858                def first = true
    59                 println "url: " + url
    6059                params.each { name, value ->
    6160                        if(first) {
     
    193192                //                               ["studies":[NuGO PPS human study],
    194193                //               "samples":[[ [...], dbnp.studycapturing.Sample: 1]]]
    195                 def closure = { map ->
     194                def closure1 = { map ->
    196195                    def studies = []
    197196                    def samples = []
     
    207206                }
    208207
    209                 addRestWrapper( url+'/rest', 'getQueryResult',  ['query'], closure )
     208                addRestWrapper( url+'/rest', 'getQueryResult',  ['query'], closure1 )
     209
     210
     211                // Rest resource: getQueryResultWithOperator
     212                //
     213                // register rest resource that returns the results of a simple query with measurement value on SAM
     214        // parameters:   query. A keyword to match a measurement type on SAM.
     215        //               operator. One of '=','<', or '>' that serves for selecting measurements.
     216        //               value. A double value for the measurement.
     217                //
     218        // return value: results list of maps. each map contains an assay, a sample, the value found,
     219        //               a unit (as String), and a type (as String).
     220                //
     221                // Example of a returned list of maps:
     222                //                               [["type":"Glucose", "unit":"g", "value":"201.0", "assay":Lipid profiling,
     223                //                                 "sample":A10_B], ["type":"Glucose", "unit":"g", "value":"101.0",
     224                //                                 "assay":Lipid profiling, "sample":A1_B], ["type":"Insulin", "unit":"g", "value":"202.0",
     225                //                                 "assay":Lipid profiling, "sample":A10_B], ["type":"Insulin", "unit":"g", "value":"102.0",
     226                //                                 "assay":Lipid profiling, "sample":A1_B]]
     227                //             
     228                def closure2 = { listOfMaps ->
     229                        def results = []
     230                        listOfMaps.each{ map ->
     231                                def result = [ type:map['type'], unit:map['unit'], value:map['value'] ]
     232                                def assayId = map['externalAssayId'].toLong()
     233                                def assay  = dbnp.studycapturing.Assay.find( "from dbnp.studycapturing.Assay as a where a.externalAssayID= ?", [assayId] )
     234                                def sample = dbnp.studycapturing.Sample.find( "from dbnp.studycapturing.Sample as s where s.name = ?", [map['externalSampleId']] )
     235                                result['assay']=assay
     236                                result['sample']=sample
     237                                results.add( result )
     238                        }
     239                        return results
     240                }
     241
     242                addRestWrapper( url+'/rest', 'getQueryResultWithOperator',  ['query','operator','value'], closure2 )
    210243    }
    211244
Note: See TracChangeset for help on using the changeset viewer.