Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/QueryService.java @ 268:58e1ed2ddbbd
Restructured the Dummy Query configuration to make it more feel like the EXT
configuration.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 24 Jul 2013 13:09:43 +0200 |
parents | df168246a4d2 |
children | 5143a9604fb9 |
comparison
equal
deleted
inserted
replaced
267:df168246a4d2 | 268:58e1ed2ddbbd |
---|---|
16 import de.intevation.lada.auth.Authentication; | 16 import de.intevation.lada.auth.Authentication; |
17 import de.intevation.lada.auth.AuthenticationException; | 17 import de.intevation.lada.auth.AuthenticationException; |
18 import de.intevation.lada.model.LOrt; | 18 import de.intevation.lada.model.LOrt; |
19 | 19 |
20 class ResultConfig { | 20 class ResultConfig { |
21 String field; | 21 String dataIndex; |
22 String label; | 22 String header; |
23 String type; | 23 Integer flex; |
24 | 24 Integer width; |
25 public ResultConfig(String field, String label, String type) { | 25 |
26 this.field = field; | 26 public ResultConfig(String dataIndex, String header, Integer flex, Integer width) { |
27 this.label = label; | 27 this.dataIndex= dataIndex; |
28 this.type = type; | 28 this.header= header; |
29 } | 29 this.flex = flex; |
30 | 30 this.width = width; |
31 /** | 31 } |
32 * @return the field | 32 |
33 */ | 33 public ResultConfig(String dataIndex, String header, Integer flex) { |
34 public String getField() { | 34 this.dataIndex= dataIndex; |
35 return field; | 35 this.header= header; |
36 } | 36 this.flex = flex; |
37 | 37 this.width = null; |
38 /** | 38 } |
39 * @param field the field to set | 39 |
40 */ | 40 public ResultConfig(String dataIndex, String header) { |
41 public void setField(String field) { | 41 this.dataIndex= dataIndex; |
42 this.field = field; | 42 this.header= header; |
43 } | 43 this.flex = 0; |
44 | 44 this.width = null; |
45 /** | 45 } |
46 * @return the label | 46 |
47 */ | 47 /** |
48 public String getLabel() { | 48 * @return the dataIndex |
49 return label; | 49 */ |
50 } | 50 public String getDataIndex() { |
51 | 51 return dataIndex; |
52 /** | 52 } |
53 * @param label the label to set | 53 |
54 */ | 54 /** |
55 public void setLabel(String label) { | 55 * @param dataIndex the dataIndex to set |
56 this.label = label; | 56 */ |
57 } | 57 public void setDataIndex(String dataIndex) { |
58 | 58 this.dataIndex = dataIndex; |
59 /** | 59 } |
60 * @return the type | 60 |
61 */ | 61 /** |
62 public String getType() { | 62 * @return the header |
63 return type; | 63 */ |
64 } | 64 public String getHeader() { |
65 | 65 return header; |
66 /** | 66 } |
67 * @param type the type to set | 67 |
68 */ | 68 /** |
69 public void setType(String type) { | 69 * @param header the header to set |
70 this.type = type; | 70 */ |
71 public void setHeader(String header) { | |
72 this.header = header; | |
73 } | |
74 | |
75 /** | |
76 * @return the width | |
77 */ | |
78 public Integer getWidth() { | |
79 return width; | |
80 } | |
81 | |
82 /** | |
83 * @param width the width to set | |
84 */ | |
85 public void setWidth(Integer width) { | |
86 this.width = width; | |
87 } | |
88 | |
89 /** | |
90 * @return the flex | |
91 */ | |
92 public Integer getFlex() { | |
93 return flex; | |
94 } | |
95 | |
96 /** | |
97 * @param flex the flex to set | |
98 */ | |
99 public void setFlex(Integer flex) { | |
100 this.flex = flex; | |
71 } | 101 } |
72 } | 102 } |
73 | 103 |
74 class QueryConfig { | 104 class QueryConfig { |
75 int id; | 105 int id; |
202 ) { | 232 ) { |
203 try { | 233 try { |
204 if (!authentication.isAuthorizedUser(headers)) { | 234 if (!authentication.isAuthorizedUser(headers)) { |
205 return new Response(false, 699, new ArrayList<LOrt>()); | 235 return new Response(false, 699, new ArrayList<LOrt>()); |
206 } | 236 } |
207 QueryConfig queries = this.loadQueryConfig(); | 237 List<QueryConfig> queries = this.loadQueryConfig(); |
208 Response response = new Response(true, 200, queries); | 238 Response response = new Response(true, 200, queries); |
209 return response; | 239 return response; |
210 } | 240 } |
211 catch(AuthenticationException ae) { | 241 catch(AuthenticationException ae) { |
212 return new Response(false, 699, new ArrayList<LOrt>()); | 242 return new Response(false, 699, new ArrayList<LOrt>()); |
213 } | 243 } |
214 } | 244 } |
215 | 245 |
216 private QueryConfig loadQueryConfig() { | 246 private List<QueryConfig> loadQueryConfig() { |
217 QueryConfig queryConfig = new QueryConfig(); | 247 List<QueryConfig> configs = new ArrayList<QueryConfig>(); |
248 | |
249 /* Typicall available fields | |
250 {header: 'Datenbasis', dataIndex: 'datenbasisId', width: 70}, | |
251 {header: 'MPL', dataIndex: 'mplId', width: 50}, | |
252 {header: 'UWB', dataIndex: 'umwId', width: 50}, | |
253 {header: 'MMT', dataIndex: 'messmethode'}, | |
254 {header: 'HPNR', dataIndex: 'hauptprobenNr'}, | |
255 {header: 'NPNR', dataIndex: 'nebenprobenNr'}, | |
256 {header: 'E.Gemeinde', dataIndex: 'bezeichnung', flex: 1}, | |
257 {header: 'Ursprungsgemeinde', dataIndex: 'kreis', flex: 1}, | |
258 {header: 'ProbeID', dataIndex: 'probeId'}, | |
259 {header: 'MST', dataIndex: 'mstId', width: 50} | |
260 */ | |
261 | |
218 /* Query 1 */ | 262 /* Query 1 */ |
219 queryConfig.setId(1); | 263 QueryConfig qc1 = new QueryConfig(); |
220 queryConfig.setName("MST, UWB"); | 264 qc1.setId(1); |
221 queryConfig.setDescription("Das ist die Beschreibung von Abfrage 1"); | 265 qc1.setName("MST, UWB"); |
222 queryConfig.setSql("Select * from l_probe"); | 266 qc1.setDescription("Das ist die Beschreibung von Abfrage 1"); |
267 qc1.setSql("Select * from l_probe"); | |
223 List<String> filters = new ArrayList<String>(); | 268 List<String> filters = new ArrayList<String>(); |
224 filters.add("mst"); | 269 filters.add("mst"); |
225 queryConfig.setFilter(filters); | 270 qc1.setFilter(filters); |
226 List<ResultConfig> results = new ArrayList<ResultConfig>(); | 271 List<ResultConfig> results = new ArrayList<ResultConfig>(); |
227 results.add(new ResultConfig("mst","Messstelle","string")); | 272 results.add(new ResultConfig("datenbasisId","Datenbases")); |
228 queryConfig.setResults(results); | 273 results.add(new ResultConfig("mplId","MPL")); |
229 return queryConfig; | 274 results.add(new ResultConfig("umwId","UWB")); |
275 results.add(new ResultConfig("messmethode","MMT")); | |
276 results.add(new ResultConfig("hauptprobenNr","HPNR")); | |
277 results.add(new ResultConfig("nebenprobenNr","NPNR")); | |
278 results.add(new ResultConfig("bezeichnung","E.Gemeinde")); | |
279 results.add(new ResultConfig("kreis","Ursprungsgemeinde")); | |
280 results.add(new ResultConfig("probeId","ProbeID")); | |
281 results.add(new ResultConfig("mstId","MS")); | |
282 qc1.setResults(results); | |
283 configs.add(qc1); | |
284 /* Query 2 */ | |
285 QueryConfig qc2 = new QueryConfig(); | |
286 qc2.setId(2); | |
287 qc2.setName("Test"); | |
288 qc2.setDescription("Das ist die Beschreibung von Abfrage 2"); | |
289 qc2.setSql("Select * from l_probe"); | |
290 List<String> qcf2= new ArrayList<String>(); | |
291 qcf2.add("mst"); | |
292 qc2.setFilter(qcf2); | |
293 List<ResultConfig> qcr2= new ArrayList<ResultConfig>(); | |
294 qcr2.add(new ResultConfig("mst","Messstelle")); | |
295 qc2.setResults(qcr2); | |
296 configs.add(qc2); | |
297 return configs; | |
230 } | 298 } |
231 } | 299 } |