Changeset 389 for trunk/grails-app/conf
- Timestamp:
- Apr 28, 2010, 4:28:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r386 r389 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 56 49 57 50 // Create a few persons, roles and Affiliations … … 142 135 ).with { if (!validate()) { errors.each { println it} } else save()} 143 136 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()} 144 142 145 143 def c57bl6Term = new Term( … … 443 441 name: 'Compound', type: TemplateFieldType.STRING, 444 442 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))459 443 .with { if (!validate()) { errors.each { println it} } else save()} 460 444 … … 516 500 exampleStudy.save() 517 501 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 532 502 println ".adding NuGO PPSH example study..." 533 503 def exampleHumanStudy = new Study( … … 545 515 546 516 def evLF = new Event( 547 template: dietTreatmentTemplate, 548 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 549 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 517 template: dietTreatmentTemplate 550 518 ) 551 519 .with { if (!validate()) { errors.each { println it} } else save()} 552 520 521 evLF.setStartTime(Date.parse('yyyy-MM-dd','2008-01-07')) 522 evLF.setEndTime(Date.parse('yyyy-MM-dd','2008-01-14')) 523 553 524 evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) 554 525 evLF.save(flush:true) … … 558 529 559 530 def evHF = new Event( 560 template: dietTreatmentTemplate, 561 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 562 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 531 template: dietTreatmentTemplate 563 532 ) 533 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07')) 534 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14')) 564 535 .setFieldValue( 'Diet','45% fat (palm oil)' ) 565 536 .with { if (!validate()) { errors.each { println it} } else save()} 566 537 567 538 def evBV = new Event( 568 template: boostTreatmentTemplate, 569 startTime: Date.parse('yyyy-MM-dd','2008-01-07'), 570 endTime: Date.parse('yyyy-MM-dd','2008-01-14') 539 template: boostTreatmentTemplate 571 540 ) 541 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07')) 542 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14')) 572 543 .setFieldValue( 'Compound','Vehicle' ) 573 544 .with { if (!validate()) { errors.each { println it} } else save()} 574 545 575 546 def evBL = new Event( 576 template: boostTreatmentTemplate ,577 startTime: Date.parse('yyyy-MM-dd','2008-01-07'),578 endTime: Date.parse('yyyy-MM-dd','2008-01-14')579 547 template: boostTreatmentTemplate 548 ) 549 .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07')) 550 .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14')) 580 551 .setFieldValue( 'Compound','Leptin' ) 581 552 .with { if (!validate()) { errors.each { println it} } else save()} … … 686 657 687 658 def x=1 688 12.times {659 40.times { 689 660 def currentSubject = new Subject( 690 661 name: "A" + x++, … … 713 684 */ 714 685 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() } 686 if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 745 687 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 746 688 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 747 689 else { LFBV1.addToSubjects(currentSubject).save() } 748 */749 750 if (x == 0) { HFBL1.addToSubjects(currentSubject).save() }751 else { LFBV1.addToSubjects(currentSubject).save() }752 690 753 691 } 754 755 692 756 693 // Add EventGroups to study … … 774 711 .save() 775 712 713 /* 776 714 println 'Adding PPSH study' 777 715 … … 781 719 code:"PPSH", 782 720 researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 721 description:"Human study", 783 722 ecCode:"unknown", 784 723 startDate: Date.parse('yyyy-MM-dd','2009-01-01') … … 786 725 787 726 def fastingEvent = new Event( 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()} 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']); 794 731 795 732 def bloodSamplingEvent = new SamplingEvent( 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()} 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]); 802 737 803 738 def rootGroup = new EventGroup(name: 'Root group'); … … 806 741 rootGroup.save() 807 742 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() 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 831 768 // Add clinical data 832 769 … … 856 793 lipidAssay.addToMeasurements ldlMeasurement 857 794 lipidAssay.addToMeasurements hdlMeasurement 858 795 859 796 def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( 860 797 assay: lipidAssay … … 878 815 879 816 // Add assay to study capture module 817 880 818 def clinicalModule = new AssayModule( 881 819 name: 'Clinical data', … … 896 834 lipidAssayRef.save() 897 835 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 836 humanStudy.addToAssays(lipidAssayRef); 917 837 humanStudy.save() 838 */ 918 839 } 919 840 }
Note: See TracChangeset
for help on using the changeset viewer.