Report mit iText 4
This commit is contained in:
parent
0e43c28c67
commit
be2bb0c6fa
9
.idea/libraries/iText_4_2_0_com_itextpdf.xml
generated
Normal file
9
.idea/libraries/iText_4_2_0_com_itextpdf.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="iText-4.2.0-com.itextpdf">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/iText-4.2.0-com.itextpdf.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
11
.idea/libraries/org_postgresql_postgresql_42_2_19.xml
generated
Normal file
11
.idea/libraries/org_postgresql_postgresql_42_2_19.xml
generated
Normal file
@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="org.postgresql:postgresql:42.2.19" type="repository">
|
||||
<properties maven-id="org.postgresql:postgresql:42.2.19" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/postgresql/postgresql/42.2.19/postgresql-42.2.19.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
7
.idea/sqldialects.xml
generated
Normal file
7
.idea/sqldialects.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/tourplaner/data/PostgresHelper.java" dialect="GenericSQL" />
|
||||
<file url="PROJECT" dialect="PostgreSQL" />
|
||||
</component>
|
||||
</project>
|
@ -10,6 +10,7 @@
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
<orderEntry type="library" name="org.ini4j:ini4j:0.5.4" level="project" />
|
||||
<orderEntry type="library" name="log4j:log4j:1.2.17" level="project" />
|
||||
<orderEntry type="library" name="org.apache.pdfbox:pdfbox:1.8.9" level="project" />
|
||||
<orderEntry type="library" name="org.postgresql:postgresql:42.2.19" level="project" />
|
||||
<orderEntry type="library" name="iText-4.2.0-com.itextpdf" level="project" />
|
||||
</component>
|
||||
</module>
|
20
TourplanerTabellen.sql
Normal file
20
TourplanerTabellen.sql
Normal file
@ -0,0 +1,20 @@
|
||||
// Tour Tabelle
|
||||
|
||||
create table tour
|
||||
(
|
||||
tourname varchar not null,
|
||||
dauer decimal,
|
||||
mapjson varchar,
|
||||
start varchar,
|
||||
ziel varchar,
|
||||
strecke decimal
|
||||
);
|
||||
|
||||
create unique index tour_tourname_uindex
|
||||
on tour (tourname);
|
||||
|
||||
alter table tour add constraint tour_pk primary key (tourname);
|
||||
|
||||
#// Log Table
|
||||
|
||||
create table log(tourname varchar constraint log_tour_tourname_fk references tour,id varchar,bemerkung varchar,datum date,strecke decimal,avg decimal,hightmeter decimal,pause decimal,gegangen decimal,dauer decimal);
|
BIN
lib/iText-4.2.0-com.itextpdf.jar
Normal file
BIN
lib/iText-4.2.0-com.itextpdf.jar
Normal file
Binary file not shown.
@ -1,15 +1,171 @@
|
||||
2021-03-18 22:41:23 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:48:51 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:53:17 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:57:20 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:57:28 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:58:33 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 22:58:34 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 23:05:00 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 23:11:45 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 23:14:55 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-19 11:56:22 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-19 22:35:19 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-19 23:23:36 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-04-13 18:30:39 ERROR FileNotFoundException:33 - \report\test.pdf (Das System kann den angegebenen Pfad nicht finden)
|
||||
2021-04-13 18:31:11 ERROR FileNotFoundException:33 - \reports\test.pdf (Das System kann den angegebenen Pfad nicht finden)
|
||||
2021-04-15 00:36:26 ERROR FileNotFoundException:33 - D:\FH_OFFLINE\tourplaner\conf.ini (Das System kann die angegebene Datei nicht finden)
|
||||
2021-04-15 00:36:26 ERROR NullPointerException:33 -
|
||||
2021-04-15 00:37:18 ERROR FileNotFoundException:33 - D:\FH_OFFLINE\tourplaner\conf.ini (Das System kann die angegebene Datei nicht finden)
|
||||
2021-04-15 00:37:18 ERROR NullPointerException:33 -
|
||||
2021-04-15 00:38:24 ERROR PSQLException:33 - Der Verbindungsversuch schlug fehl.
|
||||
2021-04-15 00:38:31 ERROR SQLException:33 - No suitable driver found for jdbc:postgresql://http://postgres.dergeorg.at:5432/tourplaner
|
||||
2021-04-15 00:38:38 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 00:38:38 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 00:38:38 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 00:38:38 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 00:38:38 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 00:38:38 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 00:38:38 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 00:38:38 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 00:40:43 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 00:40:43 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 00:40:43 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 00:40:43 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 00:40:43 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 00:40:43 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 00:40:43 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 00:40:43 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 00:44:11 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 00:44:11 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 00:44:11 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 00:44:11 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 00:44:11 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 00:44:11 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 00:44:11 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 00:44:11 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 16:30:08 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 16:30:08 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 16:30:08 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 16:30:08 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 16:30:08 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 16:30:08 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 16:30:08 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 16:30:08 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 16:33:57 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 16:33:57 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 16:33:57 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 16:33:57 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 16:33:57 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 16:33:57 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 16:33:57 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 16:33:57 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 16:38:55 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 16:38:55 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 16:38:55 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 16:38:55 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 16:38:55 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 16:38:55 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 16:38:55 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 16:38:55 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 16:50:23 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 16:50:23 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 16:50:23 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 16:50:23 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 16:50:23 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 16:50:23 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 16:50:23 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 16:50:23 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 16:51:01 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 16:51:01 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 16:51:01 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 16:51:01 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 16:51:01 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 16:51:01 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 16:51:01 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 16:51:01 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:08:17 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:08:17 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:08:17 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:08:17 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:08:17 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:08:17 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:08:17 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:08:17 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:08:21 ERROR FileNotFoundException:33 - .\reports\Tour 1.pdf (Das System kann den angegebenen Pfad nicht finden)
|
||||
2021-04-15 17:21:48 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:21:48 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:21:48 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:21:48 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:21:48 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:21:48 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:21:48 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:21:48 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:21:57 ERROR FileNotFoundException:33 - .\reports\Tour 1.pdf (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird)
|
||||
2021-04-15 17:31:40 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:31:40 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:31:40 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:31:40 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:31:40 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:31:40 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:31:40 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:31:40 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:32:30 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:32:30 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:32:30 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:32:30 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:32:30 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:32:30 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:32:30 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:32:30 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:37:57 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:37:57 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:37:57 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:37:58 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:37:58 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:37:58 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:37:58 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:37:58 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:38:41 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:38:41 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:38:41 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:38:41 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:38:41 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:38:41 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:38:41 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:38:41 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:40:30 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:40:30 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:40:30 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:40:30 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:40:30 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:40:30 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:40:30 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:40:30 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:48:48 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:48:48 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:48:48 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:48:48 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:48:48 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:48:48 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:48:48 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:48:48 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 17:49:14 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 17:49:14 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 17:49:14 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 17:49:14 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 17:49:14 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 17:49:14 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 17:49:14 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 17:49:14 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 18:00:58 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 18:00:58 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 18:00:58 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 18:00:58 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 18:00:58 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 18:00:59 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 18:00:59 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 18:00:59 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 18:09:56 ERROR FileNotFoundException:33 - .\reports\Tour 1.pdf (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird)
|
||||
2021-04-15 18:10:01 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 18:10:01 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 18:10:01 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 18:10:01 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 18:10:01 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 18:10:01 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 18:10:01 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 18:10:01 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 18:10:06 ERROR FileNotFoundException:33 - .\reports\Tour 1.pdf (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird)
|
||||
2021-04-15 18:12:47 INFO PostgresHelper:15 - Tour Table created
|
||||
2021-04-15 18:12:47 ERROR PSQLException:33 - ERROR: relation "tour" already exists
|
||||
2021-04-15 18:12:47 INFO PostgresHelper:15 - Tour Table unique created
|
||||
2021-04-15 18:12:47 ERROR PSQLException:33 - ERROR: relation "tour_tourname_uindex" already exists
|
||||
2021-04-15 18:12:47 INFO PostgresHelper:15 - Tour Table primary created
|
||||
2021-04-15 18:12:47 ERROR PSQLException:33 - ERROR: multiple primary keys for table "tour" are not allowed
|
||||
2021-04-15 18:12:47 INFO PostgresHelper:15 - Log Table created
|
||||
2021-04-15 18:12:47 ERROR PSQLException:33 - ERROR: relation "log" already exists
|
||||
2021-04-15 18:13:38 ERROR FileNotFoundException:33 - .\reports\Tour 1.pdf (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird)
|
||||
|
@ -8,6 +8,7 @@ import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.TourPlaner;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -23,6 +24,7 @@ public class Main extends Application {
|
||||
Parent root = FXMLLoader.load(Main.class.getResource("tourplaner.fxml"));
|
||||
primaryStage.setTitle(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "apptitle"));
|
||||
primaryStage.getIcons().add(new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
|
||||
TourPlaner.init();
|
||||
primaryStage.setScene(new Scene(root, 1500, 1000));
|
||||
primaryStage.show();
|
||||
}
|
||||
|
@ -1,2 +1,237 @@
|
||||
package tourplaner.business;public class Reporter {
|
||||
package tourplaner.business;
|
||||
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
|
||||
import com.itextpdf.text.Anchor;
|
||||
import com.itextpdf.text.BadElementException;
|
||||
import com.itextpdf.text.Chapter;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Element;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.List;
|
||||
import com.itextpdf.text.ListItem;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.Phrase;
|
||||
import com.itextpdf.text.Section;
|
||||
import com.itextpdf.text.pdf.PdfPCell;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class Reporter {
|
||||
|
||||
private static Font catFont = new Font(Font.TIMES_ROMAN, 18,
|
||||
Font.BOLD);
|
||||
private static Font redFont = new Font(Font.TIMES_ROMAN, 12,
|
||||
Font.NORMAL, Color.RED);
|
||||
private static Font subFont = new Font(Font.TIMES_ROMAN, 16,
|
||||
Font.BOLD);
|
||||
private static Font smallBold = new Font(Font.TIMES_ROMAN, 12,
|
||||
Font.BOLD);
|
||||
|
||||
public static void createTourReport(String tourname) {
|
||||
Tour tour = TourPlaner.getTour(tourname);
|
||||
tour.setLog(TourPlaner.getLogs(tourname));
|
||||
String file = ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "report", "path") + tourname+".pdf";
|
||||
try {
|
||||
Document document = new Document();
|
||||
PdfWriter.getInstance(document, new FileOutputStream(file));
|
||||
document.open();
|
||||
addMetaData(document, tour);
|
||||
// addTitlePage(document, tour);
|
||||
addContent(document, tour);
|
||||
document.close();
|
||||
} catch (DocumentException | FileNotFoundException e) {
|
||||
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||
}
|
||||
openDefault(file);
|
||||
}
|
||||
|
||||
// iText allows to add metadata to the PDF which can be viewed in your Adobe
|
||||
// Reader
|
||||
// under File -> Properties
|
||||
private static void addMetaData(Document document, Tour tour) {
|
||||
document.addTitle("Tour Report -> " + tour.getName());
|
||||
document.addSubject("Tourplaner by DerGeorg");
|
||||
document.addKeywords("Tourplaner, Tour, Report");
|
||||
document.addAuthor("Tourplaner");
|
||||
document.addCreator("Tourplaner");
|
||||
}
|
||||
|
||||
private static void addContent(Document document, Tour tour) throws DocumentException {
|
||||
Anchor anchor = new Anchor("Tour Report von -> " + tour.getName(), catFont);
|
||||
anchor.setName("Tour Report von -> " + tour.getName());
|
||||
|
||||
// Second parameter is the number of the chapter
|
||||
Chapter catPart = new Chapter(new Paragraph(anchor), 1);
|
||||
|
||||
Paragraph subPara = new Paragraph("Tour", subFont);
|
||||
Section subCatPart = catPart.addSection(subPara);
|
||||
subCatPart.add(new Paragraph("Report erstellt von: " + System.getProperty("user.name") + ", " + new Date()));
|
||||
subCatPart.add(new Paragraph("Startpunkt der Tour: " + tour.getStart()));
|
||||
subCatPart.add(new Paragraph("Zielpunkt der Tour: " + tour.getZiel()));
|
||||
subCatPart.add(new Paragraph("Berechnete Dauer der Tour: " + tour.getDauer()));
|
||||
subCatPart.add(new Paragraph("Berechnete Strecke der Tour: " + tour.getStrecke()));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// now add all this to the document
|
||||
document.add(catPart);
|
||||
|
||||
|
||||
ArrayList<Log> logs = tour.getLogs();
|
||||
// Second parameter is the number of the chapter
|
||||
anchor = new Anchor("Logs", catFont);
|
||||
anchor.setName("Logs");
|
||||
catPart = new Chapter(new Paragraph(anchor), 2);
|
||||
catPart.add(new Paragraph("Anzahl der Logeinträge: " + logs.size()));
|
||||
|
||||
for (Log log: logs) {
|
||||
subPara = new Paragraph("Log vom: " + log.getDatum() , subFont);
|
||||
subCatPart = catPart.addSection(subPara);
|
||||
subCatPart.add(new Paragraph("Dauer: " + log.getDauer()));
|
||||
subCatPart.add(new Paragraph("Davon Pause: " + log.getPause()));
|
||||
subCatPart.add(new Paragraph("Davon gegangen: " + log.getGegangen()));
|
||||
subCatPart.add(new Paragraph("Berechnete Durchschnittliche Geschwindigkeit: " + log.getAvgspeed()));
|
||||
subCatPart.add(new Paragraph("Entfernung: " + log.getStrecke()));
|
||||
subCatPart.add(new Paragraph("Höhenmeter: " + log.getHightmeter()));
|
||||
subCatPart.add(new Paragraph("Bemerkung: " + log.getBemerkung()));
|
||||
}
|
||||
// now add all this to the document
|
||||
document.add(catPart);
|
||||
}
|
||||
|
||||
private static void createTable(Section subCatPart)
|
||||
throws BadElementException {
|
||||
PdfPTable table = new PdfPTable(5);
|
||||
|
||||
// t.setBorderColor(BaseColor.GRAY);
|
||||
// t.setPadding(4);
|
||||
// t.setSpacing(4);
|
||||
// t.setBorderWidth(1);
|
||||
|
||||
PdfPCell c1 = new PdfPCell(new Phrase("NR"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Datum"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Entfernung"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Höhenmeter"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("AVG Geschwindigkeit"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
|
||||
table.setHeaderRows(1);
|
||||
|
||||
table.addCell("1.0");
|
||||
table.addCell("1.1");
|
||||
table.addCell("1.2");
|
||||
table.addCell("1.3");
|
||||
table.addCell("1.4");
|
||||
table.addCell("1.5");
|
||||
|
||||
table.addCell("2.0");
|
||||
table.addCell("2.1");
|
||||
table.addCell("2.2");
|
||||
table.addCell("2.3");
|
||||
table.addCell("2.4");
|
||||
table.addCell("2.5");
|
||||
|
||||
subCatPart.add(table);
|
||||
|
||||
}
|
||||
private static void createTable2(Section subCatPart)
|
||||
throws BadElementException {
|
||||
PdfPTable table = new PdfPTable(5);
|
||||
|
||||
// t.setBorderColor(BaseColor.GRAY);
|
||||
// t.setPadding(4);
|
||||
// t.setSpacing(4);
|
||||
// t.setBorderWidth(1);
|
||||
|
||||
PdfPCell c1 = new PdfPCell(new Phrase("NR"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Dauer"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Davon Gegangen"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Davon Pause"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Bemerkung"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
|
||||
table.setHeaderRows(1);
|
||||
|
||||
table.addCell("1.0");
|
||||
table.addCell("1.1");
|
||||
table.addCell("1.2");
|
||||
table.addCell("1.3");
|
||||
table.addCell("1.4");
|
||||
table.addCell("1.5");
|
||||
|
||||
table.addCell("2.0");
|
||||
table.addCell("2.1");
|
||||
table.addCell("2.2");
|
||||
table.addCell("2.3");
|
||||
table.addCell("2.4");
|
||||
table.addCell("2.5");
|
||||
|
||||
subCatPart.add(table);
|
||||
}
|
||||
|
||||
private static void addEmptyLine(Paragraph paragraph, int number) {
|
||||
for (int i = 0; i < number; i++) {
|
||||
paragraph.add(new Paragraph(" "));
|
||||
}
|
||||
}
|
||||
|
||||
private static void openDefault(String f){
|
||||
// A reference to a text file
|
||||
File file = new File(f);
|
||||
|
||||
try {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
|
||||
// Open a file using the default program for the file type. In the example
|
||||
// we will launch a default registered program to open a text file. For
|
||||
// example on Windows operating system this call might launch a notepad.exe
|
||||
// to open the file.
|
||||
desktop.open(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,11 @@ package tourplaner.business;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import tourplaner.data.DbConnect;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Haupt Logik des Tourplaners
|
||||
@ -9,14 +14,74 @@ import tourplaner.data.DbConnect;
|
||||
public class TourPlaner{
|
||||
private Logger logger;
|
||||
|
||||
public TourPlaner(){
|
||||
LogHelper.info(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "message"),
|
||||
ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "app"));
|
||||
/**
|
||||
* Erstellt alle DB Tabellen falls nötig
|
||||
*/
|
||||
public static void init(){
|
||||
new DbConnect().init();
|
||||
|
||||
}
|
||||
|
||||
public String getMapJson(String start, String ziel){
|
||||
/**
|
||||
* Holt alle touren aus der DB
|
||||
* @return Alle touren als ArrayList
|
||||
*/
|
||||
public static ArrayList<Tour> getAllTours(){
|
||||
return new DbConnect().getAllTouren();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bearbeitet eine Tour
|
||||
* @param oldname Alter Tourname
|
||||
* @param tour Neuer Tourname
|
||||
* @return false bei error
|
||||
*/
|
||||
public static boolean editTour(String oldname, Tour tour){
|
||||
return new DbConnect().editTour(oldname, tour);
|
||||
}
|
||||
|
||||
public static boolean delTour(String tourname){
|
||||
return new DbConnect().delTour(tourname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt eine Tour hinzu
|
||||
* @param newTour Neue Tour
|
||||
* @return false bei error
|
||||
*/
|
||||
public static boolean addTour(Tour newTour){
|
||||
return new DbConnect().addTour(newTour);
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<Log> getLogs(String tourname){
|
||||
return new DbConnect().getLogs(tourname);
|
||||
}
|
||||
|
||||
public static void doReport(String tourname){
|
||||
Reporter.createTourReport(tourname);
|
||||
}
|
||||
|
||||
public static Tour getTour(String tourname){
|
||||
return new DbConnect().getTour(tourname);
|
||||
}
|
||||
|
||||
public static boolean addLog(String tourname, Log log){
|
||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
||||
return new DbConnect().addLog(tourname, log);
|
||||
}
|
||||
|
||||
public static boolean delLog(String tourname, String id){
|
||||
return new DbConnect().delLog(tourname, id);
|
||||
}
|
||||
|
||||
public static boolean editLog(String tourname, Log log){
|
||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
||||
return new DbConnect().editLog(tourname, log);
|
||||
}
|
||||
|
||||
|
||||
public static String getMapJson(String start, String ziel){
|
||||
// TODO: 14.04.2021 Map Quest
|
||||
return start + " " + ziel;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
package tourplaner.data;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@ -26,10 +33,188 @@ public class DbConnect {
|
||||
* @return True bei erfolg, sonst error
|
||||
*/
|
||||
public boolean init() {
|
||||
// TODO: 26.02.2021 Alle sql im init sind noch falsch
|
||||
ArrayList<Boolean> errors = new ArrayList<>();
|
||||
errors.add(PostgresHelper.executeUpdateMessage("CREATE TABLE IF NOT EXISTS USERS (username TEXT PRIMARY KEY NOT NULL, nachname TEXT NOT NULL, email TEXT NOT NULL, password TEXT NOT NULL, bio TEXT, image TEXT, coins integer default 20 not null)", "User Table created"));
|
||||
errors.add(PostgresHelper.executeUpdateMessage("create table tour ( tourname varchar not null, dauer decimal, mapjson varchar, start varchar, ziel varchar, strecke decimal);", "Tour Table created"));
|
||||
errors.add(PostgresHelper.executeUpdateMessage("create unique index tour_tourname_uindex on tour (tourname);", "Tour Table unique created"));
|
||||
errors.add(PostgresHelper.executeUpdateMessage("alter table tour add constraint tour_pk primary key (tourname);", "Tour Table primary created"));
|
||||
errors.add(PostgresHelper.executeUpdateMessage("create table log(tourname varchar constraint log_tour_tourname_fk references tour,id varchar,bemerkung varchar,datum date,strecke decimal,avg decimal,hightmeter decimal,pause decimal,gegangen decimal,dauer decimal);", "Log Table created"));
|
||||
return !errors.contains(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bearbeitet eine Tour
|
||||
* @param oldname Alter Tour name
|
||||
* @param tour Neues Tour Object
|
||||
* @return false bei error
|
||||
*/
|
||||
public boolean editTour(String oldname, Tour tour) {
|
||||
String tourname = tour.getName();
|
||||
ArrayList<Boolean> result = new ArrayList<>();
|
||||
ArrayList<Log> logs = getLogs(oldname);
|
||||
result.add(delLogs(oldname));
|
||||
result.add(PostgresHelper.executeUpdate("UPDATE public.tour SET tourname = '"+tour.getName()+"', dauer = 1, mapjson = '"+tour.getMapJson()+"', start = '"+tour.getStart()+"', ziel = '"+tour.getZiel()+"', strecke = "+tour.getStrecke()+" WHERE tourname ='" + oldname + "';"));
|
||||
logs.forEach(log -> {
|
||||
result.add(addLog(tourname, log));
|
||||
});
|
||||
return !result.contains(false);
|
||||
}
|
||||
|
||||
private boolean delLogs(String tourname){
|
||||
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"'");
|
||||
}
|
||||
/**
|
||||
* Fügt eine Tour hinzu
|
||||
* @param tour Neue Tour
|
||||
* @return false bei error
|
||||
*/
|
||||
public boolean addTour(Tour tour){
|
||||
return PostgresHelper.executeUpdate("INSERT INTO public.tour (tourname, dauer, mapjson, start, ziel, strecke) VALUES ('"+tour.getName()+"', "+tour.getDauer()+", '"+tour.getMapJson()+"', '"+tour.getStart()+"', '"+tour.getZiel()+"', "+tour.getStrecke()+")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht eine Tour anhand des Tournamens
|
||||
* @param tourname Tourname der zu löschen ist
|
||||
* @return false bei error
|
||||
*/
|
||||
public boolean delTour(String tourname){
|
||||
ArrayList<Boolean> result = new ArrayList<>();
|
||||
result.add(delLogs(tourname));
|
||||
result.add(PostgresHelper.executeUpdate("DELETE FROM public.tour WHERE tourname = '"+tourname+"'"));
|
||||
return !result.contains(false);
|
||||
}
|
||||
|
||||
public ArrayList<Log> getLogs(String tourname){
|
||||
|
||||
this.c = PostgresHelper.con();
|
||||
String id, bemerkung ;
|
||||
double dauer, strecke, pause, gegangen, avg, hightmeter;
|
||||
Date datum;
|
||||
|
||||
ArrayList<Log> logs = new ArrayList<>();
|
||||
try {
|
||||
stmt = this.c.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM public.log where tourname = '"+ tourname +"'");
|
||||
while (rs.next()) {
|
||||
id = rs.getString("id");
|
||||
bemerkung = rs.getString("bemerkung");
|
||||
datum = rs.getDate("datum");
|
||||
dauer = rs.getDouble("dauer");
|
||||
// avg = rs.getDouble("avg");
|
||||
hightmeter = rs.getDouble("hightmeter");
|
||||
pause = rs.getDouble("pause");
|
||||
// gegangen = rs.getDouble("gegangen");
|
||||
strecke = rs.getDouble("strecke");
|
||||
if (!tourname.isEmpty()) {
|
||||
logs.add(new Log(id, dauer, datum.toLocalDate(), strecke, bemerkung,hightmeter, pause));
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
this.c.close();
|
||||
return logs;
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Füght einen Logeintrag ein
|
||||
* @param tourname Zu welcher Tour der Logeintrag gehört
|
||||
* @param log Der Logeintrag
|
||||
* @return false bei error
|
||||
*/
|
||||
public boolean addLog(String tourname, Log log){
|
||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
||||
return PostgresHelper.executeUpdate("INSERT INTO public.log (tourname, id, bemerkung, datum, strecke, avg, hightmeter, pause, gegangen, dauer) VALUES ('"+tourname+"', '"+log.getId()+"', '"+log.getBemerkung()+"', '"+log.getDatum()+"', "
|
||||
+log.getStrecke()+", "+log.getAvgspeed()+", "+log.getHightmeter()+", "+log.getPause()+", "+log.getGegangen()+", "+log.getDauer()+")");
|
||||
}
|
||||
|
||||
public boolean editLog(String tourname, Log log){
|
||||
return PostgresHelper.executeUpdate("UPDATE public.log SET bemerkung = '"+log.getBemerkung()+"', datum = '"+log.getDatum()+"', strecke = "+log.getStrecke()+", avg = "+log.getAvgspeed()+", hightmeter = "+
|
||||
log.getHightmeter()+", pause = "+log.getPause()+", gegangen = "+log.getGegangen()+", dauer = "+log.getDauer()+" WHERE tourname = '"+tourname+"' and id = '"+log.getId()+"'");
|
||||
}
|
||||
|
||||
public boolean delLog(String tourname, String id){
|
||||
System.out.println("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
||||
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt alle Touren aus der Datenbank
|
||||
* @return Null bei fehler, sonst eine List aus den IDs
|
||||
*/
|
||||
public ArrayList<Tour> getAllTouren(){
|
||||
this.c = PostgresHelper.con();
|
||||
String tourname, mapjson, start, ziel;
|
||||
double dauer, strecke;
|
||||
|
||||
ArrayList<Tour> touren = new ArrayList<>();
|
||||
try {
|
||||
stmt = this.c.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select * from tour;");
|
||||
while (rs.next()) {
|
||||
tourname = rs.getString("tourname");
|
||||
mapjson = rs.getString("mapjson");
|
||||
start = rs.getString("start");
|
||||
ziel = rs.getString("ziel");
|
||||
dauer = rs.getDouble("dauer");
|
||||
strecke = rs.getDouble("strecke");
|
||||
if (!tourname.isEmpty()) {
|
||||
touren.add(new Tour(tourname, dauer + "", mapjson, strecke, start, ziel));
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
this.c.close();
|
||||
return touren;
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt eine Tour aus der Datenbank
|
||||
* @param tn Tourname
|
||||
* @return Null bei fehler, sonst eine List aus den IDs
|
||||
*/
|
||||
public Tour getTour(String tn){
|
||||
this.c = PostgresHelper.con();
|
||||
String tourname, mapjson, start, ziel;
|
||||
double dauer, strecke;
|
||||
|
||||
Tour touren = null;
|
||||
try {
|
||||
stmt = this.c.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select * from tour where tourname = '"+tn+"';");
|
||||
while (rs.next()) {
|
||||
tourname = rs.getString("tourname");
|
||||
mapjson = rs.getString("mapjson");
|
||||
start = rs.getString("start");
|
||||
ziel = rs.getString("ziel");
|
||||
dauer = rs.getDouble("dauer");
|
||||
strecke = rs.getDouble("strecke");
|
||||
if (!tourname.isEmpty()) {
|
||||
touren = new Tour(tourname, dauer + "", mapjson, strecke, start, ziel);
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
this.c.close();
|
||||
return touren;
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,16 +3,20 @@ package tourplaner.data;
|
||||
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Hilfsfunktionen für die verwendung der Postgres DB
|
||||
*/
|
||||
public class PostgresHelper {
|
||||
|
||||
private Connection c;
|
||||
private Statement stmt;
|
||||
/**
|
||||
* Verbindet mit der Datenbank
|
||||
* @return Das Connection Objekt
|
||||
@ -21,6 +25,8 @@ public class PostgresHelper {
|
||||
Connection c = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
System.out.println("jdbc:postgresql://" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "url") + ":" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "port") + "/" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "dbname")+
|
||||
ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "user")+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "pw"));
|
||||
c = DriverManager
|
||||
.getConnection("jdbc:postgresql://" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "url") + ":" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "port") + "/" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "dbname"),
|
||||
ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "user"), ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "pw"));
|
||||
|
@ -21,6 +21,20 @@ public class Tour {
|
||||
this.log = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setTour(Tour tour){
|
||||
this.dauer = tour.getDauer();
|
||||
this.mapJson = tour.getMapJson();
|
||||
this.strecke = tour.getStrecke();
|
||||
this.name = tour.getName();
|
||||
this.start = tour.getStart();
|
||||
this.ziel = tour.getZiel();
|
||||
this.log = tour.getLogs();
|
||||
}
|
||||
|
||||
public void setLog(ArrayList<Log> log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt einen einzigen Log Eintrag anhand der Id
|
||||
* @param id Id des Eintrags der zu besorgen ist
|
||||
|
@ -11,6 +11,7 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
import tourplaner.business.TourPlaner;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
import tourplaner.viewmodels.ViewModel;
|
||||
@ -49,11 +50,13 @@ public class TourplanerController implements Initializable {
|
||||
@FXML
|
||||
private void editTourBtn(){
|
||||
this.viewModel.editTour();
|
||||
syncTour(this.viewModel.getSelectedTour().getName());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void editLogBtn(){
|
||||
this.viewModel.editLog();
|
||||
syncLogs();
|
||||
}
|
||||
/**
|
||||
* Öffnet github im standart browser
|
||||
@ -82,6 +85,19 @@ public class TourplanerController implements Initializable {
|
||||
this.viewModel.doxygenDocBrowser();
|
||||
}
|
||||
|
||||
private void syncTour(String selectedItem){
|
||||
beschreibungTableView.getItems().removeIf(s -> true); //Leert die Table View komplett
|
||||
beschreibungTableView.getItems().add(this.viewModel.getTour(selectedItem));
|
||||
}
|
||||
|
||||
private void syncTourNamen(){
|
||||
TourListView.setItems(this.viewModel.getTourNamen());
|
||||
}
|
||||
|
||||
private void syncLogs(){
|
||||
logTableView.getItems().removeIf(s -> true);
|
||||
logTableView.setItems(this.viewModel.getLogData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -93,8 +109,7 @@ public class TourplanerController implements Initializable {
|
||||
String selectedItem = TourListView.getSelectionModel().getSelectedItem();
|
||||
this.viewModel.selectTour(selectedItem);
|
||||
titleTextView.setText(selectedItem);
|
||||
beschreibungTableView.getItems().removeIf(s -> true); //Leert die Table View komplett
|
||||
beschreibungTableView.getItems().add(this.viewModel.getTour(selectedItem));
|
||||
syncTour(selectedItem);
|
||||
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
||||
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
||||
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
||||
@ -103,6 +118,7 @@ public class TourplanerController implements Initializable {
|
||||
|
||||
//Log anzeigen
|
||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
||||
logTableView.getItems().removeIf(s -> true);
|
||||
logTableView.setItems(this.viewModel.getLogData());
|
||||
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
||||
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
||||
@ -161,12 +177,13 @@ public class TourplanerController implements Initializable {
|
||||
@FXML
|
||||
private void addLog(){
|
||||
this.viewModel.addLog();
|
||||
syncLogs();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void delLog(){
|
||||
this.viewModel.delLog();
|
||||
|
||||
syncLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +205,7 @@ public class TourplanerController implements Initializable {
|
||||
//Tour list -> links
|
||||
TourListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
TourListView.setOrientation(Orientation.VERTICAL);
|
||||
TourListView.setItems(this.viewModel.getTourNamen());
|
||||
syncTourNamen();
|
||||
//Tabs zu Tour -> rechts oben
|
||||
beschreibungTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
||||
titleTextView.setText( ConfigHelper.getLangIniString("keinetourselected"));
|
||||
|
@ -2,8 +2,7 @@ package tourplaner.viewmodels;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.apache.pdfbox.exceptions.COSVisitorException;
|
||||
import tourplaner.business.Reporter;
|
||||
import tourplaner.business.TourPlaner;
|
||||
import tourplaner.ui.AlertHelper;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
@ -15,14 +14,15 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ViewModel {
|
||||
//Tour
|
||||
private final ObservableList<Tour> tourData = FXCollections.observableArrayList(new Tour("Test 1", "120", "json dings", 22.3, "Wien", "Graz"),new Tour("Test 2", "210", "json dings", 42.3, "Da", "Dort"));
|
||||
private final ObservableList<String> tourNamen = FXCollections.observableArrayList("Test 1", "Test 2");
|
||||
private final ObservableList<Tour> tourData = FXCollections.observableArrayList();
|
||||
private final ObservableList<String> tourNamen = FXCollections.observableArrayList();
|
||||
private Tour selectedTour;
|
||||
private String neueTourName, neueTourStart, neueTourZiel, neueBemerkung;
|
||||
//Log
|
||||
@ -57,8 +57,11 @@ public class ViewModel {
|
||||
|
||||
this.tourData.removeIf(tour -> tour.getName().equals(this.selectedTour.getName()));
|
||||
this.tourNamen.removeIf(tour -> tour.equals(this.selectedTour.getName()));
|
||||
this.tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
|
||||
Tour newTour = new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel);
|
||||
this.tourData.add(newTour);
|
||||
this.tourNamen.add(this.neueTourName);
|
||||
LogHelper.info("Edit Tour: " + this.neueTourName + " upload zu Postgres war: " + TourPlaner.editTour(this.selectedTour.getName(), newTour), "ViewModel - EditTour");
|
||||
selectTour(this.neueTourName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,7 +140,7 @@ public class ViewModel {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -149,8 +152,10 @@ public class ViewModel {
|
||||
tourStartInput("");
|
||||
tourZielInput("");
|
||||
if (getTour(this.neueTourName) == null) {
|
||||
tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
|
||||
Tour newTour = new Tour(this.neueTourName, "1", "1", 0, this.neueTourStart, this.neueTourZiel);
|
||||
tourData.add(newTour);
|
||||
tourNamen.add(this.neueTourName);
|
||||
TourPlaner.addTour(newTour);
|
||||
}
|
||||
this.neueTourStart = null;
|
||||
this.neueTourZiel = null;
|
||||
@ -204,10 +209,11 @@ public class ViewModel {
|
||||
Log newLog = new Log(this.selectedLog.getId(), dauer, datum, strecke, this.neueBemerkung, hightmeter, pause);
|
||||
this.logData.removeIf(ld -> ld.getId().equals(this.selectedLog.getId()));
|
||||
this.logData.add(newLog);
|
||||
tourAkt.get().delLog(this.selectedLog.getId());
|
||||
tourAkt.get().addLog(newLog);
|
||||
// tourAkt.get().delLog(this.selectedLog.getId());
|
||||
// tourAkt.get().addLog(newLog);
|
||||
this.tourData.removeIf(td -> td.getName().equals(this.selectedTour.getName()));
|
||||
this.tourData.add(tourAkt.get());
|
||||
TourPlaner.editLog(this.selectedTour.getName(), newLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -319,6 +325,7 @@ public class ViewModel {
|
||||
if (date != null) {
|
||||
Log newLog = new Log(newId.get(), dauer, date, strecke, this.neueBemerkung, hightmeter, pause);
|
||||
this.logData.add(newLog);
|
||||
TourPlaner.addLog(this.selectedTour.getName(), newLog);
|
||||
s.addLog(newLog);
|
||||
}
|
||||
}
|
||||
@ -340,25 +347,8 @@ public class ViewModel {
|
||||
*/
|
||||
public void delLog(){
|
||||
if(this.selectedLog != null) {
|
||||
this.logData.removeIf(s -> s.getId().equals(this.selectedLog.getId()));
|
||||
AtomicReference<Tour> tourToEdit = new AtomicReference<>();
|
||||
this.tourData.forEach(s -> {
|
||||
if (s.getLogs() != null) {
|
||||
s.getLogs().forEach(ss -> {
|
||||
if (ss.getId().equals(this.selectedLog.getId())) {
|
||||
tourToEdit.set(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (tourToEdit.get() != null){
|
||||
Tour toEdit = tourToEdit.get();
|
||||
toEdit.delLog(this.selectedLog.getId());
|
||||
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName()));
|
||||
this.tourData.add(toEdit);
|
||||
TourPlaner.delLog(this.selectedTour.getName(), this.selectedLog.getId());
|
||||
this.selectedLog = null;
|
||||
}
|
||||
}else{
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
@ -398,6 +388,8 @@ public class ViewModel {
|
||||
}
|
||||
|
||||
public ObservableList<Log> getLogData() {
|
||||
logData.removeAll();
|
||||
logData.addAll(TourPlaner.getLogs(this.selectedTour.getName()));
|
||||
return logData;
|
||||
}
|
||||
|
||||
@ -452,6 +444,12 @@ public class ViewModel {
|
||||
}
|
||||
|
||||
public ObservableList<String> getTourNamen() {
|
||||
ArrayList<String> namen = new ArrayList<>();
|
||||
getTourData().forEach(s -> {
|
||||
namen.add(s.getName());
|
||||
});
|
||||
tourNamen.removeAll();
|
||||
tourNamen.addAll(namen);
|
||||
return tourNamen;
|
||||
}
|
||||
|
||||
@ -472,6 +470,9 @@ public class ViewModel {
|
||||
}
|
||||
|
||||
public ObservableList<Tour> getTourData() {
|
||||
tourData.removeAll();
|
||||
// ObservableList<Tour> data = ;
|
||||
tourData.addAll(TourPlaner.getAllTours());
|
||||
return tourData;
|
||||
}
|
||||
|
||||
@ -485,6 +486,7 @@ public class ViewModel {
|
||||
tourNamen.removeIf(s -> s.equals(tourname));
|
||||
logData.removeIf(s -> true);
|
||||
setSelectedTour(null);
|
||||
TourPlaner.delTour(tourname);
|
||||
}catch (NullPointerException e){
|
||||
LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("deltournoselect"));
|
||||
@ -568,14 +570,7 @@ public class ViewModel {
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("logtournotselectedmsg"));
|
||||
}else {
|
||||
try {
|
||||
Reporter.createTourReport(this.selectedTour.getName());
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||
} catch (COSVisitorException e) {
|
||||
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||
}
|
||||
|
||||
TourPlaner.doReport(this.selectedTour.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user