From f1ec6a222ac82275fb2aaaaa7e93764fa9500b38 Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Tue, 12 Jun 2018 19:19:46 +0200 Subject: Add TODO comments as feedback which occurred during JourFixe [#28535] --- .../tuwien/sepm/assignment/groupphase/application/MainApplication.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java index d8365a7..d1569f6 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java @@ -27,6 +27,8 @@ public class MainApplication extends Application { primaryStage.centerOnScreen(); primaryStage.setOnCloseRequest(event -> Platform.exit()); + // TODO: close connection on program exit (feedback) + configApplicationContext = new AnnotationConfigApplicationContext(MainApplication.class); final var fxmlLoader = configApplicationContext.getBean(SpringFXMLLoader.class); primaryStage.setScene( -- cgit v1.2.3-70-g09d2 From 195745e68723a40c7bc1e93f049a8c511ce817ff Mon Sep 17 00:00:00 2001 From: Tharre Date: Tue, 12 Jun 2018 13:54:38 +0200 Subject: Close database connection when program terminates --- .../sepm/assignment/groupphase/application/MainApplication.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java index d1569f6..87daea4 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java @@ -1,6 +1,7 @@ package at.ac.tuwien.sepm.assignment.groupphase.application; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateOperationController; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; import javafx.application.Application; import javafx.application.Platform; @@ -25,7 +26,13 @@ public class MainApplication extends Application { public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Einsatz erstellen"); primaryStage.centerOnScreen(); - primaryStage.setOnCloseRequest(event -> Platform.exit()); + primaryStage.setOnCloseRequest( + event -> { + final var jdbcConnectionManager = + configApplicationContext.getBean(JDBCConnectionManager.class); + jdbcConnectionManager.closeConnection(); + Platform.exit(); + }); // TODO: close connection on program exit (feedback) -- cgit v1.2.3-70-g09d2 From 1a018e9eb023cc355fa72e74de1da7c4795affae Mon Sep 17 00:00:00 2001 From: Tharre Date: Mon, 18 Jun 2018 19:42:19 +0200 Subject: Add PopulateDB for testing --- .../groupphase/application/PopulateDB.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java new file mode 100644 index 0000000..b115e56 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java @@ -0,0 +1,20 @@ +package at.ac.tuwien.sepm.assignment.groupphase.application; + +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.io.InputStreamReader; +import java.sql.SQLException; +import org.h2.tools.RunScript; +import org.springframework.core.io.ClassPathResource; + +public class PopulateDB { + public static void main(String[] args) throws SQLException { + JDBCConnectionManager jdbcConnectionManager = new JDBCConnectionManager(); + + RunScript.execute( + jdbcConnectionManager.getConnection(), + new InputStreamReader( + ClassPathResource.class.getResourceAsStream("/sql/Testdaten.sql"))); + + jdbcConnectionManager.closeConnection(); + } +} -- cgit v1.2.3-70-g09d2 From 9056b605578fcaee29965074365b9527ba865ecd Mon Sep 17 00:00:00 2001 From: Martin Weick Date: Mon, 18 Jun 2018 20:03:50 +0200 Subject: edit Testdata #28617 --- .../groupphase/application/PopulateDB.java | 2 +- src/main/resources/sql/Testdaten.sql | 792 --------------------- src/main/resources/sql/testdata.sql | 792 +++++++++++++++++++++ 3 files changed, 793 insertions(+), 793 deletions(-) delete mode 100644 src/main/resources/sql/Testdaten.sql create mode 100644 src/main/resources/sql/testdata.sql (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java index b115e56..4ff1f78 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java @@ -13,7 +13,7 @@ public class PopulateDB { RunScript.execute( jdbcConnectionManager.getConnection(), new InputStreamReader( - ClassPathResource.class.getResourceAsStream("/sql/Testdaten.sql"))); + ClassPathResource.class.getResourceAsStream("/sql/testdata.sql"))); jdbcConnectionManager.closeConnection(); } diff --git a/src/main/resources/sql/Testdaten.sql b/src/main/resources/sql/Testdaten.sql deleted file mode 100644 index 960ec93..0000000 --- a/src/main/resources/sql/Testdaten.sql +++ /dev/null @@ -1,792 +0,0 @@ -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (1, 'Bess Peak', '1961-03-01', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (2, 'Maryrose Farriar', '1970-11-16', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (3, 'Hannis MacLardie', '1970-12-20', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (4, 'Major Folbige', '1959-12-09', 'NKV', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (5, 'Bronny Nel', '1966-03-07', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (6, 'Fransisco Labadini', '1963-09-01', 'NKI', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (7, 'Dannie Skeldon', '1969-12-25', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (8, 'Pippa Sickert', '1987-02-28', 'NKA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (9, 'Gwendolyn Grigolon', '1975-03-05', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (10, 'Aileen McGuinley', '1988-01-08', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (11, 'Barbra Izon', '1984-11-14', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (12, 'Ailsun Nestoruk', '1969-12-25', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (13, 'Ulrika Choake', '1975-06-17', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (14, 'Myrtia Elsmor', '1974-05-23', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (15, 'Brade Hurst', '1980-12-14', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (16, 'Valli Fancet', '1955-11-11', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (17, 'Dana Nixon', '1973-08-19', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (18, 'Anjela Orrice', '1986-04-21', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (19, 'Normie Martinie', '1988-09-30', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (20, 'Martelle Tunnick', '1972-01-29', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (21, 'Laurent Janouch', '1990-05-25', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (22, 'Scarface Portchmouth', '1970-04-26', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (23, 'Anatola McHugh', '1972-03-08', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (24, 'Tatum Flaonier', '1979-01-26', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (25, 'Dianna Philo', '1998-09-07', 'NKI', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (26, 'Ave Thow', '1965-07-30', 'NKV', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (27, 'Vail Naptine', '1986-08-28', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (28, 'Gaven Gainsbury', '1991-01-21', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (29, 'Kaile Hartill', '1970-06-30', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (30, 'Floria Trevaskis', '1955-01-14', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (31, 'Bidget Dukelow', '1969-12-14', 'NKI', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (32, 'Reece Mushet', '1989-07-18', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (33, 'Rafaellle Hurdle', '1968-04-25', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (34, 'Kristoforo Boner', '1960-11-26', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (35, 'Carree Marquot', '1982-10-29', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (36, 'Max Maldin', '1955-08-30', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (37, 'Betsy Urion', '1999-01-09', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (38, 'Jud Levey', '1986-08-28', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (39, 'Stepha Adriani', '1964-06-26', 'NA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (40, 'Jodie Yeskin', '1963-06-22', 'NKV', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (41, 'Viole Heritege', '1999-11-27', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (42, 'Mort Dudson', '1973-07-28', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (43, 'Brittney Srawley', '1955-04-12', 'NKI', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (44, 'Tod Plevey', '1994-09-28', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (45, 'Rhianon Lawday', '1963-11-15', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (46, 'Hill Jachtym', '1972-10-02', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (47, 'Gregory Sheavills', '1971-08-14', 'NKI', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (48, 'Linnea Castlake', '1966-03-31', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (49, 'Curr Robertz', '1983-09-24', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (50, 'Ricki Trevillion', '1972-08-17', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (51, 'Haily Gloyens', '1975-08-24', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (52, 'Sherwynd Bugbird', '1966-01-16', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (53, 'Cathrin Hamlen', '1973-01-15', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (54, 'Oliver Ropars', '1964-02-28', 'NKA', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (55, 'Mersey Suerz', '1988-03-03', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (56, 'Fabio Mapes', '1986-01-01', 'NKA', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (57, 'Devondra Jonsson', '1969-10-01', 'NKI', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (58, 'Malva Pulver', '1984-06-11', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (59, 'Petronella MacCorkell', '1990-01-25', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (60, 'Letty McKag', '1989-02-05', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (61, 'Nikoletta McLeish', '1956-09-19', 'NKV', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (62, 'Mella Gerred', '1963-04-28', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (63, 'Banky Bradforth', '1983-12-23', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (64, 'Etta Curnow', '1993-06-29', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (65, 'Bobina Fernez', '1956-12-14', 'NKV', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (66, 'Dreddy Pessold', '1972-02-25', 'NA', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (67, 'Maxie Speedy', '1984-04-19', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (68, 'Benetta Jent', '1969-12-27', 'NA', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (69, 'Caro Szanto', '1957-06-14', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (70, 'Carmela Alejandre', '1979-12-05', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (71, 'Merrile Doig', '1992-08-07', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (72, 'Michell Sanney', '1959-08-11', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (73, 'Kata Spark', '1988-12-18', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (74, 'Chelsie Normanville', '1972-04-14', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (75, 'Ciro Grigg', '1957-02-18', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (76, 'Shela Larkcum', '1979-12-14', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (77, 'Myrvyn Denyukin', '1976-07-07', 'NKA', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (78, 'Lethia Glede', '1972-12-10', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (79, 'Malchy Chiverton', '1971-08-14', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (80, 'Dario Rasor', '1997-10-05', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (81, 'Anni Baldacco', '1961-08-05', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (82, 'Brigit Wheelband', '1966-06-21', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (83, 'Niki Tynemouth', '1968-09-17', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (84, 'Nikki Mea', '1965-08-14', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (85, 'Dania Garrique', '1986-03-25', 'NA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (86, 'Dorelia Leggs', '1960-12-16', 'NKI', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (87, 'Cristin Carous', '1999-10-21', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (88, 'Clare Caustick', '1969-09-27', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (89, 'Conant Gallo', '1993-11-19', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (90, 'Gwyneth Cavie', '1956-04-12', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (91, 'Mabel Meadley', '1966-11-25', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (92, 'Mona Bonafant', '1957-06-12', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (93, 'Clarita Fealty', '1987-12-22', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (94, 'Elie Jardin', '1986-01-10', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (95, 'Pacorro Dobing', '1988-01-04', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (96, 'Marci Wloch', '1973-08-23', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (97, 'Micky Fossett', '2000-01-13', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (98, 'Bil Rangall', '1979-05-06', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (99, 'Athena Matteoni', '1980-11-08', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (100, 'Molly Fennelly', '1980-06-14', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (101, 'Dylan Fordyce', '1983-12-03', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (102, 'Onida Betjeman', '1993-01-12', 'NKI', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (103, 'Brietta Biswell', '1956-09-18', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (104, 'Elna Boyton', '1983-04-08', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (105, 'Zsazsa Robertazzi', '1967-08-28', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (106, 'Brook Bleier', '1976-12-04', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (107, 'Kaleena Fosh', '1987-08-04', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (108, 'Julee Polamontayne', '1988-09-30', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (109, 'Arte Elliss', '1965-08-30', 'NA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (110, 'Celia Skelcher', '1965-01-31', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (111, 'Kelsey Luetkemeyer', '1976-07-27', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (112, 'Pedro Jakubowski', '1982-07-10', 'NA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (113, 'Licha Slatten', '1985-03-19', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (114, 'Adella Sisson', '1997-06-02', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (115, 'Hagan Senett', '1979-09-25', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (116, 'Jecho Beilby', '1993-12-27', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (117, 'Karoly Toolin', '1988-06-11', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (118, 'Madelon Steart', '1987-08-04', 'NKA', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (119, 'Laverne Yelland', '1980-11-09', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (120, 'Murry Bottoner', '1955-04-21', 'NKA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (121, 'Sianna Tomney', '1987-04-14', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (122, 'Dulcea Squirrell', '1967-03-07', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (123, 'Bengt Durbridge', '1966-04-15', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (124, 'Cletus Akenhead', '1974-06-13', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (125, 'Huntington McKeand', '1988-12-21', 'NA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (126, 'Carolin Doget', '1974-05-02', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (127, 'Bobby Iredell', '1974-01-25', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (128, 'Preston Pidgeon', '1987-06-17', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (129, 'Gretta Darnbrough', '1996-05-22', 'NKI', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (130, 'Justen Hearley', '1976-08-09', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (131, 'Davon Baser', '1987-03-02', 'RS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (132, 'Alasdair Clancy', '1993-05-24', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (133, 'Hattie Kareman', '1997-07-07', 'NKA', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (134, 'Ignaz Buddell', '1986-02-07', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (135, 'Ashil Kanter', '1977-06-17', 'NFS', true, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (136, 'Daniele Mallam', '1969-01-26', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (137, 'Eugenius Stuehmeier', '1961-10-16', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (138, 'Jdavie Acey', '1991-11-21', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (139, 'Jaynell Fossord', '1967-10-15', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (140, 'Roarke Peascod', '1956-12-01', 'NKA', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (141, 'Horacio Boxer', '1990-02-12', 'NKA', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (142, 'Bard Thyng', '1979-01-25', 'NKI', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (143, 'Nadia Fayre', '1979-03-02', 'NFS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (144, 'Garrot Fry', '1960-12-30', 'NKV', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (145, 'Kristal Hammor', '1975-09-05', 'RS', true, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (146, 'Barnebas Kinsell', '2000-10-11', 'NFS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (147, 'Marleen Entwhistle', '1960-04-08', 'NFS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (148, 'Paule Kettlestring', '1978-04-04', 'RS', false, false); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (149, 'Valentin Nerval', '1999-06-01', 'RS', false, true); -insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (150, 'Zitella Bywaters', '1966-11-11', 'NKA', true, true); - - -insert into Employee (id, version) values (1, 1); -insert into Employee (id, version) values (2, 2); -insert into Employee (id, version) values (3, 3); -insert into Employee (id, version) values (4, 4); -insert into Employee (id, version) values (5, 5); -insert into Employee (id, version) values (6, 6); -insert into Employee (id, version) values (7, 7); -insert into Employee (id, version) values (8, 8); -insert into Employee (id, version) values (9, 9); -insert into Employee (id, version) values (10, 10); -insert into Employee (id, version) values (11, 11); -insert into Employee (id, version) values (12, 12); -insert into Employee (id, version) values (13, 13); -insert into Employee (id, version) values (14, 14); -insert into Employee (id, version) values (15, 15); -insert into Employee (id, version) values (16, 16); -insert into Employee (id, version) values (17, 17); -insert into Employee (id, version) values (18, 18); -insert into Employee (id, version) values (19, 19); -insert into Employee (id, version) values (20, 20); -insert into Employee (id, version) values (21, 21); -insert into Employee (id, version) values (22, 22); -insert into Employee (id, version) values (23, 23); -insert into Employee (id, version) values (24, 24); -insert into Employee (id, version) values (25, 25); -insert into Employee (id, version) values (26, 26); -insert into Employee (id, version) values (27, 27); -insert into Employee (id, version) values (28, 28); -insert into Employee (id, version) values (29, 29); -insert into Employee (id, version) values (30, 30); -insert into Employee (id, version) values (31, 31); -insert into Employee (id, version) values (32, 32); -insert into Employee (id, version) values (33, 33); -insert into Employee (id, version) values (34, 34); -insert into Employee (id, version) values (35, 35); -insert into Employee (id, version) values (36, 36); -insert into Employee (id, version) values (37, 37); -insert into Employee (id, version) values (38, 38); -insert into Employee (id, version) values (39, 39); -insert into Employee (id, version) values (40, 40); -insert into Employee (id, version) values (41, 41); -insert into Employee (id, version) values (42, 42); -insert into Employee (id, version) values (43, 43); -insert into Employee (id, version) values (44, 44); -insert into Employee (id, version) values (45, 45); -insert into Employee (id, version) values (46, 46); -insert into Employee (id, version) values (47, 47); -insert into Employee (id, version) values (48, 48); -insert into Employee (id, version) values (49, 49); -insert into Employee (id, version) values (50, 50); -insert into Employee (id, version) values (51, 51); -insert into Employee (id, version) values (52, 52); -insert into Employee (id, version) values (53, 53); -insert into Employee (id, version) values (54, 54); -insert into Employee (id, version) values (55, 55); -insert into Employee (id, version) values (56, 56); -insert into Employee (id, version) values (57, 57); -insert into Employee (id, version) values (58, 58); -insert into Employee (id, version) values (59, 59); -insert into Employee (id, version) values (60, 60); -insert into Employee (id, version) values (61, 61); -insert into Employee (id, version) values (62, 62); -insert into Employee (id, version) values (63, 63); -insert into Employee (id, version) values (64, 64); -insert into Employee (id, version) values (65, 65); -insert into Employee (id, version) values (66, 66); -insert into Employee (id, version) values (67, 67); -insert into Employee (id, version) values (68, 68); -insert into Employee (id, version) values (69, 69); -insert into Employee (id, version) values (70, 70); -insert into Employee (id, version) values (71, 71); -insert into Employee (id, version) values (72, 72); -insert into Employee (id, version) values (73, 73); -insert into Employee (id, version) values (74, 74); -insert into Employee (id, version) values (75, 75); -insert into Employee (id, version) values (76, 76); -insert into Employee (id, version) values (77, 77); -insert into Employee (id, version) values (78, 78); -insert into Employee (id, version) values (79, 79); -insert into Employee (id, version) values (80, 80); -insert into Employee (id, version) values (81, 81); -insert into Employee (id, version) values (82, 82); -insert into Employee (id, version) values (83, 83); -insert into Employee (id, version) values (84, 84); -insert into Employee (id, version) values (85, 85); -insert into Employee (id, version) values (86, 86); -insert into Employee (id, version) values (87, 87); -insert into Employee (id, version) values (88, 88); -insert into Employee (id, version) values (89, 89); -insert into Employee (id, version) values (90, 90); -insert into Employee (id, version) values (91, 91); -insert into Employee (id, version) values (92, 92); -insert into Employee (id, version) values (93, 93); -insert into Employee (id, version) values (94, 94); -insert into Employee (id, version) values (95, 95); -insert into Employee (id, version) values (96, 96); -insert into Employee (id, version) values (97, 97); -insert into Employee (id, version) values (98, 98); -insert into Employee (id, version) values (99, 99); -insert into Employee (id, version) values (100, 100); -insert into Employee (id, version) values (101, 101); -insert into Employee (id, version) values (102, 102); -insert into Employee (id, version) values (103, 103); -insert into Employee (id, version) values (104, 104); -insert into Employee (id, version) values (105, 105); -insert into Employee (id, version) values (106, 106); -insert into Employee (id, version) values (107, 107); -insert into Employee (id, version) values (108, 108); -insert into Employee (id, version) values (109, 109); -insert into Employee (id, version) values (110, 110); -insert into Employee (id, version) values (111, 111); -insert into Employee (id, version) values (112, 112); -insert into Employee (id, version) values (113, 113); -insert into Employee (id, version) values (114, 114); -insert into Employee (id, version) values (115, 115); -insert into Employee (id, version) values (116, 116); -insert into Employee (id, version) values (117, 117); -insert into Employee (id, version) values (118, 118); -insert into Employee (id, version) values (119, 119); -insert into Employee (id, version) values (120, 120); -insert into Employee (id, version) values (121, 121); -insert into Employee (id, version) values (122, 122); -insert into Employee (id, version) values (123, 123); -insert into Employee (id, version) values (124, 124); -insert into Employee (id, version) values (125, 125); -insert into Employee (id, version) values (126, 126); -insert into Employee (id, version) values (127, 127); -insert into Employee (id, version) values (128, 128); -insert into Employee (id, version) values (129, 129); -insert into Employee (id, version) values (130, 130); -insert into Employee (id, version) values (131, 131); -insert into Employee (id, version) values (132, 132); -insert into Employee (id, version) values (133, 133); -insert into Employee (id, version) values (134, 134); -insert into Employee (id, version) values (135, 135); -insert into Employee (id, version) values (136, 136); -insert into Employee (id, version) values (137, 137); -insert into Employee (id, version) values (138, 138); -insert into Employee (id, version) values (139, 139); -insert into Employee (id, version) values (140, 140); -insert into Employee (id, version) values (141, 141); -insert into Employee (id, version) values (142, 142); -insert into Employee (id, version) values (143, 143); -insert into Employee (id, version) values (144, 144); -insert into Employee (id, version) values (145, 145); -insert into Employee (id, version) values (146, 146); -insert into Employee (id, version) values (147, 147); -insert into Employee (id, version) values (148, 148); -insert into Employee (id, version) values (149, 149); -insert into Employee (id, version) values (150, 150); - - -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (1, 'BKTW', 'NORMAL', 'BKTW-1', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (2, 'KTW', 'MITTELHOCHDACH', 'KTW-2', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (3, 'KTW', 'MITTELHOCHDACH', 'KTW-3', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (4, 'BKTW', 'NORMAL', 'BKTW-4', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (5, 'RTW', 'HOCHDACH', 'RTW-5', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (6, 'RTW', 'HOCHDACH', 'RTW-6', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (7, 'BKTW', 'NORMAL', 'BKTW-7', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (8, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-8', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (9, 'RTW', 'HOCHDACH', 'RTW-9', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (10, 'RTW', 'HOCHDACH', 'RTW-10', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (11, 'RTW', 'HOCHDACH', 'RTW-11', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (12, 'RTW', 'HOCHDACH', 'RTW-12', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (13, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-13', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (14, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-14', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (15, 'BKTW', 'NORMAL', 'BKTW-15', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (16, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-16', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (17, 'KTW', 'MITTELHOCHDACH', 'KTW-17', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (18, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-18', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (19, 'RTW', 'HOCHDACH', 'RTW-19', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (20, 'RTW', 'HOCHDACH', 'RTW-20', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (21, 'RTW', 'HOCHDACH', 'RTW-21', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (22, 'BKTW', 'NORMAL', 'BKTW-22', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (23, 'RTW', 'HOCHDACH', 'RTW-23', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (24, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-24', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (25, 'KTW', 'MITTELHOCHDACH', 'KTW-25', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (26, 'RTW', 'HOCHDACH', 'RTW-26', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (27, 'KTW', 'MITTELHOCHDACH', 'KTW-27', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (28, 'KTW', 'MITTELHOCHDACH', 'KTW-28', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (29, 'BKTW', 'NORMAL', 'BKTW-29', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (30, 'RTW', 'HOCHDACH', 'RTW-30', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (31, 'RTW', 'HOCHDACH', 'RTW-31', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (32, 'RTW', 'HOCHDACH', 'RTW-32', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (33, 'RTW', 'HOCHDACH', 'RTW-33', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (34, 'KTW', 'MITTELHOCHDACH', 'KTW-34', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (35, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-35', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (36, 'RTW', 'HOCHDACH', 'RTW-36', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (37, 'RTW', 'HOCHDACH', 'RTW-37', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (38, 'BKTW', 'NORMAL', 'BKTW-38', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (39, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-39', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (40, 'RTW', 'HOCHDACH', 'RTW-40', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (41, 'RTW', 'HOCHDACH', 'RTW-41', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (42, 'KTW', 'MITTELHOCHDACH', 'KTW-42', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (43, 'RTW', 'HOCHDACH', 'RTW-43', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (44, 'RTW', 'HOCHDACH', 'RTW-44', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (45, 'RTW', 'HOCHDACH', 'RTW-45', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (46, 'RTW', 'HOCHDACH', 'RTW-46', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (47, 'KTW', 'MITTELHOCHDACH', 'KTW-47', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (48, 'BKTW', 'NORMAL', 'BKTW-48', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (49, 'RTW', 'HOCHDACH', 'RTW-49', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (50, 'RTW', 'HOCHDACH', 'RTW-50', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (51, 'NEF', 'NORMAL', 'NEF-51', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (52, 'NEF', 'NORMAL', 'NEF-52', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (53, 'NEF', 'NORMAL', 'NEF-53', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (54, 'NEF', 'NORMAL', 'NEF-54', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (55, 'NEF', 'NORMAL', 'NEF-55', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (56, 'NEF', 'NORMAL', 'NEF-56', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (57, 'NEF', 'NORMAL', 'NEF-57', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (58, 'NEF', 'NORMAL', 'NEF-58', false); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (59, 'NAH', 'NORMAL', 'NAH-59', true); -insert into VehicleVersion (id, type, constructionType, name, hasNef) values (60, 'NAH', 'NORMAL', 'NAH-60', true); - - -insert into Vehicle (id, version, status) values (1, 1, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (2, 2, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (3, 3, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (4, 4, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (5, 5, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (6, 6, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (7, 7, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (8, 8, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (9, 9, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (10, 10, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (11, 11, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (12, 12, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (13, 13, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (14, 14, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (15, 15, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (16, 16, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (17, 17, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (18, 18, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (19, 19, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (20, 20, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (21, 21, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (22, 22, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (23, 23, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (24, 24, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (25, 25, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (26, 26, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (27, 27, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (28, 28, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (29, 29, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (30, 30, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (31, 31, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (32, 32, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (33, 33, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (34, 34, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (35, 35, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (36, 36, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (37, 37, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (38, 38, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (39, 39, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (40, 40, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (41, 41, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (42, 42, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (43, 43, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (44, 44, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (45, 45, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (46, 46, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (47, 47, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (48, 48, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (49, 49, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (50, 50, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (51, 51, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (52, 52, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (53, 53, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (54, 54, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (55, 55, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (56, 56, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (57, 57, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (58, 58, 'ABGEMELDET'); -insert into Vehicle (id, version, status) values (59, 59, 'FREI_WACHE'); -insert into Vehicle (id, version, status) values (60, 60, 'FREI_WACHE'); - - -insert into Registration (id, vehicleId, employeeId, start, end, active) values (1, 5, 2, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (2, 5, 4, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (3, 46, 13, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (4, 46, 32, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (5, 32, 44, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (6, 32, 51, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (7, 45, 37, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (8, 45, 49, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (9, 14, 34, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (10, 14, 9, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (11, 11, 78, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (12, 11, 84, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (13, 47, 62, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (14, 47, 63, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (15, 41, 92, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (16, 41, 93, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (17, 50, 117, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (18, 50, 116, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (19, 17, 134, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (20, 17, 135, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (21, 42, 149, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (22, 42, 150, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (23, 12, 139, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (24, 12, 140, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (25, 34, 111, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (26, 34, 113, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (27, 22, 131, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (28, 31, 70, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (29, 31, 69, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (30, 38, 88, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (31, 49, 19, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (32, 49, 20, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (33, 40, 55, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (34, 40, 56, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (35, 26, 42, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (36, 26, 67, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (37, 36, 11, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (38, 36, 12, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (39, 37, 33, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (40, 37, 34, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (41, 37, 15, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (42, 20, 65, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (43, 20, 74, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (44, 44, 123, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (45, 44, 124, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (46, 28, 126, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (47, 28, 127, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (48, 10, 144, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (49, 10, 145, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (50, 2, 71, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (51, 2, 4, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (52, 23, 7, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (53, 23, 8, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (54, 9, 10, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (55, 9, 31, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (56, 59, 6, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (57, 59, 22, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (58, 59, 39, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (59, 60, 53, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (60, 60, 54, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (61, 60, 66, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (62, 51, 83, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (63, 51, 112, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (64, 52, 129, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (65, 52, 125, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (66, 53, 38, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (67, 53, 85, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); -/*insert into Registration (id, vehicleId, employeeId, start, end, active) values (68, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (69, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (70, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (71, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (72, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (73, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (74, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (75, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (76, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (77, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (78, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (79, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (80, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (81, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (82, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (83, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (84, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (85, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (86, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (87, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (88, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (89, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (90, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (91, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (92, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (93, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (94, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (95, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (96, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (97, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (98, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (99, , , , , true); -insert into Registration (id, vehicleId, employeeId, start, end, active) values (100, , , , , true);*/ - -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (1, 'A', 'RD-10A4V', '2017-12-02T06:12:21Z', '0121 Golf Course Crossing', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (2, 'A', 'RD-26A6J', '2017-11-13T00:12:45Z', '75 Straubel Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (3, 'C', 'RD-65C9M', '2017-07-31T19:08:42Z', '3468 Lawn Trail', 'Junction', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (4, 'A', 'RD-51A8F', '2018-04-15T08:45:33Z', '11752 Farragut Pass', 'Park', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (5, 'C', 'RD-18C3J', '2017-07-25T03:15:18Z', '546 Nova Place', 'Parkway', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (6, 'A', 'RD-93A4D', '2017-11-07T22:33:38Z', '1 Shasta Crossing', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (7, 'O', 'RD-70O3C', '2017-08-16T20:18:10Z', '20076 Surrey Crossing', 'Point', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (8, 'B', 'RD-76B9M', '2017-12-24T18:59:08Z', '214 Nova Hill', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (9, 'E', 'RD-40E5B', '2017-11-15T02:23:19Z', '3492 Atwood Alley', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (10, 'O', 'RD-70O2F', '2018-05-20T10:57:13Z', '655 Helena Junction', 'Park', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (11, 'A', 'RD-35A7U', '2018-05-27T04:41:52Z', '200 Florence Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (12, 'A', 'RD-22A8J', '2017-08-11T07:22:54Z', '017 Cambridge Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (13, 'A', 'RD-43A6K', '2017-06-29T00:40:23Z', '59960 Longview Way', 'Lane', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (14, 'C', 'RD-74C8K', '2018-04-03T04:38:37Z', '5083 Luster Hill', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (15, 'C', 'RD-93C6T', '2017-11-30T18:39:02Z', '2 Moose Parkway', 'Place', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (16, 'D', 'RD-35D8P', '2017-12-08T23:39:15Z', '9 Utah Trail', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (17, 'A', 'RD-26A9L', '2017-08-05T18:25:13Z', '7468 Commercial Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (18, 'E', 'RD-57E7X', '2017-08-12T06:26:53Z', '0 Eliot Alley', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (19, 'B', 'RD-84B8A', '2018-06-09T07:45:21Z', '05447 Division Plaza', 'Street', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (20, 'C', 'RD-99C9L', '2018-04-28T16:41:06Z', '7 Jenifer Place', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (21, 'C', 'RD-85C9X', '2017-11-01T11:30:21Z', '350 Packers Avenue', 'Street', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (22, 'A', 'RD-16A4K', '2018-05-03T01:57:10Z', '45577 Park Meadow Circle', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (23, 'B', 'RD-59B5Y', '2017-12-01T13:41:55Z', '7666 Grayhawk Terrace', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (24, 'C', 'RD-36C4V', '2018-05-02T14:45:08Z', '1520 Montana Court', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (25, 'A', 'RD-54A3B', '2018-01-27T13:02:43Z', '5478 Blackbird Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (26, 'A', 'RD-00A0Z', '2017-07-05T10:36:42Z', '668 Kenwood Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (27, 'B', 'RD-99B3Z', '2017-10-31T13:58:54Z', '4528 Meadow Ridge Way', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (28, 'E', 'RD-21E4B', '2018-03-06T15:19:53Z', '8269 Anthes Park', 'Alley', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (29, 'A', 'RD-68A4E', '2017-07-16T11:54:29Z', '34466 Mariners Cove Lane', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (30, 'A', 'RD-44A9N', '2017-11-16T22:07:30Z', '39 Shoshone Parkway', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (31, 'B', 'RD-28B1U', '2017-10-31T23:40:33Z', '9 Butternut Place', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (32, 'A', 'RD-19A8V', '2017-07-13T02:46:28Z', '9427 Clove Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (33, 'B', 'RD-03B9Q', '2017-08-21T06:54:03Z', '08242 Hintze Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (34, 'A', 'RD-33A0C', '2017-12-16T13:31:21Z', '9 Russell Terrace', 'Parkway', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (35, 'A', 'RD-54A1E', '2017-11-18T01:08:02Z', '40776 Kings Street', 'Street', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (36, 'B', 'RD-11B9D', '2017-07-16T14:58:14Z', '4379 Grover Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (37, 'A', 'RD-20A7H', '2018-04-12T17:25:55Z', '51626 Paget Drive', 'Lane', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (38, 'B', 'RD-74B2N', '2018-06-15T15:33:35Z', '4039 Northwestern Terrace', 'Circle', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (39, 'A', 'RD-14A2U', '2018-04-13T11:12:04Z', '174 Twin Pines Road', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (40, 'O', 'RD-85O8J', '2018-04-07T17:02:42Z', '15 Schiller Plaza', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (41, 'B', 'RD-17B8G', '2017-11-12T07:42:07Z', '446 Elka Drive', 'Center', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (42, 'B', 'RD-16B1V', '2017-12-14T20:35:48Z', '0493 4th Road', 'Center', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (43, 'A', 'RD-99A7V', '2017-06-29T17:17:53Z', '7815 Harper Place', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (44, 'O', 'RD-61O2F', '2017-07-15T08:41:09Z', '1388 Steensland Junction', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (45, 'A', 'RD-18A8M', '2017-12-05T14:06:22Z', '72 Golf Course Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (46, 'A', 'RD-97A2W', '2017-08-28T20:48:22Z', '7333 Alpine Street', 'Lane', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (47, 'A', 'RD-30A3J', '2018-01-26T00:15:01Z', '884 Stoughton Trail', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (48, 'O', 'RD-34O4J', '2018-06-01T01:21:24Z', '26 Riverside Lane', 'Pass', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (49, 'B', 'RD-18B6R', '2017-07-15T08:15:06Z', '04291 Dakota Way', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (50, 'A', 'RD-36A2Y', '2017-12-29T01:36:29Z', '403 Forest Run Park', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (51, 'A', 'RD-07A3U', '2017-10-23T11:03:53Z', '00758 Di Loreto Terrace', 'Place', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (52, 'O', 'RD-62O3Y', '2018-04-05T00:45:16Z', '8 Orin Court', 'Center', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (53, 'A', 'RD-18A7D', '2017-10-17T00:32:46Z', '98788 Golf Course Court', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (54, 'A', 'RD-11A4A', '2017-09-20T03:12:38Z', '567 Oak Valley Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (55, 'A', 'RD-30A2Y', '2017-11-06T08:00:24Z', '53 Fair Oaks Center', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (56, 'A', 'RD-17A3R', '2017-12-30T16:55:12Z', '075 Lighthouse Bay Junction', 'Parkway', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (57, 'O', 'RD-18O4D', '2018-02-04T12:33:46Z', '54 Eagan Circle', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (58, 'A', 'RD-25A8I', '2017-09-26T20:36:01Z', '29 Troy Center', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (59, 'B', 'RD-20B1G', '2018-04-05T04:58:38Z', '8892 Kensington Way', 'Point', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (60, 'A', 'RD-14A9B', '2017-06-27T04:49:09Z', '031 Cody Junction', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (61, 'A', 'RD-03A6S', '2017-09-10T00:46:34Z', '21 Steensland Place', 'Place', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (62, 'O', 'RD-41O3V', '2017-07-06T02:08:29Z', '27757 Sycamore Point', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (63, 'O', 'RD-36O6T', '2018-04-20T08:06:43Z', '876 Service Pass', 'Park', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (64, 'A', 'RD-42A2T', '2017-09-24T16:11:48Z', '1 Mitchell Park', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (65, 'A', 'RD-21A9L', '2018-06-11T06:03:37Z', '73686 Merrick Trail', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (66, 'C', 'RD-89C5M', '2018-03-10T16:46:56Z', '5168 Pine View Park', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (67, 'A', 'RD-10A6K', '2018-05-18T15:17:28Z', '304 Dunning Park', 'Way', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (68, 'C', 'RD-09C7S', '2018-03-08T18:52:12Z', '0 Londonderry Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (69, 'B', 'RD-75B8D', '2017-09-26T00:11:54Z', '00 Elgar Alley', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (70, 'O', 'RD-43O2V', '2017-09-02T02:56:49Z', '5969 Elmside Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (71, 'A', 'RD-24A0R', '2017-09-04T14:27:20Z', '865 Autumn Leaf Circle', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (72, 'B', 'RD-82B3A', '2018-06-03T20:09:15Z', '449 Commercial Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (73, 'A', 'RD-59A3A', '2017-11-11T20:43:16Z', '3 Banding Hill', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (74, 'B', 'RD-98B1G', '2017-06-20T12:39:45Z', '4303 Barby Road', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (75, 'A', 'RD-61A5L', '2018-03-09T18:55:16Z', '0 Macpherson Lane', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (76, 'B', 'RD-72B8U', '2018-04-27T22:48:48Z', '4 Boyd Court', 'Point', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (77, 'C', 'RD-63C3M', '2018-04-18T02:49:03Z', '3596 Miller Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (78, 'A', 'RD-03A9D', '2017-10-20T16:01:25Z', '2 Crescent Oaks Park', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (79, 'A', 'RD-62A5V', '2018-01-02T14:59:58Z', '0089 Jackson Plaza', 'Street', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (80, 'B', 'RD-36B2C', '2018-04-11T00:56:22Z', '3741 Spaight Circle', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (81, 'A', 'RD-19A7E', '2018-05-05T00:17:49Z', '90 Fair Oaks Place', 'Avenue', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (82, 'B', 'RD-90B8G', '2017-08-06T00:47:06Z', '6 Fremont Street', 'Circle', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (83, 'A', 'RD-28A0V', '2018-01-19T13:36:34Z', '20 Arrowood Parkway', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (84, 'A', 'RD-71A0B', '2018-01-09T15:30:57Z', '060 Badeau Park', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (85, 'B', 'RD-49B7X', '2018-02-07T18:46:02Z', '97261 Burning Wood Hill', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (86, 'B', 'RD-55B0F', '2018-02-02T03:23:51Z', '13987 Corscot Way', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (87, 'A', 'RD-79A5X', '2017-08-02T02:50:44Z', '90 Dexter Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (88, 'A', 'RD-04A7T', '2017-11-06T07:18:03Z', '619 Graedel Court', 'Way', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (89, 'C', 'RD-85C1G', '2017-12-17T18:50:36Z', '7 Fremont Avenue', 'Place', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (90, 'O', 'RD-40O9Z', '2017-11-19T08:07:26Z', '79953 Fair Oaks Drive', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (91, 'C', 'RD-08C4Z', '2018-03-21T02:49:58Z', '7779 Monterey Street', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (92, 'A', 'RD-13A5U', '2017-09-29T05:21:06Z', '7 Little Fleur Road', 'Circle', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (93, 'B', 'RD-02B2E', '2017-08-04T17:00:43Z', '34572 Old Shore Crossing', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (94, 'A', 'RD-11A9X', '2017-08-27T23:59:41Z', '858 Spenser Drive', 'Avenue', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (95, 'B', 'RD-95B6D', '2018-01-07T01:49:50Z', '98 Jenifer Terrace', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (96, 'A', 'RD-47A7T', '2017-07-02T09:57:56Z', '209 Talmadge Lane', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (97, 'O', 'RD-78O1Z', '2017-12-10T15:02:21Z', '5348 Blackbird Pass', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (98, 'A', 'RD-72A5Y', '2017-12-23T10:48:06Z', '394 Anzinger Avenue', 'Point', 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (99, 'C', 'RD-78C4D', '2017-12-26T03:29:27Z', '115 Petterle Crossing', null, 'COMPLETED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (100, 'A', 'RD-17A9I', '2017-10-05T17:45:19Z', '533 Transport Way', 'Crossing', 'COMPLETED'); - - -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (101, 'A', 'RD-74A1G', '2018-02-05T15:37:44Z', '625 Veith Center', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (102, 'B', 'RD-15B1U', '2017-10-20T04:54:38Z', '9 Westport Alley', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (103, 'O', 'RD-62O0B', '2018-02-05T12:18:43Z', '87559 Sherman Terrace', 'Court', 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (104, 'A', 'RD-45A0Y', '2018-05-17T17:08:18Z', '8 Delladonna Lane', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (105, 'A', 'RD-42A8G', '2018-05-03T01:52:39Z', '7 Superior Drive', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (106, 'O', 'RD-03O0G', '2018-01-21T17:21:12Z', '72 Darwin Point', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (107, 'A', 'RD-94A0W', '2017-11-08T06:11:31Z', '7168 Anniversary Way', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (108, 'A', 'RD-18A1E', '2018-02-20T15:51:48Z', '2023 Barby Road', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (109, 'A', 'RD-11A2I', '2018-02-07T06:42:04Z', '1901 Mesta Street', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (110, 'O', 'RD-78O0A', '2018-01-02T21:11:05Z', '6 David Trail', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (111, 'B', 'RD-70B6R', '2017-11-23T11:35:51Z', '188 Golden Leaf Avenue', 'Road', 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (112, 'B', 'RD-95B9K', '2018-02-03T06:44:16Z', '805 Jenna Alley', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (113, 'A', 'RD-58A3E', '2017-08-18T08:46:01Z', '954 Oriole Hill', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (114, 'B', 'RD-58B5V', '2017-06-19T12:47:16Z', '2503 East Road', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (115, 'A', 'RD-93A3V', '2018-03-04T16:46:37Z', '2 Northview Terrace', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (116, 'B', 'RD-25B6N', '2018-01-05T13:49:50Z', '43459 Crownhardt Crossing', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (117, 'A', 'RD-01A3J', '2017-08-08T05:23:13Z', '13 Kedzie Road', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (118, 'B', 'RD-70B9E', '2017-09-25T14:22:46Z', '49 Westridge Point', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (119, 'A', 'RD-18A6U', '2018-01-15T22:08:09Z', '6109 Kennedy Court', null, 'CANCELLED'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (120, 'O', 'RD-27O6C', '2017-10-06T11:55:04Z', '590 Golf Terrace', null, 'CANCELLED'); - -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (121, 'C', 'RD-34C5U', '2018-06-18T02:58:38Z', '1909 Cascade Drive', 'Hill', 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (122, 'B', 'RD-55B4X', '2018-06-18T03:55:21Z', '7 Rigney Parkway', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (123, 'C', 'RD-41C0X', '2018-06-18T06:35:58Z', '86986 Mcbride Court', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (124, 'A', 'RD-60A5T', '2018-06-18T14:33:37Z', '14649 Manley Park', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (125, 'D', 'RD-95D8H', '2018-06-18T09:15:13Z', '50 Magdeline Road', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (126, 'A', 'RD-16A9F', '2018-06-18T01:28:09Z', '25241 Bowman Alley', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (127, 'A', 'RD-33A1C', '2018-06-18T16:49:43Z', '59864 Rutledge Avenue', null, 'ACTIVE'); -insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (128, 'B', 'RD-49B4F', '2018-06-18T06:10:37Z', '43 Longview Crossing', null, 'ACTIVE'); - ---(51|52|53|59|60|2|5|9|10|11|12|14|17|20|22|23|26|28|31|32|34|36|37|38|40|41|42|44|45|46|47|49|50) - -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,1); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,2); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,3); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,4); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,5); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,6); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,7); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,8); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,9); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,10); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,11); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,12); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,13); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,14); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,15); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,16); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,17); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,18); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,19); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,20); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,21); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,22); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,23); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,24); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,25); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,26); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,27); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,28); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,29); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,30); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,31); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,32); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,33); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,34); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,35); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,36); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,37); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,38); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,39); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,40); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,41); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,42); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,43); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,44); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,45); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,46); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,47); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,48); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,49); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,50); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,51); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,52); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,53); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,54); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,55); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,56); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,57); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,58); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,59); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,60); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,61); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,62); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,63); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,64); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,65); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,66); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,67); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,68); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,69); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (14,70); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (52,71); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,72); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,73); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,74); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,75); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,76); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,77); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,78); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,79); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,80); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,81); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,82); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,83); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,84); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,85); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,86); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,87); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,88); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,89); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,90); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,91); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,92); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,93); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,94); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,95); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,96); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,97); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,98); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,99); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,100); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,101); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,102); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,103); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,104); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,105); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,106); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,107); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,108); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,109); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,110); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,111); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,112); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,113); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,114); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,115); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,116); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,117); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,118); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,119); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,120); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,121); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,122); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,123); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,124); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,125); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,125); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,126); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (27,127); -INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,128); diff --git a/src/main/resources/sql/testdata.sql b/src/main/resources/sql/testdata.sql new file mode 100644 index 0000000..3cfb0ee --- /dev/null +++ b/src/main/resources/sql/testdata.sql @@ -0,0 +1,792 @@ +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (1, 'Bess Peak', '1961-03-01', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (2, 'Maryrose Farriar', '1970-11-16', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (3, 'Hannis MacLardie', '1970-12-20', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (4, 'Major Folbige', '1959-12-09', 'NKV', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (5, 'Bronny Nel', '1966-03-07', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (6, 'Fransisco Labadini', '1963-09-01', 'NKI', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (7, 'Dannie Skeldon', '1969-12-25', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (8, 'Pippa Sickert', '1987-02-28', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (9, 'Gwendolyn Grigolon', '1975-03-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (10, 'Aileen McGuinley', '1988-01-08', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (11, 'Barbra Izon', '1984-11-14', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (12, 'Ailsun Nestoruk', '1969-12-25', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (13, 'Ulrika Choake', '1975-06-17', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (14, 'Myrtia Elsmor', '1974-05-23', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (15, 'Brade Hurst', '1980-12-14', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (16, 'Valli Fancet', '1955-11-11', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (17, 'Dana Nixon', '1973-08-19', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (18, 'Anjela Orrice', '1986-04-21', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (19, 'Normie Martinie', '1988-09-30', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (20, 'Martelle Tunnick', '1972-01-29', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (21, 'Laurent Janouch', '1990-05-25', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (22, 'Scarface Portchmouth', '1970-04-26', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (23, 'Anatola McHugh', '1972-03-08', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (24, 'Tatum Flaonier', '1979-01-26', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (25, 'Dianna Philo', '1998-09-07', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (26, 'Ave Thow', '1965-07-30', 'NKV', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (27, 'Vail Naptine', '1986-08-28', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (28, 'Gaven Gainsbury', '1991-01-21', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (29, 'Kaile Hartill', '1970-06-30', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (30, 'Floria Trevaskis', '1955-01-14', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (31, 'Bidget Dukelow', '1969-12-14', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (32, 'Reece Mushet', '1989-07-18', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (33, 'Rafaellle Hurdle', '1968-04-25', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (34, 'Kristoforo Boner', '1960-11-26', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (35, 'Carree Marquot', '1982-10-29', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (36, 'Max Maldin', '1955-08-30', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (37, 'Betsy Urion', '1999-01-09', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (38, 'Jud Levey', '1986-08-28', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (39, 'Stepha Adriani', '1964-06-26', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (40, 'Jodie Yeskin', '1963-06-22', 'NKV', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (41, 'Viole Heritege', '1999-11-27', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (42, 'Mort Dudson', '1973-07-28', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (43, 'Brittney Srawley', '1955-04-12', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (44, 'Tod Plevey', '1994-09-28', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (45, 'Rhianon Lawday', '1963-11-15', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (46, 'Hill Jachtym', '1972-10-02', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (47, 'Gregory Sheavills', '1971-08-14', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (48, 'Linnea Castlake', '1966-03-31', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (49, 'Curr Robertz', '1983-09-24', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (50, 'Ricki Trevillion', '1972-08-17', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (51, 'Haily Gloyens', '1975-08-24', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (52, 'Sherwynd Bugbird', '1966-01-16', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (53, 'Cathrin Hamlen', '1973-01-15', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (54, 'Oliver Ropars', '1964-02-28', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (55, 'Mersey Suerz', '1988-03-03', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (56, 'Fabio Mapes', '1986-01-01', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (57, 'Devondra Jonsson', '1969-10-01', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (58, 'Malva Pulver', '1984-06-11', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (59, 'Petronella MacCorkell', '1990-01-25', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (60, 'Letty McKag', '1989-02-05', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (61, 'Nikoletta McLeish', '1956-09-19', 'NKV', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (62, 'Mella Gerred', '1963-04-28', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (63, 'Banky Bradforth', '1983-12-23', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (64, 'Etta Curnow', '1993-06-29', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (65, 'Bobina Fernez', '1956-12-14', 'NKV', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (66, 'Dreddy Pessold', '1972-02-25', 'NA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (67, 'Maxie Speedy', '1984-04-19', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (68, 'Benetta Jent', '1969-12-27', 'NA', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (69, 'Caro Szanto', '1957-06-14', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (70, 'Carmela Alejandre', '1979-12-05', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (71, 'Merrile Doig', '1992-08-07', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (72, 'Michell Sanney', '1959-08-11', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (73, 'Kata Spark', '1988-12-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (74, 'Chelsie Normanville', '1972-04-14', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (75, 'Ciro Grigg', '1957-02-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (76, 'Shela Larkcum', '1979-12-14', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (77, 'Myrvyn Denyukin', '1976-07-07', 'NKA', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (78, 'Lethia Glede', '1972-12-10', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (79, 'Malchy Chiverton', '1971-08-14', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (80, 'Dario Rasor', '1997-10-05', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (81, 'Anni Baldacco', '1961-08-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (82, 'Brigit Wheelband', '1966-06-21', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (83, 'Niki Tynemouth', '1968-09-17', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (84, 'Nikki Mea', '1965-08-14', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (85, 'Dania Garrique', '1986-03-25', 'NA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (86, 'Dorelia Leggs', '1960-12-16', 'NKI', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (87, 'Cristin Carous', '1999-10-21', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (88, 'Clare Caustick', '1969-09-27', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (89, 'Conant Gallo', '1993-11-19', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (90, 'Gwyneth Cavie', '1956-04-12', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (91, 'Mabel Meadley', '1966-11-25', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (92, 'Mona Bonafant', '1957-06-12', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (93, 'Clarita Fealty', '1987-12-22', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (94, 'Elie Jardin', '1986-01-10', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (95, 'Pacorro Dobing', '1988-01-04', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (96, 'Marci Wloch', '1973-08-23', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (97, 'Micky Fossett', '2000-01-13', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (98, 'Bil Rangall', '1979-05-06', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (99, 'Athena Matteoni', '1980-11-08', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (100, 'Molly Fennelly', '1980-06-14', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (101, 'Dylan Fordyce', '1983-12-03', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (102, 'Onida Betjeman', '1993-01-12', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (103, 'Brietta Biswell', '1956-09-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (104, 'Elna Boyton', '1983-04-08', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (105, 'Zsazsa Robertazzi', '1967-08-28', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (106, 'Brook Bleier', '1976-12-04', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (107, 'Kaleena Fosh', '1987-08-04', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (108, 'Julee Polamontayne', '1988-09-30', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (109, 'Arte Elliss', '1965-08-30', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (110, 'Celia Skelcher', '1965-01-31', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (111, 'Kelsey Luetkemeyer', '1976-07-27', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (112, 'Pedro Jakubowski', '1982-07-10', 'NA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (113, 'Licha Slatten', '1985-03-19', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (114, 'Adella Sisson', '1997-06-02', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (115, 'Hagan Senett', '1979-09-25', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (116, 'Jecho Beilby', '1993-12-27', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (117, 'Karoly Toolin', '1988-06-11', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (118, 'Madelon Steart', '1987-08-04', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (119, 'Laverne Yelland', '1980-11-09', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (120, 'Murry Bottoner', '1955-04-21', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (121, 'Sianna Tomney', '1987-04-14', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (122, 'Dulcea Squirrell', '1967-03-07', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (123, 'Bengt Durbridge', '1966-04-15', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (124, 'Cletus Akenhead', '1974-06-13', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (125, 'Huntington McKeand', '1988-12-21', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (126, 'Carolin Doget', '1974-05-02', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (127, 'Bobby Iredell', '1974-01-25', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (128, 'Preston Pidgeon', '1987-06-17', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (129, 'Gretta Darnbrough', '1996-05-22', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (130, 'Justen Hearley', '1976-08-09', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (131, 'Davon Baser', '1987-03-02', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (132, 'Alasdair Clancy', '1993-05-24', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (133, 'Hattie Kareman', '1997-07-07', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (134, 'Ignaz Buddell', '1986-02-07', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (135, 'Ashil Kanter', '1977-06-17', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (136, 'Daniele Mallam', '1969-01-26', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (137, 'Eugenius Stuehmeier', '1961-10-16', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (138, 'Jdavie Acey', '1991-11-21', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (139, 'Jaynell Fossord', '1967-10-15', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (140, 'Roarke Peascod', '1956-12-01', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (141, 'Horacio Boxer', '1990-02-12', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (142, 'Bard Thyng', '1979-01-25', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (143, 'Nadia Fayre', '1979-03-02', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (144, 'Garrot Fry', '1960-12-30', 'NKV', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (145, 'Kristal Hammor', '1975-09-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (146, 'Barnebas Kinsell', '2000-10-11', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (147, 'Marleen Entwhistle', '1960-04-08', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (148, 'Paule Kettlestring', '1978-04-04', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (149, 'Valentin Nerval', '1999-06-01', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (150, 'Zitella Bywaters', '1966-11-11', 'NKA', true, true); + + +insert into Employee (id, version) values (1, 1); +insert into Employee (id, version) values (2, 2); +insert into Employee (id, version) values (3, 3); +insert into Employee (id, version) values (4, 4); +insert into Employee (id, version) values (5, 5); +insert into Employee (id, version) values (6, 6); +insert into Employee (id, version) values (7, 7); +insert into Employee (id, version) values (8, 8); +insert into Employee (id, version) values (9, 9); +insert into Employee (id, version) values (10, 10); +insert into Employee (id, version) values (11, 11); +insert into Employee (id, version) values (12, 12); +insert into Employee (id, version) values (13, 13); +insert into Employee (id, version) values (14, 14); +insert into Employee (id, version) values (15, 15); +insert into Employee (id, version) values (16, 16); +insert into Employee (id, version) values (17, 17); +insert into Employee (id, version) values (18, 18); +insert into Employee (id, version) values (19, 19); +insert into Employee (id, version) values (20, 20); +insert into Employee (id, version) values (21, 21); +insert into Employee (id, version) values (22, 22); +insert into Employee (id, version) values (23, 23); +insert into Employee (id, version) values (24, 24); +insert into Employee (id, version) values (25, 25); +insert into Employee (id, version) values (26, 26); +insert into Employee (id, version) values (27, 27); +insert into Employee (id, version) values (28, 28); +insert into Employee (id, version) values (29, 29); +insert into Employee (id, version) values (30, 30); +insert into Employee (id, version) values (31, 31); +insert into Employee (id, version) values (32, 32); +insert into Employee (id, version) values (33, 33); +insert into Employee (id, version) values (34, 34); +insert into Employee (id, version) values (35, 35); +insert into Employee (id, version) values (36, 36); +insert into Employee (id, version) values (37, 37); +insert into Employee (id, version) values (38, 38); +insert into Employee (id, version) values (39, 39); +insert into Employee (id, version) values (40, 40); +insert into Employee (id, version) values (41, 41); +insert into Employee (id, version) values (42, 42); +insert into Employee (id, version) values (43, 43); +insert into Employee (id, version) values (44, 44); +insert into Employee (id, version) values (45, 45); +insert into Employee (id, version) values (46, 46); +insert into Employee (id, version) values (47, 47); +insert into Employee (id, version) values (48, 48); +insert into Employee (id, version) values (49, 49); +insert into Employee (id, version) values (50, 50); +insert into Employee (id, version) values (51, 51); +insert into Employee (id, version) values (52, 52); +insert into Employee (id, version) values (53, 53); +insert into Employee (id, version) values (54, 54); +insert into Employee (id, version) values (55, 55); +insert into Employee (id, version) values (56, 56); +insert into Employee (id, version) values (57, 57); +insert into Employee (id, version) values (58, 58); +insert into Employee (id, version) values (59, 59); +insert into Employee (id, version) values (60, 60); +insert into Employee (id, version) values (61, 61); +insert into Employee (id, version) values (62, 62); +insert into Employee (id, version) values (63, 63); +insert into Employee (id, version) values (64, 64); +insert into Employee (id, version) values (65, 65); +insert into Employee (id, version) values (66, 66); +insert into Employee (id, version) values (67, 67); +insert into Employee (id, version) values (68, 68); +insert into Employee (id, version) values (69, 69); +insert into Employee (id, version) values (70, 70); +insert into Employee (id, version) values (71, 71); +insert into Employee (id, version) values (72, 72); +insert into Employee (id, version) values (73, 73); +insert into Employee (id, version) values (74, 74); +insert into Employee (id, version) values (75, 75); +insert into Employee (id, version) values (76, 76); +insert into Employee (id, version) values (77, 77); +insert into Employee (id, version) values (78, 78); +insert into Employee (id, version) values (79, 79); +insert into Employee (id, version) values (80, 80); +insert into Employee (id, version) values (81, 81); +insert into Employee (id, version) values (82, 82); +insert into Employee (id, version) values (83, 83); +insert into Employee (id, version) values (84, 84); +insert into Employee (id, version) values (85, 85); +insert into Employee (id, version) values (86, 86); +insert into Employee (id, version) values (87, 87); +insert into Employee (id, version) values (88, 88); +insert into Employee (id, version) values (89, 89); +insert into Employee (id, version) values (90, 90); +insert into Employee (id, version) values (91, 91); +insert into Employee (id, version) values (92, 92); +insert into Employee (id, version) values (93, 93); +insert into Employee (id, version) values (94, 94); +insert into Employee (id, version) values (95, 95); +insert into Employee (id, version) values (96, 96); +insert into Employee (id, version) values (97, 97); +insert into Employee (id, version) values (98, 98); +insert into Employee (id, version) values (99, 99); +insert into Employee (id, version) values (100, 100); +insert into Employee (id, version) values (101, 101); +insert into Employee (id, version) values (102, 102); +insert into Employee (id, version) values (103, 103); +insert into Employee (id, version) values (104, 104); +insert into Employee (id, version) values (105, 105); +insert into Employee (id, version) values (106, 106); +insert into Employee (id, version) values (107, 107); +insert into Employee (id, version) values (108, 108); +insert into Employee (id, version) values (109, 109); +insert into Employee (id, version) values (110, 110); +insert into Employee (id, version) values (111, 111); +insert into Employee (id, version) values (112, 112); +insert into Employee (id, version) values (113, 113); +insert into Employee (id, version) values (114, 114); +insert into Employee (id, version) values (115, 115); +insert into Employee (id, version) values (116, 116); +insert into Employee (id, version) values (117, 117); +insert into Employee (id, version) values (118, 118); +insert into Employee (id, version) values (119, 119); +insert into Employee (id, version) values (120, 120); +insert into Employee (id, version) values (121, 121); +insert into Employee (id, version) values (122, 122); +insert into Employee (id, version) values (123, 123); +insert into Employee (id, version) values (124, 124); +insert into Employee (id, version) values (125, 125); +insert into Employee (id, version) values (126, 126); +insert into Employee (id, version) values (127, 127); +insert into Employee (id, version) values (128, 128); +insert into Employee (id, version) values (129, 129); +insert into Employee (id, version) values (130, 130); +insert into Employee (id, version) values (131, 131); +insert into Employee (id, version) values (132, 132); +insert into Employee (id, version) values (133, 133); +insert into Employee (id, version) values (134, 134); +insert into Employee (id, version) values (135, 135); +insert into Employee (id, version) values (136, 136); +insert into Employee (id, version) values (137, 137); +insert into Employee (id, version) values (138, 138); +insert into Employee (id, version) values (139, 139); +insert into Employee (id, version) values (140, 140); +insert into Employee (id, version) values (141, 141); +insert into Employee (id, version) values (142, 142); +insert into Employee (id, version) values (143, 143); +insert into Employee (id, version) values (144, 144); +insert into Employee (id, version) values (145, 145); +insert into Employee (id, version) values (146, 146); +insert into Employee (id, version) values (147, 147); +insert into Employee (id, version) values (148, 148); +insert into Employee (id, version) values (149, 149); +insert into Employee (id, version) values (150, 150); + + +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (1, 'BKTW', 'NORMAL', 'BKTW-1', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (2, 'KTW', 'MITTELHOCHDACH', 'KTW-2', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (3, 'KTW', 'MITTELHOCHDACH', 'KTW-3', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (4, 'BKTW', 'NORMAL', 'BKTW-4', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (5, 'RTW', 'HOCHDACH', 'RTW-5', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (6, 'RTW', 'HOCHDACH', 'RTW-6', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (7, 'BKTW', 'NORMAL', 'BKTW-7', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (8, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-8', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (9, 'RTW', 'HOCHDACH', 'RTW-9', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (10, 'RTW', 'HOCHDACH', 'RTW-10', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (11, 'RTW', 'HOCHDACH', 'RTW-11', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (12, 'RTW', 'HOCHDACH', 'RTW-12', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (13, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-13', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (14, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-14', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (15, 'BKTW', 'NORMAL', 'BKTW-15', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (16, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-16', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (17, 'KTW', 'MITTELHOCHDACH', 'KTW-17', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (18, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-18', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (19, 'RTW', 'HOCHDACH', 'RTW-19', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (20, 'RTW', 'HOCHDACH', 'RTW-20', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (21, 'RTW', 'HOCHDACH', 'RTW-21', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (22, 'BKTW', 'NORMAL', 'BKTW-22', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (23, 'RTW', 'HOCHDACH', 'RTW-23', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (24, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-24', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (25, 'KTW', 'MITTELHOCHDACH', 'KTW-25', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (26, 'RTW', 'HOCHDACH', 'RTW-26', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (27, 'KTW', 'MITTELHOCHDACH', 'KTW-27', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (28, 'KTW', 'MITTELHOCHDACH', 'KTW-28', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (29, 'BKTW', 'NORMAL', 'BKTW-29', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (30, 'RTW', 'HOCHDACH', 'RTW-30', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (31, 'RTW', 'HOCHDACH', 'RTW-31', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (32, 'RTW', 'HOCHDACH', 'RTW-32', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (33, 'RTW', 'HOCHDACH', 'RTW-33', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (34, 'KTW', 'MITTELHOCHDACH', 'KTW-34', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (35, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-35', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (36, 'RTW', 'HOCHDACH', 'RTW-36', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (37, 'RTW', 'HOCHDACH', 'RTW-37', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (38, 'BKTW', 'NORMAL', 'BKTW-38', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (39, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-39', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (40, 'RTW', 'HOCHDACH', 'RTW-40', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (41, 'RTW', 'HOCHDACH', 'RTW-41', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (42, 'KTW', 'MITTELHOCHDACH', 'KTW-42', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (43, 'RTW', 'HOCHDACH', 'RTW-43', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (44, 'RTW', 'HOCHDACH', 'RTW-44', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (45, 'RTW', 'HOCHDACH', 'RTW-45', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (46, 'RTW', 'HOCHDACH', 'RTW-46', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (47, 'KTW', 'MITTELHOCHDACH', 'KTW-47', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (48, 'BKTW', 'NORMAL', 'BKTW-48', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (49, 'RTW', 'HOCHDACH', 'RTW-49', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (50, 'RTW', 'HOCHDACH', 'RTW-50', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (51, 'NEF', 'NORMAL', 'NEF-51', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (52, 'NEF', 'NORMAL', 'NEF-52', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (53, 'NEF', 'NORMAL', 'NEF-53', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (54, 'NEF', 'NORMAL', 'NEF-54', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (55, 'NEF', 'NORMAL', 'NEF-55', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (56, 'NEF', 'NORMAL', 'NEF-56', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (57, 'NEF', 'NORMAL', 'NEF-57', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (58, 'NEF', 'NORMAL', 'NEF-58', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (59, 'NAH', 'NORMAL', 'NAH-59', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (60, 'NAH', 'NORMAL', 'NAH-60', true); + + +insert into Vehicle (id, version, status) values (1, 1, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (2, 2, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (3, 3, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (4, 4, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (5, 5, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (6, 6, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (7, 7, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (8, 8, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (9, 9, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (10, 10, 'ZUM_ZIELORT'); +insert into Vehicle (id, version, status) values (11, 11, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (12, 12, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (13, 13, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (14, 14, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (15, 15, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (16, 16, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (17, 17, 'ZUM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (18, 18, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (19, 19, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (20, 20, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (21, 21, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (22, 22, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (23, 23, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (24, 24, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (25, 25, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (26, 26, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (27, 27, 'AM_ZIELORT'); +insert into Vehicle (id, version, status) values (28, 28, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (29, 29, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (30, 30, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (31, 31, 'ZUM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (32, 32, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (33, 33, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (34, 34, 'AM_ZIELORT'); +insert into Vehicle (id, version, status) values (35, 35, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (36, 36, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (37, 37, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (38, 38, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (39, 39, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (40, 40, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (41, 41, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (42, 42, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (43, 43, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (44, 44, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (45, 45, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (46, 46, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (47, 47, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (48, 48, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (49, 49, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (50, 50, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (51, 51, 'ZUM_ZIELORT'); +insert into Vehicle (id, version, status) values (52, 52, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (53, 53, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (54, 54, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (55, 55, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (56, 56, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (57, 57, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (58, 58, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (59, 59, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (60, 60, 'FREI_WACHE'); + + +insert into Registration (id, vehicleId, employeeId, start, end, active) values (1, 5, 2, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (2, 5, 4, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (3, 46, 13, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (4, 46, 32, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (5, 32, 44, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (6, 32, 51, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (7, 45, 37, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (8, 45, 49, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (9, 14, 34, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (10, 14, 9, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (11, 11, 78, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (12, 11, 84, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (13, 47, 62, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (14, 47, 63, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (15, 41, 92, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (16, 41, 93, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (17, 50, 117, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (18, 50, 116, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (19, 17, 134, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (20, 17, 135, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (21, 42, 149, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (22, 42, 150, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (23, 12, 139, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (24, 12, 140, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (25, 34, 111, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (26, 34, 113, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (27, 22, 131, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (28, 31, 70, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (29, 31, 69, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (30, 38, 88, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (31, 49, 19, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (32, 49, 20, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (33, 40, 55, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (34, 40, 56, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (35, 26, 42, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (36, 26, 67, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (37, 36, 11, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (38, 36, 12, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (39, 37, 33, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (40, 37, 34, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (41, 37, 15, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (42, 20, 65, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (43, 20, 74, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (44, 44, 123, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (45, 44, 124, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (46, 28, 126, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (47, 28, 127, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (48, 10, 144, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (49, 10, 145, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (50, 2, 71, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (51, 2, 4, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (52, 23, 7, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (53, 23, 8, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (54, 9, 10, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (55, 9, 31, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (56, 59, 6, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (57, 59, 22, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (58, 59, 39, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (59, 60, 53, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (60, 60, 54, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (61, 60, 66, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (62, 51, 83, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (63, 51, 112, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (64, 52, 129, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (65, 52, 125, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (66, 53, 38, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (67, 53, 85, '2018-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +/*insert into Registration (id, vehicleId, employeeId, start, end, active) values (68, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (69, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (70, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (71, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (72, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (73, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (74, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (75, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (76, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (77, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (78, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (79, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (80, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (81, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (82, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (83, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (84, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (85, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (86, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (87, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (88, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (89, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (90, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (91, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (92, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (93, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (94, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (95, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (96, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (97, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (98, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (99, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (100, , , , , true);*/ + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (1, 'A', 'RD-10A4V', '2017-12-02T06:12:21Z', '0121 Golf Course Crossing', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (2, 'A', 'RD-26A6J', '2017-11-13T00:12:45Z', '75 Straubel Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (3, 'C', 'RD-65C9M', '2017-07-31T19:08:42Z', '3468 Lawn Trail', 'Junction', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (4, 'A', 'RD-51A8F', '2018-04-15T08:45:33Z', '11752 Farragut Pass', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (5, 'C', 'RD-18C3J', '2017-07-25T03:15:18Z', '546 Nova Place', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (6, 'A', 'RD-93A4D', '2017-11-07T22:33:38Z', '1 Shasta Crossing', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (7, 'O', 'RD-70O3C', '2017-08-16T20:18:10Z', '20076 Surrey Crossing', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (8, 'B', 'RD-76B9M', '2017-12-24T18:59:08Z', '214 Nova Hill', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (9, 'E', 'RD-40E5B', '2017-11-15T02:23:19Z', '3492 Atwood Alley', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (10, 'O', 'RD-70O2F', '2018-05-20T10:57:13Z', '655 Helena Junction', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (11, 'A', 'RD-35A7U', '2018-05-27T04:41:52Z', '200 Florence Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (12, 'A', 'RD-22A8J', '2017-08-11T07:22:54Z', '017 Cambridge Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (13, 'A', 'RD-43A6K', '2017-06-29T00:40:23Z', '59960 Longview Way', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (14, 'C', 'RD-74C8K', '2018-04-03T04:38:37Z', '5083 Luster Hill', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (15, 'C', 'RD-93C6T', '2017-11-30T18:39:02Z', '2 Moose Parkway', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (16, 'D', 'RD-35D8P', '2017-12-08T23:39:15Z', '9 Utah Trail', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (17, 'A', 'RD-26A9L', '2017-08-05T18:25:13Z', '7468 Commercial Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (18, 'E', 'RD-57E7X', '2017-08-12T06:26:53Z', '0 Eliot Alley', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (19, 'B', 'RD-84B8A', '2018-06-09T07:45:21Z', '05447 Division Plaza', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (20, 'C', 'RD-99C9L', '2018-04-28T16:41:06Z', '7 Jenifer Place', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (21, 'C', 'RD-85C9X', '2017-11-01T11:30:21Z', '350 Packers Avenue', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (22, 'A', 'RD-16A4K', '2018-05-03T01:57:10Z', '45577 Park Meadow Circle', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (23, 'B', 'RD-59B5Y', '2017-12-01T13:41:55Z', '7666 Grayhawk Terrace', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (24, 'C', 'RD-36C4V', '2018-05-02T14:45:08Z', '1520 Montana Court', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (25, 'A', 'RD-54A3B', '2018-01-27T13:02:43Z', '5478 Blackbird Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (26, 'A', 'RD-00A0Z', '2017-07-05T10:36:42Z', '668 Kenwood Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (27, 'B', 'RD-99B3Z', '2017-10-31T13:58:54Z', '4528 Meadow Ridge Way', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (28, 'E', 'RD-21E4B', '2018-03-06T15:19:53Z', '8269 Anthes Park', 'Alley', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (29, 'A', 'RD-68A4E', '2017-07-16T11:54:29Z', '34466 Mariners Cove Lane', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (30, 'A', 'RD-44A9N', '2017-11-16T22:07:30Z', '39 Shoshone Parkway', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (31, 'B', 'RD-28B1U', '2017-10-31T23:40:33Z', '9 Butternut Place', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (32, 'A', 'RD-19A8V', '2017-07-13T02:46:28Z', '9427 Clove Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (33, 'B', 'RD-03B9Q', '2017-08-21T06:54:03Z', '08242 Hintze Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (34, 'A', 'RD-33A0C', '2017-12-16T13:31:21Z', '9 Russell Terrace', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (35, 'A', 'RD-54A1E', '2017-11-18T01:08:02Z', '40776 Kings Street', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (36, 'B', 'RD-11B9D', '2017-07-16T14:58:14Z', '4379 Grover Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (37, 'A', 'RD-20A7H', '2018-04-12T17:25:55Z', '51626 Paget Drive', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (38, 'B', 'RD-74B2N', '2018-06-15T15:33:35Z', '4039 Northwestern Terrace', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (39, 'A', 'RD-14A2U', '2018-04-13T11:12:04Z', '174 Twin Pines Road', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (40, 'O', 'RD-85O8J', '2018-04-07T17:02:42Z', '15 Schiller Plaza', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (41, 'B', 'RD-17B8G', '2017-11-12T07:42:07Z', '446 Elka Drive', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (42, 'B', 'RD-16B1V', '2017-12-14T20:35:48Z', '0493 4th Road', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (43, 'A', 'RD-99A7V', '2017-06-29T17:17:53Z', '7815 Harper Place', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (44, 'O', 'RD-61O2F', '2017-07-15T08:41:09Z', '1388 Steensland Junction', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (45, 'A', 'RD-18A8M', '2017-12-05T14:06:22Z', '72 Golf Course Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (46, 'A', 'RD-97A2W', '2017-08-28T20:48:22Z', '7333 Alpine Street', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (47, 'A', 'RD-30A3J', '2018-01-26T00:15:01Z', '884 Stoughton Trail', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (48, 'O', 'RD-34O4J', '2018-06-01T01:21:24Z', '26 Riverside Lane', 'Pass', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (49, 'B', 'RD-18B6R', '2017-07-15T08:15:06Z', '04291 Dakota Way', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (50, 'A', 'RD-36A2Y', '2017-12-29T01:36:29Z', '403 Forest Run Park', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (51, 'A', 'RD-07A3U', '2017-10-23T11:03:53Z', '00758 Di Loreto Terrace', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (52, 'O', 'RD-62O3Y', '2018-04-05T00:45:16Z', '8 Orin Court', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (53, 'A', 'RD-18A7D', '2017-10-17T00:32:46Z', '98788 Golf Course Court', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (54, 'A', 'RD-11A4A', '2017-09-20T03:12:38Z', '567 Oak Valley Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (55, 'A', 'RD-30A2Y', '2017-11-06T08:00:24Z', '53 Fair Oaks Center', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (56, 'A', 'RD-17A3R', '2017-12-30T16:55:12Z', '075 Lighthouse Bay Junction', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (57, 'O', 'RD-18O4D', '2018-02-04T12:33:46Z', '54 Eagan Circle', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (58, 'A', 'RD-25A8I', '2017-09-26T20:36:01Z', '29 Troy Center', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (59, 'B', 'RD-20B1G', '2018-04-05T04:58:38Z', '8892 Kensington Way', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (60, 'A', 'RD-14A9B', '2017-06-27T04:49:09Z', '031 Cody Junction', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (61, 'A', 'RD-03A6S', '2017-09-10T00:46:34Z', '21 Steensland Place', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (62, 'O', 'RD-41O3V', '2017-07-06T02:08:29Z', '27757 Sycamore Point', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (63, 'O', 'RD-36O6T', '2018-04-20T08:06:43Z', '876 Service Pass', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (64, 'A', 'RD-42A2T', '2017-09-24T16:11:48Z', '1 Mitchell Park', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (65, 'A', 'RD-21A9L', '2018-06-11T06:03:37Z', '73686 Merrick Trail', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (66, 'C', 'RD-89C5M', '2018-03-10T16:46:56Z', '5168 Pine View Park', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (67, 'A', 'RD-10A6K', '2018-05-18T15:17:28Z', '304 Dunning Park', 'Way', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (68, 'C', 'RD-09C7S', '2018-03-08T18:52:12Z', '0 Londonderry Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (69, 'B', 'RD-75B8D', '2017-09-26T00:11:54Z', '00 Elgar Alley', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (70, 'O', 'RD-43O2V', '2017-09-02T02:56:49Z', '5969 Elmside Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (71, 'A', 'RD-24A0R', '2017-09-04T14:27:20Z', '865 Autumn Leaf Circle', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (72, 'B', 'RD-82B3A', '2018-06-03T20:09:15Z', '449 Commercial Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (73, 'A', 'RD-59A3A', '2017-11-11T20:43:16Z', '3 Banding Hill', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (74, 'B', 'RD-98B1G', '2017-06-20T12:39:45Z', '4303 Barby Road', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (75, 'A', 'RD-61A5L', '2018-03-09T18:55:16Z', '0 Macpherson Lane', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (76, 'B', 'RD-72B8U', '2018-04-27T22:48:48Z', '4 Boyd Court', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (77, 'C', 'RD-63C3M', '2018-04-18T02:49:03Z', '3596 Miller Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (78, 'A', 'RD-03A9D', '2017-10-20T16:01:25Z', '2 Crescent Oaks Park', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (79, 'A', 'RD-62A5V', '2018-01-02T14:59:58Z', '0089 Jackson Plaza', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (80, 'B', 'RD-36B2C', '2018-04-11T00:56:22Z', '3741 Spaight Circle', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (81, 'A', 'RD-19A7E', '2018-05-05T00:17:49Z', '90 Fair Oaks Place', 'Avenue', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (82, 'B', 'RD-90B8G', '2017-08-06T00:47:06Z', '6 Fremont Street', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (83, 'A', 'RD-28A0V', '2018-01-19T13:36:34Z', '20 Arrowood Parkway', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (84, 'A', 'RD-71A0B', '2018-01-09T15:30:57Z', '060 Badeau Park', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (85, 'B', 'RD-49B7X', '2018-02-07T18:46:02Z', '97261 Burning Wood Hill', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (86, 'B', 'RD-55B0F', '2018-02-02T03:23:51Z', '13987 Corscot Way', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (87, 'A', 'RD-79A5X', '2017-08-02T02:50:44Z', '90 Dexter Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (88, 'A', 'RD-04A7T', '2017-11-06T07:18:03Z', '619 Graedel Court', 'Way', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (89, 'C', 'RD-85C1G', '2017-12-17T18:50:36Z', '7 Fremont Avenue', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (90, 'O', 'RD-40O9Z', '2017-11-19T08:07:26Z', '79953 Fair Oaks Drive', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (91, 'C', 'RD-08C4Z', '2018-03-21T02:49:58Z', '7779 Monterey Street', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (92, 'A', 'RD-13A5U', '2017-09-29T05:21:06Z', '7 Little Fleur Road', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (93, 'B', 'RD-02B2E', '2017-08-04T17:00:43Z', '34572 Old Shore Crossing', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (94, 'A', 'RD-11A9X', '2017-08-27T23:59:41Z', '858 Spenser Drive', 'Avenue', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (95, 'B', 'RD-95B6D', '2018-01-07T01:49:50Z', '98 Jenifer Terrace', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (96, 'A', 'RD-47A7T', '2017-07-02T09:57:56Z', '209 Talmadge Lane', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (97, 'O', 'RD-78O1Z', '2017-12-10T15:02:21Z', '5348 Blackbird Pass', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (98, 'A', 'RD-72A5Y', '2017-12-23T10:48:06Z', '394 Anzinger Avenue', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (99, 'C', 'RD-78C4D', '2017-12-26T03:29:27Z', '115 Petterle Crossing', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (100, 'A', 'RD-17A9I', '2017-10-05T17:45:19Z', '533 Transport Way', 'Crossing', 'COMPLETED'); + + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (101, 'A', 'RD-74A1G', '2018-02-05T15:37:44Z', '625 Veith Center', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (102, 'B', 'RD-15B1U', '2017-10-20T04:54:38Z', '9 Westport Alley', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (103, 'O', 'RD-62O0B', '2018-02-05T12:18:43Z', '87559 Sherman Terrace', 'Court', 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (104, 'A', 'RD-45A0Y', '2018-05-17T17:08:18Z', '8 Delladonna Lane', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (105, 'A', 'RD-42A8G', '2018-05-03T01:52:39Z', '7 Superior Drive', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (106, 'O', 'RD-03O0G', '2018-01-21T17:21:12Z', '72 Darwin Point', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (107, 'A', 'RD-94A0W', '2017-11-08T06:11:31Z', '7168 Anniversary Way', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (108, 'A', 'RD-18A1E', '2018-02-20T15:51:48Z', '2023 Barby Road', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (109, 'A', 'RD-11A2I', '2018-02-07T06:42:04Z', '1901 Mesta Street', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (110, 'O', 'RD-78O0A', '2018-01-02T21:11:05Z', '6 David Trail', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (111, 'B', 'RD-70B6R', '2017-11-23T11:35:51Z', '188 Golden Leaf Avenue', 'Road', 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (112, 'B', 'RD-95B9K', '2018-02-03T06:44:16Z', '805 Jenna Alley', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (113, 'A', 'RD-58A3E', '2017-08-18T08:46:01Z', '954 Oriole Hill', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (114, 'B', 'RD-58B5V', '2017-06-19T12:47:16Z', '2503 East Road', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (115, 'A', 'RD-93A3V', '2018-03-04T16:46:37Z', '2 Northview Terrace', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (116, 'B', 'RD-25B6N', '2018-01-05T13:49:50Z', '43459 Crownhardt Crossing', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (117, 'A', 'RD-01A3J', '2017-08-08T05:23:13Z', '13 Kedzie Road', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (118, 'B', 'RD-70B9E', '2017-09-25T14:22:46Z', '49 Westridge Point', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (119, 'A', 'RD-18A6U', '2018-01-15T22:08:09Z', '6109 Kennedy Court', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (120, 'O', 'RD-27O6C', '2017-10-06T11:55:04Z', '590 Golf Terrace', null, 'CANCELLED'); + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (121, 'C', 'RD-34C5U', '2018-06-18T02:58:38Z', '1909 Cascade Drive', 'Hill', 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (122, 'B', 'RD-55B4X', '2018-06-18T03:55:21Z', '7 Rigney Parkway', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (123, 'C', 'RD-41C0X', '2018-06-18T06:35:58Z', '86986 Mcbride Court', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (124, 'A', 'RD-60A5T', '2018-06-18T14:33:37Z', '14649 Manley Park', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (125, 'D', 'RD-95D8H', '2018-06-18T09:15:13Z', '50 Magdeline Road', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (126, 'A', 'RD-16A9F', '2018-06-18T01:28:09Z', '25241 Bowman Alley', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (127, 'A', 'RD-33A1C', '2018-06-18T16:49:43Z', '59864 Rutledge Avenue', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (128, 'B', 'RD-49B4F', '2018-06-18T06:10:37Z', '43 Longview Crossing', null, 'ACTIVE'); + +--(51|52|53|59|60|2|5|9|10|11|12|14|17|20|22|23|26|28|31|32|34|36|37|38|40|41|42|44|45|46|47|49|50) + +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,1); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,2); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,3); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,4); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,5); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,6); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,7); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,8); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,9); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,10); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,11); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,12); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,13); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,14); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,15); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,16); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,17); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,18); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,19); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,20); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,21); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,22); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,23); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,24); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,25); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,26); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,27); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,28); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,29); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,30); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,31); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,32); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,33); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,34); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,35); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,36); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,37); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,38); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,39); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,40); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,41); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,42); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,43); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,44); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,45); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,46); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,47); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,48); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,49); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,50); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,51); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,52); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,53); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,54); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,55); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,56); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,57); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,58); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,59); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,60); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,61); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,62); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,63); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,64); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,65); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,66); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,67); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,68); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,69); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (14,70); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (52,71); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,72); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,73); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,74); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,75); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,76); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,77); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,78); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,79); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,80); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,81); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,82); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,83); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,84); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,85); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,86); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,87); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,88); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,89); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,90); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,91); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,92); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,93); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,94); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,95); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,96); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,97); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,98); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,99); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,100); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,101); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,102); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,103); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,104); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,105); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,106); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,107); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,108); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,109); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,110); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,111); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,112); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,113); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,114); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,115); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,116); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,117); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,118); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,119); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,120); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,121); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,122); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,123); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,124); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,125); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,125); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,126); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (27,127); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,128); -- cgit v1.2.3-70-g09d2 From 17556e5701442e9c2a7e219c5d93734812344ebe Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Mon, 18 Jun 2018 20:13:05 +0200 Subject: Rename 'einsatzverwaltung' to 'missioncontrol' + remove TODO [#25963] --- .../groupphase/application/MainApplication.java | 4 +- .../controller/ArchiveOperationController.java | 213 ------------ .../controller/CreateCarController.java | 231 ------------- .../controller/CreateNewEmployeeController.java | 174 ---------- .../controller/CreateOperationController.java | 371 --------------------- .../controller/CustomListItemController.java | 24 -- .../DetailArchiveOperationController.java | 77 ----- .../controller/EmployeeListController.java | 133 -------- .../controller/EmployeeListItemController.java | 87 ----- .../controller/FilterEmployeesController.java | 65 ---- .../einsatzverwaltung/controller/Helper.java | 34 -- .../controller/ManageEmployeesController.java | 120 ------- .../controller/OperationDetailsController.java | 169 ---------- .../controller/OperationInArchiveController.java | 65 ---- .../controller/RegistrationWindowController.java | 279 ---------------- .../controller/VehiclePaneController.java | 118 ------- .../einsatzverwaltung/dao/EmployeeDAO.java | 44 --- .../einsatzverwaltung/dao/EmployeeDatabaseDAO.java | 144 -------- .../einsatzverwaltung/dao/OperationDAO.java | 48 --- .../dao/OperationDatabaseDAO.java | 221 ------------ .../einsatzverwaltung/dao/RegistrationDAO.java | 28 -- .../dao/RegistrationDatabaseDAO.java | 130 -------- .../einsatzverwaltung/dao/VehicleDAO.java | 54 --- .../einsatzverwaltung/dao/VehicleDatabaseDAO.java | 211 ------------ .../groupphase/einsatzverwaltung/dto/Employee.java | 51 --- .../einsatzverwaltung/dto/EmployeeValidator.java | 23 -- .../einsatzverwaltung/dto/Operation.java | 70 ---- .../einsatzverwaltung/dto/Registration.java | 34 -- .../dto/RegistrationValidator.java | 174 ---------- .../groupphase/einsatzverwaltung/dto/Vehicle.java | 73 ---- .../einsatzverwaltung/service/EmployeeService.java | 46 --- .../service/EmployeeServiceImpl.java | 59 ---- .../service/OperationService.java | 70 ---- .../service/OperationServiceImpl.java | 286 ---------------- .../service/RegistrationService.java | 32 -- .../service/RegistrationServiceImpl.java | 52 --- .../einsatzverwaltung/service/VehicleService.java | 49 --- .../service/VehicleServiceImpl.java | 116 ------- .../controller/ArchiveOperationController.java | 213 ++++++++++++ .../controller/CreateCarController.java | 231 +++++++++++++ .../controller/CreateNewEmployeeController.java | 174 ++++++++++ .../controller/CreateOperationController.java | 371 +++++++++++++++++++++ .../controller/CustomListItemController.java | 24 ++ .../DetailArchiveOperationController.java | 77 +++++ .../controller/EmployeeListController.java | 133 ++++++++ .../controller/EmployeeListItemController.java | 87 +++++ .../controller/FilterEmployeesController.java | 65 ++++ .../missioncontrol/controller/Helper.java | 34 ++ .../controller/ManageEmployeesController.java | 120 +++++++ .../controller/OperationDetailsController.java | 169 ++++++++++ .../controller/OperationInArchiveController.java | 65 ++++ .../controller/RegistrationWindowController.java | 279 ++++++++++++++++ .../controller/VehiclePaneController.java | 118 +++++++ .../groupphase/missioncontrol/dao/EmployeeDAO.java | 44 +++ .../missioncontrol/dao/EmployeeDatabaseDAO.java | 144 ++++++++ .../missioncontrol/dao/OperationDAO.java | 48 +++ .../missioncontrol/dao/OperationDatabaseDAO.java | 221 ++++++++++++ .../missioncontrol/dao/RegistrationDAO.java | 28 ++ .../dao/RegistrationDatabaseDAO.java | 130 ++++++++ .../groupphase/missioncontrol/dao/VehicleDAO.java | 54 +++ .../missioncontrol/dao/VehicleDatabaseDAO.java | 211 ++++++++++++ .../groupphase/missioncontrol/dto/Employee.java | 51 +++ .../missioncontrol/dto/EmployeeValidator.java | 23 ++ .../groupphase/missioncontrol/dto/Operation.java | 70 ++++ .../missioncontrol/dto/Registration.java | 34 ++ .../missioncontrol/dto/RegistrationValidator.java | 174 ++++++++++ .../groupphase/missioncontrol/dto/Vehicle.java | 73 ++++ .../missioncontrol/service/EmployeeService.java | 46 +++ .../service/EmployeeServiceImpl.java | 59 ++++ .../missioncontrol/service/OperationService.java | 70 ++++ .../service/OperationServiceImpl.java | 286 ++++++++++++++++ .../service/RegistrationService.java | 32 ++ .../service/RegistrationServiceImpl.java | 52 +++ .../missioncontrol/service/VehicleService.java | 49 +++ .../missioncontrol/service/VehicleServiceImpl.java | 116 +++++++ src/main/resources/fxml/ArchiveOperation.fxml | 2 +- .../resources/fxml/CreateOperationController.fxml | 2 +- .../resources/fxml/DetailArchiveOperation.fxml | 2 +- src/main/resources/fxml/OperationDetails.fxml | 2 +- src/main/resources/fxml/OperationInArchive.fxml | 2 +- src/main/resources/fxml/RegistrationWindow.fxml | 2 +- src/main/resources/fxml/createCar.fxml | 2 +- src/main/resources/fxml/createNewEmployee.fxml | 2 +- src/main/resources/fxml/employeeList.fxml | 2 +- src/main/resources/fxml/employeeListItem.fxml | 2 +- .../resources/fxml/filterEmployeesControl.fxml | 2 +- src/main/resources/fxml/manageEmployees.fxml | 2 +- src/main/resources/fxml/vehiclePane.fxml | 2 +- .../CreateNewEmployeeControllerTest.java | 87 ----- .../controller/CreateNewVehicleControllerTest.java | 81 ----- .../controller/GuiTestApplication.java | 101 ------ .../controller/RegistrationControllerTest.java | 22 -- .../einsatzverwaltung/dao/EmployeeDAOTest.java | 253 -------------- .../einsatzverwaltung/dao/OperationDAOTest.java | 197 ----------- .../einsatzverwaltung/dao/RegistrationDAOTest.java | 115 ------- .../einsatzverwaltung/dao/VehicleDAOTest.java | 161 --------- .../service/EmployeeServiceTest.java | 67 ---- .../service/OperationServiceIntegrationTest.java | 97 ------ .../service/OperationServiceTest.java | 205 ------------ .../RegistrationServiceIntegrationTest.java | 55 --- .../service/RegistrationServiceTest.java | 159 --------- .../CreateNewEmployeeControllerTest.java | 87 +++++ .../controller/CreateNewVehicleControllerTest.java | 81 +++++ .../controller/GuiTestApplication.java | 101 ++++++ .../controller/RegistrationControllerTest.java | 22 ++ .../missioncontrol/dao/EmployeeDAOTest.java | 253 ++++++++++++++ .../missioncontrol/dao/OperationDAOTest.java | 197 +++++++++++ .../missioncontrol/dao/RegistrationDAOTest.java | 115 +++++++ .../missioncontrol/dao/VehicleDAOTest.java | 161 +++++++++ .../service/EmployeeServiceTest.java | 67 ++++ .../service/OperationServiceIntegrationTest.java | 97 ++++++ .../service/OperationServiceTest.java | 205 ++++++++++++ .../RegistrationServiceIntegrationTest.java | 55 +++ .../service/RegistrationServiceTest.java | 159 +++++++++ 114 files changed, 5789 insertions(+), 5791 deletions(-) delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CustomListItemController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/DetailArchiveOperationController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ManageEmployeesController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceImpl.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleServiceImpl.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeControllerTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleControllerTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/GuiTestApplication.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationControllerTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAOTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAOTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAOTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceIntegrationTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceIntegrationTest.java delete mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeControllerTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewVehicleControllerTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/GuiTestApplication.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationControllerTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAOTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAOTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAOTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAOTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceIntegrationTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceIntegrationTest.java create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceTest.java (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java index 87daea4..a6c0566 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java @@ -1,6 +1,6 @@ package at.ac.tuwien.sepm.assignment.groupphase.application; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateOperationController; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.CreateOperationController; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; import javafx.application.Application; @@ -34,8 +34,6 @@ public class MainApplication extends Application { Platform.exit(); }); - // TODO: close connection on program exit (feedback) - configApplicationContext = new AnnotationConfigApplicationContext(MainApplication.class); final var fxmlLoader = configApplicationContext.getBean(SpringFXMLLoader.class); primaryStage.setScene( diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java deleted file mode 100644 index 9ac6a1a..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java +++ /dev/null @@ -1,213 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.ZoneOffset; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import javafx.fxml.FXML; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class ArchiveOperationController { - - private static final Logger LOG = LoggerFactory.getLogger(ArchiveOperationController.class); - - @FXML private ImageView imvVehicleDetail; - @FXML private Label lblStatus; - @FXML private AnchorPane apMainDetails; - @FXML private Label lblOperations; - @FXML private Label lblCompleted; - @FXML private Label lblCancelled; - @FXML private AnchorPane backApMain; - @FXML private AnchorPane backApDetails; - @FXML private AnchorPane archiveOperationAP; - @FXML private AnchorPane apDetails; - @FXML private Label lblCodeHeader; - @FXML private Label lblOpCode; - @FXML private Label lblVehicles; - @FXML private Label lblDate; - @FXML private Label lblAddress; - @FXML private FlowPane fpVehicles; - private final OperationService operationService; - @FXML private FlowPane archiveOperationFlowPane; - private final CreateOperationController createOperationController; - private Set list = new HashSet<>(); - private final SpringFXMLLoader fxmlLoader; - - public ArchiveOperationController( - OperationService operationService, - CreateOperationController createOperationController, - SpringFXMLLoader fxmlLoader) { - this.operationService = operationService; - this.createOperationController = createOperationController; - this.fxmlLoader = fxmlLoader; - } - - @FXML - private void initialize() { - update(); - } - - public void update() { - archiveOperationFlowPane.getChildren().clear(); - list.clear(); - try { - list.addAll(operationService.list(EnumSet.of(Status.CANCELLED, Status.COMPLETED))); - long cancelledAmount = 0; - long completedAmount = 0; - for (Operation operation : list) { - if (operation.status() == Status.CANCELLED) cancelledAmount++; - else completedAmount++; - } - lblCancelled.setText("storniert: " + cancelledAmount); - lblCompleted.setText("abgeschlossen: " + completedAmount); - lblOperations.setText("Einsätze: " + list.size()); - } catch (ServiceException e) { - LOG.error("ServiceException in update().", e); - showServiceExceptionAlertAndWait("Die Einsätze konnten nicht geladen werden!"); - ; - } - setFlowPane(); - } - - private void setFlowPane() { - try { - archiveOperationFlowPane.getChildren().clear(); - for (Operation operation : sortSet(list)) { - OperationInArchiveController opInAController = - OperationInArchiveController.create(); - opInAController.set(operation); - opInAController - .getRoot() - .setOnMouseClicked( - event -> { - detailOperation = operation; - backApMain.setVisible(false); - apMainDetails.setVisible(false); - backApDetails.setVisible(true); - setOperation(); - setDetailsVisible(true); - imvVehicleDetail.setImage(new Image("/images/Vehicle.png")); - }); - archiveOperationFlowPane.getChildren().add(opInAController.getRoot()); - } - } catch (IOException e) { - LOG.error("IOException in setFlowPane(). ", e); - showServiceExceptionAlertAndWait("Die Elemente konnten nicht geladen werden!"); - } - } - - private Operation detailOperation; - - private List sortSet(Set operationsSet) { - Operation[] array = operationsSet.toArray(new Operation[operationsSet.size()]); - for (int i = array.length - 1; i > 0; i--) { - for (int j = 0; j < i; j++) { - LocalDateTime first = - LocalDateTime.ofInstant( - Objects.requireNonNull(array[j].created()), ZoneOffset.UTC); - LocalDateTime second = - LocalDateTime.ofInstant( - Objects.requireNonNull(array[j + 1].created()), ZoneOffset.UTC); - if (first.isBefore(second)) { - Operation help = array[j]; - array[j] = array[j + 1]; - array[j + 1] = help; - } - } - } - return Arrays.asList(array); - } - - private void setOperation() { - lblCodeHeader.setText(detailOperation.opCode()); - if (detailOperation.created() != null) { - LocalDateTime dateTime = - LocalDateTime.ofInstant( - Objects.requireNonNull(detailOperation.created()), ZoneOffset.UTC); - lblDate.setText( - "am " - + dateTime.getDayOfMonth() - + "." - + dateTime.getMonth().getValue() - + "." - + dateTime.getYear()); - } else { - lblDate.setText("---"); - } - lblStatus.setText( - "Status: " - + (detailOperation.status() == Status.CANCELLED - ? "storniert" - : "abgeschlossen")); - lblOpCode.setText(detailOperation.opCode()); - Collection elements = - detailOperation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); - String result = String.join(", ", elements); - - lblVehicles.setText(result); - lblAddress.setText(detailOperation.destination()); - - fpVehicles.getChildren().clear(); - try { - for (Vehicle vehicle : detailOperation.vehicles()) { - DetailArchiveOperationController controller = null; - - controller = DetailArchiveOperationController.create(fxmlLoader); - - controller.set(vehicle); - fpVehicles.getChildren().add(controller.getRoot()); - } - } catch (IOException e) { - LOG.error("IOException in setOperation(). ", e); - showServiceExceptionAlertAndWait("Die Element konnte nicht geladen werden!"); - } - } - - private void setDetailsVisible(boolean b) { - apDetails.setVisible(b); - } - - public void backClicked() { - LOG.debug("Hyperlink \"Zurück\" in archive detail view clicked."); - fpVehicles.getChildren().clear(); - setDetailsVisible(false); - backApDetails.setVisible(false); - apMainDetails.setVisible(true); - backApMain.setVisible(true); - } - - public void backToMain() { - LOG.debug("Hyperlink \"Zurück\" in archive main view clicked."); - this.setVisible(false); - createOperationController.setVisible(true); - } - - void setVisible(boolean b) { - archiveOperationAP.setVisible(b); - backApMain.setVisible(b); - apMainDetails.setVisible(b); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java deleted file mode 100644 index 0734820..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java +++ /dev/null @@ -1,231 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showSuccessAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showValidationErrorAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.io.IOException; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javafx.collections.FXCollections; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ChoiceBox; -import javafx.scene.input.MouseButton; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class CreateCarController { - - @FXML private AnchorPane createCarAP; - @FXML private ChoiceBox cmbCtype; - @FXML private ChoiceBox cmbTyp; - - @FXML private Button btnCreate; - @FXML private CheckBox cbxNEF; - @FXML private FlowPane fpVehicleList; - private final CreateOperationController createOperationController; - - private static final Logger LOG = LoggerFactory.getLogger(CreateCarController.class); - private final VehicleService vehicleService; - private boolean update = false; - private long vid = -1; - - private Vehicle chooseVehicle; - - public CreateCarController( - CreateOperationController createOperationController, VehicleService vehicleService) { - this.createOperationController = createOperationController; - this.vehicleService = vehicleService; - } - - @FXML - private void initialize() { - fpVehicleList.setHgap(5); - fpVehicleList.setVgap(5); - - cmbCtype.setItems( - FXCollections.observableArrayList( - Stream.of( - ConstructionType.NORMAL, - ConstructionType.MITTELHOCHDACH, - ConstructionType.HOCHDACH) - .map(Enum::toString) - .collect(Collectors.toList()))); - cmbCtype.setValue(ConstructionType.NORMAL.toString()); - cmbTyp.setItems( - FXCollections.observableArrayList( - Stream.of( - VehicleType.BKTW, - VehicleType.KTW_B, - VehicleType.KTW, - VehicleType.RTW, - VehicleType.NEF, - VehicleType.NAH) - .map(Enum::toString) - .collect(Collectors.toList()))); - cmbTyp.setValue(VehicleType.BKTW.toString()); - - updateVehiclePane(); - } - - @FXML - private void createCar(ActionEvent actionEvent) { - - if (!update) { - LOG.debug("Button \"Erstellen\" clicked."); - Vehicle vehicle = - Vehicle.builder() - .constructionType(parseConstructionType()) - .type(parseType()) - .name("") - .status(Status.ABGEMELDET) - .hasNef(cbxNEF.isSelected()) - .build(); - try { - vehicleService.add(vehicle); - setToStart(); - } catch (InvalidVehicleException e) { - LOG.debug("Validation of Vehicle failed"); - showValidationErrorAlertAndWait(e.getMessage()); - setToStart(); - return; - } catch (ServiceException e) { - LOG.error("ServiceException in createCar(). ", e); - showServiceExceptionAlertAndWait( - "Ein Fehler beim Erstellen des Fahrzeuges ist aufgetreten."); - setToStart(); - return; - } - showSuccessAlertAndWait("Auto wurde erfolgreich angelegt."); - } else { - LOG.debug("Button \"Speichern\" clicked."); - try { - Vehicle vehicle = - Vehicle.builder() - .id(vid) - .constructionType(parseConstructionType()) - .type(parseType()) - .name("") - .status(Status.ABGEMELDET) - .hasNef(cbxNEF.isSelected()) - .build(); - vehicleService.update(vehicle); - setToStart(); - chooseVehicle = null; - } catch (InvalidVehicleException e) { - LOG.debug("Validation of Vehicle failed"); - showValidationErrorAlertAndWait(e.getMessage()); - setToStart(); - return; - } catch (ServiceException e) { - LOG.error("ServiceException in createCar(). ", e); - showServiceExceptionAlertAndWait(e.getMessage()); - setToStart(); - return; - } - showSuccessAlertAndWait("Auto wurde erfolgreich bearbeitet."); - } - - updateVehiclePane(); - } - - private ConstructionType parseConstructionType() { - if (cmbCtype.getSelectionModel().getSelectedItem() == null) { - return ConstructionType.NORMAL; - } - return ConstructionType.valueOf(cmbCtype.getSelectionModel().getSelectedItem()); - } - - private VehicleType parseType() { - if (cmbTyp.getSelectionModel().getSelectedItem() == null) { - return VehicleType.BKTW; - } - return VehicleType.valueOf(cmbTyp.getSelectionModel().getSelectedItem()); - } - - private void setToStart() { - btnCreate.setText("Erstellen"); - cbxNEF.setSelected(false); - cmbTyp.setValue(VehicleType.BKTW.name()); - cmbCtype.setValue(ConstructionType.NORMAL.name()); - update = false; - } - - private void updateVehicle(Vehicle vehicle) { - - cmbCtype.setValue(vehicle.constructionType().name()); - cmbTyp.setValue(vehicle.type().name()); - cbxNEF.setSelected(vehicle.hasNef()); - btnCreate.setText("Speichern"); - vid = vehicle.id(); - update = true; - chooseVehicle = vehicle; - } - - public void setVisible(boolean b) { - createCarAP.setVisible(b); - } - - @FXML - private void backToMain() { - LOG.debug("Hyperlink \"zurück\" clicked."); - this.setVisible(false); - createOperationController.setVisible(true); - } - - private void updateVehiclePane() { - try { - fpVehicleList.getChildren().clear(); - - Set vehicles; - - vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); - - for (Vehicle vehicle : vehicles) { - VehiclePaneController controller = VehiclePaneController.createVehiclePane(); - - controller.setData(vehicle, false, false); - controller - .getRootElement() - .setOnMouseClicked( - event -> { - if (event.getButton().equals(MouseButton.PRIMARY)) { - if (chooseVehicle == null || vehicle == chooseVehicle) { - if (update == false) { - chooseVehicle = vehicle; - updateVehicle(vehicle); - controller.setSelected(true); - } else { - setToStart(); - controller.setSelected(false); - - chooseVehicle = null; - } - } - } - }); - - fpVehicleList.getChildren().add(controller.getRootElement()); - } - } catch (ServiceException | IOException e) { - LOG.error("Exception in updateVehiclePane(). ", e); - showServiceExceptionAlertAndWait(e.getMessage()); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java deleted file mode 100644 index 5f0a8b2..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java +++ /dev/null @@ -1,174 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showSuccessAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showValidationErrorAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; -import java.io.IOException; -import java.time.LocalDate; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javafx.collections.FXCollections; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; - -@Controller -@Scope("prototype") -public class CreateNewEmployeeController { - - private static final Logger LOG = LoggerFactory.getLogger(CreateNewEmployeeController.class); - private final EmployeeService employeeService; - - @FXML private Label lblHeader; - @FXML private CheckBox inputIsDriver; - @FXML private CheckBox inputIsPilot; - @FXML private TextField inputName; - @FXML private ChoiceBox inputQualification; - @FXML private Button btnCreate; - - private Node rootElement; - private Employee employee; - private boolean isEdit; - - private Runnable consumerCancelClicked; - private Runnable consumerCreateClicked; - - public CreateNewEmployeeController(EmployeeService employeeService) { - this.employeeService = employeeService; - } - - @FXML - private void initialize() { - inputQualification.setItems( - FXCollections.observableArrayList( - Stream.of( - EducationLevel.RS, - EducationLevel.NFS, - EducationLevel.NKV, - EducationLevel.NKA, - EducationLevel.NKI, - EducationLevel.NA) - .map(Enum::toString) - .collect(Collectors.toList()))); - - inputQualification.setValue(EducationLevel.RS.toString()); - employee = - Employee.builder() - .name("") - .educationLevel(EducationLevel.RS) - .isDriver(false) - .isPilot(false) - .birthday(LocalDate.MIN) - .build(); - } - - @FXML - private void onCancelClicked() { - LOG.debug("Hyperlink \"abbrechen\" clicked."); - if (consumerCancelClicked != null) { - consumerCancelClicked.run(); - } - } - - @FXML - private void onCreateClicked() { - LOG.debug("Button {} clicked.", btnCreate.getText()); - - employee = - employee.toBuilder() - .name(inputName.getText()) - .educationLevel(parseEducationLevel()) - .birthday(LocalDate.MIN) // TODO: change UI to include birthday field - .isDriver(inputIsDriver.isSelected()) - .isPilot(inputIsPilot.isSelected()) - .build(); - - try { - if (isEdit) { - employeeService.update(employee); - } else { - employeeService.add(employee); - } - } catch (InvalidEmployeeException e) { - LOG.debug("Validation for Employee failed"); - showValidationErrorAlertAndWait(e.getMessage()); - return; - } catch (ServiceException e) { - LOG.error("ServiceException in onCreateClicked(). ", e); - showServiceExceptionAlertAndWait( - "Der Eintrag konnte nicht gespeichert werden. Bitte versuchen Sie es erneut."); - return; - } - - showSuccessAlertAndWait( - "Der/die MitarbeiterIn wurde erfolgreich angelegt und gespeichert!"); - - if (consumerCreateClicked != null) { - consumerCreateClicked.run(); - } - } - - private EducationLevel parseEducationLevel() { - if (inputQualification.getSelectionModel().getSelectedItem() == null) { - return EducationLevel.RS; - } - return EducationLevel.valueOf(inputQualification.getSelectionModel().getSelectedItem()); - } - - private void setData(Employee employee) { - isEdit = true; - this.employee = employee; - inputName.setText(employee.name()); - inputQualification.setValue(employee.educationLevel().name()); - inputIsDriver.setSelected(employee.isDriver()); - inputIsPilot.setSelected(employee.isPilot()); - lblHeader.setText("Person bearbeiten"); - btnCreate.setText("Speichern"); - } - - public static CreateNewEmployeeController createCreateNewEmployeeController( - SpringFXMLLoader fxmlLoader, Employee employee) throws IOException { - CreateNewEmployeeController controller = createCreateNewEmployeeController(fxmlLoader); - controller.setData(employee); - return controller; - } - - public static CreateNewEmployeeController createCreateNewEmployeeController( - SpringFXMLLoader fxmlLoader) throws IOException { - FXMLWrapper wrapper = - fxmlLoader.loadAndWrap( - "/fxml/createNewEmployee.fxml", CreateNewEmployeeController.class); - Node root = (Node) wrapper.getLoadedObject(); - CreateNewEmployeeController controller = wrapper.getController(); - controller.rootElement = root; - return controller; - } - - public Node getRootElement() { - return rootElement; - } - - public void setConsumerCancelClicked(Runnable consumerCancelClicked) { - this.consumerCancelClicked = consumerCancelClicked; - } - - public void setConsumerCreateClicked(Runnable consumerCreateClicked) { - this.consumerCreateClicked = consumerCreateClicked; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java deleted file mode 100644 index 19ed7bf..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java +++ /dev/null @@ -1,371 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showSuccessAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showValidationErrorAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.io.IOException; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import javafx.collections.FXCollections; -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.Label; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.MenuItem; -import javafx.scene.control.TextField; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseButton; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane; -import javafx.scene.layout.GridPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class CreateOperationController { - - private static final Logger LOG = LoggerFactory.getLogger(CreateOperationController.class); - - public AnchorPane apCreateOperation; - @FXML private GridPane grdWindowContainer; - @FXML private TextField txtCode; - @FXML private TextField txtAddress; - @FXML private TextField txtNote; - @FXML private Button btnCreateOperation; - @FXML private ListView lvVehicles; - @FXML private ListView lvActiveOperations; - @FXML private Label lblChosenVehicles; - @FXML private AnchorPane apInvisible; - @FXML private OperationDetailsController operationDetailsController; - @FXML private ManageEmployeesController manageEmployeesController; - @FXML private CreateCarController createCarController; - @FXML private RegistrationWindowController registrationWindowController; - @FXML private ArchiveOperationController archiveOperationController; - @FXML private FlowPane fpVehicles; - - private LinkedList chosenVehicles = new LinkedList<>(); - - private final OperationService operationService; - private final VehicleService vehicleService; - - public CreateOperationController( - OperationService operationService, VehicleService vehicleService) { - this.operationService = operationService; - this.vehicleService = vehicleService; - } - - @FXML - private void initialize() { - - lblChosenVehicles.setText("keine ausgewählt"); - lvActiveOperations.setCellFactory(param -> generateOpCodeListItem()); - - lvActiveOperations.setOnMouseClicked( - event -> { - if (event.getClickCount() == 2) { - if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { - return; - } - openDetailsWindow(lvActiveOperations.getSelectionModel().getSelectedItem()); - } - }); - - setVisible(true); - createCarController.setVisible(false); - registrationWindowController.setVisible(false); - } - - public void updateList() { - try { - fpVehicles.getChildren().clear(); - - // TODO: this should probably be handled differently - Set vehicles; - if (txtCode.getText().isEmpty()) { - vehicles = - vehicleService.list( - EnumSet.complementOf(EnumSet.of(Vehicle.Status.ABGEMELDET))); - } else { - vehicles = operationService.rankVehicles(txtCode.getText()); - } - - for (Vehicle vehicle : vehicles) { - VehiclePaneController controller = VehiclePaneController.createVehiclePane(); - - controller.setData(vehicle, true, false); - controller - .getRootElement() - .setOnMouseClicked( - event -> { - if (event.getButton().equals(MouseButton.SECONDARY)) { - createContextMenu(vehicle, vehicleService) - .show( - controller.getRootElement(), - event.getScreenX(), - event.getScreenY()); - } else { - if (chosenVehicles.contains(vehicle)) { - chosenVehicles.remove(vehicle); - controller.setSelected(false); - } else { - chosenVehicles.add(vehicle); - controller.setSelected(true); - } - - StringBuilder result = new StringBuilder(); - for (int i = 0; i < chosenVehicles.size(); i++) { - if (i == chosenVehicles.size() - 1) { - result.append(chosenVehicles.get(i).name()); - } else { - result.append(chosenVehicles.get(i).name()) - .append(", "); - } - } - if (result.toString().equals("")) { - lblChosenVehicles.setText("keine ausgewählt"); - } else { - lblChosenVehicles.setText(result.toString()); - } - } - }); - - if (chosenVehicles.stream().anyMatch(v -> v.id() == vehicle.id())) - controller.setSelected(true); - - fpVehicles.getChildren().add(controller.getRootElement()); - } - } catch (ServiceException | IOException e) { - LOG.error("Exception in updateList(). ", e); - showServiceExceptionAlertAndWait( - "Beim Erstellen des Ranking ist ein Fehler aufgetreten."); - } catch (InvalidOperationException e) { - LOG.debug("Validation error in updateList(). ", e); - showValidationErrorAlertAndWait(e.getMessage()); - } - try { - lvActiveOperations.setItems( - FXCollections.observableArrayList( - operationService.list(EnumSet.of(Status.ACTIVE)))); - } catch (ServiceException e) { - LOG.error("ServiceException in updateList(). ", e); - showServiceExceptionAlertAndWait( - "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten"); - } - } - - private ContextMenu createContextMenu(Vehicle data, VehicleService vehicleService) { - ContextMenu menu = new ContextMenu(); - - for (Vehicle.Status status : Vehicle.Status.values()) { - if (status == Vehicle.Status.ABGEMELDET) { - continue; - } - - MenuItem mi = new MenuItem(status.name()); - - if (status == Vehicle.Status.FREI_FUNK || status == Vehicle.Status.FREI_WACHE) { - mi.getStyleClass().add("mi-free"); - } else { - mi.getStyleClass().add("mi-other"); - } - - mi.setOnAction( - event -> { - try { - vehicleService.update(data.toBuilder().status(status).build()); - this.updateList(); - } catch (InvalidVehicleException e) { - LOG.debug( - "Validation error in createContextMenu(). (mi.setOnAction) ", - e); - showValidationErrorAlertAndWait(e.getMessage()); - } catch (ServiceException e) { - LOG.error("Exception in createContextMenu(). (mi.setOnAction) ", e); - showServiceExceptionAlertAndWait( - "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten."); - } - }); - - menu.getItems().add(mi); - } - - MenuItem abmelden = new MenuItem("abmelden"); - - abmelden.setOnAction( - event -> { - try { - List registrations = data.registrations(); - assert registrations - != null; // Otherwise the element shouldn't be in the list. - - List newRegistrations = new ArrayList<>(); - Instant now = Instant.now(); - - for (Registration registration : registrations) { - if (registration.start().isBefore(now) - && registration.end().isAfter(now)) { - newRegistrations.add( - registration - .toBuilder() - .end(Instant.now().minus(1, ChronoUnit.SECONDS)) - .build()); - } else newRegistrations.add(registration); - } - - vehicleService.update( - data.toBuilder() - .registrations(newRegistrations) - .status(Vehicle.Status.ABGEMELDET) - .build()); - - this.updateList(); - } catch (InvalidVehicleException e) { - LOG.debug( - "Validation error in createContextMenu(). (abmelden.setOnAction) ", - e); - showValidationErrorAlertAndWait(e.getMessage()); - } catch (ServiceException e) { - LOG.error("Exception in createContextMenu(). (abmelden.setOnAction) ", e); - showServiceExceptionAlertAndWait( - "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten."); - } - }); - - menu.getItems().add(abmelden); - return menu; - } - - @FXML - protected void createOperationClicked() { - LOG.debug("Button \"Erstellen\" clicked."); - Vehicle[] vehicles = new Vehicle[chosenVehicles.size()]; - for (int i = 0; i < chosenVehicles.size(); i++) { - vehicles[i] = chosenVehicles.get(i); - } - Operation operation = - Operation.builder() - .additionalInfo(txtNote.getText()) - .destination(txtAddress.getText()) - .opCode(txtCode.getText()) - .status(Status.ACTIVE) - .vehicles(Set.of(vehicles)) - .build(); - try { - operationService.add(operation); - } catch (ServiceException e) { - LOG.error("Exception in createOperationClicked(). ", e); - showServiceExceptionAlertAndWait( - "Beim Erstellen des Einsatzes ist ein Fehler aufgetreten."); - return; - } catch (InvalidOperationException e) { - LOG.debug("Validation error in createOperationClicked(). ", e); - showValidationErrorAlertAndWait(e.getMessage()); - return; - } - showSuccessAlertAndWait("Der Einsatz wurde erfolgreich gespeichert."); - updateList(); - lblChosenVehicles.setText("keine ausgewählt"); - txtAddress.setText(""); - txtCode.setText(""); - txtNote.setText(""); - chosenVehicles = new LinkedList<>(); - } - - @FXML - private void onRegistrationLinkClicked() { - LOG.debug("Hyperlink \"Anmeldungen\" clicked."); - openRegistrationWindow(); - } - - @FXML - private void onEmployeeLinkClicked() { - LOG.debug("Hyperlink \"Personen\" clicked."); - openCreateNewEmployeeWindow(); - } - - @FXML - private void onVehicleLinkClicked() { - LOG.debug("Hyperlink \"Fahrzeuge\" clicked."); - openCreateCarWindow(); - } - - @FXML - private void onArchivLinkClicked() { - LOG.debug("Hyperlink \"Archiv\" clicked."); - archiveOperationController.update(); - openArchivWindow(); - } - - private void openArchivWindow() { - archiveOperationController.setVisible(true); - this.setVisible(false); - } - - void setVisible(boolean b) { - apInvisible.setVisible(!b); - grdWindowContainer.setVisible(!b); - - updateList(); - } - - private void openDetailsWindow(Operation operation) { - operationDetailsController.initOperation(operation); - this.setVisible(false); - } - - private void openCreateNewEmployeeWindow() { - this.setVisible(false); - manageEmployeesController.setVisible(true); - } - - private void openCreateCarWindow() { - this.setVisible(false); - createCarController.setVisible(true); - } - - private void openRegistrationWindow() { - this.setVisible(false); - registrationWindowController.setVisible(true); - } - - @FXML - private void onOperationCodeChanged(KeyEvent keyEvent) { - if (keyEvent.getCode() == KeyCode.ENTER) { - updateList(); - } - } - - static ListCell generateOpCodeListItem() { - return new ListCell<>() { - @Override - protected void updateItem(Operation item, boolean empty) { - super.updateItem(item, empty); - - if (empty || item == null || item.opCode() == null) { - setText(null); - } else { - setText(item.opCode()); - } - } - }; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CustomListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CustomListItemController.java deleted file mode 100644 index 79cf243..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CustomListItemController.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import javafx.scene.Node; - -public abstract class CustomListItemController { - - protected Node rootElement; - - public Node getRootElement() { - return rootElement; - } - - public void setSelected(boolean selected) { - rootElement.getStyleClass().clear(); - - if (selected) { - rootElement.getStyleClass().add("bg-yellow"); - rootElement.getStyleClass().add("shadowed"); - } else { - rootElement.getStyleClass().add("bg-white"); - rootElement.getStyleClass().add("shadowed"); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/DetailArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/DetailArchiveOperationController.java deleted file mode 100644 index 41bd2a6..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/DetailArchiveOperationController.java +++ /dev/null @@ -1,77 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; -import java.io.IOException; -import java.util.Objects; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.layout.VBox; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class DetailArchiveOperationController { - private static final Logger LOG = - LoggerFactory.getLogger(DetailArchiveOperationController.class); - - @FXML private VBox vBoxVehicle; - @FXML private VBox vBoxPeople; - private final SpringFXMLLoader fxmlLoader; - - public DetailArchiveOperationController(SpringFXMLLoader fxmlLoader) { - this.fxmlLoader = fxmlLoader; - } - - static DetailArchiveOperationController create(SpringFXMLLoader fxmlLoader) throws IOException { - FXMLWrapper wrapper = - fxmlLoader.loadAndWrap( - "/fxml/DetailArchiveOperation.fxml", - DetailArchiveOperationController.class); - - Node root = (Node) wrapper.getLoadedObject(); - DetailArchiveOperationController result = wrapper.getController(); - result.rootElement = root; - - return result; - } - - public Node getRoot() { - return rootElement; - } - - private Node rootElement; - - public void set(Vehicle vehicle) { - VehiclePaneController controller; - try { - controller = VehiclePaneController.createVehiclePane(); - controller.setData(vehicle, false, false); - vBoxVehicle.getChildren().add(controller.getRootElement()); - } catch (IOException e) { - LOG.error("IOException in set(Vehicle). (vBoxVehicle) ", e); - showServiceExceptionAlertAndWait( - "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); - } - try { - for (int i = 0; i < Objects.requireNonNull(vehicle.registrations()).size(); i++) { - Employee employee = - Objects.requireNonNull(vehicle.registrations()).get(i).employee(); - - EmployeeListItemController employeeListItemController = - EmployeeListItemController.createEmployeeListItemController( - fxmlLoader, employee); - vBoxPeople.getChildren().add(employeeListItemController.getRootElement()); - } - } catch (IOException e) { - LOG.error("IOException in set(Vehicle). (vBoxPeople) ", e); - showServiceExceptionAlertAndWait( - "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListController.java deleted file mode 100644 index 6e1159a..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListController.java +++ /dev/null @@ -1,133 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.layout.FlowPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; - -@Controller -@Scope("prototype") -public class EmployeeListController { - - private static final Logger LOG = LoggerFactory.getLogger(EmployeeListController.class); - - @FXML private FlowPane flowPaneEmployeeList; - - private Consumer onEmployeeClicked; - - private final SpringFXMLLoader fxmlLoader; - private Node rootElement; - private List employeeListItemControllers; - private Insets listItemMargins = new Insets(10, 5, 0, 5); - - public EmployeeListController(SpringFXMLLoader fxmlLoader) { - this.fxmlLoader = fxmlLoader; - this.employeeListItemControllers = new ArrayList<>(); - } - - public void setListItemMargins(Insets value) { - this.listItemMargins = value; - } - - public void setData(Set employeeList) { - setData(employeeList, null, null); - } - - public void setData(Set employeeList, Consumer onEmployeeClicked) { - setData(employeeList, onEmployeeClicked, null); - } - - public void setData( - Set employeeList, - Consumer onEmployeeClicked, - Consumer onEmployeeListItemClicked) { - - flowPaneEmployeeList.getChildren().clear(); - employeeListItemControllers.clear(); - employeeList.forEach( - employee -> - addEmployeeToFlowPane( - employee, onEmployeeClicked, onEmployeeListItemClicked)); - } - - private void addEmployeeToFlowPane( - Employee employee, - Consumer onEmployeeClicked, - Consumer onEmployeeListItemClicked) { - - try { - EmployeeListItemController controller = - EmployeeListItemController.createEmployeeListItemController( - fxmlLoader, employee); - Node rootElement = controller.getRootElement(); - flowPaneEmployeeList.getChildren().add(rootElement); - employeeListItemControllers.add(controller); - FlowPane.setMargin(rootElement, listItemMargins); - if (onEmployeeClicked != null) { - controller.setConsumerEmployeeClicked(onEmployeeClicked); - } - if (onEmployeeListItemClicked != null) { - controller.setConsumerEmployeeListItemClicked( - employeeListItemController -> { - onEmployeeListItemClicked.accept(employeeListItemController); - if (this.onEmployeeClicked != null) { - this.onEmployeeClicked.accept( - employeeListItemController.getEmployee()); - } - }); - } - } catch (IOException e) { - LOG.error("IOException in addEmployeeToFlowPane. ", e); - } - } - - private void setEmployeeSelected(Employee employee, boolean selected) { - employeeListItemControllers - .stream() - .filter(controller -> controller.getEmployee().equals(employee)) - .forEach(controller -> controller.setSelected(selected)); - } - - public void selectEmployee(Employee employee) { - setEmployeeSelected(employee, true); - } - - public void deselectEmployee(Employee employee) { - setEmployeeSelected(employee, false); - } - - public void deselectAllEmployees() { - employeeListItemControllers.forEach( - employeeListItemController -> employeeListItemController.setSelected(false)); - } - - public static EmployeeListController createEmployeeListController(SpringFXMLLoader loader) - throws IOException { - FXMLWrapper wrapper = - loader.loadAndWrap("/fxml/employeeList.fxml", EmployeeListController.class); - Node root = (Node) wrapper.getLoadedObject(); - EmployeeListController controller = wrapper.getController(); - controller.rootElement = root; - return controller; - } - - public Node getRootElement() { - return rootElement; - } - - public void setOnEmployeeClicked(Consumer onEmployeeClicked) { - this.onEmployeeClicked = onEmployeeClicked; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java deleted file mode 100644 index 7b5910a..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java +++ /dev/null @@ -1,87 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; -import java.io.IOException; -import java.util.function.Consumer; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; - -@Controller -@Scope("prototype") -public class EmployeeListItemController extends CustomListItemController { - - @FXML private Label lblName; - @FXML private Label lblQualification; - @FXML private Label lblPilot; - @FXML private Label lblDriver; - @FXML private ImageView imgPilot; - @FXML private ImageView imgDriver; - @FXML private ImageView imgQualification; - - private Employee employee; - - private Consumer consumerEmployeeClicked; - private Consumer consumerEmployeeListItemClicked; - - @FXML - private void onEmployeeClicked() { - if (consumerEmployeeClicked != null) { - consumerEmployeeClicked.accept(employee); - } - if (consumerEmployeeListItemClicked != null) { - consumerEmployeeListItemClicked.accept(this); - } - } - - private void setData(Employee employee) { - this.employee = employee; - lblName.setText(employee.name()); - lblQualification.setText(employee.educationLevel().name()); - lblPilot.setText(String.format("%s Pilot", employee.isPilot() ? "ist" : "nicht")); - lblDriver.setText(String.format("%s Fahrer", employee.isDriver() ? "ist" : "nicht")); - imgQualification.setImage(new Image("/images/Qualification.png")); - String imgSrcPilot = - String.format("/images/%s", employee.isPilot() ? "Pilot.png" : "NotPilot.png"); - imgPilot.setImage(new Image(imgSrcPilot)); - String imgSrcDriver = - String.format("/images/%s", employee.isDriver() ? "Driver.png" : "NotDriver.png"); - imgDriver.setImage(new Image(imgSrcDriver)); - } - - public static EmployeeListItemController createEmployeeListItemController( - SpringFXMLLoader fxmlLoader, Employee employee) throws IOException { - EmployeeListItemController controller = createEmployeeListItemController(fxmlLoader); - controller.setData(employee); - return controller; - } - - public static EmployeeListItemController createEmployeeListItemController( - SpringFXMLLoader loader) throws IOException { - FXMLWrapper wrapper = - loader.loadAndWrap("/fxml/employeeListItem.fxml", EmployeeListItemController.class); - Node root = (Node) wrapper.getLoadedObject(); - EmployeeListItemController controller = wrapper.getController(); - controller.rootElement = root; - return controller; - } - - public Employee getEmployee() { - return employee; - } - - public void setConsumerEmployeeClicked(Consumer consumerEmployeeClicked) { - this.consumerEmployeeClicked = consumerEmployeeClicked; - } - - public void setConsumerEmployeeListItemClicked( - Consumer consumerEmployeeListItemClicked) { - this.consumerEmployeeListItemClicked = consumerEmployeeListItemClicked; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java deleted file mode 100644 index a1d1f70..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java +++ /dev/null @@ -1,65 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; -import java.io.IOException; -import java.util.function.Consumer; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.TextField; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; - -@Controller -@Scope("prototype") -public class FilterEmployeesController { - private static final Logger LOG = LoggerFactory.getLogger(FilterEmployeesController.class); - - @FXML private TextField inputFilterString; - - private Consumer consumerFilterTextChanged; - private Runnable consumerAddEmployeeClicked; - - private Node rootElement; - - @FXML - private void onAddEmployeeClicked() { - LOG.debug("Button \"Person hinzufügen\" clicked."); - if (consumerAddEmployeeClicked != null) { - consumerAddEmployeeClicked.run(); - } - } - - @FXML - private void onFilterTextChanged() { - LOG.debug("Filter text changed."); - if (consumerFilterTextChanged != null) { - consumerFilterTextChanged.accept(inputFilterString.getText()); - } - } - - public void setOnFilterTextChangedListener(Consumer callback) { - this.consumerFilterTextChanged = callback; - } - - public void setOnAddEmployeeClickedListener(Runnable callback) { - this.consumerAddEmployeeClicked = callback; - } - - public static FilterEmployeesController createFilterEmployeesController( - SpringFXMLLoader fxmlLoader) throws IOException { - FXMLWrapper wrapper = - fxmlLoader.loadAndWrap( - "/fxml/filterEmployeesControl.fxml", FilterEmployeesController.class); - Node root = (Node) wrapper.getLoadedObject(); - FilterEmployeesController controller = wrapper.getController(); - controller.rootElement = root; - return controller; - } - - public Node getRootElement() { - return rootElement; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java deleted file mode 100644 index 694c804..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java +++ /dev/null @@ -1,34 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.ButtonType; - -public class Helper { - - static final String ALERT_TITLE_VALIDATION_ERROR = "Validierungsfehler"; - static final String ALERT_TITLE_SERVICE_EXCEPTION = "Fehler"; - static final String ALERT_TITLE_SUCCESS = "Erfolg"; - - private Helper() {} // SonarLint insisted to create a private constructor to hide the public one - - static void showValidationErrorAlertAndWait(String message) { - showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_VALIDATION_ERROR, message); - } - - static void showServiceExceptionAlertAndWait(String message) { - showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_SERVICE_EXCEPTION, message); - } - - static void showSuccessAlertAndWait(String message) { - showAlertWithOkButtonAndWait(AlertType.INFORMATION, ALERT_TITLE_SUCCESS, message); - } - - static void showAlertWithOkButtonAndWait( - AlertType alertType, String headerText, String contentText) { - Alert alert = new Alert(alertType, contentText, ButtonType.OK); - alert.setTitle(headerText); - alert.setHeaderText(headerText); - alert.showAndWait(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ManageEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ManageEmployeesController.java deleted file mode 100644 index 3aaf040..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ManageEmployeesController.java +++ /dev/null @@ -1,120 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.io.IOException; -import java.util.HashSet; -import java.util.stream.Collectors; -import javafx.fxml.FXML; -import javafx.scene.layout.AnchorPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class ManageEmployeesController { - - private static final Logger LOG = LoggerFactory.getLogger(ManageEmployeesController.class); - @FXML private AnchorPane listEmployeesAP; - @FXML private AnchorPane containerHeader; - @FXML private EmployeeListController employeeListController; - - private final EmployeeService employeeService; - private final SpringFXMLLoader fxmlLoader; - - private final CreateOperationController createOperationController; - - public ManageEmployeesController( - EmployeeService employeeService, - SpringFXMLLoader fxmlLoader, - CreateOperationController createOperationController) { - this.employeeService = employeeService; - this.fxmlLoader = fxmlLoader; - this.createOperationController = createOperationController; - } - - @FXML - private void initialize() { - openFilter(); - } - - private void openFilter() { - try { - FilterEmployeesController filterEmployeesController = - FilterEmployeesController.createFilterEmployeesController(fxmlLoader); - containerHeader.getChildren().clear(); - containerHeader.getChildren().add(filterEmployeesController.getRootElement()); - filterEmployeesController.setOnFilterTextChangedListener(this::updateEmployeeList); - filterEmployeesController.setOnAddEmployeeClickedListener(this::openAddEmployee); - updateEmployeeList(); - - } catch (IOException e) { - LOG.error("IOException in openFilter().", e); - } - } - - private void openAddEmployee() { - employeeListController.deselectAllEmployees(); - openEmployee(null); - } - - private void openEditEmployee(Employee employee) { - employeeListController.deselectAllEmployees(); - employeeListController.selectEmployee(employee); - openEmployee(employee); - } - - private void openEmployee(Employee employee) { - try { - CreateNewEmployeeController createNewEmployeeController = - employee == null - ? CreateNewEmployeeController.createCreateNewEmployeeController( - fxmlLoader) - : CreateNewEmployeeController.createCreateNewEmployeeController( - fxmlLoader, employee); - containerHeader.getChildren().clear(); - containerHeader.getChildren().add(createNewEmployeeController.getRootElement()); - createNewEmployeeController.setConsumerCancelClicked(this::openFilter); - createNewEmployeeController.setConsumerCreateClicked(this::openFilter); - } catch (IOException e) { - LOG.error("IOException in openEmployee(). ", e); - } - } - - private void updateEmployeeList() { - updateEmployeeList(""); - } - - private void updateEmployeeList(String searchString) { - - try { - employeeListController.setData( - employeeService - .list() - .stream() - .filter( - employee -> - searchString.trim().isEmpty() - || employee.name() - .toLowerCase() - .contains(searchString.toLowerCase())) - .collect(Collectors.toCollection(HashSet::new)), - this::openEditEmployee); - - } catch (ServiceException e) { - LOG.error("ServiceException in updateEmployeeList(). ", e); - } - } - - public void setVisible(boolean b) { - listEmployeesAP.setVisible(b); - } - - public void backToMain() { - LOG.debug("Hyperlink \"Zurück\" clicked."); - this.setVisible(false); - createOperationController.setVisible(true); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java deleted file mode 100644 index c0c68f3..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java +++ /dev/null @@ -1,169 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showAlertWithOkButtonAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showSuccessAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showValidationErrorAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.io.IOException; -import java.util.Collection; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; -import javafx.collections.FXCollections; -import javafx.fxml.FXML; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.ListView; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class OperationDetailsController { - private static final Logger LOG = LoggerFactory.getLogger(OperationDetailsController.class); - - public Operation operation; - private final OperationService operationService; - private final VehicleService vehicleService; - private final CreateOperationController createOperationController; - @FXML private FlowPane fpVehicles; - @FXML private ListView lvActiveOperations; - @FXML private Label lblChosenVehicles; - @FXML private Button btnCloseOperation; - @FXML private Button btnCancelOperation; - @FXML private Label lblCode, lblAdditionalInfo, lblAddress; - @FXML private AnchorPane operationDetailsAP; - - public OperationDetailsController( - OperationService operationService, - VehicleService vehicleService, - CreateOperationController createOperationController) { - this.operationService = operationService; - this.vehicleService = vehicleService; - this.createOperationController = createOperationController; - } - - @FXML - private void initialize() { - lvActiveOperations.setCellFactory( - param -> CreateOperationController.generateOpCodeListItem()); - lvActiveOperations.setOnMouseClicked( - event -> { - if (event.getClickCount() == 2) { - if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { - return; - } - initOperation(lvActiveOperations.getSelectionModel().getSelectedItem()); - } - }); - } - - private void updateFlowPane() { - try { - fpVehicles.getChildren().clear(); - for (Vehicle vehicle : operation.vehicles()) { - VehiclePaneController controller = VehiclePaneController.createVehiclePane(); - controller.setData(vehicle, true, true); - controller.getBtnRequest().setOnAction(e -> requestVehicleClicked(controller)); - fpVehicles.getChildren().add(controller.getRootElement()); - } - } catch (IOException e) { - LOG.error("Error while updating list.", e); - showServiceExceptionAlertAndWait("Error while updating list."); - } - } - - void initOperation(Operation operation) { - fillActiveList(); - this.operation = operation; - lblCode.setText(operation.opCode()); - Collection vehicleNames = - operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); - String result = String.join(", ", vehicleNames); - lblChosenVehicles.setText(result.toString()); - lblAdditionalInfo.setText(operation.additionalInfo()); - lblAddress.setText(operation.destination()); - updateFlowPane(); - operationDetailsAP.setVisible(true); - } - - private void fillActiveList() { - try { - lvActiveOperations.setItems( - FXCollections.observableArrayList( - operationService.list(EnumSet.of(Status.ACTIVE)))); - } catch (ServiceException e) { - LOG.error("ServiceException in fillActiveList(). ", e); - showServiceExceptionAlertAndWait(e.getMessage()); - } - } - - @FXML - public void closeOperationClicked() { - LOG.debug("Button \"Abschließen\" clicked."); - try { - operationService.complete(operation.id(), Status.COMPLETED); - } catch (InvalidOperationException e) { - LOG.debug("Validation error in closeOperationClicked(). ", e); - showAlertWithOkButtonAndWait(AlertType.ERROR, "Validierungsfehler", e.getMessage()); - return; - } catch (ServiceException e) { - LOG.error("Exception in closeOperationClicked(). ", e); - showServiceExceptionAlertAndWait(e.getMessage()); - return; - } - showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); - createOperationController.updateList(); - closeWindow(); - } - - public void cancelOperationClicked() { - LOG.debug("Button \"Stornieren\" clicked."); - try { - operationService.complete(operation.id(), Status.CANCELLED); - } catch (InvalidOperationException e) { - LOG.debug("Validation error in cancelOperationClicked(). ", e); - showValidationErrorAlertAndWait(e.getMessage()); - return; - } catch (ServiceException e) { - LOG.error("Exception in cancelOperationClicked(). ", e); - showServiceExceptionAlertAndWait(e.getMessage()); - return; - } - showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); - createOperationController.updateList(); - closeWindow(); - } - - private void requestVehicleClicked(VehiclePaneController v) { - LOG.debug("Button \"Nachfordern\" clicked."); - - try { - operationService.requestVehicles(operation.id(), Set.of(v.getData().id())); - } catch (ServiceException | InvalidOperationException | InvalidVehicleException e) { - LOG.error("Exception in requestVehicleClicked()", e); - showServiceExceptionAlertAndWait(e.getMessage()); - return; - } - showSuccessAlertAndWait("Das Fahrzeug wurde erfolgreich angefordert"); - createOperationController.updateList(); - } - - public void closeWindow() { - LOG.debug("Hyperlink \"Zurück\" clicked."); - operationDetailsAP.setVisible(false); - this.createOperationController.setVisible(true); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java deleted file mode 100644 index d1b325c..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java +++ /dev/null @@ -1,65 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.ZoneOffset; -import java.util.Collection; -import java.util.Objects; -import java.util.stream.Collectors; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.text.Text; - -public class OperationInArchiveController { - - @FXML private Text txtAddress; - @FXML private Text txtVehicles; - @FXML private Text txtDate; - @FXML private Text txtOpCode; - - static OperationInArchiveController create() throws IOException { - FXMLLoader fxmlLoader = - new FXMLLoader( - OperationInArchiveController.class.getResource( - "/fxml/OperationInArchive.fxml")); - Node root = fxmlLoader.load(); - OperationInArchiveController result = fxmlLoader.getController(); - result.rootElement = root; - - return result; - } - - public Node getRoot() { - return rootElement; - } - - private Node rootElement; - - public void set(Operation operation) { - txtAddress.setText(operation.destination()); - String date = "am "; - if (operation.created() != null) { - LocalDateTime myDateTime = - LocalDateTime.ofInstant( - Objects.requireNonNull(operation.created()), ZoneOffset.UTC); - date += - myDateTime.getDayOfMonth() - + "." - + myDateTime.getMonth().getValue() - + "." - + myDateTime.getYear(); - txtDate.setText(date); - } else { - txtDate.setText("---"); - } - txtOpCode.setText(operation.opCode()); - Collection elements = - operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); - String result = String.join(", ", elements); - - txtVehicles.setText(result); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java deleted file mode 100644 index ed5a12d..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java +++ /dev/null @@ -1,279 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showServiceExceptionAlertAndWait; -import static at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.Helper.showValidationErrorAlertAndWait; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.RegistrationService; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.io.IOException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.TextField; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseButton; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.VBox; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class RegistrationWindowController { - - private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); - - private final EmployeeService employeeService; - private final VehicleService vehicleService; - private final RegistrationService registrationService; - private final CreateOperationController createOperationController; - private final SpringFXMLLoader fxmlLoader; - - @FXML private GridPane root; - @FXML private VBox vbVehicles; - @FXML private ScrollPane listEmployee; - @FXML private ChoiceBox cbStart; - @FXML private ChoiceBox cbEnd; - @FXML private Label lVehicles; - @FXML private Label lEmployees; - @FXML private TextField tfVehicleSearch; - @FXML private TextField tfEmployeeSearch; - private EmployeeListController employeeListController; - - private Vehicle chosenVehicle; - private List chosenEmployees = new LinkedList<>(); - - public RegistrationWindowController( - EmployeeService employeeService, - VehicleService vehicleService, - CreateOperationController createOperationController, - RegistrationService registrationService, - SpringFXMLLoader fxmlLoader) { - this.employeeService = employeeService; - this.vehicleService = vehicleService; - this.createOperationController = createOperationController; - this.registrationService = registrationService; - this.fxmlLoader = fxmlLoader; - } - - @FXML - private void initialize() throws IOException { - employeeListController = EmployeeListController.createEmployeeListController(fxmlLoader); - employeeListController.setListItemMargins(new Insets(10, 6, 0, 6)); - // listEmployee. .getChildren().add(employeeListController.getRootElement()); - Node emplList = employeeListController.getRootElement(); - // emplList.(360); - listEmployee.setContent(emplList); - - ObservableList hours = - FXCollections.observableArrayList( - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23); - cbStart.setItems(hours); - cbStart.setValue(0); - cbEnd.setItems(hours); - cbEnd.setValue(12); - - reset(); - } - - private void updateEmplList() { - employeeListController.deselectAllEmployees(); - - try { - Set employees = - employeeService - .list() - .stream() - .filter( - e -> - e.name() - .toLowerCase() - .contains( - tfEmployeeSearch - .getText() - .toLowerCase())) - .collect(Collectors.toCollection(HashSet::new)); - employeeListController.setData( - employees, - selection -> { - if (selection == null) { - return; - } else if (chosenEmployees.contains(selection)) { - chosenEmployees.remove(selection); - } else { - chosenEmployees.add(selection); - } - - StringBuilder text = new StringBuilder(); - boolean first = true; - for (Employee employee : chosenEmployees) { - if (!first) { - text.append(", "); - } - text.append(employee.name()); - first = false; - } - lEmployees.setText(text.toString()); - }, - contr -> contr.setSelected(chosenEmployees.contains(contr.getEmployee()))); - - employees.forEach( - e -> { - if (chosenEmployees.contains(e)) employeeListController.selectEmployee(e); - }); - } catch (ServiceException e) { - LOG.error("ServiceException in updateEmplList(). ", e); - showServiceExceptionAlertAndWait( - "Beim Auflisten des Personals ist ein Fehler aufgetreten."); - } - } - - private void updateVehList() { - vbVehicles.getChildren().clear(); - - try { - Set vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); - - boolean anyMatch = false; - - for (Vehicle vehicle : vehicles) { - if (!vehicle.name().toLowerCase().contains(tfVehicleSearch.getText().toLowerCase())) - continue; - - anyMatch = true; - - VehiclePaneController vp = VehiclePaneController.createVehiclePane(); - vp.setData(vehicle, false, false); - vbVehicles.getChildren().add(vp.getRootElement()); - - vp.getRootElement() - .setOnMouseClicked( - event -> { - if (event.getButton() == MouseButton.PRIMARY) { - chosenVehicle = vehicle; - lVehicles.setText(chosenVehicle.name()); - updateVehList(); - } - }); - if (chosenVehicle != null && chosenVehicle.id() == vehicle.id()) - vp.setSelected(true); - } - - if (!anyMatch) { - // Kind of ugly, but best way to get the size of a VehiclePane - VehiclePaneController vp = VehiclePaneController.createVehiclePane(); - vp.getRootElement().setVisible(false); - vbVehicles.getChildren().add(vp.getRootElement()); - } - } catch (ServiceException e) { - LOG.error("ServiceException in updateVehList(). ", e); - showServiceExceptionAlertAndWait( - "Beim Auflisten der Fahrzeuge ist ein Fehler aufgetreten"); - } catch (IOException e) { - LOG.error("IOException in updateVehList(). ", e); - showServiceExceptionAlertAndWait("Beim Laden der Fahrzeuge ist ein Fehler aufgetreten"); - } - } - - public void cancel() { - LOG.debug("Hyperlink \"schließen\" clicked"); - reset(); - this.setVisible(false); - createOperationController.setVisible(true); - } - - private void reset() { - chosenEmployees.clear(); - chosenVehicle = null; - tfEmployeeSearch.setText(""); - tfVehicleSearch.setText(""); - lEmployees.setText("-"); - lVehicles.setText("-"); - updateVehList(); - updateEmplList(); - } - - public void create() { - LOG.debug("Button \"ERSTELLEN\" clicked"); - - Set registrations = new HashSet<>(); - try { - if (chosenVehicle == null) { - throw new InvalidVehicleException("no Vehicle"); - } - for (Employee employee : chosenEmployees) { - registrations.add( - Registration.builder() - .id(chosenVehicle.id()) - .employee(employee) - .start( - LocalDateTime.of( - LocalDate.now(), - LocalTime.of(cbStart.getValue(), 0)) - .toInstant(OffsetDateTime.now().getOffset())) - .end( - LocalDateTime.of( - LocalDate.now(), - LocalTime.of(cbEnd.getValue(), 0)) - .toInstant(OffsetDateTime.now().getOffset())) - .build()); - } - - registrationService.add(chosenVehicle.id(), registrations); - chosenEmployees.clear(); - // ((Stage) lVehicles.getScene().getWindow()).close(); - this.setVisible(false); - createOperationController.setVisible(true); - reset(); - } catch (InvalidVehicleException e) { - LOG.debug("Validation of Vehicle in Registration failed."); - showValidationErrorAlertAndWait("Das spezifizierte Fahrzeug ist nicht gültig."); - } catch (ServiceException e) { - LOG.error("ServiceException in create(). ", e); - showServiceExceptionAlertAndWait( - "Beim Erstellen der Anmeldung ist ein Fehler aufgetreten."); - } catch (InvalidRegistrationException e) { - LOG.debug("Validation of Registration failed."); - showValidationErrorAlertAndWait( - "Die gewählte Kombination von Fahrzeug und Personal ist nicht gültig!"); - } - } - - public void setVisible(boolean b) { - root.setVisible(b); - reset(); - } - - public void tfVehicleSearch_TextChanged(KeyEvent keyEvent) { - updateVehList(); - } - - public void tfEmployeeSearch_TextChanged(KeyEvent keyEvent) { - updateEmplList(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java deleted file mode 100644 index b31228d..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java +++ /dev/null @@ -1,118 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import java.io.IOException; -import java.time.Instant; -import java.util.List; -import java.util.Optional; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.text.Text; - -public class VehiclePaneController extends CustomListItemController { - - public static VehiclePaneController createVehiclePane() throws IOException { - FXMLLoader fxmlLoader = - new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); - Node root = fxmlLoader.load(); - VehiclePaneController result = fxmlLoader.getController(); - result.rootElement = root; - - return result; - } - - @FXML private Label txtStatus; - @FXML private Text txtType; - @FXML private Text txtNumber; - @FXML private ImageView ivNEF; - @FXML private Text txtNEF; - @FXML private ImageView ivQualification; - @FXML private Text txtQualification; - @FXML private Text txtRooftype; - @FXML private Button btnRequest; - - private Vehicle data; - - public Vehicle getData() { - return data; - } - - /** - * * Set the displayed data of this VehiclePane. - * - * @param vehicle The data to display. - * @param showStatusInfo If true, the highest qualification of the vehicle's active registration - * and the vehicle's status will be shown. - */ - public void setData(Vehicle vehicle, boolean showStatusInfo, boolean showRequestVehicle) { - txtType.setText(vehicle.type().name()); - String constrType = vehicle.constructionType().name(); - txtRooftype.setText( - constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); - txtNumber.setText("-" + vehicle.id()); - if (vehicle.hasNef()) { - ivNEF.setImage(new Image("images/NEF.png")); - txtNEF.setText("hat NEF-Halterung"); - } else { - ivNEF.setImage(new Image("images/NotNEF.png")); - txtNEF.setText("keine NEF-Halterung"); - } - - if (showRequestVehicle) { - btnRequest.setVisible(true); - btnRequest.setManaged(true); - } else { - btnRequest.setVisible(false); - btnRequest.setManaged(false); - } - - if (showStatusInfo) { - txtStatus.setText(vehicle.status().name()); - if (vehicle.status() == Status.FREI_FUNK || vehicle.status() == Status.FREI_WACHE) { - txtStatus.getStyleClass().add("bg-status-green"); - } else { - txtStatus.getStyleClass().add("bg-status-orange"); - } - - Instant now = Instant.now(); - List regs = vehicle.registrations(); - - if (regs == null) { - return; - } - - Optional edu = - regs.stream() - .filter(reg -> reg.start().isBefore(now) && reg.end().isAfter(now)) - .map(reg -> reg.employee().educationLevel()) - .max(EducationLevel::compareTo); - - if (!edu.isPresent()) { - return; - } - - txtQualification.setText(edu.get().name()); - } else { - txtQualification.setVisible(false); - txtQualification.setManaged(false); - ivQualification.setVisible(false); - ivQualification.setManaged(false); - - txtStatus.setVisible(false); - } - - this.data = vehicle; - } - - public Button getBtnRequest() { - return btnRequest; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java deleted file mode 100644 index 539a8e5..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java +++ /dev/null @@ -1,44 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import java.util.Set; - -public interface EmployeeDAO { - - /** - * Persist the given employee. - * - * @param employee that should be stored - * @return the id that was assigned - * @throws PersistenceException if the employee could not be persisted - */ - long add(Employee employee) throws PersistenceException; - - /** - * Update the given employee. - * - * @param employee that should be updated - * @throws ElementNotFoundException if no employee with the given id exists - * @throws PersistenceException if the employee could not be updated - */ - void update(Employee employee) throws ElementNotFoundException, PersistenceException; - - /** - * Get all stored employees. - * - * @return list containing all stored employees - * @throws PersistenceException if loading the stored employees failed - */ - Set list() throws PersistenceException; - - /** - * Remove employee with the given id from the store. - * - * @param id of the employee that should be removed - * @throws ElementNotFoundException if no employee with the given id exists - * @throws PersistenceException if the employee could not be removed - */ - void remove(long id) throws ElementNotFoundException, PersistenceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java deleted file mode 100644 index 1d8286b..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java +++ /dev/null @@ -1,144 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.time.LocalDate; -import java.util.HashSet; -import java.util.Set; -import org.springframework.stereotype.Repository; - -@Repository -public class EmployeeDatabaseDAO implements EmployeeDAO { - - private JDBCConnectionManager jdbcConnectionManager; - - public EmployeeDatabaseDAO(JDBCConnectionManager jdbcConnectionManager) { - this.jdbcConnectionManager = jdbcConnectionManager; - } - - private long createEmployeeVersion(Connection con, Employee e) - throws PersistenceException, SQLException { - String sql = - "INSERT INTO EmployeeVersion(name, birthday, educationLevel, isDriver, isPilot) " - + "VALUES(?, ?, ?, ?, ?)"; - - try (PreparedStatement pstmt = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setString(1, e.name()); - pstmt.setObject(2, e.birthday()); - pstmt.setInt(3, e.educationLevel().ordinal()); - pstmt.setBoolean(4, e.isDriver()); - pstmt.setBoolean(5, e.isPilot()); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (!rs.next()) throw new PersistenceException("Failed to insert EmployeeVersion"); - - return rs.getLong(1); - } - } - } - - @Override - public long add(Employee employee) throws PersistenceException { - String sql = "INSERT INTO Employee(version) VALUES(?)"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - - long versionId = createEmployeeVersion(con, employee); - - try (PreparedStatement pstmt = - con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setLong(1, versionId); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (!rs.next()) { - con.rollback(); - throw new PersistenceException("Failed to insert Employee"); - } - - con.commit(); - return rs.getLong(1); - } - } - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public void update(Employee employee) throws ElementNotFoundException, PersistenceException { - String sql = "UPDATE Employee SET version = ? WHERE id = ?"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - - long versionId = createEmployeeVersion(con, employee); - - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, versionId); - pstmt.setLong(2, employee.id()); - - if (pstmt.executeUpdate() != 1) { - con.rollback(); - throw new ElementNotFoundException("No such employeeId exists"); - } - } - - con.commit(); - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public Set list() throws PersistenceException { - String sql = - "SELECT emp.id, v.name, v.birthday, v.educationLevel, v.isDriver, v.isPilot " - + "FROM employee emp " - + "JOIN EmployeeVersion v ON v.id = emp.version"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - Set employees = new HashSet<>(); - - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - try (ResultSet rs = pstmt.executeQuery()) { - while (rs.next()) { - employees.add( - Employee.builder() - .id(rs.getLong(1)) - .name(rs.getString(2)) - .birthday(rs.getObject(3, LocalDate.class)) - .educationLevel(EducationLevel.valueOf(rs.getString(4))) - .isDriver(rs.getBoolean(5)) - .isPilot(rs.getBoolean(6)) - .build()); - } - } - } - - return employees; - } catch (SQLException e) { - throw new PersistenceException(e); - } - } - - @Override - public void remove(long id) throws ElementNotFoundException, PersistenceException { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java deleted file mode 100644 index d82f768..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java +++ /dev/null @@ -1,48 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import java.util.EnumSet; -import java.util.Set; - -public interface OperationDAO { - - /** - * Persist the given operation. - * - * @param operation that should be stored - * @return the id that was assigned - * @throws PersistenceException if the operation could not be persisted - */ - long add(Operation operation) throws PersistenceException; - - /** - * Update the given operation. - * - * @param operation that should be updated - * @throws ElementNotFoundException if no operation with the given id exists - * @throws PersistenceException if the operation could not be updated - */ - void update(Operation operation) throws ElementNotFoundException, PersistenceException; - - /** - * Returns the operation with the given id. - * - * @param operationId id of the operation that should be returned - * @return operation with the given id - * @throws ElementNotFoundException if no operation with the given id exists - * @throws PersistenceException if the operation could not be loaded - */ - Operation get(long operationId) throws ElementNotFoundException, PersistenceException; - - /** - * Get all stored operations with matching status. - * - * @param statuses set containing all statuses that should be matched - * @return list containing all matched operations - * @throws PersistenceException if loading the stored operations failed - */ - Set list(EnumSet statuses) throws PersistenceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java deleted file mode 100644 index 0b6ce08..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java +++ /dev/null @@ -1,221 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Repository; - -@Repository -public class OperationDatabaseDAO implements OperationDAO { - - private JDBCConnectionManager jdbcConnectionManager; - private VehicleDAO vehicleDAO; - - public OperationDatabaseDAO( - JDBCConnectionManager jdbcConnectionManager, VehicleDAO vehicleDAO) { - this.jdbcConnectionManager = jdbcConnectionManager; - this.vehicleDAO = vehicleDAO; - } - - @Override - public long add(@NonNull Operation o) throws PersistenceException { - String sql = - "INSERT INTO Operation(opCode, severity, created, destination, additionalInfo," - + " status) VALUES (?, ?, ?, ?, ?, ?)"; - String sql2 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)"; - long operationId; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setString(1, o.opCode()); - pstmt.setInt(2, o.severity().ordinal()); - pstmt.setObject(3, OffsetDateTime.ofInstant(o.created(), ZoneId.systemDefault())); - pstmt.setString(4, o.destination()); - pstmt.setString(5, o.additionalInfo()); - pstmt.setInt(6, o.status().ordinal()); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (!rs.next()) throw new PersistenceException("Failed to persist operation"); - - operationId = rs.getLong(1); - } - } - - try (PreparedStatement pstmt = con.prepareStatement(sql2)) { - pstmt.setLong(2, operationId); - - for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { - pstmt.setLong(1, id); - pstmt.addBatch(); - } - - pstmt.executeBatch(); - } - con.commit(); - return operationId; - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public void update(@NonNull Operation o) throws ElementNotFoundException, PersistenceException { - // Note this will, by design, not update created - String sql = - "UPDATE Operation SET opCode = ?, severity = ?, destination = ?," - + " additionalInfo = ?, status = ? WHERE id = ?"; - String sql2 = "DELETE FROM VehicleOperation WHERE operationId = ?"; - String sql3 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setString(1, o.opCode()); - pstmt.setInt(2, o.severity().ordinal()); - pstmt.setString(3, o.destination()); - pstmt.setString(4, o.additionalInfo()); - pstmt.setInt(5, o.status().ordinal()); - pstmt.setLong(6, o.id()); - - if (pstmt.executeUpdate() != 1) - throw new ElementNotFoundException("No such operationId exists"); - } - - try (PreparedStatement pstmt = con.prepareStatement(sql2)) { - pstmt.setLong(1, o.id()); - pstmt.executeUpdate(); - } - - try (PreparedStatement pstmt = con.prepareStatement(sql3)) { - pstmt.setLong(2, o.id()); - - for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { - pstmt.setLong(1, id); - pstmt.addBatch(); - } - - pstmt.executeBatch(); - } - con.commit(); - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public Operation get(long operationId) throws ElementNotFoundException, PersistenceException { - String sql = "Select * from operation where id = ?"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, operationId); - pstmt.execute(); - - try (ResultSet rs = pstmt.getResultSet()) { - if (!rs.next()) - throw new ElementNotFoundException("No such element could be found"); - - return operationFromRS(rs); - } - } - } catch (SQLException e) { - throw new PersistenceException(e); - } - } - - @Override - public Set list(EnumSet statuses) throws PersistenceException { - // This hack exists because H2 currently has a bug that prevents IN (?) with an array of - // ids, i.e. pstmt.setArray(1, con.createArrayOf("INT", intarray) from working. See - // commented code below. - - // SELECT * FROM Operation WHERE status IN ('COMPLETED', 'CANCELLED') is BUGGED on H2! - // for this reason we use the ordinal values instead - String str = - statuses.stream() - .map(e -> Integer.toString(e.ordinal())) - .collect(Collectors.joining(",")); - - String sql = "SELECT * FROM Operation WHERE status IN (" + str + ")"; - Set operations = new HashSet<>(); - - try { - Connection con = jdbcConnectionManager.getConnection(); - - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - // Object[] arr = statuses.stream().map(Enum::ordinal).toArray(); - // pstmt.setArray(1, con.createArrayOf("INT", arr)); - - try (ResultSet rs = pstmt.executeQuery()) { - while (rs.next()) operations.add(operationFromRS(rs)); - } - } - - return operations; - } catch (SQLException e) { - throw new PersistenceException(e); - } - } - - private Operation operationFromRS(ResultSet rs) throws PersistenceException, SQLException { - Long operationId = rs.getLong("id"); - - return Operation.builder() - .id(operationId) - .opCode(rs.getString("opCode")) - .severity(Severity.valueOf(rs.getString("severity"))) - .status(Status.valueOf(rs.getString("status"))) - .vehicles(getVehiclesFromOperationId(operationId)) - .created((rs.getObject("created", OffsetDateTime.class)).toInstant()) - .destination(rs.getString("destination")) - .additionalInfo(rs.getString("additionalInfo")) - .build(); - } - - private Set getVehiclesFromOperationId(long operationId) throws PersistenceException { - String sql = "SELECT vehicleId FROM VehicleOperation WHERE operationId = ?"; - Set vehicles = new HashSet<>(); - - try { - Connection con = jdbcConnectionManager.getConnection(); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, operationId); - pstmt.execute(); - - try (ResultSet rs = pstmt.getResultSet()) { - while (rs.next()) { - vehicles.add(vehicleDAO.get(rs.getLong("vehicleId"))); - } - } - } - } catch (SQLException e) { - throw new PersistenceException(e); - } catch (ElementNotFoundException e) { - throw new PersistenceException("VehicleOperation contained nonexistent vehicle", e); - } - - return vehicles; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java deleted file mode 100644 index 36b6f1b..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java +++ /dev/null @@ -1,28 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import java.util.Set; - -public interface RegistrationDAO { - - /** - * Persist the given registration. - * - * @param vehicleId the id of the target vehicle - * @param registrations that should be stored - * @return a list of the ids that were assigned - * @throws PersistenceException if the registration could not be persisted - */ - Set add(long vehicleId, Set registrations) throws PersistenceException; - - /** - * Make registration with the given id inactive. - * - * @param id of the registration that should be made inactive - * @throws ElementNotFoundException if no registration with the given id exists - * @throws PersistenceException if the registration could not be made inactive - */ - void remove(long id) throws ElementNotFoundException, PersistenceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java deleted file mode 100644 index 9f7ac84..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java +++ /dev/null @@ -1,130 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - -@Repository -public class RegistrationDatabaseDAO implements RegistrationDAO { - - private JDBCConnectionManager jdbcConnectionManager; - private EmployeeDAO employeePersistence; - - @Autowired - public RegistrationDatabaseDAO( - JDBCConnectionManager jdbcConnectionManager, EmployeeDAO employeePersistence) { - this.jdbcConnectionManager = jdbcConnectionManager; - this.employeePersistence = employeePersistence; - } - - @Override - public Set add(long vehicleId, Set registrations) - throws PersistenceException { - String sql = - "INSERT INTO Registration (vehicleId, employeeId, start, end, active) VALUES (?,?,?,?,?)"; - String sql2 = "UPDATE Vehicle SET status = 'FREI_WACHE' WHERE id = ?;"; - - Set vehicleIds = new HashSet<>(); - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - - try (PreparedStatement pstmt = - con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setLong(1, vehicleId); - - for (Registration r : registrations) { - pstmt.setLong(2, r.employee().id()); - pstmt.setObject(3, OffsetDateTime.ofInstant(r.start(), ZoneId.systemDefault())); - pstmt.setObject(4, OffsetDateTime.ofInstant(r.end(), ZoneId.systemDefault())); - pstmt.setBoolean(5, true); - pstmt.addBatch(); - } - - pstmt.executeBatch(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - while (rs.next()) vehicleIds.add(rs.getLong(1)); - } - } - - try (PreparedStatement pstmt = con.prepareStatement(sql2)) { - pstmt.setLong(1, vehicleId); - if (pstmt.executeUpdate() != 1) { - con.rollback(); - throw new PersistenceException("Failed to persist registration"); - } - } - - con.commit(); - return vehicleIds; - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public void remove(long id) throws ElementNotFoundException, PersistenceException { - throw new UnsupportedOperationException(); - } - - protected List list(long vehicleId) throws PersistenceException { - String sql = "SELECT * FROM Registration WHERE vehicleId = ?"; - - List registrationList = new ArrayList<>(); - try { - Connection con = jdbcConnectionManager.getConnection(); - - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, vehicleId); - - try (ResultSet rs = pstmt.executeQuery()) { - while (rs.next()) { - long employeeId = rs.getLong("employeeId"); - // TODO: replace the following with employeePersistence.get once implemented - Employee emp = - employeePersistence - .list() - .stream() - .filter(employee -> employee.id() == employeeId) - .findAny() - .orElse(null); - Registration registration = - Registration.builder() - .id(rs.getLong("id")) - .start( - (rs.getObject("start", OffsetDateTime.class)) - .toInstant()) - .end( - (rs.getObject("end", OffsetDateTime.class)) - .toInstant()) - .employee(emp) - .build(); - registrationList.add(registration); - } - } - } - - return registrationList; - } catch (SQLException e) { - throw new PersistenceException(e); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java deleted file mode 100644 index 5782fd9..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java +++ /dev/null @@ -1,54 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import java.util.Set; - -public interface VehicleDAO { - - /** - * Persist the given vehicle. - * - * @param vehicle that should be stored - * @return the id that was assigned - * @throws PersistenceException if the vehicle could not be persisted - */ - long add(Vehicle vehicle) throws PersistenceException; - - /** - * Update the given vehicle. - * - * @param vehicle that should be updated - * @throws ElementNotFoundException if no vehicle with the given id exists - * @throws PersistenceException if the vehicle could not be updated - */ - void update(Vehicle vehicle) throws ElementNotFoundException, PersistenceException; - - /** - * Get all stored vehicles. - * - * @return list containing all stored vehicles - * @throws PersistenceException if loading the stored vehicles failed - */ - Set list() throws PersistenceException; - - /** - * Returns the vehicle with the given id. - * - * @param vehicleId id of the vehicle that should be returned - * @return vehicle with the given id - * @throws ElementNotFoundException if no vehicle with the given id exists - * @throws PersistenceException if the vehicle could not be loaded - */ - Vehicle get(long vehicleId) throws ElementNotFoundException, PersistenceException; - - /** - * Remove vehicle with the given id from the store. - * - * @param id of the vehicle that should be removed - * @throws ElementNotFoundException if no vehicle with the given id exists - * @throws PersistenceException if the vehicle could not be removed - */ - void remove(long id) throws ElementNotFoundException, PersistenceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java deleted file mode 100644 index fcae6d3..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java +++ /dev/null @@ -1,211 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashSet; -import java.util.Set; -import org.springframework.stereotype.Repository; - -@Repository -public class VehicleDatabaseDAO implements VehicleDAO { - - private final JDBCConnectionManager jdbcConnectionManager; - private RegistrationDatabaseDAO registrationDatabaseDao; - - public VehicleDatabaseDAO( - JDBCConnectionManager j, RegistrationDatabaseDAO registrationDatabaseDao) { - jdbcConnectionManager = j; - this.registrationDatabaseDao = registrationDatabaseDao; - } - - @Override - public long add(Vehicle v) throws PersistenceException { - String sql = - "INSERT INTO VehicleVersion (name,hasNef,constructionType,type) VALUES (?,?,?,?)"; - String sql2 = "INSERT INTO Vehicle (version,status) VALUES (?,?)"; - String sql3 = "UPDATE VehicleVersion SET name=? WHERE id=?"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - String name = ""; - long version, id; - - try (PreparedStatement pstmt = - con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setString(1, name); - pstmt.setBoolean(2, v.hasNef()); - pstmt.setInt(3, v.constructionType().ordinal()); - pstmt.setString(4, v.type().name()); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (!rs.next()) - throw new PersistenceException("Failed to insert into VehicleVersion"); - - version = rs.getLong(1); - } - } - - try (PreparedStatement pstmt = - con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setLong(1, version); - pstmt.setInt(2, Status.ABGEMELDET.ordinal()); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (!rs.next()) { - con.rollback(); - throw new PersistenceException("Failed to insert into Vehicle"); - } - - id = rs.getLong(1); - } - - name = v.type().name() + "-" + id; - } - - try (PreparedStatement pstmt = con.prepareStatement(sql3)) { - pstmt.setString(1, name); - pstmt.setLong(2, version); - - if (pstmt.executeUpdate() != 1) { - con.rollback(); - throw new PersistenceException("Failed to update VehicleVersion"); - } - } - - con.commit(); - return id; - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public void update(Vehicle v) throws ElementNotFoundException, PersistenceException { - String sql = "SELECT version FROM Vehicle WHERE id = ?"; - String sql2 = - "MERGE INTO VehicleVersion(name, constructionType, type, hasNef)" - + " KEY(name, constructionType, type, hasNef) VALUES(?, ?, ?, ?)"; - String sql3 = "UPDATE Vehicle SET version = ?, status = ? WHERE id = ?"; - - long versionId; - - try { - Connection con = jdbcConnectionManager.getConnection(); - con.setAutoCommit(false); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, v.id()); - - try (ResultSet rs = pstmt.executeQuery()) { - if (!rs.next()) throw new ElementNotFoundException("No such vehicleId exists"); - - versionId = rs.getLong(1); - } - } - - try (PreparedStatement pstmt = - con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { - pstmt.setString(1, v.type().name() + "-" + v.id()); - pstmt.setString(2, v.constructionType().name()); - pstmt.setString(3, v.type().name()); - pstmt.setBoolean(4, v.hasNef()); - pstmt.executeUpdate(); - - try (ResultSet rs = pstmt.getGeneratedKeys()) { - if (rs.next()) { - // version changed, update it - versionId = rs.getLong(1); - } - } - } - - try (PreparedStatement pstmt = con.prepareStatement(sql3)) { - pstmt.setLong(1, versionId); - pstmt.setString(2, v.status().name()); - pstmt.setLong(3, v.id()); - pstmt.executeUpdate(); - } - - con.commit(); - } catch (SQLException e) { - jdbcConnectionManager.rollbackConnection(); - throw new PersistenceException(e); - } - } - - @Override - public Set list() throws PersistenceException { - Set result = new HashSet<>(); - - String sql = - "Select * from VehicleVersion, Vehicle where VehicleVersion.id=Vehicle.version"; - - try (PreparedStatement pstmt = - jdbcConnectionManager.getConnection().prepareStatement(sql)) { - pstmt.executeQuery(); - try (ResultSet rs = pstmt.getResultSet()) { - while (rs.next()) { - result.add(vehicleFromRS(rs)); - } - } - } catch (SQLException e) { - throw new PersistenceException(e); - } - return result; - } - - @Override - public Vehicle get(long id) throws ElementNotFoundException, PersistenceException { - String sql = - "SELECT a.id, b.name, b.constructionType, b.type, a.status, b.hasNef" - + " FROM Vehicle a" - + " INNER JOIN VehicleVersion b" - + " ON version = b.id" - + " WHERE a.id = ?"; - - try { - Connection con = jdbcConnectionManager.getConnection(); - try (PreparedStatement pstmt = con.prepareStatement(sql)) { - pstmt.setLong(1, id); - - try (ResultSet rs = pstmt.executeQuery()) { - if (!rs.first()) throw new ElementNotFoundException("No such vehicle exists"); - - return vehicleFromRS(rs); - } - } - } catch (SQLException e) { - throw new PersistenceException(e); - } - } - - @Override - public void remove(long id) throws ElementNotFoundException, PersistenceException { - throw new UnsupportedOperationException(); - } - - private Vehicle vehicleFromRS(ResultSet rs) throws SQLException, PersistenceException { - return Vehicle.builder() - .id(rs.getLong("Vehicle.id")) - .name(rs.getString("name")) - .constructionType(ConstructionType.values()[rs.getInt("constructionType")]) - .type(VehicleType.valueOf(rs.getString("type"))) - .status(Status.values()[rs.getInt("status")]) - .hasNef(rs.getBoolean("hasNef")) - .registrations(registrationDatabaseDao.list(rs.getLong("id"))) - .build(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java deleted file mode 100644 index 583bf5b..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java +++ /dev/null @@ -1,51 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import com.google.auto.value.AutoValue; -import java.time.LocalDate; - -@AutoValue -public abstract class Employee { - public enum EducationLevel { - RS, - NFS, - NKV, - NKA, - NKI, - NA - } - - public abstract long id(); - - public abstract String name(); - - public abstract LocalDate birthday(); - - public abstract EducationLevel educationLevel(); - - public abstract boolean isDriver(); - - public abstract boolean isPilot(); - - public static Builder builder() { - return new AutoValue_Employee.Builder().id(0); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder id(long id); - - public abstract Builder name(String name); - - public abstract Builder birthday(LocalDate birthday); - - public abstract Builder educationLevel(EducationLevel educationLevel); - - public abstract Builder isDriver(boolean isDriver); - - public abstract Builder isPilot(boolean isPilot); - - public abstract Employee build(); - } - - public abstract Builder toBuilder(); -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java deleted file mode 100644 index 36d8003..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java +++ /dev/null @@ -1,23 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; - -public class EmployeeValidator { - - public static boolean validate(Employee employee) throws InvalidEmployeeException { - - if (employee.name() == null || employee.name().trim().length() == 0) { - throw new InvalidEmployeeException("Name darf nicht leer sein!"); - } - - if (employee.birthday() == null) { - throw new InvalidEmployeeException("Geburtsdatum darf nicht leer sein!"); - } - - if (employee.educationLevel() == null) { - throw new InvalidEmployeeException("Ausbildungsgrad darf nicht leer sein!"); - } - - return true; - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java deleted file mode 100644 index 3a97dc7..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java +++ /dev/null @@ -1,70 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import com.google.auto.value.AutoValue; -import java.time.Instant; -import java.util.Set; -import javax.annotation.Nullable; - -@AutoValue -public abstract class Operation { - public enum Severity { - A, - B, - C, - D, - E, - O, - } - - public enum Status { - ACTIVE, - COMPLETED, - CANCELLED, - } - - public abstract long id(); - - public abstract String opCode(); - - @Nullable - public abstract Severity severity(); - - public abstract Status status(); - - public abstract Set vehicles(); - - @Nullable - public abstract Instant created(); - - public abstract String destination(); - - @Nullable - public abstract String additionalInfo(); - - public static Builder builder() { - return new AutoValue_Operation.Builder().id(0); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder id(long id); - - public abstract Builder opCode(String opCode); - - public abstract Builder severity(Severity severity); - - public abstract Builder status(Status status); - - public abstract Builder vehicles(Set vehicles); - - public abstract Builder created(Instant created); - - public abstract Builder destination(String destination); - - public abstract Builder additionalInfo(String additionalInfo); - - public abstract Operation build(); - } - - public abstract Builder toBuilder(); -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java deleted file mode 100644 index 8551266..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java +++ /dev/null @@ -1,34 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import com.google.auto.value.AutoValue; -import java.time.Instant; - -@AutoValue -public abstract class Registration { - public abstract long id(); - - public abstract Instant start(); - - public abstract Instant end(); - - public abstract Employee employee(); - - public static Builder builder() { - return new AutoValue_Registration.Builder().id(0); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder id(long id); - - public abstract Builder start(Instant start); - - public abstract Builder end(Instant end); - - public abstract Builder employee(Employee employee); - - public abstract Registration build(); - } - - public abstract Builder toBuilder(); -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java deleted file mode 100644 index 3456534..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java +++ /dev/null @@ -1,174 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -public class RegistrationValidator { - - private RegistrationValidator() {} - - public static void validate(Vehicle vehicle, Set registrations) - throws InvalidVehicleException, InvalidRegistrationException { - /* - Vehicles and Employees are assumed to be valid. - They have been checked at creation, and for them to be checked again, access to - VehicleValidator and EmployeeValidator are needed, which are not available at this time. - */ - /* - The method used here goes as follows: All given employees are inspected in regards to their - qualifications, and added to the appropriate lists of the roles they could fill. - For example, an NFS, who is also a driver, would be added to the lists driverIds, nfsIds - and rsIds (because an NFS can always substitute an RS). - Afterwards, the number of people is checked according to the chosen vehicle type, and if - the number is okay, the program tries to find a valid combination of roles for the vehicle. - For example, for an RTW, first a driver is chosen, their ID marked as found in the aptly - titled HashMap, and then for the second RS, the list of RS is checked, excluding the chosen - driver. If no other valid RS is found, the next possible driver is chosen, and so on. If no - valid combination is found, an InvalidRegistrationException is thrown. - */ - List pilotIds = new LinkedList<>(); - List driverIds = new LinkedList<>(); - List naIds = new LinkedList<>(); - List nfsIds = new LinkedList<>(); - List rsIds = new LinkedList<>(); - HashMap found = - new HashMap<>(); // needed later in DFS, checks that no person is chosen twice - int total = 0; - for (Registration registration : registrations) { - total++; - if (found.put(registration.employee().id(), false) != null) { - throw new InvalidRegistrationException( - "Person mit der ID: " - + registration.employee().id() - + " wurde mehrmals hinzugefügt!"); - } - if (registration.employee().isPilot()) { - pilotIds.add(registration.employee().id()); - } - if (registration.employee().isDriver()) { - driverIds.add(registration.employee().id()); - } - if (registration.employee().educationLevel() == EducationLevel.NA) { - naIds.add(registration.employee().id()); - nfsIds.add(registration.employee().id()); - rsIds.add(registration.employee().id()); - } else if (isNFS(registration.employee())) { - nfsIds.add(registration.employee().id()); - rsIds.add(registration.employee().id()); - } else { // only RS left - rsIds.add(registration.employee().id()); - } - } - if (total <= 0) { - throw new InvalidRegistrationException("Kein Personal ausgewählt!"); - } - if (vehicle.type() == VehicleType.NAH) { - /* - NAH - 1 Pilot - 1 NFS - 1 NA - 3-4 Personen - */ - if (total < 3) { - throw new InvalidRegistrationException("Zu wenig Personal für NAH!"); - } else if (total > 4) { - throw new InvalidRegistrationException("Zu viel Personal für NAH!"); - } - for (long pilot_id : pilotIds) { - found.put(pilot_id, true); - for (long na_id : naIds) { - if (found.get(na_id)) continue; - found.put(na_id, true); - for (long nfs_id : nfsIds) { - if (found.get(nfs_id)) continue; - return; - } - found.put(na_id, false); - } - found.put(pilot_id, false); - } - throw new InvalidRegistrationException( - "Keine gültige Kombination von Personen für NAH!"); - } else if (vehicle.type() == VehicleType.NEF) { - /* - NEF - 1 Driver (has to be NFS) - 1 NA - */ - if (total < 2) { - throw new InvalidRegistrationException("Zu wenig Personal für NEF!"); - } else if (total > 3) { - throw new InvalidRegistrationException("Zu viel Personal für NEF!"); - } - for (long driver_id : driverIds) { - if (!nfsIds.contains(driver_id)) - continue; // if possible driver is not NFS, skip him - found.put(driver_id, true); - for (long na_id : naIds) { - if (found.get(na_id)) continue; - return; - } - found.put(driver_id, false); - } - throw new InvalidRegistrationException( - "Keine gültige Kombination von Personen für NEF!"); - } else if (vehicle.type() == VehicleType.BKTW) { - /* - BKTW - 1 Driver - */ - if (total > 3) { - throw new InvalidRegistrationException("Zu viel Personal für BKTW!"); - } - if (!driverIds.isEmpty()) { - return; - } - throw new InvalidRegistrationException("Kein Fahrer gefunden für BKTW!"); - } else { // KTW or RTW, both have the same requirements - /* - RTW/KTW - 1 Driver - 1 RS - */ - if (total < 2) { - throw new InvalidRegistrationException( - "Zu wenig Personal für " + vehicle.type().name() + "!"); - } else if (total > 4) { - throw new InvalidRegistrationException( - "Zu viel Persoanl für " + vehicle.type().name() + "!"); - } - for (long driver_id : driverIds) { // driver includes rs - found.put(driver_id, true); - for (long rs_id : rsIds) { - if (found.get(rs_id)) continue; - return; - } - } - throw new InvalidRegistrationException( - "Keine gültige Kombination von Personen für " + vehicle.type().name() + "!"); - } - } - - private static boolean isNFS(Employee employee) { - EducationLevel educationLevel = employee.educationLevel(); - switch (educationLevel) { - case NFS: - return true; - case NKA: - return true; - case NKI: - return true; - case NKV: - return true; - default: - return false; - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java deleted file mode 100644 index e81db0b..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java +++ /dev/null @@ -1,73 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; - -import com.google.auto.value.AutoValue; -import java.util.List; -import javax.annotation.Nullable; - -@AutoValue -public abstract class Vehicle { - public enum ConstructionType { - NORMAL, - HOCHDACH, - MITTELHOCHDACH, - } - - public enum VehicleType { - BKTW, - KTW_B, - KTW, - RTW, - NEF, - NAH, - } - - public enum Status { - ABGEMELDET, - FREI_WACHE, - FREI_FUNK, - ZUM_BERUFUNGSORT, - AM_BERUFUNGSORT, - ZUM_ZIELORT, - AM_ZIELORT, - } - - public abstract long id(); - - public abstract String name(); - - public abstract ConstructionType constructionType(); - - public abstract VehicleType type(); - - public abstract Status status(); - - public abstract boolean hasNef(); - - @Nullable - public abstract List registrations(); - - public static Builder builder() { - return new AutoValue_Vehicle.Builder().id(0); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder id(long id); - - public abstract Builder name(String name); - - public abstract Builder constructionType(ConstructionType constructionType); - - public abstract Builder type(VehicleType type); - - public abstract Builder status(Status status); - - public abstract Builder hasNef(boolean hasNef); - - public abstract Builder registrations(List registrations); - - public abstract Vehicle build(); - } - - public abstract Builder toBuilder(); -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java deleted file mode 100644 index f7f8e71..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java +++ /dev/null @@ -1,46 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.Set; - -public interface EmployeeService { - - /** - * Add given employee to the store. - * - * @param employee that should be added to the store - * @return the id that was assigned - * @throws InvalidEmployeeException if the employee is invalid - * @throws ServiceException if the employee could not be persisted - */ - long add(Employee employee) throws InvalidEmployeeException, ServiceException; - - /** - * Update the given employee. - * - * @param employee that should be updated - * @return the updated employee - * @throws InvalidEmployeeException if the employee is invalid - * @throws ServiceException if the updated employee could not be persisted - */ - Employee update(Employee employee) throws InvalidEmployeeException, ServiceException; - - /** - * Get all stored employees. - * - * @return list containing all stored employees - * @throws ServiceException if loading the stored employees failed - */ - Set list() throws ServiceException; - - /** - * Remove employee with the given id from the store. - * - * @param id of the employee that should be removed - * @throws InvalidEmployeeException if given employee id is invalid or does not exist - * @throws ServiceException if the employee could not be removed from the store - */ - void remove(long id) throws InvalidEmployeeException, ServiceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java deleted file mode 100644 index cf054c3..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.EmployeeDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.EmployeeValidator; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.Set; -import org.springframework.stereotype.Service; - -@Service -public class EmployeeServiceImpl implements EmployeeService { - - private final EmployeeDAO employeePersistence; - - public EmployeeServiceImpl(EmployeeDAO employeePersistence) { - this.employeePersistence = employeePersistence; - } - - @Override - public long add(Employee employee) throws InvalidEmployeeException, ServiceException { - - EmployeeValidator.validate(employee); - try { - return employeePersistence.add(employee); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - } - - @Override - public Employee update(Employee employee) throws InvalidEmployeeException, ServiceException { - - EmployeeValidator.validate(employee); - try { - employeePersistence.update(employee); - return employee; - } catch (ElementNotFoundException | PersistenceException e) { - throw new ServiceException(e); - } - } - - @Override - public Set list() throws ServiceException { - - try { - return employeePersistence.list(); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - } - - @Override - public void remove(long id) throws InvalidEmployeeException, ServiceException { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java deleted file mode 100644 index 4b7e630..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java +++ /dev/null @@ -1,70 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.EnumSet; -import java.util.Set; -import java.util.SortedSet; - -public interface OperationService { - - /** - * Add given operation to the store. - * - * @param operation that should be added to the store - * @return the id that was assigned - * @throws InvalidOperationException if the operation is invalid - * @throws ServiceException if the operation could not be persisted - */ - long add(Operation operation) throws InvalidOperationException, ServiceException; - - /** - * Request new vehicles to the given operation. - * - * @param operationId id of the operation that the vehicles should be send to - * @param vehicleIds the ids of the vehicles that should be send to the given operation - * @throws InvalidOperationException if the operationId is invalid or does not exist - * @throws InvalidVehicleException if one of the vehicle ids is invalid or does not exist - * @throws ServiceException if the vehicles could not be loaded or the operation could not be - * persisted - */ - void requestVehicles(long operationId, Set vehicleIds) - throws InvalidOperationException, InvalidVehicleException, ServiceException; - - /** - * Completes the given operation with the specified status. - * - * @param operationId id of the operation that should be completed - * @param status of the completed operation, either {@link Status#COMPLETED} or {@link - * Status#CANCELLED} - * @throws InvalidOperationException if the operationId is invalid or does not exist - * @throws ServiceException if the operation could not be persisted - */ - void complete(long operationId, Status status) - throws InvalidOperationException, ServiceException; - - /** - * Get all available vehicles, sorted by how well they fit to the given opCode, starting with - * the best fitting. - * - * @param opCode the operation code that is used to determine the ranking - * @return a sorted list containing all available vehicles - * @throws InvalidOperationException if the opCode is invalid - * @throws ServiceException if loading the stored vehicles failed - */ - SortedSet rankVehicles(String opCode) - throws InvalidOperationException, ServiceException; - - /** - * Get all stored operations with matching status. - * - * @param statuses set containing all statuses that should be matched - * @return list containing all matched operations - * @throws ServiceException if loading the stored operations failed - */ - Set list(EnumSet statuses) throws ServiceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java deleted file mode 100644 index a83cf64..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java +++ /dev/null @@ -1,286 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.OperationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@Service -public class OperationServiceImpl implements OperationService { - - private static final Logger LOG = LoggerFactory.getLogger(OperationServiceImpl.class); - - private final OperationDAO operationDAO; - private final VehicleDAO vehicleDAO; - private final VehicleService vehicleService; - - public OperationServiceImpl( - OperationDAO operationDAO, VehicleDAO vehicleDAO, VehicleService vehicleService) { - this.operationDAO = operationDAO; - this.vehicleDAO = vehicleDAO; - this.vehicleService = vehicleService; - } - - @Override - public long add(Operation o) throws InvalidOperationException, ServiceException { - if (o.created() != null) { - throw new InvalidOperationException("Erstellungszeitpunkt darf nicht gesetzt sein"); - } - - if (o.severity() != null) { - throw new InvalidOperationException("Der Schweregrad darf nicht gesetzt sein"); - } - - if (o.id() != 0) { - throw new InvalidOperationException("Einsatz-ID muss 0 sein"); - } - - if (o.status() != Status.ACTIVE) - LOG.info("Status was set but will be overridden"); // TODO: nullable instead?? - - try { - for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { - Vehicle v = vehicleDAO.get(id); - VehicleServiceImpl.validateVehicle(v); - - if (v.status() != Vehicle.Status.FREI_FUNK - && v.status() != Vehicle.Status.FREI_WACHE) - throw new InvalidOperationException("Fahrzeug nicht verfügbar: " + v.status()); - } - - validateOperation(o); - - return operationDAO.add( - o.toBuilder() - .created(Instant.now()) - .severity(extractSeverityFromOpCode(o.opCode())) - .status(Status.ACTIVE) - .build()); - } catch (PersistenceException e) { - throw new ServiceException(e); - } catch (InvalidVehicleException e) { - // already logged as invalid vehicle - throw new InvalidOperationException("Enthaltenes Fahrzeug ist ungültig", e); - } catch (ElementNotFoundException e) { - throw new InvalidOperationException("Enthaltenes Fahrzeug existiert nicht", e); - } - } - - @Override - public void requestVehicles(long operationId, Set vehicleIds) - throws InvalidOperationException, InvalidVehicleException, ServiceException { - Set vs = new HashSet<>(); - - try { - if (operationId <= 0) { - throw new InvalidOperationException("Einsatz-ID ist ungültig"); - } - Operation o = operationDAO.get(operationId); - validateOperation(o); - - if (o.opCode().trim().isEmpty() - || extractSeverityFromOpCode(o.opCode()) != o.severity()) { - throw new InvalidOperationException("Einsatzcode ist ungültig"); - } - - if (o.status() != Status.ACTIVE) { - throw new InvalidOperationException("Einsatz ist ungültig"); - } - - if (o.created() == null) { - throw new InvalidOperationException("Erstellungszeitpunkt darf nicht leer sein"); - } - - for (Long id : vehicleIds) { - if (id <= 0) { - throw new InvalidVehicleException("Fahrzeug-ID ist ungültig"); - } - - try { - Vehicle v = vehicleDAO.get(id); - VehicleServiceImpl.validateVehicle(v); - if (v.status() != Vehicle.Status.FREI_FUNK - && v.status() != Vehicle.Status.FREI_WACHE) - throw new InvalidOperationException( - "Fahrzeug nicht verfügbar: " + v.status()); - - vs.add(v); - } catch (ElementNotFoundException e) { - throw new InvalidVehicleException("VehicleId ist invalid"); - } - } - - vs.addAll(o.vehicles()); - if (vs.equals(o.vehicles())) return; - - operationDAO.update(o.toBuilder().vehicles(vs).build()); - } catch (ElementNotFoundException e) { - throw new InvalidOperationException("Kein Einsatz mit dieser ID existiert"); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - } - - @Override - public void complete(long operationId, Status status) - throws InvalidOperationException, ServiceException { - try { - Operation o = operationDAO.get(operationId); - operationDAO.update(o.toBuilder().status(status).build()); - } catch (ElementNotFoundException e) { - throw new InvalidOperationException(e); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - } - - @Override - public SortedSet rankVehicles(String opCode) - throws InvalidOperationException, ServiceException { - Set vehicles = - vehicleService.list(EnumSet.complementOf(EnumSet.of(Vehicle.Status.ABGEMELDET))); - - List> priorities = new ArrayList<>(); - Predicate ktw = v -> v.type() == VehicleType.KTW; - Predicate rtwNoNEF = v -> v.type() == VehicleType.RTW && !v.hasNef(); - Predicate rtwNEF = v -> v.type() == VehicleType.RTW && v.hasNef(); - Predicate nef = v -> v.type() == VehicleType.NEF; - Predicate nah = v -> v.type() == VehicleType.NAH; - - switch (extractSeverityFromOpCode(opCode)) { - case A: - // fallthrough - case B: - // fallthrough - case O: - priorities.add(ktw); - priorities.add(rtwNoNEF); - priorities.add(rtwNEF); - break; - case C: - priorities.add(rtwNEF); - priorities.add(rtwNoNEF); - priorities.add(ktw); - break; - case D: - priorities.add(rtwNEF); - priorities.add(nef); - priorities.add(nah); - priorities.add(rtwNoNEF); - priorities.add(ktw); - break; - case E: - priorities.add(nah); - priorities.add(nef); - priorities.add(rtwNEF); - priorities.add(rtwNoNEF); - priorities.add(ktw); - break; - } - - Comparator vehicleComparator = - (v1, v2) -> { - for (Predicate priority : priorities) { - if (priority.test(v1)) { - return -1; - } - if (priority.test(v2)) { - return +1; - } - } - return 0; - }; - - Supplier> supplier = () -> new TreeSet<>(vehicleComparator); - - return vehicles.stream().collect(Collectors.toCollection(supplier)); - } - - @Override - public Set list(EnumSet statuses) throws ServiceException { - try { - Set operations = operationDAO.list(statuses); - for (Operation o : operations) validateOperation(o); - - return operations; - } catch (PersistenceException e) { - throw new ServiceException(e); - } catch (InvalidOperationException e) { - // database returned invalid values - throw new ServiceException("DB returned invalid operation", e); - } - } - - private static void validateOperation(Operation o) throws InvalidOperationException { - if (o.vehicles().isEmpty()) { - throw new InvalidOperationException( - "Es muss mindestens ein Fahrzeug ausgewählt werden!"); - } - - for (Vehicle v : o.vehicles()) { - try { - VehicleServiceImpl.validateVehicle(v); - } catch (InvalidVehicleException e) { - throw new InvalidOperationException("Fahrzeug " + v.name() + " ist ungültig", e); - } - - // TODO: validate if NEF/RTW/NAH conditions? - } - - Instant created = o.created(); - if (created != null && created.isAfter(Instant.now())) { - throw new InvalidOperationException("Einsatz wurde in der Zukunft erstellt"); - } - - if (o.destination() == null || o.destination().trim().isEmpty()) { - throw new InvalidOperationException("Adresse darf nicht leer sein"); - } - - if (o.destination().length() > 100) { - throw new InvalidOperationException("Adresse darf 100 Zeichen nicht überschreiten"); - } - - if (o.additionalInfo() != null && o.additionalInfo().length() > 100) { - throw new InvalidOperationException("Anmerkung darf 100 Zeichen nicht überschreiten"); - } - } - - private static final Pattern opCodePattern = - Pattern.compile("(?:\\w{1,3}-\\d{0,2})([ABCDEO])(?:.*)"); - - private static Severity extractSeverityFromOpCode(String opCode) - throws InvalidOperationException { - Matcher m = opCodePattern.matcher(opCode); - - if (!m.matches()) { - throw new InvalidOperationException("Einsatzcode ist ungültig"); - } - - return Severity.valueOf(m.group(1)); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java deleted file mode 100644 index b7d8eef..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java +++ /dev/null @@ -1,32 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.Set; - -public interface RegistrationService { - - /** - * Register employee to a vehicle. - * - * @param vehicleId the id of the target vehicle - * @param registrations that should be added to the vehicle - * @return the list of ids that were assigned - * @throws InvalidVehicleException if the vehicleId is invalid or does not exist - * @throws InvalidRegistrationException if the registration is invalid - * @throws ServiceException if the registration could not be persisted - */ - Set add(long vehicleId, Set registrations) - throws InvalidVehicleException, InvalidRegistrationException, ServiceException; - - /** - * Remove given registration from the store. - * - * @param registrationId the id of the registration that should be removed - * @throws InvalidRegistrationException if the registration is invalid or does not exist - * @throws ServiceException if the registration could not be removed from the store - */ - void remove(long registrationId) throws InvalidRegistrationException, ServiceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java deleted file mode 100644 index 1d92644..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.RegistrationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.RegistrationValidator; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class RegistrationServiceImpl implements RegistrationService { - - private final RegistrationDAO registrationDAO; - private final VehicleDAO vehicleDAO; - - @Autowired - public RegistrationServiceImpl(RegistrationDAO registrationDAO, VehicleDAO vehicleDAO) { - this.registrationDAO = registrationDAO; - this.vehicleDAO = vehicleDAO; - } - - @Override - public Set add(long vehicleId, Set registrations) - throws InvalidVehicleException, InvalidRegistrationException, ServiceException { - - if (vehicleId <= 0) throw new InvalidVehicleException("VehicleId invalid"); - - try { - Vehicle vehicle = vehicleDAO.get(vehicleId); - - RegistrationValidator.validate(vehicle, registrations); - - return registrationDAO.add(vehicle.id(), registrations); - } catch (PersistenceException e) { - throw new ServiceException(e); - } catch (ElementNotFoundException e) { - throw new InvalidVehicleException(e); - } - } - - @Override - public void remove(long registrationId) throws InvalidRegistrationException, ServiceException { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java deleted file mode 100644 index fe09ca1..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java +++ /dev/null @@ -1,49 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.EnumSet; -import java.util.Set; - -public interface VehicleService { - - /** - * Add given vehicle to the store. - * - * @param vehicle that should be added to the store - * @return the id that was assigned - * @throws InvalidVehicleException if the vehicle is invalid - * @throws ServiceException if the vehicle could not be persisted - */ - long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException; - - /** - * Update the given vehicle. - * - * @param vehicle that should be updated - * @return the updated vehicle - * @throws InvalidVehicleException if the vehicle is invalid - * @throws ServiceException if the updated vehicle could not be persisted - */ - Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException; - - /** - * Get all stored vehicles with matching status. - * - * @param statuses set containing all statuses that should be matched - * @return list containing all stored vehicles - * @throws ServiceException if loading the stored vehicles failed - */ - Set list(EnumSet statuses) throws ServiceException; - - /** - * Remove vehicle with the given id from the store. - * - * @param id of the vehicle that should be removed - * @throws InvalidVehicleException if given vehicle id is invalid or does not exist - * @throws ServiceException if the vehicle could not be removed from the store - */ - void remove(long id) throws InvalidVehicleException, ServiceException; -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java deleted file mode 100644 index 0bf4aa6..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -@Service -public class VehicleServiceImpl implements VehicleService { - - private VehicleDAO vehiclePersistence; - - public VehicleServiceImpl(VehicleDAO vehiclePersistence) { - this.vehiclePersistence = vehiclePersistence; - } - - public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { - if (!CollectionUtils.isEmpty(vehicle.registrations())) { - throw new InvalidVehicleException( - "Fahrzeug kann nicht mit Anmeldungen erstellt werden"); - } - - validateVehicle(vehicle); - try { - vehiclePersistence.add(vehicle); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - return 0; - } - - public Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException { - validateVehicle(vehicle); - try { - vehiclePersistence.update(vehicle); - } catch (ElementNotFoundException e) { - throw new ServiceException("Element not found", e); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - return vehicle; - } - - protected static void validateVehicle(Vehicle vehicle) throws InvalidVehicleException { - switch (vehicle.type()) { - case RTW: - if (vehicle.constructionType() == ConstructionType.NORMAL) { - throw new InvalidVehicleException("RTW darf kein Normales Dach haben"); - } else if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { - throw new InvalidVehicleException("RTW darf kein Mittelhochdach haben"); - } - break; - case KTW: - if (vehicle.constructionType() == ConstructionType.NORMAL) { - throw new InvalidVehicleException("KTW darf kein Normales Dach haben"); - } - break; - case KTW_B: - if (vehicle.constructionType() == ConstructionType.NORMAL) { - throw new InvalidVehicleException("KTW-B darf kein Normales Dach haben"); - } - break; - case NEF: - if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { - throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); - } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) { - throw new InvalidVehicleException("NEF darf kein Hochdach haben"); - } - break; - case NAH: - if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { - throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); - } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) { - throw new InvalidVehicleException("NEF darf kein Hochdach haben"); - } - break; - case BKTW: - break; - default: - throw new IllegalStateException("BUG: invalid vehicle type" + vehicle.type()); - } - } - - @Override - public Set list(EnumSet statuses) throws ServiceException { - if (statuses == null) { - throw new ServiceException("Statuses may not be null"); - } - - Set vehicles; - - try { - vehicles = vehiclePersistence.list(); - } catch (PersistenceException e) { - throw new ServiceException(e); - } - - return vehicles.stream() - .filter(vehicle -> statuses.contains(vehicle.status())) - .collect(Collectors.toSet()); - } - - @Override - public void remove(long id) throws InvalidVehicleException, ServiceException { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java new file mode 100644 index 0000000..6e0c89d --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java @@ -0,0 +1,213 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class ArchiveOperationController { + + private static final Logger LOG = LoggerFactory.getLogger(ArchiveOperationController.class); + + @FXML private ImageView imvVehicleDetail; + @FXML private Label lblStatus; + @FXML private AnchorPane apMainDetails; + @FXML private Label lblOperations; + @FXML private Label lblCompleted; + @FXML private Label lblCancelled; + @FXML private AnchorPane backApMain; + @FXML private AnchorPane backApDetails; + @FXML private AnchorPane archiveOperationAP; + @FXML private AnchorPane apDetails; + @FXML private Label lblCodeHeader; + @FXML private Label lblOpCode; + @FXML private Label lblVehicles; + @FXML private Label lblDate; + @FXML private Label lblAddress; + @FXML private FlowPane fpVehicles; + private final OperationService operationService; + @FXML private FlowPane archiveOperationFlowPane; + private final CreateOperationController createOperationController; + private Set list = new HashSet<>(); + private final SpringFXMLLoader fxmlLoader; + + public ArchiveOperationController( + OperationService operationService, + CreateOperationController createOperationController, + SpringFXMLLoader fxmlLoader) { + this.operationService = operationService; + this.createOperationController = createOperationController; + this.fxmlLoader = fxmlLoader; + } + + @FXML + private void initialize() { + update(); + } + + public void update() { + archiveOperationFlowPane.getChildren().clear(); + list.clear(); + try { + list.addAll(operationService.list(EnumSet.of(Status.CANCELLED, Status.COMPLETED))); + long cancelledAmount = 0; + long completedAmount = 0; + for (Operation operation : list) { + if (operation.status() == Status.CANCELLED) cancelledAmount++; + else completedAmount++; + } + lblCancelled.setText("storniert: " + cancelledAmount); + lblCompleted.setText("abgeschlossen: " + completedAmount); + lblOperations.setText("Einsätze: " + list.size()); + } catch (ServiceException e) { + LOG.error("ServiceException in update().", e); + showServiceExceptionAlertAndWait("Die Einsätze konnten nicht geladen werden!"); + ; + } + setFlowPane(); + } + + private void setFlowPane() { + try { + archiveOperationFlowPane.getChildren().clear(); + for (Operation operation : sortSet(list)) { + OperationInArchiveController opInAController = + OperationInArchiveController.create(); + opInAController.set(operation); + opInAController + .getRoot() + .setOnMouseClicked( + event -> { + detailOperation = operation; + backApMain.setVisible(false); + apMainDetails.setVisible(false); + backApDetails.setVisible(true); + setOperation(); + setDetailsVisible(true); + imvVehicleDetail.setImage(new Image("/images/Vehicle.png")); + }); + archiveOperationFlowPane.getChildren().add(opInAController.getRoot()); + } + } catch (IOException e) { + LOG.error("IOException in setFlowPane(). ", e); + showServiceExceptionAlertAndWait("Die Elemente konnten nicht geladen werden!"); + } + } + + private Operation detailOperation; + + private List sortSet(Set operationsSet) { + Operation[] array = operationsSet.toArray(new Operation[operationsSet.size()]); + for (int i = array.length - 1; i > 0; i--) { + for (int j = 0; j < i; j++) { + LocalDateTime first = + LocalDateTime.ofInstant( + Objects.requireNonNull(array[j].created()), ZoneOffset.UTC); + LocalDateTime second = + LocalDateTime.ofInstant( + Objects.requireNonNull(array[j + 1].created()), ZoneOffset.UTC); + if (first.isBefore(second)) { + Operation help = array[j]; + array[j] = array[j + 1]; + array[j + 1] = help; + } + } + } + return Arrays.asList(array); + } + + private void setOperation() { + lblCodeHeader.setText(detailOperation.opCode()); + if (detailOperation.created() != null) { + LocalDateTime dateTime = + LocalDateTime.ofInstant( + Objects.requireNonNull(detailOperation.created()), ZoneOffset.UTC); + lblDate.setText( + "am " + + dateTime.getDayOfMonth() + + "." + + dateTime.getMonth().getValue() + + "." + + dateTime.getYear()); + } else { + lblDate.setText("---"); + } + lblStatus.setText( + "Status: " + + (detailOperation.status() == Status.CANCELLED + ? "storniert" + : "abgeschlossen")); + lblOpCode.setText(detailOperation.opCode()); + Collection elements = + detailOperation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); + String result = String.join(", ", elements); + + lblVehicles.setText(result); + lblAddress.setText(detailOperation.destination()); + + fpVehicles.getChildren().clear(); + try { + for (Vehicle vehicle : detailOperation.vehicles()) { + DetailArchiveOperationController controller = null; + + controller = DetailArchiveOperationController.create(fxmlLoader); + + controller.set(vehicle); + fpVehicles.getChildren().add(controller.getRoot()); + } + } catch (IOException e) { + LOG.error("IOException in setOperation(). ", e); + showServiceExceptionAlertAndWait("Die Element konnte nicht geladen werden!"); + } + } + + private void setDetailsVisible(boolean b) { + apDetails.setVisible(b); + } + + public void backClicked() { + LOG.debug("Hyperlink \"Zurück\" in archive detail view clicked."); + fpVehicles.getChildren().clear(); + setDetailsVisible(false); + backApDetails.setVisible(false); + apMainDetails.setVisible(true); + backApMain.setVisible(true); + } + + public void backToMain() { + LOG.debug("Hyperlink \"Zurück\" in archive main view clicked."); + this.setVisible(false); + createOperationController.setVisible(true); + } + + void setVisible(boolean b) { + archiveOperationAP.setVisible(b); + backApMain.setVisible(b); + apMainDetails.setVisible(b); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java new file mode 100644 index 0000000..aa76535 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java @@ -0,0 +1,231 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.io.IOException; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javafx.collections.FXCollections; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceBox; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class CreateCarController { + + @FXML private AnchorPane createCarAP; + @FXML private ChoiceBox cmbCtype; + @FXML private ChoiceBox cmbTyp; + + @FXML private Button btnCreate; + @FXML private CheckBox cbxNEF; + @FXML private FlowPane fpVehicleList; + private final CreateOperationController createOperationController; + + private static final Logger LOG = LoggerFactory.getLogger(CreateCarController.class); + private final VehicleService vehicleService; + private boolean update = false; + private long vid = -1; + + private Vehicle chooseVehicle; + + public CreateCarController( + CreateOperationController createOperationController, VehicleService vehicleService) { + this.createOperationController = createOperationController; + this.vehicleService = vehicleService; + } + + @FXML + private void initialize() { + fpVehicleList.setHgap(5); + fpVehicleList.setVgap(5); + + cmbCtype.setItems( + FXCollections.observableArrayList( + Stream.of( + ConstructionType.NORMAL, + ConstructionType.MITTELHOCHDACH, + ConstructionType.HOCHDACH) + .map(Enum::toString) + .collect(Collectors.toList()))); + cmbCtype.setValue(ConstructionType.NORMAL.toString()); + cmbTyp.setItems( + FXCollections.observableArrayList( + Stream.of( + VehicleType.BKTW, + VehicleType.KTW_B, + VehicleType.KTW, + VehicleType.RTW, + VehicleType.NEF, + VehicleType.NAH) + .map(Enum::toString) + .collect(Collectors.toList()))); + cmbTyp.setValue(VehicleType.BKTW.toString()); + + updateVehiclePane(); + } + + @FXML + private void createCar(ActionEvent actionEvent) { + + if (!update) { + LOG.debug("Button \"Erstellen\" clicked."); + Vehicle vehicle = + Vehicle.builder() + .constructionType(parseConstructionType()) + .type(parseType()) + .name("") + .status(Status.ABGEMELDET) + .hasNef(cbxNEF.isSelected()) + .build(); + try { + vehicleService.add(vehicle); + setToStart(); + } catch (InvalidVehicleException e) { + LOG.debug("Validation of Vehicle failed"); + showValidationErrorAlertAndWait(e.getMessage()); + setToStart(); + return; + } catch (ServiceException e) { + LOG.error("ServiceException in createCar(). ", e); + showServiceExceptionAlertAndWait( + "Ein Fehler beim Erstellen des Fahrzeuges ist aufgetreten."); + setToStart(); + return; + } + showSuccessAlertAndWait("Auto wurde erfolgreich angelegt."); + } else { + LOG.debug("Button \"Speichern\" clicked."); + try { + Vehicle vehicle = + Vehicle.builder() + .id(vid) + .constructionType(parseConstructionType()) + .type(parseType()) + .name("") + .status(Status.ABGEMELDET) + .hasNef(cbxNEF.isSelected()) + .build(); + vehicleService.update(vehicle); + setToStart(); + chooseVehicle = null; + } catch (InvalidVehicleException e) { + LOG.debug("Validation of Vehicle failed"); + showValidationErrorAlertAndWait(e.getMessage()); + setToStart(); + return; + } catch (ServiceException e) { + LOG.error("ServiceException in createCar(). ", e); + showServiceExceptionAlertAndWait(e.getMessage()); + setToStart(); + return; + } + showSuccessAlertAndWait("Auto wurde erfolgreich bearbeitet."); + } + + updateVehiclePane(); + } + + private ConstructionType parseConstructionType() { + if (cmbCtype.getSelectionModel().getSelectedItem() == null) { + return ConstructionType.NORMAL; + } + return ConstructionType.valueOf(cmbCtype.getSelectionModel().getSelectedItem()); + } + + private VehicleType parseType() { + if (cmbTyp.getSelectionModel().getSelectedItem() == null) { + return VehicleType.BKTW; + } + return VehicleType.valueOf(cmbTyp.getSelectionModel().getSelectedItem()); + } + + private void setToStart() { + btnCreate.setText("Erstellen"); + cbxNEF.setSelected(false); + cmbTyp.setValue(VehicleType.BKTW.name()); + cmbCtype.setValue(ConstructionType.NORMAL.name()); + update = false; + } + + private void updateVehicle(Vehicle vehicle) { + + cmbCtype.setValue(vehicle.constructionType().name()); + cmbTyp.setValue(vehicle.type().name()); + cbxNEF.setSelected(vehicle.hasNef()); + btnCreate.setText("Speichern"); + vid = vehicle.id(); + update = true; + chooseVehicle = vehicle; + } + + public void setVisible(boolean b) { + createCarAP.setVisible(b); + } + + @FXML + private void backToMain() { + LOG.debug("Hyperlink \"zurück\" clicked."); + this.setVisible(false); + createOperationController.setVisible(true); + } + + private void updateVehiclePane() { + try { + fpVehicleList.getChildren().clear(); + + Set vehicles; + + vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + + for (Vehicle vehicle : vehicles) { + VehiclePaneController controller = VehiclePaneController.createVehiclePane(); + + controller.setData(vehicle, false, false); + controller + .getRootElement() + .setOnMouseClicked( + event -> { + if (event.getButton().equals(MouseButton.PRIMARY)) { + if (chooseVehicle == null || vehicle == chooseVehicle) { + if (update == false) { + chooseVehicle = vehicle; + updateVehicle(vehicle); + controller.setSelected(true); + } else { + setToStart(); + controller.setSelected(false); + + chooseVehicle = null; + } + } + } + }); + + fpVehicleList.getChildren().add(controller.getRootElement()); + } + } catch (ServiceException | IOException e) { + LOG.error("Exception in updateVehiclePane(). ", e); + showServiceExceptionAlertAndWait(e.getMessage()); + } + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java new file mode 100644 index 0000000..433bfa6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java @@ -0,0 +1,174 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.time.LocalDate; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javafx.collections.FXCollections; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; + +@Controller +@Scope("prototype") +public class CreateNewEmployeeController { + + private static final Logger LOG = LoggerFactory.getLogger(CreateNewEmployeeController.class); + private final EmployeeService employeeService; + + @FXML private Label lblHeader; + @FXML private CheckBox inputIsDriver; + @FXML private CheckBox inputIsPilot; + @FXML private TextField inputName; + @FXML private ChoiceBox inputQualification; + @FXML private Button btnCreate; + + private Node rootElement; + private Employee employee; + private boolean isEdit; + + private Runnable consumerCancelClicked; + private Runnable consumerCreateClicked; + + public CreateNewEmployeeController(EmployeeService employeeService) { + this.employeeService = employeeService; + } + + @FXML + private void initialize() { + inputQualification.setItems( + FXCollections.observableArrayList( + Stream.of( + EducationLevel.RS, + EducationLevel.NFS, + EducationLevel.NKV, + EducationLevel.NKA, + EducationLevel.NKI, + EducationLevel.NA) + .map(Enum::toString) + .collect(Collectors.toList()))); + + inputQualification.setValue(EducationLevel.RS.toString()); + employee = + Employee.builder() + .name("") + .educationLevel(EducationLevel.RS) + .isDriver(false) + .isPilot(false) + .birthday(LocalDate.MIN) + .build(); + } + + @FXML + private void onCancelClicked() { + LOG.debug("Hyperlink \"abbrechen\" clicked."); + if (consumerCancelClicked != null) { + consumerCancelClicked.run(); + } + } + + @FXML + private void onCreateClicked() { + LOG.debug("Button {} clicked.", btnCreate.getText()); + + employee = + employee.toBuilder() + .name(inputName.getText()) + .educationLevel(parseEducationLevel()) + .birthday(LocalDate.MIN) // TODO: change UI to include birthday field + .isDriver(inputIsDriver.isSelected()) + .isPilot(inputIsPilot.isSelected()) + .build(); + + try { + if (isEdit) { + employeeService.update(employee); + } else { + employeeService.add(employee); + } + } catch (InvalidEmployeeException e) { + LOG.debug("Validation for Employee failed"); + showValidationErrorAlertAndWait(e.getMessage()); + return; + } catch (ServiceException e) { + LOG.error("ServiceException in onCreateClicked(). ", e); + showServiceExceptionAlertAndWait( + "Der Eintrag konnte nicht gespeichert werden. Bitte versuchen Sie es erneut."); + return; + } + + showSuccessAlertAndWait( + "Der/die MitarbeiterIn wurde erfolgreich angelegt und gespeichert!"); + + if (consumerCreateClicked != null) { + consumerCreateClicked.run(); + } + } + + private EducationLevel parseEducationLevel() { + if (inputQualification.getSelectionModel().getSelectedItem() == null) { + return EducationLevel.RS; + } + return EducationLevel.valueOf(inputQualification.getSelectionModel().getSelectedItem()); + } + + private void setData(Employee employee) { + isEdit = true; + this.employee = employee; + inputName.setText(employee.name()); + inputQualification.setValue(employee.educationLevel().name()); + inputIsDriver.setSelected(employee.isDriver()); + inputIsPilot.setSelected(employee.isPilot()); + lblHeader.setText("Person bearbeiten"); + btnCreate.setText("Speichern"); + } + + public static CreateNewEmployeeController createCreateNewEmployeeController( + SpringFXMLLoader fxmlLoader, Employee employee) throws IOException { + CreateNewEmployeeController controller = createCreateNewEmployeeController(fxmlLoader); + controller.setData(employee); + return controller; + } + + public static CreateNewEmployeeController createCreateNewEmployeeController( + SpringFXMLLoader fxmlLoader) throws IOException { + FXMLWrapper wrapper = + fxmlLoader.loadAndWrap( + "/fxml/createNewEmployee.fxml", CreateNewEmployeeController.class); + Node root = (Node) wrapper.getLoadedObject(); + CreateNewEmployeeController controller = wrapper.getController(); + controller.rootElement = root; + return controller; + } + + public Node getRootElement() { + return rootElement; + } + + public void setConsumerCancelClicked(Runnable consumerCancelClicked) { + this.consumerCancelClicked = consumerCancelClicked; + } + + public void setConsumerCreateClicked(Runnable consumerCreateClicked) { + this.consumerCreateClicked = consumerCreateClicked; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java new file mode 100644 index 0000000..b237265 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java @@ -0,0 +1,371 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import javafx.collections.FXCollections; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.GridPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class CreateOperationController { + + private static final Logger LOG = LoggerFactory.getLogger(CreateOperationController.class); + + public AnchorPane apCreateOperation; + @FXML private GridPane grdWindowContainer; + @FXML private TextField txtCode; + @FXML private TextField txtAddress; + @FXML private TextField txtNote; + @FXML private Button btnCreateOperation; + @FXML private ListView lvVehicles; + @FXML private ListView lvActiveOperations; + @FXML private Label lblChosenVehicles; + @FXML private AnchorPane apInvisible; + @FXML private OperationDetailsController operationDetailsController; + @FXML private ManageEmployeesController manageEmployeesController; + @FXML private CreateCarController createCarController; + @FXML private RegistrationWindowController registrationWindowController; + @FXML private ArchiveOperationController archiveOperationController; + @FXML private FlowPane fpVehicles; + + private LinkedList chosenVehicles = new LinkedList<>(); + + private final OperationService operationService; + private final VehicleService vehicleService; + + public CreateOperationController( + OperationService operationService, VehicleService vehicleService) { + this.operationService = operationService; + this.vehicleService = vehicleService; + } + + @FXML + private void initialize() { + + lblChosenVehicles.setText("keine ausgewählt"); + lvActiveOperations.setCellFactory(param -> generateOpCodeListItem()); + + lvActiveOperations.setOnMouseClicked( + event -> { + if (event.getClickCount() == 2) { + if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { + return; + } + openDetailsWindow(lvActiveOperations.getSelectionModel().getSelectedItem()); + } + }); + + setVisible(true); + createCarController.setVisible(false); + registrationWindowController.setVisible(false); + } + + public void updateList() { + try { + fpVehicles.getChildren().clear(); + + // TODO: this should probably be handled differently + Set vehicles; + if (txtCode.getText().isEmpty()) { + vehicles = + vehicleService.list( + EnumSet.complementOf(EnumSet.of(Vehicle.Status.ABGEMELDET))); + } else { + vehicles = operationService.rankVehicles(txtCode.getText()); + } + + for (Vehicle vehicle : vehicles) { + VehiclePaneController controller = VehiclePaneController.createVehiclePane(); + + controller.setData(vehicle, true, false); + controller + .getRootElement() + .setOnMouseClicked( + event -> { + if (event.getButton().equals(MouseButton.SECONDARY)) { + createContextMenu(vehicle, vehicleService) + .show( + controller.getRootElement(), + event.getScreenX(), + event.getScreenY()); + } else { + if (chosenVehicles.contains(vehicle)) { + chosenVehicles.remove(vehicle); + controller.setSelected(false); + } else { + chosenVehicles.add(vehicle); + controller.setSelected(true); + } + + StringBuilder result = new StringBuilder(); + for (int i = 0; i < chosenVehicles.size(); i++) { + if (i == chosenVehicles.size() - 1) { + result.append(chosenVehicles.get(i).name()); + } else { + result.append(chosenVehicles.get(i).name()) + .append(", "); + } + } + if (result.toString().equals("")) { + lblChosenVehicles.setText("keine ausgewählt"); + } else { + lblChosenVehicles.setText(result.toString()); + } + } + }); + + if (chosenVehicles.stream().anyMatch(v -> v.id() == vehicle.id())) + controller.setSelected(true); + + fpVehicles.getChildren().add(controller.getRootElement()); + } + } catch (ServiceException | IOException e) { + LOG.error("Exception in updateList(). ", e); + showServiceExceptionAlertAndWait( + "Beim Erstellen des Ranking ist ein Fehler aufgetreten."); + } catch (InvalidOperationException e) { + LOG.debug("Validation error in updateList(). ", e); + showValidationErrorAlertAndWait(e.getMessage()); + } + try { + lvActiveOperations.setItems( + FXCollections.observableArrayList( + operationService.list(EnumSet.of(Status.ACTIVE)))); + } catch (ServiceException e) { + LOG.error("ServiceException in updateList(). ", e); + showServiceExceptionAlertAndWait( + "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten"); + } + } + + private ContextMenu createContextMenu(Vehicle data, VehicleService vehicleService) { + ContextMenu menu = new ContextMenu(); + + for (Vehicle.Status status : Vehicle.Status.values()) { + if (status == Vehicle.Status.ABGEMELDET) { + continue; + } + + MenuItem mi = new MenuItem(status.name()); + + if (status == Vehicle.Status.FREI_FUNK || status == Vehicle.Status.FREI_WACHE) { + mi.getStyleClass().add("mi-free"); + } else { + mi.getStyleClass().add("mi-other"); + } + + mi.setOnAction( + event -> { + try { + vehicleService.update(data.toBuilder().status(status).build()); + this.updateList(); + } catch (InvalidVehicleException e) { + LOG.debug( + "Validation error in createContextMenu(). (mi.setOnAction) ", + e); + showValidationErrorAlertAndWait(e.getMessage()); + } catch (ServiceException e) { + LOG.error("Exception in createContextMenu(). (mi.setOnAction) ", e); + showServiceExceptionAlertAndWait( + "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten."); + } + }); + + menu.getItems().add(mi); + } + + MenuItem abmelden = new MenuItem("abmelden"); + + abmelden.setOnAction( + event -> { + try { + List registrations = data.registrations(); + assert registrations + != null; // Otherwise the element shouldn't be in the list. + + List newRegistrations = new ArrayList<>(); + Instant now = Instant.now(); + + for (Registration registration : registrations) { + if (registration.start().isBefore(now) + && registration.end().isAfter(now)) { + newRegistrations.add( + registration + .toBuilder() + .end(Instant.now().minus(1, ChronoUnit.SECONDS)) + .build()); + } else newRegistrations.add(registration); + } + + vehicleService.update( + data.toBuilder() + .registrations(newRegistrations) + .status(Vehicle.Status.ABGEMELDET) + .build()); + + this.updateList(); + } catch (InvalidVehicleException e) { + LOG.debug( + "Validation error in createContextMenu(). (abmelden.setOnAction) ", + e); + showValidationErrorAlertAndWait(e.getMessage()); + } catch (ServiceException e) { + LOG.error("Exception in createContextMenu(). (abmelden.setOnAction) ", e); + showServiceExceptionAlertAndWait( + "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten."); + } + }); + + menu.getItems().add(abmelden); + return menu; + } + + @FXML + protected void createOperationClicked() { + LOG.debug("Button \"Erstellen\" clicked."); + Vehicle[] vehicles = new Vehicle[chosenVehicles.size()]; + for (int i = 0; i < chosenVehicles.size(); i++) { + vehicles[i] = chosenVehicles.get(i); + } + Operation operation = + Operation.builder() + .additionalInfo(txtNote.getText()) + .destination(txtAddress.getText()) + .opCode(txtCode.getText()) + .status(Status.ACTIVE) + .vehicles(Set.of(vehicles)) + .build(); + try { + operationService.add(operation); + } catch (ServiceException e) { + LOG.error("Exception in createOperationClicked(). ", e); + showServiceExceptionAlertAndWait( + "Beim Erstellen des Einsatzes ist ein Fehler aufgetreten."); + return; + } catch (InvalidOperationException e) { + LOG.debug("Validation error in createOperationClicked(). ", e); + showValidationErrorAlertAndWait(e.getMessage()); + return; + } + showSuccessAlertAndWait("Der Einsatz wurde erfolgreich gespeichert."); + updateList(); + lblChosenVehicles.setText("keine ausgewählt"); + txtAddress.setText(""); + txtCode.setText(""); + txtNote.setText(""); + chosenVehicles = new LinkedList<>(); + } + + @FXML + private void onRegistrationLinkClicked() { + LOG.debug("Hyperlink \"Anmeldungen\" clicked."); + openRegistrationWindow(); + } + + @FXML + private void onEmployeeLinkClicked() { + LOG.debug("Hyperlink \"Personen\" clicked."); + openCreateNewEmployeeWindow(); + } + + @FXML + private void onVehicleLinkClicked() { + LOG.debug("Hyperlink \"Fahrzeuge\" clicked."); + openCreateCarWindow(); + } + + @FXML + private void onArchivLinkClicked() { + LOG.debug("Hyperlink \"Archiv\" clicked."); + archiveOperationController.update(); + openArchivWindow(); + } + + private void openArchivWindow() { + archiveOperationController.setVisible(true); + this.setVisible(false); + } + + void setVisible(boolean b) { + apInvisible.setVisible(!b); + grdWindowContainer.setVisible(!b); + + updateList(); + } + + private void openDetailsWindow(Operation operation) { + operationDetailsController.initOperation(operation); + this.setVisible(false); + } + + private void openCreateNewEmployeeWindow() { + this.setVisible(false); + manageEmployeesController.setVisible(true); + } + + private void openCreateCarWindow() { + this.setVisible(false); + createCarController.setVisible(true); + } + + private void openRegistrationWindow() { + this.setVisible(false); + registrationWindowController.setVisible(true); + } + + @FXML + private void onOperationCodeChanged(KeyEvent keyEvent) { + if (keyEvent.getCode() == KeyCode.ENTER) { + updateList(); + } + } + + static ListCell generateOpCodeListItem() { + return new ListCell<>() { + @Override + protected void updateItem(Operation item, boolean empty) { + super.updateItem(item, empty); + + if (empty || item == null || item.opCode() == null) { + setText(null); + } else { + setText(item.opCode()); + } + } + }; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java new file mode 100644 index 0000000..ced0c10 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java @@ -0,0 +1,24 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import javafx.scene.Node; + +public abstract class CustomListItemController { + + protected Node rootElement; + + public Node getRootElement() { + return rootElement; + } + + public void setSelected(boolean selected) { + rootElement.getStyleClass().clear(); + + if (selected) { + rootElement.getStyleClass().add("bg-yellow"); + rootElement.getStyleClass().add("shadowed"); + } else { + rootElement.getStyleClass().add("bg-white"); + rootElement.getStyleClass().add("shadowed"); + } + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java new file mode 100644 index 0000000..32630a5 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java @@ -0,0 +1,77 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.Objects; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class DetailArchiveOperationController { + private static final Logger LOG = + LoggerFactory.getLogger(DetailArchiveOperationController.class); + + @FXML private VBox vBoxVehicle; + @FXML private VBox vBoxPeople; + private final SpringFXMLLoader fxmlLoader; + + public DetailArchiveOperationController(SpringFXMLLoader fxmlLoader) { + this.fxmlLoader = fxmlLoader; + } + + static DetailArchiveOperationController create(SpringFXMLLoader fxmlLoader) throws IOException { + FXMLWrapper wrapper = + fxmlLoader.loadAndWrap( + "/fxml/DetailArchiveOperation.fxml", + DetailArchiveOperationController.class); + + Node root = (Node) wrapper.getLoadedObject(); + DetailArchiveOperationController result = wrapper.getController(); + result.rootElement = root; + + return result; + } + + public Node getRoot() { + return rootElement; + } + + private Node rootElement; + + public void set(Vehicle vehicle) { + VehiclePaneController controller; + try { + controller = VehiclePaneController.createVehiclePane(); + controller.setData(vehicle, false, false); + vBoxVehicle.getChildren().add(controller.getRootElement()); + } catch (IOException e) { + LOG.error("IOException in set(Vehicle). (vBoxVehicle) ", e); + showServiceExceptionAlertAndWait( + "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); + } + try { + for (int i = 0; i < Objects.requireNonNull(vehicle.registrations()).size(); i++) { + Employee employee = + Objects.requireNonNull(vehicle.registrations()).get(i).employee(); + + EmployeeListItemController employeeListItemController = + EmployeeListItemController.createEmployeeListItemController( + fxmlLoader, employee); + vBoxPeople.getChildren().add(employeeListItemController.getRootElement()); + } + } catch (IOException e) { + LOG.error("IOException in set(Vehicle). (vBoxPeople) ", e); + showServiceExceptionAlertAndWait( + "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); + } + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java new file mode 100644 index 0000000..12f6bff --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java @@ -0,0 +1,133 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; + +@Controller +@Scope("prototype") +public class EmployeeListController { + + private static final Logger LOG = LoggerFactory.getLogger(EmployeeListController.class); + + @FXML private FlowPane flowPaneEmployeeList; + + private Consumer onEmployeeClicked; + + private final SpringFXMLLoader fxmlLoader; + private Node rootElement; + private List employeeListItemControllers; + private Insets listItemMargins = new Insets(10, 5, 0, 5); + + public EmployeeListController(SpringFXMLLoader fxmlLoader) { + this.fxmlLoader = fxmlLoader; + this.employeeListItemControllers = new ArrayList<>(); + } + + public void setListItemMargins(Insets value) { + this.listItemMargins = value; + } + + public void setData(Set employeeList) { + setData(employeeList, null, null); + } + + public void setData(Set employeeList, Consumer onEmployeeClicked) { + setData(employeeList, onEmployeeClicked, null); + } + + public void setData( + Set employeeList, + Consumer onEmployeeClicked, + Consumer onEmployeeListItemClicked) { + + flowPaneEmployeeList.getChildren().clear(); + employeeListItemControllers.clear(); + employeeList.forEach( + employee -> + addEmployeeToFlowPane( + employee, onEmployeeClicked, onEmployeeListItemClicked)); + } + + private void addEmployeeToFlowPane( + Employee employee, + Consumer onEmployeeClicked, + Consumer onEmployeeListItemClicked) { + + try { + EmployeeListItemController controller = + EmployeeListItemController.createEmployeeListItemController( + fxmlLoader, employee); + Node rootElement = controller.getRootElement(); + flowPaneEmployeeList.getChildren().add(rootElement); + employeeListItemControllers.add(controller); + FlowPane.setMargin(rootElement, listItemMargins); + if (onEmployeeClicked != null) { + controller.setConsumerEmployeeClicked(onEmployeeClicked); + } + if (onEmployeeListItemClicked != null) { + controller.setConsumerEmployeeListItemClicked( + employeeListItemController -> { + onEmployeeListItemClicked.accept(employeeListItemController); + if (this.onEmployeeClicked != null) { + this.onEmployeeClicked.accept( + employeeListItemController.getEmployee()); + } + }); + } + } catch (IOException e) { + LOG.error("IOException in addEmployeeToFlowPane. ", e); + } + } + + private void setEmployeeSelected(Employee employee, boolean selected) { + employeeListItemControllers + .stream() + .filter(controller -> controller.getEmployee().equals(employee)) + .forEach(controller -> controller.setSelected(selected)); + } + + public void selectEmployee(Employee employee) { + setEmployeeSelected(employee, true); + } + + public void deselectEmployee(Employee employee) { + setEmployeeSelected(employee, false); + } + + public void deselectAllEmployees() { + employeeListItemControllers.forEach( + employeeListItemController -> employeeListItemController.setSelected(false)); + } + + public static EmployeeListController createEmployeeListController(SpringFXMLLoader loader) + throws IOException { + FXMLWrapper wrapper = + loader.loadAndWrap("/fxml/employeeList.fxml", EmployeeListController.class); + Node root = (Node) wrapper.getLoadedObject(); + EmployeeListController controller = wrapper.getController(); + controller.rootElement = root; + return controller; + } + + public Node getRootElement() { + return rootElement; + } + + public void setOnEmployeeClicked(Consumer onEmployeeClicked) { + this.onEmployeeClicked = onEmployeeClicked; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java new file mode 100644 index 0000000..543fe0d --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java @@ -0,0 +1,87 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.function.Consumer; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; + +@Controller +@Scope("prototype") +public class EmployeeListItemController extends CustomListItemController { + + @FXML private Label lblName; + @FXML private Label lblQualification; + @FXML private Label lblPilot; + @FXML private Label lblDriver; + @FXML private ImageView imgPilot; + @FXML private ImageView imgDriver; + @FXML private ImageView imgQualification; + + private Employee employee; + + private Consumer consumerEmployeeClicked; + private Consumer consumerEmployeeListItemClicked; + + @FXML + private void onEmployeeClicked() { + if (consumerEmployeeClicked != null) { + consumerEmployeeClicked.accept(employee); + } + if (consumerEmployeeListItemClicked != null) { + consumerEmployeeListItemClicked.accept(this); + } + } + + private void setData(Employee employee) { + this.employee = employee; + lblName.setText(employee.name()); + lblQualification.setText(employee.educationLevel().name()); + lblPilot.setText(String.format("%s Pilot", employee.isPilot() ? "ist" : "nicht")); + lblDriver.setText(String.format("%s Fahrer", employee.isDriver() ? "ist" : "nicht")); + imgQualification.setImage(new Image("/images/Qualification.png")); + String imgSrcPilot = + String.format("/images/%s", employee.isPilot() ? "Pilot.png" : "NotPilot.png"); + imgPilot.setImage(new Image(imgSrcPilot)); + String imgSrcDriver = + String.format("/images/%s", employee.isDriver() ? "Driver.png" : "NotDriver.png"); + imgDriver.setImage(new Image(imgSrcDriver)); + } + + public static EmployeeListItemController createEmployeeListItemController( + SpringFXMLLoader fxmlLoader, Employee employee) throws IOException { + EmployeeListItemController controller = createEmployeeListItemController(fxmlLoader); + controller.setData(employee); + return controller; + } + + public static EmployeeListItemController createEmployeeListItemController( + SpringFXMLLoader loader) throws IOException { + FXMLWrapper wrapper = + loader.loadAndWrap("/fxml/employeeListItem.fxml", EmployeeListItemController.class); + Node root = (Node) wrapper.getLoadedObject(); + EmployeeListItemController controller = wrapper.getController(); + controller.rootElement = root; + return controller; + } + + public Employee getEmployee() { + return employee; + } + + public void setConsumerEmployeeClicked(Consumer consumerEmployeeClicked) { + this.consumerEmployeeClicked = consumerEmployeeClicked; + } + + public void setConsumerEmployeeListItemClicked( + Consumer consumerEmployeeListItemClicked) { + this.consumerEmployeeListItemClicked = consumerEmployeeListItemClicked; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java new file mode 100644 index 0000000..a31c3e3 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.function.Consumer; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.TextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; + +@Controller +@Scope("prototype") +public class FilterEmployeesController { + private static final Logger LOG = LoggerFactory.getLogger(FilterEmployeesController.class); + + @FXML private TextField inputFilterString; + + private Consumer consumerFilterTextChanged; + private Runnable consumerAddEmployeeClicked; + + private Node rootElement; + + @FXML + private void onAddEmployeeClicked() { + LOG.debug("Button \"Person hinzufügen\" clicked."); + if (consumerAddEmployeeClicked != null) { + consumerAddEmployeeClicked.run(); + } + } + + @FXML + private void onFilterTextChanged() { + LOG.debug("Filter text changed."); + if (consumerFilterTextChanged != null) { + consumerFilterTextChanged.accept(inputFilterString.getText()); + } + } + + public void setOnFilterTextChangedListener(Consumer callback) { + this.consumerFilterTextChanged = callback; + } + + public void setOnAddEmployeeClickedListener(Runnable callback) { + this.consumerAddEmployeeClicked = callback; + } + + public static FilterEmployeesController createFilterEmployeesController( + SpringFXMLLoader fxmlLoader) throws IOException { + FXMLWrapper wrapper = + fxmlLoader.loadAndWrap( + "/fxml/filterEmployeesControl.fxml", FilterEmployeesController.class); + Node root = (Node) wrapper.getLoadedObject(); + FilterEmployeesController controller = wrapper.getController(); + controller.rootElement = root; + return controller; + } + + public Node getRootElement() { + return rootElement; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java new file mode 100644 index 0000000..f120eb6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java @@ -0,0 +1,34 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ButtonType; + +public class Helper { + + static final String ALERT_TITLE_VALIDATION_ERROR = "Validierungsfehler"; + static final String ALERT_TITLE_SERVICE_EXCEPTION = "Fehler"; + static final String ALERT_TITLE_SUCCESS = "Erfolg"; + + private Helper() {} // SonarLint insisted to create a private constructor to hide the public one + + static void showValidationErrorAlertAndWait(String message) { + showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_VALIDATION_ERROR, message); + } + + static void showServiceExceptionAlertAndWait(String message) { + showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_SERVICE_EXCEPTION, message); + } + + static void showSuccessAlertAndWait(String message) { + showAlertWithOkButtonAndWait(AlertType.INFORMATION, ALERT_TITLE_SUCCESS, message); + } + + static void showAlertWithOkButtonAndWait( + AlertType alertType, String headerText, String contentText) { + Alert alert = new Alert(alertType, contentText, ButtonType.OK); + alert.setTitle(headerText); + alert.setHeaderText(headerText); + alert.showAndWait(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java new file mode 100644 index 0000000..6138094 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java @@ -0,0 +1,120 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.io.IOException; +import java.util.HashSet; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.scene.layout.AnchorPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class ManageEmployeesController { + + private static final Logger LOG = LoggerFactory.getLogger(ManageEmployeesController.class); + @FXML private AnchorPane listEmployeesAP; + @FXML private AnchorPane containerHeader; + @FXML private EmployeeListController employeeListController; + + private final EmployeeService employeeService; + private final SpringFXMLLoader fxmlLoader; + + private final CreateOperationController createOperationController; + + public ManageEmployeesController( + EmployeeService employeeService, + SpringFXMLLoader fxmlLoader, + CreateOperationController createOperationController) { + this.employeeService = employeeService; + this.fxmlLoader = fxmlLoader; + this.createOperationController = createOperationController; + } + + @FXML + private void initialize() { + openFilter(); + } + + private void openFilter() { + try { + FilterEmployeesController filterEmployeesController = + FilterEmployeesController.createFilterEmployeesController(fxmlLoader); + containerHeader.getChildren().clear(); + containerHeader.getChildren().add(filterEmployeesController.getRootElement()); + filterEmployeesController.setOnFilterTextChangedListener(this::updateEmployeeList); + filterEmployeesController.setOnAddEmployeeClickedListener(this::openAddEmployee); + updateEmployeeList(); + + } catch (IOException e) { + LOG.error("IOException in openFilter().", e); + } + } + + private void openAddEmployee() { + employeeListController.deselectAllEmployees(); + openEmployee(null); + } + + private void openEditEmployee(Employee employee) { + employeeListController.deselectAllEmployees(); + employeeListController.selectEmployee(employee); + openEmployee(employee); + } + + private void openEmployee(Employee employee) { + try { + CreateNewEmployeeController createNewEmployeeController = + employee == null + ? CreateNewEmployeeController.createCreateNewEmployeeController( + fxmlLoader) + : CreateNewEmployeeController.createCreateNewEmployeeController( + fxmlLoader, employee); + containerHeader.getChildren().clear(); + containerHeader.getChildren().add(createNewEmployeeController.getRootElement()); + createNewEmployeeController.setConsumerCancelClicked(this::openFilter); + createNewEmployeeController.setConsumerCreateClicked(this::openFilter); + } catch (IOException e) { + LOG.error("IOException in openEmployee(). ", e); + } + } + + private void updateEmployeeList() { + updateEmployeeList(""); + } + + private void updateEmployeeList(String searchString) { + + try { + employeeListController.setData( + employeeService + .list() + .stream() + .filter( + employee -> + searchString.trim().isEmpty() + || employee.name() + .toLowerCase() + .contains(searchString.toLowerCase())) + .collect(Collectors.toCollection(HashSet::new)), + this::openEditEmployee); + + } catch (ServiceException e) { + LOG.error("ServiceException in updateEmployeeList(). ", e); + } + } + + public void setVisible(boolean b) { + listEmployeesAP.setVisible(b); + } + + public void backToMain() { + LOG.debug("Hyperlink \"Zurück\" clicked."); + this.setVisible(false); + createOperationController.setVisible(true); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java new file mode 100644 index 0000000..0476fc6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java @@ -0,0 +1,169 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showAlertWithOkButtonAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.io.IOException; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.fxml.FXML; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ListView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class OperationDetailsController { + private static final Logger LOG = LoggerFactory.getLogger(OperationDetailsController.class); + + public Operation operation; + private final OperationService operationService; + private final VehicleService vehicleService; + private final CreateOperationController createOperationController; + @FXML private FlowPane fpVehicles; + @FXML private ListView lvActiveOperations; + @FXML private Label lblChosenVehicles; + @FXML private Button btnCloseOperation; + @FXML private Button btnCancelOperation; + @FXML private Label lblCode, lblAdditionalInfo, lblAddress; + @FXML private AnchorPane operationDetailsAP; + + public OperationDetailsController( + OperationService operationService, + VehicleService vehicleService, + CreateOperationController createOperationController) { + this.operationService = operationService; + this.vehicleService = vehicleService; + this.createOperationController = createOperationController; + } + + @FXML + private void initialize() { + lvActiveOperations.setCellFactory( + param -> CreateOperationController.generateOpCodeListItem()); + lvActiveOperations.setOnMouseClicked( + event -> { + if (event.getClickCount() == 2) { + if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { + return; + } + initOperation(lvActiveOperations.getSelectionModel().getSelectedItem()); + } + }); + } + + private void updateFlowPane() { + try { + fpVehicles.getChildren().clear(); + for (Vehicle vehicle : operation.vehicles()) { + VehiclePaneController controller = VehiclePaneController.createVehiclePane(); + controller.setData(vehicle, true, true); + controller.getBtnRequest().setOnAction(e -> requestVehicleClicked(controller)); + fpVehicles.getChildren().add(controller.getRootElement()); + } + } catch (IOException e) { + LOG.error("Error while updating list.", e); + showServiceExceptionAlertAndWait("Error while updating list."); + } + } + + void initOperation(Operation operation) { + fillActiveList(); + this.operation = operation; + lblCode.setText(operation.opCode()); + Collection vehicleNames = + operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); + String result = String.join(", ", vehicleNames); + lblChosenVehicles.setText(result.toString()); + lblAdditionalInfo.setText(operation.additionalInfo()); + lblAddress.setText(operation.destination()); + updateFlowPane(); + operationDetailsAP.setVisible(true); + } + + private void fillActiveList() { + try { + lvActiveOperations.setItems( + FXCollections.observableArrayList( + operationService.list(EnumSet.of(Status.ACTIVE)))); + } catch (ServiceException e) { + LOG.error("ServiceException in fillActiveList(). ", e); + showServiceExceptionAlertAndWait(e.getMessage()); + } + } + + @FXML + public void closeOperationClicked() { + LOG.debug("Button \"Abschließen\" clicked."); + try { + operationService.complete(operation.id(), Status.COMPLETED); + } catch (InvalidOperationException e) { + LOG.debug("Validation error in closeOperationClicked(). ", e); + showAlertWithOkButtonAndWait(AlertType.ERROR, "Validierungsfehler", e.getMessage()); + return; + } catch (ServiceException e) { + LOG.error("Exception in closeOperationClicked(). ", e); + showServiceExceptionAlertAndWait(e.getMessage()); + return; + } + showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); + createOperationController.updateList(); + closeWindow(); + } + + public void cancelOperationClicked() { + LOG.debug("Button \"Stornieren\" clicked."); + try { + operationService.complete(operation.id(), Status.CANCELLED); + } catch (InvalidOperationException e) { + LOG.debug("Validation error in cancelOperationClicked(). ", e); + showValidationErrorAlertAndWait(e.getMessage()); + return; + } catch (ServiceException e) { + LOG.error("Exception in cancelOperationClicked(). ", e); + showServiceExceptionAlertAndWait(e.getMessage()); + return; + } + showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); + createOperationController.updateList(); + closeWindow(); + } + + private void requestVehicleClicked(VehiclePaneController v) { + LOG.debug("Button \"Nachfordern\" clicked."); + + try { + operationService.requestVehicles(operation.id(), Set.of(v.getData().id())); + } catch (ServiceException | InvalidOperationException | InvalidVehicleException e) { + LOG.error("Exception in requestVehicleClicked()", e); + showServiceExceptionAlertAndWait(e.getMessage()); + return; + } + showSuccessAlertAndWait("Das Fahrzeug wurde erfolgreich angefordert"); + createOperationController.updateList(); + } + + public void closeWindow() { + LOG.debug("Hyperlink \"Zurück\" clicked."); + operationDetailsAP.setVisible(false); + this.createOperationController.setVisible(true); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java new file mode 100644 index 0000000..17f0f55 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Collection; +import java.util.Objects; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.text.Text; + +public class OperationInArchiveController { + + @FXML private Text txtAddress; + @FXML private Text txtVehicles; + @FXML private Text txtDate; + @FXML private Text txtOpCode; + + static OperationInArchiveController create() throws IOException { + FXMLLoader fxmlLoader = + new FXMLLoader( + OperationInArchiveController.class.getResource( + "/fxml/OperationInArchive.fxml")); + Node root = fxmlLoader.load(); + OperationInArchiveController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + public Node getRoot() { + return rootElement; + } + + private Node rootElement; + + public void set(Operation operation) { + txtAddress.setText(operation.destination()); + String date = "am "; + if (operation.created() != null) { + LocalDateTime myDateTime = + LocalDateTime.ofInstant( + Objects.requireNonNull(operation.created()), ZoneOffset.UTC); + date += + myDateTime.getDayOfMonth() + + "." + + myDateTime.getMonth().getValue() + + "." + + myDateTime.getYear(); + txtDate.setText(date); + } else { + txtDate.setText("---"); + } + txtOpCode.setText(operation.opCode()); + Collection elements = + operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); + String result = String.join(", ", elements); + + txtVehicles.setText(result); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java new file mode 100644 index 0000000..9c47fe4 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java @@ -0,0 +1,279 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class RegistrationWindowController { + + private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); + + private final EmployeeService employeeService; + private final VehicleService vehicleService; + private final RegistrationService registrationService; + private final CreateOperationController createOperationController; + private final SpringFXMLLoader fxmlLoader; + + @FXML private GridPane root; + @FXML private VBox vbVehicles; + @FXML private ScrollPane listEmployee; + @FXML private ChoiceBox cbStart; + @FXML private ChoiceBox cbEnd; + @FXML private Label lVehicles; + @FXML private Label lEmployees; + @FXML private TextField tfVehicleSearch; + @FXML private TextField tfEmployeeSearch; + private EmployeeListController employeeListController; + + private Vehicle chosenVehicle; + private List chosenEmployees = new LinkedList<>(); + + public RegistrationWindowController( + EmployeeService employeeService, + VehicleService vehicleService, + CreateOperationController createOperationController, + RegistrationService registrationService, + SpringFXMLLoader fxmlLoader) { + this.employeeService = employeeService; + this.vehicleService = vehicleService; + this.createOperationController = createOperationController; + this.registrationService = registrationService; + this.fxmlLoader = fxmlLoader; + } + + @FXML + private void initialize() throws IOException { + employeeListController = EmployeeListController.createEmployeeListController(fxmlLoader); + employeeListController.setListItemMargins(new Insets(10, 6, 0, 6)); + // listEmployee. .getChildren().add(employeeListController.getRootElement()); + Node emplList = employeeListController.getRootElement(); + // emplList.(360); + listEmployee.setContent(emplList); + + ObservableList hours = + FXCollections.observableArrayList( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23); + cbStart.setItems(hours); + cbStart.setValue(0); + cbEnd.setItems(hours); + cbEnd.setValue(12); + + reset(); + } + + private void updateEmplList() { + employeeListController.deselectAllEmployees(); + + try { + Set employees = + employeeService + .list() + .stream() + .filter( + e -> + e.name() + .toLowerCase() + .contains( + tfEmployeeSearch + .getText() + .toLowerCase())) + .collect(Collectors.toCollection(HashSet::new)); + employeeListController.setData( + employees, + selection -> { + if (selection == null) { + return; + } else if (chosenEmployees.contains(selection)) { + chosenEmployees.remove(selection); + } else { + chosenEmployees.add(selection); + } + + StringBuilder text = new StringBuilder(); + boolean first = true; + for (Employee employee : chosenEmployees) { + if (!first) { + text.append(", "); + } + text.append(employee.name()); + first = false; + } + lEmployees.setText(text.toString()); + }, + contr -> contr.setSelected(chosenEmployees.contains(contr.getEmployee()))); + + employees.forEach( + e -> { + if (chosenEmployees.contains(e)) employeeListController.selectEmployee(e); + }); + } catch (ServiceException e) { + LOG.error("ServiceException in updateEmplList(). ", e); + showServiceExceptionAlertAndWait( + "Beim Auflisten des Personals ist ein Fehler aufgetreten."); + } + } + + private void updateVehList() { + vbVehicles.getChildren().clear(); + + try { + Set vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + + boolean anyMatch = false; + + for (Vehicle vehicle : vehicles) { + if (!vehicle.name().toLowerCase().contains(tfVehicleSearch.getText().toLowerCase())) + continue; + + anyMatch = true; + + VehiclePaneController vp = VehiclePaneController.createVehiclePane(); + vp.setData(vehicle, false, false); + vbVehicles.getChildren().add(vp.getRootElement()); + + vp.getRootElement() + .setOnMouseClicked( + event -> { + if (event.getButton() == MouseButton.PRIMARY) { + chosenVehicle = vehicle; + lVehicles.setText(chosenVehicle.name()); + updateVehList(); + } + }); + if (chosenVehicle != null && chosenVehicle.id() == vehicle.id()) + vp.setSelected(true); + } + + if (!anyMatch) { + // Kind of ugly, but best way to get the size of a VehiclePane + VehiclePaneController vp = VehiclePaneController.createVehiclePane(); + vp.getRootElement().setVisible(false); + vbVehicles.getChildren().add(vp.getRootElement()); + } + } catch (ServiceException e) { + LOG.error("ServiceException in updateVehList(). ", e); + showServiceExceptionAlertAndWait( + "Beim Auflisten der Fahrzeuge ist ein Fehler aufgetreten"); + } catch (IOException e) { + LOG.error("IOException in updateVehList(). ", e); + showServiceExceptionAlertAndWait("Beim Laden der Fahrzeuge ist ein Fehler aufgetreten"); + } + } + + public void cancel() { + LOG.debug("Hyperlink \"schließen\" clicked"); + reset(); + this.setVisible(false); + createOperationController.setVisible(true); + } + + private void reset() { + chosenEmployees.clear(); + chosenVehicle = null; + tfEmployeeSearch.setText(""); + tfVehicleSearch.setText(""); + lEmployees.setText("-"); + lVehicles.setText("-"); + updateVehList(); + updateEmplList(); + } + + public void create() { + LOG.debug("Button \"ERSTELLEN\" clicked"); + + Set registrations = new HashSet<>(); + try { + if (chosenVehicle == null) { + throw new InvalidVehicleException("no Vehicle"); + } + for (Employee employee : chosenEmployees) { + registrations.add( + Registration.builder() + .id(chosenVehicle.id()) + .employee(employee) + .start( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbStart.getValue(), 0)) + .toInstant(OffsetDateTime.now().getOffset())) + .end( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbEnd.getValue(), 0)) + .toInstant(OffsetDateTime.now().getOffset())) + .build()); + } + + registrationService.add(chosenVehicle.id(), registrations); + chosenEmployees.clear(); + // ((Stage) lVehicles.getScene().getWindow()).close(); + this.setVisible(false); + createOperationController.setVisible(true); + reset(); + } catch (InvalidVehicleException e) { + LOG.debug("Validation of Vehicle in Registration failed."); + showValidationErrorAlertAndWait("Das spezifizierte Fahrzeug ist nicht gültig."); + } catch (ServiceException e) { + LOG.error("ServiceException in create(). ", e); + showServiceExceptionAlertAndWait( + "Beim Erstellen der Anmeldung ist ein Fehler aufgetreten."); + } catch (InvalidRegistrationException e) { + LOG.debug("Validation of Registration failed."); + showValidationErrorAlertAndWait( + "Die gewählte Kombination von Fahrzeug und Personal ist nicht gültig!"); + } + } + + public void setVisible(boolean b) { + root.setVisible(b); + reset(); + } + + public void tfVehicleSearch_TextChanged(KeyEvent keyEvent) { + updateVehList(); + } + + public void tfEmployeeSearch_TextChanged(KeyEvent keyEvent) { + updateEmplList(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java new file mode 100644 index 0000000..66b45d2 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java @@ -0,0 +1,118 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import java.io.IOException; +import java.time.Instant; +import java.util.List; +import java.util.Optional; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.text.Text; + +public class VehiclePaneController extends CustomListItemController { + + public static VehiclePaneController createVehiclePane() throws IOException { + FXMLLoader fxmlLoader = + new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); + Node root = fxmlLoader.load(); + VehiclePaneController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + @FXML private Label txtStatus; + @FXML private Text txtType; + @FXML private Text txtNumber; + @FXML private ImageView ivNEF; + @FXML private Text txtNEF; + @FXML private ImageView ivQualification; + @FXML private Text txtQualification; + @FXML private Text txtRooftype; + @FXML private Button btnRequest; + + private Vehicle data; + + public Vehicle getData() { + return data; + } + + /** + * * Set the displayed data of this VehiclePane. + * + * @param vehicle The data to display. + * @param showStatusInfo If true, the highest qualification of the vehicle's active registration + * and the vehicle's status will be shown. + */ + public void setData(Vehicle vehicle, boolean showStatusInfo, boolean showRequestVehicle) { + txtType.setText(vehicle.type().name()); + String constrType = vehicle.constructionType().name(); + txtRooftype.setText( + constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); + txtNumber.setText("-" + vehicle.id()); + if (vehicle.hasNef()) { + ivNEF.setImage(new Image("images/NEF.png")); + txtNEF.setText("hat NEF-Halterung"); + } else { + ivNEF.setImage(new Image("images/NotNEF.png")); + txtNEF.setText("keine NEF-Halterung"); + } + + if (showRequestVehicle) { + btnRequest.setVisible(true); + btnRequest.setManaged(true); + } else { + btnRequest.setVisible(false); + btnRequest.setManaged(false); + } + + if (showStatusInfo) { + txtStatus.setText(vehicle.status().name()); + if (vehicle.status() == Status.FREI_FUNK || vehicle.status() == Status.FREI_WACHE) { + txtStatus.getStyleClass().add("bg-status-green"); + } else { + txtStatus.getStyleClass().add("bg-status-orange"); + } + + Instant now = Instant.now(); + List regs = vehicle.registrations(); + + if (regs == null) { + return; + } + + Optional edu = + regs.stream() + .filter(reg -> reg.start().isBefore(now) && reg.end().isAfter(now)) + .map(reg -> reg.employee().educationLevel()) + .max(EducationLevel::compareTo); + + if (!edu.isPresent()) { + return; + } + + txtQualification.setText(edu.get().name()); + } else { + txtQualification.setVisible(false); + txtQualification.setManaged(false); + ivQualification.setVisible(false); + ivQualification.setManaged(false); + + txtStatus.setVisible(false); + } + + this.data = vehicle; + } + + public Button getBtnRequest() { + return btnRequest; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java new file mode 100644 index 0000000..d8ac513 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java @@ -0,0 +1,44 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import java.util.Set; + +public interface EmployeeDAO { + + /** + * Persist the given employee. + * + * @param employee that should be stored + * @return the id that was assigned + * @throws PersistenceException if the employee could not be persisted + */ + long add(Employee employee) throws PersistenceException; + + /** + * Update the given employee. + * + * @param employee that should be updated + * @throws ElementNotFoundException if no employee with the given id exists + * @throws PersistenceException if the employee could not be updated + */ + void update(Employee employee) throws ElementNotFoundException, PersistenceException; + + /** + * Get all stored employees. + * + * @return list containing all stored employees + * @throws PersistenceException if loading the stored employees failed + */ + Set list() throws PersistenceException; + + /** + * Remove employee with the given id from the store. + * + * @param id of the employee that should be removed + * @throws ElementNotFoundException if no employee with the given id exists + * @throws PersistenceException if the employee could not be removed + */ + void remove(long id) throws ElementNotFoundException, PersistenceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java new file mode 100644 index 0000000..889b0fc --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java @@ -0,0 +1,144 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.LocalDate; +import java.util.HashSet; +import java.util.Set; +import org.springframework.stereotype.Repository; + +@Repository +public class EmployeeDatabaseDAO implements EmployeeDAO { + + private JDBCConnectionManager jdbcConnectionManager; + + public EmployeeDatabaseDAO(JDBCConnectionManager jdbcConnectionManager) { + this.jdbcConnectionManager = jdbcConnectionManager; + } + + private long createEmployeeVersion(Connection con, Employee e) + throws PersistenceException, SQLException { + String sql = + "INSERT INTO EmployeeVersion(name, birthday, educationLevel, isDriver, isPilot) " + + "VALUES(?, ?, ?, ?, ?)"; + + try (PreparedStatement pstmt = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setString(1, e.name()); + pstmt.setObject(2, e.birthday()); + pstmt.setInt(3, e.educationLevel().ordinal()); + pstmt.setBoolean(4, e.isDriver()); + pstmt.setBoolean(5, e.isPilot()); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (!rs.next()) throw new PersistenceException("Failed to insert EmployeeVersion"); + + return rs.getLong(1); + } + } + } + + @Override + public long add(Employee employee) throws PersistenceException { + String sql = "INSERT INTO Employee(version) VALUES(?)"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + + long versionId = createEmployeeVersion(con, employee); + + try (PreparedStatement pstmt = + con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setLong(1, versionId); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (!rs.next()) { + con.rollback(); + throw new PersistenceException("Failed to insert Employee"); + } + + con.commit(); + return rs.getLong(1); + } + } + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public void update(Employee employee) throws ElementNotFoundException, PersistenceException { + String sql = "UPDATE Employee SET version = ? WHERE id = ?"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + + long versionId = createEmployeeVersion(con, employee); + + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, versionId); + pstmt.setLong(2, employee.id()); + + if (pstmt.executeUpdate() != 1) { + con.rollback(); + throw new ElementNotFoundException("No such employeeId exists"); + } + } + + con.commit(); + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public Set list() throws PersistenceException { + String sql = + "SELECT emp.id, v.name, v.birthday, v.educationLevel, v.isDriver, v.isPilot " + + "FROM employee emp " + + "JOIN EmployeeVersion v ON v.id = emp.version"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + Set employees = new HashSet<>(); + + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + try (ResultSet rs = pstmt.executeQuery()) { + while (rs.next()) { + employees.add( + Employee.builder() + .id(rs.getLong(1)) + .name(rs.getString(2)) + .birthday(rs.getObject(3, LocalDate.class)) + .educationLevel(EducationLevel.valueOf(rs.getString(4))) + .isDriver(rs.getBoolean(5)) + .isPilot(rs.getBoolean(6)) + .build()); + } + } + } + + return employees; + } catch (SQLException e) { + throw new PersistenceException(e); + } + } + + @Override + public void remove(long id) throws ElementNotFoundException, PersistenceException { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java new file mode 100644 index 0000000..c0ef5d4 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java @@ -0,0 +1,48 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import java.util.EnumSet; +import java.util.Set; + +public interface OperationDAO { + + /** + * Persist the given operation. + * + * @param operation that should be stored + * @return the id that was assigned + * @throws PersistenceException if the operation could not be persisted + */ + long add(Operation operation) throws PersistenceException; + + /** + * Update the given operation. + * + * @param operation that should be updated + * @throws ElementNotFoundException if no operation with the given id exists + * @throws PersistenceException if the operation could not be updated + */ + void update(Operation operation) throws ElementNotFoundException, PersistenceException; + + /** + * Returns the operation with the given id. + * + * @param operationId id of the operation that should be returned + * @return operation with the given id + * @throws ElementNotFoundException if no operation with the given id exists + * @throws PersistenceException if the operation could not be loaded + */ + Operation get(long operationId) throws ElementNotFoundException, PersistenceException; + + /** + * Get all stored operations with matching status. + * + * @param statuses set containing all statuses that should be matched + * @return list containing all matched operations + * @throws PersistenceException if loading the stored operations failed + */ + Set list(EnumSet statuses) throws PersistenceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java new file mode 100644 index 0000000..1641720 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java @@ -0,0 +1,221 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Repository; + +@Repository +public class OperationDatabaseDAO implements OperationDAO { + + private JDBCConnectionManager jdbcConnectionManager; + private VehicleDAO vehicleDAO; + + public OperationDatabaseDAO( + JDBCConnectionManager jdbcConnectionManager, VehicleDAO vehicleDAO) { + this.jdbcConnectionManager = jdbcConnectionManager; + this.vehicleDAO = vehicleDAO; + } + + @Override + public long add(@NonNull Operation o) throws PersistenceException { + String sql = + "INSERT INTO Operation(opCode, severity, created, destination, additionalInfo," + + " status) VALUES (?, ?, ?, ?, ?, ?)"; + String sql2 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)"; + long operationId; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setString(1, o.opCode()); + pstmt.setInt(2, o.severity().ordinal()); + pstmt.setObject(3, OffsetDateTime.ofInstant(o.created(), ZoneId.systemDefault())); + pstmt.setString(4, o.destination()); + pstmt.setString(5, o.additionalInfo()); + pstmt.setInt(6, o.status().ordinal()); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (!rs.next()) throw new PersistenceException("Failed to persist operation"); + + operationId = rs.getLong(1); + } + } + + try (PreparedStatement pstmt = con.prepareStatement(sql2)) { + pstmt.setLong(2, operationId); + + for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { + pstmt.setLong(1, id); + pstmt.addBatch(); + } + + pstmt.executeBatch(); + } + con.commit(); + return operationId; + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public void update(@NonNull Operation o) throws ElementNotFoundException, PersistenceException { + // Note this will, by design, not update created + String sql = + "UPDATE Operation SET opCode = ?, severity = ?, destination = ?," + + " additionalInfo = ?, status = ? WHERE id = ?"; + String sql2 = "DELETE FROM VehicleOperation WHERE operationId = ?"; + String sql3 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setString(1, o.opCode()); + pstmt.setInt(2, o.severity().ordinal()); + pstmt.setString(3, o.destination()); + pstmt.setString(4, o.additionalInfo()); + pstmt.setInt(5, o.status().ordinal()); + pstmt.setLong(6, o.id()); + + if (pstmt.executeUpdate() != 1) + throw new ElementNotFoundException("No such operationId exists"); + } + + try (PreparedStatement pstmt = con.prepareStatement(sql2)) { + pstmt.setLong(1, o.id()); + pstmt.executeUpdate(); + } + + try (PreparedStatement pstmt = con.prepareStatement(sql3)) { + pstmt.setLong(2, o.id()); + + for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { + pstmt.setLong(1, id); + pstmt.addBatch(); + } + + pstmt.executeBatch(); + } + con.commit(); + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public Operation get(long operationId) throws ElementNotFoundException, PersistenceException { + String sql = "Select * from operation where id = ?"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, operationId); + pstmt.execute(); + + try (ResultSet rs = pstmt.getResultSet()) { + if (!rs.next()) + throw new ElementNotFoundException("No such element could be found"); + + return operationFromRS(rs); + } + } + } catch (SQLException e) { + throw new PersistenceException(e); + } + } + + @Override + public Set list(EnumSet statuses) throws PersistenceException { + // This hack exists because H2 currently has a bug that prevents IN (?) with an array of + // ids, i.e. pstmt.setArray(1, con.createArrayOf("INT", intarray) from working. See + // commented code below. + + // SELECT * FROM Operation WHERE status IN ('COMPLETED', 'CANCELLED') is BUGGED on H2! + // for this reason we use the ordinal values instead + String str = + statuses.stream() + .map(e -> Integer.toString(e.ordinal())) + .collect(Collectors.joining(",")); + + String sql = "SELECT * FROM Operation WHERE status IN (" + str + ")"; + Set operations = new HashSet<>(); + + try { + Connection con = jdbcConnectionManager.getConnection(); + + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + // Object[] arr = statuses.stream().map(Enum::ordinal).toArray(); + // pstmt.setArray(1, con.createArrayOf("INT", arr)); + + try (ResultSet rs = pstmt.executeQuery()) { + while (rs.next()) operations.add(operationFromRS(rs)); + } + } + + return operations; + } catch (SQLException e) { + throw new PersistenceException(e); + } + } + + private Operation operationFromRS(ResultSet rs) throws PersistenceException, SQLException { + Long operationId = rs.getLong("id"); + + return Operation.builder() + .id(operationId) + .opCode(rs.getString("opCode")) + .severity(Severity.valueOf(rs.getString("severity"))) + .status(Status.valueOf(rs.getString("status"))) + .vehicles(getVehiclesFromOperationId(operationId)) + .created((rs.getObject("created", OffsetDateTime.class)).toInstant()) + .destination(rs.getString("destination")) + .additionalInfo(rs.getString("additionalInfo")) + .build(); + } + + private Set getVehiclesFromOperationId(long operationId) throws PersistenceException { + String sql = "SELECT vehicleId FROM VehicleOperation WHERE operationId = ?"; + Set vehicles = new HashSet<>(); + + try { + Connection con = jdbcConnectionManager.getConnection(); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, operationId); + pstmt.execute(); + + try (ResultSet rs = pstmt.getResultSet()) { + while (rs.next()) { + vehicles.add(vehicleDAO.get(rs.getLong("vehicleId"))); + } + } + } + } catch (SQLException e) { + throw new PersistenceException(e); + } catch (ElementNotFoundException e) { + throw new PersistenceException("VehicleOperation contained nonexistent vehicle", e); + } + + return vehicles; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java new file mode 100644 index 0000000..02e742c --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java @@ -0,0 +1,28 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import java.util.Set; + +public interface RegistrationDAO { + + /** + * Persist the given registration. + * + * @param vehicleId the id of the target vehicle + * @param registrations that should be stored + * @return a list of the ids that were assigned + * @throws PersistenceException if the registration could not be persisted + */ + Set add(long vehicleId, Set registrations) throws PersistenceException; + + /** + * Make registration with the given id inactive. + * + * @param id of the registration that should be made inactive + * @throws ElementNotFoundException if no registration with the given id exists + * @throws PersistenceException if the registration could not be made inactive + */ + void remove(long id) throws ElementNotFoundException, PersistenceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java new file mode 100644 index 0000000..1006a33 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java @@ -0,0 +1,130 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class RegistrationDatabaseDAO implements RegistrationDAO { + + private JDBCConnectionManager jdbcConnectionManager; + private EmployeeDAO employeePersistence; + + @Autowired + public RegistrationDatabaseDAO( + JDBCConnectionManager jdbcConnectionManager, EmployeeDAO employeePersistence) { + this.jdbcConnectionManager = jdbcConnectionManager; + this.employeePersistence = employeePersistence; + } + + @Override + public Set add(long vehicleId, Set registrations) + throws PersistenceException { + String sql = + "INSERT INTO Registration (vehicleId, employeeId, start, end, active) VALUES (?,?,?,?,?)"; + String sql2 = "UPDATE Vehicle SET status = 'FREI_WACHE' WHERE id = ?;"; + + Set vehicleIds = new HashSet<>(); + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + + try (PreparedStatement pstmt = + con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setLong(1, vehicleId); + + for (Registration r : registrations) { + pstmt.setLong(2, r.employee().id()); + pstmt.setObject(3, OffsetDateTime.ofInstant(r.start(), ZoneId.systemDefault())); + pstmt.setObject(4, OffsetDateTime.ofInstant(r.end(), ZoneId.systemDefault())); + pstmt.setBoolean(5, true); + pstmt.addBatch(); + } + + pstmt.executeBatch(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + while (rs.next()) vehicleIds.add(rs.getLong(1)); + } + } + + try (PreparedStatement pstmt = con.prepareStatement(sql2)) { + pstmt.setLong(1, vehicleId); + if (pstmt.executeUpdate() != 1) { + con.rollback(); + throw new PersistenceException("Failed to persist registration"); + } + } + + con.commit(); + return vehicleIds; + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public void remove(long id) throws ElementNotFoundException, PersistenceException { + throw new UnsupportedOperationException(); + } + + protected List list(long vehicleId) throws PersistenceException { + String sql = "SELECT * FROM Registration WHERE vehicleId = ?"; + + List registrationList = new ArrayList<>(); + try { + Connection con = jdbcConnectionManager.getConnection(); + + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, vehicleId); + + try (ResultSet rs = pstmt.executeQuery()) { + while (rs.next()) { + long employeeId = rs.getLong("employeeId"); + // TODO: replace the following with employeePersistence.get once implemented + Employee emp = + employeePersistence + .list() + .stream() + .filter(employee -> employee.id() == employeeId) + .findAny() + .orElse(null); + Registration registration = + Registration.builder() + .id(rs.getLong("id")) + .start( + (rs.getObject("start", OffsetDateTime.class)) + .toInstant()) + .end( + (rs.getObject("end", OffsetDateTime.class)) + .toInstant()) + .employee(emp) + .build(); + registrationList.add(registration); + } + } + } + + return registrationList; + } catch (SQLException e) { + throw new PersistenceException(e); + } + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java new file mode 100644 index 0000000..ed24498 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java @@ -0,0 +1,54 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import java.util.Set; + +public interface VehicleDAO { + + /** + * Persist the given vehicle. + * + * @param vehicle that should be stored + * @return the id that was assigned + * @throws PersistenceException if the vehicle could not be persisted + */ + long add(Vehicle vehicle) throws PersistenceException; + + /** + * Update the given vehicle. + * + * @param vehicle that should be updated + * @throws ElementNotFoundException if no vehicle with the given id exists + * @throws PersistenceException if the vehicle could not be updated + */ + void update(Vehicle vehicle) throws ElementNotFoundException, PersistenceException; + + /** + * Get all stored vehicles. + * + * @return list containing all stored vehicles + * @throws PersistenceException if loading the stored vehicles failed + */ + Set list() throws PersistenceException; + + /** + * Returns the vehicle with the given id. + * + * @param vehicleId id of the vehicle that should be returned + * @return vehicle with the given id + * @throws ElementNotFoundException if no vehicle with the given id exists + * @throws PersistenceException if the vehicle could not be loaded + */ + Vehicle get(long vehicleId) throws ElementNotFoundException, PersistenceException; + + /** + * Remove vehicle with the given id from the store. + * + * @param id of the vehicle that should be removed + * @throws ElementNotFoundException if no vehicle with the given id exists + * @throws PersistenceException if the vehicle could not be removed + */ + void remove(long id) throws ElementNotFoundException, PersistenceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java new file mode 100644 index 0000000..dd7c0f2 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java @@ -0,0 +1,211 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashSet; +import java.util.Set; +import org.springframework.stereotype.Repository; + +@Repository +public class VehicleDatabaseDAO implements VehicleDAO { + + private final JDBCConnectionManager jdbcConnectionManager; + private RegistrationDatabaseDAO registrationDatabaseDao; + + public VehicleDatabaseDAO( + JDBCConnectionManager j, RegistrationDatabaseDAO registrationDatabaseDao) { + jdbcConnectionManager = j; + this.registrationDatabaseDao = registrationDatabaseDao; + } + + @Override + public long add(Vehicle v) throws PersistenceException { + String sql = + "INSERT INTO VehicleVersion (name,hasNef,constructionType,type) VALUES (?,?,?,?)"; + String sql2 = "INSERT INTO Vehicle (version,status) VALUES (?,?)"; + String sql3 = "UPDATE VehicleVersion SET name=? WHERE id=?"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + String name = ""; + long version, id; + + try (PreparedStatement pstmt = + con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setString(1, name); + pstmt.setBoolean(2, v.hasNef()); + pstmt.setInt(3, v.constructionType().ordinal()); + pstmt.setString(4, v.type().name()); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (!rs.next()) + throw new PersistenceException("Failed to insert into VehicleVersion"); + + version = rs.getLong(1); + } + } + + try (PreparedStatement pstmt = + con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setLong(1, version); + pstmt.setInt(2, Status.ABGEMELDET.ordinal()); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (!rs.next()) { + con.rollback(); + throw new PersistenceException("Failed to insert into Vehicle"); + } + + id = rs.getLong(1); + } + + name = v.type().name() + "-" + id; + } + + try (PreparedStatement pstmt = con.prepareStatement(sql3)) { + pstmt.setString(1, name); + pstmt.setLong(2, version); + + if (pstmt.executeUpdate() != 1) { + con.rollback(); + throw new PersistenceException("Failed to update VehicleVersion"); + } + } + + con.commit(); + return id; + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public void update(Vehicle v) throws ElementNotFoundException, PersistenceException { + String sql = "SELECT version FROM Vehicle WHERE id = ?"; + String sql2 = + "MERGE INTO VehicleVersion(name, constructionType, type, hasNef)" + + " KEY(name, constructionType, type, hasNef) VALUES(?, ?, ?, ?)"; + String sql3 = "UPDATE Vehicle SET version = ?, status = ? WHERE id = ?"; + + long versionId; + + try { + Connection con = jdbcConnectionManager.getConnection(); + con.setAutoCommit(false); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, v.id()); + + try (ResultSet rs = pstmt.executeQuery()) { + if (!rs.next()) throw new ElementNotFoundException("No such vehicleId exists"); + + versionId = rs.getLong(1); + } + } + + try (PreparedStatement pstmt = + con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { + pstmt.setString(1, v.type().name() + "-" + v.id()); + pstmt.setString(2, v.constructionType().name()); + pstmt.setString(3, v.type().name()); + pstmt.setBoolean(4, v.hasNef()); + pstmt.executeUpdate(); + + try (ResultSet rs = pstmt.getGeneratedKeys()) { + if (rs.next()) { + // version changed, update it + versionId = rs.getLong(1); + } + } + } + + try (PreparedStatement pstmt = con.prepareStatement(sql3)) { + pstmt.setLong(1, versionId); + pstmt.setString(2, v.status().name()); + pstmt.setLong(3, v.id()); + pstmt.executeUpdate(); + } + + con.commit(); + } catch (SQLException e) { + jdbcConnectionManager.rollbackConnection(); + throw new PersistenceException(e); + } + } + + @Override + public Set list() throws PersistenceException { + Set result = new HashSet<>(); + + String sql = + "Select * from VehicleVersion, Vehicle where VehicleVersion.id=Vehicle.version"; + + try (PreparedStatement pstmt = + jdbcConnectionManager.getConnection().prepareStatement(sql)) { + pstmt.executeQuery(); + try (ResultSet rs = pstmt.getResultSet()) { + while (rs.next()) { + result.add(vehicleFromRS(rs)); + } + } + } catch (SQLException e) { + throw new PersistenceException(e); + } + return result; + } + + @Override + public Vehicle get(long id) throws ElementNotFoundException, PersistenceException { + String sql = + "SELECT a.id, b.name, b.constructionType, b.type, a.status, b.hasNef" + + " FROM Vehicle a" + + " INNER JOIN VehicleVersion b" + + " ON version = b.id" + + " WHERE a.id = ?"; + + try { + Connection con = jdbcConnectionManager.getConnection(); + try (PreparedStatement pstmt = con.prepareStatement(sql)) { + pstmt.setLong(1, id); + + try (ResultSet rs = pstmt.executeQuery()) { + if (!rs.first()) throw new ElementNotFoundException("No such vehicle exists"); + + return vehicleFromRS(rs); + } + } + } catch (SQLException e) { + throw new PersistenceException(e); + } + } + + @Override + public void remove(long id) throws ElementNotFoundException, PersistenceException { + throw new UnsupportedOperationException(); + } + + private Vehicle vehicleFromRS(ResultSet rs) throws SQLException, PersistenceException { + return Vehicle.builder() + .id(rs.getLong("Vehicle.id")) + .name(rs.getString("name")) + .constructionType(ConstructionType.values()[rs.getInt("constructionType")]) + .type(VehicleType.valueOf(rs.getString("type"))) + .status(Status.values()[rs.getInt("status")]) + .hasNef(rs.getBoolean("hasNef")) + .registrations(registrationDatabaseDao.list(rs.getLong("id"))) + .build(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java new file mode 100644 index 0000000..f45550e --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java @@ -0,0 +1,51 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import com.google.auto.value.AutoValue; +import java.time.LocalDate; + +@AutoValue +public abstract class Employee { + public enum EducationLevel { + RS, + NFS, + NKV, + NKA, + NKI, + NA + } + + public abstract long id(); + + public abstract String name(); + + public abstract LocalDate birthday(); + + public abstract EducationLevel educationLevel(); + + public abstract boolean isDriver(); + + public abstract boolean isPilot(); + + public static Builder builder() { + return new AutoValue_Employee.Builder().id(0); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(long id); + + public abstract Builder name(String name); + + public abstract Builder birthday(LocalDate birthday); + + public abstract Builder educationLevel(EducationLevel educationLevel); + + public abstract Builder isDriver(boolean isDriver); + + public abstract Builder isPilot(boolean isPilot); + + public abstract Employee build(); + } + + public abstract Builder toBuilder(); +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java new file mode 100644 index 0000000..b03fa04 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java @@ -0,0 +1,23 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; + +public class EmployeeValidator { + + public static boolean validate(Employee employee) throws InvalidEmployeeException { + + if (employee.name() == null || employee.name().trim().length() == 0) { + throw new InvalidEmployeeException("Name darf nicht leer sein!"); + } + + if (employee.birthday() == null) { + throw new InvalidEmployeeException("Geburtsdatum darf nicht leer sein!"); + } + + if (employee.educationLevel() == null) { + throw new InvalidEmployeeException("Ausbildungsgrad darf nicht leer sein!"); + } + + return true; + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java new file mode 100644 index 0000000..e119622 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java @@ -0,0 +1,70 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import com.google.auto.value.AutoValue; +import java.time.Instant; +import java.util.Set; +import javax.annotation.Nullable; + +@AutoValue +public abstract class Operation { + public enum Severity { + A, + B, + C, + D, + E, + O, + } + + public enum Status { + ACTIVE, + COMPLETED, + CANCELLED, + } + + public abstract long id(); + + public abstract String opCode(); + + @Nullable + public abstract Severity severity(); + + public abstract Status status(); + + public abstract Set vehicles(); + + @Nullable + public abstract Instant created(); + + public abstract String destination(); + + @Nullable + public abstract String additionalInfo(); + + public static Builder builder() { + return new AutoValue_Operation.Builder().id(0); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(long id); + + public abstract Builder opCode(String opCode); + + public abstract Builder severity(Severity severity); + + public abstract Builder status(Status status); + + public abstract Builder vehicles(Set vehicles); + + public abstract Builder created(Instant created); + + public abstract Builder destination(String destination); + + public abstract Builder additionalInfo(String additionalInfo); + + public abstract Operation build(); + } + + public abstract Builder toBuilder(); +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java new file mode 100644 index 0000000..a12c038 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java @@ -0,0 +1,34 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import com.google.auto.value.AutoValue; +import java.time.Instant; + +@AutoValue +public abstract class Registration { + public abstract long id(); + + public abstract Instant start(); + + public abstract Instant end(); + + public abstract Employee employee(); + + public static Builder builder() { + return new AutoValue_Registration.Builder().id(0); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(long id); + + public abstract Builder start(Instant start); + + public abstract Builder end(Instant end); + + public abstract Builder employee(Employee employee); + + public abstract Registration build(); + } + + public abstract Builder toBuilder(); +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java new file mode 100644 index 0000000..9512f64 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java @@ -0,0 +1,174 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +public class RegistrationValidator { + + private RegistrationValidator() {} + + public static void validate(Vehicle vehicle, Set registrations) + throws InvalidVehicleException, InvalidRegistrationException { + /* + Vehicles and Employees are assumed to be valid. + They have been checked at creation, and for them to be checked again, access to + VehicleValidator and EmployeeValidator are needed, which are not available at this time. + */ + /* + The method used here goes as follows: All given employees are inspected in regards to their + qualifications, and added to the appropriate lists of the roles they could fill. + For example, an NFS, who is also a driver, would be added to the lists driverIds, nfsIds + and rsIds (because an NFS can always substitute an RS). + Afterwards, the number of people is checked according to the chosen vehicle type, and if + the number is okay, the program tries to find a valid combination of roles for the vehicle. + For example, for an RTW, first a driver is chosen, their ID marked as found in the aptly + titled HashMap, and then for the second RS, the list of RS is checked, excluding the chosen + driver. If no other valid RS is found, the next possible driver is chosen, and so on. If no + valid combination is found, an InvalidRegistrationException is thrown. + */ + List pilotIds = new LinkedList<>(); + List driverIds = new LinkedList<>(); + List naIds = new LinkedList<>(); + List nfsIds = new LinkedList<>(); + List rsIds = new LinkedList<>(); + HashMap found = + new HashMap<>(); // needed later in DFS, checks that no person is chosen twice + int total = 0; + for (Registration registration : registrations) { + total++; + if (found.put(registration.employee().id(), false) != null) { + throw new InvalidRegistrationException( + "Person mit der ID: " + + registration.employee().id() + + " wurde mehrmals hinzugefügt!"); + } + if (registration.employee().isPilot()) { + pilotIds.add(registration.employee().id()); + } + if (registration.employee().isDriver()) { + driverIds.add(registration.employee().id()); + } + if (registration.employee().educationLevel() == EducationLevel.NA) { + naIds.add(registration.employee().id()); + nfsIds.add(registration.employee().id()); + rsIds.add(registration.employee().id()); + } else if (isNFS(registration.employee())) { + nfsIds.add(registration.employee().id()); + rsIds.add(registration.employee().id()); + } else { // only RS left + rsIds.add(registration.employee().id()); + } + } + if (total <= 0) { + throw new InvalidRegistrationException("Kein Personal ausgewählt!"); + } + if (vehicle.type() == VehicleType.NAH) { + /* + NAH + 1 Pilot + 1 NFS + 1 NA + 3-4 Personen + */ + if (total < 3) { + throw new InvalidRegistrationException("Zu wenig Personal für NAH!"); + } else if (total > 4) { + throw new InvalidRegistrationException("Zu viel Personal für NAH!"); + } + for (long pilot_id : pilotIds) { + found.put(pilot_id, true); + for (long na_id : naIds) { + if (found.get(na_id)) continue; + found.put(na_id, true); + for (long nfs_id : nfsIds) { + if (found.get(nfs_id)) continue; + return; + } + found.put(na_id, false); + } + found.put(pilot_id, false); + } + throw new InvalidRegistrationException( + "Keine gültige Kombination von Personen für NAH!"); + } else if (vehicle.type() == VehicleType.NEF) { + /* + NEF + 1 Driver (has to be NFS) + 1 NA + */ + if (total < 2) { + throw new InvalidRegistrationException("Zu wenig Personal für NEF!"); + } else if (total > 3) { + throw new InvalidRegistrationException("Zu viel Personal für NEF!"); + } + for (long driver_id : driverIds) { + if (!nfsIds.contains(driver_id)) + continue; // if possible driver is not NFS, skip him + found.put(driver_id, true); + for (long na_id : naIds) { + if (found.get(na_id)) continue; + return; + } + found.put(driver_id, false); + } + throw new InvalidRegistrationException( + "Keine gültige Kombination von Personen für NEF!"); + } else if (vehicle.type() == VehicleType.BKTW) { + /* + BKTW + 1 Driver + */ + if (total > 3) { + throw new InvalidRegistrationException("Zu viel Personal für BKTW!"); + } + if (!driverIds.isEmpty()) { + return; + } + throw new InvalidRegistrationException("Kein Fahrer gefunden für BKTW!"); + } else { // KTW or RTW, both have the same requirements + /* + RTW/KTW + 1 Driver + 1 RS + */ + if (total < 2) { + throw new InvalidRegistrationException( + "Zu wenig Personal für " + vehicle.type().name() + "!"); + } else if (total > 4) { + throw new InvalidRegistrationException( + "Zu viel Persoanl für " + vehicle.type().name() + "!"); + } + for (long driver_id : driverIds) { // driver includes rs + found.put(driver_id, true); + for (long rs_id : rsIds) { + if (found.get(rs_id)) continue; + return; + } + } + throw new InvalidRegistrationException( + "Keine gültige Kombination von Personen für " + vehicle.type().name() + "!"); + } + } + + private static boolean isNFS(Employee employee) { + EducationLevel educationLevel = employee.educationLevel(); + switch (educationLevel) { + case NFS: + return true; + case NKA: + return true; + case NKI: + return true; + case NKV: + return true; + default: + return false; + } + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java new file mode 100644 index 0000000..c2033f5 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java @@ -0,0 +1,73 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; + +import com.google.auto.value.AutoValue; +import java.util.List; +import javax.annotation.Nullable; + +@AutoValue +public abstract class Vehicle { + public enum ConstructionType { + NORMAL, + HOCHDACH, + MITTELHOCHDACH, + } + + public enum VehicleType { + BKTW, + KTW_B, + KTW, + RTW, + NEF, + NAH, + } + + public enum Status { + ABGEMELDET, + FREI_WACHE, + FREI_FUNK, + ZUM_BERUFUNGSORT, + AM_BERUFUNGSORT, + ZUM_ZIELORT, + AM_ZIELORT, + } + + public abstract long id(); + + public abstract String name(); + + public abstract ConstructionType constructionType(); + + public abstract VehicleType type(); + + public abstract Status status(); + + public abstract boolean hasNef(); + + @Nullable + public abstract List registrations(); + + public static Builder builder() { + return new AutoValue_Vehicle.Builder().id(0); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(long id); + + public abstract Builder name(String name); + + public abstract Builder constructionType(ConstructionType constructionType); + + public abstract Builder type(VehicleType type); + + public abstract Builder status(Status status); + + public abstract Builder hasNef(boolean hasNef); + + public abstract Builder registrations(List registrations); + + public abstract Vehicle build(); + } + + public abstract Builder toBuilder(); +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java new file mode 100644 index 0000000..fa4d0e6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java @@ -0,0 +1,46 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.Set; + +public interface EmployeeService { + + /** + * Add given employee to the store. + * + * @param employee that should be added to the store + * @return the id that was assigned + * @throws InvalidEmployeeException if the employee is invalid + * @throws ServiceException if the employee could not be persisted + */ + long add(Employee employee) throws InvalidEmployeeException, ServiceException; + + /** + * Update the given employee. + * + * @param employee that should be updated + * @return the updated employee + * @throws InvalidEmployeeException if the employee is invalid + * @throws ServiceException if the updated employee could not be persisted + */ + Employee update(Employee employee) throws InvalidEmployeeException, ServiceException; + + /** + * Get all stored employees. + * + * @return list containing all stored employees + * @throws ServiceException if loading the stored employees failed + */ + Set list() throws ServiceException; + + /** + * Remove employee with the given id from the store. + * + * @param id of the employee that should be removed + * @throws InvalidEmployeeException if given employee id is invalid or does not exist + * @throws ServiceException if the employee could not be removed from the store + */ + void remove(long id) throws InvalidEmployeeException, ServiceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java new file mode 100644 index 0000000..945fb49 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java @@ -0,0 +1,59 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.EmployeeValidator; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.Set; +import org.springframework.stereotype.Service; + +@Service +public class EmployeeServiceImpl implements EmployeeService { + + private final EmployeeDAO employeePersistence; + + public EmployeeServiceImpl(EmployeeDAO employeePersistence) { + this.employeePersistence = employeePersistence; + } + + @Override + public long add(Employee employee) throws InvalidEmployeeException, ServiceException { + + EmployeeValidator.validate(employee); + try { + return employeePersistence.add(employee); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + + @Override + public Employee update(Employee employee) throws InvalidEmployeeException, ServiceException { + + EmployeeValidator.validate(employee); + try { + employeePersistence.update(employee); + return employee; + } catch (ElementNotFoundException | PersistenceException e) { + throw new ServiceException(e); + } + } + + @Override + public Set list() throws ServiceException { + + try { + return employeePersistence.list(); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + + @Override + public void remove(long id) throws InvalidEmployeeException, ServiceException { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java new file mode 100644 index 0000000..ca1dce9 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java @@ -0,0 +1,70 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.EnumSet; +import java.util.Set; +import java.util.SortedSet; + +public interface OperationService { + + /** + * Add given operation to the store. + * + * @param operation that should be added to the store + * @return the id that was assigned + * @throws InvalidOperationException if the operation is invalid + * @throws ServiceException if the operation could not be persisted + */ + long add(Operation operation) throws InvalidOperationException, ServiceException; + + /** + * Request new vehicles to the given operation. + * + * @param operationId id of the operation that the vehicles should be send to + * @param vehicleIds the ids of the vehicles that should be send to the given operation + * @throws InvalidOperationException if the operationId is invalid or does not exist + * @throws InvalidVehicleException if one of the vehicle ids is invalid or does not exist + * @throws ServiceException if the vehicles could not be loaded or the operation could not be + * persisted + */ + void requestVehicles(long operationId, Set vehicleIds) + throws InvalidOperationException, InvalidVehicleException, ServiceException; + + /** + * Completes the given operation with the specified status. + * + * @param operationId id of the operation that should be completed + * @param status of the completed operation, either {@link Status#COMPLETED} or {@link + * Status#CANCELLED} + * @throws InvalidOperationException if the operationId is invalid or does not exist + * @throws ServiceException if the operation could not be persisted + */ + void complete(long operationId, Status status) + throws InvalidOperationException, ServiceException; + + /** + * Get all available vehicles, sorted by how well they fit to the given opCode, starting with + * the best fitting. + * + * @param opCode the operation code that is used to determine the ranking + * @return a sorted list containing all available vehicles + * @throws InvalidOperationException if the opCode is invalid + * @throws ServiceException if loading the stored vehicles failed + */ + SortedSet rankVehicles(String opCode) + throws InvalidOperationException, ServiceException; + + /** + * Get all stored operations with matching status. + * + * @param statuses set containing all statuses that should be matched + * @return list containing all matched operations + * @throws ServiceException if loading the stored operations failed + */ + Set list(EnumSet statuses) throws ServiceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceImpl.java new file mode 100644 index 0000000..baae598 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceImpl.java @@ -0,0 +1,286 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.OperationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +@Service +public class OperationServiceImpl implements OperationService { + + private static final Logger LOG = LoggerFactory.getLogger(OperationServiceImpl.class); + + private final OperationDAO operationDAO; + private final VehicleDAO vehicleDAO; + private final VehicleService vehicleService; + + public OperationServiceImpl( + OperationDAO operationDAO, VehicleDAO vehicleDAO, VehicleService vehicleService) { + this.operationDAO = operationDAO; + this.vehicleDAO = vehicleDAO; + this.vehicleService = vehicleService; + } + + @Override + public long add(Operation o) throws InvalidOperationException, ServiceException { + if (o.created() != null) { + throw new InvalidOperationException("Erstellungszeitpunkt darf nicht gesetzt sein"); + } + + if (o.severity() != null) { + throw new InvalidOperationException("Der Schweregrad darf nicht gesetzt sein"); + } + + if (o.id() != 0) { + throw new InvalidOperationException("Einsatz-ID muss 0 sein"); + } + + if (o.status() != Status.ACTIVE) + LOG.info("Status was set but will be overridden"); // TODO: nullable instead?? + + try { + for (long id : (Iterable) o.vehicles().stream().map(Vehicle::id)::iterator) { + Vehicle v = vehicleDAO.get(id); + VehicleServiceImpl.validateVehicle(v); + + if (v.status() != Vehicle.Status.FREI_FUNK + && v.status() != Vehicle.Status.FREI_WACHE) + throw new InvalidOperationException("Fahrzeug nicht verfügbar: " + v.status()); + } + + validateOperation(o); + + return operationDAO.add( + o.toBuilder() + .created(Instant.now()) + .severity(extractSeverityFromOpCode(o.opCode())) + .status(Status.ACTIVE) + .build()); + } catch (PersistenceException e) { + throw new ServiceException(e); + } catch (InvalidVehicleException e) { + // already logged as invalid vehicle + throw new InvalidOperationException("Enthaltenes Fahrzeug ist ungültig", e); + } catch (ElementNotFoundException e) { + throw new InvalidOperationException("Enthaltenes Fahrzeug existiert nicht", e); + } + } + + @Override + public void requestVehicles(long operationId, Set vehicleIds) + throws InvalidOperationException, InvalidVehicleException, ServiceException { + Set vs = new HashSet<>(); + + try { + if (operationId <= 0) { + throw new InvalidOperationException("Einsatz-ID ist ungültig"); + } + Operation o = operationDAO.get(operationId); + validateOperation(o); + + if (o.opCode().trim().isEmpty() + || extractSeverityFromOpCode(o.opCode()) != o.severity()) { + throw new InvalidOperationException("Einsatzcode ist ungültig"); + } + + if (o.status() != Status.ACTIVE) { + throw new InvalidOperationException("Einsatz ist ungültig"); + } + + if (o.created() == null) { + throw new InvalidOperationException("Erstellungszeitpunkt darf nicht leer sein"); + } + + for (Long id : vehicleIds) { + if (id <= 0) { + throw new InvalidVehicleException("Fahrzeug-ID ist ungültig"); + } + + try { + Vehicle v = vehicleDAO.get(id); + VehicleServiceImpl.validateVehicle(v); + if (v.status() != Vehicle.Status.FREI_FUNK + && v.status() != Vehicle.Status.FREI_WACHE) + throw new InvalidOperationException( + "Fahrzeug nicht verfügbar: " + v.status()); + + vs.add(v); + } catch (ElementNotFoundException e) { + throw new InvalidVehicleException("VehicleId ist invalid"); + } + } + + vs.addAll(o.vehicles()); + if (vs.equals(o.vehicles())) return; + + operationDAO.update(o.toBuilder().vehicles(vs).build()); + } catch (ElementNotFoundException e) { + throw new InvalidOperationException("Kein Einsatz mit dieser ID existiert"); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + + @Override + public void complete(long operationId, Status status) + throws InvalidOperationException, ServiceException { + try { + Operation o = operationDAO.get(operationId); + operationDAO.update(o.toBuilder().status(status).build()); + } catch (ElementNotFoundException e) { + throw new InvalidOperationException(e); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + + @Override + public SortedSet rankVehicles(String opCode) + throws InvalidOperationException, ServiceException { + Set vehicles = + vehicleService.list(EnumSet.complementOf(EnumSet.of(Vehicle.Status.ABGEMELDET))); + + List> priorities = new ArrayList<>(); + Predicate ktw = v -> v.type() == VehicleType.KTW; + Predicate rtwNoNEF = v -> v.type() == VehicleType.RTW && !v.hasNef(); + Predicate rtwNEF = v -> v.type() == VehicleType.RTW && v.hasNef(); + Predicate nef = v -> v.type() == VehicleType.NEF; + Predicate nah = v -> v.type() == VehicleType.NAH; + + switch (extractSeverityFromOpCode(opCode)) { + case A: + // fallthrough + case B: + // fallthrough + case O: + priorities.add(ktw); + priorities.add(rtwNoNEF); + priorities.add(rtwNEF); + break; + case C: + priorities.add(rtwNEF); + priorities.add(rtwNoNEF); + priorities.add(ktw); + break; + case D: + priorities.add(rtwNEF); + priorities.add(nef); + priorities.add(nah); + priorities.add(rtwNoNEF); + priorities.add(ktw); + break; + case E: + priorities.add(nah); + priorities.add(nef); + priorities.add(rtwNEF); + priorities.add(rtwNoNEF); + priorities.add(ktw); + break; + } + + Comparator vehicleComparator = + (v1, v2) -> { + for (Predicate priority : priorities) { + if (priority.test(v1)) { + return -1; + } + if (priority.test(v2)) { + return +1; + } + } + return 0; + }; + + Supplier> supplier = () -> new TreeSet<>(vehicleComparator); + + return vehicles.stream().collect(Collectors.toCollection(supplier)); + } + + @Override + public Set list(EnumSet statuses) throws ServiceException { + try { + Set operations = operationDAO.list(statuses); + for (Operation o : operations) validateOperation(o); + + return operations; + } catch (PersistenceException e) { + throw new ServiceException(e); + } catch (InvalidOperationException e) { + // database returned invalid values + throw new ServiceException("DB returned invalid operation", e); + } + } + + private static void validateOperation(Operation o) throws InvalidOperationException { + if (o.vehicles().isEmpty()) { + throw new InvalidOperationException( + "Es muss mindestens ein Fahrzeug ausgewählt werden!"); + } + + for (Vehicle v : o.vehicles()) { + try { + VehicleServiceImpl.validateVehicle(v); + } catch (InvalidVehicleException e) { + throw new InvalidOperationException("Fahrzeug " + v.name() + " ist ungültig", e); + } + + // TODO: validate if NEF/RTW/NAH conditions? + } + + Instant created = o.created(); + if (created != null && created.isAfter(Instant.now())) { + throw new InvalidOperationException("Einsatz wurde in der Zukunft erstellt"); + } + + if (o.destination() == null || o.destination().trim().isEmpty()) { + throw new InvalidOperationException("Adresse darf nicht leer sein"); + } + + if (o.destination().length() > 100) { + throw new InvalidOperationException("Adresse darf 100 Zeichen nicht überschreiten"); + } + + if (o.additionalInfo() != null && o.additionalInfo().length() > 100) { + throw new InvalidOperationException("Anmerkung darf 100 Zeichen nicht überschreiten"); + } + } + + private static final Pattern opCodePattern = + Pattern.compile("(?:\\w{1,3}-\\d{0,2})([ABCDEO])(?:.*)"); + + private static Severity extractSeverityFromOpCode(String opCode) + throws InvalidOperationException { + Matcher m = opCodePattern.matcher(opCode); + + if (!m.matches()) { + throw new InvalidOperationException("Einsatzcode ist ungültig"); + } + + return Severity.valueOf(m.group(1)); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java new file mode 100644 index 0000000..027417f --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java @@ -0,0 +1,32 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.Set; + +public interface RegistrationService { + + /** + * Register employee to a vehicle. + * + * @param vehicleId the id of the target vehicle + * @param registrations that should be added to the vehicle + * @return the list of ids that were assigned + * @throws InvalidVehicleException if the vehicleId is invalid or does not exist + * @throws InvalidRegistrationException if the registration is invalid + * @throws ServiceException if the registration could not be persisted + */ + Set add(long vehicleId, Set registrations) + throws InvalidVehicleException, InvalidRegistrationException, ServiceException; + + /** + * Remove given registration from the store. + * + * @param registrationId the id of the registration that should be removed + * @throws InvalidRegistrationException if the registration is invalid or does not exist + * @throws ServiceException if the registration could not be removed from the store + */ + void remove(long registrationId) throws InvalidRegistrationException, ServiceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java new file mode 100644 index 0000000..3ec69e7 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java @@ -0,0 +1,52 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.RegistrationValidator; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class RegistrationServiceImpl implements RegistrationService { + + private final RegistrationDAO registrationDAO; + private final VehicleDAO vehicleDAO; + + @Autowired + public RegistrationServiceImpl(RegistrationDAO registrationDAO, VehicleDAO vehicleDAO) { + this.registrationDAO = registrationDAO; + this.vehicleDAO = vehicleDAO; + } + + @Override + public Set add(long vehicleId, Set registrations) + throws InvalidVehicleException, InvalidRegistrationException, ServiceException { + + if (vehicleId <= 0) throw new InvalidVehicleException("VehicleId invalid"); + + try { + Vehicle vehicle = vehicleDAO.get(vehicleId); + + RegistrationValidator.validate(vehicle, registrations); + + return registrationDAO.add(vehicle.id(), registrations); + } catch (PersistenceException e) { + throw new ServiceException(e); + } catch (ElementNotFoundException e) { + throw new InvalidVehicleException(e); + } + } + + @Override + public void remove(long registrationId) throws InvalidRegistrationException, ServiceException { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java new file mode 100644 index 0000000..d96dfb7 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java @@ -0,0 +1,49 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.EnumSet; +import java.util.Set; + +public interface VehicleService { + + /** + * Add given vehicle to the store. + * + * @param vehicle that should be added to the store + * @return the id that was assigned + * @throws InvalidVehicleException if the vehicle is invalid + * @throws ServiceException if the vehicle could not be persisted + */ + long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException; + + /** + * Update the given vehicle. + * + * @param vehicle that should be updated + * @return the updated vehicle + * @throws InvalidVehicleException if the vehicle is invalid + * @throws ServiceException if the updated vehicle could not be persisted + */ + Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException; + + /** + * Get all stored vehicles with matching status. + * + * @param statuses set containing all statuses that should be matched + * @return list containing all stored vehicles + * @throws ServiceException if loading the stored vehicles failed + */ + Set list(EnumSet statuses) throws ServiceException; + + /** + * Remove vehicle with the given id from the store. + * + * @param id of the vehicle that should be removed + * @throws InvalidVehicleException if given vehicle id is invalid or does not exist + * @throws ServiceException if the vehicle could not be removed from the store + */ + void remove(long id) throws InvalidVehicleException, ServiceException; +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleServiceImpl.java new file mode 100644 index 0000000..6a035c6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleServiceImpl.java @@ -0,0 +1,116 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Collectors; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +@Service +public class VehicleServiceImpl implements VehicleService { + + private VehicleDAO vehiclePersistence; + + public VehicleServiceImpl(VehicleDAO vehiclePersistence) { + this.vehiclePersistence = vehiclePersistence; + } + + public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { + if (!CollectionUtils.isEmpty(vehicle.registrations())) { + throw new InvalidVehicleException( + "Fahrzeug kann nicht mit Anmeldungen erstellt werden"); + } + + validateVehicle(vehicle); + try { + vehiclePersistence.add(vehicle); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + return 0; + } + + public Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException { + validateVehicle(vehicle); + try { + vehiclePersistence.update(vehicle); + } catch (ElementNotFoundException e) { + throw new ServiceException("Element not found", e); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + return vehicle; + } + + protected static void validateVehicle(Vehicle vehicle) throws InvalidVehicleException { + switch (vehicle.type()) { + case RTW: + if (vehicle.constructionType() == ConstructionType.NORMAL) { + throw new InvalidVehicleException("RTW darf kein Normales Dach haben"); + } else if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { + throw new InvalidVehicleException("RTW darf kein Mittelhochdach haben"); + } + break; + case KTW: + if (vehicle.constructionType() == ConstructionType.NORMAL) { + throw new InvalidVehicleException("KTW darf kein Normales Dach haben"); + } + break; + case KTW_B: + if (vehicle.constructionType() == ConstructionType.NORMAL) { + throw new InvalidVehicleException("KTW-B darf kein Normales Dach haben"); + } + break; + case NEF: + if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { + throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); + } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) { + throw new InvalidVehicleException("NEF darf kein Hochdach haben"); + } + break; + case NAH: + if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) { + throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); + } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) { + throw new InvalidVehicleException("NEF darf kein Hochdach haben"); + } + break; + case BKTW: + break; + default: + throw new IllegalStateException("BUG: invalid vehicle type" + vehicle.type()); + } + } + + @Override + public Set list(EnumSet statuses) throws ServiceException { + if (statuses == null) { + throw new ServiceException("Statuses may not be null"); + } + + Set vehicles; + + try { + vehicles = vehiclePersistence.list(); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + + return vehicles.stream() + .filter(vehicle -> statuses.contains(vehicle.status())) + .collect(Collectors.toSet()); + } + + @Override + public void remove(long id) throws InvalidVehicleException, ServiceException { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/resources/fxml/ArchiveOperation.fxml b/src/main/resources/fxml/ArchiveOperation.fxml index 0150d81..e9549ae 100644 --- a/src/main/resources/fxml/ArchiveOperation.fxml +++ b/src/main/resources/fxml/ArchiveOperation.fxml @@ -12,7 +12,7 @@ - + diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 0c82e29..56e0c90 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -14,7 +14,7 @@ - +