changeset 267:df168246a4d2

Add Dummy Query Configuration. Needs to be replaced with w more simple configuration file later.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 24 Jul 2013 12:08:52 +0200
parents 2e86f535f290
children 58e1ed2ddbbd
files src/main/java/de/intevation/lada/rest/QueryService.java
diffstat 1 files changed, 167 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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<String> filter;
+    List<ResultConfig> 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<String> getFilter() {
+        return filter;
+    }
+
+    /**
+     * @param filter the filter to set
+     */
+    public void setFilter(List<String> filter) {
+        this.filter = filter;
+    }
+
+    /**
+     * @return the results
+     */
+    public List<ResultConfig> getResults() {
+        return results;
+    }
+
+    /**
+     * @param results the results to set
+     */
+    public void setResults(List<ResultConfig> 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<LOrt>());
             }
-            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<String> filters = new ArrayList<String>();
+        filters.add("mst");
+        queryConfig.setFilter(filters);
+        List<ResultConfig> results = new ArrayList<ResultConfig>();
+        results.add(new ResultConfig("mst","Messstelle","string"));
+        queryConfig.setResults(results);
+        return queryConfig;
     }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)