Merge remote-tracking branch 'origin/SPM-31'
This commit is contained in:
commit
005bc14a93
|
@ -27,14 +27,12 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<List<String>, List<String>> getResult() {
|
public Map<List<String>, List<String>> getResult() {
|
||||||
if(result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new HashMap<>();
|
result = new HashMap<>();
|
||||||
|
|
||||||
Apriori model = new Apriori();
|
|
||||||
|
|
||||||
for (int i = 0; i < 11; i++) {
|
for (int i = 0; i < 11; i++) {
|
||||||
instances.deleteAttributeAt(0);
|
instances.deleteAttributeAt(0);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +58,8 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Apriori model = new Apriori();
|
||||||
|
|
||||||
model.setTreatZeroAsMissing(true);
|
model.setTreatZeroAsMissing(true);
|
||||||
try {
|
try {
|
||||||
model.buildAssociations(instances);
|
model.buildAssociations(instances);
|
||||||
|
@ -67,19 +67,19 @@ public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < model.getAssociationRules().getRules().size();i++){
|
for (int i = 0; i < model.getAssociationRules().getRules().size(); i++) {
|
||||||
AssociationRule rule = model.getAssociationRules().getRules().get(i);
|
AssociationRule rule = model.getAssociationRules().getRules().get(i);
|
||||||
|
|
||||||
List<String> l1 = new ArrayList<>();
|
List<String> l1 = new ArrayList<>();
|
||||||
for(Item item : rule.getPremise()){
|
for (Item item : rule.getPremise()) {
|
||||||
l1.add(item.getAttribute().name());
|
l1.add(item.getAttribute().name());
|
||||||
}
|
}
|
||||||
List<String> l2 = new ArrayList<>();
|
List<String> l2 = new ArrayList<>();
|
||||||
for(Item item : rule.getConsequence()){
|
for (Item item : rule.getConsequence()) {
|
||||||
l2.add(item.getAttribute().name());
|
l2.add(item.getAttribute().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
result.put(l1,l2);
|
result.put(l1, l2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package de.hsel.spm.baudas.web;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* all possible error codes.
|
||||||
|
*
|
||||||
|
* @author Julian Hinxlage
|
||||||
|
* @version 0.1
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is there a error code with this name ?.
|
||||||
|
*
|
||||||
|
* @param message string to search for
|
||||||
|
* @return error code exits ?
|
||||||
|
*/
|
||||||
|
public static boolean exists(String message) {
|
||||||
|
for (ErrorCode code : values()) {
|
||||||
|
System.out.println(message + " == " + code.name());
|
||||||
|
if (code.name().equals(message))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package de.hsel.spm.baudas.web;
|
package de.hsel.spm.baudas.web;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import weka.core.converters.CSVLoader;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.MultipartConfig;
|
import javax.servlet.annotation.MultipartConfig;
|
||||||
|
@ -20,7 +21,7 @@ import java.nio.file.StandardCopyOption;
|
||||||
/**
|
/**
|
||||||
* saves uploaded files.
|
* saves uploaded files.
|
||||||
*
|
*
|
||||||
* @author Johannes Theiner
|
* @author Johannes Theiner, Julian Hinxlage
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
**/
|
**/
|
||||||
|
@ -31,16 +32,62 @@ public class Upload extends HttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 14144111845151L;
|
private static final long serialVersionUID = 14144111845151L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* let weka check if the format is valid.
|
||||||
|
*
|
||||||
|
* @param stream input stream
|
||||||
|
* @return format valid
|
||||||
|
*/
|
||||||
|
private boolean checkFormat(InputStream stream) {
|
||||||
|
CSVLoader loader = new CSVLoader();
|
||||||
|
try {
|
||||||
|
loader.setSource(stream);
|
||||||
|
return loader.getDataSet() != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(@NotNull HttpServletRequest req, HttpServletResponse resp)
|
protected void doPost(@NotNull HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
throws ServletException, IOException {
|
|
||||||
req.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
req.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
|
|
||||||
Part filePart = req.getPart("file");
|
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();
|
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();
|
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);
|
Path path = Data.add(fileName);
|
||||||
if (!Files.exists(path)) {
|
if (!Files.exists(path)) {
|
||||||
|
@ -49,6 +96,7 @@ public class Upload extends HttpServlet {
|
||||||
|
|
||||||
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
|
|
||||||
resp.sendRedirect("");
|
resp.sendRedirect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
<%@include file="head.jsp"%>
|
||||||
|
|
||||||
|
<!--Navbar-->
|
||||||
|
<div class="navbar-fixed">
|
||||||
|
<nav class="nav-extended blue-grey darken-3 white-text row">
|
||||||
|
<a href="#" class="brand-logo hide-on-small-and-down center">BauDas</a>
|
||||||
|
<!--Navbar Items-->
|
||||||
|
<div class="nav-wrapper col 2 right">
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<br>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<%@ page import="de.hsel.spm.baudas.web.ErrorCode" %>
|
||||||
|
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||||
|
<%@ page import="java.util.List" %>
|
||||||
|
<%@ page import="java.util.Arrays" %>
|
||||||
|
<%@ page import="java.util.ArrayList" %>
|
||||||
|
<%@ 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.exists(code)){
|
||||||
|
ErrorCode errorCode = ErrorCode.valueOf(code);
|
||||||
|
%>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s4 push-s4">
|
||||||
|
<div class="card-panel red darken-1">
|
||||||
|
<h5 class="white-text center-align">
|
||||||
|
<%= errorCode.getMessage()%>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
<%@include file="theming.jsp"%>
|
|
@ -5,14 +5,8 @@
|
||||||
integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
|
integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
|
||||||
<!--Script für Materlialize-->
|
|
||||||
<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 type="text/javascript"
|
<%@include file="theming.jsp"%>
|
||||||
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/cache.js"></script>
|
<script src="js/cache.js"></script>
|
||||||
<script src="js/week_overview.js"></script>
|
<script src="js/week_overview.js"></script>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||||
|
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<title>BauDas</title>
|
||||||
|
<!--Import Google Icon Font-->
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<!--Import materialize.css-->
|
||||||
|
<link type="text/css" rel="stylesheet"
|
||||||
|
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
|
||||||
|
media="screen,projection"/>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"
|
||||||
|
integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous"/>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
|
||||||
|
|
||||||
|
<!--Let browser know website is optimized for mobile-->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
|
||||||
|
</head>
|
|
@ -1,6 +1,6 @@
|
||||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||||
<%@include file="header.jsp"%>
|
<%@include file="menu.jsp"%>
|
||||||
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||||
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,6 @@
|
||||||
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
|
||||||
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<title>BauDas</title>
|
|
||||||
<!--Import Google Icon Font-->
|
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
||||||
<!--Import materialize.css-->
|
|
||||||
<link type="text/css" rel="stylesheet"
|
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
|
|
||||||
media="screen,projection"/>
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"
|
|
||||||
integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous"/>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
|
|
||||||
|
|
||||||
<!--Let browser know website is optimized for mobile-->
|
<%@include file="head.jsp"%>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body class="blue-grey lighten-5">
|
|
||||||
<!--Navbar-->
|
<!--Navbar-->
|
||||||
<div class="navbar-fixed">
|
<div class="navbar-fixed">
|
||||||
<nav class="nav-extended blue-grey darken-3 white-text row">
|
<nav class="nav-extended blue-grey darken-3 white-text row">
|
||||||
|
@ -96,4 +76,4 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</form>
|
</form>
|
||||||
</ul>
|
</ul>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<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>
|
Loading…
Reference in New Issue