Changeset 421 for trunk/grails-app/conf
- Timestamp:
- May 17, 2010, 3:26:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r408 r421 24 24 println ".development bootstrapping..."; 25 25 26 // add NCBIspecies ontology26 // add Subject>species ontology 27 27 println ".adding NCBI species ontology" 28 28 def speciesOntology = new Ontology( … … 35 35 ).with { if (!validate()) { errors.each { println it} } else save()} 36 36 37 // add Sample>material ontology 37 38 println ".adding BRENDA source material ontology" 38 39 def brendaOntology = new Ontology( … … 45 46 ).with { if (!validate()) { errors.each { println it} } else save()} 46 47 47 // add TERMS 48 // add NCI ontology which is used in Mouse genotype template field 49 def nciOntology = new Ontology( 50 name: 'NCI Thesaurus', 51 description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.', 52 url: 'http://ncicb.nci.nih.gov/core/EVS', 53 versionNumber: '10.01', 54 ncboId: '1032', 55 ncboVersionedId: '42693' 56 ).with { if (!validate()) { errors.each { println it} } else save()} 57 58 // add Terms 48 59 println ".adding mouse term" 49 60 def mouseTerm = new Term( … … 58 69 accession: '9606' 59 70 ).with { if (!validate()) { errors.each { println it} } else save()} 60 61 // Create a few persons, roles and Affiliations62 println ".adding persons, roles and affiliations"63 def affiliation1 = new PersonAffiliation(64 name: "Science Institute NYC"65 ).save();66 def affiliation2 = new PersonAffiliation(67 name: "InfoStats GmbH, Hamburg"68 ).save();69 def role1 = new PersonRole(70 name: "Principal Investigator"71 ).save();72 def role2 = new PersonRole(73 name: "Statician"74 ).save();75 76 // Create 30 roles to test pagination77 def roleCounter = 1;78 30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() }79 80 // Create persons81 def person1 = new Person(82 lastName: "Scientist",83 firstName: "John",84 gender: "Male",85 initials: "J.R.",86 email: "john@scienceinstitute.com",87 phone: "1-555-3049",88 address: "First street 2,NYC"89 )90 .addToAffiliations( affiliation1 )91 .addToAffiliations( affiliation2 )92 .save();93 94 def person2 = new Person(95 lastName: "Statician",96 firstName: "Jane",97 gender: "Female",98 initials: "W.J.",99 email: "jane@statisticalcompany.de",100 phone: "49-555-8291",101 address: "Dritten strasse 38, Hamburg, Germany"102 )103 .addToAffiliations( affiliation2 )104 .save();105 106 // Create 30 persons to test pagination107 def personCounter = 1;108 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() }109 110 /* COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL111 112 // ontologies113 def speciesOntology = new Ontology(114 name: 'NCBI Taxonomy',115 shortName: 'Taxon',116 url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy'117 ).with { if (!validate()) { errors.each { println it} } else save()}118 119 def humanBodyOntology = new Ontology(120 name: 'Foundational Model of Anatomy',121 shortName: 'HumanBody',122 url: 'http://bioportal.bioontology.org/ontologies/39966'123 ).with { if (!validate()) { errors.each { println it} } else save()}124 125 def nciOntology = new Ontology(126 name: 'NCI Thesaurus',127 shortName: 'NCI',128 url: 'http://bioportal.bioontology.org/ontologies/42331'129 ).with { if (!validate()) { errors.each { println it} } else save()}130 131 // terms132 def mouseTerm = new Term(133 name: 'Mus musculus',134 ontology: speciesOntology,135 accession: '10090'136 ).with { if (!validate()) { errors.each { println it} } else save()}137 def humanTerm = new Term(138 name: 'Homo sapiens',139 ontology: speciesOntology,140 accession: '9606'141 ).with { if (!validate()) { errors.each { println it} } else save()}142 71 def arabTerm = new Term( 143 72 name: 'Arabidopsis thaliana', … … 145 74 accession: '3702' 146 75 ).with { if (!validate()) { errors.each { println it} } else save()} 147 76 148 77 def bloodTerm = new Term( 149 name: ' Portion of blood',150 ontology: humanBodyOntology,151 accession: ' 9670'78 name: 'blood plasma', 79 ontology: brendaOntology, 80 accession: 'BTO:0000131' 152 81 ).with { if (!validate()) { errors.each { println it} } else save()} 153 82 … … 158 87 ).with { if (!validate()) { errors.each { println it} } else save()} 159 88 160 def madmaxOntology = new Ontology( 161 name: 'Madmax ontology', 162 shortName: 'MDMX', 163 url: 'madmax.bioinformatics.nl' 164 ).with { if (!validate()) { errors.each { println it} } else save()} 165 166 def treatmentTerm = new Term( 167 name: 'ExperimentalProtocol', 168 ontology: madmaxOntology, 169 accession: 'P-MDMXGE-264' 170 ).with { if (!validate()) { errors.each { println it} } else save()} 171 172 def dietProtocol = new Protocol( 173 name: 'Diet treatment Protocol NuGO PPS3 leptin module', 174 reference: treatmentTerm 175 ).with { if (!validate()) { errors.each { println it} } else save()} 176 177 def boostProtocol = new Protocol( 178 name: 'Boost treatment Protocol NuGO PPS3 leptin module', 179 reference: treatmentTerm 180 ).with { if (!validate()) { errors.each { println it} } else save()} 181 182 def fastingProtocol = new Protocol( 183 name: 'Fasting', 184 reference: treatmentTerm 185 ).with { if (!validate()) { errors.each { println it} } else save()} 186 187 188 // ParameterStringListItems 189 def oil10= new ParameterStringListItem( 190 name: '10% fat (palm oil)' 191 ).with { if (!validate()) { errors.each { println it} } else save()} 192 def oil45= new ParameterStringListItem( 193 name: '45% fat (palm oil)' 194 ).with { if (!validate()) { errors.each { println it} } else save()} 195 def vehicle= new ParameterStringListItem( 196 name: 'Vehicle' 197 ).with { if (!validate()) { errors.each { println it} } else save()} 198 def leptin= new ParameterStringListItem( 199 name: 'Leptin' 200 ).with { if (!validate()) { errors.each { println it} } else save()} 201 202 203 dietProtocol 204 .addToParameters(new ProtocolParameter( 205 name: 'Diet', 206 type: ProtocolParameterType.STRINGLIST, 207 listEntries: [oil10,oil45])) 208 .save() 209 210 boostProtocol 211 .addToParameters(new ProtocolParameter( 212 name: 'Compound', 213 type: ProtocolParameterType.STRINGLIST, 214 listEntries: [vehicle,leptin])) 215 .save() 216 217 fastingProtocol 218 .addToParameters(new ProtocolParameter( 219 name: 'Fasting period', 220 type: ProtocolParameterType.STRING)) 221 .save() 222 223 224 // sampling event protocols 225 226 def liverSamplingProtocol = new Protocol( 227 name: 'Liver sampling' 228 ).with { if (!validate()) { errors.each { println it} } else save()} 229 230 liverSamplingProtocol 231 .addToParameters(new ProtocolParameter( 232 name: 'Sample weight', 233 unit: 'mg', 234 type: ProtocolParameterType.FLOAT)) 235 .save() 236 237 def bloodSamplingProtocol = new Protocol( 238 name: 'Blood sampling' 239 ).with { if (!validate()) { errors.each { println it} } else save()} 240 241 bloodSamplingProtocol 242 .addToParameters(new ProtocolParameter( 243 name: 'Sample volume', 244 unit: 'ml', 245 type: ProtocolParameterType.FLOAT)) 246 .save() 247 */ 248 // create system user 249 250 /*def systemUser = userService.createUser(InstanceGenerator.user( 251 username: 'system', 252 pass: 'system', 253 passConfirm: 'system', 254 enabled: true 255 ))*/ 256 257 89 // Create a few persons, roles and Affiliations 90 println ".adding persons, roles and affiliations" 91 def affiliation1 = new PersonAffiliation( 92 name: "Science Institute NYC" 93 ).save(); 94 def affiliation2 = new PersonAffiliation( 95 name: "InfoStats GmbH, Hamburg" 96 ).save(); 97 def role1 = new PersonRole( 98 name: "Principal Investigator" 99 ).save(); 100 def role2 = new PersonRole( 101 name: "Statician" 102 ).save(); 103 104 // Create 30 roles to test pagination 105 def roleCounter = 1; 106 30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() } 107 108 // Create persons 109 def person1 = new Person( 110 lastName: "Scientist", 111 firstName: "John", 112 gender: "Male", 113 initials: "J.R.", 114 email: "john@scienceinstitute.com", 115 phone: "1-555-3049", 116 address: "First street 2,NYC" 117 ) 118 .addToAffiliations( affiliation1 ) 119 .addToAffiliations( affiliation2 ) 120 .save(); 121 122 def person2 = new Person( 123 lastName: "Statician", 124 firstName: "Jane", 125 gender: "Female", 126 initials: "W.J.", 127 email: "jane@statisticalcompany.de", 128 phone: "49-555-8291", 129 address: "Dritten strasse 38, Hamburg, Germany" 130 ) 131 .addToAffiliations( affiliation2 ) 132 .save(); 133 134 // Create 30 persons to test pagination 135 def personCounter = 1; 136 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } 137 138 // Create templates 139 258 140 def genderField = new TemplateField( 259 141 name: 'Gender',type: TemplateFieldType.STRINGLIST, … … 442 324 .with { if (!validate()) { errors.each { println it} } else save()} 443 325 444 /* 445 //events 446 def eventDiet = new EventDescription( 447 name: 'Diet treatment', 448 description: 'Diet treatment (fat percentage)', 449 classification: treatmentTerm, 450 protocol: dietProtocol, 451 isSamplingEvent: false 452 ).with { if (!validate()) { errors.each { println it} } else save()} 453 454 def eventBoost = new EventDescription( 455 name: 'Boost treatment', 456 description: 'Boost treatment (leptin or vehicle)', 457 classification: treatmentTerm, 458 protocol: boostProtocol, 459 isSamplingEvent: false 460 ).with { if (!validate()) { errors.each { println it} } else save()} 461 462 def samplingEvent = new EventDescription( 326 def fastingTreatment = new Template( 327 name: 'Fasting treatment', 328 description: 'Fasting Protocol NuGO PPSH', 329 entity: dbnp.studycapturing.Event) 330 .addToFields(new TemplateField( 331 name: 'Fasting period', 332 type: TemplateFieldType.STRING)) 333 .with { if (!validate()) { errors.each { println it} } else save()} 334 335 // SamplingEvent templates 336 337 def liverSamplingEventTemplate = new Template( 463 338 name: 'Liver extraction', 464 339 description: 'Liver sampling for transcriptomics arrays', 465 protocol: liverSamplingProtocol, 466 isSamplingEvent: true 467 ).with { if (!validate()) { errors.each { println it} } else save()} 468 469 def bloodSamplingEventDescription = new EventDescription( 340 entity: dbnp.studycapturing.SamplingEvent) 341 .addToFields(new TemplateField( 342 name: 'Sample weight', 343 unit: 'mg', 344 type: TemplateFieldType.FLOAT)) 345 .with { if (!validate()) { errors.each { println it} } else save()} 346 347 def bloodSamplingEventTemplate = new Template( 470 348 name: 'Blood extraction', 471 349 description: 'Blood extraction targeted at lipid assays', 472 protocol: bloodSamplingProtocol, 473 isSamplingEvent: true 474 ).with { if (!validate()) { errors.each { println it} } else save()} 475 476 477 def fastingTreatment = new EventDescription( 478 name: 'Fasting treatment', 479 description: 'Fasting Protocol NuGO PPSH', 480 protocol: fastingProtocol, 481 isSamplingEvent: false 482 ).with { if (!validate()) { errors.each { println it} } else save()} 483 484 println('Adding PPS3 study...') 485 */ 486 // studies 350 entity: dbnp.studycapturing.SamplingEvent) 351 .addToFields(new TemplateField( 352 name: 'Sample volume', 353 unit: 'ml', 354 type: TemplateFieldType.FLOAT)) 355 .with { if (!validate()) { errors.each { println it} } else save()} 356 357 358 // Add example studies 487 359 if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) { 488 360 println ".adding NuGO PPS3 leptin example study..." 489 def exampleStudy = new Study(361 def mouseStudy = new Study( 490 362 template: studyTemplate, 491 363 title:"NuGO PPS3 mouse study leptin module", … … 497 369 .with { if (!validate()) { errors.each { println it} } else save()} 498 370 499 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." ) 500 exampleStudy.save() 501 502 println ".adding NuGO PPSH example study..." 503 def exampleHumanStudy = new Study( 504 template: studyTemplate, 505 title:"Human example template", 506 code:"Human example code", 507 researchQuestion:"Leptin etc.", 508 ecCode:"2007117.c", 509 startDate: Date.parse('yyyy-MM-dd','2007-12-11') 510 ) 511 .with { if (!validate()) { errors.each { println it} } else save()} 512 513 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." ) 514 exampleHumanStudy.save() 371 mouseStudy.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." ) 372 mouseStudy.save() 515 373 516 374 def evLF = new Event( … … 519 377 template: dietTreatmentTemplate 520 378 ) 521 .with { if (!validate()) { errors.each { println it} } else save()} 522 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 523 evLF.save(flush:true) 379 .setFieldValue( 'Diet','10% fat (palm oil)') 380 .with { if (!validate()) { errors.each { println it} } else save()} 524 381 525 382 def evHF = new Event( … … 547 404 .with { if (!validate()) { errors.each { println it} } else save()} 548 405 549 /*550 406 def evLF4 = new Event( 551 407 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 552 408 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 553 eventDescription: eventDiet, 554 parameterStringValues: ['Diet':'10% fat (palm oil)'] 555 ).with { if (!validate()) { errors.each { println it} } else save()} 409 template: dietTreatmentTemplate 410 ) 411 .setFieldValue( 'Diet','10% fat (palm oil)') 412 .with { if (!validate()) { errors.each { println it} } else save()} 556 413 557 414 def evHF4 = new Event( 558 415 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 559 416 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 560 eventDescription: eventDiet, 561 parameterStringValues: ['Diet':'45% fat (palm oil)'] 562 ).with { if (!validate()) { errors.each { println it} } else save()} 417 template: dietTreatmentTemplate 418 ) 419 .setFieldValue( 'Diet','45% fat (palm oil)' ) 420 .with { if (!validate()) { errors.each { println it} } else save()} 563 421 564 422 def evBV4 = new Event( 565 423 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 566 424 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 567 eventDescription: eventBoost, 568 parameterStringValues: ['Compound':'Vehicle'] 569 ).with { if (!validate()) { errors.each { println it} } else save()} 425 template: boostTreatmentTemplate 426 ) 427 .setFieldValue( 'Compound','Vehicle' ) 428 .with { if (!validate()) { errors.each { println it} } else save()} 570 429 571 430 def evBL4 = new Event( 572 431 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 573 432 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 574 eventDescription: eventBoost, 575 parameterStringValues: ['Compound':'Leptin'] 576 ).with { if (!validate()) { errors.each { println it} } else save()} 433 template: boostTreatmentTemplate 434 ) 435 .setFieldValue( 'Compound','Leptin' ) 436 .with { if (!validate()) { errors.each { println it} } else save()} 577 437 578 438 def evS = new SamplingEvent( 579 580 581 eventDescription: samplingEvent,582 parameterFloatValues: ['Sample weight':5F]583 ).with { if (!validate()) { errors.each { println it} } else save()}439 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 440 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 441 template: liverSamplingEventTemplate) 442 .setFieldValue('Sample weight',5F) 443 .with { if (!validate()) { errors.each { println it} } else save()} 584 444 585 445 def evS4 = new SamplingEvent( 586 startTime: Date.parse('yyyy-MM-dd','2008-02-04'), 587 endTime: Date.parse('yyyy-MM-dd','2008-02-04'), 588 eventDescription: samplingEvent, 589 parameterFloatValues: ['Sample weight':5F] 590 ).with { if (!validate()) { errors.each { println it} } else save()} 591 */ 446 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 447 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 448 template: liverSamplingEventTemplate) 449 .setFieldValue('Sample weight',5F) 450 .with { if (!validate()) { errors.each { println it} } else save()} 592 451 593 452 // Add events to study 594 exampleStudy453 mouseStudy 595 454 .addToEvents(evLF) 596 455 .addToEvents(evHF) 597 456 .addToEvents(evBV) 598 457 .addToEvents(evBL) 599 /*600 458 .addToEvents(evLF4) 601 459 .addToEvents(evHF4) … … 604 462 .addToSamplingEvents(evS) 605 463 .addToSamplingEvents(evS4) 606 */607 464 .save() 608 465 … … 610 467 .addToEvents(evLF) 611 468 .addToEvents(evBV) 469 .addToEvents(evS) 612 470 .with { if (!validate()) { errors.each { println it} } else save()} 613 471 … … 615 473 .addToEvents(evLF) 616 474 .addToEvents(evBL) 475 .addToEvents(evS) 617 476 .with { if (!validate()) { errors.each { println it} } else save()} 618 477 … … 620 479 .addToEvents(evHF) 621 480 .addToEvents(evBV) 481 .addToEvents(evS) 622 482 .with { if (!validate()) { errors.each { println it} } else save()} 623 483 … … 625 485 .addToEvents(evHF) 626 486 .addToEvents(evBL) 627 . with { if (!validate()) { errors.each { println it} } else save()}628 629 /* 487 .addToEvents(evS) 488 .with { if (!validate()) { errors.each { println it} } else save()} 489 630 490 def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") 631 491 .addToEvents(evLF4) 632 492 .addToEvents(evBV4) 493 .addToEvents(evS4) 633 494 .with { if (!validate()) { errors.each { println it} } else save()} 634 495 … … 636 497 .addToEvents(evLF4) 637 498 .addToEvents(evBL4) 499 .addToEvents(evS4) 638 500 .with { if (!validate()) { errors.each { println it} } else save()} 639 501 … … 641 503 .addToEvents(evHF4) 642 504 .addToEvents(evBV4) 505 .addToEvents(evS4) 643 506 .with { if (!validate()) { errors.each { println it} } else save()} 644 507 … … 646 509 .addToEvents(evHF4) 647 510 .addToEvents(evBL4) 648 .with { if (!validate()) { errors.each { println it} } else save()} 649 */ 650 651 // Add subjects and samples and compose EventGroups 652 511 .addToEvents(evS4) 512 .with { if (!validate()) { errors.each { println it} } else save()} 513 514 // Add subjects and samples and compose EventGroups 653 515 def x=1 654 40.times {516 80.times { 655 517 def currentSubject = new Subject( 656 518 name: "A" + x++, … … 659 521 ) 660 522 .setFieldValue("Gender", "Male") 661 //.setFieldValue("Genotype", c57bl6Term)523 .setFieldValue("Genotype", c57bl6Term) 662 524 .setFieldValue("Age (weeks)", 17) 663 525 .setFieldValue("Cage", "" + (int)(x/2)) 664 526 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 665 527 666 exampleStudy.addToSubjects(currentSubject)528 mouseStudy.addToSubjects(currentSubject) 667 529 .with { if (!validate()) { errors.each { println it} } else save()} 668 530 669 531 // Add subject to appropriate EventGroup 670 /*671 532 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 672 533 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } … … 677 538 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 678 539 else { LFBV1.addToSubjects(currentSubject).save() } 679 */680 681 if (x > 30) { HFBL1.addToSubjects(currentSubject).save() }682 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() }683 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }684 else { LFBV1.addToSubjects(currentSubject).save() }685 540 686 541 } 687 542 688 543 // Add EventGroups to study 689 exampleStudy544 mouseStudy 690 545 .addToEventGroups(LFBV1) 691 546 .addToEventGroups(LFBL1) 692 547 .addToEventGroups(HFBV1) 693 548 .addToEventGroups(HFBL1) 694 //.addToEventGroups(LFBV4)695 //.addToEventGroups(LFBL4)696 //.addToEventGroups(HFBV4)697 //.addToEventGroups(HFBL4)549 .addToEventGroups(LFBV4) 550 .addToEventGroups(LFBL4) 551 .addToEventGroups(HFBV4) 552 .addToEventGroups(HFBL4) 698 553 699 554 // Add persons to study … … 701 556 def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); 702 557 703 exampleStudy558 mouseStudy 704 559 .addToPersons( studyperson1 ) 705 560 .addToPersons( studyperson2 ) 706 561 .save() 707 562 708 709 /* 710 println 'Adding PPSH study' 563 println ".adding NuGO PPSH example study..." 711 564 712 565 def humanStudy = new Study( … … 717 570 description:"Human study", 718 571 ecCode:"unknown", 719 startDate: Date.parse('yyyy-MM-dd','2009-01-01') 720 ).with { if (!validate()) { errors.each { println it} } else save()} 572 startDate: Date.parse('yyyy-MM-dd','2008-01-14')) 573 .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) 574 .with { if (!validate()) { errors.each { println it} } else save()} 575 576 def rootGroup = new EventGroup(name: 'Root group'); 721 577 722 578 def fastingEvent = new Event( 723 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 724 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 725 eventDescription: fastingTreatment, 726 parameterStringValues: ['Fasting period':'8h']); 579 startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-14 22:00'), 580 endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), 581 template: fastingTreatment) 582 .setFieldValue('Fasting period','8h'); 583 727 584 728 585 def bloodSamplingEvent = new SamplingEvent( 729 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 730 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 731 eventDescription: bloodSamplingEventDescription, 732 parameterFloatValues: ['Sample volume':4.5F]); 733 734 def rootGroup = new EventGroup(name: 'Root group'); 586 startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), 587 endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), 588 template: bloodSamplingEventTemplate) 589 .setFieldValue('Sample volume',4.5F); 590 735 591 rootGroup.addToEvents fastingEvent 736 592 rootGroup.addToEvents bloodSamplingEvent 737 593 rootGroup.save() 738 594 739 def y = 1 740 11.times { 741 def currentSubject = new Subject( 742 name: "" + y++, 743 species: humanTerm, 744 template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age (years)", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight (kg)", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} 745 746 rootGroup.addToSubjects currentSubject 747 rootGroup.save() 748 749 def currentSample = new Sample( 750 name: currentSubject.name + '_B', 751 material: bloodTerm, 752 parentSubject: currentSubject, 753 parentEvent: bloodSamplingEvent); 754 755 756 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 757 } 758 759 humanStudy.addToEvents(fastingEvent) 760 humanStudy.addToSamplingEvents(bloodSamplingEvent) 761 humanStudy.addToEventGroups rootGroup 762 humanStudy.save() 763 595 def y = 1 596 11.times { 597 def currentSubject = new Subject( 598 name: "" + y++, 599 species: humanTerm, 600 template: humanTemplate) 601 .setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female") 602 .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) 603 .setFieldValue("Age (years)", 30) 604 .setFieldValue("Height", Math.random() * 2F) 605 .setFieldValue("Weight (kg)", Math.random() * 150F) 606 .setFieldValue("BMI", 20 + Math.random() * 10F) 607 .with { if (!validate()) { errors.each { println it} } else save()} 608 609 rootGroup.addToSubjects currentSubject 610 rootGroup.save() 611 612 def currentSample = new Sample( 613 name: currentSubject.name + '_B', 614 material: bloodTerm, 615 parentSubject: currentSubject, 616 parentEvent: bloodSamplingEvent); 617 618 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 619 } 620 621 humanStudy.addToEvents(fastingEvent) 622 humanStudy.addToSamplingEvents(bloodSamplingEvent) 623 humanStudy.addToEventGroups rootGroup 624 humanStudy.save() 625 626 /* 764 627 // Add clinical data 765 628 … … 833 696 humanStudy.save() 834 697 */ 698 835 699 } 836 700 }
Note: See TracChangeset
for help on using the changeset viewer.