diff --git a/server/CrowsSourcing/src/main/com/intergraph/cs/schema/CrowdSourcingSchema.java b/server/CrowsSourcing/src/main/com/intergraph/cs/schema/CrowdSourcingSchema.java index 1c7a66d..ff9f3a7 100644 --- a/server/CrowsSourcing/src/main/com/intergraph/cs/schema/CrowdSourcingSchema.java +++ b/server/CrowsSourcing/src/main/com/intergraph/cs/schema/CrowdSourcingSchema.java @@ -40,4 +40,5 @@ public interface CrowdSourcingSchema { String CONFIG_TAGS = "tags"; String CONFIG_MIME_TYPES = "mime_types"; String CONFIG_STATUSES = "statuses"; + String CONFIG_PRIORITIES = "priorities"; } diff --git a/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/ConfigServlet.java b/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/ConfigServlet.java index 6989518..230dad3 100644 --- a/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/ConfigServlet.java +++ b/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/ConfigServlet.java @@ -5,6 +5,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; +import java.util.Collection; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; @@ -30,8 +31,6 @@ public ConfigServlet() { super(); } - public static final String QUERY_GET_TAGS = "SELECT value FROM tag"; - /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ @@ -41,35 +40,16 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) Exception exception = null; Connection connection = null; Statement statement = null; - ResultSet result = null; try { - JSONObject config = new JSONObject(); - - JSONArray tags = new JSONArray(); - connection = openDatabaseConnection(); - statement = connection.createStatement(); - result = statement.executeQuery(QUERY_GET_TAGS); - while (result.next()) { - tags.add(result.getString(1)); - } - - if (tags.size() > 0) - config.put(CONFIG_TAGS, tags); - JSONArray mediaTypes = new JSONArray(); - mediaTypes.add("image/jpeg"); - mediaTypes.add("image/png"); - config.put(CONFIG_MIME_TYPES, mediaTypes); + JSONObject config = new JSONObject(); + addToConfig(config, CONFIG_TAGS, getAvailableTags(connection)); + addToConfig(config, CONFIG_MIME_TYPES, getSupportedMimeTypes(connection)); + addToConfig(config, CONFIG_STATUSES, getAvailableStatuses(connection)); + addToConfig(config, CONFIG_PRIORITIES, getAvailablePriorities(connection)); - JSONArray statuses = new JSONArray(); - statuses.add("new"); - statuses.add("assigned"); - statuses.add("approved"); - statuses.add("closed"); - config.put(CONFIG_STATUSES, statuses); - PrintWriter writer = response.getWriter(); config.writeJSONString(writer); } @@ -77,7 +57,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) exception = e; } finally { - closeQuietly(result); closeQuietly(statement); closeQuietly(connection); } @@ -88,6 +67,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) } } + private void addToConfig(JSONObject config, String key, Collection values) { + JSONArray array = new JSONArray(); + array.addAll(values); + config.put(key, array); + } + /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ diff --git a/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/EventCreateServlet.java b/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/EventCreateServlet.java index 3830d1e..b3d6e73 100644 --- a/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/EventCreateServlet.java +++ b/server/CrowsSourcing/src/main/com/intergraph/cs/servlet/EventCreateServlet.java @@ -99,17 +99,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) double latitude = getDoubleOrThrow(location, LOCATION_LATITUDE); int srid = getSRID(getString(location, LOCATION_CRS)); -// -// statement = connection.prepareStatement(INSERT_LOCATION); -// statement.setDouble(1, longitude); -// statement.setDouble(2, latitude); -// statement.setString(3, crs); -// result = statement.executeQuery(); -// result.next(); -// int locationId = result.getInt(1); -// result.close(); -// statement.close(); - statement = connection.prepareStatement(SELECT_USER); statement.setString(1, userId); result = statement.executeQuery();