From e6d56675d32eea40c4a6e44fb3504b6ce6ae186a Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 16 May 2019 14:56:02 +0200 Subject: [PATCH 01/18] ~changed WeekOverview to use Costumer count instead of Artikel count --- .../java/de/hsel/spm/baudas/analysis/WeekOverview.java | 7 +------ .../java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java index 7c54043..58f1443 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java @@ -48,18 +48,13 @@ public class WeekOverview implements Analysis(0.0, 0)); } result.put(day, new AbstractMap.SimpleEntry<>( result.get(day).getKey() + amount, - result.get(day).getValue() + count + result.get(day).getValue() + 1 ) ); } diff --git a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java index 0f6f283..be3ea77 100644 --- a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java +++ b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java @@ -30,8 +30,7 @@ class WeekOverviewTest { AtomicReference>> result = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(1), () -> result.set(overview.getResult())); - + assertTimeout(Duration.ofMillis(2), () -> result.set(overview.getResult())); assertEquals(2477, result.get().get("Montag").getKey()); assertEquals(3359, result.get().get("Dienstag").getKey()); From ad0e2040ee41277f686a1197ea9e4d5b33089623 Mon Sep 17 00:00:00 2001 From: joethei Date: Thu, 16 May 2019 15:24:39 +0200 Subject: [PATCH 02/18] ~ testing correct stuff again #SPM-14: add work #20m testing --- .../spm/baudas/analysis/WeekOverviewTest.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java index be3ea77..71907eb 100644 --- a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java +++ b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java @@ -30,7 +30,7 @@ class WeekOverviewTest { AtomicReference>> result = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(2), () -> result.set(overview.getResult())); + assertTimeout(Duration.ofMillis(15), () -> result.set(overview.getResult())); assertEquals(2477, result.get().get("Montag").getKey()); assertEquals(3359, result.get().get("Dienstag").getKey()); @@ -39,12 +39,12 @@ class WeekOverviewTest { assertEquals(2399, result.get().get("Freitag").getKey()); assertEquals(18273, result.get().get("Samstag").getKey()); - assertEquals(3216, result.get().get("Montag").getValue()); - assertEquals(5503, result.get().get("Dienstag").getValue()); - assertEquals(1888, result.get().get("Mittwoch").getValue()); - assertEquals(3568, result.get().get("Donnerstag").getValue()); - assertEquals(2953, result.get().get("Freitag").getValue()); - assertEquals(26243, result.get().get("Samstag").getValue()); + assertEquals(8, result.get().get("Montag").getValue()); + assertEquals(13, result.get().get("Dienstag").getValue()); + assertEquals(5, result.get().get("Mittwoch").getValue()); + assertEquals(9, result.get().get("Donnerstag").getValue()); + assertEquals(10, result.get().get("Freitag").getValue()); + assertEquals(55, result.get().get("Samstag").getValue()); } @Test @@ -56,7 +56,7 @@ class WeekOverviewTest { AtomicReference>> result = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(3), () -> result.set(overview.getResult())); + assertTimeout(Duration.ofMillis(15), () -> result.set(overview.getResult())); assertEquals(26273, result.get().get("Montag").getKey()); @@ -66,12 +66,12 @@ class WeekOverviewTest { assertEquals(26413, result.get().get("Freitag").getKey()); assertEquals(146279, result.get().get("Samstag").getKey()); - assertEquals(39839, result.get().get("Montag").getValue()); - assertEquals(34992, result.get().get("Dienstag").getValue()); - assertEquals(37299, result.get().get("Mittwoch").getValue()); - assertEquals(35005, result.get().get("Donnerstag").getValue()); - assertEquals(38911, result.get().get("Freitag").getValue()); - assertEquals(214051, result.get().get("Samstag").getValue()); + assertEquals(108, result.get().get("Montag").getValue()); + assertEquals(93, result.get().get("Dienstag").getValue()); + assertEquals(89, result.get().get("Mittwoch").getValue()); + assertEquals(90, result.get().get("Donnerstag").getValue()); + assertEquals(110, result.get().get("Freitag").getValue()); + assertEquals(510, result.get().get("Samstag").getValue()); } @Test @@ -83,7 +83,7 @@ class WeekOverviewTest { AtomicReference>> result = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(30), () -> result.set(overview.getResult())); + assertTimeout(Duration.ofMillis(50), () -> result.set(overview.getResult())); assertEquals(295688, result.get().get("Montag").getKey()); @@ -93,11 +93,11 @@ class WeekOverviewTest { assertEquals(330907, result.get().get("Freitag").getKey()); assertEquals(1410789, result.get().get("Samstag").getKey()); - assertEquals(426952, result.get().get("Montag").getValue()); - assertEquals(379125, result.get().get("Dienstag").getValue()); - assertEquals(373891, result.get().get("Mittwoch").getValue()); - assertEquals(356996, result.get().get("Donnerstag").getValue()); - assertEquals(480062, result.get().get("Freitag").getValue()); - assertEquals(2015766, result.get().get("Samstag").getValue()); + assertEquals(1058, result.get().get("Montag").getValue()); + assertEquals(942, result.get().get("Dienstag").getValue()); + assertEquals(915, result.get().get("Mittwoch").getValue()); + assertEquals(919, result.get().get("Donnerstag").getValue()); + assertEquals(1177, result.get().get("Freitag").getValue()); + assertEquals(4989, result.get().get("Samstag").getValue()); } } From 41ae0c46e7260f6d7f5031ca974f1aeb88c548ef Mon Sep 17 00:00:00 2001 From: joethei Date: Thu, 16 May 2019 15:45:58 +0200 Subject: [PATCH 03/18] ~ removed unusable variables --- .../java/de/hsel/spm/baudas/analysis/WeekOverview.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java index 58f1443..acb1f8d 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java @@ -36,16 +36,11 @@ public class WeekOverview implements Analysis(); - int dayIndex = Attribute.SHOPPING_DAY; - int amountIndex = Attribute.PURCHASE_AMOUNT; - - int startArticles = Attribute.POWER_TOOLS; - int endArticles = Attribute.GARDENING_TOOLS + 1; for (int i = 0; i < instances.numInstances(); i++) { Instance instance = instances.get(i); - double amount = instance.value(amountIndex); - String day = instance.stringValue(dayIndex); + double amount = instance.value(Attribute.PURCHASE_AMOUNT); + String day = instance.stringValue(Attribute.SHOPPING_DAY); if (!result.containsKey(day)) { From 243eb1c7f9581192b68514fa94b04d251cec5f3f Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 21 May 2019 16:55:35 +0200 Subject: [PATCH 04/18] + error messages for file upload --- .../de/hsel/spm/baudas/web/ErrorCode.java | 14 ++++++ .../java/de/hsel/spm/baudas/web/Upload.java | 44 +++++++++++++++++++ src/main/webapp/emptyHeader.jsp | 13 ++++++ src/main/webapp/error.jsp | 36 +++++++++++++++ src/main/webapp/footer.jsp | 6 +-- src/main/webapp/head.jsp | 21 +++++++++ src/main/webapp/index.jsp | 2 +- src/main/webapp/{header.jsp => menu.jsp} | 24 +--------- src/main/webapp/theming.jsp | 4 ++ 9 files changed, 137 insertions(+), 27 deletions(-) create mode 100644 src/main/java/de/hsel/spm/baudas/web/ErrorCode.java create mode 100644 src/main/webapp/emptyHeader.jsp create mode 100644 src/main/webapp/error.jsp create mode 100644 src/main/webapp/head.jsp rename src/main/webapp/{header.jsp => menu.jsp} (76%) create mode 100644 src/main/webapp/theming.jsp diff --git a/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java b/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java new file mode 100644 index 0000000..906aef6 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java @@ -0,0 +1,14 @@ +package de.hsel.spm.baudas.web; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorCode { + FILE_NOT_FOUND ("Die Hochgeladene Datei konnte nicht gefunden werden"), + EMPTY_FILE ("Die Hochgeladene Datei ist leer"), + INVALID_FORMAT("Die Hochgeladene Datei hat ein falsches Format"); + + private String message; +} diff --git a/src/main/java/de/hsel/spm/baudas/web/Upload.java b/src/main/java/de/hsel/spm/baudas/web/Upload.java index 28f7c9d..c5adec8 100644 --- a/src/main/java/de/hsel/spm/baudas/web/Upload.java +++ b/src/main/java/de/hsel/spm/baudas/web/Upload.java @@ -1,6 +1,7 @@ package de.hsel.spm.baudas.web; import org.jetbrains.annotations.NotNull; +import weka.core.converters.CSVLoader; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; @@ -32,15 +33,57 @@ public class Upload extends HttpServlet { private static final long serialVersionUID = 14144111845151L; + private boolean checkFormat(InputStream stream) { + CSVLoader loader = new CSVLoader(); + try { + loader.setSource(stream); + return loader.getDataSet() != null; + } catch (IOException e) { + return false; + } + } + @Override protected void doPost(@NotNull HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding(StandardCharsets.UTF_8.name()); Part filePart = req.getPart("file"); + + if(filePart == null){ + resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + return; + } + + if(filePart.getSubmittedFileName() == null){ + resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + return; + } + String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); + + if(fileName == null){ + resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + return; + } + InputStream inputStream = filePart.getInputStream(); + if(inputStream == null){ + resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + return; + } + if(inputStream.available() == 0) { + resp.sendRedirect("error.jsp?code=" + ErrorCode.EMPTY_FILE); + return; + } + + if(!checkFormat(inputStream)){ + resp.sendRedirect("error.jsp?code=" + ErrorCode.INVALID_FORMAT); + return; + }else{ + inputStream = filePart.getInputStream(); + } Path path = Data.add(fileName); if (!Files.exists(path)) { @@ -49,6 +92,7 @@ public class Upload extends HttpServlet { Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING); + resp.sendRedirect(""); } } \ No newline at end of file diff --git a/src/main/webapp/emptyHeader.jsp b/src/main/webapp/emptyHeader.jsp new file mode 100644 index 0000000..d779ff1 --- /dev/null +++ b/src/main/webapp/emptyHeader.jsp @@ -0,0 +1,13 @@ + +<%@include file="head.jsp"%> + + + +
diff --git a/src/main/webapp/error.jsp b/src/main/webapp/error.jsp new file mode 100644 index 0000000..c1cfc0f --- /dev/null +++ b/src/main/webapp/error.jsp @@ -0,0 +1,36 @@ +<%-- + Created by IntelliJ IDEA. + User: julian + Date: 21.05.19 + Time: 14:21 + To change this template use File | Settings | File Templates. +--%> + +<%@ page import="java.nio.charset.StandardCharsets" %> +<%@ page import="de.hsel.spm.baudas.web.ErrorCode" %> +<%@ page contentType="text/html;charset=UTF-8" %> +<%@include file="emptyHeader.jsp"%> +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> + +<% + String code = request.getParameter("code"); + if(code != null){ + ErrorCode errorCode = ErrorCode.valueOf(code); +%> + +
+
+
+
+ <%= errorCode.getMessage()%> +
+
+
+
+<% + } +%> + + +<%@include file="theming.jsp"%> \ No newline at end of file diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index e6dd7bc..173d2e2 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -6,10 +6,8 @@ - - + +<%@include file="theming.jsp"%> diff --git a/src/main/webapp/head.jsp b/src/main/webapp/head.jsp new file mode 100644 index 0000000..fab1aeb --- /dev/null +++ b/src/main/webapp/head.jsp @@ -0,0 +1,21 @@ +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> + + + + BauDas + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 8cf6ee5..4052050 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,6 +1,6 @@ <%@ page import="java.nio.charset.StandardCharsets" %> <%@ page contentType="text/html;charset=UTF-8" %> -<%@include file="header.jsp"%> +<%@include file="menu.jsp"%> <% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> <% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> diff --git a/src/main/webapp/header.jsp b/src/main/webapp/menu.jsp similarity index 76% rename from src/main/webapp/header.jsp rename to src/main/webapp/menu.jsp index 77aceae..be68ab7 100644 --- a/src/main/webapp/header.jsp +++ b/src/main/webapp/menu.jsp @@ -1,26 +1,6 @@ -<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> -<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> - - - - BauDas - - - - - - - - - +<%@include file="head.jsp"%> - - - From 1b9e4884dcddca41ed5d7dd2f1abc60a8e890f66 Mon Sep 17 00:00:00 2001 From: Karsten Date: Sun, 26 May 2019 20:35:50 +0200 Subject: [PATCH 07/18] GUI for Shopping Cart Analysis done --- .../java/de/hsel/spm/baudas/web/Columns.java | 11 ++++ .../spm/baudas/web/ShoppingCartDiagram.java | 65 +++++++++++++++++++ src/main/webapp/footer.jsp | 2 + src/main/webapp/header.jsp | 1 + src/main/webapp/index.jsp | 11 ++-- src/main/webapp/js/cache.js | 1 + src/main/webapp/js/shopping_cart.js | 19 ++++++ 7 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 src/main/java/de/hsel/spm/baudas/web/Columns.java create mode 100644 src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java create mode 100644 src/main/webapp/js/shopping_cart.js diff --git a/src/main/java/de/hsel/spm/baudas/web/Columns.java b/src/main/java/de/hsel/spm/baudas/web/Columns.java new file mode 100644 index 0000000..9b00650 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/Columns.java @@ -0,0 +1,11 @@ +package de.hsel.spm.baudas.web; + +public class Columns { + private String col1; //NOPMD + private String col2; //NOPMD + + public Columns(String col1, String col2){ + this.col1 = col1; + this.col2 = col2; + } +} diff --git a/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java b/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java new file mode 100644 index 0000000..33f8f8c --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java @@ -0,0 +1,65 @@ +package de.hsel.spm.baudas.web; + +import com.google.gson.Gson; +import de.hsel.spm.baudas.analysis.ShoppingCart; +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.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * Changes data to readable format for Tabulator + * + * @author Karsten Eden + * @version 0.1 + * @since 0.1 + */ +@WebServlet("/shopping_cart") +public class ShoppingCartDiagram extends HttpServlet { + + private static final long serialVersionUID = 5026732432605473505L; + + 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(); + + Gson gson = new Gson(); + + List colList = new ArrayList<>(); + + if (req.getParameter("id") == null) { + out.print(gson.toJson(colList)); + return; + } + + UUID uuid = UUID.fromString(req.getParameter("id")); + File file = Data.get(uuid); + + ShoppingCart cart = new ShoppingCart(file); + + Map, List> map = cart.getResult(); + + List col1 = new ArrayList<>(); + List col2 = new ArrayList<>(); + + for(Map.Entry, List> entry : map.entrySet()){ + col1.add(entry.getKey().toString()); + col2.add(entry.getValue().toString()); + } + + for(int i = 0; i < col1.size(); i++ ){ + colList.add(new Columns(col1.get(i).replaceAll("\\[", "").replaceAll("\\]", ""), col2.get(i).replaceAll("\\[", "").replaceAll("\\]", ""))); + } + + out.print(gson.toJson(colList)); + } +} diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index 5e91340..c00e169 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -3,6 +3,7 @@ + @@ -16,6 +17,7 @@ + <%----%> diff --git a/src/main/webapp/header.jsp b/src/main/webapp/header.jsp index 5cd9784..9daab49 100644 --- a/src/main/webapp/header.jsp +++ b/src/main/webapp/header.jsp @@ -12,6 +12,7 @@ media="screen,projection"/> + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 6879491..2365169 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -64,14 +64,13 @@ -
+
+
+ Warenkorbanalyse +
-
- Warenkorbanalyse -
-
-

Coming Soon

+
diff --git a/src/main/webapp/js/cache.js b/src/main/webapp/js/cache.js index 8876e59..16e1c2e 100644 --- a/src/main/webapp/js/cache.js +++ b/src/main/webapp/js/cache.js @@ -38,6 +38,7 @@ function updateAll(uuid) { updateWeekOverviewChart(uuid); updateShoppingTimesChart(uuid); updateTopFlopChart(uuid); + updateShoppingCartTable(uuid); //add new charts here. } diff --git a/src/main/webapp/js/shopping_cart.js b/src/main/webapp/js/shopping_cart.js new file mode 100644 index 0000000..1ea2d35 --- /dev/null +++ b/src/main/webapp/js/shopping_cart.js @@ -0,0 +1,19 @@ +let table = new Tabulator("#shopping_cart_table", { + layout:"fitColumns", + columns:[ + {title:"Produkte", field:"col1", headerSort:false}, + {title:"zusammen mit", field:"col2", headerSort:false}, + ], +}); + + +function updateShoppingCartTable(id) { + if (typeof id !== 'undefined') { + request('shopping_cart', id).then(function () { + table.setData("/bauDas/shopping_cart?id="+id); + }); + } else request('shopping_cart').then(function () { + table.setData(); + }); +} + From c087ed77068825a05d5615a95ecc9d3ccb60b608 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Mon, 27 May 2019 09:06:04 +0200 Subject: [PATCH 08/18] + table for clusters (gui) --- .../hsel/spm/baudas/web/ClusterDiagram.java | 47 +++++++++++++++++++ src/main/webapp/footer.jsp | 1 + src/main/webapp/index.jsp | 3 +- src/main/webapp/js/cache.js | 1 + src/main/webapp/js/clusters.js | 39 +++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/hsel/spm/baudas/web/ClusterDiagram.java create mode 100644 src/main/webapp/js/clusters.js diff --git a/src/main/java/de/hsel/spm/baudas/web/ClusterDiagram.java b/src/main/java/de/hsel/spm/baudas/web/ClusterDiagram.java new file mode 100644 index 0000000..4da9a7f --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/ClusterDiagram.java @@ -0,0 +1,47 @@ +package de.hsel.spm.baudas.web; + +import com.google.gson.Gson; +import de.hsel.spm.baudas.analysis.Cluster; +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.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * changes data from cluster analysis into a readable format + * + * @author Julian Hinxlage + * @version 0.1 + * @since 0.1 + **/ +@WebServlet("/clusters") +public class ClusterDiagram 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(); + + if (req.getParameter("id") == null) { + out.print(gson.toJson(result)); + return; + } + UUID uuid = UUID.fromString(req.getParameter("id")); + File file = Data.get(uuid); + + Cluster cluster = new Cluster(file); + result = cluster.getResult(); + out.print(gson.toJson(result)); + } +} diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index 5e91340..b496efb 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -16,6 +16,7 @@ + <%----%> diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 6879491..6d0cb93 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -85,7 +85,8 @@ Gruppenübersicht
-

Coming Soon

+ +
diff --git a/src/main/webapp/js/cache.js b/src/main/webapp/js/cache.js index 8876e59..e712e2b 100644 --- a/src/main/webapp/js/cache.js +++ b/src/main/webapp/js/cache.js @@ -38,6 +38,7 @@ function updateAll(uuid) { updateWeekOverviewChart(uuid); updateShoppingTimesChart(uuid); updateTopFlopChart(uuid); + updateClusters(uuid) //add new charts here. } diff --git a/src/main/webapp/js/clusters.js b/src/main/webapp/js/clusters.js new file mode 100644 index 0000000..cb04091 --- /dev/null +++ b/src/main/webapp/js/clusters.js @@ -0,0 +1,39 @@ +let cluster_result; + +function updateClusters(id) { + if(typeof id !== 'undefined') { + request('clusters', id).then(function (data) { + cluster_result = data; + drawClusterTable(); + }); + }else request('clusters').then(function(data) { + cluster_result = data; + drawClusterTable(); + }); +} + +function drawClusterTable(){ + let row = $(""); + row.append(""); + row.append("Alter"); + row.append("Wohnort"); + row.append("Einkaufstag"); + row.append("Geschlecht"); + row.append("Familienstand"); + row.append("Einkaufsuhrzeit"); + row.append(""); + row.append(""); + row.append(""); + for(x in cluster_result){ + row.append($("")); + row.append($("" + cluster_result[x].Alter +"")); + row.append($("" + cluster_result[x].Wohnort +"")); + row.append($("" + cluster_result[x].Einkaufstag +"")); + row.append($("" + cluster_result[x].Geschlecht +"")); + row.append($("" + cluster_result[x].Familienstand +"")); + row.append($("" + cluster_result[x].Einkaufsuhrzeit +"")); + row.append($("")); + } + row.append(""); + $("#cluster_table").append(row); +} From b6f02e255fe3403c11b1ed18cc69d13331d968b9 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Mon, 27 May 2019 09:31:35 +0200 Subject: [PATCH 09/18] + working version Signed-off-by: Johannes Theiner #SPM-27: add work 6h development --- .../spm/baudas/web/ShoppingTimesDiagram.java | 23 +++-- .../spm/baudas/web/TopFlopArticleDiagram.java | 19 ++++- .../java/de/hsel/spm/baudas/web/Upload.java | 2 - .../spm/baudas/web/WeekOverviewDiagram.java | 20 +++-- src/main/webapp/footer.jsp | 1 + src/main/webapp/header.jsp | 84 +++++++++++++++++-- src/main/webapp/js/cache.js | 31 ++++++- src/main/webapp/js/shopping_times.js | 4 +- src/main/webapp/js/upload.js | 38 +++++++++ src/main/webapp/js/week_overview.js | 8 +- 10 files changed, 202 insertions(+), 28 deletions(-) create mode 100644 src/main/webapp/js/upload.js diff --git a/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java b/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java index 11b6c69..ed40db8 100644 --- a/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java +++ b/src/main/java/de/hsel/spm/baudas/web/ShoppingTimesDiagram.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.UUID; +import java.util.regex.Pattern; /** * changes data from shopping times diagram into a readable format for chart.js @@ -34,6 +35,8 @@ import java.util.UUID; @WebServlet("/shopping_times") public class ShoppingTimesDiagram extends HttpServlet { + private static Map cache = new HashMap<>(); + private static final long serialVersionUID = 6567531484L; @Override @@ -50,13 +53,21 @@ public class ShoppingTimesDiagram extends HttpServlet { Gson gson = new Gson(); - - if (req.getParameter("id") == null) { - result.put("labels", definedOrder); - out.print(gson.toJson(result)); + String id = req.getParameter("id"); + boolean match = Pattern.matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", id); + if (id == null || !match) { return; } - UUID uuid = UUID.fromString(req.getParameter("id")); + + UUID uuid = UUID.fromString(id); + + + if(cache.containsKey(uuid)) { + out.print(gson.toJson(cache.get(uuid))); + return; + } + + File file = Data.get(uuid); ShoppingTimes shoppingTimes = new ShoppingTimes(file); @@ -81,7 +92,7 @@ public class ShoppingTimesDiagram extends HttpServlet { } } - + cache.put(uuid, result); out.print(gson.toJson(result)); } diff --git a/src/main/java/de/hsel/spm/baudas/web/TopFlopArticleDiagram.java b/src/main/java/de/hsel/spm/baudas/web/TopFlopArticleDiagram.java index 2d6692f..660d6e3 100644 --- a/src/main/java/de/hsel/spm/baudas/web/TopFlopArticleDiagram.java +++ b/src/main/java/de/hsel/spm/baudas/web/TopFlopArticleDiagram.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.regex.Pattern; /** * @author Johannes Theiner @@ -23,6 +24,8 @@ import java.util.*; @WebServlet("/top_flop") public class TopFlopArticleDiagram extends HttpServlet { + private static Map cache = new HashMap<>(); + private static final long serialVersionUID = 6567531464214L; @Override @@ -34,7 +37,19 @@ public class TopFlopArticleDiagram extends HttpServlet { Gson gson = new Gson(); - UUID uuid = UUID.fromString(req.getParameter("id")); + String id = req.getParameter("id"); + boolean match = Pattern.matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", id); + if(id == null || !match) { + return; + } + + UUID uuid = UUID.fromString(id); + + if(cache.containsKey(uuid)) { + out.println(gson.toJson(cache.get(uuid))); + return; + } + File file = Data.get(uuid); TopFlopArticle articles = new TopFlopArticle(file); @@ -53,6 +68,8 @@ public class TopFlopArticleDiagram extends HttpServlet { result.put("labels", labels); result.put("data", data); + + cache.put(uuid, result); out.print(gson.toJson(result)); } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/Upload.java b/src/main/java/de/hsel/spm/baudas/web/Upload.java index 28f7c9d..11f7794 100644 --- a/src/main/java/de/hsel/spm/baudas/web/Upload.java +++ b/src/main/java/de/hsel/spm/baudas/web/Upload.java @@ -48,7 +48,5 @@ public class Upload extends HttpServlet { } Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING); - - resp.sendRedirect(""); } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/WeekOverviewDiagram.java b/src/main/java/de/hsel/spm/baudas/web/WeekOverviewDiagram.java index 9230839..6f8534f 100644 --- a/src/main/java/de/hsel/spm/baudas/web/WeekOverviewDiagram.java +++ b/src/main/java/de/hsel/spm/baudas/web/WeekOverviewDiagram.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.regex.Pattern; /** * changes data from week overview into readable format for chart.js @@ -30,6 +31,8 @@ import java.util.UUID; @WebServlet("/week_overview") public class WeekOverviewDiagram extends HttpServlet { + private static Map cache = new HashMap<>(); + private static final long serialVersionUID = 8484151844118L; @@ -45,16 +48,20 @@ public class WeekOverviewDiagram extends HttpServlet { Gson gson = new Gson(); + String id = req.getParameter("id"); + boolean match = Pattern.matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", id); - if (req.getParameter("id") == null) { - result.put("labels", definedOrder); - result.put("count", new ArrayList<>()); - result.put("revenue", new ArrayList<>()); - out.print(gson.toJson(result)); + + if (id == null || !match) { + return; + } + + UUID uuid = UUID.fromString(id); + if(cache.containsKey(uuid)) { + out.println(gson.toJson(cache.get(uuid))); return; } - UUID uuid = UUID.fromString(req.getParameter("id")); File file = Data.get(uuid); WeekOverview overview = new WeekOverview(file); @@ -79,6 +86,7 @@ public class WeekOverviewDiagram extends HttpServlet { result.put("count", count); result.put("revenue", revenue); + cache.put(uuid, result); out.print(gson.toJson(result)); } } \ No newline at end of file diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index 5e91340..175265d 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -12,6 +12,7 @@ M.AutoInit(); + diff --git a/src/main/webapp/header.jsp b/src/main/webapp/header.jsp index 5cd9784..a3a8979 100644 --- a/src/main/webapp/header.jsp +++ b/src/main/webapp/header.jsp @@ -12,6 +12,7 @@ media="screen,projection"/> + @@ -37,7 +38,7 @@ diff --git a/src/main/webapp/js/shopping_cart.js b/src/main/webapp/js/shopping_cart.js index 1ea2d35..0365594 100644 --- a/src/main/webapp/js/shopping_cart.js +++ b/src/main/webapp/js/shopping_cart.js @@ -1,4 +1,4 @@ -let table = new Tabulator("#shopping_cart_table", { +/*let table = new Tabulator("#shopping_cart_table", { layout:"fitColumns", columns:[ {title:"Produkte", field:"col1", headerSort:false}, @@ -15,5 +15,42 @@ function updateShoppingCartTable(id) { } else request('shopping_cart').then(function () { table.setData(); }); +}*/ + +let shopping_cart_result; + +function updateShoppingCartTable(id) { + if(typeof id !== 'undefined') { + request('shopping_cart', id).then(function (data) { + shopping_cart_result = data; + drawShoppingCartTable(); + }); + }else request('shopping_cart_result').then(function(data) { + shopping_cart_result = data; + drawShoppingCartTable(); + }); +} + +function drawShoppingCartTable(){ + let table = document.getElementById("shopping_cart_table"); + while(table.hasChildNodes()){ + table.removeChild(table.firstChild); + } + + let row = $(""); + row.append(""); + row.append("Artikel"); + row.append("Wird häufig zusammen gekauft mit") + row.append(""); + row.append(""); + row.append(""); + for (x in shopping_cart_result){ + row.append(""); + row.append("" + shopping_cart_result[x].col1 + ""); + row.append("" + shopping_cart_result[x].col2 + ""); + row.append(""); + } + row.append(""); + $("#shopping_cart_table").append(row); } From aa0a170ef6dcaa86142e4bdef7f9a125395105ed Mon Sep 17 00:00:00 2001 From: Karsten Date: Tue, 28 May 2019 15:10:43 +0200 Subject: [PATCH 15/18] Unused Code removed --- src/main/webapp/js/shopping_cart.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/main/webapp/js/shopping_cart.js b/src/main/webapp/js/shopping_cart.js index 0365594..8edb9c5 100644 --- a/src/main/webapp/js/shopping_cart.js +++ b/src/main/webapp/js/shopping_cart.js @@ -1,22 +1,3 @@ -/*let table = new Tabulator("#shopping_cart_table", { - layout:"fitColumns", - columns:[ - {title:"Produkte", field:"col1", headerSort:false}, - {title:"zusammen mit", field:"col2", headerSort:false}, - ], -}); - - -function updateShoppingCartTable(id) { - if (typeof id !== 'undefined') { - request('shopping_cart', id).then(function () { - table.setData("/bauDas/shopping_cart?id="+id); - }); - } else request('shopping_cart').then(function () { - table.setData(); - }); -}*/ - let shopping_cart_result; function updateShoppingCartTable(id) { From 3e42b632907340a9b1ad4e99e701f8011bc3eaba Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 28 May 2019 15:22:39 +0200 Subject: [PATCH 16/18] ~set color for chart labels to black --- src/main/webapp/index.jsp | 4 ++-- src/main/webapp/js/cache.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 0f73f27..1d25b3d 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -6,7 +6,7 @@ -
+
@@ -16,7 +16,7 @@
- +
diff --git a/src/main/webapp/js/cache.js b/src/main/webapp/js/cache.js index e712e2b..705181b 100644 --- a/src/main/webapp/js/cache.js +++ b/src/main/webapp/js/cache.js @@ -1,3 +1,5 @@ +Chart.defaults.global.defaultFontColor = "black"; + $(document).ready(function () { let dataset = $('#dataset'); request('files').then(results => { @@ -33,7 +35,6 @@ function updateCache() { } } - function updateAll(uuid) { updateWeekOverviewChart(uuid); updateShoppingTimesChart(uuid); From 987d2a84a80513fe4151b30f830b633fc82f469c Mon Sep 17 00:00:00 2001 From: edgar Date: Tue, 28 May 2019 15:28:05 +0200 Subject: [PATCH 17/18] =?UTF-8?q?GUI=20Marketingma=C3=9Fnahmen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/index.jsp | 107 +++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 37 deletions(-) diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index c0ccd3c..c8158c2 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -142,55 +142,88 @@
- -
-
-
-
- Marketingmaßnahme 1 +
+
+
+
+
+ Werbung +
+
+

+ Werbung dient dazu, auf bestimmte Produkte, Angebote oder den Markt im Allgemeinen aufmerksam zu machen. Sie kann über verschiedene Wege verbreitet werden, etwa das Internet, Zeitungsannoncen oder auch per TV/Radio. + Im Gegensatz zu Rabatten (die zeitabhängig am besten funktionieren) ist Werbung stark von der Zielgruppe abhängig. Insbesondere in der Kombination mit anderen Marketingmaßnahmen kann sie so ihre volle Wirkung entfalten. +
+
+ Analysen, die für Werbung nützlich sein könnten: + Clusteranalyse, Wochenübersicht, Verkaufszahlen +

+
-
-

Coming Soon

+
+
+
+
+
+
+ Sortimentsveränderung +
+
+

+ Gibt es eine Produktgruppe, die sich besonders gut verkauft, so sollte unter Umständen über die Erweiterung des Sortiments innerhalb dieser Gruppe nachgedacht werden. + Im Umkehrschluss dazu bietet sich an, schlecht verkaufte Produkte, welche keinen hohen Gewinn abwerfen aus dem täglichen Verkaufsgeschäft wieder zu entfernen. Dies verringert die Bildung von „Ladenhütern“ und schafft Platz für neue, sich besser verkaufende Produkte. +
+
+ Analysen, die bei der Sortimentswahl nützlich sein könnten: + Verkaufszahlen, Clusterübersicht +

+
-
-
-
-
- Marketingmaßnahme 2 -
-
-

Coming Soon

+
+
+
+
+
+ Rabatt +
+
+

+ Rabatte können z.B. an Tagen angeboten werden, an denen nur wenige Kunden erscheinen. Dadurch wird einerseits an dieses Tagen oder Uhrzeiten das Kaufverhalten angeregt, als auch der Andrang an anderen reduziert. Dies dient insbesondere der Entzerrung des zeitabhängigen Kaufverhaltens. + Des Weiteren können durch Rabatte weniger gut laufende Produkte in den Vordergrund gerückt du vergünstigt angeboten werden. + Zusätzlich dazu können sich gut verkaufende Produkte mit einem (vermeintlich) verringerten Preis versehen werden. Dies kann beim Kunden den „inneren Schnäppchenjäger“ wecken und dafür sorgen, dass er sich dieses gute Angebot nicht entgehen lassen kann. +
+
+ Analysen, die zur Platzierung von Rabatten nützlich sein können: + Wochenübersicht, Einkaufszeiten, Verkaufszahlen +

+
-
-
-
-
-
- Marketingmaßnahme 3 -
-
-

Coming Soon

-
-
-
-
-
-
-
-
- Marketingmaßnahme 4 -
-
-

Coming Soon

+
+
+
+
+ Produktplatzierung +
+
+

+ Es gibt bestimmte Produkte, die werden häufig zusammen erworben. Sind diese Produkte quer durch den Laden verstreut, so müssen die Kunden zusätzlich zu ihren Wunschprodukten auch an anderen Auslagen vorbei und die Anzahl an Spontankäufen eben jener weiteren Produkte steigt. +
+
+ Analysen, die bei der Produktplatzierung hilfreich sein könnten: + Warenkorbsanalyse, Verkaufszahlen +

+
+ + <%@include file="footer.jsp"%> \ No newline at end of file From 614f4b29ba1553cd6b6bf59ba038de95f83e51a1 Mon Sep 17 00:00:00 2001 From: joethei Date: Tue, 28 May 2019 16:42:32 +0200 Subject: [PATCH 18/18] merge missed one --- src/main/webapp/index.jsp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 2f081a6..25064ff 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -63,7 +63,6 @@
- <<<<<<< HEAD
@@ -75,23 +74,19 @@
+
- - -
-
-
- Warenkorbanalyse -
-
- -
- >>>>>>> origin/SPM-24 -
+ +
+
+
+ Warenkorbanalyse +
+
+ +
- -