+ started work

Signed-off-by: Johannes Theiner <j.theiner@live.de>
#SPM-18: add work 20m development
This commit is contained in:
Johannes Theiner 2019-05-08 21:15:52 +02:00
parent cdb743ca0a
commit ee14f2b295
2 changed files with 53 additions and 2 deletions

View File

@ -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<String, List<Integer>> 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()));
}
}

View File

@ -1,7 +1,8 @@
<%@ page import="weka.core.Version" %> <%@ page import="weka.core.Version" %>
<%@ page import="java.io.File" %>
Server info: <%= application.getServerInfo() %><br> Server info: <%= application.getServerInfo() %><br>
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %><br> Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %><br>
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br> JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
Java version: <%= System.getProperty("java.version") %><br> Java version: <%= System.getProperty("java.version") %><br>
Weka version: <%= Version.VERSION %><br>
Weka version: <%= Version.VERSION %> File root: <%= new File("").getAbsolutePath() %>