Changeset 904
- Timestamp:
- Oct 1, 2010, 11:46:02 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r903 r904 1 1 /** 2 * RestControl er2 * RestController 3 3 * 4 4 * This controler provides a REST service. … … 80 80 * Provide a list of all studies owned by the supplied user. 81 81 * 82 * @return JSON object list containing ' externalStudyID', and 'name' (title) for each study82 * @return JSON object list containing 'studyToken', and 'name' (title) for each study 83 83 */ 84 84 def getStudies = { … … 86 86 def user = params.user 87 87 Study.findAllByOwner(requestUser).each { study -> 88 studies.push( [ ' externalStudyID': study.code, 'title':study.title, 'studyToken':study.code ] )88 studies.push( [ 'title':study.title, 'studyToken':study.code ] ) 89 89 } 90 90 render studies as JSON … … 97 97 * Provide a list of all subjects belonging to a study. 98 98 * 99 * @param externalStudyIDString The external study id (code) of the target GSCF Study object99 * @param studyToken String The external study id (code) of the target GSCF Study object 100 100 * @return JSON object list of subject names 101 101 */ 102 102 def getSubjects = { 103 103 List subjects = [] 104 if( params. externalStudyID) {105 def id = params. externalStudyID104 if( params.studyToken ) { 105 def id = params.studyToken 106 106 def study = Study.find( "from Study as s where s.code=?", [id]) 107 107 if(study) study.subjects.each { subjects.push it.name } … … 117 117 * 118 118 * Example call of the getAssays REST resource: 119 * http://localhost:8080/gscf/rest/getAssays? externalStudyID=PPSH&moduleURL=http://localhost:8182/sam120 * 121 * @param externalStudyIDString The external study id (code) of the target GSCF Study object119 * http://localhost:8080/gscf/rest/getAssays?studyToken=PPSH&moduleURL=http://localhost:8182/sam 120 * 121 * @param stuyToken String The external study id (code) of the target GSCF Study object 122 122 * @param moduleURL String The base URL of the calling dbNP module 123 123 * @return list of assays in the study as JSON object list, filtered to only contain assays 124 * for the specified module, with ' externalAssayID' and 'name' for each assay124 * for the specified module, with 'assayToken' and 'name' for each assay 125 125 */ 126 126 def getAssays = { 127 127 List assays = [] 128 if( params. externalStudyID || params.studyToken ) {129 def id = params.studyToken ?: params.externalStudyID128 if( params.studyToken ) { 129 def id = params.studyToken 130 130 def study = Study.find( "from Study as s where s.code=?", [id] ) 131 131 if(study && study.owner == requestUser) study.assays.each{ assay -> 132 if (assay.module.url.equals(params.moduleURL)) {133 def map = ['name':assay.name, ' externalAssayID':assay.externalAssayID, 'assayToken':assay.externalAssayID]132 //if (assay.module.url.equals(params.moduleURL)) { 133 def map = ['name':assay.name, 'assayToken':assay.externalAssayID] 134 134 assays.push( map ) 135 }135 //} 136 136 } 137 137 } … … 145 145 * Provide all samples of a given Assay. The result is an enriched list with additional information for each sample. 146 146 * 147 * @param externalAssayID String (externalAssayIDof some Assay in GSCF)147 * @param assayToken String (assayToken of some Assay in GSCF) 148 148 * @return As a JSON object list, for each sample in that assay: 149 149 * @return 'name' (Sample name, which is unique) … … 155 155 def getSamples = { 156 156 def items = [] 157 if( params. externalAssayID) {158 def assay = Assay.find( "from Assay as a where externalAssayID=?",[params. externalAssayID])157 if( params.assayToken ) { 158 def assay = Assay.find( "from Assay as a where externalAssayID=?",[params.assayToken]) 159 159 assay.getSamples().each { sample -> 160 160 def item = [ … … 241 241 * One specific sample of a given Assay. 242 242 * 243 * @param externalAssayID String (externalAssayIDof some Assay in GSCF)243 * @param assayToken String (id of some Assay in GSCF) 244 244 * @return As a JSON object list, for each sample in that assay: 245 245 * @return 'name' (Sample name, which is unique)
Note: See TracChangeset
for help on using the changeset viewer.