Changeset 386 for trunk/grails-app/conf
- Timestamp:
- Apr 27, 2010, 3:53:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r384 r386 47 47 accession: '9606' 48 48 ).with { if (!validate()) { errors.each { println it} } else save()} 49 50 def bloodTerm = new Term( 51 name: 'Portion of blood', 52 ontology: speciesOntology, 53 accession: '9670' 54 ).with { if (!validate()) { errors.each { println it} } else save()} 55 49 56 50 57 // Create a few persons, roles and Affiliations … … 135 142 ).with { if (!validate()) { errors.each { println it} } else save()} 136 143 137 def bloodTerm = new Term(138 name: 'Portion of blood',139 ontology: humanBodyOntology,140 accession: '9670'141 ).with { if (!validate()) { errors.each { println it} } else save()}142 144 143 145 def c57bl6Term = new Term( … … 441 443 name: 'Compound', type: TemplateFieldType.STRING, 442 444 listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) 445 .with { if (!validate()) { errors.each { println it} } else save()} 446 447 def bloodSamplingEventTemplate = new Template( 448 name: 'Blood extraction', entity: dbnp.studycapturing.Event) 449 .addToFields(sampleDescriptionField) 450 .addToFields(new TemplateField( 451 name: 'Sample volume', type: TemplateFieldType.FLOAT)) 452 .with { if (!validate()) { errors.each { println it} } else save()} 453 454 def fastingTreatmentTemplate = new Template( 455 name: 'Fasting treatment', entity: dbnp.studycapturing.Event) 456 .addToFields(sampleDescriptionField) 457 .addToFields(new TemplateField( 458 name: 'Fasting period', type: TemplateFieldType.STRING)) 443 459 .with { if (!validate()) { errors.each { println it} } else save()} 444 460 … … 500 516 exampleStudy.save() 501 517 518 519 /* Test output of fields things */ 520 println "-----------------------------" 521 print "Diet domain fields: " 522 println exampleStudy.giveDomainFields().join( ", " ) 523 524 print "Diet template fields: " 525 println exampleStudy.giveTemplateFields().join( ", " ) 526 527 print "Diet all fields: " 528 println exampleStudy.giveFields().join( ", " ) 529 530 println "-----------------------------" 531 502 532 println ".adding NuGO PPSH example study..." 503 533 def exampleHumanStudy = new Study( … … 515 545 516 546 def evLF = new Event( 517 template: dietTreatmentTemplate 547 template: dietTreatmentTemplate, 548 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 549 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 518 550 ) 519 551 .with { if (!validate()) { errors.each { println it} } else save()} 520 552 521 evLF.setStartTime(Date.parse('yyyy-MM-dd','2008-01-07'))522 evLF.setEndTime(Date.parse('yyyy-MM-dd','2008-01-14'))523 524 553 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 525 554 evLF.save(flush:true) … … 529 558 530 559 def evHF = new Event( 531 template: dietTreatmentTemplate 560 template: dietTreatmentTemplate, 561 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 562 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 532 563 ) 533 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07'))534 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14'))535 564 .setFieldValue( 'Diet','45% fat (palm oil)' ) 536 565 .with { if (!validate()) { errors.each { println it} } else save()} 537 566 538 567 def evBV = new Event( 539 template: boostTreatmentTemplate 568 template: boostTreatmentTemplate, 569 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 570 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 540 571 ) 541 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07'))542 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14'))543 572 .setFieldValue( 'Compound','Vehicle' ) 544 573 .with { if (!validate()) { errors.each { println it} } else save()} 545 574 546 575 def evBL = new Event( 547 template: boostTreatmentTemplate 548 )549 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07'))550 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14'))576 template: boostTreatmentTemplate, 577 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 578 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 579 ) 551 580 .setFieldValue( 'Compound','Leptin' ) 552 581 .with { if (!validate()) { errors.each { println it} } else save()} … … 657 686 658 687 def x=1 659 40.times {688 12.times { 660 689 def currentSubject = new Subject( 661 690 name: "A" + x++, … … 684 713 */ 685 714 686 if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 715 if (x > 9) { HFBL1.addToSubjects(currentSubject).save() } 716 else if (x > 6) { HFBV1.addToSubjects(currentSubject).save() } 717 else if (x > 3) { LFBL1.addToSubjects(currentSubject).save() } 718 else { LFBV1.addToSubjects(currentSubject).save() } 719 720 } 721 722 // Also add some human subjects 723 2.times { 724 def currentSubject = new Subject( 725 name: "H" + x++, 726 species: humanTerm, 727 template: humanTemplate, 728 ) 729 .setFieldValue("Gender", "Male") 730 //.setFieldValue("Genotype", c57bl6Term) 731 .setFieldValue("Age (years)", 27) 732 .setFieldValue("Height", 1.5) 733 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 734 735 exampleStudy.addToSubjects(currentSubject) 736 .with { if (!validate()) { errors.each { println it} } else save()} 737 738 // Add subject to appropriate EventGroup 739 /* 740 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 741 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 742 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 743 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 744 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 687 745 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 688 746 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 689 747 else { LFBV1.addToSubjects(currentSubject).save() } 748 */ 749 750 if (x == 0) { HFBL1.addToSubjects(currentSubject).save() } 751 else { LFBV1.addToSubjects(currentSubject).save() } 690 752 691 753 } 754 692 755 693 756 // Add EventGroups to study … … 711 774 .save() 712 775 713 /*714 776 println 'Adding PPSH study' 715 777 … … 719 781 code:"PPSH", 720 782 researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 721 description:"Human study",722 783 ecCode:"unknown", 723 784 startDate: Date.parse('yyyy-MM-dd','2009-01-01') … … 725 786 726 787 def fastingEvent = new Event( 727 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 728 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 729 eventDescription: fastingTreatment, 730 parameterStringValues: ['Fasting period':'8h']); 788 template: fastingTreatmentTemplate, 789 startTime: Date.parse('yyyy-MM-dd','2008-01-14' ), 790 endTime: Date.parse('yyyy-MM-dd','2008-01-14' ) 791 ) 792 .setFieldValue( 'Fasting period','8h' ) 793 .with { if (!validate()) { errors.each { println it} } else save()} 731 794 732 795 def bloodSamplingEvent = new SamplingEvent( 733 startTime: Date.parse('yyyy-MM-dd','2008-01-14'), 734 endTime: Date.parse('yyyy-MM-dd','2008-01-14'), 735 eventDescription: bloodSamplingEventDescription, 736 parameterFloatValues: ['Sample volume':4.5F]); 796 template: bloodSamplingEventTemplate, 797 startTime: Date.parse('yyyy-MM-dd','2008-01-14' ), 798 endTime: Date.parse('yyyy-MM-dd','2008-01-14' ) 799 ) 800 .setFieldValue( 'Sample volume',4.5F ) 801 .with { if (!validate()) { errors.each { println it} } else save()} 737 802 738 803 def rootGroup = new EventGroup(name: 'Root group'); … … 741 806 rootGroup.save() 742 807 743 def y = 1 744 11.times { 745 def currentSubject = new Subject( 746 name: "" + y++, 747 species: humanTerm, 748 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()} 749 750 rootGroup.addToSubjects currentSubject 751 rootGroup.save() 752 753 def currentSample = new Sample( 754 name: currentSubject.name + '_B', 755 material: bloodTerm, 756 parentSubject: currentSubject, 757 parentEvent: bloodSamplingEvent); 758 759 760 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 761 } 762 763 humanStudy.addToEvents(fastingEvent) 764 humanStudy.addToSamplingEvents(bloodSamplingEvent) 765 humanStudy.addToEventGroups rootGroup 766 humanStudy.save() 767 808 def y = 1 809 11.times { 810 def currentSubject = new Subject( 811 name: "" + y++, 812 species: humanTerm, 813 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()} 814 815 rootGroup.addToSubjects currentSubject 816 rootGroup.save() 817 818 def currentSample = new Sample( 819 name: currentSubject.name + '_B', 820 material: bloodTerm, 821 parentSubject: currentSubject, 822 parentEvent: bloodSamplingEvent); 823 824 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 825 } 826 827 humanStudy.addToEvents(fastingEvent) 828 humanStudy.addToSamplingEvents(bloodSamplingEvent) 829 humanStudy.addToEventGroups rootGroup 830 humanStudy.save() 768 831 // Add clinical data 769 832 … … 793 856 lipidAssay.addToMeasurements ldlMeasurement 794 857 lipidAssay.addToMeasurements hdlMeasurement 795 858 796 859 def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( 797 860 assay: lipidAssay … … 815 878 816 879 // Add assay to study capture module 817 818 880 def clinicalModule = new AssayModule( 819 881 name: 'Clinical data', … … 834 896 lipidAssayRef.save() 835 897 836 humanStudy.addToAssays(lipidAssayRef); 898 humanStudy.addToAssays(lipidAssayRef); 899 900 // Add some sample assay 901 // Add assay to study capture module 902 def dummyModule = new AssayModule( 903 name: 'Dummy data', 904 type: AssayType.CLINICAL_DATA, 905 platform: 'other type of measurement platform', 906 url: 'http://localhost:8080/gscf' 907 ).with { if (!validate()) { errors.each { println it} } else save()} 908 909 def dummyAssayRef = new Assay( 910 name: 'Test assay', 911 module: dummyModule, 912 externalAssayId: lipidAssayInstance.id 913 ).with { if (!validate()) { errors.each { println it} } else save()} 914 915 humanStudy.addToAssays(dummyAssayRef); 916 837 917 humanStudy.save() 838 */839 918 } 840 919 }
Note: See TracChangeset
for help on using the changeset viewer.