* code format cleanup
* load total collections and future/finished ones
This commit is contained in:
parent
34ab59c9a3
commit
16270da70f
11
.idea/artifacts/WasteInformationServer_main_jar.xml
generated
Normal file
11
.idea/artifacts/WasteInformationServer_main_jar.xml
generated
Normal file
@ -0,0 +1,11 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="WasteInformationServer.main:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/WasteInformationServer_main_jar</output-path>
|
||||
<root id="archive" name="WasteInformationServer.main.jar">
|
||||
<element id="module-output" name="WasteInformationServer.main" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.eclipse.paho/org.eclipse.paho.client.mqttv3/1.0.2/e1c9a81aadf25b884c779298a90750d0ab8013a5/org.eclipse.paho.client.mqttv3-1.0.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/mysql/mysql-connector-java/8.0.18/e088efaa4b568bc7d9f7274b9c5ea1a00da1a45c/mysql-connector-java-8.0.18.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protobuf-java/3.6.1/d06d46ecfd92ec6d0f3b423b4cd81cb38d8b924/protobuf-java-3.6.1.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
@ -11,7 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Date {
|
||||
public class Dateget {
|
||||
private int index = 0;
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
ArrayList<String> listnew = new ArrayList<>();
|
||||
@ -26,7 +26,7 @@ public class Date {
|
||||
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum="+datum+"&bdatum=19.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
|
||||
url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum=" + datum + "&bdatum=19.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
|
||||
Scanner scanner = new Scanner(new InputStreamReader(url.openStream()));
|
||||
|
||||
int n = 0;
|
||||
@ -81,22 +81,19 @@ public class Date {
|
||||
String part1 = parts[0]; // 004
|
||||
String part2 = parts[1]; // 034556*/
|
||||
|
||||
splitter();
|
||||
splitter();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void splitter()
|
||||
{
|
||||
String temp="</ul><h2>";
|
||||
private void splitter() {
|
||||
String temp = "</ul><h2>";
|
||||
|
||||
for (int n=0; n<listnew.size();n++)
|
||||
{
|
||||
for (int n = 0; n < listnew.size(); n++) {
|
||||
|
||||
if(listnew.get(n).equals(temp))
|
||||
{
|
||||
if (listnew.get(n).equals(temp)) {
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package com.wasteinformationserver.db;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class JDCB {
|
||||
static Connection conn;
|
||||
@ -21,18 +22,18 @@ public class JDCB {
|
||||
usernamec = username;
|
||||
passwordc = password;
|
||||
dbnamec = dbname;
|
||||
jdcb = new JDCB(username,password,dbname,ip,port);
|
||||
jdcb = new JDCB(username, password, dbname, ip, port);
|
||||
}
|
||||
|
||||
private JDCB(String username, String password, String dbname, String ip, int port) throws IOException {
|
||||
logintodb(username,password,dbname,ip, port);
|
||||
logintodb(username, password, dbname, ip, port);
|
||||
}
|
||||
|
||||
public static JDCB getInstance() throws IOException {
|
||||
if (loggedin){
|
||||
if (loggedin) {
|
||||
return jdcb;
|
||||
}else {
|
||||
logintodb(usernamec,passwordc,dbnamec,ipc,portc);
|
||||
} else {
|
||||
logintodb(usernamec, passwordc, dbnamec, ipc, portc);
|
||||
return jdcb;
|
||||
}
|
||||
|
||||
@ -66,8 +67,8 @@ public class JDCB {
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql) throws SQLException {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
|
||||
return stmt.executeUpdate();
|
||||
return stmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.wasteinformationserver;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import com.wasteinformationserver.db.JDCB;
|
||||
import com.wasteinformationserver.mqtt.*;
|
||||
import com.wasteinformationserver.mqtt.mqtt;
|
||||
import com.wasteinformationserver.website.Webserver;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,7 +33,7 @@ public class mqtt {
|
||||
client.connect(connOpts);
|
||||
|
||||
} catch (MqttException e) {
|
||||
Log.error("Connection to the ESB was failes");
|
||||
Log.error("Connection to the ESB was failed");
|
||||
}
|
||||
|
||||
mqttreceiver mr = new mqttreceiver(client);
|
||||
@ -92,7 +92,7 @@ public class mqtt {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.error("No data from databank");
|
||||
Log.error("No data from database");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
package com.wasteinformationserver.mqtt;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
@ -2,7 +2,6 @@ package com.wasteinformationserver.mqtt;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
|
@ -19,40 +19,42 @@ import com.sun.net.httpserver.HttpHandler;
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import com.wasteinformationserver.website.datarequests.login.LoginState;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class MainPage implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange t) throws IOException {
|
||||
String path = t.getRequestURI().getPath();
|
||||
|
||||
if (path.equals("/")){
|
||||
if (path.equals("/")) {
|
||||
path += "index.html";
|
||||
}
|
||||
|
||||
Log.debug("looking for: " + path);
|
||||
Log.debug("looking for: " + path);
|
||||
|
||||
if (path.contains(".html")){
|
||||
if (LoginState.getObject().isLoggedIn() || path.equals("/register.html")){ //pass only register page
|
||||
if (path.contains(".html")) {
|
||||
if (LoginState.getObject().isLoggedIn() || path.equals("/register.html")) { //pass only register page
|
||||
sendPage(path, t);
|
||||
}else {
|
||||
} else {
|
||||
Log.warning("user not logged in --> redirecting to login page");
|
||||
sendPage("/index.html",t);
|
||||
sendPage("/index.html", t);
|
||||
}
|
||||
}else { //only detect login state on html pages
|
||||
} else { //only detect login state on html pages
|
||||
sendPage(path, t);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPage(String path, HttpExchange t) throws IOException {
|
||||
InputStream fs = getClass().getResourceAsStream("/wwwroot"+path);
|
||||
InputStream fs = getClass().getResourceAsStream("/wwwroot" + path);
|
||||
|
||||
if (fs== null && path.substring(path.length() - 4).equals("html")) {
|
||||
if (fs == null && path.substring(path.length() - 4).equals("html")) {
|
||||
Log.warning("wrong page sending 404");
|
||||
sendPage("/404Error.html",t);
|
||||
} else if(fs== null){
|
||||
sendPage("/404Error.html", t);
|
||||
} else if (fs == null) {
|
||||
|
||||
}else {
|
||||
} else {
|
||||
// Object exists and is a file: accept with response code 200.
|
||||
String mime = "text/html";
|
||||
if (path.substring(path.length() - 3).equals(".js")) mime = "application/javascript";
|
||||
|
@ -3,11 +3,11 @@ package com.wasteinformationserver.website;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import com.wasteinformationserver.website.datarequests.AdminRequests;
|
||||
import com.wasteinformationserver.website.datarequests.NewDateRequest;
|
||||
import com.wasteinformationserver.website.datarequests.login.CheckLoginState;
|
||||
import com.wasteinformationserver.website.datarequests.DataRequest;
|
||||
import com.wasteinformationserver.website.datarequests.login.LoginRequest;
|
||||
import com.wasteinformationserver.website.datarequests.NewDateRequest;
|
||||
import com.wasteinformationserver.website.datarequests.RegisterRequest;
|
||||
import com.wasteinformationserver.website.datarequests.login.CheckLoginState;
|
||||
import com.wasteinformationserver.website.datarequests.login.LoginRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -37,7 +37,6 @@ public abstract class GetRequest implements HttpHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params received get params from com.wasteinformationserver.website
|
||||
* @return json reply to com.wasteinformationserver.website
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@ public abstract class PostRequest implements HttpHandler {
|
||||
while ((i = ios.read()) != -1) {
|
||||
sb.append((char) i);
|
||||
}
|
||||
String query = sb.toString();
|
||||
String query = sb.toString();
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
|
||||
@ -44,7 +44,6 @@ public abstract class PostRequest implements HttpHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params received get params from com.wasteinformationserver.website
|
||||
* @return json reply to com.wasteinformationserver.website
|
||||
*/
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.wasteinformationserver.website.datarequests;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
import com.wasteinformationserver.db.JDCB;
|
||||
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
@ -20,7 +18,7 @@ public class AdminRequests extends PostRequest {
|
||||
break;
|
||||
case "restartserver":
|
||||
final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
|
||||
File currentJar = null;
|
||||
File currentJar = null;
|
||||
try {
|
||||
currentJar = new File(AdminRequests.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
} catch (URISyntaxException e) {
|
||||
@ -28,7 +26,7 @@ public class AdminRequests extends PostRequest {
|
||||
}
|
||||
|
||||
/* is it a jar file? */
|
||||
if(!currentJar.getName().endsWith(".jar"))
|
||||
if (!currentJar.getName().endsWith(".jar"))
|
||||
System.out.println("not jar");
|
||||
|
||||
/* Build command: java -jar application.jar */
|
||||
|
@ -8,12 +8,15 @@ import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DataRequest extends PostRequest {
|
||||
@Override
|
||||
public String request(HashMap<String, String> params) {
|
||||
String result = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
JDCB jdcb;
|
||||
try {
|
||||
jdcb = JDCB.getInstance();
|
||||
@ -23,7 +26,6 @@ public class DataRequest extends PostRequest {
|
||||
}
|
||||
switch (params.get("action")) {
|
||||
case "newCity":
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{");
|
||||
Log.debug(params.toString());
|
||||
|
||||
@ -67,23 +69,19 @@ public class DataRequest extends PostRequest {
|
||||
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
|
||||
result = sb.toString();
|
||||
break;
|
||||
case "getAllCities":
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
ResultSet sett = jdcb.executeQuery("select * from cities");
|
||||
Log.debug(sett.toString());
|
||||
builder.append("{\"data\":[");
|
||||
sb.append("{\"data\":[");
|
||||
try {
|
||||
while (sett.next()) {
|
||||
builder.append("{\"cityname\":\"" + sett.getString("name") + "\"");
|
||||
builder.append(",\"wastetype\":\"" + sett.getString("wastetype") + "\"");
|
||||
builder.append(",\"id\":\"" + sett.getString("id") + "\"");
|
||||
builder.append(",\"zone\":\"" + sett.getString("zone") + "\"}");
|
||||
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"");
|
||||
sb.append(",\"wastetype\":\"" + sett.getString("wastetype") + "\"");
|
||||
sb.append(",\"id\":\"" + sett.getString("id") + "\"");
|
||||
sb.append(",\"zone\":\"" + sett.getString("zone") + "\"}");
|
||||
if (!sett.isLast()) {
|
||||
builder.append(",");
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
// System.out.println(sett.getString("name"));
|
||||
@ -91,43 +89,89 @@ public class DataRequest extends PostRequest {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
builder.append("]");
|
||||
builder.append(",\"query\":\"ok\"");
|
||||
builder.append("}");
|
||||
result = builder.toString();
|
||||
Log.debug(result);
|
||||
sb.append("]");
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
case "deletecity":
|
||||
//DELETE FROM `cities` WHERE `id`=0
|
||||
|
||||
StringBuilder sbb = new StringBuilder(); // TODO: 06.12.19 better naming and sb for all
|
||||
sbb.append("{");
|
||||
sb.append("{");
|
||||
Log.debug(params.get("id"));
|
||||
int status = 0;
|
||||
try{
|
||||
status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
||||
if (status == 1){
|
||||
try {
|
||||
status = jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id") + "'");
|
||||
if (status == 1) {
|
||||
//success
|
||||
sbb.append("\"status\" : \"success\"");
|
||||
}else {
|
||||
sbb.append("\"status\" : \"error\"");
|
||||
sb.append("\"status\" : \"success\"");
|
||||
} else {
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
}catch (SQLIntegrityConstraintViolationException e){
|
||||
} catch (SQLIntegrityConstraintViolationException e) {
|
||||
Log.warning("dependencies of deletion exist");
|
||||
sbb.append("\"status\" : \"dependenciesnotdeleted\"");
|
||||
sb.append("\"status\" : \"dependenciesnotdeleted\"");
|
||||
} catch (SQLException e) {
|
||||
Log.error("sql exception: "+e.getMessage());
|
||||
sbb.append("\"status\" : \"error\"");
|
||||
Log.error("sql exception: " + e.getMessage());
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
|
||||
Log.debug(status);
|
||||
|
||||
sbb.append(",\"query\":\"ok\"");
|
||||
sbb.append("}");
|
||||
result = sbb.toString();
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
|
||||
break;
|
||||
case "getcollectionnumber": //todo maybe combine all three to one
|
||||
sb.append("{");
|
||||
|
||||
try {
|
||||
ResultSet settt = jdcb.executeQuery("select * from pickupdates");
|
||||
settt.last();
|
||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
||||
} catch (SQLException e) {
|
||||
Log.error("sql exception: " + e.getMessage());
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
case "getcollectioninfuture":
|
||||
sb.append("{");
|
||||
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = new Date();
|
||||
String time = sdf.format(date);
|
||||
ResultSet settt = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '"+time+"' AND '2222-12-27'");
|
||||
settt.last();
|
||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
||||
} catch (SQLException e) {
|
||||
Log.error("sql exception: " + e.getMessage());
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
case "getfinishedcollections":
|
||||
sb.append("{");
|
||||
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = new Date();
|
||||
String time = sdf.format(date);
|
||||
ResultSet settt = jdcb.executeQuery("SELECT * FROM `pickupdates` WHERE `pickupdate` BETWEEN '0000-12-27' AND '"+time+"'");
|
||||
settt.last();
|
||||
sb.append("\"collectionnumber\":\"" + settt.getRow() + "\"");
|
||||
} catch (SQLException e) {
|
||||
Log.error("sql exception: " + e.getMessage());
|
||||
sb.append("\"status\" : \"error\"");
|
||||
}
|
||||
|
||||
sb.append(",\"query\":\"ok\"");
|
||||
sb.append("}");
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class RegisterRequest extends PostRequest {
|
||||
}
|
||||
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
|
||||
try {
|
||||
int s = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('"+params.get("username")+"', '"+params.get("firstname")+"', '"+params.get("lastname")+"', '"+passhash+"', '"+params.get("email")+"', current_timestamp());");
|
||||
int s = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('" + params.get("username") + "', '" + params.get("firstname") + "', '" + params.get("lastname") + "', '" + passhash + "', '" + params.get("email") + "', current_timestamp());");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ public class CheckLoginState extends PostRequest {
|
||||
@Override
|
||||
public String request(HashMap<String, String> params) {
|
||||
Log.message("checking login state");
|
||||
if ((params.get("action")).equals("getloginstate")){
|
||||
if (LoginState.getObject().isLoggedIn()){
|
||||
return "{\"loggedin\":true, \"username\":\""+LoginState.getObject().getUsername()+"\", \"permission\":\""+LoginState.getObject().getPermission()+"\"}";
|
||||
}else {
|
||||
if ((params.get("action")).equals("getloginstate")) {
|
||||
if (LoginState.getObject().isLoggedIn()) {
|
||||
return "{\"loggedin\":true, \"username\":\"" + LoginState.getObject().getUsername() + "\", \"permission\":\"" + LoginState.getObject().getPermission() + "\"}";
|
||||
} else {
|
||||
return "{\"loggedin\":false}";
|
||||
}
|
||||
}else if ((params.get("action")).equals("logout")){
|
||||
} else if ((params.get("action")).equals("logout")) {
|
||||
Log.debug("logging out");
|
||||
LoginState.getObject().logOut();
|
||||
return "{\"loggedin\":false}";
|
||||
|
@ -27,7 +27,8 @@ public class LoginRequest extends PostRequest {
|
||||
return "{\"status\" : \"nodbconn\"}";
|
||||
}
|
||||
|
||||
ResultSet s = jdcb.executeQuery("select * from user where username ='" + username + "'");;
|
||||
ResultSet s = jdcb.executeQuery("select * from user where username ='" + username + "'");
|
||||
;
|
||||
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation").executeQuery("select * from user where username ='" + username + "'");
|
||||
Log.debug("successfully logged in to db");
|
||||
String response = "{\"accept\": false}";
|
||||
@ -38,7 +39,7 @@ public class LoginRequest extends PostRequest {
|
||||
if (HttpTools.StringToMD5(password).equals(s.getString("password"))) {
|
||||
Log.debug("login success");
|
||||
LoginState.getObject().logIn();
|
||||
LoginState.getObject().setAccountData(username,"","","", s.getInt("permission")); // TODO: 06.12.19
|
||||
LoginState.getObject().setAccountData(username, "", "", "", s.getInt("permission")); // TODO: 06.12.19
|
||||
response = "{\"accept\": true}";
|
||||
} else {
|
||||
Log.debug("wrong password");
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.wasteinformationserver.website.datarequests.login;
|
||||
|
||||
public class LoginState {
|
||||
private LoginState() {}
|
||||
private LoginState() {
|
||||
}
|
||||
|
||||
private static LoginState mythis=new LoginState();
|
||||
private static LoginState mythis = new LoginState();
|
||||
|
||||
public static LoginState getObject(){
|
||||
public static LoginState getObject() {
|
||||
return mythis;
|
||||
}
|
||||
|
||||
@ -17,23 +18,23 @@ public class LoginState {
|
||||
|
||||
boolean loggedin = true;
|
||||
|
||||
public void logIn(){
|
||||
loggedin=true;
|
||||
public void logIn() {
|
||||
loggedin = true;
|
||||
}
|
||||
|
||||
public void logOut(){
|
||||
loggedin=false;
|
||||
public void logOut() {
|
||||
loggedin = false;
|
||||
}
|
||||
|
||||
public void setAccountData(String username, String firstname, String lastname, String email, int permission){
|
||||
this.username=username;
|
||||
this.firstname=firstname;
|
||||
this.lastname=lastname;
|
||||
this.email=email;
|
||||
public void setAccountData(String username, String firstname, String lastname, String email, int permission) {
|
||||
this.username = username;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.email = email;
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn(){
|
||||
public boolean isLoggedIn() {
|
||||
return loggedin;
|
||||
}
|
||||
|
||||
|
@ -132,9 +132,9 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3>150</h3>
|
||||
<h3 id="total-connection-labels">42</h3>
|
||||
|
||||
<p>Totale Abholungen</p>
|
||||
<p>Total collections</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-bag"></i>
|
||||
@ -162,9 +162,9 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-warning">
|
||||
<div class="inner">
|
||||
<h3>44</h3>
|
||||
<h3 id="planed-collection-label">44</h3>
|
||||
|
||||
<p>Geplante Abholungen</p>
|
||||
<p>Planned Collections</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-person-add"></i>
|
||||
@ -177,9 +177,9 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-danger">
|
||||
<div class="inner">
|
||||
<h3>65</h3>
|
||||
<h3 id="finished-collection-label">65</h3>
|
||||
|
||||
<p>Abgeschlossene Abholungen</p>
|
||||
<p>Finished Collections</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-pie-graph"></i>
|
||||
|
@ -12,6 +12,24 @@ $(document).ready(function () {
|
||||
}
|
||||
}, 'json');
|
||||
|
||||
//load total collections
|
||||
$.post('/senddata/wastedata', 'action=getcollectionnumber', function (data) {
|
||||
console.log(data);
|
||||
$("#total-connection-labels").html(data.collectionnumber);
|
||||
}, 'json');
|
||||
|
||||
//load future collections
|
||||
$.post('/senddata/wastedata', 'action=getcollectioninfuture', function (data) {
|
||||
console.log(data);
|
||||
$("#planed-collection-label").html(data.collectionnumber);
|
||||
}, 'json');
|
||||
|
||||
//load future collections
|
||||
$.post('/senddata/wastedata', 'action=getfinishedcollections', function (data) {
|
||||
console.log(data);
|
||||
$("#finished-collection-label").html(data.collectionnumber);
|
||||
}, 'json');
|
||||
|
||||
var citytable;
|
||||
|
||||
function reloadtable() {
|
||||
|
Loading…
Reference in New Issue
Block a user