Changeset 1245
- Timestamp:
- Dec 9, 2010, 2:51:51 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrapStudies.groovy
r1178 r1245 23 23 * Add example studies. This function is meant to be called only in development mode 24 24 */ 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) { 26 26 "inserting initial studies".grom() 27 27 … … 30 30 31 31 // Look up the used ontologies which should be in the database by now 32 def speciesOntology 33 def brendaOntology 34 def nciOntology 35 def chebiOntology 32 def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 33 def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) 34 def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) 35 def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) 36 36 37 37 // Look up the used templates which should also be in the database by now 38 def studyTemplate 39 def mouseTemplate 40 def humanTemplate 41 def dietTreatmentTemplate 42 def boostTreatmentTemplate 43 def liverSamplingEventTemplate 44 def fastingTreatmentTemplate 45 def bloodSamplingEventTemplate 46 def humanTissueSampleTemplate 47 def humanBloodSampleTemplate 48 def ccAssayTemplate 49 def metAssayTemplate 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") 50 50 51 51 // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website 52 52 def mouseTerm = new Term( 53 name : 'Mus musculus',54 ontology : speciesOntology,55 accession : '10090'53 name : 'Mus musculus', 54 ontology : speciesOntology, 55 accession : '10090' 56 56 ).with { if (!validate()) { errors.each { println it} } else save()} 57 57 58 58 def humanTerm = new Term( 59 name : 'Homo sapiens',60 ontology : speciesOntology,61 accession : '9606'59 name : 'Homo sapiens', 60 ontology : speciesOntology, 61 accession : '9606' 62 62 ).with { if (!validate()) { errors.each { println it} } else save()} 63 63 64 64 def arabTerm = new Term( 65 name : 'Arabidopsis thaliana',66 ontology : speciesOntology,67 accession : '3702'65 name : 'Arabidopsis thaliana', 66 ontology : speciesOntology, 67 accession : '3702' 68 68 ).with { if (!validate()) { errors.each { println it} } else save()} 69 69 70 70 def tomatoTerm = new Term( 71 name : 'Solanum lycopersicum',72 ontology : speciesOntology,73 accession : '4081'71 name : 'Solanum lycopersicum', 72 ontology : speciesOntology, 73 accession : '4081' 74 74 ).with { if (!validate()) { errors.each { println it} } else save()} 75 75 76 76 def potatoTerm = new Term( 77 name : 'Solanum tuberosum',78 ontology : speciesOntology,79 accession : '0000'77 name : 'Solanum tuberosum', 78 ontology : speciesOntology, 79 accession : '0000' 80 80 ).with { if (!validate()) { errors.each { println it} } else save()} 81 81 82 82 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' 86 86 ).with { if (!validate()) { errors.each { println it} } else save()} 87 87 88 88 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' 92 92 ).with { if (!validate()) { errors.each { println it} } else save()} 93 93 94 94 def glucoseTerm = new Term( 95 name : 'glucose',96 ontology : chebiOntology,97 accession : 'CHEBI:17234'95 name : 'glucose', 96 ontology : chebiOntology, 97 accession : 'CHEBI:17234' 98 98 ).with { if (!validate()) { errors.each { println it} } else save()} 99 99 100 100 // Create a few persons, roles and Affiliations 101 101 def affiliation1 = new PersonAffiliation( 102 institute : "Science Institute NYC",103 department : "Department of Mathematics"102 institute : "Science Institute NYC", 103 department : "Department of Mathematics" 104 104 ).save(); 105 105 def affiliation2 = new PersonAffiliation( 106 institute : "InfoStats GmbH, Hamburg",107 department : "Life Sciences"106 institute : "InfoStats GmbH, Hamburg", 107 department : "Life Sciences" 108 108 ).save(); 109 109 def role1 = new PersonRole( 110 name : "Principal Investigator"110 name : "Principal Investigator" 111 111 ).save(); 112 112 def role2 = new PersonRole( 113 name : "Statician"113 name : "Statician" 114 114 ).save(); 115 115 116 116 // Create persons 117 117 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(); 129 126 130 127 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(); 141 136 142 137 // Create 30 persons to test pagination 143 138 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 } 145 146 146 147 // Create a few publications 147 148 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(); 155 155 156 156 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(); 164 163 165 164 // Add example mouse study 166 165 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()} 179 176 180 177 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') 186 182 187 183 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') 193 188 194 189 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') 200 194 201 195 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') 207 200 208 201 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') 214 206 215 207 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') 221 212 222 213 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') 228 218 229 219 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') 235 224 236 225 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) 241 229 242 230 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) 247 234 248 235 // 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()} 261 237 262 238 // Extra check if the SamplingEvents are saved correctly … … 264 240 evS4.with { if (!validate()) { errors.each { println it} } else save()} 265 241 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 308 260 80.times { 309 261 def currentSubject = new Subject( … … 311 263 species: mouseTerm, 312 264 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)) 318 266 319 267 // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set … … 330 278 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 331 279 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 332 else 280 else { LFBV1.addToSubjects(currentSubject).save() } 333 281 334 282 // Create sample … … 342 290 mouseStudy.addToSamples(currentSample) 343 291 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)) 345 293 } 346 294 347 295 // 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()} 358 297 359 298 // 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()} 369 303 370 304 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()} 383 315 384 316 def rootGroup = new EventGroup(name: 'Root group'); 385 317 386 318 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'); 391 322 392 323 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); 397 327 398 328 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); 403 332 404 333 rootGroup.addToEvents fastingEvent … … 412 341 humanStudy.addToEventGroups rootGroup 413 342 414 humanStudy.save() 343 humanStudy.save() 415 344 416 345 def y = 1 417 346 11.times { 418 347 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) 430 353 431 354 humanStudy.addToSubjects(currentSubject) … … 436 359 437 360 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, 441 364 parentSubject: currentSubject, 442 parentEvent : bloodSamplingEventBefore365 parentEvent : bloodSamplingEventBefore 443 366 ); 444 367 445 368 humanStudy.addToSamples(currentSample) 446 369 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)) 448 371 449 372 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, 453 376 parentSubject: currentSubject, 454 parentEvent : bloodSamplingEventAfter377 parentEvent : bloodSamplingEventAfter 455 378 ); 456 379 457 380 humanStudy.addToSamples(currentSample) 458 381 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)) 460 383 } 461 384 462 385 // 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()} 468 388 469 389 // Add SAM assay reference … … 493 413 module: metabolomicsModule, 494 414 externalAssayID: 'PPS3_Lipidomics' 495 ) 496 .setFieldValue('Spectrometry technique','LC/MS') 415 ).setFieldValue('Spectrometry technique', 'LC/MS') 497 416 498 417 mouseStudy.samples*.each { … … 505 424 mouseStudy.save() 506 425 507 def 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, 511 430 externalAssayID: 'PPSH-Glu-B' 512 431 ) 513 432 514 def 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, 518 437 externalAssayID: 'PPSH-Glu-A' 519 438 ) 520 439 521 440 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, 525 444 externalAssayID: 'PPSH_Lipidomics_start' 526 ) 527 .setFieldValue('Spectrometry technique','GC/MS') 445 ).setFieldValue('Spectrometry technique', 'GC/MS') 528 446 529 447 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, 533 451 externalAssayID: 'PPSH_Lipidomics_end' 534 ) 535 .setFieldValue('Spectrometry technique','GC/MS') 452 ).setFieldValue('Spectrometry technique', 'GC/MS') 536 453 537 454 humanStudy.samples*.each { … … 551 468 humanStudy.addToAssays(metAssayRefB) 552 469 humanStudy.save() 553 554 470 } 555 556 471 } -
trunk/grails-app/conf/BootStrapTemplates.groovy
r1153 r1245 72 72 entity: dbnp.studycapturing.Study 73 73 ) 74 .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT, entity: Study,comment:'Describe here the type of subjects and the treatment, challenges and sampling.'))75 74 .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,entity: Study,comment:'Fill out the aim or questions of the study')) 76 75 .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 93 93 // use the same view for showing the study and comparing multiple 94 94 // 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}" : '' ] 96 96 } 97 97 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r1233 r1245 16 16 SecUser owner // The owner of the study. A new study is automatically owned by its creator. 17 17 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 19 20 Date dateCreated 20 21 Date lastUpdated … … 74 75 type: TemplateFieldType.STRING, 75 76 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), 76 82 new TemplateField( 77 83 name: 'code', … … 431 437 // User that are not logged in, are not allowed to write to a study 432 438 if (user == null) 433 return [];439 return []; 434 440 435 441 def c = Study.createCriteria() -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r1224 r1245 24 24 Map templateStringFields = [:] 25 25 Map templateTextFields = [:] 26 Map templateStringListFields 26 Map templateStringListFields= [:] 27 27 Map templateDoubleFields = [:] 28 28 Map templateDateFields = [:] … … 41 41 static hasMany = [ 42 42 templateStringFields : String, 43 templateTextFields : String,43 templateTextFields : String, 44 44 templateStringListFields: TemplateFieldListItem, 45 45 templateDoubleFields : double, 46 templateDateFields : Date,47 templateTermFields : Term,46 templateDateFields : Date, 47 templateTermFields : Term, 48 48 templateRelTimeFields : long, 49 templateFileFields : String,49 templateFileFields : String, 50 50 templateBooleanFields : boolean, 51 51 templateTemplateFields : Template, 52 52 templateModuleFields : AssayModule, 53 templateLongFields : long,54 systemFields : TemplateField53 templateLongFields : long, 54 systemFields : TemplateField 55 55 ] 56 56 -
trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy
r1153 r1245 10 10 */ 11 11 public enum TemplateFieldType implements Serializable { 12 STRING ('String','Text', 'max 255 chars'),// string13 TEXT ('Long string', 'Text', 'unlimited'),// text14 //INTEGER ('Integer number', 'Numerical', '1'),// integer15 //FLOAT ('Floating-point number', 'Numerical', '1.0'),// float16 DOUBLE ('Floating point number', 'Numerical', '1.0'), // double17 STRINGLIST ('List of items', 'Text', ''),// string list18 ONTOLOGYTERM('Ontology Reference' , 'Other', ''), // ontology reference19 DATE ('Date', 'Date', '2010-01-01'),// date20 RELTIME ('Relative time', 'Date', '3 days'),// relative date, e.g. days since start of study21 FILE ('File', 'Other', '') ,// file22 BOOLEAN ('Boolean', 'Other', 'true/false'),// boolean23 TEMPLATE ('Template', 'Other', ''),// template24 MODULE ('Module', 'Other', ''),// third party connected module,25 LONG ('Integer number', 'Numerical', '100')// long12 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 26 26 // TODO: add a timezone-aware date type to use for study start date 27 27 -
trunk/grails-app/views/study/show.gsp
r1244 r1245 5 5 <head> 6 6 <meta name="layout" content="main"/> 7 <g:if test="${studyList.size() }">7 <g:if test="${studyList.size() == 1}"> 8 8 <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'}"/> 14 10 </g:if> 15 11 <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}"/>
Note: See TracChangeset
for help on using the changeset viewer.