Changeset 370 for trunk/grails-app/conf


Ignore:
Timestamp:
Apr 22, 2010, 9:31:50 AM (13 years ago)
Author:
roberth
Message:

Updated studies list to handle the new data model.
Updated the bootstrap to contain some studies with attached events and persons in order to test the updated studies list
Added fieldExists method to TemplateEntity? to check whether a given field exists or not

File:
1 edited

Legend:

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

    r367 r370  
    4848                        ).with { if (!validate()) { errors.each { println it} } else save()}
    4949
     50                        // Create a few persons, roles and Affiliations
     51                        println ".adding persons, roles and affiliations"
     52                        def affiliation1 = new PersonAffiliation(
     53                            name: "Science Institute NYC"
     54                        ).save();
     55                        def affiliation2 = new PersonAffiliation(
     56                            name: "InfoStats GmbH, Hamburg"
     57                        ).save();
     58                        def role1 = new PersonRole(
     59                            name: "Principal Investigator"
     60                        ).save();
     61                        def role2 = new PersonRole(
     62                            name: "Statician"
     63                        ).save();
     64                        def person1 = new Person(
     65                            lastName: "Scientist",
     66                            firstName: "John",
     67                            midInitials: "R",
     68                            email: "john@scienceinstitute.com",
     69                            phone: "1-555-3049",
     70                            address: "First street 2,NYC"
     71                        )
     72                        .addToAffiliations( affiliation1 )
     73                        .addToAffiliations( affiliation2 )
     74                        .save();
     75                       
     76                        def person2 = new Person(
     77                            lastName: "Statician",
     78                            firstName: "Jane",
     79                            midInitials: "W",
     80                            email: "jane@statisticalcompany.de",
     81                            phone: "49-555-8291",
     82                            address: "Dritten strasse 38, Hamburg, Germany"
     83                        )
     84                        .addToAffiliations( affiliation2 )
     85                        .save();
    5086
    5187 /*   COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL
     
    223259                        def studyTemplate = new Template(
    224260                                name: 'Academic study', entity: dbnp.studycapturing.Study)
    225                                 .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT))
     261                                //.addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT))
    226262                                .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING))
    227263                                .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT))
     
    303339
    304340                        // Human sample template
    305 /* COMMENTED OUT AS IT BREAKS THE WHOLE LOT
    306341                        def humanSampleTemplate = new Template(
    307342                                name: 'Human tissue sample', entity: dbnp.studycapturing.Sample)
     
    363398
    364399
     400                        // Event template
     401                        def dietTreatmentTemplate = new Template(
     402                                name: 'Diet treatment ', entity: dbnp.studycapturing.Event)
     403                        .addToFields(sampleDescriptionField)
     404                        .addToFields(new TemplateField(
     405                                name: 'Diet', type: TemplateFieldType.STRING))
     406                        .with { if (!validate()) { errors.each { println it} } else save()}
     407
     408                        def boostTreatmentTemplate = new Template(
     409                                name: 'Boost treatment ', entity: dbnp.studycapturing.Event)
     410                        .addToFields(sampleDescriptionField)
     411                        .addToFields(new TemplateField(
     412                                name: 'Compound', type: TemplateFieldType.STRING))
     413                        .with { if (!validate()) { errors.each { println it} } else save()}
     414
     415                        /*
    365416                        //events
    366417                        def eventDiet = new EventDescription(
     
    403454
    404455                        println('Adding PPS3 study...')
    405 
     456                        */
    406457                        // studies
    407458                        def exampleStudy = new Study(
     
    410461                                code:"PPS3_leptin_module",
    411462                                researchQuestion:"Leptin etc.",
    412                                 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.",
    413463                                ecCode:"2007117.c",
    414464                                startDate: Date.parse('yyyy-MM-dd','2007-12-11')
    415                         ).with { if (!validate()) { errors.each { println it} } else save()}
     465                        )
     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                        .with { if (!validate()) { errors.each { println it} } else save()}
    416468
    417469                        def exampleHumanStudy = new Study(
     
    420472                                code:"Human example code",
    421473                                researchQuestion:"Leptin etc.",
    422                                 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.",
    423474                                ecCode:"2007117.c",
    424475                                startDate: Date.parse('yyyy-MM-dd','2007-12-11')
    425                         ).with { if (!validate()) { errors.each { println it} } else save()}
     476                        )
     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                        .with { if (!validate()) { errors.each { println it} } else save()}
    426479
    427480                        def evLF = new Event(
    428481                                startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    429482                                endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    430                                 eventDescription: eventDiet,
    431                                 parameterStringValues: ['Diet':'10% fat (palm oil)']
    432                         ).with { if (!validate()) { errors.each { println it} } else save()}
     483                                template: dietTreatmentTemplate
     484                        )
     485                        .setFieldValue( 'Diet','10% fat (palm oil)' )
     486                        .with { if (!validate()) { errors.each { println it} } else save()}
    433487
    434488                        def evHF = new Event(
    435489                                startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    436490                                endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    437                                 eventDescription: eventDiet,
    438                                 parameterStringValues: ['Diet':'45% fat (palm oil)']
    439                         ).with { if (!validate()) { errors.each { println it} } else save()}
     491                                template: dietTreatmentTemplate
     492                        )
     493                        .setFieldValue( 'Diet','45% fat (palm oil)' )
     494                        .with { if (!validate()) { errors.each { println it} } else save()}
    440495
    441496                        def evBV = new Event(
    442497                                startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    443498                                endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    444                                 eventDescription: eventBoost,
    445                                 parameterStringValues: ['Compound':'Vehicle']
    446                         ).with { if (!validate()) { errors.each { println it} } else save()}
     499                                template: boostTreatmentTemplate
     500                        )
     501                        .setFieldValue( 'Compound','Vehicle' )
     502                        .with { if (!validate()) { errors.each { println it} } else save()}
    447503
    448504                        def evBL = new Event(
    449505                                startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    450506                                endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    451                                 eventDescription: eventBoost,
    452                                 parameterStringValues: ['Compound':'Leptin']
    453                         ).with { if (!validate()) { errors.each { println it} } else save()}
    454 
     507                                template: boostTreatmentTemplate
     508                        )
     509                        .setFieldValue( 'Compound','Leptin' )
     510                        .with { if (!validate()) { errors.each { println it} } else save()}
     511
     512                        /*
    455513                        def evLF4 = new Event(
    456514                                startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
     
    494552                                        parameterFloatValues: ['Sample weight':5F]
    495553                        ).with { if (!validate()) { errors.each { println it} } else save()}
     554                        */
    496555
    497556                        // Add events to study
     
    501560                        .addToEvents(evBV)
    502561                        .addToEvents(evBL)
    503                         .addToEvents(evLF4)
     562                        /*
     563                        .addToEvents(evLF4)
    504564                        .addToEvents(evHF4)
    505565                        .addToEvents(evBV4)
     
    507567                        .addToSamplingEvents(evS)
    508568                        .addToSamplingEvents(evS4)
     569                        */
    509570                        .save()
    510571
     
    529590                        .with { if (!validate()) { errors.each { println it} } else save()}
    530591
     592                        /*
    531593                        def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks")
    532594                        .addToEvents(evLF4)
     
    548610                        .addToEvents(evBL4)
    549611                        .with { if (!validate()) { errors.each { println it} } else save()}
     612                        */
    550613
    551614            // Add subjects and samples and compose EventGroups
    552615
    553616                        def x=1
    554                         80.times {
     617                        40.times {
    555618                                def currentSubject = new Subject(
    556619                                        name: "A" + x++,
     
    559622                                )
    560623                                .setFieldValue("Gender", "Male")
    561                                 .setFieldValue("Genotype", c57bl6Term)
     624                                //.setFieldValue("Genotype", c57bl6Term)
    562625                                .setFieldValue("Age (weeks)", 17)
    563626                                .setFieldValue("Cage", "" + (int)(x/2))
     
    568631
    569632                                // Add subject to appropriate EventGroup
    570                                 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() }
     633                                /*
     634                                if (x > 70) { HFBL4.addToSubjects(currentSubject).save() }
    571635                                else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() }
    572636                                else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() }
     
    576640                                else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
    577641                                else             { LFBV1.addToSubjects(currentSubject).save() }
    578 
    579                         }
     642                                */
     643
     644                                if (x > 30) { HFBL1.addToSubjects(currentSubject).save() }
     645                                else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() }
     646                                else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
     647                                else             { LFBV1.addToSubjects(currentSubject).save() }
     648
     649                        }
    580650
    581651                        // Add EventGroups to study
     
    585655                        .addToEventGroups(HFBV1)
    586656                        .addToEventGroups(HFBL1)
    587                         .addToEventGroups(LFBV4)
    588                         .addToEventGroups(LFBL4)
    589                         .addToEventGroups(HFBV4)
    590                         .addToEventGroups(HFBL4)
    591                         .save()
    592 
    593                         println 'Adding PPSH study'
     657                        //.addToEventGroups(LFBV4)
     658                        //.addToEventGroups(LFBL4)
     659                        //.addToEventGroups(HFBV4)
     660                        //.addToEventGroups(HFBL4)
     661
     662                        // Add persons to study
     663                        def studyperson1 = new StudyPerson( person: person1, role: role1 ).save();
     664                        def studyperson2 = new StudyPerson( person: person2, role: role2 ).save();
     665
     666                        exampleStudy
     667                        .addToPersons( studyperson1 )
     668                        .addToPersons( studyperson2 )
     669                        .save()
     670
     671                        /*
     672                        println 'Adding PPSH study'
    594673
    595674                        def humanStudy = new Study(
Note: See TracChangeset for help on using the changeset viewer.