root/trunk/grails-app/controllers/SandboxController.groovy @ 253

Revision 253, 1.7 KB (checked in by keesvb, 4 years ago)

Cleaned up BootStrap? (removed accidental multiple addition of eventGroup in PPSH study), cleaned up scaffolded classes in root package, removed obsolete BaseController?, added some code to Sandbox

  • Property svn:keywords set to Author Rev Date
RevLine 
[146]1import dbnp.studycapturing.*
[187]2import dbnp.clinicaldata.ClinicalFloatData
3import dbnp.clinicaldata.ClinicalMeasurement
[144]4
5// The sandbox is meant for internal communication over code examples etc.
6
7class SandboxController {
8
[187]9        def clinicalDataLayerService
10
[146]11        def index = {
[144]12
[146]13                // Get the example study in a lazy way
14                def st = Study.get(1)
[253]15                def fieldsAll = st.giveSubjectTemplates().fields
16        def f = fieldsAll[0]
17        println fieldsAll.class
18            println f.class
19      f.each {
20        println "" + it + "-" + it.class
21      }
22      //println st.giveAllFields()
[144]23
[146]24                // This is a way to iterate over the fields in your controller
25                // And print them to the console
26                // Most of the time, you would just iterate over them in the view using <g:each>
27                // See also views/sandbox/index.gsp
[253]28                f.each { field ->
[146]29                        println field.name + "(" + field.type + ")"
30                }
[144]31
[146]32                //Let's get a certain field for a certain subject
[187]33                /*def subject = st.subjects.get(1)
34
35                if (subject) {
[146]36                println st.template.getSubjectFieldType('Age')
[176]37                println subject.getFieldValue('Genotype')
38                subject.setFieldValue('Genotype','wildtype')
39                println subject.getFieldValue('Genotype')
40                subject.setFieldValue('name','hallo')
[187]41                println subject.name }*/
[186]42
43
[187]44                // Demonstration of querying mechanism
[188]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[])
[187]47
[146]48                // Specify which variables we want to be available in the controller (implicit return statement)
[253]49                [fields: f, subjects: st.subjects, studyInstance: st]
[187]50        }
[144]51}
Note: See TracBrowser for help on using the browser.