Changeset 644 for trunk/src/groovy
- Timestamp:
- Jul 9, 2010, 11:34:14 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/groovy/dbnp/rest/common/CommunicationManager.groovy
r641 r644 26 26 class CommunicationManager { 27 27 28 def static Encoding= "UTF-8"29 def public static SAMServerURL = "localhost:8182/sam"30 def public static GSCFServerURL = " localhost:8080/gscf"28 def static Encoding = "UTF-8" 29 def public static SAMServerURL = "http://localhost:8182/sam" 30 def public static GSCFServerURL = "http://localhost:8080/gscf" 31 31 32 32 … … 57 57 def url = RestServerURL + '/' + resource 58 58 def first = true 59 println "url: " + url 59 60 params.each { name, value -> 60 61 if(first) { … … 105 106 */ 106 107 107 public static addRestWrapper( serverURL, restName, params = [] ) {108 public static addRestWrapper( serverURL, restName, params = [], closure = { return it } ) { 108 109 CommunicationManager.metaClass.registerStaticMethod( restName ) { Object [] strangeGroovyArgs -> 109 110 def map = [:] … … 113 114 map[param] = args[i] 114 115 } 115 return getRestResource( serverURL, restName, map ) 116 } 117 } 116 return closure( getRestResource( serverURL, restName, map ) ) 117 } 118 println "registered + ${restName}" 119 } 120 121 118 122 119 123 … … 163 167 */ 164 168 public static registerRestWrapperMethodsSAMtoGSCF() { 165 def url = SAMServerURL 169 def url = SAMServerURL 166 170 167 171 // register method that links to the SAM view for importing a SimpleAssay. … … 180 184 // parameters: externalAssayID 181 185 addViewWrapper( 'getMeasurementTypesURL', url, 'simpleAssayMeasurementType/list', ['externalStudyID'] ) 186 187 // register rest resource that returns the results of a full text query on SAM 188 // parameters: query. A string for fulltext search on SAM 189 // return value: results map. It contains two keys 'studyIds', and 'assays'. 'studyIds' 190 // key maps to a list of Study domain objects of GSCF. 'assays' map to a 191 // list of pairs. Each pair consists of an Assay domain object of GSCF and 192 // additional assay information from SAM provided as a map. 193 // Example of a returned map: 194 // [studyIds:[PPSH], 195 // assays:[[isIntake:false, isDrug:false, correctionMethod:test Correction Method 1, 196 // detectableLimit:1, isNew:false, class:data.SimpleAssay, externalAssayID:1, id:1, 197 // measurements:null, unit:Insulin, inSerum:false, name:test Simple Assay 1, 198 // referenceValues:test Reference Values 1]]] 199 def closure = { map -> 200 def studies = [] 201 def assays = [] 202 map['studyIds'].each { studies.add( dbnp.studycapturing.Study.find("from dbnp.studycapturing.Study as s where s.code=?",[it]) ) } 203 map['assays'].each { samAssay -> 204 def assayID = samAssay['externalAssayID'] 205 def assay = dbnp.studycapturing.Assay.find("from dbnp.studycapturing.Assay as a where a.externalAssayID='${assayID}'") 206 assays.add( [samAssay,assay] ) 207 } 208 return [studies:studies, assays:assays] 209 } 210 211 addRestWrapper( url+'/rest', 'getQueryResult', ['query'], closure ) 212 182 213 } 183 214
Note: See TracChangeset
for help on using the changeset viewer.