diff --git a/.classpath b/.classpath
index 61e40ff..e47eadb 100644
--- a/.classpath
+++ b/.classpath
@@ -6,5 +6,6 @@
+
diff --git a/DB_PATH b/DB_PATH
new file mode 100644
index 0000000..9e5295d
Binary files /dev/null and b/DB_PATH differ
diff --git a/bin/application/DBController$1.class b/bin/application/DBController$1.class
deleted file mode 100644
index 6925686..0000000
Binary files a/bin/application/DBController$1.class and /dev/null differ
diff --git a/bin/application/DBController.class b/bin/application/DBController.class
index 006445c..a8c4934 100644
Binary files a/bin/application/DBController.class and b/bin/application/DBController.class differ
diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class
index 3aa1da2..ec26f13 100644
Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ
diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class
index 1bd60b4..59c975b 100644
Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ
diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class
index 36d6a72..7713d77 100644
Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ
diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class
index 03908c6..3bf77ce 100644
Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ
diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class
index 5862215..f76c610 100644
Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ
diff --git a/src/application/DBController.java b/src/application/DBController.java
index 958eb0a..7ee00f0 100644
--- a/src/application/DBController.java
+++ b/src/application/DBController.java
@@ -1,3 +1,9 @@
+/**
+ * DBController for Project HomeFlix
+ *
+ * TODO fav and defav
+ */
+
package application;
import java.sql.Connection; //für Datenbank
@@ -6,211 +12,484 @@ import java.sql.PreparedStatement; //f
import java.sql.ResultSet; //für Datenbank
import java.sql.SQLException; //für Datenbank
import java.sql.Statement; //für Datenbank
-import java.io.File;//für Dateien einlesen
-class DBController {
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
+import com.eclipsesource.json.JsonValue;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class DBController {
+
+ public DBController(MainWindowController m){
+ mainWindowController=m;
+ }
- @SuppressWarnings("unused")
private MainWindowController mainWindowController;
- private static final DBController dbcontroller = new DBController();
- private static Connection connection;
- private static final String DB_PATH = System.getProperty("user.dir") + "/" + "Homeflix.db"; // der Pfad der Datenbank-Datei
- private String path;
- File f;
- File file[]; //ArrayList für die Dateien
+ private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; // der Pfad der Datenbank-Datei
+ Connection connection = null;
+
+ public void main()
+ {
+
+ System.out.println("Hallo");
+
+ try
+ {
+ // create a database connection
+ connection = DriverManager.getConnection("jdbc:sqlite:"+DB_PATH);
+// Statement statement = connection.createStatement();
+// statement.setQueryTimeout(30); // set timeout to 30 sec. TODO don't know wath to do with this
- static {
- try {
- Class.forName("org.sqlite.JDBC"); //Datenbanktreiber
- } catch (ClassNotFoundException e) {
- System.err.println("Fehler beim Laden des JDBC-Treibers");
- e.printStackTrace();
- }
- }
- public static void main(String input) {
- DBController datenbank = DBController.getInstance(); //neues Datenbank-Objekt wird erstellt
- datenbank.setPath(input); // Pfad zuweisen
- datenbank.f = new File(datenbank.getPath()); // für Datenbank-Datei einlesen
- datenbank.file = datenbank.f.listFiles(); // für Datenbank-Datei einlesen
- datenbank.verbindeDatenbank();
- datenbank.fuelleDatenbank();
- //datenbank.defavorisieren("Frozen");
- //datenbank.favorisieren("Frozen");
- //datenbank.ausgebenTitel();
- //System.out.println("Pfad: " + datenbank.getPfad("Frozen"));
- //System.out.println("Bewertung: " + datenbank.getFavStatus("Frozen"));
- }
-
- DBController(){
- }
-
- private static DBController getInstance(){
- return dbcontroller;
- }
-// Die Datenbak wird mit Hilfe des JDBC-Treibers eingebunden
- public void verbindeDatenbank() {
- try {
- if (connection != null)
- return;
- System.out.println("Erstelle Verbindung zur Datenbank...");
- connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
- if (!connection.isClosed())
- System.out.println("...Verbindung hergestellt");
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- try {
- if (!connection.isClosed() && connection != null) {
- connection.close();
- if (connection.isClosed())
- System.out.println("Verbindung getrennt");
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- });
- }
-// Die Dateien werden in die Datenbank geschrieben
+
+ fuelleDatenbank();
+// ausgeben();
+ getFavStatus("House of Cards");
+ favorisieren("House of Cards");
+ getFavStatus("House of Cards");
+ defavorisieren("House of Cards");
+ getFavStatus("House of Cards");
+
+ }
+ catch(SQLException e)
+ {
+ // if the error message is "out of memory",
+ // it probably means no database file is found
+ System.err.println(e.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if(connection != null)
+ connection.close();
+ }
+ catch(SQLException e)
+ {
+ // connection close failed.
+ System.err.println(e);
+ }
+ }
+ }
+
public void fuelleDatenbank() {
try {
- System.out.println("Erstelle Einträge");
- Statement stmt = connection.createStatement();
- stmt.executeUpdate("DROP TABLE IF EXISTS filme;");
- stmt.executeUpdate("CREATE TABLE filme (titel, pfad, bewertung);"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
+ System.out.println("Erstelle Einträge local");
+ Statement stmt = connection.createStatement();
+ Statement stmtS = connection.createStatement();
+ stmt.executeUpdate("drop table if exists film_local");
+ stmtS.executeUpdate("drop table if exists film_streaming");
+ stmt.executeUpdate("create table film_local (rating, titel, streamUrl)"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
+ stmtS.executeUpdate("create table film_streaming (year, season, episode, rating, resolution, titel, streamUrl)"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
- PreparedStatement ps = connection.prepareStatement("INSERT INTO filme VALUES (?, ?, ?);"); // SQL Befehl
- //System.out.println(file.length);
+ PreparedStatement ps = connection.prepareStatement("insert into film_local values (?, ?, ?)"); // SQL Befehl
+ PreparedStatement psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)"); // SQL Befehl
- for(int i=0;i!=file.length;i++) // Geht alle Dateien im Verzeichniss durch
+ String[] entries = new File(mainWindowController.getPath()).list();
+ System.out.println("Size: "+entries.length);
+
+ for(int i=0;i!=entries.length;i++) // Geht alle Dateien im Verzeichniss durch
{
//System.out.println(file[i].getName());
- ps.setString(1, ohneEndung(file[i].getName())); // definiert Name als String in der ersten Spalte
- ps.setString(2,file[i].getName()); // definiert Pfad als String in der zweiten Spalte
- ps.setInt(3, 0); // definiert Bewertung als Integer in der dritten Spalte
+ ps.setInt(1, 0); // definiert Bewertung als Integer in der dritten Spalte
+ ps.setString(2, ohneEndung(entries[i])); // definiert Name als String in der ersten Spalte
+ ps.setString(3,entries[i]); // definiert Pfad als String in der zweiten Spalte
ps.addBatch(); // fügt den Eintrag hinzu
}
+
+
+ System.out.println("Erstelle Einträge streaming");
+ System.out.println(mainWindowController.getStreamingPath());
+ if(mainWindowController.getStreamingPath().equals("")||mainWindowController.getStreamingPath().equals(null)){
+ System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
+ }else{
+ for(int i=0; i< mainWindowController.streamingData.size(); i++){
+ String fileName = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(i).getStreamUrl();
+ try {
+ JsonObject object = Json.parse(new FileReader(fileName)).asObject();
+ JsonArray items = object.get("entries").asArray();
+ for (JsonValue item : items) {
+ psS.setInt(1, item.asObject().getInt("year", 0));
+ psS.setInt(2, item.asObject().getInt("season", 0));
+ psS.setInt(3, item.asObject().getInt("episode", 0));
+ psS.setInt(4, 0);
+ psS.setString(5, item.asObject().getString("resolution", ""));
+ psS.setString(6, item.asObject().getString("titel",""));
+ psS.setString(7, item.asObject().getString("streamUrl", ""));
+ psS.addBatch(); // fügt den Eintrag hinzu
+ }
+ } catch (IOException e) {
+ //Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
connection.setAutoCommit(false);
ps.executeBatch(); // scheibt alle Einträge in die Datenbank
- connection.setAutoCommit(true);
+ psS.executeBatch();
+ connection.setAutoCommit(true);
+ ps.close();
+ psS.close();
//connection.close();
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
- }
+ }
public void ausgeben(){
- System.out.println("Einträge ausgeben");
- try {
- Statement stmt = connection.createStatement();
- mainWindowController = new MainWindowController();
- ResultSet rs = stmt.executeQuery("SELECT * FROM filme;");
- while (rs.next()) {
-// MainWindowController mainWindowController = new MainWindowController();
- }
- //rs.close();
-// mainWindowController.initTabel();
-
-
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
- }
-
+ System.out.println("Einträge ausgeben ... \n");
+ try {
+ Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
+ while (rs.next()) {
+ System.out.println(rs.getString(1));
+ System.out.println(rs.getString(2));
+ System.out.println(rs.getString(3)+"\n");
+ }
+ rs.close();
- }
-// Kontroll Methode, ob ein Film wirklich in der Datenbank ist
- public String getTitel(String name){
- try {
- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" );
- return rs.getString("titel");
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
+ System.out.println("Streaming Entries: \n");
+
+ ResultSet rsS = stmt.executeQuery("SELECT * FROM film_streaming;");
+ while (rsS.next()) {
+ System.out.println(rsS.getString(1));
+ System.out.println(rsS.getString(2));
+ System.out.println(rsS.getString(3));
+ System.out.println(rsS.getString(4));
+ System.out.println(rsS.getString(5));
+ System.out.println(rsS.getString(6));
+ System.out.println(rsS.getString(7)+"\n");
}
- return "Error 404";
+ rsS.close();
+
+ } catch (SQLException e) {
+ System.err.println("Konnte nicht ausgeführt werden");
+ e.printStackTrace();
}
-// gibt den Pfad eines bestimmten Films
- public String getPfad(String name){
- try {
+ mainWindowController.ta1.setText("Hallo");
+}
+
+//gibt die Favorisierung eines bestimmten Films
+ public void getFavStatus(String name){
+ try{
Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
- return rs.getString("pfad");
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
- }
- return "Error 404";
- }
-// gibt die Favorisierung eines bestimmten Films
- public boolean getFavStatus(String name){
- try {
- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT titel, bewertung FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
- System.out.println(rs.getInt("bewertung"));
- if((rs.getInt("bewertung")) == 1){
- return true;
+ ResultSet rs = stmt.executeQuery("SELECT titel, rating FROM film_local WHERE titel = '"+name+"';" ); //SQL Befehl
+ System.out.println("local:"+rs.getInt("rating"));
+ }catch(SQLException e){
+ try {
+ Statement stmtS = connection.createStatement();
+ ResultSet rsS = stmtS.executeQuery("SELECT titel, rating FROM film_streaming WHERE titel = '"+name+"';" );
+ System.out.println("streaming:"+rsS.getInt("rating"));
+ } catch (SQLException e1) {
+ System.out.println("Ups! an error occured!");
+ e1.printStackTrace();
}
- else{
- return false;
- }
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
- return false;
- }
- }
-// setzt die Defavorisierung eines bestimmten Films
- public void defavorisieren(String name){
- System.out.println("setze Bewertung");
- try {
- Statement stmt = connection.createStatement();
- String sql = ("UPDATE filme SET bewertung=0 WHERE titel='"+name+"';"); //SQL Befehl
- stmt.executeUpdate(sql);
- connection.setAutoCommit(false);
- connection.setAutoCommit(true);
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
- }
- }
-// setzt die Favorisierung eines bestimmten Films
- public void favorisieren(String name){
- System.out.println("setze Bewertung");
- try {
- Statement stmt = connection.createStatement();
- String sql = ("UPDATE filme SET bewertung=1 WHERE titel='"+name+"';"); //SQL Befehl
- stmt.executeUpdate(sql);
- connection.setAutoCommit(false);
- connection.setAutoCommit(true);
- } catch (SQLException e) {
- System.err.println("Konnte nicht ausgeführt werden");
- e.printStackTrace();
}
}
+//setzt die Defavorisierung eines bestimmten Films
+ public void defavorisieren(String name){
+ System.out.println("defavorisieren ...");
+ try{
+ Statement stmt = connection.createStatement();
+ stmt.executeUpdate("UPDATE film_local SET rating=0 WHERE titel='"+name+"';");
+ connection.commit(); //TODO hier kommt es zu fehlern mit dem autocommit
+ }catch(SQLException e){
+ try {
+ Statement stmtS = connection.createStatement();
+ stmtS.executeUpdate("UPDATE film_streaming SET rating=0 WHERE titel='"+name+"';");
+ connection.commit();
+ } catch (SQLException e1) {
+ System.out.println("Ups! an error occured!");
+ e1.printStackTrace();
+ }
+ }
+ }
+//setzt die Favorisierung eines bestimmten Films
+ public void favorisieren(String name){
+ System.out.println("favorisieren ...");
+ try{
+ Statement stmt = connection.createStatement();
+ stmt.executeUpdate("UPDATE film_local SET rating=1 WHERE titel='"+name+"';");
+ connection.commit(); //TODO hier kommt es zu fehlern mit dem autocommit
+ }catch(SQLException e){
+ try {
+ Statement stmtS = connection.createStatement();
+ stmtS.executeUpdate("UPDATE film_streaming SET rating=1 WHERE titel='"+name+"';");
+ connection.commit();
+ } catch (SQLException e1) {
+ System.out.println("Ups! an error occured!");
+ e1.printStackTrace();
+ }
+ }
+ }
+
//entfernt die Endung
- private static String ohneEndung (String str) {
+ private String ohneEndung (String str) {
if (str == null) return null;
int pos = str.lastIndexOf(".");
if (pos == -1) return str;
return str.substring(0, pos);
}
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path.replace("\\", "\\\\");
- }
+
}
+
+// private static final DBController dbcontroller = new DBController();
+// private static Connection connection;
+// private static final String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; // der Pfad der Datenbank-Datei
+// private String path;
+// File f;
+// File file[]; //ArrayList für die Dateien
+//
+// public DBController(MainWindowController m){
+// mainWindowController=m;
+// }
+//
+// private MainWindowController mainWindowController;
+//
+// static {
+// try {
+// Class.forName("org.sqlite.JDBC"); //Datenbanktreiber
+// } catch (ClassNotFoundException e) {
+// System.err.println("Fehler beim Laden des JDBC-Treibers");
+// e.printStackTrace();
+// }
+// }
+//
+// public static void main(String input) {
+// DBController datenbank = DBController.getInstance(); //neues Datenbank-Objekt wird erstellt
+// datenbank.setPath(input); // Pfad zuweisen
+// datenbank.f = new File(datenbank.getPath()); // für Datenbank-Datei einlesen
+// datenbank.file = datenbank.f.listFiles(); // für Datenbank-Datei einlesen
+// datenbank.verbindeDatenbank();
+// datenbank.fuelleDatenbank();
+// //datenbank.defavorisieren("Frozen");
+// //datenbank.favorisieren("Frozen");
+// //datenbank.ausgebenTitel();
+// //System.out.println("Pfad: " + datenbank.getPfad("Frozen"));
+// //System.out.println("Bewertung: " + datenbank.getFavStatus("Frozen"));
+// }
+//
+// DBController(){
+// }
+//
+// private static DBController getInstance(){
+// return dbcontroller;
+// }
+//// Die Datenbak wird mit Hilfe des JDBC-Treibers eingebunden
+// public void verbindeDatenbank() {
+// try {
+// if (connection != null)
+// return;
+// System.out.println("Erstelle Verbindung zur Datenbank...");
+// connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
+// if (!connection.isClosed())
+// System.out.println("...Verbindung hergestellt");
+// } catch (SQLException e) {
+// throw new RuntimeException(e);
+// }
+//
+// Runtime.getRuntime().addShutdownHook(new Thread() {
+// public void run() {
+// try {
+// if (!connection.isClosed() && connection != null) {
+// connection.close();
+// if (connection.isClosed())
+// System.out.println("Verbindung getrennt");
+// }
+// } catch (SQLException e) {
+// e.printStackTrace();
+// }
+// }
+// });
+// }
+//// Die Dateien werden in die Datenbank geschrieben
+// public void fuelleDatenbank() {
+//
+// try {
+// System.out.println("Erstelle Einträge local");
+// Statement stmt = connection.createStatement();
+// stmt.executeUpdate("DROP TABLE IF EXISTS film_local;");
+// stmt.executeUpdate("CREATE TABLE film_local (rating, titel, streamUrl);"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
+//
+// PreparedStatement ps = connection.prepareStatement("INSERT INTO film_local VALUES (?, ?, ?);"); // SQL Befehl
+// PreparedStatement psS = connection.prepareStatement("INSERT INTO film_streaming VALUES (?, ?, ?, ?, ?, ?, ?);"); // SQL Befehl
+//
+// System.out.println("Size: "+file.length);
+//
+// for(int i=0;i!=file.length;i++) // Geht alle Dateien im Verzeichniss durch
+// {
+// //System.out.println(file[i].getName());
+// ps.setInt(1, 0); // definiert Bewertung als Integer in der dritten Spalte
+// ps.setString(2, ohneEndung(file[i].getName())); // definiert Name als String in der ersten Spalte
+// ps.setString(3,file[i].getName()); // definiert Pfad als String in der zweiten Spalte
+// ps.addBatch(); // fügt den Eintrag hinzu
+// }
+//
+//
+// System.out.println("Erstelle Einträge streaming");
+// Statement stmtS = connection.createStatement();
+// stmtS.executeUpdate("DROP TABLE IF EXISTS film_streaming;");
+// stmtS.executeUpdate("CREATE TABLE film_streaming (year, season, episode, rating, resolution, titel, streamUrl);"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
+//
+// System.out.println(mainWindowController.getStreamingPath());
+// if(mainWindowController.getStreamingPath().equals("")||mainWindowController.getStreamingPath().equals(null)){
+// System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
+// }else{
+// for(int i=0; i< mainWindowController.streamingData.size(); i++){
+// String fileName = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(i).getStreamUrl();
+// try {
+// JsonObject object = Json.parse(new FileReader(fileName)).asObject();
+// JsonArray items = object.get("entries").asArray();
+// for (JsonValue item : items) {
+// psS.setInt(1, item.asObject().getInt("year", 0));
+// psS.setInt(2, item.asObject().getInt("season", 0));
+// psS.setInt(3, item.asObject().getInt("episode", 0));
+// psS.setInt(4, 0);
+// psS.setString(5, item.asObject().getString("resolution", ""));
+// psS.setString(6, item.asObject().getString("titel",""));
+// psS.setString(7, item.asObject().getString("streamUrl", ""));
+// psS.addBatch(); // fügt den Eintrag hinzu
+// }
+// } catch (IOException e) {
+// //Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+// }
+// connection.setAutoCommit(false);
+// ps.executeBatch(); // scheibt alle Einträge in die Datenbank
+// psS.executeBatch();
+// connection.setAutoCommit(true);
+// //connection.close();
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+// }
+//
+// public void ausgeben(){
+// System.out.println("Einträge ausgeben ... \n");
+// try {
+// Statement stmt = connection.createStatement();
+// mainWindowController = new MainWindowController();
+// ResultSet rs = stmt.executeQuery("SELECT * FROM film_local;");
+// while (rs.next()) {
+// System.out.println(rs.getString(1));
+// System.out.println(rs.getString(2));
+// System.out.println(rs.getString(3)+"\n");
+// }
+// rs.close();
+//
+// ResultSet rsS = stmt.executeQuery("SELECT * FROM film_streaming;");
+// while (rsS.next()) {
+// System.out.println(rsS.getString(1));
+// System.out.println(rsS.getString(2));
+// System.out.println(rsS.getString(3)+"\n");
+// }
+// rsS.close();
+//// mainWindowController.initTabel();
+//
+//
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+//
+//
+// }
+//// Kontroll Methode, ob ein Film wirklich in der Datenbank ist
+// public String getTitel(String name){
+// try {
+// Statement stmt = connection.createStatement();
+// ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" );
+// return rs.getString("titel");
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+// return "Error 404";
+// }
+//// gibt den Pfad eines bestimmten Films
+// public String getPfad(String name){
+// try {
+// Statement stmt = connection.createStatement();
+// ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
+// return rs.getString("pfad");
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+// return "Error 404";
+// }
+//// gibt die Favorisierung eines bestimmten Films
+// public boolean getFavStatus(String name){
+// try {
+// Statement stmt = connection.createStatement();
+// ResultSet rs = stmt.executeQuery("SELECT titel, bewertung FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
+// System.out.println(rs.getInt("bewertung"));
+// if((rs.getInt("bewertung")) == 1){
+// return true;
+// }
+// else{
+// return false;
+// }
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// return false;
+// }
+// }
+//// setzt die Defavorisierung eines bestimmten Films
+// public void defavorisieren(String name){
+// System.out.println("setze Bewertung");
+// try {
+// Statement stmt = connection.createStatement();
+// String sql = ("UPDATE filme SET bewertung=0 WHERE titel='"+name+"';"); //SQL Befehl
+// stmt.executeUpdate(sql);
+// connection.setAutoCommit(false);
+// connection.setAutoCommit(true);
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+// }
+//// setzt die Favorisierung eines bestimmten Films
+// public void favorisieren(String name){
+// System.out.println("setze Bewertung");
+// try {
+// Statement stmt = connection.createStatement();
+// String sql = ("UPDATE filme SET bewertung=1 WHERE titel='"+name+"';"); //SQL Befehl
+// stmt.executeUpdate(sql);
+// connection.setAutoCommit(false);
+// connection.setAutoCommit(true);
+// } catch (SQLException e) {
+// System.err.println("Konnte nicht ausgeführt werden");
+// e.printStackTrace();
+// }
+// }
+////entfernt die Endung
+// private static String ohneEndung (String str) {
+//
+// if (str == null) return null;
+// int pos = str.lastIndexOf(".");
+// if (pos == -1) return str;
+// return str.substring(0, pos);
+// }
+//
+// public String getPath() {
+// return path;
+// }
+//
+// public void setPath(String path) {
+// this.path = path.replace("\\", "\\\\");
+// }
+//}
diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java
index 41c4955..0db4035 100644
--- a/src/application/MainWindowController.java
+++ b/src/application/MainWindowController.java
@@ -239,7 +239,7 @@ public class MainWindowController {
private ObservableList filterData = FXCollections.observableArrayList();
private ObservableList streamData = FXCollections.observableArrayList();
private ObservableList locals = FXCollections.observableArrayList("english", "deutsch");
- private ObservableList streamingData = FXCollections.observableArrayList();
+ ObservableList streamingData = FXCollections.observableArrayList();
private ImageView menu_icon_black = new ImageView(new Image("recources/icons/menu_icon_black.png"));
private ImageView menu_icon_white = new ImageView(new Image("recources/icons/menu_icon_white.png"));
private ImageView skip_previous_white = new ImageView(new Image("recources/icons/ic_skip_previous_white_18dp_1x.png"));
@@ -253,6 +253,7 @@ public class MainWindowController {
private updater Updater;
private apiQuery ApiQuery;
+ private DBController dbController;
//wenn menubtn clicked
/**
@@ -424,6 +425,7 @@ public class MainWindowController {
@FXML
private void debugBtnclicked(){
+ dbController.main();
//for testing
}
@@ -508,11 +510,14 @@ public class MainWindowController {
Updater = new updater(this);
ApiQuery = new apiQuery(this);
+ dbController = new DBController(this);
System.out.println("Mode: "+mode);
- debugBtn.setDisable(true); //debugging btn for tests
- debugBtn.setVisible(false);
+// dbController.ausgeben();
+
+ debugBtn.setDisable(false); //debugging btn for tests
+ debugBtn.setVisible(true);
tfPath.setText(getPath());
diff --git a/src/libraries/sqlite-jdbc-3.15.1.jar b/src/libraries/sqlite-jdbc-3.15.1.jar
new file mode 100644
index 0000000..f628324
Binary files /dev/null and b/src/libraries/sqlite-jdbc-3.15.1.jar differ