diff --git a/bin/application/DBController.class b/bin/application/DBController.class index a8c4934..cd23503 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 ec26f13..32fe9f1 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 59c975b..a6e3573 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 7713d77..e3e4960 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 3bf77ce..a277bc1 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 f76c610..be88a40 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 7ee00f0..ee23e59 100644 --- a/src/application/DBController.java +++ b/src/application/DBController.java @@ -1,12 +1,12 @@ /** * DBController for Project HomeFlix * - * TODO fav and defav + * connection is in manual commit! */ package application; -import java.sql.Connection; //für Datenbank +import java.sql.Connection; //für Datenbank import java.sql.DriverManager; //für Datenbank import java.sql.PreparedStatement; //für Datenbank import java.sql.ResultSet; //für Datenbank @@ -22,59 +22,46 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; -public class DBController { - - public DBController(MainWindowController m){ - mainWindowController=m; +public class DBController { + + public DBController(MainWindowController m) { + mainWindowController = m; } - + private MainWindowController mainWindowController; 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 + Connection connection = null; + public void main() { + 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 - - 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); - } - } - } + connection.setAutoCommit(false); //Autocommit to false -> manual commit is active! + 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() { @@ -92,7 +79,6 @@ public class DBController { PreparedStatement psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)"); // SQL Befehl 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 { @@ -104,9 +90,7 @@ public class DBController { } - System.out.println("Erstelle Einträge streaming"); - - System.out.println(mainWindowController.getStreamingPath()); + System.out.println("Erstelle Einträge streaming \n"); if(mainWindowController.getStreamingPath().equals("")||mainWindowController.getStreamingPath().equals(null)){ System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist }else{ @@ -131,16 +115,16 @@ public class DBController { } } } - connection.setAutoCommit(false); +// connection.setAutoCommit(false); ps.executeBatch(); // scheibt alle Einträge in die Datenbank - psS.executeBatch(); - connection.setAutoCommit(true); + psS.executeBatch(); + connection.commit(); ps.close(); psS.close(); //connection.close(); - } catch (SQLException e) { + } catch (SQLException ea) { System.err.println("Konnte nicht ausgeführt werden"); - e.printStackTrace(); + ea.printStackTrace(); } } @@ -200,16 +184,18 @@ public class DBController { 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(); - } + connection.commit(); + }catch(SQLException e){ + System.out.println("Ups! an error occured!"); + e.printStackTrace(); + } + 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 @@ -218,16 +204,18 @@ public class DBController { 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(); - } + connection.commit(); + }catch(SQLException e){ + System.out.println("Ups! an error occured!"); + e.printStackTrace(); + } + 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(); } } diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 0db4035..26494d4 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -425,7 +425,12 @@ public class MainWindowController { @FXML private void debugBtnclicked(){ - dbController.main(); + dbController.main(); //TODO das muss vor einen anderen Befehl warum auch immer + dbController.getFavStatus("House of Cards"); + dbController.favorisieren("House of Cards"); + dbController.getFavStatus("House of Cards"); +// dbController.defavorisieren("House of Cards"); +// dbController.getFavStatus("House of Cards"); //for testing } @@ -514,7 +519,7 @@ public class MainWindowController { System.out.println("Mode: "+mode); -// dbController.ausgeben(); +// dbController.main(); debugBtn.setDisable(false); //debugging btn for tests debugBtn.setVisible(true); diff --git a/src/recources/icons/ic_favorite_black_18dp_1x.png b/src/recources/icons/ic_favorite_black_18dp_1x.png new file mode 100644 index 0000000..69be1f5 Binary files /dev/null and b/src/recources/icons/ic_favorite_black_18dp_1x.png differ diff --git a/src/recources/icons/ic_favorite_border_black_18dp_1x.png b/src/recources/icons/ic_favorite_border_black_18dp_1x.png new file mode 100644 index 0000000..7edb675 Binary files /dev/null and b/src/recources/icons/ic_favorite_border_black_18dp_1x.png differ