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

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