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

Last change on this file since 1635 was 1621, checked in by robert@…, 12 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
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 = {
[1621]10                println Study.list();
11               
[146]12                // Get the example study in a lazy way
13                def st = Study.get(1)
[375]14                println st.title
15                println st.subjects
16                def fieldsAll = st.giveSubjectTemplates().asList().first().fields
[253]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()
[144]24
[146]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
[253]29                f.each { field ->
[146]30                        println field.name + "(" + field.type + ")"
31                }
[144]32
[146]33                //Let's get a certain field for a certain subject
[187]34                /*def subject = st.subjects.get(1)
35
36                if (subject) {
[146]37                println st.template.getSubjectFieldType('Age')
[176]38                println subject.getFieldValue('Genotype')
39                subject.setFieldValue('Genotype','wildtype')
40                println subject.getFieldValue('Genotype')
41                subject.setFieldValue('name','hallo')
[187]42                println subject.name }*/
[186]43
44
[187]45                // Demonstration of querying mechanism
[375]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[])
[187]48
[146]49                // Specify which variables we want to be available in the controller (implicit return statement)
[338]50                [fields: f, subjects: st.subjects, studyInstance: st, subject: Subject.findByName('A1')]
[187]51        }
[338]52
[923]53        def oauth = {           
[926]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+"]")
[925]59
[918]60            render ("Response: " + response)
[338]61
[918]62        }
63
64
[144]65}
Note: See TracBrowser for help on using the repository browser.