Changeset 1245


Ignore:
Timestamp:
Dec 9, 2010, 2:51:51 PM (12 years ago)
Author:
work@…
Message:
  • moved 'description' from study template fields into domain variables so that every study will contain a -non required- description which is more logical
Location:
trunk/grails-app
Files:
7 edited

Legend:

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

    r1178 r1245  
    2323         * Add example studies. This function is meant to be called only in development mode
    2424         */
    25         public static void addExampleStudies(dbnp.authentication.SecUser owner, dbnp.authentication.SecUser otherUser ) {
     25        public static void addExampleStudies(dbnp.authentication.SecUser owner, dbnp.authentication.SecUser otherUser) {
    2626                "inserting initial studies".grom()
    2727
     
    3030
    3131                // Look up the used ontologies which should be in the database by now
    32                 def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132)
    33                 def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005)
    34                 def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032)
    35                 def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007)
     32                def speciesOntology                             = Ontology.getOrCreateOntologyByNcboId(1132)
     33                def brendaOntology                              = Ontology.getOrCreateOntologyByNcboId(1005)
     34                def nciOntology                                 = Ontology.getOrCreateOntologyByNcboId(1032)
     35                def chebiOntology                               = Ontology.getOrCreateOntologyByNcboId(1007)
    3636
    3737                // Look up the used templates which should also be in the database by now
    38                 def studyTemplate = Template.findByName("Academic study")
    39                 def mouseTemplate = Template.findByName("Mouse")
    40                 def humanTemplate = Template.findByName("Human")
    41                 def dietTreatmentTemplate = Template.findByName("Diet treatment")
    42                 def boostTreatmentTemplate = Template.findByName("Compound challenge")
    43                 def liverSamplingEventTemplate = Template.findByName("Liver extraction")
    44                 def fastingTreatmentTemplate = Template.findByName("Fasting treatment")
    45                 def bloodSamplingEventTemplate = Template.findByName("Blood extraction")
    46                 def humanTissueSampleTemplate = Template.findByName("Human tissue sample")
    47                 def humanBloodSampleTemplate = Template.findByName("Human blood sample")
    48                 def ccAssayTemplate = Template.findByName("Clinical chemistry assay")
    49                 def metAssayTemplate = Template.findByName("Metabolomics assay")
     38                def studyTemplate                               = Template.findByName("Academic study")
     39                def mouseTemplate                               = Template.findByName("Mouse")
     40                def humanTemplate                               = Template.findByName("Human")
     41                def dietTreatmentTemplate               = Template.findByName("Diet treatment")
     42                def boostTreatmentTemplate              = Template.findByName("Compound challenge")
     43                def liverSamplingEventTemplate  = Template.findByName("Liver extraction")
     44                def fastingTreatmentTemplate    = Template.findByName("Fasting treatment")
     45                def bloodSamplingEventTemplate  = Template.findByName("Blood extraction")
     46                def humanTissueSampleTemplate   = Template.findByName("Human tissue sample")
     47                def humanBloodSampleTemplate    = Template.findByName("Human blood sample")
     48                def ccAssayTemplate                             = Template.findByName("Clinical chemistry assay")
     49                def metAssayTemplate                    = Template.findByName("Metabolomics assay")
    5050
    5151                // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website
    5252                def mouseTerm = new Term(
    53                         name: 'Mus musculus',
    54                         ontology: speciesOntology,
    55                         accession: '10090'
     53                        name            : 'Mus musculus',
     54                        ontology        : speciesOntology,
     55                        accession       : '10090'
    5656                ).with { if (!validate()) { errors.each { println it} } else save()}
    5757
    5858                def humanTerm = new Term(
    59                         name: 'Homo sapiens',
    60                         ontology: speciesOntology,
    61                         accession: '9606'
     59                        name            : 'Homo sapiens',
     60                        ontology        : speciesOntology,
     61                        accession       : '9606'
    6262                ).with { if (!validate()) { errors.each { println it} } else save()}
    6363
    6464                def arabTerm = new Term(
    65                         name: 'Arabidopsis thaliana',
    66                         ontology: speciesOntology,
    67                         accession: '3702'
     65                        name            : 'Arabidopsis thaliana',
     66                        ontology        : speciesOntology,
     67                        accession       : '3702'
    6868                ).with { if (!validate()) { errors.each { println it} } else save()}
    6969
    7070                def tomatoTerm = new Term(
    71                         name: 'Solanum lycopersicum',
    72                         ontology: speciesOntology,
    73                         accession: '4081'
     71                        name            : 'Solanum lycopersicum',
     72                        ontology        : speciesOntology,
     73                        accession       : '4081'
    7474                ).with { if (!validate()) { errors.each { println it} } else save()}
    7575
    7676                def potatoTerm = new Term(
    77                         name: 'Solanum tuberosum',
    78                         ontology: speciesOntology,
    79                         accession: '0000'
     77                        name            : 'Solanum tuberosum',
     78                        ontology        : speciesOntology,
     79                        accession       : '0000'
    8080                ).with { if (!validate()) { errors.each { println it} } else save()}
    8181
    8282                def bloodTerm = new Term(
    83                         name: 'blood plasma',
    84                         ontology: brendaOntology,
    85                         accession: 'BTO:0000131'
     83                        name            : 'blood plasma',
     84                        ontology        : brendaOntology,
     85                        accession       : 'BTO:0000131'
    8686                ).with { if (!validate()) { errors.each { println it} } else save()}
    8787
    8888                def c57bl6Term = new Term(
    89                         name: 'C57BL/6 Mouse',
    90                         ontology: nciOntology,
    91                         accession: 'C14424'
     89                        name            : 'C57BL/6 Mouse',
     90                        ontology        : nciOntology,
     91                        accession       : 'C14424'
    9292                ).with { if (!validate()) { errors.each { println it} } else save()}
    9393
    9494                def glucoseTerm = new Term(
    95                         name: 'glucose',
    96                         ontology: chebiOntology,
    97                         accession: 'CHEBI:17234'
     95                        name            : 'glucose',
     96                        ontology        : chebiOntology,
     97                        accession       : 'CHEBI:17234'
    9898                ).with { if (!validate()) { errors.each { println it} } else save()}
    9999
    100100                // Create a few persons, roles and Affiliations
    101101                def affiliation1 = new PersonAffiliation(
    102                         institute: "Science Institute NYC",
    103                         department: "Department of Mathematics"
     102                        institute       : "Science Institute NYC",
     103                        department      : "Department of Mathematics"
    104104                ).save();
    105105                def affiliation2 = new PersonAffiliation(
    106                         institute: "InfoStats GmbH, Hamburg",
    107                         department: "Life Sciences"
     106                        institute       : "InfoStats GmbH, Hamburg",
     107                        department      : "Life Sciences"
    108108                ).save();
    109109                def role1 = new PersonRole(
    110                         name: "Principal Investigator"
     110                        name            : "Principal Investigator"
    111111                ).save();
    112112                def role2 = new PersonRole(
    113                         name: "Statician"
     113                        name            : "Statician"
    114114                ).save();
    115115
    116116                // Create persons
    117117                def person1 = new Person(
    118                         lastName: "Scientist",
    119                         firstName: "John",
    120                         gender: "Male",
    121                         initials: "J.R.",
    122                         email: "john@scienceinstitute.com",
    123                         phone: "1-555-3049",
    124                         address: "First street 2,NYC"
    125                 )
    126                 .addToAffiliations( affiliation1 )
    127                 .addToAffiliations( affiliation2 )
    128                 .save();
     118                        lastName        : "Scientist",
     119                        firstName       : "John",
     120                        gender          : "Male",
     121                        initials        : "J.R.",
     122                        email           : "john@scienceinstitute.com",
     123                        phone           : "1-555-3049",
     124                        address         : "First street 2,NYC"
     125                ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save();
    129126
    130127                def person2 = new Person(
    131                         lastName: "Statician",
    132                         firstName: "Jane",
    133                         gender: "Female",
    134                         initials: "W.J.",
    135                         email: "jane@statisticalcompany.de",
    136                         phone: "49-555-8291",
    137                         address: "Dritten strasse 38, Hamburg, Germany"
    138                 )
    139                 .addToAffiliations( affiliation2 )
    140                 .save();
     128                        lastName        : "Statician",
     129                        firstName       : "Jane",
     130                        gender          : "Female",
     131                        initials        : "W.J.",
     132                        email           : "jane@statisticalcompany.de",
     133                        phone           : "49-555-8291",
     134                        address         : "Dritten strasse 38, Hamburg, Germany"
     135                ).addToAffiliations(affiliation2).save();
    141136
    142137                // Create 30 persons to test pagination
    143138                def personCounter = 1;
    144                 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() }
     139                30.times {
     140                        new Person(
     141                                firstName       : "Person #${personCounter}",
     142                                lastName        : "Testperson",
     143                                email           : "email${personCounter++}@testdomain.com"
     144                        ).save()
     145                }
    145146
    146147                // Create a few publications
    147148                def publication1 = new Publication(
    148                         title: "Postnatal development of hypothalamic leptin receptors",
    149                         authorsList: "Cottrell EC, Mercer JG, Ozanne SE.",
    150                         pubMedID: "20472140",
    151                         comments: "Not published yet",
    152                         DOI: "unknown"
    153                 )
    154                 .save();
     149                        title           : "Postnatal development of hypothalamic leptin receptors",
     150                        authorsList     : "Cottrell EC, Mercer JG, Ozanne SE.",
     151                        pubMedID        : "20472140",
     152                        comments        : "Not published yet",
     153                        DOI                     : "unknown"
     154                ).save();
    155155
    156156                def publication2 = new Publication(
    157                         title: "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice",
    158                         authorsList: "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.",
    159                         pubMedID: "20445103",
    160                         comments: "",
    161                         DOI: ""
    162                 )
    163                 .save();
     157                        title           : "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice",
     158                        authorsList     : "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.",
     159                        pubMedID        : "20445103",
     160                        comments        : "",
     161                        DOI                     : ""
     162                ).save();
    164163
    165164                // Add example mouse study
    166165                def mouseStudy = new Study(
    167                         template: studyTemplate,
    168                         title:"NuGO PPS3 mouse study leptin module",
    169                         code:"PPS3_leptin_module",
    170                         researchQuestion:"Leptin etc.",
    171                         ecCode:"2007117.c",
    172                         startDate: Date.parse('yyyy-MM-dd','2008-01-02'),
    173                         owner: owner,
    174                         readers: [otherUser]
    175                 ).with { if (!validate()) { errors.each { println it} } else save()}
    176 
    177                 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." )
    178                 mouseStudy.save()
     166                        template        : studyTemplate,
     167                        title           : "NuGO PPS3 mouse study leptin module",
     168                        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.",
     169                        code            : "PPS3_leptin_module",
     170                        researchQuestion: "Leptin etc.",
     171                        ecCode          : "2007117.c",
     172                        startDate       : Date.parse('yyyy-MM-dd', '2008-01-02'),
     173                        owner           : owner,
     174                        readers         : [otherUser]
     175                ).with { if (!validate()) { errors.each { println it} } else save()}
    179176
    180177                def evLF = new Event(
    181                         startTime: 3600,
    182                         endTime: 3600 +7 * 24 * 3600,
    183                         template: dietTreatmentTemplate
    184                 )
    185                 .setFieldValue( 'Diet','low fat')
     178                        startTime       : 3600,
     179                        endTime         : 3600 + 7 * 24 * 3600,
     180                        template        : dietTreatmentTemplate
     181                ).setFieldValue('Diet', 'low fat')
    186182
    187183                def evHF = new Event(
    188                         startTime: 3600,
    189                         endTime: 3600 +7 * 24 * 3600,
    190                         template: dietTreatmentTemplate
    191                 )
    192                 .setFieldValue( 'Diet','high fat' )
     184                        startTime       : 3600,
     185                        endTime         : 3600 + 7 * 24 * 3600,
     186                        template        : dietTreatmentTemplate
     187                ).setFieldValue('Diet', 'high fat')
    193188
    194189                def evBV = new Event(
    195                         startTime: 3600,
    196                         endTime: 3600 +7 * 24 * 3600,
    197                         template: boostTreatmentTemplate
    198                 )
    199                 .setFieldValue( 'Control','true' )
     190                        startTime       : 3600,
     191                        endTime         : 3600 + 7 * 24 * 3600,
     192                        template        : boostTreatmentTemplate
     193                ).setFieldValue('Control', 'true')
    200194
    201195                def evBL = new Event(
    202                         startTime: 3600,
    203                         endTime: 3600 +7 * 24 * 3600,
    204                         template: boostTreatmentTemplate
    205                 )
    206                 .setFieldValue( 'Control','false' )
     196                        startTime       : 3600,
     197                        endTime         : 3600 + 7 * 24 * 3600,
     198                        template        : boostTreatmentTemplate
     199                ).setFieldValue('Control', 'false')
    207200
    208201                def evLF4 = new Event(
    209                         startTime: 3600,
    210                         endTime: 3600 + 4 * 7 * 24 * 3600,
    211                         template: dietTreatmentTemplate
    212                 )
    213                 .setFieldValue( 'Diet','low fat')
     202                        startTime       : 3600,
     203                        endTime         : 3600 + 4 * 7 * 24 * 3600,
     204                        template        : dietTreatmentTemplate
     205                ).setFieldValue('Diet', 'low fat')
    214206
    215207                def evHF4 = new Event(
    216                         startTime: 3600,
    217                         endTime: 3600 + 4 * 7 * 24 * 3600,
    218                         template: dietTreatmentTemplate
    219                 )
    220                 .setFieldValue( 'Diet','high fat' )
     208                        startTime       : 3600,
     209                        endTime         : 3600 + 4 * 7 * 24 * 3600,
     210                        template        : dietTreatmentTemplate
     211                ).setFieldValue('Diet', 'high fat')
    221212
    222213                def evBV4 = new Event(
    223                         startTime: 3600,
    224                         endTime: 3600 + 4 * 7 * 24 * 3600,
    225                         template: boostTreatmentTemplate
    226                 )
    227                 .setFieldValue( 'Control','true' )
     214                        startTime       : 3600,
     215                        endTime         : 3600 + 4 * 7 * 24 * 3600,
     216                        template        : boostTreatmentTemplate
     217                ).setFieldValue('Control', 'true')
    228218
    229219                def evBL4 = new Event(
    230                         startTime: 3600,
    231                         endTime: 3600 + 4 * 7 * 24 * 3600,
    232                         template: boostTreatmentTemplate
    233                 )
    234                 .setFieldValue( 'Control','false' )
     220                        startTime       : 3600,
     221                        endTime         : 3600 + 4 * 7 * 24 * 3600,
     222                        template        : boostTreatmentTemplate
     223                ).setFieldValue('Control', 'false')
    235224
    236225                def evS = new SamplingEvent(
    237                         startTime: 3600 +7 * 24 * 3600,
    238                         template: liverSamplingEventTemplate,
    239                         sampleTemplate: humanTissueSampleTemplate)
    240                 .setFieldValue('Sample weight',5F)
     226                        startTime       : 3600 + 7 * 24 * 3600,
     227                        template        : liverSamplingEventTemplate,
     228                        sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F)
    241229
    242230                def evS4 = new SamplingEvent(
    243                         startTime: 3600 +7 * 24 * 3600,
    244                         template: liverSamplingEventTemplate,
    245                         sampleTemplate: humanTissueSampleTemplate)
    246                 .setFieldValue('Sample weight',5F)
     231                        startTime       : 3600 + 7 * 24 * 3600,
     232                        template        : liverSamplingEventTemplate,
     233                        sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F)
    247234
    248235                // Add events to study
    249                 mouseStudy
    250                 .addToEvents(evLF)
    251                 .addToEvents(evHF)
    252                 .addToEvents(evBV)
    253                 .addToEvents(evBL)
    254                 .addToEvents(evLF4)
    255                 .addToEvents(evHF4)
    256                 .addToEvents(evBV4)
    257                 .addToEvents(evBL4)
    258                 .addToSamplingEvents(evS)
    259                 .addToSamplingEvents(evS4)
    260                 .with { if (!validate()) { errors.each { println it} } else save()}
     236                mouseStudy.addToEvents(evLF).addToEvents(evHF).addToEvents(evBV).addToEvents(evBL).addToEvents(evLF4).addToEvents(evHF4).addToEvents(evBV4).addToEvents(evBL4).addToSamplingEvents(evS).addToSamplingEvents(evS4).with { if (!validate()) { errors.each { println it} } else save()}
    261237
    262238                // Extra check if the SamplingEvents are saved correctly
     
    264240                evS4.with { if (!validate()) { errors.each { println it} } else save()}
    265241
    266                 def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week")
    267                 .addToEvents(evLF)
    268                 .addToEvents(evBV)
    269                 .addToSamplingEvents(evS)
    270 
    271                 def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week")
    272                 .addToEvents(evLF)
    273                 .addToEvents(evBL)
    274                 .addToSamplingEvents(evS)
    275 
    276                 def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week")
    277                 .addToEvents(evHF)
    278                 .addToEvents(evBV)
    279                 .addToSamplingEvents(evS)
    280 
    281                 def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week")
    282                 .addToEvents(evHF)
    283                 .addToEvents(evBL)
    284                 .addToSamplingEvents(evS)
    285 
    286                 def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks")
    287                 .addToEvents(evLF4)
    288                 .addToEvents(evBV4)
    289                 .addToSamplingEvents(evS4)
    290 
    291                 def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks")
    292                 .addToEvents(evLF4)
    293                 .addToEvents(evBL4)
    294                 .addToSamplingEvents(evS4)
    295 
    296                 def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks")
    297                 .addToEvents(evHF4)
    298                 .addToEvents(evBV4)
    299                 .addToSamplingEvents(evS4)
    300 
    301                 def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks")
    302                 .addToEvents(evHF4)
    303                 .addToEvents(evBL4)
    304                 .addToSamplingEvents(evS4)
    305                
    306         // Add subjects and samples and compose EventGroups
    307                 def x=1
     242                def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToEvents(evBV).addToSamplingEvents(evS)
     243
     244                def LFBL1 = new EventGroup(name: "10% fat + leptin for 1 week").addToEvents(evLF).addToEvents(evBL).addToSamplingEvents(evS)
     245
     246                def HFBV1 = new EventGroup(name: "45% fat + vehicle for 1 week").addToEvents(evHF).addToEvents(evBV).addToSamplingEvents(evS)
     247
     248                def HFBL1 = new EventGroup(name: "45% fat + leptin for 1 week").addToEvents(evHF).addToEvents(evBL).addToSamplingEvents(evS)
     249
     250                def LFBV4 = new EventGroup(name: "10% fat + vehicle for 4 weeks").addToEvents(evLF4).addToEvents(evBV4).addToSamplingEvents(evS4)
     251
     252                def LFBL4 = new EventGroup(name: "10% fat + leptin for 4 weeks").addToEvents(evLF4).addToEvents(evBL4).addToSamplingEvents(evS4)
     253
     254                def HFBV4 = new EventGroup(name: "45% fat + vehicle for 4 weeks").addToEvents(evHF4).addToEvents(evBV4).addToSamplingEvents(evS4)
     255
     256                def HFBL4 = new EventGroup(name: "45% fat + leptin for 4 weeks").addToEvents(evHF4).addToEvents(evBL4).addToSamplingEvents(evS4)
     257
     258                // Add subjects and samples and compose EventGroups
     259                def x = 1
    308260                80.times {
    309261                        def currentSubject = new Subject(
     
    311263                                species: mouseTerm,
    312264                                template: mouseTemplate,
    313                         )
    314                         .setFieldValue("Gender", "Male")
    315                         .setFieldValue("Genotype", c57bl6Term)
    316                         .setFieldValue("Age", 17)
    317                         .setFieldValue("Cage", "" + (int)(x/2))
     265                        ).setFieldValue("Gender", "Male").setFieldValue("Genotype", c57bl6Term).setFieldValue("Age", 17).setFieldValue("Cage", "" + (int) (x / 2))
    318266
    319267                        // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set
     
    330278                        else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() }
    331279                        else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() }
    332                         else             { LFBV1.addToSubjects(currentSubject).save() }
     280                        else { LFBV1.addToSubjects(currentSubject).save() }
    333281
    334282                        // Create sample
     
    342290                        mouseStudy.addToSamples(currentSample)
    343291                        currentSample.with { if (!validate()) { errors.each { println it} } else save()}
    344                         currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
     292                        currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))
    345293                }
    346294
    347295                // Add EventGroups to study
    348                 mouseStudy
    349                 .addToEventGroups(LFBV1)
    350                 .addToEventGroups(LFBL1)
    351                 .addToEventGroups(HFBV1)
    352                 .addToEventGroups(HFBL1)
    353                 .addToEventGroups(LFBV4)
    354                 .addToEventGroups(LFBL4)
    355                 .addToEventGroups(HFBV4)
    356                 .addToEventGroups(HFBL4)
    357                 .with { if (!validate()) { errors.each { println it} } else save()}
     296                mouseStudy.addToEventGroups(LFBV1).addToEventGroups(LFBL1).addToEventGroups(HFBV1).addToEventGroups(HFBL1).addToEventGroups(LFBV4).addToEventGroups(LFBL4).addToEventGroups(HFBV4).addToEventGroups(HFBL4).with { if (!validate()) { errors.each { println it} } else save()}
    358297
    359298                // Add persons and publications to study
    360                 def studyperson1 = new StudyPerson( person: person1, role: role1 )
    361                 def studyperson2 = new StudyPerson( person: person2, role: role2 )
    362 
    363                 mouseStudy
    364                 .addToPersons( studyperson1 )
    365                 .addToPersons( studyperson2 )
    366         .addToPublications( publication1 )
    367         .addToPublications( publication2 )
    368                 .with { if (!validate()) { errors.each { println it} } else save()}
     299                def studyperson1 = new StudyPerson(person: person1, role: role1)
     300                def studyperson2 = new StudyPerson(person: person2, role: role2)
     301
     302                mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()}
    369303
    370304                def humanStudy = new Study(
    371                         template: studyTemplate,
    372                         title:"NuGO PPS human study",
    373                         code:"PPSH",
    374                         researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?",
    375                         description:"Human study",
    376                         ecCode:"unknown",
    377                         startDate: Date.parse('yyyy-MM-dd','2008-01-14'),
    378                         owner: owner,
    379                         writers: [otherUser]
    380                 )
    381                 .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." )
    382                 .with { if (!validate()) { errors.each { println it} } else save()}
     305                        template                : studyTemplate,
     306                        title                   : "NuGO PPS human study",
     307                        code                    : "PPSH",
     308                        researchQuestion: "How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?",
     309                        description             : "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.",
     310                        ecCode                  : "unknown",
     311                        startDate               : Date.parse('yyyy-MM-dd', '2008-01-14'),
     312                        owner                   : owner,
     313                        writers                 : [otherUser]
     314                ).with { if (!validate()) { errors.each { println it} } else save()}
    383315
    384316                def rootGroup = new EventGroup(name: 'Root group');
    385317
    386318                def fastingEvent = new Event(
    387                         startTime: 3 * 24 * 3600 + 22 * 3600,
    388                         endTime: 3 * 24 * 3600 + 30 * 3600,
    389                         template: fastingTreatmentTemplate)
    390                 .setFieldValue('Fasting period','8h');
     319                        startTime               : 3 * 24 * 3600 + 22 * 3600,
     320                        endTime                 : 3 * 24 * 3600 + 30 * 3600,
     321                        template                : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h');
    391322
    392323                def bloodSamplingEventBefore = new SamplingEvent(
    393                         startTime: 0,
    394                         template: bloodSamplingEventTemplate,
    395                         sampleTemplate: humanBloodSampleTemplate)
    396                 .setFieldValue('Sample volume',4.5F);
     324                        startTime               : 0,
     325                        template                : bloodSamplingEventTemplate,
     326                        sampleTemplate  : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F);
    397327
    398328                def bloodSamplingEventAfter = new SamplingEvent(
    399                         startTime: 3 * 24 * 3600 + 30 * 3600,
    400                         template: bloodSamplingEventTemplate,
    401                         sampleTemplate: humanBloodSampleTemplate)
    402                 .setFieldValue('Sample volume',4.5F);
     329                        startTime               : 3 * 24 * 3600 + 30 * 3600,
     330                        template                : bloodSamplingEventTemplate,
     331                        sampleTemplate  : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F);
    403332
    404333                rootGroup.addToEvents fastingEvent
     
    412341                humanStudy.addToEventGroups rootGroup
    413342
    414                 humanStudy.save()               
     343                humanStudy.save()
    415344
    416345                def y = 1
    417346                11.times {
    418347                        def currentSubject = new Subject(
    419                                 name: "" + y++,
    420                                 species: humanTerm,
    421                                 template: humanTemplate
    422                         )
    423                         .setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female")
    424                         //.setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80))))
    425                         .setFieldValue("DOB", new Date().parse("dd/mm/yyyy", ((10 + (int) Math.random() * 18) + "/0" + (1 + (int) (Math.random() * 8)) + "/19" + (10 + (int) (Math.random() * 80))) ))
    426                         .setFieldValue("Age", 30)
    427                         .setFieldValue("Height", Math.random() * 2F)
    428                         .setFieldValue("Weight", Math.random() * 150F)
    429                         .setFieldValue("BMI", 20 + Math.random() * 10F)
     348                                name            : "" + y++,
     349                                species         : humanTerm,
     350                                template        : humanTemplate
     351                        ).setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female")
     352                                //.setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("DOB", new Date().parse("dd/mm/yyyy", ((10 + (int) Math.random() * 18) + "/0" + (1 + (int) (Math.random() * 8)) + "/19" + (10 + (int) (Math.random() * 80))))).setFieldValue("Age", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F)
    430353
    431354                        humanStudy.addToSubjects(currentSubject)
     
    436359
    437360                        def currentSample = new Sample(
    438                                 name: currentSubject.name + '_B',
    439                                 material: bloodTerm,
    440                                 template: humanBloodSampleTemplate,
     361                                name            : currentSubject.name + '_B',
     362                                material        : bloodTerm,
     363                                template        : humanBloodSampleTemplate,
    441364                                parentSubject: currentSubject,
    442                                 parentEvent: bloodSamplingEventBefore
     365                                parentEvent     : bloodSamplingEventBefore
    443366                        );
    444367
    445368                        humanStudy.addToSamples(currentSample)
    446369                        currentSample.with { if (!validate()) { errors.each { println it} } else save()}
    447                         currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
     370                        currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))
    448371
    449372                        currentSample = new Sample(
    450                                 name: currentSubject.name + '_A',
    451                                 material: bloodTerm,
    452                                 template: humanBloodSampleTemplate,
     373                                name            : currentSubject.name + '_A',
     374                                material        : bloodTerm,
     375                                template        : humanBloodSampleTemplate,
    453376                                parentSubject: currentSubject,
    454                                 parentEvent: bloodSamplingEventAfter
     377                                parentEvent     : bloodSamplingEventAfter
    455378                        );
    456379
    457380                        humanStudy.addToSamples(currentSample)
    458381                        currentSample.with { if (!validate()) { errors.each { println it} } else save()}
    459                         currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) )
     382                        currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))
    460383                }
    461384
    462385                // Add persons to study
    463                 def studyperson3 = new StudyPerson( person: person1, role: role2 )
    464                 humanStudy
    465                 .addToPersons( studyperson3 )
    466                 .addToPublications( publication2 )
    467                 .with { if (!validate()) { errors.each { println it} } else save()}
     386                def studyperson3 = new StudyPerson(person: person1, role: role2)
     387                humanStudy.addToPersons(studyperson3).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()}
    468388
    469389                // Add SAM assay reference
     
    493413                        module: metabolomicsModule,
    494414                        externalAssayID: 'PPS3_Lipidomics'
    495                 )
    496                 .setFieldValue('Spectrometry technique','LC/MS')
     415                ).setFieldValue('Spectrometry technique', 'LC/MS')
    497416
    498417                mouseStudy.samples*.each {
     
    505424                mouseStudy.save()
    506425
    507                 def  glucoseAssayBRef = new Assay(
    508                         name: 'Glucose assay before',
    509                         template: ccAssayTemplate,
    510                         module: clinicalModule,
     426                def glucoseAssayBRef = new Assay(
     427                        name            : 'Glucose assay before',
     428                        template        : ccAssayTemplate,
     429                        module          : clinicalModule,
    511430                        externalAssayID: 'PPSH-Glu-B'
    512431                )
    513432
    514                 def  glucoseAssayARef = new Assay(
    515                         name: 'Glucose assay after',
    516                         template: ccAssayTemplate,
    517                         module: clinicalModule,
     433                def glucoseAssayARef = new Assay(
     434                        name            : 'Glucose assay after',
     435                        template        : ccAssayTemplate,
     436                        module          : clinicalModule,
    518437                        externalAssayID: 'PPSH-Glu-A'
    519438                )
    520439
    521440                def metAssayRefB = new Assay(
    522                         name: 'Lipidomics profile before',
    523                         template: metAssayTemplate,
    524                         module: metabolomicsModule,
     441                        name            : 'Lipidomics profile before',
     442                        template        : metAssayTemplate,
     443                        module          : metabolomicsModule,
    525444                        externalAssayID: 'PPSH_Lipidomics_start'
    526                 )
    527                 .setFieldValue('Spectrometry technique','GC/MS')
     445                ).setFieldValue('Spectrometry technique', 'GC/MS')
    528446
    529447                def metAssayRefA = new Assay(
    530                         name: 'Lipidomics profile after',
    531                         template: metAssayTemplate,
    532                         module: metabolomicsModule,
     448                        name            : 'Lipidomics profile after',
     449                        template        : metAssayTemplate,
     450                        module          : metabolomicsModule,
    533451                        externalAssayID: 'PPSH_Lipidomics_end'
    534                 )
    535                 .setFieldValue('Spectrometry technique','GC/MS')
     452                ).setFieldValue('Spectrometry technique', 'GC/MS')
    536453
    537454                humanStudy.samples*.each {
     
    551468                humanStudy.addToAssays(metAssayRefB)
    552469                humanStudy.save()
    553 
    554470        }
    555 
    556471}
  • trunk/grails-app/conf/BootStrapTemplates.groovy

    r1153 r1245  
    7272                        entity: dbnp.studycapturing.Study
    7373                )
    74                 .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT, entity: Study,comment:'Describe here the type of subjects and the treatment, challenges and sampling.'))
    7574                .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,entity: Study,comment:'Fill out the aim or questions of the study'))
    7675                .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING,entity: Study,comment:'If the study was performed within a consortium (e.g. NMC, NuGO), you can indicate this here'))
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy

    r1241 r1245  
    9393            // use the same view for showing the study and comparing multiple
    9494            // studies
    95             [studyList: [ studyInstance ], multipleStudies: false, loggedInUser: loggedInUser, facebookLikeUrl: "/study/show/${studyInstance?.id}" ]
     95            [studyList: [ studyInstance ], multipleStudies: false, loggedInUser: loggedInUser, facebookLikeUrl: studyInstance.getFieldValue('published') ? "/study/show/${studyInstance?.id}" : '' ]
    9696        }
    9797    }
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r1233 r1245  
    1616        SecUser owner           // The owner of the study. A new study is automatically owned by its creator.
    1717        String title            // The title of the study
    18         String code              // currently used as the external study ID, e.g. to reference a study in a SAM module
     18        String description      // A brief synopsis of what the study is about
     19        String code                     // currently used as the external study ID, e.g. to reference a study in a SAM module
    1920        Date dateCreated
    2021        Date lastUpdated
     
    7475                        type: TemplateFieldType.STRING,
    7576                        required: true),
     77                new TemplateField(
     78                        name: 'description',
     79                        type: TemplateFieldType.TEXT,
     80                        comment:'Give a brief synopsis of what your study is about',
     81                        required: false),
    7682                new TemplateField(
    7783                        name: 'code',
     
    431437                // User that are not logged in, are not allowed to write to a study
    432438                if (user == null)
    433                 return [];
     439                        return [];
    434440
    435441                def c = Study.createCriteria()
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy

    r1224 r1245  
    2424        Map templateStringFields        = [:]
    2525        Map templateTextFields          = [:]
    26         Map templateStringListFields    = [:]
     26        Map templateStringListFields= [:]
    2727        Map templateDoubleFields        = [:]
    2828        Map templateDateFields          = [:]
     
    4141        static hasMany = [
    4242                templateStringFields    : String,
    43                 templateTextFields      : String,
     43                templateTextFields              : String,
    4444                templateStringListFields: TemplateFieldListItem,
    4545                templateDoubleFields    : double,
    46                 templateDateFields      : Date,
    47                 templateTermFields      : Term,
     46                templateDateFields              : Date,
     47                templateTermFields              : Term,
    4848                templateRelTimeFields   : long,
    49                 templateFileFields      : String,
     49                templateFileFields              : String,
    5050                templateBooleanFields   : boolean,
    5151                templateTemplateFields  : Template,
    5252                templateModuleFields    : AssayModule,
    53                 templateLongFields      : long,
    54                 systemFields            : TemplateField
     53                templateLongFields              : long,
     54                systemFields                    : TemplateField
    5555        ]
    5656
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy

    r1153 r1245  
    1010 */
    1111public enum TemplateFieldType implements Serializable {
    12         STRING('String','Text', 'max 255 chars'),                                                                                       // string
    13         TEXT('Long string', 'Text', 'unlimited'),                                                                               // text
    14         //INTEGER('Integer number', 'Numerical', '1'),                                                  // integer
    15         //FLOAT('Floating-point number', 'Numerical', '1.0'),                                           // float
    16         DOUBLE('Floating point number', 'Numerical', '1.0'),                                    // double
    17         STRINGLIST('List of items', 'Text', ''),                                                                // string list
    18         ONTOLOGYTERM('Ontology Reference', 'Other', ''),                                                // ontology reference
    19         DATE('Date', 'Date', '2010-01-01'),                                                                             // date
    20         RELTIME('Relative time', 'Date', '3 days'),                                                             // relative date, e.g. days since start of study
    21         FILE('File', 'Other', '')               ,                                                                               // file
    22         BOOLEAN('Boolean', 'Other', 'true/false'),                                                              // boolean
    23         TEMPLATE('Template', 'Other', ''),                                                                              // template
    24         MODULE('Module', 'Other', ''),                                                                                  // third party connected module,
    25         LONG('Integer number', 'Numerical', '100')                                                              // long
     12        STRING          ('String'                               , 'Text'                , 'max 255 chars'),                     // string
     13        TEXT            ('Long string'                  , 'Text'                , 'unlimited'),                         // text
     14        //INTEGER       ('Integer number'               , 'Numerical'   , '1'),                                         // integer
     15        //FLOAT         ('Floating-point number', 'Numerical'   , '1.0'),                                       // float
     16        DOUBLE          ('Floating point number', 'Numerical'   , '1.0'),                                       // double
     17        STRINGLIST      ('List of items'                , 'Text'                , ''),                                          // string list
     18        ONTOLOGYTERM('Ontology Reference'       , 'Other'               , ''),                                          // ontology reference
     19        DATE            ('Date'                                 , 'Date'                , '2010-01-01'),                        // date
     20        RELTIME         ('Relative time'                , 'Date'                , '3 days'),                            // relative date, e.g. days since start of study
     21        FILE            ('File'                                 , 'Other'               , '')           ,                               // file
     22        BOOLEAN         ('Boolean'                              , 'Other'               , 'true/false'),                        // boolean
     23        TEMPLATE        ('Template'                             , 'Other'               , ''),                                          // template
     24        MODULE          ('Module'                               , 'Other'               , ''),                                          // third party connected module,
     25        LONG            ('Integer number'               , 'Numerical'   , '100')                                        // long
    2626    // TODO: add a timezone-aware date type to use for study start date
    2727
  • trunk/grails-app/views/study/show.gsp

    r1244 r1245  
    55<head>
    66        <meta name="layout" content="main"/>
    7         <g:if test="${studyList.size()}">
     7        <g:if test="${studyList.size() == 1}">
    88        <meta property="og:title" content="${studyList[0].title}"/>
    9         <g:if test="${studyList[0].getField('description')}">
    10         <meta property="og:description" content="${(studyList[0].getFieldValue('Description')) ? studyList[0].getFieldValue('Description') : 'A study in the Generic Study Capture Framework'}"/>
    11         </g:if><g:else>
    12         <meta property="og:description" content="A study in the Generic Study Capture Framework"/>
    13         </g:else>
     9        <meta property="og:description" content="${(studyList[0].getFieldValue('description')) ? studyList[0].getFieldValue('description') : 'A study in the Generic Study Capture Framework'}"/>
    1410        </g:if>
    1511        <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}"/>
Note: See TracChangeset for help on using the changeset viewer.