source: trunk/grails-app/controllers/SandboxController.groovy @ 186

Last change on this file since 186 was 186, checked in by keesvb, 10 years ago

added samples, assays and clinical data to bootstrap, modified clean data module linkage

  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 1.1 KB
Line 
1import dbnp.studycapturing.*
2
3// The sandbox is meant for internal communication over code examples etc.
4
5class SandboxController {
6
7        def index = {
8
9                // Get the example study in a lazy way
10                def st = Study.get(1)
11                def f = st.template.subjectFields
12
13                //println st.giveAllFields()
14
15                // This is a way to iterate over the fields in your controller
16                // And print them to the console
17                // Most of the time, you would just iterate over them in the view using <g:each>
18                // See also views/sandbox/index.gsp
19                f.each {field ->
20                        println field.name + "(" + field.type + ")"
21                }
22
23                //Let's get a certain field for a certain subject
24                def subject = Subject.findByName('A1')
25                println st.template.getSubjectFieldType('Age')
26                println subject.getFieldValue('Genotype')
27                subject.setFieldValue('Genotype','wildtype')
28                println subject.getFieldValue('Genotype')
29                subject.setFieldValue('name','hallo')
30                println subject.name
31
32                println Study.get(2).giveSamples()*.name
33       
34
35                // Specify which variables we want to be available in the controller (implicit return statement)
36                [fields: f, subjects: st.subjects]
37}
38}
Note: See TracBrowser for help on using the repository browser.