worked on dbcontroller part 4
nearly finished only a few things to do (addEntry and UI things)
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/application/MainWindowController$5.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/application/MainWindowController$5.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/application/MainWindowController$6.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/application/MainWindowController$6.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -1,27 +1,28 @@ | ||||
| /** | ||||
|  * DBController for Project HomeFlix | ||||
|  *  | ||||
|  * connection is in manual commit! | ||||
|  * TODO <20>berpr<70>fen ob neue filme hinzu gekommen sind | ||||
|  */ | ||||
|  | ||||
| package application; | ||||
|  | ||||
| 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 | ||||
| import java.sql.SQLException; //f<>r Datenbank | ||||
| import java.sql.Statement; //f<>r Datenbank | ||||
| import java.io.File; | ||||
| import java.io.FileReader; | ||||
| import java.io.IOException; | ||||
| import java.sql.Connection; | ||||
| import java.sql.DriverManager; | ||||
| import java.sql.PreparedStatement; | ||||
| import java.sql.ResultSet; | ||||
| import java.sql.SQLException; | ||||
| import java.sql.Statement; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| 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) { | ||||
| @ -30,6 +31,11 @@ public class DBController { | ||||
|  | ||||
| 	private MainWindowController mainWindowController; | ||||
| 	private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; // der Pfad der Datenbank-Datei | ||||
| 	private List<String> filmsdb = new ArrayList<String>(); | ||||
| 	private List<String> filmsAll = new ArrayList<String>(); | ||||
| 	private List<String> filmsDir = new ArrayList<String>(); | ||||
| 	private List<String> filmsStream = new ArrayList<String>(); | ||||
| 	private List<Integer> counter = new ArrayList<Integer>(); | ||||
| 	Connection connection = null; | ||||
|  | ||||
| 	public void main() { | ||||
| @ -39,8 +45,8 @@ public class DBController { | ||||
| 			// Statement statement = connection.createStatement(); | ||||
| 			// statement.setQueryTimeout(30); // set timeout to 30 sec. TODO don't know wath to do with this | ||||
|  | ||||
| 			connection.setAutoCommit(false);	//Autocommit to false -> manual commit is active! | ||||
| 			fuelleDatenbank(); | ||||
| 			connection.setAutoCommit(false);	//Autocommit to false -> manual commit is active | ||||
| //			fuelleDatenbank(); | ||||
| 		} catch (SQLException e) { | ||||
| 			// if the error message is "out of memory", it probably means no database file is found | ||||
| 			System.err.println(e.getMessage()); | ||||
| @ -56,72 +62,239 @@ public class DBController { | ||||
| //		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void fuelleDatenbank() {  | ||||
|  | ||||
| 		try {  | ||||
| 			System.out.println("Erstelle Eintr<74>ge local"); | ||||
| 	void createDatabase() {  | ||||
| 		System.out.println("<=====starting loading sql=====>"); | ||||
| 		 | ||||
| 		PreparedStatement ps; | ||||
| 		PreparedStatement psS;	 | ||||
| 		String[] entries = new File(mainWindowController.getPath()).list(); | ||||
| 	 | ||||
| 		try { | ||||
| 			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 | ||||
| 			stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl)"); | ||||
| 			stmt.executeUpdate("create table if not exists film_streaming (year, season, episode, rating, resolution, titel, streamUrl)"); | ||||
| 			stmt.close(); | ||||
| 		} catch (SQLException e1) { | ||||
| 			e1.printStackTrace(); | ||||
| 		}  | ||||
| 			 | ||||
| 			try {  | ||||
| 				Statement stmt = connection.createStatement();  | ||||
| 				ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");  | ||||
| 				while (rs.next()) {  | ||||
| 					filmsdb.add(rs.getString(2)); | ||||
| 				} | ||||
| 				stmt.close(); | ||||
| 				rs.close(); | ||||
|  | ||||
|  | ||||
| 			PreparedStatement ps = connection.prepareStatement("insert into film_local values (?, ?, ?)"); // SQL Befehl | ||||
| 			PreparedStatement psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)"); // SQL Befehl | ||||
|  | ||||
| 			String[] entries = new File(mainWindowController.getPath()).list(); | ||||
|  | ||||
| 			for(int i=0;i!=entries.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(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 | ||||
| 				rs = stmt.executeQuery("SELECT * FROM film_streaming;");  | ||||
| 				while (rs.next()) {  | ||||
| 					filmsdb.add(rs.getString(6)); | ||||
| 				} | ||||
| 				stmt.close(); | ||||
| 				rs.close(); | ||||
| 			}catch (SQLException ea){ | ||||
| 				//TODO | ||||
| 			} | ||||
| 			 | ||||
| 			 | ||||
| 			System.out.println("Erstelle Eintr<74>ge streaming \n"); | ||||
| 			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(); | ||||
| 				 | ||||
| 			System.out.println("filme in db: "+filmsdb.size()); | ||||
| 				 | ||||
| 			for(int i=0;i!=entries.length;i++){ | ||||
| 				filmsDir.add(cutOffEnd(entries[i])); | ||||
| 			} | ||||
| 				 | ||||
| 			for(int v=0; v< mainWindowController.streamingData.size(); v++){ | ||||
| 				String fileName = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(v).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 | ||||
| 						filmsStream.add(item.asObject().getString("titel","")); | ||||
| 					} | ||||
| 				} catch (IOException e) { | ||||
| 					//Auto-generated catch block | ||||
| 					e.printStackTrace(); | ||||
| 				} | ||||
| 				}		 | ||||
| 			filmsAll.addAll(filmsDir); | ||||
| 			filmsAll.addAll(filmsStream); | ||||
| 			System.out.println("films in directory: "+filmsAll.size()); | ||||
|  | ||||
| 				 | ||||
| 				if(filmsdb.size() == 0){ | ||||
| 					System.out.println("creating entries ..."); | ||||
| 					 | ||||
| 					try{ | ||||
| 						ps = connection.prepareStatement("insert into film_local values (?, ?, ?)"); | ||||
| 						psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)"); | ||||
| 					 | ||||
| 						for(int j=0;j!=entries.length;j++) // Geht alle Dateien im Verzeichniss durch | ||||
| 						{ | ||||
| 							ps.setInt(1, 0); // definiert Bewertung als Integer in der dritten Spalte | ||||
| 							ps.setString(2, cutOffEnd(entries[j])); // definiert Name als String in der ersten Spalte | ||||
| 							ps.setString(3,entries[j]); // definiert Pfad als String in der zweiten Spalte | ||||
| 							ps.addBatch(); // f<>gt den Eintrag hinzu | ||||
| 						} | ||||
| 					 | ||||
| 						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 fileNamea = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(i).getStreamUrl(); | ||||
| 							try { | ||||
| 								JsonObject object = Json.parse(new FileReader(fileNamea)).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) { | ||||
| 								e.printStackTrace(); | ||||
| 							} | ||||
| 						} | ||||
| 						} | ||||
| 						ps.executeBatch();  // scheibt alle Eintr<74>ge in die Datenbank | ||||
| 						psS.executeBatch();			 | ||||
| 						connection.commit(); | ||||
| 						ps.close(); | ||||
| 						psS.close(); | ||||
| 					}catch (SQLException ea) {  | ||||
| 						System.err.println("Konnte nicht ausgef<65>hrt werden");  | ||||
| 						ea.printStackTrace();  | ||||
| 					} | ||||
| 				}else if(filmsdb.size() == filmsAll.size()){ | ||||
| 					for(int i=0;i<filmsAll.size();i++){ | ||||
| 						if(filmsAll.contains(filmsdb.get(i))){ | ||||
| 						}else{		//calls updateDB if there is a different name between db and dir | ||||
| 							int l=0; | ||||
| 							try { | ||||
| 								Statement stmt = connection.createStatement();  | ||||
| 								ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); | ||||
| 								while (rs.next()) {  | ||||
| 									if(filmsDir.contains(rs.getString(2))){ | ||||
| 										l++; | ||||
| 										System.out.println("gleich L"+l); | ||||
| 									}else{ | ||||
| 										l++; | ||||
| 										counter.add(l); | ||||
| 										System.out.println("ungleich L"); | ||||
| 									} | ||||
| 								} | ||||
| 								stmt.close(); | ||||
| 								rs.close(); | ||||
| 								 | ||||
| 								rs = stmt.executeQuery("SELECT * FROM film_streaming;");  | ||||
| 								while (rs.next()) {  | ||||
| 									if(filmsStream.contains(rs.getString(6))){ | ||||
| 										l++; | ||||
| 										System.out.println("gleich S"+l); | ||||
| 									}else{ | ||||
| 										l++; | ||||
| 										counter.add(l); | ||||
| 										System.out.println("ungleich S"); | ||||
| 									} | ||||
| 								} | ||||
| 								stmt.close(); | ||||
| 								rs.close(); | ||||
| 								System.out.println(counter); | ||||
| 								updateDB(); | ||||
| 							} catch (SQLException e1) { | ||||
| 								e1.printStackTrace(); | ||||
| 							}  | ||||
| 						} | ||||
| 					} | ||||
| 				}else{ | ||||
| 					addEntry();	//TODO calls updateDB if there is a different size between db and dir | ||||
| 				} | ||||
| 	} | ||||
| 	 | ||||
| 	//loading data from database to mainWindowController  | ||||
| 	void loadData(){ | ||||
| 		System.out.println("loading data to mwc ...");  | ||||
| 		try {  | ||||
| 			//load local Data | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");  | ||||
| 			while (rs.next()) { | ||||
| 				mainWindowController.newDaten.add(new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3))); | ||||
| 			} | ||||
| 			stmt.close(); | ||||
| 			rs.close(); | ||||
| 			 | ||||
| 			//load streaming Data TODO check if there are streaming data before loading -> maybe there is an issue now | ||||
| 			rs = stmt.executeQuery("SELECT * FROM film_streaming;");  | ||||
| 			while (rs.next()) { | ||||
| 				mainWindowController.streamData.add(new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7))); | ||||
| 			} | ||||
| //			connection.setAutoCommit(false);  | ||||
| 			ps.executeBatch();  // scheibt alle Eintr<74>ge in die Datenbank | ||||
| 			psS.executeBatch();			 | ||||
| 			connection.commit(); | ||||
| 			ps.close(); | ||||
| 			psS.close(); | ||||
| 			//connection.close();  | ||||
| 		} catch (SQLException ea) {  | ||||
| 			System.err.println("Konnte nicht ausgef<65>hrt werden");  | ||||
| 			ea.printStackTrace();  | ||||
| 			stmt.close(); | ||||
| 			rs.close(); 		 | ||||
| 		} catch (SQLException e) {  | ||||
| 			System.err.println("Ups! an error occured!");  | ||||
| 			e.printStackTrace();  | ||||
| 		} | ||||
| 		System.out.println("<=====finished loading sql=====>");  | ||||
| 	} | ||||
| 	 | ||||
| 	//refreshs the data in mainWindowController.newDaten and mainWindowController.streamData | ||||
| 	void refresh(String name,int i) throws SQLException{ | ||||
| 		System.out.println("refresh ..."); | ||||
| 		Statement stmt; | ||||
| 		try { | ||||
| 			stmt = connection.createStatement(); | ||||
| 			ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" ); | ||||
| 			mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3))); | ||||
| 			stmt.close(); | ||||
| 			rs.close(); | ||||
| 		} catch (SQLException e) { | ||||
| 			try { | ||||
| 				stmt = connection.createStatement(); | ||||
| 				ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" ); | ||||
| 				mainWindowController.streamData.set(i,new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7))); | ||||
| 				stmt.close(); | ||||
| 				rs.close(); | ||||
| 			} catch (SQLException e1) { | ||||
| 				System.err.println("Ups! an error occured!");  | ||||
| 				e1.printStackTrace();  | ||||
| 			}  | ||||
| 		}  | ||||
| 	} | ||||
| 	 | ||||
| 	public void ausgeben(){ | ||||
| 	private void updateDB(){ | ||||
| 		System.out.println("updating DB ..."); | ||||
| 		for(int i=0; i<counter.size();i++){ | ||||
| 			String ending = ""; | ||||
| 			try{ | ||||
| 				 | ||||
| 				Statement stmt = connection.createStatement();  | ||||
| 				ResultSet rs = stmt.executeQuery("SELECT streamUrl FROM film_local WHERE titel='"+filmsdb.get(counter.get(i)-1)+"';");  | ||||
| 				while (rs.next()) { | ||||
| 					ending=rs.getString(1); | ||||
| 					int pos = ending.lastIndexOf("."); | ||||
| 					ending = ending.substring(pos); | ||||
| 					System.out.println(pos); | ||||
| 					System.out.println(ending); | ||||
| 				} | ||||
| 				 | ||||
| 				stmt.executeUpdate("UPDATE film_local SET titel='"+filmsAll.get(counter.get(i)-1)+"', streamUrl='"+filmsAll.get(counter.get(i)-1)+ending+"' WHERE titel='"+filmsdb.get(counter.get(i)-1)+"';"); | ||||
| 				connection.commit(); | ||||
| 				stmt.close(); | ||||
| 			}catch(SQLException e){ | ||||
| 				System.out.println("Ups! an error occured!"); | ||||
| 				e.printStackTrace(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	private void addEntry(){ | ||||
| 		System.out.println("adding entry to DB ..."); | ||||
| 	} | ||||
| 	 | ||||
| 	void ausgeben(){ | ||||
| 	System.out.println("Eintr<EFBFBD>ge ausgeben ... \n");  | ||||
| 	try {  | ||||
| 		Statement stmt = connection.createStatement();  | ||||
| @ -136,89 +309,86 @@ public class DBController { | ||||
| 		 | ||||
| 		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"); | ||||
| 		rs = stmt.executeQuery("SELECT * FROM film_streaming;");  | ||||
| 		while (rs.next()) {  | ||||
| 			System.out.println(rs.getString(1)); | ||||
| 			System.out.println(rs.getString(2)); | ||||
| 			System.out.println(rs.getString(3)); | ||||
| 			System.out.println(rs.getString(4)); | ||||
| 			System.out.println(rs.getString(5)); | ||||
| 			System.out.println(rs.getString(6)); | ||||
| 			System.out.println(rs.getString(7)+"\n"); | ||||
| 		} | ||||
| 		stmt.close(); | ||||
| 		rsS.close();  | ||||
| 		rs.close();  | ||||
|  | ||||
| 	} catch (SQLException e) {  | ||||
| 		System.err.println("Konnte nicht ausgef<65>hrt werden");  | ||||
| 		e.printStackTrace();  | ||||
| 	} | ||||
|     mainWindowController.ta1.setText("Hallo"); | ||||
| } | ||||
| 	 | ||||
| //gibt die Favorisierung eines bestimmten Films | ||||
| 	public void getFavStatus(String name){ | ||||
| 	//gibt die Favorisierung eines bestimmten Films | ||||
| 	void getFavStatus(String name){ | ||||
| 		try{ | ||||
| 			Statement stmta = connection.createStatement();  | ||||
| 			ResultSet rs = stmta.executeQuery("SELECT titel, rating FROM film_local WHERE titel = '"+name+"';" ); //SQL Befehl | ||||
| 			System.out.println("local:"+rs.getString("rating")); | ||||
| 			stmta.close(); | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			ResultSet rs = stmt.executeQuery("SELECT titel, rating FROM film_local WHERE titel = '"+name+"';" ); //SQL Befehl | ||||
| 			System.out.println("local:"+rs.getString("rating")+", "+rs.getString("titel")); | ||||
| 			stmt.close(); | ||||
| 			rs.close(); | ||||
| 		}catch(SQLException e){ | ||||
| 			 | ||||
| 			try { | ||||
| 				System.out.println("streaming"); | ||||
| 				Statement stmtSa = connection.createStatement();  | ||||
| 				ResultSet rsS = stmtSa.executeQuery("SELECT titel, rating FROM film_streaming WHERE titel = '"+name+"';" ); | ||||
| 				System.out.println("streaming:"+rsS.getString("rating")); | ||||
| 				stmtSa.close(); | ||||
| 				Statement stmtS = connection.createStatement();  | ||||
| 				ResultSet rsS = stmtS.executeQuery("SELECT titel, rating FROM film_streaming WHERE titel = '"+name+"';" ); | ||||
| 				System.out.println("streaming:"+rsS.getString("rating")+", "+rsS.getString("titel")); | ||||
| 				stmtS.close(); | ||||
| 				rsS.close(); | ||||
| 			} catch (SQLException e1) { | ||||
| //				System.out.println("Ups! an error occured!"); | ||||
| 				System.out.println("Ups! an error occured!"); | ||||
| 				e1.printStackTrace(); | ||||
| 			} | ||||
| 			 | ||||
| 			 | ||||
| //			System.out.println("Ups! an error occured!"); | ||||
| //			e.printStackTrace(); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| //setzt die Defavorisierung eines bestimmten Films | ||||
| 	public void defavorisieren(String name){ | ||||
| 	//setzt die Defavorisierung eines bestimmten Films | ||||
| 	void dislike(String name){ | ||||
| 		System.out.println("defavorisieren ...");		 | ||||
| 		try{ | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			stmt.executeUpdate("UPDATE film_local SET rating=0 WHERE titel='"+name+"';"); | ||||
| 			connection.commit(); | ||||
| 			stmt.close(); | ||||
| 		}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+"';"); | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			stmt.executeUpdate("UPDATE film_streaming SET rating=0 WHERE titel='"+name+"';"); | ||||
| 			connection.commit(); | ||||
| 			stmt.close(); | ||||
| 		} catch (SQLException e1) { | ||||
| 			System.out.println("Ups! an error occured!"); | ||||
| 			e1.printStackTrace(); | ||||
| 		} | ||||
| 	} | ||||
| //setzt die Favorisierung eines bestimmten Films | ||||
| 	public void favorisieren(String name){ | ||||
| 	//setzt die Favorisierung eines bestimmten Films | ||||
| 	void like(String name){ | ||||
| 		System.out.println("favorisieren ..."); | ||||
| 		try{ | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			stmt.executeUpdate("UPDATE film_local SET rating=1 WHERE titel='"+name+"';"); | ||||
| 			connection.commit(); | ||||
| 			stmt.close(); | ||||
| 		}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+"';"); | ||||
| 			Statement stmt = connection.createStatement();  | ||||
| 			stmt.executeUpdate("UPDATE film_streaming SET rating=1 WHERE titel='"+name+"';"); | ||||
| 			connection.commit(); | ||||
| 			stmt.close(); | ||||
| 		} catch (SQLException e1) { | ||||
| 			System.out.println("Ups! an error occured!"); | ||||
| 			e1.printStackTrace(); | ||||
| @ -226,7 +396,7 @@ public class DBController { | ||||
| 	} | ||||
| 	 | ||||
| //entfernt die Endung | ||||
| 	private String ohneEndung (String str) { | ||||
| 	private String cutOffEnd (String str) { | ||||
|  | ||||
| 		if (str == null) return null; | ||||
| 		int pos = str.lastIndexOf("."); | ||||
|  | ||||
| @ -20,7 +20,9 @@ | ||||
|  *  | ||||
|  */ | ||||
| package application; | ||||
| 	 | ||||
| /** | ||||
|  * TODO OSX and	Linux directory and file (Linux: 99% not working!) | ||||
|  */ | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.IOException; | ||||
| @ -50,8 +52,8 @@ public class Main extends Application { | ||||
| 	private String mode = "local";	//local or streaming | ||||
| 	private double size = 12; | ||||
| 	private int local = 0; | ||||
| 	private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");	//Windows: C:/Users/"User"/Documents/HomeFlix	OSX: has to be tested	Linux: has to be tested(shalt not work!) | ||||
| 	private File file = new File(dir + "/config.xml");	//Windows: C:/Users/"User"/Documents/HomeFlix/config.xml	OSX: has to be tested	Linux: has to be tested(shalt not work!) | ||||
| 	private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");	//Windows: C:/Users/"User"/Documents/HomeFlix	OSX: not tested yet	Linux: not tested yet(shalt not work!) | ||||
| 	private File file = new File(dir + "/config.xml");	//Windows: C:/Users/"User"/Documents/HomeFlix/config.xml	OSX: not tested yet	Linux: not tested yet(shalt not work!) | ||||
| 	Properties props = new Properties(); | ||||
| 	private MainWindowController mainWindowController; | ||||
| 	 | ||||
| @ -70,13 +72,13 @@ public class Main extends Application { | ||||
| 		primaryStage.setMinWidth(900.00); | ||||
| 		primaryStage.setResizable(false); | ||||
| 		primaryStage.setTitle("Project HomeFlix"); | ||||
| 		primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //f<EFBFBD>gt Anwendungsicon hinzu | ||||
| 		primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //adds application icon | ||||
|  | ||||
| 		mainWindowController = loader.getController();	//verkn<EFBFBD>pfung von FXMLController und Controller Klasse | ||||
| 		mainWindowController.setAutoUpdate(autoUpdate);	//setzt autoupdate | ||||
| 		mainWindowController.setMain(this);	//aufruf setMain | ||||
| 		mainWindowController = loader.getController();	//Link of FXMLController and controller class | ||||
| 		mainWindowController.setAutoUpdate(autoUpdate);	//set autoupdate | ||||
| 		mainWindowController.setMain(this);	//call setMain | ||||
| 		 | ||||
| 		//dir exists -> check config.xml 	TODO nur Windows getestet siehe dir und file | ||||
| 		//dir exists -> check config.xml | ||||
| 		if(dir.exists() == true){ | ||||
| 			if (file.exists() != true) { | ||||
| 				mainWindowController.setPath(firstStart()); | ||||
| @ -105,26 +107,31 @@ public class Main extends Application { | ||||
| 		Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar");	//start again (preventing Bugs) | ||||
| 		System.exit(0);	//finishes itself | ||||
| 		} | ||||
| //		mainWindowController.loadStreamingSettings(); | ||||
| 		mainWindowController.applyColor();	//setzt die Theme Farbe | ||||
| 		mainWindowController.cbLocal.getSelectionModel().select(mainWindowController.getLocal()); //setzt local | ||||
| 		 | ||||
| 		mainWindowController.loadStreamingSettings(); | ||||
| 		mainWindowController.applyColor();	//set theme color | ||||
| 		mainWindowController.cbLocal.getSelectionModel().select(mainWindowController.getLocal()); //set local | ||||
| 		mainWindowController.mainColor.setValue(Color.valueOf(mainWindowController.getColor())); | ||||
| 		mainWindowController.loadData();	//l<>d die Daten im Controller | ||||
| 		 | ||||
| 		mainWindowController.dbController.main(); //initialize database controller | ||||
| 		mainWindowController.dbController.createDatabase(); //creating the database | ||||
| 		mainWindowController.dbController.loadData(); 	//loading data from database to mainWindowController  | ||||
| 		 | ||||
| //		mainWindowController.loadData();	//l<>d die Daten im Controller | ||||
| 		mainWindowController.addDataUI(); | ||||
| 		 | ||||
| 		Scene scene = new Scene(pane);	//neue Scen um inhalt der stage anzuzeigen | ||||
| 		Scene scene = new Scene(pane);	//create new scene, append pane to scene | ||||
| 		 | ||||
| 		primaryStage.setScene(scene); | ||||
| 		primaryStage.show();	//zeige scene | ||||
| 		primaryStage.setScene(scene);	//append scene to stage | ||||
| 		primaryStage.show();	//show stage | ||||
| 		} catch (IOException e) { | ||||
| 			// Auto-generated catch block | ||||
| 			e.printStackTrace(); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	//methode f<>r den erstmaligen Start | ||||
| 	private String firstStart(){ | ||||
| 		Alert alert = new Alert(AlertType.CONFIRMATION);	//neuer alert mit filechooser | ||||
| 		Alert alert = new Alert(AlertType.CONFIRMATION);	//new alert with filechooser | ||||
| 		alert.setTitle("Project HomeFlix"); | ||||
| 		alert.setHeaderText("Es ist kein Stammverzeichniss f<>r Filme angegeben!");	//TODO translate | ||||
| 		alert.setContentText("Stammverzeichniss angeben?"); | ||||
|  | ||||
| @ -26,7 +26,6 @@ import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | ||||
| import java.io.FileReader; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | ||||
| @ -36,16 +35,13 @@ import java.io.StringWriter; | ||||
| import java.math.BigInteger; | ||||
| import java.net.URI; | ||||
| import java.net.URISyntaxException; | ||||
| import java.sql.SQLException; | ||||
| import java.util.Locale; | ||||
| import java.util.Properties; | ||||
| import java.util.ResourceBundle; | ||||
|  | ||||
| import org.apache.commons.lang3.SystemUtils; | ||||
|  | ||||
| import com.eclipsesource.json.Json; | ||||
| import com.eclipsesource.json.JsonArray; | ||||
| import com.eclipsesource.json.JsonObject; | ||||
| import com.eclipsesource.json.JsonValue; | ||||
| import com.jfoenix.controls.JFXButton; | ||||
| import com.jfoenix.controls.JFXColorPicker; | ||||
| import com.jfoenix.controls.JFXDialog; | ||||
| @ -63,11 +59,15 @@ import javafx.beans.value.ChangeListener; | ||||
| import javafx.beans.value.ObservableValue; | ||||
| import javafx.collections.FXCollections; | ||||
| import javafx.collections.ObservableList; | ||||
| import javafx.event.ActionEvent; | ||||
| import javafx.event.EventHandler; | ||||
| import javafx.fxml.FXML; | ||||
| import javafx.scene.control.Alert; | ||||
| import javafx.scene.control.Alert.AlertType; | ||||
| import javafx.scene.control.ChoiceBox; | ||||
| import javafx.scene.control.ContextMenu; | ||||
| import javafx.scene.control.Label; | ||||
| import javafx.scene.control.MenuItem; | ||||
| import javafx.scene.control.TableColumn; | ||||
| import javafx.scene.control.TableView; | ||||
| import javafx.scene.control.TextArea; | ||||
| @ -211,7 +211,9 @@ public class MainWindowController { | ||||
| 	private String Name; | ||||
| 	private String datPath; | ||||
| 	private String autoUpdate; | ||||
| 	private String mode;	 | ||||
| 	private String mode; | ||||
| 	@SuppressWarnings("unused") | ||||
| 	private String ratingSortType; | ||||
| 	String title; | ||||
| 	String year; | ||||
| 	String rating; | ||||
| @ -237,10 +239,10 @@ public class MainWindowController { | ||||
| 	private File selectedStreamingFolder; | ||||
| 	ResourceBundle bundle; | ||||
|  | ||||
| 	private ObservableList<streamUiData> newDaten = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<streamUiData> filterData = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<streamUiData> streamData = FXCollections.observableArrayList(); | ||||
| 	private ObservableList<String> locals = FXCollections.observableArrayList("english", "deutsch"); | ||||
| 	ObservableList<streamUiData> newDaten = FXCollections.observableArrayList(); | ||||
| 	ObservableList<streamUiData> streamData = FXCollections.observableArrayList(); | ||||
| 	ObservableList<streamUiData> 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")); | ||||
| @ -251,11 +253,14 @@ public class MainWindowController { | ||||
| 	private ImageView play_arrow_white = new ImageView(new Image("recources/icons/ic_play_arrow_white_18dp_1x.png")); | ||||
| 	private ImageView play_arrow_black = new ImageView(new Image("recources/icons/ic_play_arrow_black_18dp_1x.png")); | ||||
| 	private DirectoryChooser directoryChooser = new DirectoryChooser(); | ||||
| 	private ContextMenu menu = new ContextMenu(); | ||||
|     private MenuItem like = new MenuItem("like"); | ||||
|     private MenuItem dislike = new MenuItem("dislike");	//TODO one option (like or dislike) | ||||
| 	Properties props = new Properties(); | ||||
| 	 | ||||
| 	private updater Updater; | ||||
| 	private apiQuery ApiQuery; | ||||
| 	private DBController dbController; | ||||
| 	DBController dbController; | ||||
| 	 | ||||
| 	//wenn menubtn clicked | ||||
| 	/** | ||||
| @ -427,12 +432,13 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	@FXML | ||||
| 	private void debugBtnclicked(){ | ||||
| //		dbController.ausgeben(); | ||||
| 		dbController.getFavStatus("Zootopia"); | ||||
| 		dbController.favorisieren("Zootopia"); | ||||
| 		dbController.getFavStatus("Zootopia"); | ||||
| 		dbController.defavorisieren("Zootopia"); | ||||
| 		dbController.getFavStatus("Zootopia"); | ||||
| 		System.out.println(columnRating.getSortType()); | ||||
| //		System.out.println(newDaten.get(selected).getTitel()+","+newDaten.get(selected).getRating()); | ||||
| //		dbController.getFavStatus("Zootopia"); | ||||
| //		dbController.like("Zootopia"); | ||||
| //		dbController.getFavStatus("House of Cards"); | ||||
| //		dbController.dislike("Zootopia"); | ||||
| //		dbController.getFavStatus("Zootopia"); | ||||
| 		//for testing | ||||
| 	} | ||||
|  | ||||
| @ -510,19 +516,21 @@ public class MainWindowController { | ||||
| 	 | ||||
| 	//"Main" Methode die beim start von der Klasse Main aufgerufen wird, initialiesirung der einzellnen UI-Objekte  | ||||
| 	public void setMain(Main main) { | ||||
| 		Updater = new updater(this); | ||||
| 		ApiQuery = new apiQuery(this); | ||||
| 		dbController = new DBController(this); | ||||
| 		 | ||||
| 		loadSettings(); | ||||
| 		initTabel(); | ||||
| 		initActions(); | ||||
| 		 | ||||
| 		Updater = new updater(this); | ||||
| 		ApiQuery = new apiQuery(this); | ||||
| 		dbController = new DBController(this); | ||||
| 		 | ||||
| 		System.out.println("Mode: "+mode);	//TODO debugging | ||||
| 		 | ||||
| 		loadStreamingSettings(); | ||||
| 		dbController.main(); | ||||
|  | ||||
| //		if(ratingSortType == "DESCENDING"){	//TODO not fully implemented yet | ||||
| //			columnRating.setSortType(TreeTableColumn.SortType.DESCENDING); | ||||
| //		}else{ | ||||
| //			columnRating.setSortType(TreeTableColumn.SortType.ASCENDING); | ||||
| //		} | ||||
| 		 | ||||
| 		debugBtn.setDisable(false); 	//debugging btn for tests | ||||
| 		debugBtn.setVisible(true); | ||||
| @ -532,6 +540,7 @@ public class MainWindowController { | ||||
|         sliderFontSize.setValue(getSize()); | ||||
|          | ||||
|         cbLocal.setItems(locals); | ||||
|         menu.getItems().addAll(like,dislike); | ||||
|          | ||||
|         updateBtn.setFont(Font.font("System", 12)); | ||||
|          | ||||
| @ -544,7 +553,7 @@ public class MainWindowController { | ||||
|  | ||||
|     	ta1.setWrapText(true); | ||||
|     	ta1.setEditable(false); | ||||
|     	ta1.setFont(Font.font("System", getSize())); | ||||
|     	ta1.setFont(Font.font("System", getSize()));	 | ||||
| 	} | ||||
| 	 | ||||
| 	//initialisierung der Tabellen f<>r filme(beide Modi) und Streaming-Settings | ||||
| @ -603,6 +612,9 @@ public class MainWindowController { | ||||
| 			} | ||||
| 		}); | ||||
| 	     | ||||
| 	    //context menu for treetableview   | ||||
| 	    treeTableViewfilm.setContextMenu(menu); | ||||
|  | ||||
| 	    //Streaming-Settings Tabelle | ||||
| 	    dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titelProperty()); | ||||
| 	    dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty()); | ||||
| @ -611,13 +623,13 @@ public class MainWindowController { | ||||
| 	    tableViewStreamingdata.setItems(streamingData); | ||||
| 	} | ||||
| 	 | ||||
| 	//initialisierung der Button Actions | ||||
| 	//Initializing the actions | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	private void initActions(){ | ||||
| 		 | ||||
| 		//TODO unterscheiden zwischen streaming und local | ||||
|         tfsearch.textProperty().addListener(new ChangeListener<String>() { | ||||
|     	    @SuppressWarnings("unchecked") | ||||
| 			@Override | ||||
|     	    @Override | ||||
|     	    public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) { | ||||
|     	    	int counter = newDaten.size(); | ||||
|     	    	filterData.removeAll(filterData); | ||||
| @ -652,56 +664,90 @@ public class MainWindowController { | ||||
| 				saveSettings(); | ||||
| 			 } | ||||
|         }); | ||||
|          | ||||
|         like.setOnAction(new EventHandler<ActionEvent>() { | ||||
|             @Override | ||||
|             public void handle(ActionEvent event) { | ||||
| 				dbController.like(Name); | ||||
| 				dbController.getFavStatus(Name); | ||||
| 				try { | ||||
| 					dbController.refresh(Name, selected); | ||||
| 				} catch (SQLException e) { | ||||
| 					// TODO Auto-generated catch block error msg | ||||
| 					e.printStackTrace(); | ||||
| 				} | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 	    	}); | ||||
|          | ||||
|         dislike.setOnAction(new EventHandler<ActionEvent>() { | ||||
|             @Override | ||||
|             public void handle(ActionEvent event) { | ||||
| 				dbController.dislike(Name); | ||||
| 				dbController.getFavStatus(Name); | ||||
| 				try { | ||||
| 					dbController.refresh(Name, selected); | ||||
| 				} catch (SQLException e) { | ||||
| 					// TODO Auto-generated catch block error msg | ||||
| 					e.printStackTrace(); | ||||
| 				} | ||||
| 				refreshTable(); | ||||
| 			} | ||||
| 	    	}); | ||||
| 	} | ||||
| 	 | ||||
| 	private void refreshTable(){ | ||||
| 		root.getChildren().set(selected, new TreeItem<streamUiData>(newDaten.get(selected))); | ||||
| 	} | ||||
| 	 | ||||
| 	//l<>dt die Daten im angegeben Ordner in newDaten | ||||
| 	void loadData(){ | ||||
| 			//load local Data | ||||
| 			if(getPath().equals("")||getPath().equals(null)){ | ||||
| 				System.out.println("Kein Pfad angegeben");	//falls der Pfad null oder "" ist | ||||
| 			}else{ | ||||
| 			String[] entries = new File(getPath()).list(); | ||||
| 				for(int i = 0; i < entries.length; i++){ | ||||
| 					String titel = ohneEndung(entries[i]); | ||||
| 					String data = entries[i]; | ||||
| 					newDaten.add(new streamUiData(1, 1, 1, 5.0, "1", titel, data)); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			//load streaming Data TODO pr<70>fen ob streaming daten vorhanden -> momentan evtl. fehler | ||||
| 			String titel = null; | ||||
|         	String resolution = null; | ||||
|         	String streamUrl = null;   | ||||
|         	int season; | ||||
|         	int episode; | ||||
|         	int year; | ||||
|         	double rating = 5.0; | ||||
|         	if(getStreamingPath().equals("")||getStreamingPath().equals(null)){ | ||||
| 				System.out.println("Kein Pfad angegeben");	//falls der Pfad null oder "" ist | ||||
| 			}else{ | ||||
| 			for(int i=0; i< streamingData.size(); i++){ | ||||
| 				String fileName = streamingPath+"/"+streamingData.get(i).getStreamUrl(); | ||||
| 				try { | ||||
| 					JsonObject object = Json.parse(new FileReader(fileName)).asObject(); | ||||
| 					JsonArray items = object.get("entries").asArray(); | ||||
| 					 | ||||
| 	            	for (JsonValue item : items) { | ||||
| 	            	  titel = item.asObject().getString("titel",""); | ||||
| 	            	  season = item.asObject().getInt("season", 0); | ||||
| 	            	  episode = item.asObject().getInt("episode", 0); | ||||
| 	            	  year = item.asObject().getInt("year", 0); | ||||
| 	            	  resolution = item.asObject().getString("resolution", ""); | ||||
| 	            	  streamUrl = item.asObject().getString("streamUrl", ""); | ||||
| 	            	  streamData.add(new streamUiData(year, season, episode, rating, resolution, titel, streamUrl)); | ||||
| 	            	} | ||||
| 					 | ||||
| 				} catch (IOException e) { | ||||
| 					//Auto-generated catch block | ||||
| 					e.printStackTrace(); | ||||
| 				} | ||||
| 			} | ||||
| 			}	 | ||||
| 	} | ||||
| //	void loadData(){ | ||||
| //			//load local Data | ||||
| //			if(getPath().equals("")||getPath().equals(null)){ | ||||
| //				System.out.println("Kein Pfad angegeben");	//falls der Pfad null oder "" ist | ||||
| //			}else{ | ||||
| //			String[] entries = new File(getPath()).list(); | ||||
| //				for(int i = 0; i < entries.length; i++){ | ||||
| //					String titel = ohneEndung(entries[i]); | ||||
| //					String data = entries[i]; | ||||
| //					newDaten.add(new streamUiData(1, 1, 1, 5.0, "1", titel, data)); | ||||
| //				} | ||||
| //			} | ||||
| // | ||||
| //			//load streaming Data TODO pr<70>fen ob streaming daten vorhanden -> momentan evtl. fehler | ||||
| //			String titel = null; | ||||
| //        	String resolution = null; | ||||
| //        	String streamUrl = null;   | ||||
| //        	int season; | ||||
| //        	int episode; | ||||
| //        	int year; | ||||
| //        	double rating = 5.0; | ||||
| //        	if(getStreamingPath().equals("")||getStreamingPath().equals(null)){ | ||||
| //				System.out.println("Kein Pfad angegeben");	//falls der Pfad null oder "" ist | ||||
| //			}else{ | ||||
| //			for(int i=0; i< streamingData.size(); i++){ | ||||
| //				String fileName = streamingPath+"/"+streamingData.get(i).getStreamUrl(); | ||||
| //				try { | ||||
| //					JsonObject object = Json.parse(new FileReader(fileName)).asObject(); | ||||
| //					JsonArray items = object.get("entries").asArray(); | ||||
| //					 | ||||
| //	            	for (JsonValue item : items) { | ||||
| //	            	  titel = item.asObject().getString("titel",""); | ||||
| //	            	  season = item.asObject().getInt("season", 0); | ||||
| //	            	  episode = item.asObject().getInt("episode", 0); | ||||
| //	            	  year = item.asObject().getInt("year", 0); | ||||
| //	            	  resolution = item.asObject().getString("resolution", ""); | ||||
| //	            	  streamUrl = item.asObject().getString("streamUrl", ""); | ||||
| //	            	  streamData.add(new streamUiData(year, season, episode, rating, resolution, titel, streamUrl)); | ||||
| //	            	} | ||||
| //					 | ||||
| //				} catch (IOException e) { | ||||
| //					//Auto-generated catch block | ||||
| //					e.printStackTrace(); | ||||
| //				} | ||||
| //			} | ||||
| //			}	 | ||||
| //	} | ||||
| 	 | ||||
| 	void addDataUI(){ | ||||
| 		if(mode.equals("local")){ | ||||
| @ -731,7 +777,7 @@ public class MainWindowController { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	private void loadStreamingSettings(){ | ||||
| 	void loadStreamingSettings(){ | ||||
| 		if(getStreamingPath().equals("")||getStreamingPath().equals(null)){ | ||||
| 			System.out.println("Kein Pfad angegeben");	//falls der Pfad null oder "" ist | ||||
| 		}else{ | ||||
| @ -946,6 +992,7 @@ public class MainWindowController { | ||||
| 			props.setProperty("local", Integer.toString(getLocal())); | ||||
| 			props.setProperty("streamingPath", getStreamingPath()); | ||||
| 			props.setProperty("mode", getMode()); | ||||
| 			props.setProperty("ratingSortType", columnRating.getSortType().toString()); | ||||
| 			OutputStream outputStream = new FileOutputStream(file);	//new outputstream | ||||
| 			props.storeToXML(outputStream, "Project HomeFlix settings");	//writes new .xml | ||||
| 			outputStream.close(); | ||||
| @ -967,6 +1014,7 @@ public class MainWindowController { | ||||
| 			autoUpdate = props.getProperty("autoUpdate"); | ||||
| 			local = Integer.parseInt(props.getProperty("local")); | ||||
| 			mode = props.getProperty("mode"); | ||||
| 			ratingSortType = props.getProperty("ratingSortType"); | ||||
| 			inputStream.close(); | ||||
| 		} catch (IOException e) { | ||||
| //			showErrorMsg(errorLoad, e); //TODO das soll beim ersten start nicht erscheinen | ||||
|  | ||||
		Reference in New Issue
	
	Block a user