Changeset 389 for trunk/grails-app/conf


Ignore:
Timestamp:
Apr 28, 2010, 4:28:39 PM (13 years ago)
Author:
duh
Message:
  • reverted changes of revisions 386, 387 and 388 as they completely broke the repository (you need to get cake now! ;)
  • committed development version of modified study capture wizard (works until events)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r386 r389  
    4747                                accession: '9606'
    4848                        ).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 
    5649
    5750                        // Create a few persons, roles and Affiliations
     
    142135                        ).with { if (!validate()) { errors.each { println it} } else save()}
    143136                       
     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()}
    144142
    145143                        def c57bl6Term = new Term(
     
    443441                                name: 'Compound', type: TemplateFieldType.STRING,
    444442                                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))
    459443                        .with { if (!validate()) { errors.each { println it} } else save()}
    460444
     
    516500                        exampleStudy.save()
    517501
    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 
    532502                        println ".adding NuGO PPSH example study..."
    533503                        def exampleHumanStudy = new Study(
     
    545515
    546516                        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
    550518                        )
    551519                        .with { if (!validate()) { errors.each { println it} } else save()}
    552520
     521                        evLF.setStartTime(Date.parse('yyyy-MM-dd','2008-01-07'))
     522                        evLF.setEndTime(Date.parse('yyyy-MM-dd','2008-01-14'))
     523
    553524                        evLF.setFieldValue( 'Diet','10% fat (palm oil)' )
    554525                        evLF.save(flush:true)
     
    558529
    559530                        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
    563532                        )
     533                        .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07'))
     534                        .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14'))
    564535                        .setFieldValue( 'Diet','45% fat (palm oil)' )
    565536                        .with { if (!validate()) { errors.each { println it} } else save()}
    566537
    567538                        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
    571540                        )
     541                        .setStartTime( Date.parse('yyyy-MM-dd','2008-01-07'))
     542                        .setEndTime( Date.parse('yyyy-MM-dd','2008-01-14'))
    572543                        .setFieldValue( 'Compound','Vehicle' )
    573544                        .with { if (!validate()) { errors.each { println it} } else save()}
    574545
    575546                        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'))
    580551                        .setFieldValue( 'Compound','Leptin' )
    581552                        .with { if (!validate()) { errors.each { println it} } else save()}
     
    686657
    687658                        def x=1
    688                         12.times {
     659                        40.times {
    689660                                def currentSubject = new Subject(
    690661                                        name: "A" + x++,
     
    713684                                */
    714685
    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() }
    745687                                else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() }
    746688                                else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
    747689                                else             { LFBV1.addToSubjects(currentSubject).save() }
    748                                 */
    749 
    750                                 if (x == 0)      { HFBL1.addToSubjects(currentSubject).save() }
    751                                 else             { LFBV1.addToSubjects(currentSubject).save() }
    752690
    753691                        }
    754 
    755692
    756693                        // Add EventGroups to study
     
    774711                        .save()
    775712                       
     713                        /*
    776714                        println 'Adding PPSH study'
    777715
     
    781719                                code:"PPSH",
    782720                                researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?",
     721                                description:"Human study",
    783722                                ecCode:"unknown",
    784723                                startDate: Date.parse('yyyy-MM-dd','2009-01-01')
     
    786725
    787726                        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']);
    794731
    795732                        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]);
    802737
    803738                        def rootGroup = new EventGroup(name: 'Root group');
     
    806741                        rootGroup.save()
    807742
    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
    831768                        // Add clinical data
    832769
     
    856793                        lipidAssay.addToMeasurements ldlMeasurement
    857794                        lipidAssay.addToMeasurements hdlMeasurement
    858                        
     795
    859796                        def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance(
    860797                                assay: lipidAssay
     
    878815
    879816                        // Add assay to study capture module
     817
    880818                        def clinicalModule = new AssayModule(
    881819                                name: 'Clinical data',
     
    896834                        lipidAssayRef.save()
    897835
    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);
    917837                        humanStudy.save()
     838*/
    918839                }
    919840        }
Note: See TracChangeset for help on using the changeset viewer.