Changeset 1440
- Timestamp:
- Jan 25, 2011, 5:57:37 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r1430 r1440 137 137 } 138 138 else if( params.studyToken instanceof String ) { 139 def study = Study.findBy Code( params.studyToken )139 def study = Study.findByStudyUUID( params.studyToken ) 140 140 if( study ) { 141 141 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) { … … 153 153 else { 154 154 params.studyToken.each{ studyToken -> 155 def study = Study.findBy Code( studyToken );155 def study = Study.findByStudyUUID( studyToken ); 156 156 if( study ) 157 157 studies.push study … … 166 166 if( study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 167 167 168 def items = [ :]168 def items = [studyToken:study.giveUUID()] 169 169 study.giveFields().each { field -> 170 170 def name = field.name 171 171 def value = study.getFieldValue( name ) 172 if( name=='code' ) {173 name = 'studyToken'174 }175 172 items[name] = value 176 173 } … … 215 212 return false 216 213 } else { 217 study = Study.findBy Code( params.studyToken )214 study = Study.findByStudyUUID( params.studyToken ) 218 215 if( study ) { 219 216 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) { … … 248 245 List subjects = [] 249 246 if( params.studyToken ) { 250 def id = params.studyToken 251 def study = Study.find( "from Study as s where s.code=?", [id]) 247 def study = Study.findByStudyUUID( params.studyToken) 252 248 253 249 if(study) { … … 321 317 if( params.studyToken ) { 322 318 323 def id = params.studyToken 324 def study = Study.findByCode(id) 319 def study = Study.findByStudyUUID(params.studyToken) 325 320 326 321 if(study) { … … 336 331 } 337 332 else if( params.assayToken instanceof String ) { 338 def assay = study.assays.find{ it. externalAssayID==params.assayToken }333 def assay = study.assays.find{ it.giveUUID() == params.assayToken } 339 334 if( assay ) { 340 335 assays.push assay … … 343 338 else { // there are multiple assayTokens instances 344 339 params.assayToken.each { assayToken -> 345 def assay = study.assays.find{ it. externalAssayID==assayToken }340 def assay = study.assays.find{ it.giveUUID() == assayToken } 346 341 if(assay) { 347 342 assays.push assay … … 353 348 if (assay.module.url.equals(params.consumer)) { 354 349 if(assay) { 355 def map = [ :]350 def map = [assayToken : assay.giveUUID()] 356 351 assay.giveFields().each { field -> 357 352 def name = field.name 358 353 def value = assay.getFieldValue( name ) 359 if(field.name=='externalAssayID') {360 name = 'assayToken'361 }362 354 map[name] = value 363 355 } 364 map["parentStudyToken"] = assay.parent.g etToken()356 map["parentStudyToken"] = assay.parent.giveUUID() 365 357 returnList.push( map ) 366 358 } … … 375 367 render returnList as JSON 376 368 } 377 378 379 380 381 382 383 369 384 370 /** … … 442 428 def items = [] 443 429 if( params.assayToken ) { 444 def assay = Assay.find ( "from Assay as a where externalAssayID=?",[params.assayToken])430 def assay = Assay.findByAssayUUID( params.assayToken ); 445 431 446 432 if( assay ) { … … 458 444 samples = [] 459 445 sampleTokens.each{ sampleToken -> 460 samples.addAll(assay.getSamples().find{ sample -> sampleToken == sample. name})446 samples.addAll(assay.getSamples().find{ sample -> sampleToken == sample.giveUUID() }) 461 447 } 462 448 } … … 465 451 466 452 def item = [ 453 'sampleToken' : sample.giveUUID(), 467 454 'material' : sample.material?.name, 468 455 'subject' : sample.parentSubject?.name, … … 485 472 parentEvent.giveFields().each { field -> 486 473 def name = field.name 487 if( name !='sampleTemplate' && name!='fields') {474 if( name !='sampleTemplate' && name != 'fields') { 488 475 def value = parentEvent.getFieldValue( name ) 489 476 eventHash[name]=value … … 517 504 } 518 505 519 520 521 522 523 524 525 526 506 /** 527 507 * Returns the authorization level the user has for a given study. … … 537 517 def getAuthorizationLevel = { 538 518 if( params.studyToken ) { 539 def id = params.studyToken 540 def study = Study.find( "from Study as s where s.code=?", [id]) 519 def study = Study.findByStudyUUID(params.studyToken) 541 520 542 521 if( !study ) { -
trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy
r1430 r1440 52 52 53 53 def showByToken = { 54 def assayInstance = Assay.findBy ExternalAssayID(params.id)54 def assayInstance = Assay.findByAssayUUID(params.id) 55 55 if (!assayInstance) { 56 56 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'assay.label', default: 'Assay'), params.id])}" -
trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy
r1436 r1440 252 252 253 253 def showByToken = { 254 def studyInstance = Study.findBy Code(params.id)254 def studyInstance = Study.findByStudyUUID(params.id) 255 255 if (!studyInstance) { 256 256 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" -
trunk/grails-app/domain/dbnp/studycapturing/Assay.groovy
r1430 r1440 1 1 package dbnp.studycapturing 2 2 import nl.grails.plugins.gdt.* 3 import java.util.UUID; 3 4 4 5 /** … … 17 18 // This ID is generated in GSCF, but is used in the submodules to refer to this particular Assay. 18 19 String externalAssayID 20 21 /** 22 * UUID of this assay 23 */ 24 String assayUUID 19 25 20 26 /** … … 50 56 static constraints = { 51 57 externalAssayID(nullable:false, blank:false, unique: true) 58 assayUUID(nullable:true, unique: true) 52 59 } 53 60 … … 64 71 65 72 def getToken() { 66 return externalAssayID73 return giveUUID() 67 74 } 75 76 /** 77 * Returns the UUID of this sample and generates one if needed 78 */ 79 public String giveUUID() { 80 if( !this.assayUUID ) { 81 this.assayUUID = UUID.randomUUID().toString(); 82 this.save(); 83 } 84 85 return this.assayUUID; 86 } 68 87 } -
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r1430 r1440 2 2 3 3 import nl.grails.plugins.gdt.* 4 import java.util.UUID; 4 5 5 6 /** … … 34 35 String name // should be unique with respect to the parent study (which can be inferred) 35 36 Term material // material of the sample (should normally be bound to the BRENDA ontology) 36 37 38 /** 39 * UUID of this sample 40 */ 41 String sampleUUID 42 37 43 /** 38 44 * return the domain fields for this domain class … … 69 75 // The material domain field is optional 70 76 material(nullable: true) 77 78 sampleUUID(nullable: true, unique: true) 71 79 72 80 // Check if the externalSampleId (currently defined as name) is really unique within each parent study of this sample. … … 123 131 return name 124 132 } 133 134 /** 135 * Returns the UUID of this sample and generates one if needed 136 */ 137 public String giveUUID() { 138 if( !this.sampleUUID ) { 139 this.sampleUUID = UUID.randomUUID().toString(); 140 this.save(); 141 } 142 143 return this.sampleUUID; 144 } 125 145 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r1430 r1440 3 3 import dbnp.authentication.SecUser 4 4 import nl.grails.plugins.gdt.* 5 import java.util.UUID; 5 6 6 7 /** … … 33 34 boolean publicstudy = false // Determines whether anonymous users are allowed to see this study. This has only effect when published = true 34 35 36 /** 37 * UUID of this study 38 */ 39 String studyUUID 40 41 35 42 static hasMany = [ 36 43 subjects: Subject, … … 49 56 owner(nullable: true, blank: true) 50 57 code(nullable: false, blank: true, unique: true) 51 58 studyUUID(nullable:true, unique:true) 52 59 // TODO: add custom validator for 'published' to assess whether the study meets all quality criteria for publication 53 60 // tested by SampleTests.testStudyPublish … … 68 75 // It is used from within dbNP submodules to refer to particular study in this GSCF instance. 69 76 70 def getToken() { code}77 def getToken() { return giveUUID() } 71 78 72 79 /** … … 502 509 } 503 510 } 511 512 /** 513 * Returns the UUID of this study and generates one if needed 514 */ 515 public String giveUUID() { 516 if( !this.studyUUID ) { 517 this.studyUUID = UUID.randomUUID().toString(); 518 this.save(); 519 } 520 521 return this.studyUUID; 522 } 504 523 505 524 // Send messages to modules about changes in this study
Note: See TracChangeset
for help on using the changeset viewer.