source: trunk/grails-app/controllers/RestController.groovy @ 480

Last change on this file since 480 was 480, checked in by jahn, 8 years ago

Providing some methods for showing that REST/JSON actually works for the gscf.

File size: 1.2 KB
Line 
1/**
2 * RestController Controler
3 *
4 * Description this is for testing the dbNP.rest.CCMCommunicationManager only and should be removed,
5 * once the CCMCommunicationManager works with an exteneral server (nbx5)!!!!
6 *
7 * This class renders two REST related requests (features and get_json).
8 *
9 * @author  Jahn
10 * @since   20100526
11 *
12 */
13
14import grails.converters.JSON
15import org.codehaus.groovy.grails.web.json.*
16import dbnp.studycapturing.TemplateFieldListItem
17import dbnp.studycapturing.Template
18import dbnp.rest.CCMCommunicationManager
19
20
21class RestController {
22
23
24    /**
25     * result of querying the Clinical Chemistry Module
26     * if assay in the database : return the Clinical Assay
27     * else : return the list of all Assays in the database
28     * @return Clinical Assay
29     */
30    def features = {
31            //def items = TemplateFieldListItem.list()
32            def items = Template.list()
33            items.each{ render (it as JSON) } 
34            render params
35    }
36
37
38    /* Use a REST resource to get data using the CCMCommunicationManager */
39    def get_json = {
40        def json_result = new CCMCommunicationManager().getFeatures()
41        json_result.each { render "Value : ${it}\n"}
42    }
43
44}
Note: See TracBrowser for help on using the repository browser.