# HG changeset patch # User Torsten Irländer # Date 1374660532 -7200 # Node ID df168246a4d20fd30f31ebc493cdde90f0653577 # Parent 2e86f535f290395e2aaa9d1d76b28fe69e70c2d1 Add Dummy Query Configuration. Needs to be replaced with w more simple configuration file later. diff -r 2e86f535f290 -r df168246a4d2 src/main/java/de/intevation/lada/rest/QueryService.java --- a/src/main/java/de/intevation/lada/rest/QueryService.java Wed Jul 24 10:57:18 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/QueryService.java Wed Jul 24 12:08:52 2013 +0200 @@ -1,6 +1,7 @@ package de.intevation.lada.rest; import java.util.ArrayList; +import java.util.List; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @@ -16,6 +17,157 @@ import de.intevation.lada.auth.AuthenticationException; import de.intevation.lada.model.LOrt; +class ResultConfig { + String field; + String label; + String type; + + public ResultConfig(String field, String label, String type) { + this.field = field; + this.label = label; + this.type = type; + } + + /** + * @return the field + */ + public String getField() { + return field; + } + + /** + * @param field the field to set + */ + public void setField(String field) { + this.field = field; + } + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * @param label the label to set + */ + public void setLabel(String label) { + this.label = label; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } +} + +class QueryConfig { + int id; + String name; + String description; + String sql; + List filter; + List results; + + public QueryConfig() + { + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the sql + */ + public String getSql() { + return sql; + } + + /** + * @param sql the sql to set + */ + public void setSql(String sql) { + this.sql = sql; + } + + /** + * @return the filter + */ + public List getFilter() { + return filter; + } + + /** + * @param filter the filter to set + */ + public void setFilter(List filter) { + this.filter = filter; + } + + /** + * @return the results + */ + public List getResults() { + return results; + } + + /** + * @param results the results to set + */ + public void setResults(List results) { + this.results = results; + } +} + /** * This class produces a RESTful service to read, write and update * LOrt objects. @@ -52,7 +204,7 @@ if (!authentication.isAuthorizedUser(headers)) { return new Response(false, 699, new ArrayList()); } - String queries = this.loadQueryConfig(); + QueryConfig queries = this.loadQueryConfig(); Response response = new Response(true, 200, queries); return response; } @@ -61,18 +213,19 @@ } } - private String loadQueryConfig() { - String query = "[" + - "{" + - "\"id\": \"1\"," + - "\"description\": \"Beschreibung für Query 1\"," + - "\"sql\": \"SELECT * FROM l_probe;\"," + - "\"filters\": [\"mst\"]," + - "\"results\": [" + - "{\"field\": \"\", \"label\": \"\", \"type\": \"\"}" + - "]" + - "}" + - "]"; - return query; + private QueryConfig loadQueryConfig() { + QueryConfig queryConfig = new QueryConfig(); + /* Query 1 */ + queryConfig.setId(1); + queryConfig.setName("MST, UWB"); + queryConfig.setDescription("Das ist die Beschreibung von Abfrage 1"); + queryConfig.setSql("Select * from l_probe"); + List filters = new ArrayList(); + filters.add("mst"); + queryConfig.setFilter(filters); + List results = new ArrayList(); + results.add(new ResultConfig("mst","Messstelle","string")); + queryConfig.setResults(results); + return queryConfig; } }