Changeset 375
- Timestamp:
- Apr 23, 2010, 11:26:57 AM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r370 r375 248 248 def genotypeTypeField = new TemplateField( 249 249 name: 'Genotype type',type: TemplateFieldType.STRINGLIST, 250 listEntries: [new TemplateFieldListItem(name:'transgenic'), 250 listEntries: [new TemplateFieldListItem(name:'wildtype'), 251 new TemplateFieldListItem(name:'transgenic'), 251 252 new TemplateFieldListItem(name:'knock-out'), 252 253 new TemplateFieldListItem(name:'knock-in')]) … … 259 260 def studyTemplate = new Template( 260 261 name: 'Academic study', entity: dbnp.studycapturing.Study) 261 //.addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT))262 .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT)) 262 263 .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING)) 263 264 .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT)) … … 339 340 340 341 // Human sample template 342 println ".adding human sample template..." 341 343 def humanSampleTemplate = new Template( 342 344 name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) … … 348 350 349 351 //Plant template 352 println ".adding plant template..." 350 353 def plantTemplate = new Template( 351 354 name: 'Plant template', entity: dbnp.studycapturing.Subject) … … 389 392 .with { if (!validate()) { errors.each { println it} } else save()} 390 393 394 println ".adding plant sample template..." 391 395 def plantSampleTemplate = new Template( 392 396 name: 'Plant sample', entity: dbnp.studycapturing.Sample) … … 398 402 399 403 400 // Event template 404 // Event templates 405 println ".adding event templates..." 401 406 def dietTreatmentTemplate = new Template( 402 407 name: 'Diet treatment ', entity: dbnp.studycapturing.Event) 403 408 .addToFields(sampleDescriptionField) 404 409 .addToFields(new TemplateField( 405 name: 'Diet', type: TemplateFieldType.STRING)) 410 name: 'Diet', type: TemplateFieldType.STRINGLIST, 411 listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) 406 412 .with { if (!validate()) { errors.each { println it} } else save()} 407 413 … … 410 416 .addToFields(sampleDescriptionField) 411 417 .addToFields(new TemplateField( 412 name: 'Compound', type: TemplateFieldType.STRING)) 418 name: 'Compound', type: TemplateFieldType.STRING, 419 listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) 413 420 .with { if (!validate()) { errors.each { println it} } else save()} 414 421 … … 456 463 */ 457 464 // studies 465 println ".adding NuGO PPS3 leptin example study..." 458 466 def exampleStudy = new Study( 459 467 template: studyTemplate, … … 464 472 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 465 473 ) 466 //.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )467 474 .with { if (!validate()) { errors.each { println it} } else save()} 468 475 476 exampleStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 477 exampleStudy.save() 478 479 println ".adding NuGO PPSH example study..." 469 480 def exampleHumanStudy = new Study( 470 template: humanTemplate,481 template: studyTemplate, 471 482 title:"Human example template", 472 483 code:"Human example code", … … 475 486 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 476 487 ) 477 //.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )478 488 .with { if (!validate()) { errors.each { println it} } else save()} 489 490 exampleHumanStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) 491 exampleHumanStudy.save() 479 492 480 493 def evLF = new Event( … … 483 496 template: dietTreatmentTemplate 484 497 ) 485 .setFieldValue( 'Diet','10% fat (palm oil)' )486 498 .with { if (!validate()) { errors.each { println it} } else save()} 499 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 500 evLF.save(flush:true) 501 // TODO: find out why Diet is not set and Compound is 487 502 488 503 def evHF = new Event( … … 625 640 .setFieldValue("Age (weeks)", 17) 626 641 .setFieldValue("Cage", "" + (int)(x/2)) 627 .with { if (!validate()) { errors.each { println it} } else save( )}642 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 628 643 629 644 exampleStudy.addToSubjects(currentSubject) -
trunk/grails-app/controllers/SandboxController.groovy
r359 r375 13 13 // Get the example study in a lazy way 14 14 def st = Study.get(1) 15 def fieldsAll = st.giveSubjectTemplates().fields 15 println st.title 16 println st.subjects 17 def fieldsAll = st.giveSubjectTemplates().asList().first().fields 16 18 def f = fieldsAll[0] 17 19 println fieldsAll.class … … 43 45 44 46 // Demonstration of querying mechanism 45 println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0])46 println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])47 //println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0]) 48 //println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[]) 47 49 48 50 // Specify which variables we want to be available in the controller (implicit return statement) -
trunk/grails-app/domain/dbnp/studycapturing/Event.groovy
r370 r375 24 24 } 25 25 }) 26 } 27 28 Map giveDomainFields() { 29 return ['startTime':TemplateFieldType.DATE,'endTime':TemplateFieldType.DATE] 26 30 } 27 31 -
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r359 r375 16 16 // a member that describes the quantity of the sample? --> should be in the templates 17 17 18 Map giveDomainFields() { 19 return ['name':TemplateFieldType.STRING,'material':TemplateFieldType.ONTOLOGYTERM] 20 } 21 18 22 static constraints = { 19 23 parentSubject(nullable:true) -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r370 r375 23 23 //String ecCode 24 24 25 Map giveDomainFields() { 26 return ['title':TemplateFieldType.STRING,'startDate':TemplateFieldType.DATE] 27 } 25 28 26 29 static hasMany = [ -
trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy
r359 r375 15 15 String name 16 16 Term species 17 18 Map giveDomainFields() { 19 return ['name':TemplateFieldType.STRING,'species':TemplateFieldType.ONTOLOGYTERM] 20 } 17 21 } -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r370 r375 357 357 * @return key-value pairs describing the built-in fields, with the names as keys and type (as TemplateFieldType) as values 358 358 */ 359 def giveDomainFields() { 359 abstract Map giveDomainFields() 360 /*def giveDomainFields() { 360 361 def fieldSet = [:]; 361 362 if (super.hasProperty('name')) { … … 363 364 } 364 365 return fieldSet; 365 } 366 }*/ 366 367 367 368 // See revision 237 for ideas about initializing the different templateField Maps -
trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy
r359 r375 18 18 List listEntries 19 19 20 static hasMany = [listEntries : TemplateFieldListItem,21 20 static hasMany = [listEntries : 21 TemplateFieldListItem, // to store the entries to choose from when the type is 'item from predefined list' 22 22 ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term' 23 23 ] 24 24 25 25 static constraints = { 26 name(unique: true)26 // TODO: verify that TemplateField names are unique within templates of each super entity 27 27 unit(nullable: true, blank: true) 28 28 comment(nullable:true, blank: true) -
trunk/grails-app/views/sandbox/index.gsp
r359 r375 30 30 </tr> 31 31 </table> 32 <h2>Events</h2>33 <% println studyInstance.events.eventDescription.protocol.name %>34 32 <h2>Subject Fields</h2> 35 33 <table>
Note: See TracChangeset
for help on using the changeset viewer.