This commit is contained in:
Georg Reisinger 2021-05-31 21:48:16 +02:00
parent 7e9efc138c
commit d228a9bab3
7 changed files with 56 additions and 18 deletions

View File

@ -7,7 +7,6 @@ import tourplaner.object.Tour;
import tourplaner.ui.ProgressBar;
import java.io.*;
import java.sql.SQLException;
import java.util.ArrayList;
/**
@ -46,6 +45,8 @@ public class Exporter {
/**
* Führt den Imput aus: File holen, Daten in db erstellen
* @param progressBar Progressbar
* @param progressMax Progressbar Maximum
*/
public void doImport(ProgressBar progressBar, int progressMax) {
try {

View File

@ -32,6 +32,8 @@ public class Reporter {
/**
* Erstellt den Summary Report
* @param progressBar Progressbar
* @param maxLevel Progressbar Maximum
*/
public static void sumReport(ProgressBar progressBar, int maxLevel){
ArrayList<Tour> tours = TourPlaner.getAllTours(progressBar, maxLevel);

View File

@ -9,7 +9,6 @@ import tourplaner.ui.ProgressBar;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;
@ -30,6 +29,8 @@ public class TourPlaner{
/**
* Holt alle touren aus der DB
* @return Alle touren als ArrayList
* @param progressBar Progressbar
* @param maxLevel Progressbar Maximum
*/
public static ArrayList<Tour> getAllTours(ProgressBar progressBar, int maxLevel){
return new DbConnect().getAllTouren(progressBar, maxLevel);
@ -39,8 +40,8 @@ public class TourPlaner{
* Bearbeitet eine Tour
* @param oldname Alter Tourname
* @param tour Neuer Tourname
* @return false bei error
* @throws IOException Fehler beim editieren der Tour
* @throws DbErrorException Fehler beim editieren der Tour
* @throws DirectionMapException Fehler in der DirectionMap Abfrage
*/
public static void editTour(String oldname, Tour tour) throws DbErrorException, DirectionMapException {
ProgressBar progressBar = new ProgressBar("Edit...");
@ -59,6 +60,7 @@ public class TourPlaner{
/**
* Löscht eine Tour
* @param tourname Tourname
* @throws DbErrorException Fehler beim editieren der Tour
*/
public static void delTour(String tourname) throws DbErrorException {
FileHelper.delFile(new File(getImagePath(tourname)));
@ -70,7 +72,8 @@ public class TourPlaner{
* @param newTour Neue Tour
* @param progressBar Aktuelle Progressbar
* @param progressMax Maximale anzeige der Progress bar
* @throws IOException Fehler beim hinzufügen der Tour
* @throws DbErrorException Fehler beim editieren der Tour
* @throws DirectionMapException Fehler in der DirectionMap Abfrage
*/
public static void addTourMax(Tour newTour, ProgressBar progressBar, int progressMax) throws DbErrorException, DirectionMapException {
int step = progressBar.getProgressSize(2, progressMax);
@ -86,7 +89,8 @@ public class TourPlaner{
* Fügt eine Tour hinzu
* @param newTour Neue Tour
* @param progressBar Aktuelle Progressbar
* @throws IOException Fehler beim hinzufügen der Tour
* @throws DbErrorException Fehler beim editieren der Tour
* @throws DirectionMapException Fehler in der DirectionMap Abfrage
*/
public static void addTour(Tour newTour, ProgressBar progressBar) throws DbErrorException, DirectionMapException {
addTourMax(newTour, progressBar, 100);
@ -141,6 +145,7 @@ public class TourPlaner{
* Fügt ein Log hinzu
* @param tourname Name der Tour
* @param log Neues Log
* @throws DbErrorException Fehler beim editieren der Tour
*/
public static void addLog(String tourname, Log log) throws DbErrorException {
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
@ -151,6 +156,7 @@ public class TourPlaner{
* Löscht ein Log
* @param tourname Name der Tour
* @param id Id des Logs
* @throws DbErrorException Fehler beim editieren der Tour
*/
public static void delLog(String tourname, String id) throws DbErrorException {
new DbConnect().delLog(tourname, id);
@ -160,6 +166,7 @@ public class TourPlaner{
* Editiert ein Log
* @param tourname Name der Tour
* @param log Neues Log
* @throws DbErrorException Fehler beim editieren der Tour
*/
public static void editLog(String tourname, Log log) throws DbErrorException {
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
@ -169,6 +176,8 @@ public class TourPlaner{
/**
* Sucht alle touren die den gegebenen tournamen enthalten
* @param tourname Name der zu suchen ist
* @param progressBar Progressbar
* @param maxProgress Progressbar Maximum
* @return Alle touren die auf den Suchterm passen
*/
public static ArrayList<Tour> sucheTour(String tourname, ProgressBar progressBar, int maxProgress){

View File

@ -40,6 +40,7 @@ public class DbConnect {
* Bearbeitet eine Tour
* @param oldname Alter Tour name
* @param tour Neues Tour Object
* @throws DbErrorException Datenbank error
*/
public void editTour(String oldname, Tour tour) throws DbErrorException {
String tourname = tour.getName();
@ -70,7 +71,7 @@ public class DbConnect {
/**
* Fügt eine Tour hinzu
* @param tour Neue Tour
* @return false bei error
* @throws DbErrorException Db error
*/
public void addTour(Tour tour) throws DbErrorException {
try{
@ -83,6 +84,7 @@ public class DbConnect {
/**
* Löscht eine Tour anhand des Tournamens
* @param tourname Tourname der zu löschen ist
* @throws DbErrorException Db error
*/
public void delTour(String tourname) throws DbErrorException {
try {
@ -93,6 +95,11 @@ public class DbConnect {
}
}
/**
* Holt die Logs einer Tour
* @param tourname name der Tour
* @return Logs der Tour
*/
public ArrayList<Log> getLogs(String tourname){
this.c = PostgresHelper.con();
@ -135,8 +142,8 @@ public class DbConnect {
* Füght einen Logeintrag ein
* @param tourname Zu welcher Tour der Logeintrag gehört
* @param log Der Logeintrag
* @return false bei error
*/
* @throws DbErrorException DB Error
* */
public void addLog(String tourname, Log log) throws DbErrorException {
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
try{
@ -146,6 +153,12 @@ public class DbConnect {
}
}
/**
* Edit Log
* @param tourname Name der Tour
* @param log ID des logs
* @throws DbErrorException DB Error
*/
public void editLog(String tourname, Log log) throws DbErrorException {
try{
PostgresHelper.executeUpdateEditLog("UPDATE public.log SET bemerkung = ?, datum = ?, strecke = ?, avg = ?, hightmeter = ?, pause = ?, gegangen = ?, dauer = ?, rating = ? WHERE tourname = ? and id = ?", log.getBemerkung(),log.getDatum(),log.getStrecke(),log.getAvgspeed(),log.getHightmeter(),log.getPause(),log.getGegangen(),log.getDauer(),log.getRating(),tourname ,log.getId());
@ -154,6 +167,12 @@ public class DbConnect {
}
}
/**
* Del Log
* @param tourname Name der Tour
* @param id ID des Logs
* @throws DbErrorException DB Error
*/
public void delLog(String tourname, String id) throws DbErrorException {
try{
PostgresHelper.executeUpdateDelLog("DELETE FROM public.log WHERE tourname = ? and id = ?", tourname, id);
@ -162,6 +181,11 @@ public class DbConnect {
}
}
/**
* holt Die Tour größe
* @return Größe der Tour
* @throws DbErrorException DB Error
*/
private int getTourSize() throws DbErrorException {
Connection con = PostgresHelper.con();
try{

View File

@ -68,7 +68,6 @@ public class PostgresHelper {
* @param gegangen Gegangene Zeit des Logs
* @param dauer Dauer des Logs
* @param rating Rating des Logs
* @return false bei error
* @throws SQLException Sql error
*/
public static void executeUpdateAddLog(String content, String tourname, String id, String bemerkung, LocalDate datum, double strecke, double avgspeed, double hightmeter, double pause, double gegangen, double dauer, String rating) throws SQLException {
@ -103,7 +102,6 @@ public class PostgresHelper {
* @param rating Rating des Logs
* @param tourname Name der Tour des Logs
* @param id ID des Logs
* @return false bei error
* @throws SQLException Sql error
*/
public static void executeUpdateEditLog(String content, String bemerkung, LocalDate datum, double strecke, double avgspeed, double hightmeter, double pause, double gegangen, double dauer, String rating, String tourname, String id) throws SQLException {
@ -129,7 +127,6 @@ public class PostgresHelper {
* @param content Sql statement
* @param tourname Name der Tour
* @param id Id des logs
* @return false bei error
* @throws SQLException SQL error
*/
public static void executeUpdateDelLog(String content, String tourname, String id) throws SQLException {
@ -145,7 +142,6 @@ public class PostgresHelper {
* Führt sql statement aus, mit einem String
* @param content Sql Statement
* @param string String im statement
* @return false bei error
* @throws SQLException Sql error
*/
public static void executeUpdateString(String content, String string) throws SQLException {
@ -165,7 +161,6 @@ public class PostgresHelper {
* @param start Start der Tour
* @param ziel Ziel der Tour
* @param strecke Strecke der Tour
* @return false bei error
* @throws SQLException Sql error
*/
public static void executeUpdateAddTour(String content, String name, String dauer, String mapJson, String start, String ziel, double strecke) throws SQLException {
@ -191,7 +186,6 @@ public class PostgresHelper {
* @param ziel Ziel der Tour
* @param strecke Strecke der Tour
* @param oldname Alter Name der Tour
* @return false bei error
* @throws SQLException Sql error
*/
public static void executeUpdateEditTour(String content, String name, String mapJson, String start, String ziel, double strecke, String oldname) throws SQLException {

View File

@ -20,7 +20,6 @@ import tourplaner.viewmodels.ViewModel;
import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicInteger;

View File

@ -39,7 +39,8 @@ public class ViewModel {
/**
* Bearbeitet eine bereits bestehende Tour
* prüft ob eine tour ausgewählt ist
* @throws IOException Fehler beim editieren der Tour
* @throws DbErrorException Fehler beim editieren der Tour
* @throws DirectionMapException Fehler in der DirectionMap Abfrage
*/
public void editTour() throws DbErrorException, DirectionMapException {
if (this.selectedTour == null){
@ -194,6 +195,7 @@ public class ViewModel {
/**
* Bearbeitet einen gewählten Log eintrag
* @throws DbErrorException Fehler beim editieren der Tour
*/
@SuppressWarnings("UnusedAssignment")
public void editLog() throws DbErrorException {
@ -403,6 +405,7 @@ public class ViewModel {
/**
* Entfernt ein Log anhand des selectierten Logs
* @throws DbErrorException Fehler beim editieren der Tour
*/
public void delLog() throws DbErrorException {
if(this.selectedLog != null) {
@ -521,6 +524,8 @@ public class ViewModel {
/**
* Sucht eine Tour
* @param sucheInput Text nach dem gesucht werden soll
* @param progressBar ProgressBar
* @param maxProgress Maximaler Progress
*/
public void suche(String sucheInput, ProgressBar progressBar, int maxProgress){
if(sucheInput.isEmpty()){
@ -623,6 +628,7 @@ public class ViewModel {
/**
* Importiert alle daten von einem File das hier gewählt wird
* @return Die aktuelle Progressbar
* @param maxProgress Maximaler Progress
*/
public ProgressBar importData(int maxProgress) {
String file = AlertHelper.fileChooser("Importiere");
@ -651,6 +657,7 @@ public class ViewModel {
/**
* Kopiert einen Log eintrag und erstellt dafür eine neue Id für das kopierte log
* @throws DbErrorException DB Error
*/
public void copyLog() throws DbErrorException {
Log selectedLog = getSelectedLog();
@ -671,6 +678,8 @@ public class ViewModel {
/**
* Kopiert eie Tour und hängt dafür am ende des namens ein _copy an
* @param progressBar ProgressBar
* @param maxLevel Maximaler Progress
*/
public void copyTour(ProgressBar progressBar, int maxLevel) {
Tour selectedTour = getSelectedTour();