From ee14f2b295778cf3b8917708dce52f787a044b52 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Wed, 8 May 2019 21:15:52 +0200 Subject: [PATCH] + started work Signed-off-by: Johannes Theiner #SPM-18: add work 20m development --- .../spm/baudas/web/ShoppingTimesDiagram.java | 50 +++++++++++++++++++ src/main/webapp/version.jsp | 5 +- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java diff --git a/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java b/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java new file mode 100644 index 0000000..0042832 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java @@ -0,0 +1,50 @@ +package de.hsel.spm.baudas.web; + +import com.google.gson.Gson; +import de.hsel.spm.baudas.analysis.ShoppingTimes; +import org.jetbrains.annotations.NotNull; + +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Johannes Theiner + * @version 0.1 + * @since 0.1 + **/ + +@WebServlet("/shopping_times") +public class ShoppingTimesDiagram extends HttpServlet { + + @Override + protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { + req.setCharacterEncoding(StandardCharsets.UTF_8.name()); + resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); + resp.setContentType("application/json"); + PrintWriter out = resp.getWriter(); + + Map> result = new HashMap<>(); + + Gson gson = new Gson(); + + SavedFile file = Data.getFiles().peek(); + if (file == null) { + out.print(gson.toJson(result)); + return; + } + assert file.getUuid() != null; + ShoppingTimes shoppingTimes = new ShoppingTimes(Data.get(file.getUuid())); + + out.print(gson.toJson(shoppingTimes.getResult())); + + + } +} \ No newline at end of file diff --git a/src/main/webapp/version.jsp b/src/main/webapp/version.jsp index d47f7ea..64f838f 100644 --- a/src/main/webapp/version.jsp +++ b/src/main/webapp/version.jsp @@ -1,7 +1,8 @@ <%@ page import="weka.core.Version" %> +<%@ page import="java.io.File" %> Server info: <%= application.getServerInfo() %>
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>
Java version: <%= System.getProperty("java.version") %>
- -Weka version: <%= Version.VERSION %> \ No newline at end of file +Weka version: <%= Version.VERSION %>
+File root: <%= new File("").getAbsolutePath() %> \ No newline at end of file