Changeset 1588
- Timestamp:
- Mar 4, 2011, 12:30:52 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r1547 r1588 74 74 // - ontologies 75 75 // - and/or studies 76 if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT || grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST || grails.util.GrailsUtil.environment == "dbnpdemo") { 76 77 78 if ( grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT || 79 grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST || 80 grails.util.GrailsUtil.environment == "dbnpdemo") { 77 81 // add ontologies? 78 82 if (!Ontology.count()) ExampleTemplates.initTemplateOntologies() -
trunk/grails-app/conf/Config.groovy
r1541 r1588 1 import dbnp.rest.common.CommunicationManager 2 import org.apache.commons.lang.RandomStringUtils 3 4 /** 1 /** 5 2 * Application Configuration 6 3 * -
trunk/grails-app/conf/dbnp/configuration/BootStrapAuthentication.groovy
r1581 r1588 28 28 29 29 // create the admin role 30 def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save( )30 def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save(failOnError:true) 31 31 32 32 // iterate through default users, see … … 53 53 } 54 54 } 55 56 //package dbnp.configuration 57 //import dbnp.authentication.* 58 //import org.codehaus.groovy.grails.commons.ConfigurationHolder 59 // 60 ///** 61 // * @Author Jeroen Wesbeek <work@osx.eu> 62 // * @Since 20101111 63 // * 64 // * Revision information: 65 // * $Rev$ 66 // * $Author$ 67 // * $Date$ 68 // */ 69 //class BootStrapAuthentication { 70 // /** 71 // * set up the initial roles and users if required 72 // * @visibility public 73 // * @void 74 // */ 75 // public static void initDefaultAuthentication(springSecurityService) { 76 // "setting up default authentication".grom() 77 // 78 // // user work variable 79 // def user=null 80 // 81 // // get configuration 82 // def config = ConfigurationHolder.config 83 // 84 // // create the admin role 85 // def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save() 86 // 87 // // iterate through default users, see 88 // // - grails-app/conf/config-environment.properties 89 // // - ~/.grails-config/environment-gscf.properties 90 // config.authentication.users.each { key, values -> 91 // // make sure we do not add duplicate users 92 // if (!SecUser.findAllByUsername(values.username)) { 93 // // create user instance 94 // user = new SecUser( 95 // username:values.username, 96 // password:springSecurityService.encodePassword( values.password , values.username ), 97 // email:values.email, 98 // userConfirmed: true, 99 // adminConfirmed: true 100 // ).save(failOnError: true) 101 // 102 // // is this user an administrator? 103 // if (values.administrator == 'true') { 104 // SecUserSecRole.create(user, adminRole, true) 105 // } 106 // } 107 // } 108 // } 109 //} -
trunk/grails-app/conf/dbnp/configuration/ExampleStudies.groovy
r1581 r1588 55 55 ontology : speciesOntology, 56 56 accession : '10090' 57 ). with { if (!validate()) { errors.each { println it} } else save()}57 ).save(failOnError:true) 58 58 59 59 def humanTerm = new Term( … … 61 61 ontology : speciesOntology, 62 62 accession : '9606' 63 ). with { if (!validate()) { errors.each { println it} } else save()}63 ).save(failOnError:true) 64 64 65 65 def arabTerm = new Term( … … 67 67 ontology : speciesOntology, 68 68 accession : '3702' 69 ).with { if (!validate()) { errors.each { println it} } else save()} 69 ).save(failOnError:true) 70 70 71 71 def tomatoTerm = new Term( … … 73 73 ontology : speciesOntology, 74 74 accession : '4081' 75 ).with { if (!validate()) { errors.each { println it} } else save()} 75 ).save(failOnError:true) 76 76 77 77 def potatoTerm = new Term( … … 79 79 ontology : speciesOntology, 80 80 accession : '0000' 81 ).with { if (!validate()) { errors.each { println it} } else save()} 81 ).save(failOnError:true) 82 82 83 83 def bloodTerm = new Term( … … 85 85 ontology : brendaOntology, 86 86 accession : 'BTO:0000131' 87 ).with { if (!validate()) { errors.each { println it} } else save()} 87 ).save(failOnError:true) 88 88 89 89 def c57bl6Term = new Term( … … 91 91 ontology : nciOntology, 92 92 accession : 'C14424' 93 ).with { if (!validate()) { errors.each { println it} } else save()} 93 ).save(failOnError:true) 94 94 95 95 def glucoseTerm = new Term( … … 97 97 ontology : chebiOntology, 98 98 accession : 'CHEBI:17234' 99 ).with { if (!validate()) { errors.each { println it} } else save()} 99 ).save(failOnError:true) 100 100 101 101 // Create a few persons, roles and Affiliations … … 103 103 institute : "Science Institute NYC", 104 104 department : "Department of Mathematics" 105 ).save(); 105 ).save(failOnError:true) 106 106 107 def affiliation2 = new PersonAffiliation( 107 108 institute : "InfoStats GmbH, Hamburg", 108 109 department : "Life Sciences" 109 ).save(); 110 ).save(failOnError:true) 111 110 112 def role1 = new PersonRole( 111 113 name : "Principal Investigator" 112 ).save(); 114 ).save(failOnError:true) 115 113 116 def role2 = new PersonRole( 114 117 name : "Statician" 115 ).save(); 118 ).save(failOnError:true) 116 119 117 120 // Create persons … … 124 127 phone : "1-555-3049", 125 128 address : "First street 2,NYC" 126 ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save( );129 ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save(failOnError:true) 127 130 128 131 def person2 = new Person( … … 134 137 phone : "49-555-8291", 135 138 address : "Dritten strasse 38, Hamburg, Germany" 136 ).addToAffiliations(affiliation2).save( );139 ).addToAffiliations(affiliation2).save(failOnError:true) 137 140 138 141 // Create 30 persons to test pagination 139 def personCounter = 1 ;142 def personCounter = 1 140 143 30.times { 141 144 new Person( … … 143 146 lastName : "Testperson", 144 147 email : "email${personCounter++}@testdomain.com" 145 ).save( )148 ).save(failOnError:true) 146 149 } 147 150 … … 153 156 comments : "Not published yet", 154 157 DOI : "unknown" 155 ).save( );158 ).save(failOnError:true) 156 159 157 160 def publication2 = new Publication( … … 161 164 comments : "", 162 165 DOI : "" 163 ).save( );166 ).save(failOnError:true) 164 167 165 168 // Add example mouse study … … 174 177 owner : owner, 175 178 readers : [otherUser] 176 ).with { if (!validate()) { errors.each { println it} } else save()} 179 ).save(failOnError:true) 177 180 178 181 def evLF = new Event( … … 235 238 236 239 // Add events to study 237 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()}240 mouseStudy.addToEvents(evLF).addToEvents(evHF).addToEvents(evBV).addToEvents(evBL).addToEvents(evLF4).addToEvents(evHF4).addToEvents(evBV4).addToEvents(evBL4).addToSamplingEvents(evS).addToSamplingEvents(evS4).save(failOnError:true) 238 241 239 242 // Extra check if the SamplingEvents are saved correctly 240 evS. with { if (!validate()) { errors.each { println it} } else save()}241 evS4. with { if (!validate()) { errors.each { println it} } else save()}243 evS.save(failOnError:true) 244 evS4.save(failOnError:true) 242 245 243 246 def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToEvents(evBV).addToSamplingEvents(evS) … … 269 272 // (this is possibly a Grails or Hibernate bug) 270 273 mouseStudy.addToSubjects(currentSubject) 271 currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 274 275 currentSubject.save(failOnError:true) 272 276 273 277 // Add subject to appropriate EventGroup 274 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 275 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 276 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 277 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 278 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 279 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 280 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 281 else { LFBV1.addToSubjects(currentSubject).save() } 278 def tmpEventGroup 279 if (x > 70) { tmpEventGroup = HFBL4 } 280 else if (x > 60) { tmpEventGroup = HFBV4 } 281 else if (x > 50) { tmpEventGroup = LFBL4 } 282 else if (x > 40) { tmpEventGroup = LFBV4 } 283 else if (x > 30) { tmpEventGroup = HFBL1 } 284 else if (x > 20) { tmpEventGroup = HFBV1 } 285 else if (x > 10) { tmpEventGroup = LFBL1 } 286 else { tmpEventGroup = LFBV1 } 287 288 tmpEventGroup.addToSubjects(currentSubject) 282 289 283 290 // Create sample … … 288 295 parentSubject: currentSubject, 289 296 parentEvent: evS //x > 40 ? evS4 : evS 290 ); 297 ) 298 291 299 mouseStudy.addToSamples(currentSample) 292 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 293 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))294 300 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 301 currentSample.save(failOnError:true) 302 } 295 303 296 304 // Add EventGroups to study 297 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()}305 mouseStudy.addToEventGroups(LFBV1).addToEventGroups(LFBL1).addToEventGroups(HFBV1).addToEventGroups(HFBL1).addToEventGroups(LFBV4).addToEventGroups(LFBL4).addToEventGroups(HFBV4).addToEventGroups(HFBL4).save(failOnError:true) 298 306 299 307 // Add persons and publications to study … … 301 309 def studyperson2 = new StudyPerson(person: person2, role: role2) 302 310 303 mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2). with { if (!validate()) { errors.each { println it} } else save()}311 mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2).save(failOnError:true) 304 312 305 313 def humanStudy = new Study( … … 311 319 ecCode : "unknown", 312 320 startDate : Date.parse('yyyy-MM-dd', '2008-01-14'), 313 owner : owner, 314 writers : [otherUser] 315 ).with { if (!validate()) { errors.each { println it} } else save()} 316 317 def rootGroup = new EventGroup(name: 'Root group'); 321 owner : owner 322 ).addToWriters(otherUser).save(failOnError:true) 323 324 def rootGroup = new EventGroup(name: 'Root group') 318 325 319 326 def fastingEvent = new Event( 320 327 startTime : 3 * 24 * 3600 + 22 * 3600, 321 328 endTime : 3 * 24 * 3600 + 30 * 3600, 322 template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h') ;329 template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h') 323 330 324 331 def bloodSamplingEventBefore = new SamplingEvent( 325 332 startTime : 0, 326 333 template : bloodSamplingEventTemplate, 327 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) ;334 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) 328 335 329 336 def bloodSamplingEventAfter = new SamplingEvent( 330 337 startTime : 3 * 24 * 3600 + 30 * 3600, 331 338 template : bloodSamplingEventTemplate, 332 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) ;339 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) 333 340 334 341 rootGroup.addToEvents fastingEvent 335 342 rootGroup.addToSamplingEvents bloodSamplingEventBefore 336 343 rootGroup.addToSamplingEvents bloodSamplingEventAfter 337 rootGroup.save()338 344 339 345 humanStudy.addToEvents(fastingEvent) … … 342 348 humanStudy.addToEventGroups rootGroup 343 349 344 humanStudy.save( )350 humanStudy.save(failOnError:true) 345 351 346 352 def y = 1 … … 354 360 355 361 humanStudy.addToSubjects(currentSubject) 356 currentSubject. with { if (!validate()) { errors.each { println it} } else save()}362 currentSubject.save(failOnError:true) 357 363 358 364 rootGroup.addToSubjects currentSubject 359 rootGroup.save( )365 rootGroup.save(failOnError:true) 360 366 361 367 def currentSample = new Sample( … … 365 371 parentSubject: currentSubject, 366 372 parentEvent : bloodSamplingEventBefore 367 ) ;373 ) 368 374 369 375 humanStudy.addToSamples(currentSample) 370 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 371 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))376 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 377 currentSample.save(failOnError:true) 372 378 373 379 currentSample = new Sample( … … 377 383 parentSubject: currentSubject, 378 384 parentEvent : bloodSamplingEventAfter 379 ) ;385 ) 380 386 381 387 humanStudy.addToSamples(currentSample) 382 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 383 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))384 388 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 389 currentSample.save(failOnError:true) 390 } 385 391 386 392 // Add persons to study 387 393 def studyperson3 = new StudyPerson(person: person1, role: role2) 388 humanStudy.addToPersons(studyperson3).addToPublications(publication2). with { if (!validate()) { errors.each { println it} } else save()}394 humanStudy.addToPersons(studyperson3).addToPublications(publication2).save(failOnError:true) 389 395 390 396 // Add SAM assay reference … … 393 399 platform: 'clinical measurements', 394 400 url: config.modules.sam.url.toString() 395 ). with { if (!validate()) { errors.each { println it} } else save()}401 ).save(failOnError:true) 396 402 397 403 // Add metabolomics assay reference … … 400 406 platform: 'GCMS/LCMS', 401 407 url: config.modules.metabolomics.url.toString() 402 ). with { if (!validate()) { errors.each { println it} } else save()}403 408 ).save(failOnError:true) 409 404 410 // Add metabolomics assay reference 405 411 def metagenomicsModule = new AssayModule( … … 407 413 platform: 'High throughput sequencing', 408 414 url: config.modules.metagenomics.url.toString() 409 ). with { if (!validate()) { errors.each { println it} } else save()}410 415 ).save(failOnError:true) 416 411 417 def lipidAssayRef = new Assay( 412 418 name: 'Lipid profiling', … … 430 436 mouseStudy.addToAssays(lipidAssayRef); 431 437 mouseStudy.addToAssays(metAssayRef); 432 mouseStudy.save( )438 mouseStudy.save(failOnError:true) 433 439 434 440 def glucoseAssayBRef = new Assay( … … 460 466 ).setFieldValue('Spectrometry technique', 'GC/MS') 461 467 462 468 463 469 // Add sequencing (metagenomics) assays 464 470 def sequencingAssay16SRef = new Assay( … … 468 474 externalAssayID: 'PPSH-SEQ-16S' 469 475 ) 470 476 471 477 // Add sequencing (metagenomics) assays 472 478 def sequencingAssay18SRef = new Assay( … … 476 482 externalAssayID: 'PPSH-SEQ-18S' 477 483 ) 478 484 479 485 humanStudy.samples*.each { 480 486 if (it.parentEvent.startTime == 0) { … … 489 495 } 490 496 } 491 497 492 498 humanStudy.addToAssays(sequencingAssay16SRef) 493 499 humanStudy.addToAssays(sequencingAssay18SRef) … … 496 502 humanStudy.addToAssays(metAssayRefA) 497 503 humanStudy.addToAssays(metAssayRefB) 498 humanStudy.save( )504 humanStudy.save(failOnError:true) 499 505 } 506 507 /** 508 * Add test studies. This function is meant to be called only in test mode 509 */ 510 static addTestStudies() { 511 512 final String testStudyName = "Test study" 513 final String testStudyTemplateName = "Academic study" 514 final String testStudyCode = "AAA-Test" 515 final String testStudyDescription = "Description of Test Study" 516 final Date testStudyStartDate = Date.parse('yyyy-MM-dd','2007-12-11') 517 518 def studyTemplate = Template.findByName(testStudyTemplateName) 519 assert studyTemplate 520 521 def study = new Study( 522 title: testStudyName, 523 template: studyTemplate, 524 startDate: testStudyStartDate, 525 code: testStudyCode, 526 description: testStudyDescription 527 ) 528 529 study.save(failOnError: true) 530 531 } 500 532 } 533 534 //package dbnp.configuration 535 // 536 ///** 537 // * @Author kees 538 // * @Since Jun 25, 2010 539 // * 540 // * Revision information: 541 // * $Rev$ 542 // * $Author$ 543 // * $Date$ 544 // */ 545 // 546 //import dbnp.studycapturing.* 547 //import org.dbnp.gdt.* 548 //import org.codehaus.groovy.grails.commons.GrailsApplication 549 //import grails.util.GrailsUtil 550 //import dbnp.rest.common.CommunicationManager 551 //import org.codehaus.groovy.grails.commons.* 552 // 553 // 554 //class ExampleStudies { 555 // 556 // /** 557 // * Add example studies. This function is meant to be called only in development mode 558 // */ 559 // public static void addExampleStudies(dbnp.authentication.SecUser owner, dbnp.authentication.SecUser otherUser) { 560 // "inserting initial studies".grom() 561 // 562 // // get configuration 563 // def config = ConfigurationHolder.config 564 // 565 // // Look up the used ontologies which should be in the database by now 566 // def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 567 // def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) 568 // def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) 569 // def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) 570 // 571 // // Look up the used templates which should also be in the database by now 572 // def studyTemplate = Template.findByName("Academic study") 573 // def mouseTemplate = Template.findByName("Mouse") 574 // def humanTemplate = Template.findByName("Human") 575 // def dietTreatmentTemplate = Template.findByName("Diet treatment") 576 // def boostTreatmentTemplate = Template.findByName("Compound challenge") 577 // def liverSamplingEventTemplate = Template.findByName("Liver extraction") 578 // def fastingTreatmentTemplate = Template.findByName("Fasting treatment") 579 // def bloodSamplingEventTemplate = Template.findByName("Blood extraction") 580 // def humanTissueSampleTemplate = Template.findByName("Human tissue sample") 581 // def humanBloodSampleTemplate = Template.findByName("Human blood sample") 582 // def ccAssayTemplate = Template.findByName("Clinical chemistry assay") 583 // def metAssayTemplate = Template.findByName("Metabolomics assay") 584 // 585 // // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website 586 // def mouseTerm = new Term( 587 // name : 'Mus musculus', 588 // ontology : speciesOntology, 589 // accession : '10090' 590 // ).with { if (!validate()) { errors.each { println it} } else save()} 591 // 592 // def humanTerm = new Term( 593 // name : 'Homo sapiens', 594 // ontology : speciesOntology, 595 // accession : '9606' 596 // ).with { if (!validate()) { errors.each { println it} } else save()} 597 // 598 // def arabTerm = new Term( 599 // name : 'Arabidopsis thaliana', 600 // ontology : speciesOntology, 601 // accession : '3702' 602 // ).with { if (!validate()) { errors.each { println it} } else save()} 603 // 604 // def tomatoTerm = new Term( 605 // name : 'Solanum lycopersicum', 606 // ontology : speciesOntology, 607 // accession : '4081' 608 // ).with { if (!validate()) { errors.each { println it} } else save()} 609 // 610 // def potatoTerm = new Term( 611 // name : 'Solanum tuberosum', 612 // ontology : speciesOntology, 613 // accession : '0000' 614 // ).with { if (!validate()) { errors.each { println it} } else save()} 615 // 616 // def bloodTerm = new Term( 617 // name : 'blood plasma', 618 // ontology : brendaOntology, 619 // accession : 'BTO:0000131' 620 // ).with { if (!validate()) { errors.each { println it} } else save()} 621 // 622 // def c57bl6Term = new Term( 623 // name : 'C57BL/6 Mouse', 624 // ontology : nciOntology, 625 // accession : 'C14424' 626 // ).with { if (!validate()) { errors.each { println it} } else save()} 627 // 628 // def glucoseTerm = new Term( 629 // name : 'glucose', 630 // ontology : chebiOntology, 631 // accession : 'CHEBI:17234' 632 // ).with { if (!validate()) { errors.each { println it} } else save()} 633 // 634 // // Create a few persons, roles and Affiliations 635 // def affiliation1 = new PersonAffiliation( 636 // institute : "Science Institute NYC", 637 // department : "Department of Mathematics" 638 // ).save(); 639 // def affiliation2 = new PersonAffiliation( 640 // institute : "InfoStats GmbH, Hamburg", 641 // department : "Life Sciences" 642 // ).save(); 643 // def role1 = new PersonRole( 644 // name : "Principal Investigator" 645 // ).save(); 646 // def role2 = new PersonRole( 647 // name : "Statician" 648 // ).save(); 649 // 650 // // Create persons 651 // def person1 = new Person( 652 // lastName : "Scientist", 653 // firstName : "John", 654 // gender : "Male", 655 // initials : "J.R.", 656 // email : "john@scienceinstitute.com", 657 // phone : "1-555-3049", 658 // address : "First street 2,NYC" 659 // ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save(); 660 // 661 // def person2 = new Person( 662 // lastName : "Statician", 663 // firstName : "Jane", 664 // gender : "Female", 665 // initials : "W.J.", 666 // email : "jane@statisticalcompany.de", 667 // phone : "49-555-8291", 668 // address : "Dritten strasse 38, Hamburg, Germany" 669 // ).addToAffiliations(affiliation2).save(); 670 // 671 // // Create 30 persons to test pagination 672 // def personCounter = 1; 673 // 30.times { 674 // new Person( 675 // firstName : "Person #${personCounter}", 676 // lastName : "Testperson", 677 // email : "email${personCounter++}@testdomain.com" 678 // ).save() 679 // } 680 // 681 // // Create a few publications 682 // def publication1 = new Publication( 683 // title : "Postnatal development of hypothalamic leptin receptors", 684 // authorsList : "Cottrell EC, Mercer JG, Ozanne SE.", 685 // pubMedID : "20472140", 686 // comments : "Not published yet", 687 // DOI : "unknown" 688 // ).save(); 689 // 690 // def publication2 = new Publication( 691 // title : "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice", 692 // authorsList : "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.", 693 // pubMedID : "20445103", 694 // comments : "", 695 // DOI : "" 696 // ).save(); 697 // 698 // // Add example mouse study 699 // def mouseStudy = new Study( 700 // template : studyTemplate, 701 // title : "NuGO PPS3 mouse study leptin module", 702 // 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.", 703 // code : "PPS3_leptin_module", 704 // researchQuestion: "Leptin etc.", 705 // ecCode : "2007117.c", 706 // startDate : Date.parse('yyyy-MM-dd', '2008-01-02'), 707 // owner : owner, 708 // readers : [otherUser] 709 // ).with { if (!validate()) { errors.each { println it} } else save()} 710 // 711 // def evLF = new Event( 712 // startTime : 3600, 713 // endTime : 3600 + 7 * 24 * 3600, 714 // template : dietTreatmentTemplate 715 // ).setFieldValue('Diet', 'low fat') 716 // 717 // def evHF = new Event( 718 // startTime : 3600, 719 // endTime : 3600 + 7 * 24 * 3600, 720 // template : dietTreatmentTemplate 721 // ).setFieldValue('Diet', 'high fat') 722 // 723 // def evBV = new Event( 724 // startTime : 3600, 725 // endTime : 3600 + 7 * 24 * 3600, 726 // template : boostTreatmentTemplate 727 // ).setFieldValue('Control', 'true') 728 // 729 // def evBL = new Event( 730 // startTime : 3600, 731 // endTime : 3600 + 7 * 24 * 3600, 732 // template : boostTreatmentTemplate 733 // ).setFieldValue('Control', 'false') 734 // 735 // def evLF4 = new Event( 736 // startTime : 3600, 737 // endTime : 3600 + 4 * 7 * 24 * 3600, 738 // template : dietTreatmentTemplate 739 // ).setFieldValue('Diet', 'low fat') 740 // 741 // def evHF4 = new Event( 742 // startTime : 3600, 743 // endTime : 3600 + 4 * 7 * 24 * 3600, 744 // template : dietTreatmentTemplate 745 // ).setFieldValue('Diet', 'high fat') 746 // 747 // def evBV4 = new Event( 748 // startTime : 3600, 749 // endTime : 3600 + 4 * 7 * 24 * 3600, 750 // template : boostTreatmentTemplate 751 // ).setFieldValue('Control', 'true') 752 // 753 // def evBL4 = new Event( 754 // startTime : 3600, 755 // endTime : 3600 + 4 * 7 * 24 * 3600, 756 // template : boostTreatmentTemplate 757 // ).setFieldValue('Control', 'false') 758 // 759 // def evS = new SamplingEvent( 760 // startTime : 3600 + 7 * 24 * 3600, 761 // template : liverSamplingEventTemplate, 762 // sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F) 763 // 764 // def evS4 = new SamplingEvent( 765 // startTime : 3600 + 7 * 24 * 3600, 766 // template : liverSamplingEventTemplate, 767 // sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F) 768 // 769 // // Add events to study 770 // 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()} 771 // 772 // // Extra check if the SamplingEvents are saved correctly 773 // evS.with { if (!validate()) { errors.each { println it} } else save()} 774 // evS4.with { if (!validate()) { errors.each { println it} } else save()} 775 // 776 // def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToEvents(evBV).addToSamplingEvents(evS) 777 // 778 // def LFBL1 = new EventGroup(name: "10% fat + leptin for 1 week").addToEvents(evLF).addToEvents(evBL).addToSamplingEvents(evS) 779 // 780 // def HFBV1 = new EventGroup(name: "45% fat + vehicle for 1 week").addToEvents(evHF).addToEvents(evBV).addToSamplingEvents(evS) 781 // 782 // def HFBL1 = new EventGroup(name: "45% fat + leptin for 1 week").addToEvents(evHF).addToEvents(evBL).addToSamplingEvents(evS) 783 // 784 // def LFBV4 = new EventGroup(name: "10% fat + vehicle for 4 weeks").addToEvents(evLF4).addToEvents(evBV4).addToSamplingEvents(evS4) 785 // 786 // def LFBL4 = new EventGroup(name: "10% fat + leptin for 4 weeks").addToEvents(evLF4).addToEvents(evBL4).addToSamplingEvents(evS4) 787 // 788 // def HFBV4 = new EventGroup(name: "45% fat + vehicle for 4 weeks").addToEvents(evHF4).addToEvents(evBV4).addToSamplingEvents(evS4) 789 // 790 // def HFBL4 = new EventGroup(name: "45% fat + leptin for 4 weeks").addToEvents(evHF4).addToEvents(evBL4).addToSamplingEvents(evS4) 791 // 792 // // Add subjects and samples and compose EventGroups 793 // def x = 1 794 // 80.times { 795 // def currentSubject = new Subject( 796 // name: "A" + x++, 797 // species: mouseTerm, 798 // template: mouseTemplate, 799 // ).setFieldValue("Gender", "Male").setFieldValue("Genotype", c57bl6Term).setFieldValue("Age", 17).setFieldValue("Cage", "" + (int) (x / 2)) 800 // 801 // // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set 802 // // (this is possibly a Grails or Hibernate bug) 803 // mouseStudy.addToSubjects(currentSubject) 804 // currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 805 // 806 // // Add subject to appropriate EventGroup 807 // if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 808 // else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 809 // else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 810 // else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 811 // else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 812 // else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 813 // else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 814 // else { LFBV1.addToSubjects(currentSubject).save() } 815 // 816 // // Create sample 817 // def currentSample = new Sample( 818 // name: currentSubject.name + '_B', 819 // material: bloodTerm, 820 // template: humanBloodSampleTemplate, 821 // parentSubject: currentSubject, 822 // parentEvent: evS //x > 40 ? evS4 : evS 823 // ); 824 // mouseStudy.addToSamples(currentSample) 825 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 826 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 827 // } 828 // 829 // // Add EventGroups to study 830 // 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()} 831 // 832 // // Add persons and publications to study 833 // def studyperson1 = new StudyPerson(person: person1, role: role1) 834 // def studyperson2 = new StudyPerson(person: person2, role: role2) 835 // 836 // mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()} 837 // 838 // def humanStudy = new Study( 839 // template : studyTemplate, 840 // title : "NuGO PPS human study", 841 // code : "PPSH", 842 // researchQuestion: "How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 843 // description : "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.", 844 // ecCode : "unknown", 845 // startDate : Date.parse('yyyy-MM-dd', '2008-01-14'), 846 // owner : owner, 847 // writers : [otherUser] 848 // ).with { if (!validate()) { errors.each { println it} } else save()} 849 // 850 // def rootGroup = new EventGroup(name: 'Root group'); 851 // 852 // def fastingEvent = new Event( 853 // startTime : 3 * 24 * 3600 + 22 * 3600, 854 // endTime : 3 * 24 * 3600 + 30 * 3600, 855 // template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h'); 856 // 857 // def bloodSamplingEventBefore = new SamplingEvent( 858 // startTime : 0, 859 // template : bloodSamplingEventTemplate, 860 // sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F); 861 // 862 // def bloodSamplingEventAfter = new SamplingEvent( 863 // startTime : 3 * 24 * 3600 + 30 * 3600, 864 // template : bloodSamplingEventTemplate, 865 // sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F); 866 // 867 // rootGroup.addToEvents fastingEvent 868 // rootGroup.addToSamplingEvents bloodSamplingEventBefore 869 // rootGroup.addToSamplingEvents bloodSamplingEventAfter 870 // rootGroup.save() 871 // 872 // humanStudy.addToEvents(fastingEvent) 873 // humanStudy.addToSamplingEvents(bloodSamplingEventBefore) 874 // humanStudy.addToSamplingEvents(bloodSamplingEventAfter) 875 // humanStudy.addToEventGroups rootGroup 876 // 877 // humanStudy.save() 878 // 879 // def y = 1 880 // 11.times { 881 // def currentSubject = new Subject( 882 // name : "" + y++, 883 // species : humanTerm, 884 // template : humanTemplate 885 // ).setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") 886 // //.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) 887 // 888 // humanStudy.addToSubjects(currentSubject) 889 // currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 890 // 891 // rootGroup.addToSubjects currentSubject 892 // rootGroup.save() 893 // 894 // def currentSample = new Sample( 895 // name : currentSubject.name + '_B', 896 // material : bloodTerm, 897 // template : humanBloodSampleTemplate, 898 // parentSubject: currentSubject, 899 // parentEvent : bloodSamplingEventBefore 900 // ); 901 // 902 // humanStudy.addToSamples(currentSample) 903 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 904 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 905 // 906 // currentSample = new Sample( 907 // name : currentSubject.name + '_A', 908 // material : bloodTerm, 909 // template : humanBloodSampleTemplate, 910 // parentSubject: currentSubject, 911 // parentEvent : bloodSamplingEventAfter 912 // ); 913 // 914 // humanStudy.addToSamples(currentSample) 915 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 916 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 917 // } 918 // 919 // // Add persons to study 920 // def studyperson3 = new StudyPerson(person: person1, role: role2) 921 // humanStudy.addToPersons(studyperson3).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()} 922 // 923 // // Add SAM assay reference 924 // def clinicalModule = new AssayModule( 925 // name: 'SAM module for clinical data', 926 // platform: 'clinical measurements', 927 // url: config.modules.sam.url.toString() 928 // ).with { if (!validate()) { errors.each { println it} } else save()} 929 // 930 // // Add metabolomics assay reference 931 // def metabolomicsModule = new AssayModule( 932 // name: 'Metabolomics module', 933 // platform: 'GCMS/LCMS', 934 // url: config.modules.metabolomics.url.toString() 935 // ).with { if (!validate()) { errors.each { println it} } else save()} 936 // 937 // // Add metabolomics assay reference 938 // def metagenomicsModule = new AssayModule( 939 // name: 'Metagenomics module', 940 // platform: 'High throughput sequencing', 941 // url: config.modules.metagenomics.url.toString() 942 // ).with { if (!validate()) { errors.each { println it} } else save()} 943 // 944 // def lipidAssayRef = new Assay( 945 // name: 'Lipid profiling', 946 // template: ccAssayTemplate, 947 // module: clinicalModule, 948 // externalAssayID: 'PPS3_SAM' 949 // ) 950 // 951 // def metAssayRef = new Assay( 952 // name: 'Lipidomics profile', 953 // template: metAssayTemplate, 954 // module: metabolomicsModule, 955 // externalAssayID: 'PPS3_Lipidomics' 956 // ).setFieldValue('Spectrometry technique', 'LC/MS') 957 // 958 // mouseStudy.samples*.each { 959 // lipidAssayRef.addToSamples(it) 960 // metAssayRef.addToSamples(it) 961 // } 962 // 963 // mouseStudy.addToAssays(lipidAssayRef); 964 // mouseStudy.addToAssays(metAssayRef); 965 // mouseStudy.save() 966 // 967 // def glucoseAssayBRef = new Assay( 968 // name : 'Glucose assay before', 969 // template : ccAssayTemplate, 970 // module : clinicalModule, 971 // externalAssayID: 'PPSH-Glu-B' 972 // ) 973 // 974 // def glucoseAssayARef = new Assay( 975 // name : 'Glucose assay after', 976 // template : ccAssayTemplate, 977 // module : clinicalModule, 978 // externalAssayID: 'PPSH-Glu-A' 979 // ) 980 // 981 // def metAssayRefB = new Assay( 982 // name : 'Lipidomics profile before', 983 // template : metAssayTemplate, 984 // module : metabolomicsModule, 985 // externalAssayID: 'PPSH_Lipidomics_start' 986 // ).setFieldValue('Spectrometry technique', 'GC/MS') 987 // 988 // def metAssayRefA = new Assay( 989 // name : 'Lipidomics profile after', 990 // template : metAssayTemplate, 991 // module : metabolomicsModule, 992 // externalAssayID: 'PPSH_Lipidomics_end' 993 // ).setFieldValue('Spectrometry technique', 'GC/MS') 994 // 995 // 996 // // Add sequencing (metagenomics) assays 997 // def sequencingAssay16SRef = new Assay( 998 // name : '16S Sequencing assay', 999 // template : ccAssayTemplate, 1000 // module : metagenomicsModule, 1001 // externalAssayID: 'PPSH-SEQ-16S' 1002 // ) 1003 // 1004 // // Add sequencing (metagenomics) assays 1005 // def sequencingAssay18SRef = new Assay( 1006 // name : '18S Sequencing assay', 1007 // template : ccAssayTemplate, 1008 // module : metagenomicsModule, 1009 // externalAssayID: 'PPSH-SEQ-18S' 1010 // ) 1011 // 1012 // humanStudy.samples*.each { 1013 // if (it.parentEvent.startTime == 0) { 1014 // glucoseAssayBRef.addToSamples(it) 1015 // metAssayRefB.addToSamples(it) 1016 // } 1017 // else { 1018 // glucoseAssayARef.addToSamples(it) 1019 // metAssayRefA.addToSamples(it) 1020 // sequencingAssay16SRef.addToSamples(it) 1021 // sequencingAssay18SRef.addToSamples(it) 1022 // } 1023 // } 1024 // 1025 // humanStudy.addToAssays(sequencingAssay16SRef) 1026 // humanStudy.addToAssays(sequencingAssay18SRef) 1027 // humanStudy.addToAssays(glucoseAssayARef) 1028 // humanStudy.addToAssays(glucoseAssayBRef) 1029 // humanStudy.addToAssays(metAssayRefA) 1030 // humanStudy.addToAssays(metAssayRefB) 1031 // humanStudy.save() 1032 // } 1033 //} -
trunk/grails-app/conf/dbnp/configuration/ExampleTemplates.groovy
r1581 r1588 36 36 ncboId: '1132', 37 37 ncboVersionedId: '38802' 38 ). with { if (!validate()) { errors.each { println it} } else save()}38 ).save(failOnError:true) 39 39 40 40 // add Sample>material ontology … … 46 46 ncboId: '1005', 47 47 ncboVersionedId: '40643' 48 ). with { if (!validate()) { errors.each { println it} } else save()}48 ).save(failOnError:true) 49 49 50 50 // add NCI ontology which is used in Mouse genotype template field … … 56 56 ncboId: '1032', 57 57 ncboVersionedId: '42838' 58 ). with { if (!validate()) { errors.each { println it} } else save()}58 ).save(failOnError:true) 59 59 60 60 // add CHEBI ontology which is used for describing chemicals in e.g. events … … 66 66 ncboId: '1007', 67 67 ncboVersionedId: '44746' 68 ). with { if (!validate()) { errors.each { println it} } else save()}68 ).save(failOnError:true) 69 69 70 70 } … … 89 89 name: 'Gender',type: TemplateFieldType.STRINGLIST, entity: Subject, 90 90 listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')]) 91 . with { if (!validate()) { errors.each { println it} } else save()}91 .save(failOnError:true) 92 92 93 93 def ageField = new TemplateField( 94 94 name: 'Age',type: TemplateFieldType.LONG,entity: Subject,unit: 'years',comment: 'Either include age at the start of the study or date of birth (if known)') 95 . with { if (!validate()) { errors.each { println it} } else save()}95 .save(failOnError:true) 96 96 97 97 def genotypeField = new TemplateField( 98 98 name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM,entity: Subject, 99 99 comment: 'If present, indicate the genetic variance of the subject (e.g., mutagenized populations,knock-out/in,transgene etc)') 100 .with { if (!validate()) { errors.each { println it} } else save()} 101 102 100 .save(failOnError:true) 101 102 def genotypeTypeField = new TemplateField( 103 103 name: 'Genotype type',type: TemplateFieldType.STRINGLIST,entity: Subject, 104 104 listEntries: [new TemplateFieldListItem(name:'wildtype'), … … 107 107 new TemplateFieldListItem(name:'knock-in')], 108 108 comment: 'If a genotype was specified, please indicate here the type of the genotype') 109 .with { if (!validate()) { errors.each { println it} } else save()} 109 .save(failOnError:true) 110 110 111 111 def varietyField = new TemplateField( 112 112 name: 'Variety', type: TemplateFieldType.STRING,entity: Subject, 113 113 comment: 'taxonomic category consisting of members of a species that differ from others of the same species in minor but heritable characteristics') 114 .with { if (!validate()) { errors.each { println it} } else save()} 114 .save(failOnError:true) 115 115 116 116 def ecotypeField = new TemplateField( 117 117 name: 'Ecotype', type: TemplateFieldType.STRING,entity: Subject, 118 118 comment: 'a type or subspecies of life that is especially well adapted to a certain environment' 119 ) 120 .with { if (!validate()) { errors.each { println it} } else save()} 119 ).save(failOnError:true) 121 120 122 121 // Nutritional study template … … 131 130 .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING,entity: Study,comment:'In which institute was the study performed; indicate the full address information (to be replaced by persons-affiliations?)')) 132 131 .addToFields(new TemplateField(name: 'Study protocol',type: TemplateFieldType.FILE,entity: Study,comment:'Optionally attach a file in which the protocol in the study is described')) 133 .with { if (!validate()) { errors.each { println it} } else save()} 132 .save(failOnError:true) 134 133 135 134 // Mouse template … … 154 153 .addToFields(new TemplateField( 155 154 name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',entity: Subject,comment:'If known indicate the weight of the subject in grams at the start of the study')) 156 .with { if (!validate()) { errors.each { println it} } else save()} 155 .save(failOnError:true) 157 156 158 157 // Human template … … 183 182 .addToFields(new TemplateField( 184 183 name: 'Run-in-food',type: TemplateFieldType.TEXT,entity: Subject, comment:'If defined, give a short description of the food used before the measurements')) 185 . with { if (!validate()) { errors.each { println it} } else save()}184 .save(failOnError:true) 186 185 187 186 def sampleRemarksField = new TemplateField( … … 189 188 type: TemplateFieldType.TEXT, 190 189 entity: Sample 191 ) 192 .with { if (!validate()) { errors.each { println it} } else save()} 190 ).save(failOnError:true) 193 191 194 192 def sampleVialTextField = new TemplateField( … … 196 194 type: TemplateFieldType.STRING, 197 195 entity: Sample 198 ) 199 .with { if (!validate()) { errors.each { println it} } else save()} 196 ).save(failOnError:true) 200 197 201 198 // Human tissue sample template … … 213 210 entity: Sample 214 211 ) 215 ) 216 .with { if (!validate()) { errors.each { println it} } else save()} 212 ).save(failOnError:true) 217 213 218 214 // Human blood sample template … … 230 226 entity: Sample 231 227 ) 232 ) 233 .with { if (!validate()) { errors.each { println it} } else save()} 234 235 236 /* 228 ).save(failOnError:true) 229 230 231 /* 237 232 * Add NMC - DCL Sample Mapping Template 238 233 * by Michael van Vliet 239 * 234 * 240 235 * For the Pilot running in Leiden (NOV2010) 241 236 */ … … 244 239 type: TemplateFieldType.STRING, 245 240 entity: Sample 246 ) 247 .with { if (!validate()) { errors.each { println it} } else save()} 241 ).save(failOnError:true) 248 242 249 243 // Human tissue sample template … … 253 247 ) 254 248 .addToFields(sampleDCLTextField) 255 .with { if (!validate()) { errors.each { println it} } else save()} 249 .save(failOnError:true) 256 250 // EO DCL Sample Mapping Template********************************** 257 258 251 252 259 253 /* 260 254 def GrowthTreatmentTemplate = new Template( … … 270 264 .addToFields(new TemplateField(name: 'Light Intensity',type: TemplateFieldType.STRING)) 271 265 .addToFields(new TemplateField(name: 'Harvest Delay',type: TemplateFieldType.STRING)) 272 . with { if (!validate()) { errors.each { println it} } else save()}266 .save(failOnError:true) 273 267 */ 274 268 … … 280 274 .addToFields(varietyField) 281 275 .addToFields(ecotypeField) 282 276 .addToFields(genotypeField) 283 277 /* 284 278 .addToFields(genotypeTypeField) … … 343 337 .addToFields(new TemplateField( 344 338 name: 'Additional info', entity: Subject, type: TemplateFieldType.TEXT)) 345 .with { if (!validate()) { errors.each { println it} } else save()} 339 .save(failOnError:true) 346 340 347 341 def FieldTemplate = new Template( … … 363 357 .addToFields(new TemplateField( 364 358 name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT)) 365 .with { if (!validate()) { errors.each { println it} } else save()} 359 .save(failOnError:true) 366 360 367 361 //Plant template … … 417 411 .addToFields(new TemplateField( 418 412 name: 'Harvest delay', type: TemplateFieldType.TEXT, entity: Subject)) 419 . with { if (!validate()) { errors.each { println it} } else save()}413 .save(failOnError:true) 420 414 421 415 def plantSampleTemplate = new Template( … … 425 419 .addToFields(sampleRemarksField) 426 420 .addToFields(sampleVialTextField) 427 .with { if (!validate()) { errors.each { println it} } else save()} 421 .save(failOnError:true) 428 422 429 423 def materialPrepTemplate = new Template( … … 463 457 entity: Event 464 458 ) 465 ) 466 .with { if (!validate()) { errors.each { println it} } else save()} 459 ).save(failOnError:true) 467 460 468 461 def protocolField = new TemplateField( … … 471 464 entity: Event, 472 465 comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the event' 473 ) 474 .with { if (!validate()) { errors.each { println it} } else save()} 466 ).save(failOnError:true) 467 475 468 476 469 // diet treatment template … … 491 484 ) 492 485 .addToFields(protocolField) 493 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 494 dietTreatmentTemplate.refresh() 486 .save(failOnError:true) 495 487 496 488 // boost treatment template … … 515 507 ) 516 508 .addToFields(protocolField) 517 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 518 boostTreatmentTemplate.refresh() 509 .save(failOnError:true) 519 510 520 511 // fasting treatment template … … 530 521 entity: Event 531 522 ) 532 ) 533 .with { if (!validate()) { errors.each { println it} } else save()} 523 ).save(failOnError:true) 534 524 535 525 // SamplingEvent templates … … 539 529 type: TemplateFieldType.FILE, 540 530 comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the sampling event' 541 ) 542 .with { if (!validate()) { errors.each { println it} } else save()} 531 ).save(failOnError:true) 543 532 544 533 // liver sampling event template … … 556 545 type: TemplateFieldType.DOUBLE 557 546 ) 558 ) 559 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 560 liverSamplingEventTemplate.refresh() 547 ).save(failOnError:true) 561 548 562 549 // blood sampling … … 574 561 type: TemplateFieldType.DOUBLE 575 562 ) 576 ) 577 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 578 bloodSamplingEventTemplate.refresh() 563 ).save(failOnError:true) 579 564 580 565 // plant sample extraction event template … … 605 590 ] 606 591 ) 607 ) 608 .with { if (!validate()) { errors.each { println it} } else save()} 592 ).save(failOnError:true) 609 593 610 594 // plant sampling event template … … 645 629 type: TemplateFieldType.STRING 646 630 ) 647 ) 648 .with { if (!validate()) { errors.each { println it} } else save()} 631 ).save(failOnError:true) 649 632 650 633 … … 655 638 entity: Assay, 656 639 type: TemplateFieldType.STRING 657 ); 658 assayDescriptionField.with { if (!validate()) { errors.each { println it} } else save()} 640 ).save(failOnError:true) 659 641 660 642 def ccAssayTemplate = new Template( … … 664 646 ) 665 647 .addToFields(assayDescriptionField) 666 . with { if (!validate()) { errors.each { println it} } else save()}648 .save(failOnError:true) 667 649 668 650 def metAssayTemplate = new Template( … … 684 666 new TemplateFieldListItem(name: 'HPLC') 685 667 ]) 686 ) 687 .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 688 metAssayTemplate.refresh() 668 ).save(failOnError:true) 689 669 } 690 670 691 671 } 672 673 ///** 674 // * @Author kees 675 // * @Since Jun 25, 2010 676 // * 677 // * Revision information: 678 // * $Rev$ 679 // * $Author$ 680 // * $Date$ 681 // */ 682 //package dbnp.configuration 683 // 684 // 685 //import dbnp.studycapturing.* 686 //import org.dbnp.gdt.* 687 //import org.codehaus.groovy.grails.commons.GrailsApplication 688 // 689 //class ExampleTemplates { 690 // 691 // /** 692 // * Add the ontologies that are necessary for the templates below manually 693 // * This function can be called to avoid the HTTP requests to BioPortal each time 694 // * (e.g. in development or automated test environments) 695 // */ 696 // public static void initTemplateOntologies() { 697 // "inserting initial ontologies".grom() 698 // 699 // // If running in development or test mode, add ontologies manually to speed up development and allow running offline 700 // if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT || grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST) { 701 // 702 // // add Species ontology which is used for a.o. the Subject domain field 'species' 703 // def speciesOntology = new Ontology( 704 // name: 'NCBI organismal classification', 705 // description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', 706 // url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', 707 // versionNumber: '1.2', 708 // ncboId: '1132', 709 // ncboVersionedId: '38802' 710 // ).with { if (!validate()) { errors.each { println it} } else save()} 711 // 712 // // add Sample>material ontology 713 // def brendaOntology = new Ontology( 714 // name: 'BRENDA tissue / enzyme source', 715 // description: 'A structured controlled vocabulary for the source of an enzyme. It comprises terms for tissues, cell lines, cell types and cell cultures from uni- and multicellular organisms.', 716 // url: 'http://www.brenda-enzymes.info', 717 // versionNumber: '1.3', 718 // ncboId: '1005', 719 // ncboVersionedId: '40643' 720 // ).with { if (!validate()) { errors.each { println it} } else save()} 721 // 722 // // add NCI ontology which is used in Mouse genotype template field 723 // def nciOntology = new Ontology( 724 // name: 'NCI Thesaurus', 725 // description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.', 726 // url: 'http://ncicb.nci.nih.gov/core/EVS', 727 // versionNumber: '10.03', 728 // ncboId: '1032', 729 // ncboVersionedId: '42838' 730 // ).with { if (!validate()) { errors.each { println it} } else save()} 731 // 732 // // add CHEBI ontology which is used for describing chemicals in e.g. events 733 // def chebiOntology = new Ontology( 734 // name: 'Chemical entities of biological interest', 735 // description: 'A structured classification of chemical compounds of biological relevance.', 736 // url: 'http://www.ebi.ac.uk/chebi', 737 // versionNumber: '1.73', 738 // ncboId: '1007', 739 // ncboVersionedId: '44746' 740 // ).with { if (!validate()) { errors.each { println it} } else save()} 741 // 742 // } 743 // // otherwise, this may be a production demo instance, so initialize the ontologies dynamically from BioPortal 744 // else { 745 // 746 // def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 747 // def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) 748 // def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) 749 // def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) 750 // } 751 // } 752 // 753 // 754 // /** 755 // * Add example templates, this function would normally be called on an empty database 756 // */ 757 // public static void initTemplates() { 758 // "inserting initial templates".grom() 759 // 760 // def genderField = new TemplateField( 761 // name: 'Gender',type: TemplateFieldType.STRINGLIST, entity: Subject, 762 // listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')]) 763 // .with { if (!validate()) { errors.each { println it} } else save()} 764 // 765 // def ageField = new TemplateField( 766 // name: 'Age',type: TemplateFieldType.LONG,entity: Subject,unit: 'years',comment: 'Either include age at the start of the study or date of birth (if known)') 767 // .with { if (!validate()) { errors.each { println it} } else save()} 768 // 769 // def genotypeField = new TemplateField( 770 // name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM,entity: Subject, 771 // comment: 'If present, indicate the genetic variance of the subject (e.g., mutagenized populations,knock-out/in,transgene etc)') 772 // .with { if (!validate()) { errors.each { println it} } else save()} 773 // 774 // def genotypeTypeField = new TemplateField( 775 // name: 'Genotype type',type: TemplateFieldType.STRINGLIST,entity: Subject, 776 // listEntries: [new TemplateFieldListItem(name:'wildtype'), 777 // new TemplateFieldListItem(name:'transgenic'), 778 // new TemplateFieldListItem(name:'knock-out'), 779 // new TemplateFieldListItem(name:'knock-in')], 780 // comment: 'If a genotype was specified, please indicate here the type of the genotype') 781 // .with { if (!validate()) { errors.each { println it} } else save()} 782 // 783 // def varietyField = new TemplateField( 784 // name: 'Variety', type: TemplateFieldType.STRING,entity: Subject, 785 // comment: 'taxonomic category consisting of members of a species that differ from others of the same species in minor but heritable characteristics') 786 // .with { if (!validate()) { errors.each { println it} } else save()} 787 // 788 // def ecotypeField = new TemplateField( 789 // name: 'Ecotype', type: TemplateFieldType.STRING,entity: Subject, 790 // comment: 'a type or subspecies of life that is especially well adapted to a certain environment' 791 // ) 792 // .with { if (!validate()) { errors.each { println it} } else save()} 793 // 794 // // Nutritional study template 795 // def studyTemplate = new Template( 796 // name: 'Academic study', 797 // entity: dbnp.studycapturing.Study 798 // ) 799 // .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,entity: Study,comment:'Fill out the aim or questions of the study')) 800 // .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')) 801 // .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING,entity: Study,comment:'If a cohort was used the name or code of the cohort can be define here (define a cohort template)')) 802 // .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING,entity: Study,comment:'In which lab was the study performed; indicate the roomnumber.')) 803 // .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING,entity: Study,comment:'In which institute was the study performed; indicate the full address information (to be replaced by persons-affiliations?)')) 804 // .addToFields(new TemplateField(name: 'Study protocol',type: TemplateFieldType.FILE,entity: Study,comment:'Optionally attach a file in which the protocol in the study is described')) 805 // .with { if (!validate()) { errors.each { println it} } else save()} 806 // 807 // // Mouse template 808 // def mouseTemplate = new Template( 809 // name: 'Mouse', entity: dbnp.studycapturing.Subject) 810 // .addToFields(new TemplateField( 811 // name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM, ontologies: [Ontology.getOrCreateOntologyByNcboId(1032)], entity: Subject, comment: "This is an ontology term, if the right strain is not in the list please add it with 'add more'")) 812 // .addToFields(genotypeField) 813 // .addToFields(genotypeTypeField) 814 // .addToFields(genderField) 815 // .addToFields(new TemplateField( 816 // name: 'Age', type: TemplateFieldType.LONG, entity: Subject, unit: 'weeks', comment: 'Age at start of study')) 817 // .addToFields(new TemplateField( 818 // name: 'Age type',type: TemplateFieldType.STRINGLIST,entity: Subject, 819 // listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) 820 // .addToFields(new TemplateField( 821 // name: 'Cage',type: TemplateFieldType.STRING,entity: Subject,comment:'Indicate the cage used for housing (type and/or size)')) 822 // .addToFields(new TemplateField( 823 // name: '#Mice in cage',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the number of mice per cage')) 824 // .addToFields(new TemplateField( 825 // name: 'Litter size',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the litter size of the litter from which the subject originates')) 826 // .addToFields(new TemplateField( 827 // name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',entity: Subject,comment:'If known indicate the weight of the subject in grams at the start of the study')) 828 // .with { if (!validate()) { errors.each { println it} } else save()} 829 // 830 // // Human template 831 // def humanTemplate = new Template( 832 // name: 'Human', entity: dbnp.studycapturing.Subject) 833 // .addToFields(genderField) 834 // .addToFields(ageField) 835 // .addToFields(new TemplateField( 836 // name: 'DOB',type: TemplateFieldType.DATE,entity: Subject,comment:'Date of birth')) 837 // .addToFields(new TemplateField( 838 // name: 'Height',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'm')) 839 // .addToFields(new TemplateField( 840 // name: 'Weight',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg')) 841 // .addToFields(new TemplateField( 842 // name: 'BMI',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg/m2',comment:'Body-mass-index')) 843 // .addToFields(new TemplateField( 844 // name: 'Race',type: TemplateFieldType.STRING,entity: Subject, comment:'If known and of interest the ethnic group can be indicated')) 845 // .addToFields(new TemplateField( 846 // name: 'Waist circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, comment:'The waist circumference is measured just above the hip bone. Indicate the measure at the start of the study.')) 847 // .addToFields(new TemplateField( 848 // name: 'Hip circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, comment:'The hip circumference is measured at the level of the two bony prominences front of the hips. Indicate the measure at the start of the study.')) 849 // .addToFields(new TemplateField( 850 // name: 'Systolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG')) 851 // .addToFields(new TemplateField( 852 // name: 'Diastolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG')) 853 // .addToFields(new TemplateField( 854 // name: 'Heart rate',type: TemplateFieldType.DOUBLE, unit: 'beats/min',entity: Subject, comment:'Indicate the heart rate at the start of in study in beats per minute')) 855 // .addToFields(new TemplateField( 856 // name: 'Run-in-food',type: TemplateFieldType.TEXT,entity: Subject, comment:'If defined, give a short description of the food used before the measurements')) 857 // .with { if (!validate()) { errors.each { println it} } else save()} 858 // 859 // def sampleRemarksField = new TemplateField( 860 // name: 'Remarks', 861 // type: TemplateFieldType.TEXT, 862 // entity: Sample 863 // ) 864 // .with { if (!validate()) { errors.each { println it} } else save()} 865 // 866 // def sampleVialTextField = new TemplateField( 867 // name: 'Text on vial', 868 // type: TemplateFieldType.STRING, 869 // entity: Sample 870 // ) 871 // .with { if (!validate()) { errors.each { println it} } else save()} 872 // 873 // // Human tissue sample template 874 // def humanSampleTemplate = new Template( 875 // name: 'Human tissue sample', 876 // entity: dbnp.studycapturing.Sample 877 // ) 878 // .addToFields(sampleRemarksField) 879 // .addToFields(sampleVialTextField) 880 // .addToFields( 881 // new TemplateField( 882 // name: 'Sample measured weight', 883 // unit: 'mg', 884 // type: TemplateFieldType.DOUBLE, 885 // entity: Sample 886 // ) 887 // ) 888 // .with { if (!validate()) { errors.each { println it} } else save()} 889 // 890 // // Human blood sample template 891 // def humanBloodSampleTemplate = new Template( 892 // name: 'Human blood sample', 893 // entity: dbnp.studycapturing.Sample 894 // ) 895 // .addToFields(sampleRemarksField) 896 // .addToFields(sampleVialTextField) 897 // .addToFields( 898 // new TemplateField( 899 // name: 'Sample measured volume', 900 // unit: 'ml', 901 // type: TemplateFieldType.DOUBLE, 902 // entity: Sample 903 // ) 904 // ) 905 // .with { if (!validate()) { errors.each { println it} } else save()} 906 // 907 // 908 // /* 909 // * Add NMC - DCL Sample Mapping Template 910 // * by Michael van Vliet 911 // * 912 // * For the Pilot running in Leiden (NOV2010) 913 // */ 914 // def sampleDCLTextField = new TemplateField( 915 // name: 'DCL Sample Reference', 916 // type: TemplateFieldType.STRING, 917 // entity: Sample 918 // ) 919 // .with { if (!validate()) { errors.each { println it} } else save()} 920 // 921 // // Human tissue sample template 922 // def dclSampleTemplate = new Template( 923 // name: 'DCL Sample information', 924 // entity: dbnp.studycapturing.Sample 925 // ) 926 // .addToFields(sampleDCLTextField) 927 // .with { if (!validate()) { errors.each { println it} } else save()} 928 // // EO DCL Sample Mapping Template********************************** 929 // 930 // 931 // /* 932 // def GrowthTreatmentTemplate = new Template( 933 // name: 'Growth treatment', 934 // entity: dbnp.studycapturing.Event 935 // ) 936 // .addToFields(sampleDescriptionField) 937 // .addToFields(new TemplateField(name: 'position X',type: TemplateFieldType.STRING)) 938 // .addToFields(new TemplateField(name: 'position Y',type: TemplateFieldType.STRING)) 939 // .addToFields(new TemplateField(name: 'Block',type: TemplateFieldType.STRING)) 940 // .addToFields(new TemplateField(name: 'Temparature Day',type: TemplateFieldType.STRING)) 941 // .addToFields(new TemplateField(name: 'Temparature Night',type: TemplateFieldType.STRING)) 942 // .addToFields(new TemplateField(name: 'Light Intensity',type: TemplateFieldType.STRING)) 943 // .addToFields(new TemplateField(name: 'Harvest Delay',type: TemplateFieldType.STRING)) 944 // .with { if (!validate()) { errors.each { println it} } else save()} 945 // */ 946 // 947 // //Plant template 948 // def greenHouseTemplate = new Template( 949 // name: 'Plant-green house ', 950 // entity: dbnp.studycapturing.Subject 951 // ) 952 // .addToFields(varietyField) 953 // .addToFields(ecotypeField) 954 // .addToFields(genotypeField) 955 // /* 956 // .addToFields(genotypeTypeField) 957 // .addToFields( 958 // new TemplateField( 959 // name: 'Growth location', type: TemplateFieldType.STRINGLIST, 960 // listEntries: [ 961 // new TemplateFieldListItem(name:'Greenhouse'), 962 // new TemplateFieldListItem(name: 'Field') 963 // ] 964 // ) 965 // ) 966 // .addToFields( 967 // new TemplateField( 968 // name: 'Room', type: TemplateFieldType.STRING, 969 // comment: 'Chamber number in case of Greenhouse' 970 // ) 971 // ) 972 // */ 973 // .addToFields( 974 // new TemplateField( 975 // name: 'Chamber no.', 976 // type: TemplateFieldType.STRING, 977 // entity: Subject, 978 // comment: 'Chamber number in the Greenhouse' 979 // ) 980 // ) 981 // .addToFields( 982 // new TemplateField( 983 // name: 'Growth type', 984 // entity: Subject, 985 // type: TemplateFieldType.STRINGLIST, 986 // listEntries: [ 987 // new TemplateFieldListItem(name:'Standard'), 988 // new TemplateFieldListItem(name: 'Experimental'), 989 // new TemplateFieldListItem(name: 'Unknown') 990 // ] 991 // ) 992 // ) 993 // .addToFields(new TemplateField( 994 // name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT)) 995 // .addToFields(new TemplateField( 996 // name: 'Position X', entity: Subject, type: TemplateFieldType.DOUBLE)) 997 // .addToFields(new TemplateField( 998 // name: 'Position Y', entity: Subject, type: TemplateFieldType.DOUBLE)) 999 // .addToFields(new TemplateField( 1000 // name: 'Block', entity: Subject, type: TemplateFieldType.STRING)) 1001 // .addToFields(new TemplateField( 1002 // name: 'Temperature at day', entity: Subject, type: TemplateFieldType.DOUBLE)) 1003 // .addToFields(new TemplateField( 1004 // name: 'Temperature at night', entity: Subject, type: TemplateFieldType.DOUBLE)) 1005 // .addToFields(new TemplateField( 1006 // name: 'Photo period', entity: Subject, type: TemplateFieldType.STRING)) 1007 // .addToFields(new TemplateField( 1008 // name: 'Light intensity', entity: Subject, type: TemplateFieldType.STRING)) 1009 // .addToFields(new TemplateField( 1010 // name: 'Start date', entity: Subject, type: TemplateFieldType.DATE)) 1011 // .addToFields(new TemplateField( 1012 // name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE)) 1013 // .addToFields(new TemplateField( 1014 // name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT)) 1015 // .addToFields(new TemplateField( 1016 // name: 'Additional info', entity: Subject, type: TemplateFieldType.TEXT)) 1017 // .with { if (!validate()) { errors.each { println it} } else save()} 1018 // 1019 // def FieldTemplate = new Template( 1020 // name: 'Plant-open field', 1021 // entity: dbnp.studycapturing.Subject 1022 // ) 1023 // .addToFields(varietyField) 1024 // .addToFields(ecotypeField) 1025 // .addToFields(genotypeField) 1026 // .addToFields(new TemplateField( 1027 // name: 'Start date', entity: Subject, type: TemplateFieldType.DATE)) 1028 // .addToFields(new TemplateField( 1029 // name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE)) 1030 // .addToFields(new TemplateField( 1031 // name: 'Growth type', entity: Subject, type: TemplateFieldType.STRINGLIST, 1032 // listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) 1033 // .addToFields(new TemplateField( 1034 // name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT)) 1035 // .addToFields(new TemplateField( 1036 // name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT)) 1037 // .with { if (!validate()) { errors.each { println it} } else save()} 1038 // 1039 // //Plant template 1040 // def chamberTemplate = new Template( 1041 // name: 'Plant-chamber', 1042 // entity: dbnp.studycapturing.Subject 1043 // ) 1044 // .addToFields(varietyField) 1045 // .addToFields(ecotypeField) 1046 // .addToFields(genotypeField) 1047 // /* 1048 // .addToFields(genotypeTypeField) 1049 // .addToFields( 1050 // new TemplateField( 1051 // name: 'Growth location', 1052 // type: TemplateFieldType.STRINGLIST, 1053 // listEntries: [ 1054 // new TemplateFieldListItem(name:'Greenhouse'), 1055 // new TemplateFieldListItem(name: 'Field') 1056 // ] 1057 // ) 1058 // ) 1059 // */ 1060 // .addToFields(new TemplateField( 1061 // name: 'Room', type: TemplateFieldType.STRING, entity: Subject, 1062 // comment: 'room number')) 1063 // .addToFields(new TemplateField( 1064 // name: 'Chamber no.', type: TemplateFieldType.STRING, entity: Subject, 1065 // comment: 'Chamber number')) 1066 // .addToFields(new TemplateField( 1067 // name: 'Block', type: TemplateFieldType.STRING, entity: Subject)) 1068 // .addToFields(new TemplateField( 1069 // name: 'Position X', type: TemplateFieldType.DOUBLE, entity: Subject)) 1070 // .addToFields(new TemplateField( 1071 // name: 'Position Y', type: TemplateFieldType.DOUBLE, entity: Subject)) 1072 // .addToFields(new TemplateField( 1073 // name: 'Temperature at day', type: TemplateFieldType.DOUBLE, entity: Subject)) 1074 // .addToFields(new TemplateField( 1075 // name: 'Temperature at night', type: TemplateFieldType.DOUBLE, entity: Subject)) 1076 // .addToFields(new TemplateField( 1077 // name: 'Photo period', type: TemplateFieldType.STRING, entity: Subject)) 1078 // .addToFields(new TemplateField( 1079 // name: 'Light intensity', type: TemplateFieldType.STRING, entity: Subject)) 1080 // .addToFields(new TemplateField( 1081 // name: 'Start date', type: TemplateFieldType.DATE, entity: Subject)) 1082 // .addToFields(new TemplateField( 1083 // name: 'Harvest date', type: TemplateFieldType.DATE, entity: Subject)) 1084 // .addToFields(new TemplateField( 1085 // name: 'Growth type', type: TemplateFieldType.STRINGLIST, entity: Subject, 1086 // listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) 1087 // .addToFields(new TemplateField( 1088 // name: 'Growth protocol', type: TemplateFieldType.TEXT, entity: Subject)) 1089 // .addToFields(new TemplateField( 1090 // name: 'Harvest delay', type: TemplateFieldType.TEXT, entity: Subject)) 1091 // .with { if (!validate()) { errors.each { println it} } else save()} 1092 // 1093 // def plantSampleTemplate = new Template( 1094 // name: 'Plant sample', 1095 // entity: dbnp.studycapturing.Sample 1096 // ) 1097 // .addToFields(sampleRemarksField) 1098 // .addToFields(sampleVialTextField) 1099 // .with { if (!validate()) { errors.each { println it} } else save()} 1100 // 1101 // def materialPrepTemplate = new Template( 1102 // name: 'Plant-material preparation', 1103 // description: 'material preparation', 1104 // entity: dbnp.studycapturing.Event 1105 // ) 1106 // .addToFields(new TemplateField( 1107 // name: 'Tissue', 1108 // type: TemplateFieldType.STRING, 1109 // entity: Event, 1110 // comment: 'organ/ fraction of culture/ plant part') 1111 // ) 1112 // .addToFields( 1113 // new TemplateField( 1114 // name: 'Grinding', 1115 // type: TemplateFieldType.STRINGLIST, 1116 // entity: Event, 1117 // listEntries: [ 1118 // new TemplateFieldListItem(name:'yes'), 1119 // new TemplateFieldListItem(name: 'no'), 1120 // new TemplateFieldListItem(name: 'unknown') 1121 // ] 1122 // ) 1123 // ) 1124 // .addToFields( 1125 // new TemplateField( 1126 // name: 'Storage location', 1127 // type: TemplateFieldType.STRING, 1128 // entity: Event 1129 // ) 1130 // ) 1131 // .addToFields( 1132 // new TemplateField( 1133 // name: 'protocol reference', 1134 // type: TemplateFieldType.STRING, 1135 // entity: Event 1136 // ) 1137 // ) 1138 // .with { if (!validate()) { errors.each { println it} } else save()} 1139 // 1140 // def protocolField = new TemplateField( 1141 // name: 'Protocol', 1142 // type: TemplateFieldType.FILE, 1143 // entity: Event, 1144 // comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the event' 1145 // ) 1146 // .with { if (!validate()) { errors.each { println it} } else save()} 1147 // 1148 // // diet treatment template 1149 // def dietTreatmentTemplate = new Template( 1150 // name: 'Diet treatment', 1151 // entity: dbnp.studycapturing.Event 1152 // ) 1153 // .addToFields( 1154 // new TemplateField( 1155 // name: 'Diet', 1156 // type: TemplateFieldType.STRINGLIST, 1157 // entity: Event, 1158 // listEntries: [ 1159 // new TemplateFieldListItem(name:'low fat'), 1160 // new TemplateFieldListItem(name: 'high fat') 1161 // ] 1162 // ) 1163 // ) 1164 // .addToFields(protocolField) 1165 // .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 1166 // dietTreatmentTemplate.refresh() 1167 // 1168 // // boost treatment template 1169 // def boostTreatmentTemplate = new Template( 1170 // name: 'Compound challenge', 1171 // entity: dbnp.studycapturing.Event 1172 // ) 1173 // .addToFields( 1174 // new TemplateField( 1175 // name: 'Compound', 1176 // type: TemplateFieldType.ONTOLOGYTERM, 1177 // entity: Event, 1178 // ontologies: [Ontology.getOrCreateOntologyByNcboId(1007)] 1179 // ) 1180 // ) 1181 // .addToFields( 1182 // new TemplateField( 1183 // name: 'Control', 1184 // type: TemplateFieldType.BOOLEAN, 1185 // entity: Event 1186 // ) 1187 // ) 1188 // .addToFields(protocolField) 1189 // .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 1190 // boostTreatmentTemplate.refresh() 1191 // 1192 // // fasting treatment template 1193 // def fastingTreatment = new Template( 1194 // name: 'Fasting treatment', 1195 // description: 'Fasting for a specific amount of time', 1196 // entity: dbnp.studycapturing.Event 1197 // ) 1198 // .addToFields( 1199 // new TemplateField( 1200 // name: 'Fasting period', 1201 // type: TemplateFieldType.RELTIME, 1202 // entity: Event 1203 // ) 1204 // ) 1205 // .with { if (!validate()) { errors.each { println it} } else save()} 1206 // 1207 // // SamplingEvent templates 1208 // def samplingProtocolField = new TemplateField( 1209 // name: 'Sample Protocol', 1210 // entity: SamplingEvent, 1211 // type: TemplateFieldType.FILE, 1212 // comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the sampling event' 1213 // ) 1214 // .with { if (!validate()) { errors.each { println it} } else save()} 1215 // 1216 // // liver sampling event template 1217 // def liverSamplingEventTemplate = new Template( 1218 // name: 'Liver extraction', 1219 // description: 'Liver sampling for transcriptomics arrays', 1220 // entity: dbnp.studycapturing.SamplingEvent 1221 // ) 1222 // .addToFields(samplingProtocolField) 1223 // .addToFields( 1224 // new TemplateField( 1225 // name: 'Sample weight', 1226 // unit: 'mg', 1227 // entity: SamplingEvent, 1228 // type: TemplateFieldType.DOUBLE 1229 // ) 1230 // ) 1231 // .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 1232 // liverSamplingEventTemplate.refresh() 1233 // 1234 // // blood sampling 1235 // def bloodSamplingEventTemplate = new Template( 1236 // name: 'Blood extraction', 1237 // description: 'Blood extraction targeted at lipid assays', 1238 // entity: dbnp.studycapturing.SamplingEvent 1239 // ) 1240 // .addToFields(samplingProtocolField) 1241 // .addToFields( 1242 // new TemplateField( 1243 // name: 'Sample volume', 1244 // entity: SamplingEvent, 1245 // unit: 'ml', 1246 // type: TemplateFieldType.DOUBLE 1247 // ) 1248 // ) 1249 // .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 1250 // bloodSamplingEventTemplate.refresh() 1251 // 1252 // // plant sample extraction event template 1253 // def plantSamplingExtractEventTemplate = new Template( 1254 // name: 'Plant sample extraction', 1255 // description: 'sample extraction', 1256 // entity: dbnp.studycapturing.SamplingEvent, 1257 // sampleTemplates: [plantSampleTemplate] 1258 // ) 1259 // .addToFields(samplingProtocolField) 1260 // .addToFields( 1261 // new TemplateField( 1262 // name: 'Sample weight', 1263 // unit: 'ul', 1264 // entity: SamplingEvent, 1265 // type: TemplateFieldType.DOUBLE 1266 // ) 1267 // ) 1268 // .addToFields( 1269 // new TemplateField( 1270 // name: 'Sample when measured', 1271 // type: TemplateFieldType.STRINGLIST, 1272 // entity: SamplingEvent, 1273 // listEntries: [ 1274 // new TemplateFieldListItem(name:'Dried'), 1275 // new TemplateFieldListItem(name: 'Fresh'), 1276 // new TemplateFieldListItem(name: 'Unknown') 1277 // ] 1278 // ) 1279 // ) 1280 // .with { if (!validate()) { errors.each { println it} } else save()} 1281 // 1282 // // plant sampling event template 1283 // def plantSamplingEventTemplate = new Template( 1284 // name: 'Plant-sample', 1285 // description: 'plant sample ', 1286 // entity: dbnp.studycapturing.SamplingEvent, 1287 // sampleTemplates: [plantSampleTemplate] 1288 // ) 1289 // //.addToFields(samplingProtocolField) 1290 // .addToFields( 1291 // new TemplateField( 1292 // name: 'material', 1293 // comment: 'physical charecteristic. e.g, grounded powder of tomato seed or liquid', 1294 // entity: SamplingEvent, 1295 // type: TemplateFieldType.STRING 1296 // ) 1297 // ) 1298 // .addToFields( 1299 // new TemplateField( 1300 // name: 'Description', 1301 // type: TemplateFieldType.STRING, 1302 // entity: SamplingEvent 1303 // ) 1304 // ) 1305 // .addToFields( 1306 // new TemplateField( 1307 // name: 'extracted material', 1308 // comment: 'substance to be extracted. e.g., lipids, volatiles, primary metabolites etc', 1309 // type: TemplateFieldType.STRING, 1310 // entity: SamplingEvent 1311 // ) 1312 // ) 1313 // .addToFields( 1314 // new TemplateField( 1315 // name: 'Text on vial', 1316 // entity: SamplingEvent, 1317 // type: TemplateFieldType.STRING 1318 // ) 1319 // ) 1320 // .with { if (!validate()) { errors.each { println it} } else save()} 1321 // 1322 // 1323 // // assay templates 1324 // def assayDescriptionField = new TemplateField( 1325 // name: 'Description', 1326 // comment: 'add general assay information here', 1327 // entity: Assay, 1328 // type: TemplateFieldType.STRING 1329 // ); 1330 // assayDescriptionField.with { if (!validate()) { errors.each { println it} } else save()} 1331 // 1332 // def ccAssayTemplate = new Template( 1333 // name: 'Clinical chemistry assay', 1334 // description: 'Clinical chemistry assay stored in a SAM module', 1335 // entity: dbnp.studycapturing.Assay 1336 // ) 1337 // .addToFields(assayDescriptionField) 1338 // .with { if (!validate()) { errors.each { println it} } else save()} 1339 // 1340 // def metAssayTemplate = new Template( 1341 // name: 'Metabolomics assay', 1342 // description: 'Metabolomics assay stored in a metabolomics module', 1343 // entity: dbnp.studycapturing.Assay 1344 // ) 1345 // .addToFields(assayDescriptionField) 1346 // .addToFields( 1347 // new TemplateField( 1348 // name: 'Spectrometry technique', 1349 // comment: 'Select the used metabolomics technique', 1350 // entity: Assay, 1351 // type: TemplateFieldType.STRINGLIST, 1352 // listEntries: [ 1353 // new TemplateFieldListItem(name: 'GC/MS'), 1354 // new TemplateFieldListItem(name: 'LC/MS'), 1355 // new TemplateFieldListItem(name: 'NMR'), 1356 // new TemplateFieldListItem(name: 'HPLC') 1357 // ]) 1358 // ) 1359 // .with { if (!validate()) { errors.each { println it} } else save(flush:true)} 1360 // metAssayTemplate.refresh() 1361 // } 1362 // 1363 //} -
trunk/grails-app/controllers/RestController.groovy
r1579 r1588 30 30 /**************************************************/ 31 31 32 def AuthenticationService33 def beforeInterceptor = [action:this.&auth,except:["isUser"]]32 def authenticationService 33 // def beforeInterceptor = [action:this.&auth,except:["isUser"]] 34 34 def credentials 35 35 def requestUser … … 45 45 */ 46 46 private def auth() { 47 if( ! AuthenticationService.isRemotelyLoggedIn( params.consumer, params.token ) ) {47 if( !authenticationService.isRemotelyLoggedIn( params.consumer, params.token ) ) { 48 48 response.sendError(403) 49 49 return false … … 63 63 */ 64 64 def isUser = { 65 boolean isUser = AuthenticationService.isRemotelyLoggedIn( params.consumer, params.token )65 boolean isUser = authenticationService.isRemotelyLoggedIn( params.consumer, params.token ) 66 66 def reply = ['authenticated':isUser] 67 67 render reply as JSON … … 78 78 */ 79 79 def getUser = { 80 SecUser user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )80 SecUser user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) 81 81 def reply = [username: user.username, id: user.id] 82 82 render reply as JSON … … 139 139 def study = Study.findByStudyUUID( params.studyToken ) 140 140 if( study ) { 141 if( !study.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {141 if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) { 142 142 response.sendError(401) 143 143 return false … … 162 162 studies.each { study -> 163 163 if(study) { 164 def user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )164 def user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) 165 165 // Check whether the person is allowed to read the data of this study 166 if( study.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {166 if( study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 167 167 168 168 def items = [studyToken:study.giveUUID()] … … 214 214 study = Study.findByStudyUUID( params.studyToken ) 215 215 if( study ) { 216 if( !study.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {216 if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) { 217 217 response.sendError(401) 218 218 return false … … 249 249 if(study) { 250 250 // Check whether the person is allowed to read the data of this study 251 if( !study.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {251 if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 252 252 response.sendError(401) 253 253 return false … … 321 321 if(study) { 322 322 // Check whether the person is allowed to read the data of this study 323 if( !study.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {323 if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 324 324 response.sendError(401) 325 325 return false … … 443 443 if( assay ) { 444 444 // Check whether the person is allowed to read the data of this study 445 if( !assay.parent.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {445 if( !assay.parent.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 446 446 response.sendError(401) 447 447 return false … … 456 456 } else { 457 457 // Find all samples from studies the user can read 458 def studies = Study.list().findAll { it.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) ) };458 def studies = Study.list().findAll { it.canRead( authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) ) }; 459 459 samples = studies*.getSamples().flatten(); 460 460 } … … 537 537 } 538 538 539 def user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token );539 def user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ); 540 540 def auth = ['isOwner': study.isOwner(user), 'canRead': study.canRead(user), 'canWrite': study.canWrite(user)]; 541 541 log.trace "Authorization for study " + study.title + " and user " + user.username + ": " + auth -
trunk/grails-app/controllers/dbnp/authentication/LoginController.groovy
r1430 r1588 28 28 * Dependency injection for the GSCF authentication service 29 29 */ 30 def AuthenticationService30 def authenticationService 31 31 32 32 /** … … 75 75 // If the user is already authenticated with this session_id, redirect 76 76 // him 77 if( AuthenticationService.isRemotelyLoggedIn( consumer, token ) ) {77 if( authenticationService.isRemotelyLoggedIn( consumer, token ) ) { 78 78 if( returnUrl ) { 79 79 redirect url: returnUrl … … 85 85 // If the user is already logged in locally, we log him in and 86 86 // immediately redirect him 87 if ( AuthenticationService.isLoggedIn()) {88 AuthenticationService.logInRemotely( consumer, token, AuthenticationService.getLoggedInUser() )87 if (authenticationService.isLoggedIn()) { 88 authenticationService.logInRemotely( consumer, token, authenticationService.getLoggedInUser() ) 89 89 90 90 if( returnUrl ) { -
trunk/grails-app/controllers/dbnp/authentication/LogoutController.groovy
r1482 r1588 4 4 5 5 class LogoutController { 6 def AuthenticationService6 def authenticationService 7 7 8 8 /** … … 24 24 if( params.consumer || params.token ) { 25 25 // Log out the remote user 26 AuthenticationService.logOffRemotely( params.consumer, params.token )26 authenticationService.logOffRemotely( params.consumer, params.token ) 27 27 } 28 28 -
trunk/grails-app/controllers/dbnp/exporter/ExporterController.groovy
r1456 r1588 1 1 /** 2 * ExporterController Control er2 * ExporterController Controller 3 3 * 4 4 * Description of my controller … … 32 32 class ExporterController { 33 33 34 def AuthenticationService 35 def ImporterService 34 def authenticationService 36 35 37 36 /* … … 41 40 def index = { 42 41 43 def user = AuthenticationService.getLoggedInUser()42 def user = authenticationService.getLoggedInUser() 44 43 def max = Math.min(params.max ? params.int('max') : 10, 100) 45 44 -
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1562 r1588 27 27 def authenticationService 28 28 def fileService 29 def ImporterService29 def importerService 30 30 def validationTagLib = new ValidationTagLib() 31 def GdtService31 def gdtService 32 32 33 33 /** … … 114 114 115 115 if (params.entity) { 116 flash.importer_datatemplates = Template.findAllByEntity( GdtService.getInstanceByEntity(params.entity.decodeURL()))116 flash.importer_datatemplates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL())) 117 117 } 118 118 … … 133 133 134 134 if (params.entity) { 135 flash.importer_datatemplates = Template.findAllByEntity( GdtService.getInstanceByEntity(params.entity.decodeURL()))135 flash.importer_datatemplates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL())) 136 136 } 137 137 … … 320 320 def ajaxGetTemplatesByEntity = { 321 321 // fetch all templates for a specific entity 322 def templates = Template.findAllByEntity( GdtService.getInstanceByEntity(params.entity.decodeURL()))322 def templates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL())) 323 323 324 324 … … 340 340 if (importedfile.exists()) { 341 341 try { 342 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile))342 session.importer_workbook = importerService.getWorkbook(new FileInputStream(importedfile)) 343 343 } catch (Exception e) { 344 344 log.error ".importer wizard could not load file: " + e … … 351 351 352 352 try { 353 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile))353 session.importer_workbook = importerService.getWorkbook(new FileInputStream(importedfile)) 354 354 } catch (Exception e) { 355 355 log.error ".importer wizard could not load file: " + e … … 360 360 def selectedentities = [] 361 361 362 def entityName = GdtService.decryptEntity(params.entity.decodeURL())363 def entityClass = GdtService.getInstanceByEntityName(entityName)362 def entityName = gdtService.decryptEntity(params.entity.decodeURL()) 363 def entityClass = gdtService.getInstanceByEntityName(entityName) 364 364 365 365 // Initialize some session variables … … 371 371 flow.importer_headerrow = params.headerrow.toInteger() 372 372 flow.importer_entityclass = entityClass 373 flow.importer_entity = GdtService.cachedEntities.find{ it.entity==entityName }373 flow.importer_entity = gdtService.cachedEntities.find{ it.entity==entityName } 374 374 375 375 // Get the header from the Excel file using the arguments given in the first step of the wizard 376 flow.importer_header = ImporterService.getHeader(session.importer_workbook,376 flow.importer_header = importerService.getHeader(session.importer_workbook, 377 377 flow.importer_sheetindex, 378 378 flow.importer_headerrow, … … 380 380 entityClass) 381 381 382 session.importer_datamatrix = ImporterService.getDatamatrix(382 session.importer_datamatrix = importerService.getDatamatrix( 383 383 session.importer_workbook, flow.importer_header, 384 384 flow.importer_sheetindex, … … 437 437 // Create an actual class instance of the selected entity with the selected template 438 438 // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities 439 //def entityClass = GdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName())439 //def entityClass = gdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName()) 440 440 def entityObj = flow.importer_entityclass.newInstance(template:template) 441 441 … … 520 520 521 521 // Import the workbook and store the table with entity records and store the failed cells 522 def (table, failedcells) = ImporterService.importData(flow.importer_template_id,522 def (table, failedcells) = importerService.importData(flow.importer_template_id, 523 523 session.importer_workbook, 524 524 flow.importer_sheetindex, … … 661 661 //def (validatedSuccesfully, updatedEntities, failedToPersist) = 662 662 //try { 663 ImporterService.saveDatamatrix(flow.importer_study, flow.importer_importeddata, authenticationService, log)663 importerService.saveDatamatrix(flow.importer_study, flow.importer_importeddata, authenticationService, log) 664 664 665 665 //} -
trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy
r1494 r1588 11 11 */ 12 12 class StudyController { 13 def AuthenticationService13 def authenticationService 14 14 15 15 //static allowedMethods = [save: "POST", update: "POST", delete: "POST"] … … 24 24 def list = { 25 25 26 def user = AuthenticationService.getLoggedInUser()26 def user = authenticationService.getLoggedInUser() 27 27 def max = Math.min(params.max ? params.int('max') : 10, 100) 28 28 def offset = params.offset ? params.int( 'offset' ) : 0 … … 37 37 @Secured(['IS_AUTHENTICATED_REMEMBERED']) 38 38 def myStudies = { 39 def user = AuthenticationService.getLoggedInUser()39 def user = authenticationService.getLoggedInUser() 40 40 def max = Math.min(params.max ? params.int('max') : 10, 100) 41 41 def offset = params.offset ? params.int( 'offset' ) : 0 … … 88 88 else { 89 89 // Check whether the user may see this study 90 def loggedInUser = AuthenticationService.getLoggedInUser()90 def loggedInUser = authenticationService.getLoggedInUser() 91 91 if( !studyInstance.canRead(loggedInUser) ) { 92 92 flash.message = "You have no access to this study" … … 111 111 return 112 112 113 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]113 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 114 114 } 115 115 … … 124 124 return 125 125 126 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]126 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 127 127 } 128 128 … … 137 137 return 138 138 139 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]139 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 140 140 } 141 141 … … 150 150 return 151 151 152 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]152 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 153 153 } 154 154 … … 163 163 return 164 164 165 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]165 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 166 166 } 167 167 … … 176 176 return 177 177 178 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]178 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 179 179 } 180 180 … … 189 189 return 190 190 191 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]191 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ] 192 192 } 193 193 … … 236 236 // Check whether the user may see these studies 237 237 def studiesAllowed = [] 238 def loggedInUser = AuthenticationService.getLoggedInUser()238 def loggedInUser = authenticationService.getLoggedInUser() 239 239 240 240 studyList.each { studyInstance -> … … 262 262 else { 263 263 // Check whether the user may see this study 264 def loggedInUser = AuthenticationService.getLoggedInUser()264 def loggedInUser = authenticationService.getLoggedInUser() 265 265 if( !studyInstance.canRead(loggedInUser) ) { 266 266 flash.message = "You have no access to this study" -
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r1545 r1588 73 73 // The material domain field is optional 74 74 material(nullable: true) 75 75 76 76 sampleUUID(nullable: true, unique: true) 77 77 -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r1585 r1588 694 694 } 695 695 696 // This closure is used in the before{Insert,Update,Delete} closures below. 697 // It is necessary to prevent flushing in the same session as a top level 698 // database action such as 'save' or 'addTo...'. This confuses hibernate and 699 // produces hard to trace errors. 700 // The same holds for flushing during validation (but that's not the case 701 // here). 702 // http://grails.1312388.n4.nabble.com/Grails-hibernate-flush-causes-IndexOutOfBoundsException-td3031979.html 703 static manualFlush(closure) { 704 withSession {session -> 705 def save 706 try { 707 save = session.flushMode 708 session.flushMode = org.hibernate.FlushMode.MANUAL 709 closure() 710 } finally { 711 if (save) { 712 session.flushMode = save 713 } 714 } 715 } 716 } 717 696 718 // Send messages to modules about changes in this study 697 719 def beforeInsert = { 698 moduleNotificationService.invalidateStudy( this ); 720 manualFlush{cd .. 721 moduleNotificationService.invalidateStudy( this ) 722 } 699 723 } 700 724 def beforeUpdate = { 701 moduleNotificationService.invalidateStudy( this ); 725 manualFlush{ 726 moduleNotificationService.invalidateStudy( this ) 727 } 702 728 } 703 729 def beforeDelete = { 704 moduleNotificationService.invalidateStudy( this ); 730 manualFlush{ 731 moduleNotificationService.invalidateStudy( this ) 732 } 705 733 } 706 734 } -
trunk/grails-app/services/dbnp/authentication/AuthenticationService.groovy
r1577 r1588 18 18 19 19 class AuthenticationService { 20 def SpringSecurityService20 def springSecurityService 21 21 static final int expiryTime = 60; // Number of minutes a remotely logged in user remains active 22 22 23 booleantransactional = true23 static transactional = true 24 24 25 25 public boolean isLoggedIn() { 26 return SpringSecurityService.isLoggedIn();26 return springSecurityService.isLoggedIn(); 27 27 } 28 28 29 29 public SecUser getLoggedInUser() { 30 def principal = SpringSecurityService.getPrincipal()30 def principal = springSecurityService.getPrincipal() 31 31 32 32 // If the user is logged in, the principal should be a GrailsUser object. -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1553 r1588 22 22 def authenticationService 23 23 24 booleantransactional = true24 static transactional = true 25 25 26 26 /** -
trunk/grails-app/services/dbnp/modules/ModuleNotificationService.groovy
r1581 r1588 19 19 20 20 class ModuleNotificationService implements Serializable { 21 booleantransactional = false21 static transactional = false 22 22 23 23 /** -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r1552 r1588 25 25 class ImporterTagLib { 26 26 static namespace = 'importer' 27 def ImporterService28 def GdtService27 def importerService 28 def gdtService 29 29 30 30 /** … … 130 130 // Just return the matched value only 131 131 if (returnmatchonly) 132 out << ImporterService.mostSimilar(matchvalue, templatefields, fuzzyTreshold)132 out << importerService.mostSimilar(matchvalue, templatefields, fuzzyTreshold) 133 133 else // Return a selectbox 134 134 out << createPropertySelect(attrs['name'], templatefields, matchvalue, selected, mc.index, fuzzyTreshold) … … 147 147 def createPropertySelect(String name, options, matchvalue, selected, Integer columnIndex, float fuzzyTreshold = 0.1f) { 148 148 // Determine which field in the options list matches the best with the matchvalue 149 def mostsimilar = (matchvalue) ? ImporterService.mostSimilar(matchvalue, options, fuzzyTreshold) : ""149 def mostsimilar = (matchvalue) ? importerService.mostSimilar(matchvalue, options, fuzzyTreshold) : "" 150 150 151 151 def res = "<select style=\"font-size:10px\" id=\"${name}.index.${columnIndex}\" name=\"${name}.index.${columnIndex}\">" … … 186 186 def res = "<select style=\"font-size:10px\" name=\"${name}.index.${custval}\">" 187 187 188 GdtService.getTemplateEntities().each { e ->188 gdtService.getTemplateEntities().each { e -> 189 189 res += "<option value\"${e.name}\"" 190 190 res += ">${e.name} bla</option>" -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r1565 r1588 17 17 */ 18 18 class WizardTagLib extends GdtTagLib { 19 def AuthenticationService19 def authenticationService 20 20 21 21 /** … … 39 39 def studySelect = { attrs -> 40 40 // Find all studies the user has access to (max 100) 41 attrs.from = Study.giveWritableStudies( AuthenticationService.getLoggedInUser(), 100);41 attrs.from = Study.giveWritableStudies(authenticationService().getLoggedInUser(), 100); 42 42 43 43 // got a name? -
trunk/src/templates/artifacts/Service.groovy
r1580 r1588 9 9 * 10 10 * Revision information: 11 * $Rev $12 * $Author $13 * $Date $11 * $Rev: 1430 $ 12 * $Author: work@osx.eu $ 13 * $Date: 2011-01-21 21:05:36 +0100 (Fri, 21 Jan 2011) $ 14 14 */ 15 15 @artifact.package@class @artifact.name@ { 16 16 17 booleantransactional = true17 static transactional = true 18 18 19 19 def serviceMethod() { -
trunk/test/integration/RestControllerIntegrationTests.groovy
r1433 r1588 17 17 */ 18 18 class RestControllerIntegrationTests extends ControllerUnitTestCase { 19 def AuthenticationService19 def authenticationService 20 20 21 21 String consumer = "TEST" … … 29 29 super.setUp() 30 30 31 controller. AuthenticationService = AuthenticationService31 controller.authenticationService = authenticationService 32 32 } 33 33 … … 46 46 47 47 // Check whether the user is really logged in 48 assert AuthenticationService.isRemotelyLoggedIn( consumer, token )48 assert authenticationService.isRemotelyLoggedIn( consumer, token ) 49 49 50 50 // Set authentication parameters -
trunk/test/integration/dbnp/query/SampleSearchTests.groovy
r1521 r1588 3 3 import dbnp.authentication.SecUser 4 4 import dbnp.studycapturing.* 5 import dbnp.configuration. *5 import dbnp.configuration.ExampleStudies 6 6 7 7 /** … … 23 23 protected void setUp() { 24 24 super.setUp() 25 // 26 // def owner = SecUser.findByUsername( "user" ); 27 // 28 // // Look up the used ontologies which should be in the database by now 29 // def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 30 // 31 // // Look up the used templates which should also be in the database by now 32 // def studyTemplate = Template.findByName("Academic study") 33 // def mouseTemplate = Template.findByName("Mouse") 34 // def dietTreatmentTemplate = Template.findByName("Diet treatment") 35 // def liverSamplingEventTemplate = Template.findByName("Liver extraction") 36 // def humanTissueSampleTemplate = Template.findByName("Human tissue sample") 37 // def ccAssayTemplate = Template.findByName("Clinical chemistry assay") 38 // 39 // // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website 40 // def mouseTerm = Term.findByName( "Mus musculus" ); 41 // 42 // // Add example mouse study 43 // def testStudy = new Study( 44 // template : studyTemplate, 45 // title : "TestStudy 1", 46 // 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.", 47 // code : "TESTPPS3_leptin_module", 48 // researchQuestion: "Leptin etc.", 49 // ecCode : "2007117.c", 50 // startDate : Date.parse('yyyy-MM-dd', '2008-01-02'), 51 // owner : owner 52 // ).with { if (!validate()) { errors.each { println it} } else save()} 53 // 54 // 55 // def evLF = new Event( 56 // startTime : 3600, 57 // endTime : 3600 + 7 * 24 * 3600, 58 // template : dietTreatmentTemplate 59 // ).setFieldValue('Diet', 'low fat') 60 // 61 // def evS = new SamplingEvent( 62 // startTime : 3600, 63 // template : liverSamplingEventTemplate, 64 // sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F) 65 // 66 // // Add events to study 67 // testStudy.addToEvents(evLF).addToSamplingEvents(evS).with { if (!validate()) { errors.each { println it} } else save()} 68 // 69 // // Extra check if the SamplingEvents are saved correctly 70 // evS.with { if (!validate()) { errors.each { println it} } else save()} 71 // evLF.with { if (!validate()) { errors.each { println it} } else save()} 72 // 73 // 74 // def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToSamplingEvents(evS) 75 // 76 // // Add subjects and samples and compose EventGroups 77 // def x = 1 78 // 5.times { 79 // def currentSubject = new Subject( 80 // name: "TestA" + x++, 81 // species: mouseTerm, 82 // template: mouseTemplate, 83 // ).setFieldValue("Gender", "Male") 84 // 85 // // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set 86 // // (this is possibly a Grails or Hibernate bug) 87 // testStudy.addToSubjects(currentSubject) 88 // currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 89 // 90 // // Add subject to appropriate EventGroup 91 // LFBV1.addToSubjects(currentSubject).with { if (!validate()) { errors.each { println it} } else save()} 92 // 93 // // Create sample 94 // def currentSample = new Sample( 95 // name: currentSubject.name + '_B', 96 // material: mouseTerm, 97 // template: humanTissueSampleTemplate, 98 // parentSubject: currentSubject, 99 // parentEvent: evS 100 // ); 101 // testStudy.addToSamples(currentSample) 102 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 103 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 104 // } 105 // 106 // // Add EventGroups to study 107 // testStudy.addToEventGroups(LFBV1) 108 // LFBV1.with { if (!validate()) { errors.each { println it} } else save()} 109 // testStudy.with { if (!validate()) { errors.each { println it} } else save(flush:true)} 110 // 111 // testStudy.save(flush:true) 112 // 113 // //assert Sample.list()*.name.contains( "TestA2_B" ); 114 // 115 // // Make sure session is kept open 116 // Session session = SessionFactoryUtils.getSession(sessionFactory, true) 117 // session.flush(); 118 // session.clear(); 119 120 BootStrapTemplates.initTemplateOntologies(); 121 BootStrapTemplates.initTemplates() 122 BootStrapStudies.addExampleStudies(SecUser.findByUsername('user'), SecUser.findByUsername('admin')) 25 26 ExampleStudies.addExampleStudies(SecUser.findByUsername('user'), SecUser.findByUsername('admin')) 123 27 } 124 28 … … 134 38 new Criterion( entity: "Study", field: "code", operator: Operator.equals, value: "PPSH" ) 135 39 ] 136 40 137 41 def search = new SampleSearch(); 138 42 139 43 // Make sure the 'user' is logged in 140 44 search.user = SecUser.findByUsername('user'); 141 45 142 46 search.setCriteria( [ criteria[0] ] ); 47 48 def a = Sample.findAll() 49 143 50 search.execute(); 144 51 assert search.getResults().size() >= 2 145 52 146 53 assert search.getResults()[0] instanceof Sample 147 54 assert search.getResults()*.name.contains( "A2_B" ); 148 55 assert search.getResults()*.name.contains( "A4_B" ); 149 56 150 57 search.setCriteria( [ criteria[0], criteria[1] ] ); 151 58 search.execute(); 152 59 assert search.getResults().size() >= 1 153 60 assert search.getResults()*.name.contains( "A2_B" ); 154 61 155 62 search.setCriteria( [ criteria[0], criteria[2] ] ); 156 63 search.execute(); 157 64 assert search.getResults().size() >= 1 158 65 159 66 // Conflicting criteria shouldn't return any samples 160 67 search.setCriteria( [ criteria[2], criteria[1] ] ); … … 162 69 assert search.getResults().size() == 0 163 70 } 164 71 165 72 void testExecuteDifferentCriteria() { 166 73 List criteria = [ … … 172 79 //new Criterion( entity: "SamplingEvent", field: "startTime", operator: Operator.equals, value: 3600 + 7 * 24 * 3600 ), 173 80 ] 174 81 175 82 def search = new SampleSearch(); 176 83 … … 183 90 search.setCriteria( [ it ] ); 184 91 search.execute(); 185 92 186 93 def results = search.getResults(); 187 94 assert results; … … 201 108 new Criterion( entity: "SamplingEvent", field: "startTime", operator: Operator.equals, value: "0192039" ), 202 109 ] 203 110 204 111 def search = new SampleSearch(); 205 112 206 113 // Make sure the 'user' is logged in 207 114 search.user = SecUser.findByUsername('user'); 208 115 209 116 // All criteria should result in 1 study with code 'abc' 210 117 criteria.each { -
trunk/test/integration/gscf/EventGroupTests.groovy
r1430 r1588 117 117 assert EventGroup.count() == 0 118 118 assert study.eventGroups.size() == 0 119 119 120 120 } 121 121 -
trunk/test/integration/gscf/ImporterTests.groovy
r1525 r1588 1 1 package gscf 2 2 3 import grails.test.*4 3 import org.springframework.core.io.* 5 4 import grails.converters.* 6 5 import dbnp.authentication.* 7 import org.dbnp.gdt. *6 import org.dbnp.gdt.Template 8 7 9 8 /** … … 22 21 */ 23 22 class ImporterTests extends GroovyTestCase { 24 def ImporterService23 def importerService 25 24 26 25 static final String testStudyExcelFile = "testfiles/NTC_Experiment_test4.xls" -
trunk/test/integration/gscf/SampleTests.groovy
r1504 r1588 31 31 final String testEventGroupName = "Test Group" 32 32 33 34 33 protected void setUp() { 35 34 super.setUp() … … 61 60 } 62 61 assert sample.validate() 63 64 // Make sure the sample is saved to the database65 assert sample.save(flush: true)66 67 62 } 68 63 … … 125 120 } 126 121 127 /** 128 * Test whether a study which has orphan (without parent subject/event) samples cannot be published 129 */ 130 void testStudyPublish() { 131 def sampleDB = Sample.findByName(testSampleName) 132 assert sampleDB 133 134 // Retrieve the parent study 135 def study = Study.findByTitle(testStudyName) 136 assert study 137 138 // Make sure the study validates at this point 139 assert study.validate() 140 141 // Try to publish the study, should fail as it has a sample without a parent sampling event 142 study.published = true 143 assert !study.validate() 144 145 // Add parent sampling event 146 addParentSamplingEvent() 147 148 // Add parent subject 149 addParentSubject() 150 151 // Now the study should validate 152 assert study.validate() 153 } 122 // Commented out by Siemen: functionality to be tested not implemented yet. See 123 // comment in Study's contraints section 124 // /** 125 // * Test whether a study which has orphan (without parent subject/event) samples cannot be published 126 // */ 127 // void testStudyPublish() { 128 // def sampleDB = Sample.findByName(testSampleName) 129 // assert sampleDB 130 // 131 // // Retrieve the parent study 132 // def study = Study.findByTitle(testStudyName) 133 // assert study 134 // 135 // // Make sure the study validates at this point 136 // assert study.validate() 137 // 138 // // Try to publish the study, should fail as it has a sample without a parent sampling event 139 // study.published = true 140 // assert !study.validate() 141 // 142 // // Add parent sampling event 143 // addParentSamplingEvent() 144 // 145 // // Add parent subject 146 // addParentSubject() 147 // 148 // // Now the study should validate 149 // assert study.validate() 150 // } 154 151 155 152 void testSave() { … … 169 166 170 167 void testDelete() { 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 168 def sampleDB = Sample.findByName(testSampleName) 169 assert sampleDB 170 sampleDB.delete() 171 try { 172 sampleDB.save() 173 assert false // The save should not succeed since the sample is referenced by a study 174 } 175 catch(org.springframework.dao.InvalidDataAccessApiUsageException e) { 176 sampleDB.discard() 177 assert true // OK, correct exception (at least for the in-mem db, for PostgreSQL it's probably a different one...) 178 } 179 180 // Now, delete the sample from the study samples collection, and then the delete action should be cascaded to the sample itself 181 def study = Study.findByTitle(testStudyName) 182 assert study 183 study.removeFromSamples sampleDB 184 185 // Make sure the sample doesn't exist anymore at this point 186 assert !Sample.findByName(testSampleName) 187 assert Sample.count() == 0 188 assert study.samples.size() == 0 192 189 } 193 190 … … 388 385 // Add parent sampling event 389 386 addParentSamplingEvent() 390 387 391 388 // Try to retrieve the sampling event by using the time... 392 389 // (should be also the parent study but that's not yet implemented) -
trunk/test/integration/gscf/StudyTests.groovy
r1504 r1588 37 37 assert studyTemplate 38 38 39 def study = new Study( 40 title: testStudyName, 41 template: studyTemplate, 42 startDate: testStudyStartDate, 43 code: testStudyCode, 44 description: testStudyDescription 45 ) 46 47 if (!study.validate()) { 48 study.errors.each { println it} 49 } 50 assert study.validate() 51 52 53 assert study.save(flush: true) 39 dbnp.configuration.ExampleStudies.addTestStudies() 54 40 55 41 } … … 83 69 assert study.isDomainField('startDate') 84 70 assert study.isDomainField('code') 85 71 86 72 } 87 73 … … 94 80 assert study.validate() 95 81 assert study.save(flush:true) 96 assert study.getFieldValue("startDate").equals(testStudyStartDate2) 82 assert study.getFieldValue("startDate").equals(testStudyStartDate2) 97 83 98 84 } … … 100 86 protected void tearDown() { 101 87 102 // Delete the created study103 /*def study = Study.findByCode(testStudyCode)104 assert study105 106 study.delete()107 assert Study.findByCode(testStudyCode) == null108 */109 88 super.tearDown() 110 89 } -
trunk/test/unit/RestControllerTests.groovy
r1430 r1588 3 3 4 4 class RestControllerTests extends ControllerUnitTestCase { 5 def AuthenticationService5 def authenticationService 6 6 7 7 protected void setUp() { 8 8 super.setUp() 9 9 10 controller. AuthenticationService = AuthenticationService10 controller.authenticationService = authenticationService 11 11 } 12 12 -
trunk/test/unit/dbnp/studycapturing/AssayServiceTests.groovy
r1559 r1588 202 202 203 203 def fieldMap = [ 204 'Subject Data':[ 'tf1','tf2','tf3','species','name'],205 'Sampling Event Data':[ 'startTime','duration'],206 'Sample Data':[ 'name'],207 'Event Group':[ 'name']204 'Subject Data':[[name:'tf1'],[name:'tf2'],[name:'tf3'],[name:'species'],[name:'name']], 205 'Sampling Event Data':[[name:'startTime'],[name:'duration']], 206 'Sample Data':[[name:'name']], 207 'Event Group':[[name:'name']] 208 208 ] 209 209 -
trunk/test/unit/dbnp/studycapturing/StudyTests.groovy
r1430 r1588 2 2 3 3 import grails.test.* 4 import groovy.util.GroovyTestCase 4 5 5 class StudyTests extends GrailsUnitTestCase { 6 6 7 protected void setUp() { 7 8 super.setUp()
Note: See TracChangeset
for help on using the changeset viewer.