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

Last change on this file since 1430 was 1430, checked in by work@…, 10 years ago
  • set keyword expansion
  • 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
11                // Get the example study in a lazy way
12                def st = Study.get(1)
13                println st.title
14                println st.subjects
15                def fieldsAll = st.giveSubjectTemplates().asList().first().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()
23
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
28                f.each { field ->
29                        println field.name + "(" + field.type + ")"
30                }
31
32                //Let's get a certain field for a certain subject
33                /*def subject = st.subjects.get(1)
34
35                if (subject) {
36                println st.template.getSubjectFieldType('Age')
37                println subject.getFieldValue('Genotype')
38                subject.setFieldValue('Genotype','wildtype')
39                println subject.getFieldValue('Genotype')
40                subject.setFieldValue('name','hallo')
41                println subject.name }*/
42
43
44                // 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
48                // Specify which variables we want to be available in the controller (implicit return statement)
49                [fields: f, subjects: st.subjects, studyInstance: st, subject: Subject.findByName('A1')]
50        }
51
52        def oauth = {           
53            def secret = session.oauthToken.secret
54            def response = oauthService.accessResource('http://www.myexperiment.org/whoami.xml', 'myExperiment',
55                           [key: session.oauthToken.key, secret: session.oauthToken.secret], 'GET')
56           
57            render ("Calling whoami from myExperiment [key:" +  session.oauthToken.key + ", secret:"+ session.oauthToken.secret+"]")
58
59            render ("Response: " + response)
60
61        }
62
63
64}
Note: See TracBrowser for help on using the repository browser.