Changeset 600 for trunk/grails-app/controllers/RestController.groovy
- Timestamp:
- Jun 23, 2010, 10:25:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r560 r600 40 40 */ 41 41 def getStudies = { 42 42 List studies = [] 43 43 Study.list().each { study -> 44 45 46 44 studies.push( [ 'externalStudyID': study.code, 'name':study.title ] ) 45 } 46 render studies as JSON 47 47 } 48 48 … … 58 58 */ 59 59 def getSubjects = { 60 60 List subjects = [] 61 61 if( params.externalStudyID ) { 62 62 def id = params.externalStudyID 63 63 def study = Study.find( "from Study as s where s.code=?", [id]) 64 64 if(study) study.subjects.each { subjects.push it.name } 65 66 65 } 66 render subjects as JSON 67 67 } 68 68 … … 78 78 */ 79 79 def getAssays = { 80 80 List assays = [] 81 81 if( params.externalStudyID ) { 82 82 def id = Long.parseLong(params.externalStudyID) 83 83 def study = Study.find( "from Study as s where s.code=?", [id]) 84 84 if(study) study.assays.each{ assay -> assays.push assay.externalAssayID } 85 85 } 86 86 render assays as JSON 87 87 } 88 88 … … 92 92 * Provide all samples of a given Assay. The result is an enriched list with additional informatin on a sample. 93 93 * 94 95 94 * Example for calling this resource: http://localhost:8080/gscf/rest/getAssays/json?externalStudyID=2 95 * 96 96 * @param assayID (externalAssayID of some Assay in GSCF) 97 97 * @return list of element of Sample.name x Sample.material x Sample.subject.name x Sample.Event.name x Sample.Event.time 98 98 */ 99 99 def getSamples = { 100 100 def items = [] 101 101 if( params.externalAssayID ) { 102 102 def id = Long.parseLong(params.externalAssayID) 103 103 Assay.find( "from Assay as a where externalAssayID=?",[id]).getSamples().each { sample -> 104 104 def item = [ 105 'name' 106 'material' 107 'subject' 108 //'event' : sample.parentEvent.name, // get the freaking name109 'startTime' 105 'name' : sample.name, 106 'material' : sample.material.name, 107 'subject' : sample.parentSubject.name, 108 'event' : sample.parentEvent.template.name, // get the freaking name 109 'startTime' : sample.parentEvent.startTime 110 110 ] 111 111 items.push item 112 112 } 113 113 } 114 114 render items as JSON 115 115 } 116 116
Note: See TracChangeset
for help on using the changeset viewer.