~ more fixes

#SPM32: add work development 3h
This commit is contained in:
Johannes Theiner 2019-05-29 23:08:32 +02:00
parent 89468525ab
commit e5d55e04d9
22 changed files with 112 additions and 85 deletions

View File

@ -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

1
password.txt Normal file
View File

@ -0,0 +1 @@
SPM2019SS

View File

@ -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");
}

View File

@ -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<T> {
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;
}

View File

@ -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<Map<Integer, Map<String, String>>> {
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<Map<Integer, Map<String, String>>> {
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<Map<Integer, Map<String, String>>> {
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;
}

View File

@ -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<Map<List<String>, List<String>>> {
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<Map<List<String>, List<String>>> {
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<Map<List<String>, List<String>>> {
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++) {

View File

@ -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 {

View File

@ -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<String, List<SavedFile>> 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() {
}
}

View File

@ -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("<font color='red' class='align-center'>Das eingegebene Passwort ist falsch.</font>");
rd.include(request, response);
out.print("<script>$('#wrong_password').removeClass('hide')</script>");
}
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -1,3 +1,6 @@
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!--Cards-->
<!--Analyse-Cards-->
<div id="analysis" class="row container black-text">
@ -62,7 +65,7 @@
<div id="group_overview" class="card white">
<div class="card-content">
<div class="center">
<span class="card-title center">Gruppenübersicht</span>
<span class="card-title center">Clusterübersicht</span>
</div>
<div>
<table id="cluster_table">

View File

@ -1,11 +1,20 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js"
integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/google-palette@1.1.0/palette.min.js"></script>
<script>
M.AutoInit();
</script>
<script src="js/upload.js"></script>
<script src="js/datasets.js"></script>
<script src="js/week_overview.js"></script>
<script src="js/shopping_times.js"></script>
<script src="js/sales.js"></script>
<script src="js/clusters.js"></script>
<script src="js/shopping_cart.js"></script>
<!--Ende Skriptbereich-->
</body>

View File

@ -7,4 +7,4 @@
<%@include file="analysis.jsp"%>
<%@include file="marketing.jsp"%>
<%@include file="theming.jsp" %>
<%@include file="footer.jsp" %>

View File

@ -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();
}
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -1,7 +1,7 @@
<%@include file="emptyHeader.jsp" %>
<div class="container row">
<!--Login-->
<div class="container">
<div class="row">
<div class="center">
<div class="card white col s6 push-s3">
<div class="card-content">
@ -13,7 +13,8 @@
<div class="col s8 push-s2">
<form action="login" method="post">
<input id="password" type="password" class="validate" placeholder="Passwort" name="password">
<input id="password" type="password" class="validate" placeholder="Passwort"
name="password">
<input class="white-text btn blue-grey lighten-2" type="submit" value="Login">
</form>
</div>
@ -23,4 +24,15 @@
</div>
</div>
<div class="row hide" id="wrong_password">
<div class="col s4 push-s4">
<div class="card-panel red darken-1">
<h5 class="white-text center-align">
Das Passwort ist falsch
</h5>
</div>
</div>
</div>
</div>
<%@include file="footer.jsp" %>

View File

@ -1,3 +1,6 @@
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!--Marketing-Cards-->
<div id="marketing" class="row container">
<div class="row">

View File

@ -71,7 +71,7 @@
</div>
</li>
<li>
<div class="col s12">
<div class="col s12 center">
<button class="btn blue-grey waves-effect waves-light" type="submit" name="action">Hochladen<i
class="material-icons right">file_upload</i></button>
</div>

View File

@ -1,17 +0,0 @@
<!--Script für Diagramme-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js"
integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/upload.js"></script>
<script src="js/datasets.js"></script>
<script src="js/week_overview.js"></script>
<script src="js/shopping_times.js"></script>
<script src="js/sales.js"></script>
<script src="js/clusters.js"></script>
<script src="js/shopping_cart.js"></script>
<%@include file="footer.jsp"%>