From 62570c6418ebb1cfd391ce61e9fe153c0b5e53f5 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 23 Apr 2017 16:02:35 -0400 Subject: [PATCH] My Tickets Page Created --- .../webpages/administration/allTickets.jsp | 4 - .../html/webpages/components/adminnavbar.jsp | 1 + .../html/webpages/components/navbar.jsp | 1 + WebContent/html/webpages/mytickets.jsp | 250 ++++++++++++++++++ WebContent/html/webpages/shoppingCart.jsp | 19 +- src/database/AdminQueries.java | 1 - src/database/DeviceQueries.java | 45 +++- src/database/TicketQueries.java | 58 +++- src/entities/Ticket.java | 2 +- 9 files changed, 352 insertions(+), 29 deletions(-) create mode 100644 WebContent/html/webpages/mytickets.jsp diff --git a/WebContent/html/webpages/administration/allTickets.jsp b/WebContent/html/webpages/administration/allTickets.jsp index 339bfb0..a512dc0 100644 --- a/WebContent/html/webpages/administration/allTickets.jsp +++ b/WebContent/html/webpages/administration/allTickets.jsp @@ -42,10 +42,6 @@ pageEncoding="ISO-8859-1"%> text-align: left; } - .btn{ - margin-top: 15px; - } - body{ overflow: visible; } diff --git a/WebContent/html/webpages/components/adminnavbar.jsp b/WebContent/html/webpages/components/adminnavbar.jsp index 4bfbe33..df885d5 100644 --- a/WebContent/html/webpages/components/adminnavbar.jsp +++ b/WebContent/html/webpages/components/adminnavbar.jsp @@ -32,6 +32,7 @@ diff --git a/WebContent/html/webpages/components/navbar.jsp b/WebContent/html/webpages/components/navbar.jsp index 99c35ac..cd353f8 100644 --- a/WebContent/html/webpages/components/navbar.jsp +++ b/WebContent/html/webpages/components/navbar.jsp @@ -32,6 +32,7 @@ diff --git a/WebContent/html/webpages/mytickets.jsp b/WebContent/html/webpages/mytickets.jsp new file mode 100644 index 0000000..ee3e086 --- /dev/null +++ b/WebContent/html/webpages/mytickets.jsp @@ -0,0 +1,250 @@ +<%@ page import = "database.*,entities.*" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" +pageEncoding="ISO-8859-1"%> + + + + + + + + + + + Innovation Hub + + + + + + + + + + + + + + + + + + + +
+

My Tickets

+ +
+ +
+ + + + + + + + + + + + + + +
Ticket IDRequestor NameLocation NameDevice NameStatusPermanent?Return Date
+
+ +<% +/* + Get all tickets in users name. +*/ +Ticket[] tickets = TicketQueries.getAllTickets(Integer.parseInt(navsso)); +String ticketStr = Ticket.arrayToString(tickets); +%> + + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/shoppingCart.jsp b/WebContent/html/webpages/shoppingCart.jsp index 35a396d..2e2a398 100644 --- a/WebContent/html/webpages/shoppingCart.jsp +++ b/WebContent/html/webpages/shoppingCart.jsp @@ -17,9 +17,9 @@ pageEncoding="ISO-8859-1"%> Innovation Hub + - @@ -85,7 +74,7 @@ pageEncoding="ISO-8859-1"%>

- +

@@ -171,7 +160,7 @@ pageEncoding="ISO-8859-1"%>
- +
diff --git a/src/database/AdminQueries.java b/src/database/AdminQueries.java index ad0bddc..5a1d541 100644 --- a/src/database/AdminQueries.java +++ b/src/database/AdminQueries.java @@ -6,7 +6,6 @@ * This class is responsible for performing most queries corresponding * to admin (object) actions. * @author Connor Jackson - * */ public class AdminQueries { diff --git a/src/database/DeviceQueries.java b/src/database/DeviceQueries.java index 6281521..5bbf7a8 100644 --- a/src/database/DeviceQueries.java +++ b/src/database/DeviceQueries.java @@ -4,12 +4,22 @@ import entities.Device; +/** + * This class is responsible for performing most queries corresponding + * to device actions. + * @author Connor Jackson + */ public class DeviceQueries { private static String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317"; private static String user = "b372dfe7409692"; private static String password = "74f6e317"; + /** + * This function retrieves all devices checked out by a certain user. + * This is in support of the "My Devices" webpage. + * @author Connor Jackson + */ public static Device[] getUserDevices(String userID) throws SQLException, ClassNotFoundException, InterruptedException{ System.getenv("VCAP_SERVICES"); Class.forName("com.mysql.jdbc.Driver"); @@ -69,6 +79,11 @@ public static Device[] getUserDevices(String userID) throws SQLException, ClassN return devices; } + /** + * This function retrieves all devices currently in inventory. + * This is in support of the Device Library webpage, and Device Admin Settings. + * @author Connor Jackson + */ public static Device[] getAllDevices() throws SQLException, ClassNotFoundException, InterruptedException{ //database connect System.getenv("VCAP_SERVICES"); @@ -129,6 +144,11 @@ public static Device[] getAllDevices() throws SQLException, ClassNotFoundExcepti return devices; } + /** + * This function retrieves all devices that are currently available. + * This is to support the Request Hub, we only want users to see devices they can actually order. + * @author Connor Jackson + */ public static Device[] getAvailableDevices() throws SQLException, ClassNotFoundException, InterruptedException{ //database connect System.getenv("VCAP_SERVICES"); @@ -190,13 +210,9 @@ public static Device[] getAvailableDevices() throws SQLException, ClassNotFoundE } /** - * This function will take devices as input and return them. - * More specifically, the input will be a string that looks like an array. - * The values in this array correspond to device ID's. - * @param devices - * @throws ClassNotFoundException - * @throws SQLException - * @throws InterruptedException + * This function will change the device's status to "Returning", indicating that it's on its way + * home. + * @param devices A Stringified Array on Device ID's */ public static void returnDevices(String devices) throws ClassNotFoundException, SQLException, InterruptedException{ //connect to DB @@ -232,6 +248,11 @@ public static void returnDevices(String devices) throws ClassNotFoundException, connection.close(); } + /** + * This function will create a new device in the database. + * This is in support of the Device Hub webpage for admins. + * @author Connor Jackson + */ public static void addDevice(Device device) throws SQLException, ClassNotFoundException, InterruptedException{ System.getenv("VCAP_SERVICES"); Class.forName("com.mysql.jdbc.Driver"); @@ -273,6 +294,11 @@ public static void addDevice(Device device) throws SQLException, ClassNotFoundEx connection.close(); } + /** + * This function will update information about a device in the database. + * This supports the Device Hub for admins. + * @author Connor Jackson + */ public static void modifyDevice(Device device) throws ClassNotFoundException, SQLException, InterruptedException{ System.getenv("VCAP_SERVICES"); Class.forName("com.mysql.jdbc.Driver"); @@ -301,6 +327,11 @@ public static void modifyDevice(Device device) throws ClassNotFoundException, SQ connection.close(); } + /** + * This function will delete a device from the database. + * This is to support the Device Hub for admins. + * @author Connor Jackson + */ public static void deleteDevice(int id) throws ClassNotFoundException, SQLException, InterruptedException{ System.getenv("VCAP_SERVICES"); Class.forName("com.mysql.jdbc.Driver"); diff --git a/src/database/TicketQueries.java b/src/database/TicketQueries.java index 85a2701..18ecc4a 100644 --- a/src/database/TicketQueries.java +++ b/src/database/TicketQueries.java @@ -8,7 +8,6 @@ * This class is responsible for performing most queries corresponding * to ticket actions. * @author Brianna Boyce, Connor Jackson, Adam Claxton - * */ public class TicketQueries { @@ -181,6 +180,63 @@ public static Ticket[] getAllTickets() return tickets; } + /** + * This function retrieves all tickets based on user id.. + * @author Connor Jackson + */ + public static Ticket[] getAllTickets(int sso) + throws SQLException, ClassNotFoundException, InterruptedException{ + int i = 0; + System.getenv("VCAP_SERVICES"); + Class.forName("com.mysql.jdbc.Driver"); + Connection connection; + Statement stmt; + for(;;){ + try{ + connection = DriverManager.getConnection(database, user, password); + break; + } + catch(SQLException e){ + Thread.sleep(1); + } + } + for(;;){ + try{ + stmt = connection.createStatement(); + break; + } + catch(SQLException e){ + Thread.sleep(1); + } + } + ResultSet resultSet = stmt.executeQuery("SELECT ticket.*, employee.Name AS 'username', devices.Device_Name, location.Name AS 'locationname' FROM ticket INNER JOIN employee ON ticket.Requestor = employee.Employee_ID INNER JOIN devices ON ticket.Device_ID = devices.Device_ID INNER JOIN location ON ticket.Location = location.Location_ID WHERE Requestor = " + sso); + resultSet.last(); + int rows = resultSet.getRow(); + resultSet.beforeFirst(); + Ticket[] tickets = new Ticket[rows]; + + while(resultSet.next()){ + tickets[i] = new Ticket( + resultSet.getInt("Ticket_ID"), + resultSet.getInt("Requestor"), + resultSet.getLong("Request_Date"), + resultSet.getInt("Location"), + resultSet.getInt("Device_ID"), + resultSet.getString("Status"), + resultSet.getLong("Status_Date_Fields"), + resultSet.getString("Return_Date"), + resultSet.getString("username"), + resultSet.getString("Device_Name"), + resultSet.getString("locationname"), + resultSet.getInt("Permanent_Order") + ); + i++; + } + stmt.close(); + connection.close(); + return tickets; + } + /** * This function accepts a ticket, and assigns that ticket & device to its * corresponding renter and location. diff --git a/src/entities/Ticket.java b/src/entities/Ticket.java index e6b1bea..edcdadc 100644 --- a/src/entities/Ticket.java +++ b/src/entities/Ticket.java @@ -17,7 +17,7 @@ public class Ticket { private String devicename; private String permanent; - public Ticket(int id, int requestor, long requestDate, int location, int deviceId, String status, long statusDateFields, String returnDate, String username, String locationname, String devicename, int permanent){ + public Ticket(int id, int requestor, long requestDate, int location, int deviceId, String status, long statusDateFields, String returnDate, String username, String devicename, String locationname, int permanent){ this._id = id; this._requestor = requestor; this._requestDate = requestDate;