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

Last change on this file since 1270 was 1208, checked in by work@…, 12 years ago
  • obsolete import in sanbox controller broke gscf
  • added ajax-flow plugin version 0.1.0
  • Property svn:keywords set to Author Date Rev
File size: 2.2 KB
RevLine 
[146]1import dbnp.studycapturing.*
[144]2
3// The sandbox is meant for internal communication over code examples etc.
4class SandboxController {
5
[187]6        def clinicalDataLayerService
[919]7        def oauthService
[187]8
[146]9        def index = {
[144]10
[146]11                // Get the example study in a lazy way
12                def st = Study.get(1)
[375]13                println st.title
14                println st.subjects
15                def fieldsAll = st.giveSubjectTemplates().asList().first().fields
[253]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()
[144]23
[146]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
[253]28                f.each { field ->
[146]29                        println field.name + "(" + field.type + ")"
30                }
[144]31
[146]32                //Let's get a certain field for a certain subject
[187]33                /*def subject = st.subjects.get(1)
34
35                if (subject) {
[146]36                println st.template.getSubjectFieldType('Age')
[176]37                println subject.getFieldValue('Genotype')
38                subject.setFieldValue('Genotype','wildtype')
39                println subject.getFieldValue('Genotype')
40                subject.setFieldValue('name','hallo')
[187]41                println subject.name }*/
[186]42
43
[187]44                // Demonstration of querying mechanism
[375]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[])
[187]47
[146]48                // Specify which variables we want to be available in the controller (implicit return statement)
[338]49                [fields: f, subjects: st.subjects, studyInstance: st, subject: Subject.findByName('A1')]
[187]50        }
[338]51
[923]52        def oauth = {           
[926]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+"]")
[925]58
[918]59            render ("Response: " + response)
[338]60
[918]61        }
62
63
[144]64}
Note: See TracBrowser for help on using the repository browser.