Changeset 1094 for trunk/grails-app/controllers/RestController.groovy
- Timestamp:
- Nov 7, 2010, 10:08:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r1053 r1094 33 33 def beforeInterceptor = [action:this.&auth,except:["isUser"]] 34 34 def credentials 35 def requestUser // = SecUser.findByUsername( "user" )35 def requestUser 36 36 37 37 /** … … 42 42 * @param consumer consumer name of the calling module 43 43 * @param token token for the authenticated user (e.g. session_id) 44 * @return true if the user is remotely logged in, false otherwise44 * @return true if the user is remotely logged in, false otherwise 45 45 */ 46 46 private def auth() { … … 144 144 studies.each { study -> 145 145 if(study) { 146 def user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) 146 147 // Check whether the person is allowed to read the data of this study 147 148 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { … … 257 258 if(study) { 258 259 // Check whether the person is allowed to read the data of this study 260 /* 259 261 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 260 262 response.sendError(401) 261 263 return false 262 264 } 265 */ 263 266 264 267 def assays = [] … … 326 329 * @return 'event' (the name of the template of the SamplingEvent describing the sampling) 327 330 * @return 'startTime' (the time the sample was taken relative to the start of the study, as a string) 331 * @return additional template fields are returned 328 332 * 329 333 * … … 370 374 def assay = Assay.find( "from Assay as a where externalAssayID=?",[params.assayToken]) 371 375 if( assay ) { 372 if( params.sampleToken ) { 376 def samples = assay.getSamples() // on all samples 377 378 if( params.sampleToken ) { // or on a subset of samples? 373 379 def sampleTokens = (params.sampleToken instanceof String) ? 374 380 [params.sampleToken] : params.sampleToken 375 assay.getSamples().each { sample -> 376 if( sampleTokens.find{ it == sample.name } ) { 377 def item = [ 378 'sampleToken' : sample.name, 379 'material' : sample.material?.name, 380 'subject' : sample.parentSubject?.name, 381 'event' : sample.parentEvent?.template?.name, 382 'startTime' : sample.parentEvent?.getStartTimeString() 383 ] 384 items.push item 381 samples = [] 382 sampleTokens.each{ sampleToken -> 383 assay.getSamples().find{ sample -> sampleToken == sample.name } 384 } 385 } 386 387 samples.each { sample -> 388 389 def item = [ 390 'material' : sample.material?.name, 391 'subject' : sample.parentSubject?.name, 392 'event' : sample.parentEvent?.template?.name, 393 'startTime' : sample.parentEvent?.getStartTimeString() 394 ] 395 396 sample.giveFields().each { field -> 397 def name = field.name 398 def value = sample.getFieldValue( name ) 399 if(name!='material') 400 { 401 item[name]=value 385 402 } 386 403 } 387 } 388 else { 389 assay.getSamples().each { sample -> 390 def item = [ 391 'sampleToken' : sample.name, 392 'material' : sample.material?.name, 393 'subject' : sample.parentSubject?.name, 394 'event' : sample.parentEvent?.template?.name, 395 'startTime' : sample.parentEvent?.getStartTimeString() 396 ] 397 items.push item 398 } 404 items.push item 399 405 } 400 406 } … … 402 408 render items as JSON 403 409 } 410 411 412 413 414 404 415 405 416 … … 433 444 } 434 445 } 446 447 448 449 450 451 435 452 }
Note: See TracChangeset
for help on using the changeset viewer.