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