~ fixed a few problems that sonarqube found
#SPM32: add work development 2h
This commit is contained in:
parent
c19bb535f4
commit
89468525ab
|
@ -2,8 +2,8 @@
|
||||||
#Kundenkarten Analyse
|
#Kundenkarten Analyse
|
||||||
|
|
||||||
[![Build Status](https://teamcity.joethei.xyz/app/rest/builds/buildType:(id:Studium_Programmierung_Softwareprojektmanagement_SpmProd)/statusIcon)](https://tcstatus.joethei.space/dashboard/spm)
|
[![Build Status](https://teamcity.joethei.xyz/app/rest/builds/buildType:(id:Studium_Programmierung_Softwareprojektmanagement_SpmProd)/statusIcon)](https://tcstatus.joethei.space/dashboard/spm)
|
||||||
[![Quality Gate](https://sonarqube.joethei.xyz/api/project_badges/measure?project=Studium_Programmierung_Softwareprojektmanagement&metric=alert_status)
|
[![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)
|
||||||
![Code Coverage](https://sonarqube.joethei.xyz/api/project_badges/measure?project=Studium_Programmierung_Softwareprojektmanagement&metric=coverage)](https://sonarqube.joethei.xyz/dashboard?id=Studium_Programmierung_Softwareprojektmanagement)
|
|
||||||
|
|
||||||
## minimal Requirements
|
## minimal Requirements
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import weka.core.converters.CSVLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* base interface for analysis.
|
* base interface for analysis.
|
||||||
|
@ -31,7 +32,7 @@ public interface Analysis<T> {
|
||||||
loader.setSource(file);
|
loader.setSource(file);
|
||||||
return loader.getDataSet();
|
return loader.getDataSet();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "load", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,7 @@ class Attribute {
|
||||||
static final int GARDENING_TOOLS = 25;
|
static final int GARDENING_TOOLS = 25;
|
||||||
|
|
||||||
|
|
||||||
|
private Attribute() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import weka.filters.unsupervised.attribute.Remove;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cluster Analysis.
|
* Cluster Analysis.
|
||||||
|
@ -46,7 +47,7 @@ public class Cluster implements Analysis<Map<Integer, Map<String, String>>> {
|
||||||
remove.setInputFormat(instances);
|
remove.setInputFormat(instances);
|
||||||
instances = Filter.useFilter(instances, remove);
|
instances = Filter.useFilter(instances, remove);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//creating a single cluster to get average, weka has no way to get that from a bigger one.
|
//creating a single cluster to get average, weka has no way to get that from a bigger one.
|
||||||
|
@ -59,7 +60,7 @@ public class Cluster implements Analysis<Map<Integer, Map<String, String>>> {
|
||||||
averageCentroids = averageMeans.getClusterCentroids();
|
averageCentroids = averageMeans.getClusterCentroids();
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex);
|
||||||
}
|
}
|
||||||
assert averageCentroids != null;
|
assert averageCentroids != null;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public class Cluster implements Analysis<Map<Integer, Map<String, String>>> {
|
||||||
putIntoMap(centroids, count);
|
putIntoMap(centroids, count);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shopping-cart analysis.
|
* The shopping-cart analysis.
|
||||||
|
@ -45,7 +46,7 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
nc.setInputFormat(instances);
|
nc.setInputFormat(instances);
|
||||||
instances = Filter.useFilter(instances, nc);
|
instances = Filter.useFilter(instances, nc);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
num2nom.setInputFormat(instances);
|
num2nom.setInputFormat(instances);
|
||||||
instances = Filter.useFilter(instances, num2nom);
|
instances = Filter.useFilter(instances, num2nom);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Apriori model = new Apriori();
|
Apriori model = new Apriori();
|
||||||
|
@ -64,7 +65,7 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
try {
|
try {
|
||||||
model.buildAssociations(instances);
|
model.buildAssociations(instances);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < model.getAssociationRules().getRules().size(); i++) {
|
for (int i = 0; i < model.getAssociationRules().getRules().size(); i++) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ public class WeekOverview implements Analysis<Map<String, Map.Entry<Double, Inte
|
||||||
private Map<String, Map.Entry<Double, Integer>> result;
|
private Map<String, Map.Entry<Double, Integer>> result;
|
||||||
|
|
||||||
public WeekOverview(File file) {
|
public WeekOverview(File file) {
|
||||||
|
|
||||||
instances = load(file);
|
instances = load(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,9 @@ public class AuthorizationFilter implements Filter {
|
||||||
* initialize this filter.
|
* initialize this filter.
|
||||||
*
|
*
|
||||||
* @param filterConfig configuration
|
* @param filterConfig configuration
|
||||||
* @throws ServletException failed to initialize filter
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(@NotNull FilterConfig filterConfig) throws ServletException {
|
public void init(@NotNull FilterConfig filterConfig) {
|
||||||
this.context = filterConfig.getServletContext();
|
this.context = filterConfig.getServletContext();
|
||||||
this.context.log("AuthorizationFilter initialized");
|
this.context.log("AuthorizationFilter initialized");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* manages data about .csv files.
|
* manages data about .csv files.
|
||||||
|
@ -45,8 +47,10 @@ public class DatasetManagement {
|
||||||
|
|
||||||
if (files.get(session).size() >= 5) {
|
if (files.get(session).size() >= 5) {
|
||||||
SavedFile file = files.get(session).iterator().next();
|
SavedFile file = files.get(session).iterator().next();
|
||||||
if (!get(file.getUuid()).delete()) {
|
try {
|
||||||
System.err.println("failed to delete file " + file);
|
Files.delete(get(file.getUuid()).toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "add", e);
|
||||||
}
|
}
|
||||||
files.get(session).remove(file);
|
files.get(session).remove(file);
|
||||||
}
|
}
|
||||||
|
@ -63,16 +67,19 @@ public class DatasetManagement {
|
||||||
if (!files.containsKey(session)) return;
|
if (!files.containsKey(session)) return;
|
||||||
|
|
||||||
for (SavedFile file : files.get(session)) {
|
for (SavedFile file : files.get(session)) {
|
||||||
if (!get(file.getUuid()).delete())
|
try {
|
||||||
System.err.println("failed to delete file " + file);
|
Files.delete(get(file.getUuid()).toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
files.remove(session);
|
files.remove(session);
|
||||||
|
|
||||||
//deleting all files older than x days.
|
//deleting all files older than x days.
|
||||||
int days = 30;
|
int days = 30;
|
||||||
|
|
||||||
try {
|
try (Stream<Path> stream = Files.list(Paths.get(""))) {
|
||||||
Files.list(Paths.get("")).forEach(path -> {
|
stream.forEach(path -> {
|
||||||
if (path.toFile().getName().endsWith("*.csv")) {
|
if (path.toFile().getName().endsWith("*.csv")) {
|
||||||
long diff = new Date().getTime() - path.toFile().lastModified();
|
long diff = new Date().getTime() - path.toFile().lastModified();
|
||||||
|
|
||||||
|
@ -80,13 +87,13 @@ public class DatasetManagement {
|
||||||
try {
|
try {
|
||||||
Files.delete(path);
|
Files.delete(path);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,4 +120,7 @@ public class DatasetManagement {
|
||||||
private static String getFileName(@NotNull UUID uuid) {
|
private static String getFileName(@NotNull UUID uuid) {
|
||||||
return uuid + ".csv";
|
return uuid + ".csv";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DatasetManagement() {
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -27,7 +27,6 @@ public enum ErrorCode {
|
||||||
*/
|
*/
|
||||||
public static boolean exists(String message) {
|
public static boolean exists(String message) {
|
||||||
for (ErrorCode code : values()) {
|
for (ErrorCode code : values()) {
|
||||||
System.out.println(message + " == " + code.name());
|
|
||||||
if (code.name().equals(message))
|
if (code.name().equals(message))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class LoginServlet extends HttpServlet {
|
||||||
* @param response response object
|
* @param response response object
|
||||||
* @throws IOException failed to initialize print writer
|
* @throws IOException failed to initialize print writer
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws ServletException, IOException {
|
||||||
String password = request.getParameter("password");
|
String password = request.getParameter("password");
|
||||||
if (this.password.equals(password)) {
|
if (this.password.equals(password)) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class LogoutServlet extends HttpServlet {
|
||||||
* @param response response object
|
* @param response response object
|
||||||
* @throws IOException failed to initialize print writer
|
* @throws IOException failed to initialize print writer
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException {
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves uploaded files.
|
* saves uploaded files.
|
||||||
|
@ -62,45 +63,59 @@ public class UploadServlet extends HttpServlet {
|
||||||
Part filePart = req.getPart("file");
|
Part filePart = req.getPart("file");
|
||||||
|
|
||||||
if (filePart == null) {
|
if (filePart == null) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND);
|
error(resp, ErrorCode.FILE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePart.getSubmittedFileName() == null) {
|
if (filePart.getSubmittedFileName() == null) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND);
|
error(resp, ErrorCode.FILE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString();
|
String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString();
|
||||||
|
|
||||||
if (fileName == null) {
|
if (fileName == null) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND);
|
error(resp, ErrorCode.FILE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream inputStream = filePart.getInputStream();
|
InputStream inputStream = filePart.getInputStream();
|
||||||
|
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND);
|
error(resp, ErrorCode.FILE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inputStream.available() == 0) {
|
if (inputStream.available() == 0) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.EMPTY_FILE);
|
error(resp, ErrorCode.EMPTY_FILE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkFormat(inputStream)) {
|
if (!checkFormat(inputStream)) {
|
||||||
resp.sendRedirect("error.jsp?code=" + ErrorCode.INVALID_FORMAT);
|
error(resp, ErrorCode.INVALID_FORMAT);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
inputStream = filePart.getInputStream();
|
inputStream = filePart.getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path path = DatasetManagement.add(fileName, req.getSession().getId());
|
Path path = DatasetManagement.add(fileName, req.getSession().getId());
|
||||||
if (!Files.exists(path)) {
|
if (!path.toFile().exists()) {
|
||||||
Files.createFile(path);
|
Files.createFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redirect to error page.
|
||||||
|
*
|
||||||
|
* @param response response object
|
||||||
|
* @param code error code
|
||||||
|
*/
|
||||||
|
private void error(@NotNull HttpServletResponse response, @NotNull ErrorCode code) {
|
||||||
|
try {
|
||||||
|
response.sendRedirect("error.jsp?code=" + code);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Logger.getLogger("BauDas").throwing(getClass().getName(), "error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ import java.util.UUID;
|
||||||
@WebServlet("/clusters")
|
@WebServlet("/clusters")
|
||||||
public class ClusterTable extends HttpServlet implements Depiction {
|
public class ClusterTable extends HttpServlet implements Depiction {
|
||||||
|
|
||||||
private static Map<UUID, Map> cache;
|
private static Map<UUID, Map> cache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns formatted analysis result to HTTP GET request from supplied id.
|
* returns formatted analysis result to HTTP GET request from supplied id.
|
||||||
|
@ -37,15 +37,14 @@ public class ClusterTable extends HttpServlet implements Depiction {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||||
UUID uuid = setup(req, resp, cache);
|
UUID uuid = init(req, resp, cache);
|
||||||
if (uuid == null) return;
|
if (uuid == null) return;
|
||||||
|
|
||||||
|
|
||||||
Map<Integer, Map<String, String>> result = new HashMap<>();
|
|
||||||
File file = DatasetManagement.get(uuid);
|
File file = DatasetManagement.get(uuid);
|
||||||
|
|
||||||
Cluster cluster = new Cluster(file);
|
Cluster cluster = new Cluster(file);
|
||||||
result = cluster.getResult();
|
Map<Integer, Map<String, String>> result = cluster.getResult();
|
||||||
|
|
||||||
PrintWriter out = resp.getWriter();
|
PrintWriter out = resp.getWriter();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.io.PrintWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +32,7 @@ interface Depiction {
|
||||||
* @return validated uuid
|
* @return validated uuid
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default UUID setup(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Map<UUID, Map> cache) {
|
default UUID init(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Map<UUID, Map> cache) {
|
||||||
try {
|
try {
|
||||||
request.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
request.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
|
@ -50,7 +51,7 @@ interface Depiction {
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("BauDas").throwing(this.getClass().getName(), "init", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SalesNumberChart extends HttpServlet implements Depiction {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||||
UUID uuid = setup(req, resp, cache);
|
UUID uuid = init(req, resp, cache);
|
||||||
if (uuid == null) return;
|
if (uuid == null) return;
|
||||||
|
|
||||||
File file = DatasetManagement.get(uuid);
|
File file = DatasetManagement.get(uuid);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ShoppingCartTable extends HttpServlet implements Depiction {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5026732432605473505L;
|
private static final long serialVersionUID = 5026732432605473505L;
|
||||||
|
|
||||||
private static Map<UUID, Map> cache;
|
private static Map<UUID, Map> cache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns formatted analysis result to HTTP GET request from supplied id.
|
* returns formatted analysis result to HTTP GET request from supplied id.
|
||||||
|
@ -40,8 +40,9 @@ public class ShoppingCartTable extends HttpServlet implements Depiction {
|
||||||
* @param resp response object
|
* @param resp response object
|
||||||
* @throws IOException failed to initialize print writer
|
* @throws IOException failed to initialize print writer
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||||
UUID uuid = setup(req, resp, cache);
|
UUID uuid = init(req, resp, cache);
|
||||||
if (uuid == null) return;
|
if (uuid == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class ShoppingTimesChart extends HttpServlet implements Depiction {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||||
UUID uuid = setup(req, resp, cache);
|
UUID uuid = init(req, resp, cache);
|
||||||
if (uuid == null) return;
|
if (uuid == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class WeekOverviewChart extends HttpServlet implements Depiction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||||
UUID uuid = setup(req, resp, cache);
|
UUID uuid = init(req, resp, cache);
|
||||||
|
|
||||||
if (uuid == null) return;
|
if (uuid == null) return;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* renders cluster analysis results as a table.
|
||||||
|
*
|
||||||
|
* @author Julian Hinxlage
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let cluster_result;
|
let cluster_result;
|
||||||
|
|
||||||
function updateClusters(id) {
|
function updateClusters(id) {
|
||||||
|
@ -21,7 +29,7 @@ function drawClusterTable(){
|
||||||
let row = $("<thead>");
|
let row = $("<thead>");
|
||||||
row.append("<tr>");
|
row.append("<tr>");
|
||||||
row.append("<td></td>");
|
row.append("<td></td>");
|
||||||
for (x in cluster_result){
|
for (let x in cluster_result) {
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
row.append("<td>" + "Durchschnitt" + "</td>");
|
row.append("<td>" + "Durchschnitt" + "</td>");
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,7 +56,7 @@ function appendClusterTable(row, attrib){
|
||||||
row.append("</tbody>");
|
row.append("</tbody>");
|
||||||
row.append("<tr>");
|
row.append("<tr>");
|
||||||
row.append("<td>" + attrib + "</td>");
|
row.append("<td>" + attrib + "</td>");
|
||||||
for (x in cluster_result){
|
for (let x in cluster_result) {
|
||||||
row.append($("<td>" + cluster_result[x][attrib] + "</td>"));
|
row.append($("<td>" + cluster_result[x][attrib] + "</td>"));
|
||||||
}
|
}
|
||||||
row.append("</tr>");
|
row.append("</tr>");
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* Dataset switching and listing.
|
||||||
|
*
|
||||||
|
* @author Johannes Theiner
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
Chart.defaults.global.defaultFontColor = "black";
|
Chart.defaults.global.defaultFontColor = "black";
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* renders sales numbers as chart.
|
||||||
|
*
|
||||||
|
* @author Johannes Theiner
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let top_flop_result;
|
let top_flop_result;
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +21,7 @@ let sales = new Chart($("#sales_chart"), {
|
||||||
options: {
|
options: {
|
||||||
responsive: true,
|
responsive: true,
|
||||||
title: {
|
title: {
|
||||||
display: false,
|
display: false
|
||||||
text: 'Top Flop Artikel'
|
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* renders shopping cart analysis results as a table.
|
||||||
|
*
|
||||||
|
* @author Karsten Eden
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let shopping_cart_result;
|
let shopping_cart_result;
|
||||||
|
|
||||||
function updateShoppingCartTable(id) {
|
function updateShoppingCartTable(id) {
|
||||||
|
@ -25,7 +33,7 @@ function drawShoppingCartTable(){
|
||||||
row.append("</tr>");
|
row.append("</tr>");
|
||||||
row.append("</thead>");
|
row.append("</thead>");
|
||||||
row.append("<tbody>");
|
row.append("<tbody>");
|
||||||
for (x in shopping_cart_result){
|
for (let x in shopping_cart_result){
|
||||||
row.append("<tr>");
|
row.append("<tr>");
|
||||||
row.append("<td>" + shopping_cart_result[x].key + "</td>");
|
row.append("<td>" + shopping_cart_result[x].key + "</td>");
|
||||||
row.append("<td>" + shopping_cart_result[x].value + "</td>");
|
row.append("<td>" + shopping_cart_result[x].value + "</td>");
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* renders shopping times analysis result as chart with day selection.
|
||||||
|
*
|
||||||
|
* @author Johannes Theiner
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let shopping_result;
|
let shopping_result;
|
||||||
|
|
||||||
let shopping_chart = new Chart(document.getElementById("shopping_times_chart"), {
|
let shopping_chart = new Chart(document.getElementById("shopping_times_chart"), {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* upload files and show loading modal
|
||||||
|
*
|
||||||
|
* @author Johannes Theiner
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let form = document.getElementById("upload");
|
let form = document.getElementById("upload");
|
||||||
|
|
||||||
form.onsubmit = function (event) {
|
form.onsubmit = function (event) {
|
||||||
|
@ -12,7 +20,7 @@ form.onsubmit = function (event) {
|
||||||
loading.removeClass("hide");
|
loading.removeClass("hide");
|
||||||
$('.sidenav').sidenav('close');
|
$('.sidenav').sidenav('close');
|
||||||
loading.modal('open');
|
loading.modal('open');
|
||||||
}
|
};
|
||||||
|
|
||||||
xhr.upload.addEventListener("progress", function (event) {
|
xhr.upload.addEventListener("progress", function (event) {
|
||||||
if (event.lengthComputable) {
|
if (event.lengthComputable) {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
* render week overview analysis result as chart.
|
||||||
|
*
|
||||||
|
* @author Johannes Theiner
|
||||||
|
* @version 0.1
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
let week_result;
|
let week_result;
|
||||||
|
|
||||||
let week_overview = new Chart($("#overview_chart"), {
|
let week_overview = new Chart($("#overview_chart"), {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></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/upload.js"></script>
|
||||||
<script src="js/cache.js"></script>
|
<script src="js/datasets.js"></script>
|
||||||
<script src="js/week_overview.js"></script>
|
<script src="js/week_overview.js"></script>
|
||||||
<script src="js/shopping_times.js"></script>
|
<script src="js/shopping_times.js"></script>
|
||||||
<script src="js/sales.js"></script>
|
<script src="js/sales.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue