Changeset 421 for trunk/grails-app/conf


Ignore:
Timestamp:
May 17, 2010, 3:26:48 PM (13 years ago)
Author:
keesvb
Message:

cleaned up BootStrap? and re-added Samples, updated study/show to also show sampling events in EventGroups?, added description field for Templates

File:
1 edited

Legend:

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

    r408 r421  
    2424                        println ".development bootstrapping...";
    2525
    26                         // add NCBI species ontology
     26                        // add Subject>species ontology
    2727                        println ".adding NCBI species ontology"
    2828                        def speciesOntology = new Ontology(
     
    3535                        ).with { if (!validate()) { errors.each { println it} } else save()}
    3636
     37                        // add Sample>material ontology
    3738                        println ".adding BRENDA source material ontology"
    3839                        def brendaOntology = new Ontology(
     
    4546                        ).with { if (!validate()) { errors.each { println it} } else save()}
    4647
    47                         // add TERMS
     48                        // add NCI ontology which is used in Mouse genotype template field
     49                        def nciOntology = new Ontology(
     50                                name: 'NCI Thesaurus',
     51                                description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.',
     52                                url: 'http://ncicb.nci.nih.gov/core/EVS',
     53                                versionNumber: '10.01',
     54                                ncboId: '1032',
     55                                ncboVersionedId: '42693'
     56                        ).with { if (!validate()) { errors.each { println it} } else save()}
     57                       
     58                        // add Terms
    4859                        println ".adding mouse term"
    4960                        def mouseTerm = new Term(
     
    5869                                accession: '9606'
    5970                        ).with { if (!validate()) { errors.each { println it} } else save()}
    60 
    61                         // Create a few persons, roles and Affiliations
    62                         println ".adding persons, roles and affiliations"
    63                         def affiliation1 = new PersonAffiliation(
    64                             name: "Science Institute NYC"
    65                         ).save();
    66                         def affiliation2 = new PersonAffiliation(
    67                             name: "InfoStats GmbH, Hamburg"
    68                         ).save();
    69                         def role1 = new PersonRole(
    70                             name: "Principal Investigator"
    71                         ).save();
    72                         def role2 = new PersonRole(
    73                             name: "Statician"
    74                         ).save();
    75 
    76                         // Create 30 roles to test pagination
    77                         def roleCounter = 1;
    78                         30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() }
    79 
    80                         // Create persons
    81                         def person1 = new Person(
    82                             lastName: "Scientist",
    83                             firstName: "John",
    84                             gender: "Male",
    85                             initials: "J.R.",
    86                             email: "john@scienceinstitute.com",
    87                             phone: "1-555-3049",
    88                             address: "First street 2,NYC"
    89                         )
    90                         .addToAffiliations( affiliation1 )
    91                         .addToAffiliations( affiliation2 )
    92                         .save();
    93                        
    94                         def person2 = new Person(
    95                             lastName: "Statician",
    96                             firstName: "Jane",
    97                             gender: "Female",
    98                             initials: "W.J.",
    99                             email: "jane@statisticalcompany.de",
    100                             phone: "49-555-8291",
    101                             address: "Dritten strasse 38, Hamburg, Germany"
    102                         )
    103                         .addToAffiliations( affiliation2 )
    104                         .save();
    105 
    106                         // Create 30 persons to test pagination
    107                         def personCounter = 1;
    108                         30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() }
    109 
    110  /*   COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL
    111 
    112                         // ontologies
    113                         def speciesOntology = new Ontology(
    114                                 name: 'NCBI Taxonomy',
    115                                 shortName: 'Taxon',
    116                                 url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy'
    117                         ).with { if (!validate()) { errors.each { println it} } else save()}
    118 
    119                         def humanBodyOntology = new Ontology(
    120                                 name: 'Foundational Model of Anatomy',
    121                                 shortName: 'HumanBody',
    122                                 url: 'http://bioportal.bioontology.org/ontologies/39966'
    123                         ).with { if (!validate()) { errors.each { println it} } else save()}
    124 
    125                         def nciOntology = new Ontology(
    126                                 name: 'NCI Thesaurus',
    127                                 shortName: 'NCI',
    128                                 url: 'http://bioportal.bioontology.org/ontologies/42331'
    129                         ).with { if (!validate()) { errors.each { println it} } else save()}
    130 
    131                         // terms
    132                         def mouseTerm = new Term(
    133                                 name: 'Mus musculus',
    134                                 ontology: speciesOntology,
    135                                 accession: '10090'
    136                         ).with { if (!validate()) { errors.each { println it} } else save()}
    137                         def humanTerm = new Term(
    138                                 name: 'Homo sapiens',
    139                                 ontology: speciesOntology,
    140                                 accession: '9606'
    141                         ).with { if (!validate()) { errors.each { println it} } else save()}
    14271                        def arabTerm = new Term(
    14372                                name: 'Arabidopsis thaliana',
     
    14574                                accession: '3702'
    14675                        ).with { if (!validate()) { errors.each { println it} } else save()}
    147                        
     76
    14877                        def bloodTerm = new Term(
    149                                 name: 'Portion of blood',
    150                                 ontology: humanBodyOntology,
    151                                 accession: '9670'
     78                                name: 'blood plasma',
     79                                ontology: brendaOntology,
     80                                accession: 'BTO:0000131'
    15281                        ).with { if (!validate()) { errors.each { println it} } else save()}
    15382
     
    15887                        ).with { if (!validate()) { errors.each { println it} } else save()}
    15988
    160                         def madmaxOntology = new Ontology(
    161                                 name: 'Madmax ontology',
    162                                 shortName: 'MDMX',
    163                                 url: 'madmax.bioinformatics.nl'
    164                         ).with { if (!validate()) { errors.each { println it} } else save()}
    165 
    166                         def treatmentTerm = new Term(
    167                                 name: 'ExperimentalProtocol',
    168                                 ontology: madmaxOntology,
    169                                 accession: 'P-MDMXGE-264'
    170                         ).with { if (!validate()) { errors.each { println it} } else save()}
    171 
    172                         def dietProtocol = new Protocol(
    173                                 name: 'Diet treatment Protocol NuGO PPS3 leptin module',
    174                                 reference: treatmentTerm
    175                         ).with { if (!validate()) { errors.each { println it} } else save()}
    176 
    177                         def boostProtocol = new Protocol(
    178                                 name: 'Boost treatment Protocol NuGO PPS3 leptin module',
    179                                 reference: treatmentTerm
    180                         ).with { if (!validate()) { errors.each { println it} } else save()}
    181 
    182                         def fastingProtocol = new Protocol(
    183                                 name: 'Fasting',
    184                                 reference: treatmentTerm
    185                         ).with { if (!validate()) { errors.each { println it} } else save()}
    186 
    187 
    188                         // ParameterStringListItems
    189                         def oil10= new ParameterStringListItem(
    190                                 name: '10% fat (palm oil)'
    191                         ).with { if (!validate()) { errors.each { println it} } else save()}
    192                         def oil45= new ParameterStringListItem(
    193                                 name: '45% fat (palm oil)'
    194                         ).with { if (!validate()) { errors.each { println it} } else save()}
    195                         def vehicle= new ParameterStringListItem(
    196                                 name: 'Vehicle'
    197                         ).with { if (!validate()) { errors.each { println it} } else save()}
    198                         def leptin= new ParameterStringListItem(
    199                                 name: 'Leptin'
    200                         ).with { if (!validate()) { errors.each { println it} } else save()}
    201 
    202 
    203                         dietProtocol
    204                         .addToParameters(new ProtocolParameter(
    205                                 name: 'Diet',
    206                                 type: ProtocolParameterType.STRINGLIST,
    207                                 listEntries: [oil10,oil45]))
    208                         .save()
    209 
    210                         boostProtocol
    211                         .addToParameters(new ProtocolParameter(
    212                                 name: 'Compound',
    213                                 type: ProtocolParameterType.STRINGLIST,
    214                                 listEntries: [vehicle,leptin]))
    215                         .save()
    216 
    217                         fastingProtocol
    218                         .addToParameters(new ProtocolParameter(
    219                                 name: 'Fasting period',
    220                                 type: ProtocolParameterType.STRING))
    221                         .save()
    222 
    223 
    224                         // sampling event protocols
    225 
    226                         def liverSamplingProtocol = new Protocol(
    227                                 name: 'Liver sampling'
    228                         ).with { if (!validate()) { errors.each { println it} } else save()}
    229 
    230                         liverSamplingProtocol
    231                         .addToParameters(new ProtocolParameter(
    232                                 name: 'Sample weight',
    233                                 unit: 'mg',
    234                                 type: ProtocolParameterType.FLOAT))
    235                         .save()
    236 
    237                         def bloodSamplingProtocol = new Protocol(
    238                                 name: 'Blood sampling'
    239                         ).with { if (!validate()) { errors.each { println it} } else save()}
    240 
    241                         bloodSamplingProtocol
    242                         .addToParameters(new ProtocolParameter(
    243                                 name: 'Sample volume',
    244                                 unit: 'ml',
    245                                 type: ProtocolParameterType.FLOAT))
    246                         .save()
    247  */
    248                         // create system user
    249 
    250                         /*def systemUser = userService.createUser(InstanceGenerator.user(
    251                                 username: 'system',
    252                                 pass: 'system',
    253                                 passConfirm: 'system',
    254                                 enabled: true
    255                         ))*/
    256 
    257  
     89                        // Create a few persons, roles and Affiliations
     90                        println ".adding persons, roles and affiliations"
     91                        def affiliation1 = new PersonAffiliation(
     92                            name: "Science Institute NYC"
     93                        ).save();
     94                        def affiliation2 = new PersonAffiliation(
     95                            name: "InfoStats GmbH, Hamburg"
     96                        ).save();
     97                        def role1 = new PersonRole(
     98                            name: "Principal Investigator"
     99                        ).save();
     100                        def role2 = new PersonRole(
     101                            name: "Statician"
     102                        ).save();
     103
     104                        // Create 30 roles to test pagination
     105                        def roleCounter = 1;
     106                        30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() }
     107
     108                        // Create persons
     109                        def person1 = new Person(
     110                            lastName: "Scientist",
     111                            firstName: "John",
     112                            gender: "Male",
     113                            initials: "J.R.",
     114                            email: "john@scienceinstitute.com",
     115                            phone: "1-555-3049",
     116                            address: "First street 2,NYC"
     117                        )
     118                        .addToAffiliations( affiliation1 )
     119                        .addToAffiliations( affiliation2 )
     120                        .save();
     121
     122                        def person2 = new Person(
     123                            lastName: "Statician",
     124                            firstName: "Jane",
     125                            gender: "Female",
     126                            initials: "W.J.",
     127                            email: "jane@statisticalcompany.de",
     128                            phone: "49-555-8291",
     129                            address: "Dritten strasse 38, Hamburg, Germany"
     130                        )
     131                        .addToAffiliations( affiliation2 )
     132                        .save();
     133
     134                        // Create 30 persons to test pagination
     135                        def personCounter = 1;
     136                        30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() }
     137
     138                        // Create templates
     139
    258140                        def genderField = new TemplateField(
    259141                                name: 'Gender',type: TemplateFieldType.STRINGLIST,
     
    442324                        .with { if (!validate()) { errors.each { println it} } else save()}
    443325
    444                         /*
    445                         //events
    446                         def eventDiet = new EventDescription(
    447                                 name: 'Diet treatment',
    448                                 description: 'Diet treatment (fat percentage)',
    449                                 classification: treatmentTerm,
    450                                 protocol: dietProtocol,
    451                                 isSamplingEvent: false
    452                         ).with { if (!validate()) { errors.each { println it} } else save()}
    453 
    454                         def eventBoost = new EventDescription(
    455                                 name: 'Boost treatment',
    456                                 description: 'Boost treatment (leptin or vehicle)',
    457                                 classification: treatmentTerm,
    458                                 protocol: boostProtocol,
    459                                 isSamplingEvent: false
    460                         ).with { if (!validate()) { errors.each { println it} } else save()}
    461 
    462                         def samplingEvent = new EventDescription(
     326                        def fastingTreatment = new Template(
     327                                 name: 'Fasting treatment',
     328                                 description: 'Fasting Protocol NuGO PPSH',
     329                                 entity: dbnp.studycapturing.Event)
     330                         .addToFields(new TemplateField(
     331                                 name: 'Fasting period',
     332                                 type: TemplateFieldType.STRING))
     333                         .with { if (!validate()) { errors.each { println it} } else save()}
     334
     335                        // SamplingEvent templates
     336
     337                        def liverSamplingEventTemplate = new Template(
    463338                                name: 'Liver extraction',
    464339                                description: 'Liver sampling for transcriptomics arrays',
    465                                 protocol: liverSamplingProtocol,
    466                                 isSamplingEvent: true
    467                         ).with { if (!validate()) { errors.each { println it} } else save()}
    468 
    469                         def bloodSamplingEventDescription = new EventDescription(
     340                                entity: dbnp.studycapturing.SamplingEvent)
     341                        .addToFields(new TemplateField(
     342                                name: 'Sample weight',
     343                                unit: 'mg',
     344                                type: TemplateFieldType.FLOAT))
     345                        .with { if (!validate()) { errors.each { println it} } else save()}
     346
     347                        def bloodSamplingEventTemplate = new Template(
    470348                                name: 'Blood extraction',
    471349                                description: 'Blood extraction targeted at lipid assays',
    472                                 protocol: bloodSamplingProtocol,
    473                                 isSamplingEvent: true
    474                         ).with { if (!validate()) { errors.each { println it} } else save()}
    475 
    476 
    477             def fastingTreatment = new EventDescription(
    478                                 name: 'Fasting treatment',
    479                                 description: 'Fasting Protocol NuGO PPSH',
    480                                 protocol: fastingProtocol,
    481                                 isSamplingEvent: false
    482                         ).with { if (!validate()) { errors.each { println it} } else save()}
    483 
    484                         println('Adding PPS3 study...')
    485                         */
    486                         // studies
     350                                entity: dbnp.studycapturing.SamplingEvent)
     351                        .addToFields(new TemplateField(
     352                                name: 'Sample volume',
     353                                unit: 'ml',
     354                                type: TemplateFieldType.FLOAT))
     355                        .with { if (!validate()) { errors.each { println it} } else save()}
     356
     357
     358                        // Add example studies
    487359                        if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) {
    488360                                println ".adding NuGO PPS3 leptin example study..."
    489                                 def exampleStudy = new Study(
     361                                def mouseStudy = new Study(
    490362                                        template: studyTemplate,
    491363                                        title:"NuGO PPS3 mouse study leptin module",
     
    497369                                .with { if (!validate()) { errors.each { println it} } else save()}
    498370
    499                                 exampleStudy.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." )
    500                                 exampleStudy.save()
    501 
    502                                 println ".adding NuGO PPSH example study..."
    503                                 def exampleHumanStudy = new Study(
    504                                         template: studyTemplate,
    505                                         title:"Human example template",
    506                                         code:"Human example code",
    507                                         researchQuestion:"Leptin etc.",
    508                                         ecCode:"2007117.c",
    509                                         startDate: Date.parse('yyyy-MM-dd','2007-12-11')
    510                                 )
    511                                 .with { if (!validate()) { errors.each { println it} } else save()}
    512 
    513                                 exampleHumanStudy.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." )
    514                                 exampleHumanStudy.save()
     371                                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." )
     372                                mouseStudy.save()
    515373
    516374                                def evLF = new Event(
     
    519377                                        template: dietTreatmentTemplate
    520378                                )
    521                                 .with { if (!validate()) { errors.each { println it} } else save()}
    522                                 evLF.setFieldValue( 'Diet','10% fat (palm oil)' )
    523                                 evLF.save(flush:true)
     379                                .setFieldValue( 'Diet','10% fat (palm oil)')
     380                                .with { if (!validate()) { errors.each { println it} } else save()}
    524381
    525382                                def evHF = new Event(
     
    547404                                .with { if (!validate()) { errors.each { println it} } else save()}
    548405
    549                                 /*
    550406                                def evLF4 = new Event(
    551407                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    552408                                        endTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    553                                         eventDescription: eventDiet,
    554                                         parameterStringValues: ['Diet':'10% fat (palm oil)']
    555                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     409                                        template: dietTreatmentTemplate
     410                                )
     411                                .setFieldValue( 'Diet','10% fat (palm oil)')
     412                                .with { if (!validate()) { errors.each { println it} } else save()}
    556413
    557414                                def evHF4 = new Event(
    558415                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    559416                                        endTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    560                                         eventDescription: eventDiet,
    561                                         parameterStringValues: ['Diet':'45% fat (palm oil)']
    562                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     417                                        template: dietTreatmentTemplate
     418                                )
     419                                .setFieldValue( 'Diet','45% fat (palm oil)' )
     420                                .with { if (!validate()) { errors.each { println it} } else save()}
    563421
    564422                                def evBV4 = new Event(
    565423                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    566424                                        endTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    567                                         eventDescription: eventBoost,
    568                                         parameterStringValues: ['Compound':'Vehicle']
    569                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     425                                        template: boostTreatmentTemplate
     426                                )
     427                                .setFieldValue( 'Compound','Vehicle' )
     428                                .with { if (!validate()) { errors.each { println it} } else save()}
    570429
    571430                                def evBL4 = new Event(
    572431                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
    573432                                        endTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    574                                         eventDescription: eventBoost,
    575                                         parameterStringValues: ['Compound':'Leptin']
    576                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     433                                        template: boostTreatmentTemplate
     434                                )
     435                                .setFieldValue( 'Compound','Leptin' )
     436                                .with { if (!validate()) { errors.each { println it} } else save()}
    577437
    578438                                def evS = new SamplingEvent(
    579                                                 startTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    580                                                 endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    581                                                 eventDescription: samplingEvent,
    582                                                 parameterFloatValues: ['Sample weight':5F]
    583                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     439                                        startTime: Date.parse('yyyy-MM-dd','2008-01-14'),
     440                                        endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
     441                                        template: liverSamplingEventTemplate)
     442                                .setFieldValue('Sample weight',5F)
     443                                .with { if (!validate()) { errors.each { println it} } else save()}
    584444
    585445                                def evS4 = new SamplingEvent(
    586                                                 startTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    587                                                 endTime: Date.parse('yyyy-MM-dd','2008-02-04'),
    588                                                 eventDescription: samplingEvent,
    589                                                 parameterFloatValues: ['Sample weight':5F]
    590                                 ).with { if (!validate()) { errors.each { println it} } else save()}
    591                                 */
     446                                        startTime: Date.parse('yyyy-MM-dd','2008-01-14'),
     447                                        endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
     448                                        template: liverSamplingEventTemplate)
     449                                .setFieldValue('Sample weight',5F)
     450                                .with { if (!validate()) { errors.each { println it} } else save()}
    592451
    593452                                // Add events to study
    594                                 exampleStudy
     453                                mouseStudy
    595454                                .addToEvents(evLF)
    596455                                .addToEvents(evHF)
    597456                                .addToEvents(evBV)
    598457                                .addToEvents(evBL)
    599                                 /*
    600458                                .addToEvents(evLF4)
    601459                                .addToEvents(evHF4)
     
    604462                                .addToSamplingEvents(evS)
    605463                                .addToSamplingEvents(evS4)
    606                                 */
    607464                                .save()
    608465
     
    610467                                .addToEvents(evLF)
    611468                                .addToEvents(evBV)
     469                                .addToEvents(evS)
    612470                                .with { if (!validate()) { errors.each { println it} } else save()}
    613471
     
    615473                                .addToEvents(evLF)
    616474                                .addToEvents(evBL)
     475                                .addToEvents(evS)
    617476                                .with { if (!validate()) { errors.each { println it} } else save()}
    618477
     
    620479                                .addToEvents(evHF)
    621480                                .addToEvents(evBV)
     481                                .addToEvents(evS)
    622482                                .with { if (!validate()) { errors.each { println it} } else save()}
    623483
     
    625485                                .addToEvents(evHF)
    626486                                .addToEvents(evBL)
    627                                 .with { if (!validate()) { errors.each { println it} } else save()}
    628 
    629                                 /*
     487                                .addToEvents(evS)
     488                                .with { if (!validate()) { errors.each { println it} } else save()}
     489
    630490                                def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks")
    631491                                .addToEvents(evLF4)
    632492                                .addToEvents(evBV4)
     493                                .addToEvents(evS4)
    633494                                .with { if (!validate()) { errors.each { println it} } else save()}
    634495
     
    636497                                .addToEvents(evLF4)
    637498                                .addToEvents(evBL4)
     499                                .addToEvents(evS4)
    638500                                .with { if (!validate()) { errors.each { println it} } else save()}
    639501
     
    641503                                .addToEvents(evHF4)
    642504                                .addToEvents(evBV4)
     505                                .addToEvents(evS4)
    643506                                .with { if (!validate()) { errors.each { println it} } else save()}
    644507
     
    646509                                .addToEvents(evHF4)
    647510                                .addToEvents(evBL4)
    648                                 .with { if (!validate()) { errors.each { println it} } else save()}
    649                                 */
    650 
    651                     // Add subjects and samples and compose EventGroups
    652 
     511                                .addToEvents(evS4)
     512                                .with { if (!validate()) { errors.each { println it} } else save()}
     513
     514                                // Add subjects and samples and compose EventGroups
    653515                                def x=1
    654                                 40.times {
     516                                80.times {
    655517                                        def currentSubject = new Subject(
    656518                                                name: "A" + x++,
     
    659521                                        )
    660522                                        .setFieldValue("Gender", "Male")
    661                                         //.setFieldValue("Genotype", c57bl6Term)
     523                                        .setFieldValue("Genotype", c57bl6Term)
    662524                                        .setFieldValue("Age (weeks)", 17)
    663525                                        .setFieldValue("Cage", "" + (int)(x/2))
    664526                                        .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
    665527
    666                                         exampleStudy.addToSubjects(currentSubject)
     528                                        mouseStudy.addToSubjects(currentSubject)
    667529                                        .with { if (!validate()) { errors.each { println it} } else save()}
    668530
    669531                                        // Add subject to appropriate EventGroup
    670                                         /*
    671532                                        if (x > 70) { HFBL4.addToSubjects(currentSubject).save() }
    672533                                        else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() }
     
    677538                                        else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
    678539                                        else             { LFBV1.addToSubjects(currentSubject).save() }
    679                                         */
    680 
    681                                         if (x > 30) { HFBL1.addToSubjects(currentSubject).save() }
    682                                         else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() }
    683                                         else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
    684                                         else             { LFBV1.addToSubjects(currentSubject).save() }
    685540
    686541                                }
    687542
    688543                                // Add EventGroups to study
    689                                 exampleStudy
     544                                mouseStudy
    690545                                .addToEventGroups(LFBV1)
    691546                                .addToEventGroups(LFBL1)
    692547                                .addToEventGroups(HFBV1)
    693548                                .addToEventGroups(HFBL1)
    694                                 //.addToEventGroups(LFBV4)
    695                                 //.addToEventGroups(LFBL4)
    696                                 //.addToEventGroups(HFBV4)
    697                                 //.addToEventGroups(HFBL4)
     549                                .addToEventGroups(LFBV4)
     550                                .addToEventGroups(LFBL4)
     551                                .addToEventGroups(HFBV4)
     552                                .addToEventGroups(HFBL4)
    698553
    699554                                // Add persons to study
     
    701556                                def studyperson2 = new StudyPerson( person: person2, role: role2 ).save();
    702557
    703                                 exampleStudy
     558                                mouseStudy
    704559                                .addToPersons( studyperson1 )
    705560                                .addToPersons( studyperson2 )
    706561                                .save()
    707562
    708 
    709                                 /*
    710                                 println 'Adding PPSH study'
     563                                println ".adding NuGO PPSH example study..."
    711564
    712565                                def humanStudy = new Study(
     
    717570                                        description:"Human study",
    718571                                        ecCode:"unknown",
    719                                         startDate: Date.parse('yyyy-MM-dd','2009-01-01')
    720                                 ).with { if (!validate()) { errors.each { println it} } else save()}
     572                                        startDate: Date.parse('yyyy-MM-dd','2008-01-14'))
     573                                .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." )
     574                                .with { if (!validate()) { errors.each { println it} } else save()}
     575
     576                                def rootGroup = new EventGroup(name: 'Root group');
    721577
    722578                                def fastingEvent = new Event(
    723                                                 startTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    724                                                 endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    725                                                 eventDescription: fastingTreatment,
    726                                                 parameterStringValues: ['Fasting period':'8h']);
     579                                        startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-14 22:00'),
     580                                        endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'),
     581                                        template: fastingTreatment)
     582                                .setFieldValue('Fasting period','8h');
     583
    727584
    728585                                def bloodSamplingEvent = new SamplingEvent(
    729                                                 startTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    730                                                 endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
    731                                                 eventDescription: bloodSamplingEventDescription,
    732                                                 parameterFloatValues: ['Sample volume':4.5F]);
    733 
    734                                 def rootGroup = new EventGroup(name: 'Root group');
     586                                        startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'),
     587                                        endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'),
     588                                        template: bloodSamplingEventTemplate)
     589                                .setFieldValue('Sample volume',4.5F);
     590
    735591                                rootGroup.addToEvents fastingEvent
    736592                                rootGroup.addToEvents bloodSamplingEvent
    737593                                rootGroup.save()
    738594
    739                     def y = 1
    740                     11.times {
    741                       def currentSubject = new Subject(
    742                               name: "" + y++,
    743                               species: humanTerm,
    744                               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()}
    745 
    746                       rootGroup.addToSubjects currentSubject
    747                       rootGroup.save()
    748 
    749                       def currentSample = new Sample(
    750                               name: currentSubject.name + '_B',
    751                               material: bloodTerm,
    752                               parentSubject: currentSubject,
    753                               parentEvent: bloodSamplingEvent);
    754 
    755 
    756                       humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()}
    757                   }
    758 
    759                   humanStudy.addToEvents(fastingEvent)
    760                   humanStudy.addToSamplingEvents(bloodSamplingEvent)
    761                   humanStudy.addToEventGroups rootGroup
    762                   humanStudy.save()
    763 
     595                                def y = 1
     596                                11.times {
     597                                        def currentSubject = new Subject(
     598                                              name: "" + y++,
     599                                              species: humanTerm,
     600                                              template: humanTemplate)
     601                                        .setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female")
     602                                        .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80))))
     603                                        .setFieldValue("Age (years)", 30)
     604                                        .setFieldValue("Height", Math.random() * 2F)
     605                                        .setFieldValue("Weight (kg)", Math.random() * 150F)
     606                                        .setFieldValue("BMI", 20 + Math.random() * 10F)
     607                                        .with { if (!validate()) { errors.each { println it} } else save()}
     608
     609                                        rootGroup.addToSubjects currentSubject
     610                                        rootGroup.save()
     611
     612                                        def currentSample = new Sample(
     613                                              name: currentSubject.name + '_B',
     614                                              material: bloodTerm,
     615                                              parentSubject: currentSubject,
     616                                              parentEvent: bloodSamplingEvent);
     617
     618                                        humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()}
     619                                }
     620
     621                                humanStudy.addToEvents(fastingEvent)
     622                                humanStudy.addToSamplingEvents(bloodSamplingEvent)
     623                                humanStudy.addToEventGroups rootGroup
     624                                humanStudy.save()
     625
     626                                /*
    764627                                // Add clinical data
    765628
     
    833696                                humanStudy.save()
    834697                                */
     698                               
    835699                        }
    836700                }
Note: See TracChangeset for help on using the changeset viewer.