Changeset 375


Ignore:
Timestamp:
Apr 23, 2010, 11:26:57 AM (9 years ago)
Author:
keesvb
Message:

added giveDomainFields to TemplateEntity? entities, fixed some problems in BootStrap?

Location:
trunk/grails-app
Files:
9 edited

Legend:

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

    r370 r375  
    248248                        def genotypeTypeField = new TemplateField(
    249249                                name: 'Genotype type',type: TemplateFieldType.STRINGLIST,
    250                                 listEntries: [new TemplateFieldListItem(name:'transgenic'),
     250                                listEntries: [new TemplateFieldListItem(name:'wildtype'),
     251                                        new TemplateFieldListItem(name:'transgenic'),
    251252                                        new TemplateFieldListItem(name:'knock-out'),
    252253                                        new TemplateFieldListItem(name:'knock-in')])
     
    259260                        def studyTemplate = new Template(
    260261                                name: 'Academic study', entity: dbnp.studycapturing.Study)
    261                                 //.addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT))
     262                                .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT))
    262263                                .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING))
    263264                                .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT))
     
    339340
    340341                        // Human sample template
     342                        println ".adding human sample template..."
    341343                        def humanSampleTemplate = new Template(
    342344                                name: 'Human tissue sample', entity: dbnp.studycapturing.Sample)
     
    348350
    349351                        //Plant template
     352                        println ".adding plant template..."
    350353                        def plantTemplate = new Template(
    351354                                name: 'Plant template', entity: dbnp.studycapturing.Subject)
     
    389392                        .with { if (!validate()) { errors.each { println it} } else save()}
    390393
     394                        println ".adding plant sample template..."
    391395                        def plantSampleTemplate = new Template(
    392396                                name: 'Plant sample', entity: dbnp.studycapturing.Sample)
     
    398402
    399403
    400                         // Event template
     404                        // Event templates
     405                        println ".adding event templates..."
    401406                        def dietTreatmentTemplate = new Template(
    402407                                name: 'Diet treatment ', entity: dbnp.studycapturing.Event)
    403408                        .addToFields(sampleDescriptionField)
    404409                        .addToFields(new TemplateField(
    405                                 name: 'Diet', type: TemplateFieldType.STRING))
     410                                name: 'Diet', type: TemplateFieldType.STRINGLIST,
     411                                listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')]))
    406412                        .with { if (!validate()) { errors.each { println it} } else save()}
    407413
     
    410416                        .addToFields(sampleDescriptionField)
    411417                        .addToFields(new TemplateField(
    412                                 name: 'Compound', type: TemplateFieldType.STRING))
     418                                name: 'Compound', type: TemplateFieldType.STRING,
     419                                listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')]))
    413420                        .with { if (!validate()) { errors.each { println it} } else save()}
    414421
     
    456463                        */
    457464                        // studies
     465                        println ".adding NuGO PPS3 leptin example study..."
    458466                        def exampleStudy = new Study(
    459467                                template: studyTemplate,
     
    464472                                startDate: Date.parse('yyyy-MM-dd','2007-12-11')
    465473                        )
    466                         //.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )
    467474                        .with { if (!validate()) { errors.each { println it} } else save()}
    468475
     476                        exampleStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )
     477                        exampleStudy.save()
     478
     479                        println ".adding NuGO PPSH example study..."
    469480                        def exampleHumanStudy = new Study(
    470                                 template: humanTemplate,
     481                                template: studyTemplate,
    471482                                title:"Human example template",
    472483                                code:"Human example code",
     
    475486                                startDate: Date.parse('yyyy-MM-dd','2007-12-11')
    476487                        )
    477                         //.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )
    478488                        .with { if (!validate()) { errors.each { println it} } else save()}
     489
     490                        exampleHumanStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." )
     491                        exampleHumanStudy.save()
    479492
    480493                        def evLF = new Event(
     
    483496                                template: dietTreatmentTemplate
    484497                        )
    485                         .setFieldValue( 'Diet','10% fat (palm oil)' )
    486498                        .with { if (!validate()) { errors.each { println it} } else save()}
     499                        evLF.setFieldValue( 'Diet','10% fat (palm oil)' )
     500                        evLF.save(flush:true)
     501                        // TODO: find out why Diet is not set and Compound is
    487502
    488503                        def evHF = new Event(
     
    625640                                .setFieldValue("Age (weeks)", 17)
    626641                                .setFieldValue("Cage", "" + (int)(x/2))
    627                                 .with { if (!validate()) { errors.each { println it} } else save()}
     642                                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
    628643
    629644                                exampleStudy.addToSubjects(currentSubject)
  • trunk/grails-app/controllers/SandboxController.groovy

    r359 r375  
    1313                // Get the example study in a lazy way
    1414                def st = Study.get(1)
    15                 def fieldsAll = st.giveSubjectTemplates().fields
     15                println st.title
     16                println st.subjects
     17                def fieldsAll = st.giveSubjectTemplates().asList().first().fields
    1618        def f = fieldsAll[0]
    1719        println fieldsAll.class
     
    4345
    4446                // Demonstration of querying mechanism
    45                 println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0])
    46                 println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])
     47                //println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0])
     48                //println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])
    4749
    4850                // Specify which variables we want to be available in the controller (implicit return statement)
  • trunk/grails-app/domain/dbnp/studycapturing/Event.groovy

    r370 r375  
    2424           }
    2525        })
     26        }
     27
     28        Map giveDomainFields() {
     29                return ['startTime':TemplateFieldType.DATE,'endTime':TemplateFieldType.DATE]
    2630        }
    2731
  • trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy

    r359 r375  
    1616        // a member that describes the quantity of the sample? --> should be in the templates
    1717
     18        Map giveDomainFields() {
     19                return ['name':TemplateFieldType.STRING,'material':TemplateFieldType.ONTOLOGYTERM]
     20        }
     21
    1822        static constraints = {
    1923                parentSubject(nullable:true)
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r370 r375  
    2323        //String ecCode
    2424
     25        Map giveDomainFields() {
     26                return ['title':TemplateFieldType.STRING,'startDate':TemplateFieldType.DATE]
     27        }
    2528
    2629        static hasMany = [
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r359 r375  
    1515        String name
    1616        Term species
     17
     18        Map giveDomainFields() {
     19                return ['name':TemplateFieldType.STRING,'species':TemplateFieldType.ONTOLOGYTERM]
     20        }
    1721}
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy

    r370 r375  
    357357         * @return key-value pairs describing the built-in fields, with the names as keys and type (as TemplateFieldType) as values
    358358         */
    359         def giveDomainFields() {
     359        abstract Map giveDomainFields()
     360        /*def giveDomainFields() {
    360361                def fieldSet = [:];
    361362                if (super.hasProperty('name')) {
     
    363364                }
    364365                return fieldSet;
    365         }
     366        }*/
    366367
    367368        // See revision 237 for ideas about initializing the different templateField Maps
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy

    r359 r375  
    1818        List listEntries
    1919
    20     static hasMany = [listEntries : TemplateFieldListItem,
    21                 // to store the entries to choose from when the type is 'item from predefined list'
     20    static hasMany = [listEntries :
     21                TemplateFieldListItem, // to store the entries to choose from when the type is 'item from predefined list'
    2222                ontologies : Ontology // to store the ontologies to choose from when the type is 'ontology term'
    2323        ]
    2424       
    2525        static constraints = {
    26                 name(unique: true)
     26                // TODO: verify that TemplateField names are unique within templates of each super entity
    2727                unit(nullable: true, blank: true)
    2828                comment(nullable:true, blank: true)
  • trunk/grails-app/views/sandbox/index.gsp

    r359 r375  
    3030</tr>
    3131</table>
    32 <h2>Events</h2>
    33 <% println studyInstance.events.eventDescription.protocol.name %>
    3432<h2>Subject Fields</h2>
    3533<table>
Note: See TracChangeset for help on using the changeset viewer.