diff --git a/README.md b/README.md index ec8c82e..32d2ed0 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ #Kundenkarten Analyse [![Build Status](https://teamcity.joethei.xyz/app/rest/builds/buildType:(id:Studium_Programmierung_Softwareprojektmanagement_SpmProd)/statusIcon)](https://tcstatus.joethei.space/dashboard/spm) -[![Quality Gate Status](https://sonarqube.joethei.xyz/api/project_badges/measure?project=de.hs-el.spm%3AbauDas-kundenkarten&metric=alert_status)](https://sonarqube.joethei.xyz/dashboard?id=de.hs-el.spm%3AbauDas-kundenkarten) - ## minimal Requirements diff --git a/password.txt b/password.txt new file mode 100644 index 0000000..7653102 --- /dev/null +++ b/password.txt @@ -0,0 +1 @@ +SPM2019SS \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/BauDas.java b/src/main/java/de/hsel/spm/baudas/BauDas.java new file mode 100644 index 0000000..c3beb76 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/BauDas.java @@ -0,0 +1,19 @@ +package de.hsel.spm.baudas; + +import lombok.Getter; + +import java.util.logging.Logger; + +/** + * general . + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ +public class BauDas { + + @Getter + private static Logger logger = Logger.getLogger("BauDas"); + +} \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java index e91a931..397a032 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java @@ -1,12 +1,12 @@ package de.hsel.spm.baudas.analysis; +import de.hsel.spm.baudas.BauDas; import org.jetbrains.annotations.Nullable; import weka.core.Instances; import weka.core.converters.CSVLoader; import java.io.File; import java.io.IOException; -import java.util.logging.Logger; /** * base interface for analysis. @@ -32,7 +32,7 @@ public interface Analysis { loader.setSource(file); return loader.getDataSet(); } catch (IOException e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "load", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } return null; } diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java index d5d974e..cd55e87 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java @@ -1,5 +1,6 @@ package de.hsel.spm.baudas.analysis; +import de.hsel.spm.baudas.BauDas; import org.jetbrains.annotations.NotNull; import weka.clusterers.SimpleKMeans; import weka.core.Instances; @@ -9,7 +10,6 @@ import weka.filters.unsupervised.attribute.Remove; import java.io.File; import java.util.HashMap; import java.util.Map; -import java.util.logging.Logger; /** * Cluster Analysis. @@ -47,7 +47,7 @@ public class Cluster implements Analysis>> { remove.setInputFormat(instances); instances = Filter.useFilter(instances, remove); } catch (Exception e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } //creating a single cluster to get average, weka has no way to get that from a bigger one. @@ -60,7 +60,7 @@ public class Cluster implements Analysis>> { averageCentroids = averageMeans.getClusterCentroids(); } catch (Exception ex) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), ex); } assert averageCentroids != null; @@ -78,7 +78,7 @@ public class Cluster implements Analysis>> { putIntoMap(centroids, count); } catch (Exception ex) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), ex); } return result; } diff --git a/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java b/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java index da437e9..91ef241 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java @@ -1,5 +1,6 @@ package de.hsel.spm.baudas.analysis; +import de.hsel.spm.baudas.BauDas; import weka.associations.Apriori; import weka.associations.AssociationRule; import weka.associations.Item; @@ -13,7 +14,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Logger; /** * The shopping-cart analysis. @@ -46,7 +46,7 @@ public class ShoppingCart implements Analysis, List>> { nc.setInputFormat(instances); instances = Filter.useFilter(instances, nc); } catch (Exception e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } @@ -56,7 +56,7 @@ public class ShoppingCart implements Analysis, List>> { num2nom.setInputFormat(instances); instances = Filter.useFilter(instances, num2nom); } catch (Exception e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } Apriori model = new Apriori(); @@ -65,7 +65,7 @@ public class ShoppingCart implements Analysis, List>> { try { model.buildAssociations(instances); } catch (Exception e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } for (int i = 0; i < model.getAssociationRules().getRules().size(); i++) { diff --git a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java index c30d696..5b39252 100644 --- a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java +++ b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java @@ -56,7 +56,8 @@ public class AuthorizationFilter implements Filter { String url = req.getRequestURI(); if (url.contains("login") || url.contains("logo") || url.contains("js/")) { chain.doFilter(request, response); - } else if (session == null || !((boolean) session.getAttribute("authentication"))) { //checking whether the session exists and if authentication succeed + } else if (session == null || session.getAttribute("authentication") == null + || !((boolean) session.getAttribute("authentication"))) { //checking whether the session exists and if authentication succeed this.context.log("Unauthorized access request"); res.sendRedirect(req.getContextPath() + "/login.jsp"); } else { diff --git a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java index 95db76d..33b8cdf 100644 --- a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java +++ b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java @@ -1,5 +1,6 @@ package de.hsel.spm.baudas.web; +import de.hsel.spm.baudas.BauDas; import lombok.Getter; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -16,7 +17,6 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.logging.Logger; import java.util.stream.Stream; /** @@ -31,6 +31,8 @@ public class DatasetManagement { @Getter private static ConcurrentMap> files = new ConcurrentHashMap<>(); + private DatasetManagement() {} + /** * adds file to list and generates a new filename. @@ -50,7 +52,7 @@ public class DatasetManagement { try { Files.delete(get(file.getUuid()).toPath()); } catch (IOException e) { - Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "add", e); + BauDas.getLogger().throwing(DatasetManagement.class.getName(), DatasetManagement.class.getEnclosingMethod().getName(), e); } files.get(session).remove(file); } @@ -70,7 +72,7 @@ public class DatasetManagement { try { Files.delete(get(file.getUuid()).toPath()); } catch (IOException e) { - Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e); + BauDas.getLogger().throwing(DatasetManagement.class.getName(), DatasetManagement.class.getEnclosingMethod().getName(), e); } } files.remove(session); @@ -87,13 +89,13 @@ public class DatasetManagement { try { Files.delete(path); } catch (IOException e) { - Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e); + BauDas.getLogger().throwing(DatasetManagement.class.getName(), DatasetManagement.class.getEnclosingMethod().getName(), e); } } } }); } catch (IOException ex) { - Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", ex); + BauDas.getLogger().throwing(DatasetManagement.class.getName(), DatasetManagement.class.getEnclosingMethod().getName(), ex); } } @@ -121,6 +123,5 @@ public class DatasetManagement { return uuid + ".csv"; } - private DatasetManagement() { - } + } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java index 83baa02..25ce233 100644 --- a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java @@ -11,6 +11,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Paths; /** * authenticates users. @@ -23,8 +25,6 @@ import java.io.PrintWriter; @WebServlet("/login") public class LoginServlet extends HttpServlet { - private final String password = "SPM2019SS"; - /** * reads from HTTP POST parameter 'password' and compares it. * @@ -34,17 +34,19 @@ public class LoginServlet extends HttpServlet { */ @Override protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws ServletException, IOException { + String pw = Files.readString(Paths.get("password.txt")); + String password = request.getParameter("password"); - if (this.password.equals(password)) { + if (pw.equals(password)) { HttpSession newSession = request.getSession(true); newSession.setAttribute("authentication", true); - newSession.setMaxInactiveInterval(5 * 60 * 60); //setting session to expiry in 5 hours - response.sendRedirect("/"); + newSession.setMaxInactiveInterval(5 * 60 * 60); //setting session to expire in 5 hours + response.sendRedirect("index.jsp"); } else { RequestDispatcher rd = getServletContext().getRequestDispatcher("/login.jsp"); PrintWriter out = response.getWriter(); - out.println("Das eingegebene Passwort ist falsch."); rd.include(request, response); + out.print(""); } } } diff --git a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java index 747a632..3f09c45 100644 --- a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java @@ -1,5 +1,6 @@ package de.hsel.spm.baudas.web; +import de.hsel.spm.baudas.BauDas; import org.jetbrains.annotations.NotNull; import weka.core.converters.CSVLoader; @@ -17,7 +18,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import java.util.logging.Logger; /** * saves uploaded files. @@ -115,7 +115,7 @@ public class UploadServlet extends HttpServlet { try { response.sendRedirect("error.jsp?code=" + code); } catch (IOException e) { - Logger.getLogger("BauDas").throwing(getClass().getName(), "error", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java b/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java index 070edbd..59e21d8 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java @@ -1,6 +1,7 @@ package de.hsel.spm.baudas.web.depiction; import com.google.gson.Gson; +import de.hsel.spm.baudas.BauDas; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -11,7 +12,6 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; -import java.util.logging.Logger; import java.util.regex.Pattern; /** @@ -51,7 +51,7 @@ interface Depiction { } return uuid; } catch (IOException e) { - Logger.getLogger("BauDas").throwing(this.getClass().getName(), "init", e); + BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } return null; } diff --git a/src/main/webapp/analysis.jsp b/src/main/webapp/analysis.jsp index db38a5d..0bf84a8 100644 --- a/src/main/webapp/analysis.jsp +++ b/src/main/webapp/analysis.jsp @@ -1,3 +1,6 @@ +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<%@ page contentType="text/html;charset=UTF-8" %>
@@ -62,7 +65,7 @@
- Gruppenübersicht + Clusterübersicht
diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index e597888..dab74de 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -1,11 +1,20 @@ - - + + + + + + + + + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 28e2390..d8d96a7 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -7,4 +7,4 @@ <%@include file="analysis.jsp"%> <%@include file="marketing.jsp"%> -<%@include file="theming.jsp" %> \ No newline at end of file +<%@include file="footer.jsp" %> \ No newline at end of file diff --git a/src/main/webapp/js/datasets.js b/src/main/webapp/js/datasets.js index 904b7f5..c15a37f 100644 --- a/src/main/webapp/js/datasets.js +++ b/src/main/webapp/js/datasets.js @@ -24,7 +24,7 @@ Chart.plugins.register({ ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.font = "16px normal 'Helvetica Nueue'"; - ctx.fillText('Kein Datenset ausgewählt', width / 2, height / 2); + ctx.fillText('Kein Datensatz ausgewählt', width / 2, height / 2); ctx.restore(); } } diff --git a/src/main/webapp/js/sales.js b/src/main/webapp/js/sales.js index a506b62..d5a64e9 100644 --- a/src/main/webapp/js/sales.js +++ b/src/main/webapp/js/sales.js @@ -19,6 +19,13 @@ let sales = new Chart($("#sales_chart"), { }] }, options: { + tooltips: { + callbacks: { + label: function (tooltipItems, data) { + return tooltipItems.xLabel + ' Stück'; + } + }, + }, responsive: true, title: { display: false diff --git a/src/main/webapp/js/upload.js b/src/main/webapp/js/upload.js index 4c50324..03c1f39 100644 --- a/src/main/webapp/js/upload.js +++ b/src/main/webapp/js/upload.js @@ -22,17 +22,6 @@ form.onsubmit = function (event) { loading.modal('open'); }; - xhr.upload.addEventListener("progress", function (event) { - if (event.lengthComputable) { - self.progress = Math.round(100 / event.total * event.loaded); - } else if (this.explicitTotal) { - self.progress = Math.min(1, event.loaded / self.explicitTotal); - } else { - self.progress = 0; - } - - }, false); - xhr.onloadend = function (e) { clearSelected(); updateDatasets(); diff --git a/src/main/webapp/js/week_overview.js b/src/main/webapp/js/week_overview.js index 72198bf..2fad832 100644 --- a/src/main/webapp/js/week_overview.js +++ b/src/main/webapp/js/week_overview.js @@ -17,22 +17,21 @@ let week_overview = new Chart($("#overview_chart"), { yAxisID: 'y-axis-1', data: [], fill: true, - backgroundColor: 'rgba(104, 216, 154, 0.5)', + backgroundColor: 'rgba(113, 114, 231, 1)', lineTension: 0 }, { label: "Einnahmen in €", yAxisID: 'y-axis-2', data: [], fill: true, - backgroundColor: 'rgba(113, 114, 231, 1)', + backgroundColor: 'rgba(244, 67, 54, 1)', lineTension: 0 }] }, options: { responsive: true, title: { - display: false, - text: 'Übersicht' + display: false }, legend: { display: false diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index f3153e3..0cbd537 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -1,26 +1,38 @@ -<%@include file="emptyHeader.jsp"%> +<%@include file="emptyHeader.jsp" %> -
- -
-
-
-
- -
-
-
-
+
+
+
+
+
+
+ +
+
+
+
-
- - - +
+ + + +
+ +
+
+
+
+ Das Passwort ist falsch +
+
+
+
-<%@include file="footer.jsp"%> \ No newline at end of file +<%@include file="footer.jsp" %> \ No newline at end of file diff --git a/src/main/webapp/marketing.jsp b/src/main/webapp/marketing.jsp index 79cbc3b..0b82a82 100644 --- a/src/main/webapp/marketing.jsp +++ b/src/main/webapp/marketing.jsp @@ -1,3 +1,6 @@ +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<%@ page contentType="text/html;charset=UTF-8" %>
diff --git a/src/main/webapp/menu.jsp b/src/main/webapp/menu.jsp index 0d814c0..d222eb7 100644 --- a/src/main/webapp/menu.jsp +++ b/src/main/webapp/menu.jsp @@ -71,7 +71,7 @@
  • -
    +
    diff --git a/src/main/webapp/theming.jsp b/src/main/webapp/theming.jsp deleted file mode 100644 index b0267ea..0000000 --- a/src/main/webapp/theming.jsp +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - -<%@include file="footer.jsp"%> \ No newline at end of file