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

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

added first version of importer data model, added helper methods to domain class for getting all entity fields, added study template fields

  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 1.0 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                // Specify which variables we want to be available in the controller (implicit return statement)
33                [fields: f, subjects: st.subjects]
34}
35}
Note: See TracBrowser for help on using the repository browser.