Changeset 754 for trunk/grails-app/conf


Ignore:
Timestamp:
Jul 30, 2010, 3:05:41 PM (13 years ago)
Author:
keesvb
Message:

big refactoring / change of the data model: implemented belongsTo everywhere where it should be, added comments to the domain classes, changed BootStrap? accordingly

File:
1 edited

Legend:

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

    r703 r754  
    167167                        ecCode:"2007117.c",
    168168                        startDate: Date.parse('yyyy-MM-dd','2008-01-02'),
    169                 )
    170                 .with { if (!validate()) { errors.each { println it} } else save()}
     169                ).with { if (!validate()) { errors.each { println it} } else save()}
    171170
    172171                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." )
     
    179178                )
    180179                .setFieldValue( 'Diet','low fat')
    181                 .with { if (!validate()) { errors.each { println it} } else save()}
    182180
    183181                def evHF = new Event(
     
    187185                )
    188186                .setFieldValue( 'Diet','high fat' )
    189                 .with { if (!validate()) { errors.each { println it} } else save()}
    190187
    191188                def evBV = new Event(
     
    195192                )
    196193                .setFieldValue( 'Control','true' )
    197                 .with { if (!validate()) { errors.each { println it} } else save()}
    198194
    199195                def evBL = new Event(
     
    203199                )
    204200                .setFieldValue( 'Control','false' )
    205                 .with { if (!validate()) { errors.each { println it} } else save()}
    206201
    207202                def evLF4 = new Event(
     
    211206                )
    212207                .setFieldValue( 'Diet','low fat')
    213                 .with { if (!validate()) { errors.each { println it} } else save()}
    214208
    215209                def evHF4 = new Event(
     
    219213                )
    220214                .setFieldValue( 'Diet','high fat' )
    221                 .with { if (!validate()) { errors.each { println it} } else save()}
    222215
    223216                def evBV4 = new Event(
     
    227220                )
    228221                .setFieldValue( 'Control','true' )
    229                 .with { if (!validate()) { errors.each { println it} } else save()}
    230222
    231223                def evBL4 = new Event(
     
    235227                )
    236228                .setFieldValue( 'Control','false' )
    237                 .with { if (!validate()) { errors.each { println it} } else save()}
    238229
    239230                def evS = new SamplingEvent(
     
    242233                        template: liverSamplingEventTemplate)
    243234                .setFieldValue('Sample weight',5F)
    244                 .with { if (!validate()) { errors.each { println it} } else save()}
    245235
    246236                def evS4 = new SamplingEvent(
     
    249239                        template: liverSamplingEventTemplate)
    250240                .setFieldValue('Sample weight',5F)
    251                 .with { if (!validate()) { errors.each { println it} } else save()}
    252241
    253242                // Add events to study
     
    263252                .addToSamplingEvents(evS)
    264253                .addToSamplingEvents(evS4)
    265                 .save()
     254                .with { if (!validate()) { errors.each { println it} } else save()}
     255
     256                // Extra check if the SamplingEvents are saved correctly
     257                evS.with { if (!validate()) { errors.each { println it} } else save()}
     258                evS4.with { if (!validate()) { errors.each { println it} } else save()}
    266259
    267260                def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week")
    268261                .addToEvents(evLF)
    269262                .addToEvents(evBV)
    270                 .addToEvents(evS)
    271                 .with { if (!validate()) { errors.each { println it} } else save()}
     263                .addToSamplingEvents(evS)
    272264
    273265                def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week")
    274266                .addToEvents(evLF)
    275267                .addToEvents(evBL)
    276                 .addToEvents(evS)
    277                 .with { if (!validate()) { errors.each { println it} } else save()}
     268                .addToSamplingEvents(evS)
    278269
    279270                def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week")
    280271                .addToEvents(evHF)
    281272                .addToEvents(evBV)
    282                 .addToEvents(evS)
    283                 .with { if (!validate()) { errors.each { println it} } else save()}
     273                .addToSamplingEvents(evS)
    284274
    285275                def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week")
    286276                .addToEvents(evHF)
    287277                .addToEvents(evBL)
    288                 .addToEvents(evS)
    289                 .with { if (!validate()) { errors.each { println it} } else save()}
     278                .addToSamplingEvents(evS)
    290279
    291280                def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks")
    292281                .addToEvents(evLF4)
    293282                .addToEvents(evBV4)
    294                 .addToEvents(evS4)
    295                 .with { if (!validate()) { errors.each { println it} } else save()}
     283                .addToSamplingEvents(evS4)
    296284
    297285                def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks")
    298286                .addToEvents(evLF4)
    299287                .addToEvents(evBL4)
    300                 .addToEvents(evS4)
    301                 .with { if (!validate()) { errors.each { println it} } else save()}
     288                .addToSamplingEvents(evS4)
    302289
    303290                def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks")
    304291                .addToEvents(evHF4)
    305292                .addToEvents(evBV4)
    306                 .addToEvents(evS4)
    307                 .with { if (!validate()) { errors.each { println it} } else save()}
     293                .addToSamplingEvents(evS4)
    308294
    309295                def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks")
    310296                .addToEvents(evHF4)
    311297                .addToEvents(evBL4)
    312                 .addToEvents(evS4)
    313                 .with { if (!validate()) { errors.each { println it} } else save()}
    314 
     298                .addToSamplingEvents(evS4)
     299               
    315300        // Add subjects and samples and compose EventGroups
    316301                def x=1
    317                 20.times {
     302                80.times {
    318303                        def currentSubject = new Subject(
    319304                                name: "A" + x++,
     
    325310                        .setFieldValue("Age", 17)
    326311                        .setFieldValue("Cage", "" + (int)(x/2))
    327                         .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
    328312
    329313                        mouseStudy.addToSubjects(currentSubject)
     
    344328                                name: currentSubject.name + '_B',
    345329                                material: bloodTerm,
    346                                         template: humanBloodSampleTemplate,
     330                                template: humanBloodSampleTemplate,
    347331                                parentSubject: currentSubject,
    348332                                parentEvent: x > 40 ? evS4 : evS
    349333                        );
    350                         currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
    351 
     334                        currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
    352335                        mouseStudy.addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()}
    353336                }
     
    363346                .addToEventGroups(HFBV4)
    364347                .addToEventGroups(HFBL4)
     348                .with { if (!validate()) { errors.each { println it} } else save()}
    365349
    366350                // Add persons and publications to study
    367                 def studyperson1 = new StudyPerson( person: person1, role: role1 ).save();
    368                 def studyperson2 = new StudyPerson( person: person2, role: role2 ).save();
     351                def studyperson1 = new StudyPerson( person: person1, role: role1 )
     352                def studyperson2 = new StudyPerson( person: person2, role: role2 )
    369353
    370354                mouseStudy
     
    373357        .addToPublications( publication1 )
    374358        .addToPublications( publication2 )
    375                 .save()
     359                .with { if (!validate()) { errors.each { println it} } else save()}
    376360
    377361                // Add example human study
     
    406390
    407391                rootGroup.addToEvents fastingEvent
    408                 rootGroup.addToEvents bloodSamplingEvent
     392                rootGroup.addToSamplingEvents bloodSamplingEvent
    409393                rootGroup.save()
    410394
     
    422406                        .setFieldValue("Weight", Math.random() * 150F)
    423407                        .setFieldValue("BMI", 20 + Math.random() * 10F)
    424                         .with { if (!validate()) { errors.each { println it} } else save()}
    425408
    426409                        rootGroup.addToSubjects currentSubject
    427                          rootGroup.save()
     410                        rootGroup.save()
    428411
    429412                        def currentSample = new Sample(
    430413                                name: currentSubject.name + '_B',
    431414                                material: bloodTerm,
    432                                         template: humanBloodSampleTemplate,
     415                                template: humanBloodSampleTemplate,
    433416                                parentSubject: currentSubject,
    434417                                parentEvent: bloodSamplingEvent
    435418                        );
    436                                 currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
    437 
    438                         humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()}
     419                        currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
     420
     421                        humanStudy.addToSubjects(currentSubject).addToSamples(currentSample)
     422                        .with { if (!validate()) { errors.each { println it} } else save()}
    439423                }
    440424
     
    445429
    446430                // Add persons to study
    447                 def studyperson3 = new StudyPerson( person: person1, role: role2 ).save();
     431                def studyperson3 = new StudyPerson( person: person1, role: role2 )
    448432
    449433                humanStudy
    450434                .addToPersons( studyperson3 )
    451                         .addToPublications( publication2 )
    452                 .save()
     435                .addToPublications( publication2 )
     436                .with { if (!validate()) { errors.each { println it} } else save()}
    453437
    454438                // Add clinical data       ==> to be moved to SAM
     
    519503                }
    520504
    521                 mouseStudy.addToAssays(lipidAssayRef);
     505                mouseStudy.addToAssays(lipidAssayRef);
    522506                mouseStudy.save()
    523507
Note: See TracChangeset for help on using the changeset viewer.