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

Last change on this file since 1681 was 1621, checked in by robert@…, 10 years ago

Fixed some bugs in simple wizard and study view page

  • Property svn:keywords set to Rev Author Date
File size: 2.2 KB
Line 
1import dbnp.studycapturing.*
2
3// The sandbox is meant for internal communication over code examples etc.
4class SandboxController {
5
6        def clinicalDataLayerService
7        def oauthService
8
9        def index = {
10                println Study.list();
11               
12                // Get the example study in a lazy way
13                def st = Study.get(1)
14                println st.title
15                println st.subjects
16                def fieldsAll = st.giveSubjectTemplates().asList().first().fields
17        def f = fieldsAll[0]
18        println fieldsAll.class
19            println f.class
20      f.each {
21        println "" + it + "-" + it.class
22      }
23      //println st.giveAllFields()
24
25                // This is a way to iterate over the fields in your controller
26                // And print them to the console
27                // Most of the time, you would just iterate over them in the view using <g:each>
28                // See also views/sandbox/index.gsp
29                f.each { field ->
30                        println field.name + "(" + field.type + ")"
31                }
32
33                //Let's get a certain field for a certain subject
34                /*def subject = st.subjects.get(1)
35
36                if (subject) {
37                println st.template.getSubjectFieldType('Age')
38                println subject.getFieldValue('Genotype')
39                subject.setFieldValue('Genotype','wildtype')
40                println subject.getFieldValue('Genotype')
41                subject.setFieldValue('name','hallo')
42                println subject.name }*/
43
44
45                // Demonstration of querying mechanism
46                //println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0])
47                //println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])
48
49                // Specify which variables we want to be available in the controller (implicit return statement)
50                [fields: f, subjects: st.subjects, studyInstance: st, subject: Subject.findByName('A1')]
51        }
52
53        def oauth = {           
54            def secret = session.oauthToken.secret
55            def response = oauthService.accessResource('http://www.myexperiment.org/whoami.xml', 'myExperiment',
56                           [key: session.oauthToken.key, secret: session.oauthToken.secret], 'GET')
57           
58            render ("Calling whoami from myExperiment [key:" +  session.oauthToken.key + ", secret:"+ session.oauthToken.secret+"]")
59
60            render ("Response: " + response)
61
62        }
63
64
65}
Note: See TracBrowser for help on using the repository browser.