From 835f2eab77231507c49b23481c288523d067f177 Mon Sep 17 00:00:00 2001 From: Jannik Date: Mon, 5 Mar 2018 23:03:05 +0100 Subject: [PATCH] minor fixes --- .../application/MainWindowController.java | 32 +++++----- .../HomeFlix/controller/DBController.java | 64 +++++++++---------- .../HomeFlix/controller/apiQuery.java | 12 ++-- .../HomeFlix/datatypes/FilmTabelDataType.java | 2 +- 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java index 3c5e30f..f0d4446 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java +++ b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java @@ -215,7 +215,7 @@ public class MainWindowController { @FXML TreeTableColumn columnRating = new TreeTableColumn<>("Rating"); @FXML - TreeTableColumn columnTitel = new TreeTableColumn<>("Titel"); + TreeTableColumn columnTitle = new TreeTableColumn<>("Title"); @FXML TreeTableColumn columnStreamUrl = new TreeTableColumn<>("File Name"); @FXML @@ -317,14 +317,14 @@ public class MainWindowController { treeTableViewfilm.setShowRoot(false); // write content into cell - columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty()); + columnTitle.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty()); columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty()); columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty()); columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject()); columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject()); // add columns to treeTableViewfilm - treeTableViewfilm.getColumns().add(columnTitel); + treeTableViewfilm.getColumns().add(columnTitle); treeTableViewfilm.getColumns().add(columnRating); treeTableViewfilm.getColumns().add(columnStreamUrl); treeTableViewfilm.getColumns().add(columnSeason); @@ -506,7 +506,7 @@ public class MainWindowController { selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // get selected item last = selected - 1; next = selected + 1; - title = columnTitel.getCellData(selected); // get name of selected item + title = columnTitle.getCellData(selected); // get name of selected item streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item if (mode.equals("local")) { @@ -732,21 +732,21 @@ public class MainWindowController { } // TODO rework - public void addDataUI(){ - - if(mode.equals("local")){ - for(int i = 0; i < localFilms.size(); i++){ - filmRoot.getChildren().add(new TreeItem(localFilms.get(i))); //add data to root-node + public void addDataUI() { + + if (mode.equals("local")) { + for (int i = 0; i < localFilms.size(); i++) { + filmRoot.getChildren().add(new TreeItem(localFilms.get(i))); // add data to root-node } columnRating.setMaxWidth(85); - columnTitel.setMaxWidth(290); + columnTitle.setMaxWidth(290); treeTableViewfilm.getColumns().get(3).setVisible(false); treeTableViewfilm.getColumns().get(4).setVisible(false); - }else if(mode.equals("streaming")){ - for(int i = 0; i < streamingFilms.size(); i++){ - filmRoot.getChildren().add(new TreeItem(streamingFilms.get(i))); //add data to root-node + } else { + for (int i = 0; i < streamingFilms.size(); i++) { + filmRoot.getChildren().add(new TreeItem(streamingFilms.get(i))); // add data to root-node } - columnTitel.setMaxWidth(215); + columnTitle.setMaxWidth(215); columnRating.setMaxWidth(60); columnSeason.setMaxWidth(55); columnEpisode.setMaxWidth(64); @@ -755,11 +755,13 @@ public class MainWindowController { } } + // add a source to the sources table on the settings pane public void addSourceToTable(String path, String mode) { sourcesList.add(new SourceDataType(path, mode)); streamingRoot.getChildren().add(new TreeItem(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node } + // add a source to the newsources list public void addSource(String path, String mode) { JsonObject source = null; JsonArray newsources = null; @@ -879,7 +881,7 @@ public class MainWindowController { languageLbl.setText(getBundle().getString("languageLbl")); autoUpdateToggleBtn.setText(getBundle().getString("autoUpdate")); branchLbl.setText(getBundle().getString("branchLbl")); - columnTitel.setText(getBundle().getString("columnName")); + columnTitle.setText(getBundle().getString("columnName")); columnRating.setText(getBundle().getString("columnRating")); columnStreamUrl.setText(getBundle().getString("columnStreamUrl")); columnSeason.setText(getBundle().getString("columnSeason")); diff --git a/src/main/java/kellerkinder/HomeFlix/controller/DBController.java b/src/main/java/kellerkinder/HomeFlix/controller/DBController.java index 22ea0f4..ed9bf07 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/DBController.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/DBController.java @@ -100,8 +100,8 @@ public class DBController { private void createDatabase() { try { Statement stmt = connection.createStatement(); - stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, cached)"); - stmt.executeUpdate("create table if not exists film_streaming (season, episode, rating, titel, streamUrl, cached)"); + stmt.executeUpdate("create table if not exists film_local (rating, title, streamUrl, cached)"); + stmt.executeUpdate("create table if not exists film_streaming (season, episode, rating, title, streamUrl, cached)"); stmt.executeUpdate("create table if not exists cache (" + "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer," + " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes," @@ -119,14 +119,14 @@ public class DBController { Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); while (rs.next()) { - filmsdbDir.add(rs.getString("titel")); + filmsdbDir.add(rs.getString("title")); } stmt.close(); rs.close(); rs = stmt.executeQuery("SELECT * FROM film_streaming;"); while (rs.next()) { - filmsdbAll.add(rs.getString("titel")); + filmsdbAll.add(rs.getString("title")); filmsdbStreamURL.add(rs.getString("streamUrl")); } stmt.close(); @@ -169,10 +169,10 @@ public class DBController { JsonObject object = Json.parse(new FileReader(path)).asObject(); JsonArray items = object.get("entries").asArray(); for (JsonValue item : items) { - filmsAll.add(item.asObject().getString("titel", "")); + filmsAll.add(item.asObject().getString("title", "")); filmsStreamURL.add(item.asObject().getString("streamUrl", "")); // TODO check if all this is needed, maybe only use one table! -// System.out.println(item.asObject().getString("titel", "")); +// System.out.println(item.asObject().getString("title", "")); // System.out.println(item.asObject().getString("streamUrl", "")); } LOGGER.info("added films from: " + path); @@ -192,29 +192,29 @@ public class DBController { try { //load local Data Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel"); + ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY title"); while (rs.next()) { if (rs.getInt("rating") == 1) { - mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"), + mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); } else { - mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"), + mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); } } stmt.close(); rs.close(); - //load streaming Data FIXME check if there are streaming data before loading -> maybe there is an issue now - rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY titel;"); + //load streaming Data + rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY title;"); while (rs.next()) { if (rs.getInt("rating") == 1) { mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"), - rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), + rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); } else { mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"), - rs.getInt("episode"),rs.getDouble("rating"), rs.getString("titel"),rs.getString("streamUrl"), + rs.getInt("episode"),rs.getDouble("rating"), rs.getString("title"),rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); } } @@ -243,21 +243,21 @@ public class DBController { ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE streamUrl = \"" + streamUrl + "\";"); if (rs.getInt("rating") == 1) { mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"), - rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); + rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); } else { mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"), - rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); + rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); } rs.close(); } else { ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE streamUrl = \"" + streamUrl + "\";"); if (rs.getInt("rating") == 1) { mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"), - rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), + rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); } else { mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"), - rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), + rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); } rs.close(); @@ -313,7 +313,7 @@ public class DBController { for (String entry : filmsdbDir) { if (!filmsAll.contains(cutOffEnd(entry))) { - stmt.executeUpdate("delete from film_local where titel = \"" + entry + "\""); + stmt.executeUpdate("delete from film_local where title = \"" + entry + "\""); connection.commit(); LOGGER.info("removed \"" + entry + "\" from database"); } @@ -341,7 +341,7 @@ public class DBController { */ private void checkAddEntry() throws SQLException, FileNotFoundException, IOException { Statement stmt = connection.createStatement(); - PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?)"); LOGGER.info("checking for entrys to add to DB ..."); // source is a single source of the sources list @@ -351,7 +351,7 @@ public class DBController { for (String entry : new File(source.getPath()).list()) { if (!filmsdbAll.contains(cutOffEnd(entry))) { stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \"" - + source.getPath() + "/" + entry + "\",\"favorite_border_black\",0)"); + + source.getPath() + "/" + entry + "\",0)"); connection.commit(); stmt.close(); LOGGER.info("added \"" + entry + "\" to database"); @@ -366,21 +366,19 @@ public class DBController { // for each item, check if it's the needed for (JsonValue item : items) { String streamUrl = item.asObject().getString("streamUrl", ""); - String titel = item.asObject().getString("titel", ""); + String title = item.asObject().getString("title", ""); // if it's the needed add it to the database if (streamUrl.equals(entry)) { - ps.setInt(1, item.asObject().getInt("year", 0)); - ps.setInt(2, item.asObject().getInt("season", 0)); - ps.setInt(3, item.asObject().getInt("episode", 0)); - ps.setInt(4, 0); - ps.setString(5, item.asObject().getString("resolution", "")); - ps.setString(6, titel); - ps.setString(7, streamUrl); - ps.setBoolean(8, false); + ps.setInt(1, item.asObject().getInt("season", 0)); + ps.setInt(2, item.asObject().getInt("episode", 0)); + ps.setInt(3, 0); + ps.setString(4, title); + ps.setString(5, streamUrl); + ps.setBoolean(6, false); ps.addBatch(); // adds the entry - LOGGER.info("added \"" + titel + "\" to database"); - filmsAll.add(cutOffEnd(titel)); + LOGGER.info("added \"" + title + "\" to database"); + filmsAll.add(cutOffEnd(title)); } } } @@ -400,7 +398,7 @@ public class DBController { ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); while (rs.next()) { System.out.println(rs.getString("rating")); - System.out.println(rs.getString("titel")); + System.out.println(rs.getString("title")); System.out.println(rs.getString("streamUrl")); System.out.println(rs.getString("cached") + "\n"); } @@ -414,7 +412,7 @@ public class DBController { System.out.println(rs.getString("season")); System.out.println(rs.getString("episode")); System.out.println(rs.getString("rating")); - System.out.println(rs.getString("titel")); + System.out.println(rs.getString("title")); System.out.println(rs.getString("streamUrl")); System.out.println(rs.getString("cached") + "\n"); } diff --git a/src/main/java/kellerkinder/HomeFlix/controller/apiQuery.java b/src/main/java/kellerkinder/HomeFlix/controller/apiQuery.java index 6f92a4e..d0bf937 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/apiQuery.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/apiQuery.java @@ -70,7 +70,7 @@ public class apiQuery{ /** * apiQuery for Project HomeFlix, sends a query to the omdb api */ - public void startQuery(String titel, String streamUrl){ + public void startQuery(String title, String streamUrl){ URL queryURL = null; Scanner sc = null; String moviename = null; @@ -89,7 +89,7 @@ public class apiQuery{ //get film title sc = new Scanner(System.in); - moviename = titel; + moviename = title; // in case of no or "" Film title if (moviename == null || moviename.equals("")) { @@ -139,11 +139,11 @@ public class apiQuery{ int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 198, 297); if (System.getProperty("os.name").equals("Linux")) { - posterPath = posterCache+"/"+titel+".png"; - ImageIO.write(resizeImagePNG, "png", new File(posterCache+"/"+titel+".png")); //change path where you want it saved + posterPath = posterCache+"/"+title+".png"; + ImageIO.write(resizeImagePNG, "png", new File(posterCache+"/"+title+".png")); //change path where you want it saved } else { - ImageIO.write(resizeImagePNG, "png", new File(posterCache+"\\"+titel+".png")); //change path where you want it saved - posterPath = posterCache+"\\"+titel+".png"; + ImageIO.write(resizeImagePNG, "png", new File(posterCache+"\\"+title+".png")); //change path where you want it saved + posterPath = posterCache+"\\"+title+".png"; } LOGGER.info("adding poster to cache: "+posterPath); diff --git a/src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java b/src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java index 656fa1b..cd881d5 100644 --- a/src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java +++ b/src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java @@ -46,7 +46,7 @@ public class FilmTabelDataType { * @param season season if it's a series * @param episode episode if it's a series * @param rating indicator for favorites, used for sorting the items - * @param titel title of the film + * @param title title of the film * @param streamUrl the concrete path to the file or the URL * @param cached indicator for caching status */