1 | package dbnp.rest |
---|
2 | |
---|
3 | import java.util.Map; |
---|
4 | import java.util.HashMap; |
---|
5 | import grails.converters.JSON |
---|
6 | import org.codehaus.groovy.grails.web.json.* |
---|
7 | import dbnp.studycapturing.TemplateFieldListItem |
---|
8 | import dbnp.studycapturing.Template |
---|
9 | import dbnp.data.CleanDataLayer |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | class CCMCommunicationManager implements CleanDataLayer { |
---|
14 | |
---|
15 | //def static ServerURL = "http://localhost:8080/gscf/rest"; |
---|
16 | def static ServerURL = "http://nbx5.nugo.org:8182/ClinicalChemistry/rest"; |
---|
17 | |
---|
18 | |
---|
19 | /* Methods implemented for CleanDataLayer */ |
---|
20 | |
---|
21 | |
---|
22 | /** |
---|
23 | * Get the names of all quantitative features that are available for a certain assay |
---|
24 | * @param assayID the module internal ID for the assay |
---|
25 | * @return |
---|
26 | */ |
---|
27 | public String[] getFeaturesQuantitative(long assayID) { |
---|
28 | return new String [20]; |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | /** |
---|
34 | * Get the data for a quantitative feature for a certain assay for a certain set of samples |
---|
35 | * @param feature |
---|
36 | * @param assayID |
---|
37 | * @param sampleIDs |
---|
38 | * @return Map |
---|
39 | */ |
---|
40 | public Map getDataQuantitative(String feature, long assayID, String[] sampleIDs) { |
---|
41 | return new HashMap(); |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | /** |
---|
49 | * Testing REST. Remove when connection to nbx5 is established. |
---|
50 | * |
---|
51 | * @return list of ClinicalFloatData |
---|
52 | */ |
---|
53 | public Object getFeatures() { |
---|
54 | def url = new URL( ServerURL + "/features" ) |
---|
55 | return JSON.parse(url.newReader()) |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * Testing REST. Remove when connection to nbx5 is established. |
---|
61 | * |
---|
62 | * @return list of ClinicalFloatData |
---|
63 | */ |
---|
64 | private String getSearchable( keyword ) { |
---|
65 | return "submit=Query&q=" + keyword |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | /** |
---|
70 | * Testing REST. Remove when connection to nbx5 is established. |
---|
71 | * |
---|
72 | * @return list of ClinicalFloatData |
---|
73 | */ |
---|
74 | public String getStudiesForKeyword( String keyword ) { |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | public Object getMeasurementsResource( String keyword ) { |
---|
79 | def url = new URL( ServerURL + "/" + getSearchable(keyword) ) |
---|
80 | return JSON.parse( url.newReader() ) |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | public void getMeasurementsForValueResource() { |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | public void getMeasurementsForRangeResource() { |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | public void getDataSimple() { |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | /** Send a request for the REST resource to the server and deliver the |
---|
97 | * resulting JSON object. |
---|
98 | * |
---|
99 | * @param resource: the name of the resource including parameters |
---|
100 | * @return JSON object |
---|
101 | */ |
---|
102 | private Object requesService( String resource ) { |
---|
103 | def url = new URL( ServerURL + "/" + resource ); |
---|
104 | return JSON.parse( url.newReader() ); |
---|
105 | } |
---|
106 | |
---|
107 | } |
---|