From 62570c6418ebb1cfd391ce61e9fe153c0b5e53f5 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 23 Apr 2017 16:02:35 -0400 Subject: [PATCH 1/6] 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; From c5bd266d380de09acdd1e79c716d5cbc61ec1cef Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 23 Apr 2017 18:25:34 -0400 Subject: [PATCH 2/6] Adding logs --- WebContent/html/javascript/request.jsp | 1 + .../webpages/redirect/adminpasswordchange.jsp | 4 +- .../webpages/redirect/adminpasswordupdate.jsp | 5 +- src/database/DeviceQueries.java | 31 +++++++--- src/database/LocationQueries.java | 60 ++++++++++++------- src/database/TicketQueries.java | 24 +++++--- 6 files changed, 84 insertions(+), 41 deletions(-) diff --git a/WebContent/html/javascript/request.jsp b/WebContent/html/javascript/request.jsp index 78a1ce9..640eb5e 100644 --- a/WebContent/html/javascript/request.jsp +++ b/WebContent/html/javascript/request.jsp @@ -11,6 +11,7 @@ Device[] mydevices = DeviceQueries.getAvailableDevices(); //string representation of array. String deviceString = Device.arrayToString(mydevices); +deviceString = deviceString.replace("'","\\'"); //out.println(description); //out.println(hardware); %> diff --git a/WebContent/html/webpages/redirect/adminpasswordchange.jsp b/WebContent/html/webpages/redirect/adminpasswordchange.jsp index b0181bb..5d226df 100644 --- a/WebContent/html/webpages/redirect/adminpasswordchange.jsp +++ b/WebContent/html/webpages/redirect/adminpasswordchange.jsp @@ -76,7 +76,9 @@ if(request.getParameter("submit") != null){ } } ResultSet result; - result = stmt.executeQuery("select * FROM admin where Admin_ID='" + navsso + "' AND Password='" + generatedOldPass + "'"); + String query = "select * FROM admin where Admin_ID='" + navsso + "' AND Password='" + generatedOldPass + "'"; + result = stmt.executeQuery(query); + System.out.println("Executing query: "+query); if(result.next()){//if old password is accurate if (!old.equals(newpass) && newpass.equals(confirm) && pincode.length() == 4 && AdminQueries.pincodeInt(pincode)){//if the password is new AND both news ones are equal AND pincode is 4 digits AND pincode is a number try { diff --git a/WebContent/html/webpages/redirect/adminpasswordupdate.jsp b/WebContent/html/webpages/redirect/adminpasswordupdate.jsp index 5dc7241..b8b9363 100644 --- a/WebContent/html/webpages/redirect/adminpasswordupdate.jsp +++ b/WebContent/html/webpages/redirect/adminpasswordupdate.jsp @@ -87,8 +87,9 @@ if(request.getParameter("password") != null){ } } ResultSet result; - result = stmt.executeQuery("select * FROM admin where Admin_ID='" + navsso + "' AND Password='" + generatedOldPass + "'"); - + String query = "select * FROM admin where Admin_ID='" + navsso + "' AND Password='" + generatedOldPass + "'"; + result = stmt.executeQuery(query); + System.out.println("Executing query: "+query); /* If the old password is correct, then we can continue to change the password. */ diff --git a/src/database/DeviceQueries.java b/src/database/DeviceQueries.java index 5bbf7a8..d19e753 100644 --- a/src/database/DeviceQueries.java +++ b/src/database/DeviceQueries.java @@ -43,8 +43,9 @@ public static Device[] getUserDevices(String userID) throws SQLException, ClassN Thread.sleep(1); } } - - ResultSet resultSet = stmt.executeQuery("SELECT * FROM devices WHERE Renter = " + userID + " AND Status <> \"Available\" AND Status <> \"Returning \""); + String query = "SELECT * FROM devices WHERE Renter = " + userID + " AND Status <> \"Available\" AND Status <> \"Returning \""; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int counter = 0; resultSet.last(); @@ -109,7 +110,9 @@ public static Device[] getAllDevices() throws SQLException, ClassNotFoundExcepti } } - ResultSet resultSet = stmt.executeQuery("SELECT * FROM devices"); + String query = "SELECT * FROM devices"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int counter = 0; resultSet.last(); @@ -174,7 +177,9 @@ public static Device[] getAvailableDevices() throws SQLException, ClassNotFoundE } } - ResultSet resultSet = stmt.executeQuery("SELECT * FROM devices WHERE Status = \"Available\""); + String query = "SELECT * FROM devices WHERE Status = \"Available\""; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int counter = 0; resultSet.last(); @@ -242,7 +247,9 @@ public static void returnDevices(String devices) throws ClassNotFoundException, String[] deviceArray = devices.replaceAll("\\[","").replaceAll("\\]","").replaceAll("\\s","").split(","); for(int i = 0; i < deviceArray.length; i++){ //update statement - stmt.executeUpdate("UPDATE devices SET Status = \"Returning\" WHERE Device_ID = " + deviceArray[i]); + String query = "UPDATE devices SET Status = \"Returning\" WHERE Device_ID = " + deviceArray[i]; + stmt.executeUpdate(query); + System.out.println("Executing query: "+query); } stmt.close(); connection.close(); @@ -280,15 +287,17 @@ public static void addDevice(Device device) throws SQLException, ClassNotFoundEx int i = -1; int id=0; while(i <= 0){ - ResultSet results = stmt.executeQuery("SELECT * from devices ORDER BY Device_ID"); + String query = "SELECT * from devices ORDER BY Device_ID"; + ResultSet results = stmt.executeQuery(query); + System.out.println("Executing query: "+query); results.last(); //gets largest ID id = results.getInt("Device_ID"); id++; //tries this statement, otherwise tries again with a new id String command = "INSERT INTO devices (Device_ID,Device_Name,Device_Description,MAC_Address,Manufacturer,Hardware,Model,Serial_Num,Status,NFC_ID,Locker_Position,Operating_System,Admin_Comments) " + "VALUES (" + id +",\"" + device.getName() + "\",\"" + device.getDesc()+ "\",\"" + device.getMAC() + "\",\"" + device.getManufacturer() + "\",\""+device.getHardware()+ "\",\"" + device.getModel() + "\",\"" + device.getSerial() + "\",\"" + device.getStatus() + "\",\"" + device.getNFC() + "\",\"" + device.getPos() + "\",\"" + device.getOS() + "\",\"" + device.getComment() +"\");"; - System.out.println(command); i = stmt.executeUpdate(command); + System.out.println("Executing query: "+command); } stmt.close(); connection.close(); @@ -322,7 +331,9 @@ public static void modifyDevice(Device device) throws ClassNotFoundException, SQ Thread.sleep(1); } } - stmt.executeUpdate("UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = \"" + device.getNFC() + "\", Admin_Comments = \"" + device.getComment() + "\", Operating_System = \"" + device.getOS() + "\", Locker_Position = \"" + device.getPos() + "\" WHERE Device_ID = " + device.getID()); + String query = "UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = \"" + device.getNFC() + "\", Admin_Comments = \"" + device.getComment() + "\", Operating_System = \"" + device.getOS() + "\", Locker_Position = \"" + device.getPos() + "\" WHERE Device_ID = " + device.getID(); + stmt.executeUpdate(query); + System.out.println("Executing query: "+query); stmt.close(); connection.close(); } @@ -355,7 +366,9 @@ public static void deleteDevice(int id) throws ClassNotFoundException, SQLExcept Thread.sleep(1); } } - stmt.executeUpdate("DELETE from devices WHERE Device_ID = " + id); + String query = "DELETE from devices WHERE Device_ID = " + id; + stmt.executeUpdate(query); + System.out.println("Executing query: "+query); stmt.close(); connection.close(); } diff --git a/src/database/LocationQueries.java b/src/database/LocationQueries.java index d3e5222..8bf5313 100644 --- a/src/database/LocationQueries.java +++ b/src/database/LocationQueries.java @@ -34,7 +34,9 @@ public static int locationStringToInt(String locString) throws SQLException, Cla Thread.sleep(1); } } - ResultSet resultSet = stmt.executeQuery("SELECT Location_ID FROM location WHERE Address = '"+locString+"'"); + String query = "SELECT Location_ID FROM location WHERE Address = '"+locString+"'"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.next(); int returnResult = resultSet.getInt("Location_ID"); stmt.close(); @@ -66,7 +68,9 @@ public static String locationIntToString(int locInt) throws ClassNotFoundExcepti Thread.sleep(1); } } - ResultSet resultSet = stmt.executeQuery("SELECT Address FROM location WHERE Location_ID = "+locInt); + String query = "SELECT Address FROM location WHERE Location_ID = "+locInt; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.next(); String returnResult = resultSet.getString("Address"); stmt.close(); @@ -101,14 +105,19 @@ public static int addLocation(Location location) throws SQLException, ClassNotFo } int i = -1; int id=0; + String query = "SELECT * from location ORDER BY Location_ID"; while(i <= 0){ - ResultSet results = stmt.executeQuery("SELECT * from location ORDER BY Location_ID"); + ResultSet results = stmt.executeQuery(query); + System.out.println("Executing query: "+query); results.last(); //gets largest ID id = results.getInt("Location_ID"); id++; //tries this statement, otherwise tries again with a new id - i = stmt.executeUpdate("INSERT INTO location (Location_ID,Name,Address,Town,State,Zip_Code,Employee_Flag,Latitude,Longitude) VALUES (" + id +",\"" + location.getName() + "\",\"" + location.getAddress()+ "\",\"" + location.getTown() + "\",\"" + location.getState() + "\",\"" + location.getZip() + "\"," + location.getEmployeeFlag() + ",\"" + location.getLat() + "\",\"" + location.getLng() + "\")"); + query = "INSERT INTO location (Location_ID,Name,Address,Town,State,Zip_Code,Employee_Flag,Latitude,Longitude) VALUES (" + id +",\"" + location.getName() + "\",\"" + location.getAddress()+ "\",\"" + location.getTown() + "\",\"" + location.getState() + "\",\"" + location.getZip() + "\"," + location.getEmployeeFlag() + ",\"" + location.getLat() + "\",\"" + location.getLng() + "\")"; + i = stmt.executeUpdate(query); + System.out.println("Executing query: "+query); + query = "SELECT * from location ORDER BY Location_ID"; } stmt.close(); connection.close(); @@ -139,7 +148,9 @@ public static Location[] getAdminLocations() throws ClassNotFoundException, SQLE Thread.sleep(1); } } - ResultSet resultSet = stmt.executeQuery("SELECT * FROM location WHERE Employee_Flag = 0 ORDER BY Location_ID"); + String query = "SELECT * FROM location WHERE Employee_Flag = 0 ORDER BY Location_ID"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int counter = 0; resultSet.last(); @@ -165,7 +176,9 @@ public static Location[] getAdminLocations() throws ClassNotFoundException, SQLE ); counter++; } - resultSet = stmt.executeQuery("SELECT location.location_id, count(*) AS 'count' FROM location JOIN devices ON devices.location = location.location_id WHERE employee_flag = 0 group by location.Location_ID ORDER BY location.Location_ID"); + query = "SELECT location.location_id, count(*) AS 'count' FROM location JOIN devices ON devices.location = location.location_id WHERE employee_flag = 0 group by location.Location_ID ORDER BY location.Location_ID"; + resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.last(); rows = resultSet.getRow(); resultSet.beforeFirst(); @@ -180,7 +193,9 @@ public static Location[] getAdminLocations() throws ClassNotFoundException, SQLE } j++; } - resultSet = stmt.executeQuery("SELECT location.location_id, count(*) AS 'count' FROM location JOIN employee ON employee.location_id = location.location_id WHERE employee_flag = 0 group by location.Location_ID ORDER BY location.Location_ID"); + query = "SELECT location.location_id, count(*) AS 'count' FROM location JOIN employee ON employee.location_id = location.location_id WHERE employee_flag = 0 group by location.Location_ID ORDER BY location.Location_ID"; + resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.last(); rows = resultSet.getRow(); resultSet.beforeFirst(); @@ -228,10 +243,13 @@ public static Location[] getLocations(int userID) throws SQLException, ClassNotF Thread.sleep(1); } } - ResultSet rs = stmt.executeQuery("SELECT COUNT(Location_ID) FROM location WHERE Employee_Flag = 0 OR Employee_Flag = "+userID); + String resultlength = "SELECT COUNT(Location_ID) FROM location WHERE Employee_Flag = 0 OR Employee_Flag = "+userID; + ResultSet rs = stmt.executeQuery(resultlength); + System.out.println("Executing query: "+query); rs.next(); Location[] locations = new Location[rs.getInt("COUNT(Location_ID)")]; rs = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int i=0; while(rs.next()) { @@ -256,10 +274,7 @@ public static Location[] getLocations(int userID) throws SQLException, ClassNotF /** * Updates a location, assuming that all input fields have been changed. - * @param location - * @throws ClassNotFoundException - * @throws SQLException - * @throws InterruptedException + * @author Connor Jackson */ public static void modifyLocation(Location location) throws ClassNotFoundException, SQLException, InterruptedException{ System.getenv("VCAP_SERVICES"); @@ -284,17 +299,16 @@ public static void modifyLocation(Location location) throws ClassNotFoundExcepti Thread.sleep(1); } } - stmt.executeUpdate("UPDATE location SET Name = \"" + location.getName() + "\", Address = \"" + location.getAddress() + "\", Town = \"" + location.getTown() + "\", State = \"" + location.getState() + "\", Zip_Code = \"" + location.getZip() + "\", Latitude = \"" + location.getLat() + "\", Longitude = \"" + location.getLng() + "\" WHERE Location_ID = " + location.getID()); + String query = "UPDATE location SET Name = \"" + location.getName() + "\", Address = \"" + location.getAddress() + "\", Town = \"" + location.getTown() + "\", State = \"" + location.getState() + "\", Zip_Code = \"" + location.getZip() + "\", Latitude = \"" + location.getLat() + "\", Longitude = \"" + location.getLng() + "\" WHERE Location_ID = " + location.getID(); + stmt.executeUpdate(query); + System.out.println("Executing query: "+query); stmt.close(); connection.close(); } /** * Deletes a location based on input id. - * @param id - * @throws ClassNotFoundException - * @throws SQLException - * @throws InterruptedException + * @author Connor Jackson */ public static int deleteLocation(int id) throws ClassNotFoundException, SQLException, InterruptedException{ System.getenv("VCAP_SERVICES"); @@ -319,8 +333,10 @@ public static int deleteLocation(int id) throws ClassNotFoundException, SQLExcep Thread.sleep(1); } } + String query = "DELETE from location WHERE Location_ID = " + id; try { - stmt.executeUpdate("DELETE from location WHERE Location_ID = " + id); + stmt.executeUpdate(query); + System.out.println("Executing query: "+query); } catch (SQLException e) { stmt.close(); connection.close(); @@ -355,7 +371,9 @@ public static Location[] getAllLocations() throws SQLException, ClassNotFoundExc Thread.sleep(1); } } - ResultSet resultSet = stmt.executeQuery("SELECT * FROM location"); + String query = "SELECT * FROM location"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); int counter = 0; resultSet.last(); @@ -411,7 +429,9 @@ public static Location getLocationByID(int id) throws InterruptedException, Clas Thread.sleep(1); } } - ResultSet resultSet = stmt.executeQuery("SELECT * FROM location WHERE Location_ID = " + id); + String query = "SELECT * FROM location WHERE Location_ID = " + id; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.next(); return new Location( resultSet.getInt("Location_ID"), diff --git a/src/database/TicketQueries.java b/src/database/TicketQueries.java index 18ecc4a..b93f5be 100644 --- a/src/database/TicketQueries.java +++ b/src/database/TicketQueries.java @@ -59,8 +59,8 @@ public static int generateTicket(int requester, int location, int device, String query+= "'"+time+"'" +", "; query+= "'"+returnDate+"'" + ", "; query+= perm + ");"; - System.out.println(query); stmt.executeUpdate(query); + System.out.println("Executing query: "+query); stmt.close(); connection.close(); return ticketID; @@ -95,7 +95,9 @@ public static Ticket[] getRequestedTickets() 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 ticket.Status = 'Requested'"); + String query = "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 ticket.Status = 'Requested'"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.last(); int rows = resultSet.getRow(); resultSet.beforeFirst(); @@ -152,7 +154,9 @@ public static Ticket[] getAllTickets() 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"); + String query = "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"; + ResultSet resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.last(); int rows = resultSet.getRow(); resultSet.beforeFirst(); @@ -209,7 +213,9 @@ public static Ticket[] getAllTickets(int sso) 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); + String query = "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 resultSet = stmt.executeQuery(query); + System.out.println("Executing query: "+query); resultSet.last(); int rows = resultSet.getRow(); resultSet.beforeFirst(); @@ -273,10 +279,9 @@ public static void acceptTicket(int ticketid, int deviceid, int locationid, int +", devices.Status = \"Ready to Ship\", devices.Renter = " + sso +", devices.Location = " + locationid +", devices.Permanent = " + perm - +" WHERE ticket.Ticket_ID = " + ticketid + " AND devices.Device_ID = " + deviceid; - System.out.println("Executing query: "+query); + +" WHERE ticket.Ticket_ID = " + ticketid + " AND devices.Device_ID = " + deviceid; stmt.executeUpdate(query); - + System.out.println("Executing query: "+query); stmt.close(); connection.close(); } @@ -311,8 +316,8 @@ public static void rejectTicket(int id) } long milliseconds = new Date().getTime(); String query="UPDATE ticket SET Status = \"Rejected\", Status_Date_Fields = "+milliseconds+" WHERE Ticket_ID = " + id; - System.out.println("Executing query "+query); stmt.executeUpdate(query); + System.out.println("Executing query: "+query); stmt.close(); connection.close(); } @@ -332,8 +337,8 @@ public static Ticket[] getRecentlyChangedTickets(int userID, String status, long +"INNER JOIN location ON ticket.Location = location.Location_ID " +"WHERE ticket.Status = '"+status+"' AND Requestor = " + userID +" AND Status_Date_Fields >= " + milliseconds; - System.out.println("Executing query '"+query+"'"); ResultSet results = stmt.executeQuery(query); + System.out.println("Executing query: "+query); results.last(); int rows = results.getRow(); results.beforeFirst(); @@ -391,6 +396,7 @@ public static int getUserID(int ticketID) throws ClassNotFoundException, SQLExce } String query = "SELECT Requestor FROM ticket WHERE Ticket_ID = "+ticketID+";"; ResultSet results = stmt.executeQuery(query); + System.out.println("Executing query: "+query); results.next(); int answer = results.getInt("Requestor"); stmt.close(); From 4fe48e21ad4a00b2390a2903280cc03d265ffaf9 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 23 Apr 2017 20:11:09 -0400 Subject: [PATCH 3/6] Bootstrap Tables. Boostrap Tables Everywhere. --- .../webpages/administration/adminApprove.jsp | 56 +++++++++---- .../webpages/administration/adminLocation.jsp | 80 +++++++++++++++---- .../webpages/administration/allTickets.jsp | 14 ++-- WebContent/html/webpages/mytickets.jsp | 7 +- 4 files changed, 117 insertions(+), 40 deletions(-) diff --git a/WebContent/html/webpages/administration/adminApprove.jsp b/WebContent/html/webpages/administration/adminApprove.jsp index af64ee3..4eafaf7 100644 --- a/WebContent/html/webpages/administration/adminApprove.jsp +++ b/WebContent/html/webpages/administration/adminApprove.jsp @@ -11,13 +11,18 @@ pageEncoding="ISO-8859-1"%> - Innovation Hub - - - - - - + Innovation Hub + + + + + + + + + + + @@ -93,16 +107,16 @@ pageEncoding="ISO-8859-1"%>
- +
- - - - - - - + + + + + + + @@ -147,6 +161,18 @@ String ticketStr = Ticket.arrayToString(tickets); var searchbar = document.getElementsByName('searchBar'); searchbar[0].onkeyup = refresh; + // Set up table record event listeners + $('#tabledisplay').bootstrapTable({onClickRow: function(row,$element){ + var id = $element[0].getAttribute('id'); + var html = ""; + document.getElementById("tablemodal").innerHTML = html; + $("#ticketIDfield").val(ticks[id].id); + $("#deviceIDfield").val(ticks[id].deviceID); + $("#locationIDfield").val(ticks[id].location); + $("#permField").val(ticks[id].permanent); + $("#Modal").show(); + }}); + /* Params: tickets - array of objects, formatted as tickets. This function will display tickets in a table on the webpage. diff --git a/WebContent/html/webpages/administration/adminLocation.jsp b/WebContent/html/webpages/administration/adminLocation.jsp index 4868e39..9bb08d9 100644 --- a/WebContent/html/webpages/administration/adminLocation.jsp +++ b/WebContent/html/webpages/administration/adminLocation.jsp @@ -15,11 +15,17 @@ + + + + + + + + - -
Ticket IDRequestor NameLocation NameDevice NameStatusPermanent?Return DateTicket IDRequestor NameLocation NameDevice NameStatusPermanent?Return Date
" + ticks[id].id + "" + ticks[id].username + "" + ticks[id].locationname + "" + ticks[id].devicename + "" + ticks[id].status + "" + ticks[id].permanent + "" + ticks[id].return + "
- - - - - - - - - - - - +
NameAddressTownStateZip Code
+ + + + + + + + + + + +
NameAddressTownStateZip Code
@@ -297,6 +312,41 @@ window.onkeydown = function(e){if (e.keyCode == 27){closeAddModal();closeModifyM //Event listener exits modal when click outside modal. window.onclick = function(e){var add = document.getElementById('addModal'); var modify = document.getElementById('modifyModal'); if(e.target == add || e.target == modify) {closeAddModal();closeModifyModal();}} +// Event listener for table records. +$('#tabledisplay').bootstrapTable({onClickRow: function(row,$element){ + var id = $element[0].getAttribute('id'); + for(var i = 0; i < locations.length; i++){ + if(id == locations[i].id) + break; + } + //autofill all information from what you clicked on into modal + $("#modifyName").val(locations[i].name.replace(/"/g,"\"")); + $("#modifyAddress").val(locations[i].address.replace(/"/g,"\"")); + $("#modifyTown").val(locations[i].town.replace(/"/g,"\"")); + $("#modifyState").val(locations[i].state); + $("#modifyZip").val(locations[i].zip); + $("#modifyID").val(locations[i].id); + + var geocoder = new google.maps.Geocoder(); + //this function assumes that you are using a proper zip code... + geocoder.geocode({'address':locations[i].zip}, function(results,status) + {if (status == google.maps.GeocoderStatus.OK) + {$("#modifylat").val(results[0].geometry.location.lat()); + $("#modifylng").val(results[0].geometry.location.lng());} + }); + + //if the location has a foreign key constraint, then the delete button should be restricted + if(locations[i].numDevices > 0 || locations[i].numEmployees > 0){ + $('#thedeletebutton').attr('disabled',true); + $('#thedeletebutton').attr('title','Cannot delete because devices and/or employees are at this location!'); + } + else{ + $('#thedeletebutton').attr('disabled',false); + $('#thedeletebutton').removeAttr('title'); + } + $("#modifyModal").show(); +}}); + //Places all locations from query into page function populateLocations(){ var html = ""; diff --git a/WebContent/html/webpages/administration/allTickets.jsp b/WebContent/html/webpages/administration/allTickets.jsp index a512dc0..0ea097a 100644 --- a/WebContent/html/webpages/administration/allTickets.jsp +++ b/WebContent/html/webpages/administration/allTickets.jsp @@ -29,10 +29,6 @@ pageEncoding="ISO-8859-1"%> text-align: center; } - tr.entry{ - cursor: pointer; - } - .table{ width: auto; background-color: #E9EAEB; @@ -45,6 +41,12 @@ pageEncoding="ISO-8859-1"%> body{ overflow: visible; } + + div.displayDevice{ + padding-right: 30px; + padding-bottom: 30px; + } + @@ -65,7 +67,8 @@ pageEncoding="ISO-8859-1"%>
-
+ +
@@ -81,6 +84,7 @@ pageEncoding="ISO-8859-1"%>
+
<% diff --git a/WebContent/html/webpages/mytickets.jsp b/WebContent/html/webpages/mytickets.jsp index ee3e086..47047c1 100644 --- a/WebContent/html/webpages/mytickets.jsp +++ b/WebContent/html/webpages/mytickets.jsp @@ -30,10 +30,6 @@ pageEncoding="ISO-8859-1"%> width: 50%; } - tr.entry{ - cursor: pointer; - } - .table{ background-color: #E9EAEB; } @@ -43,10 +39,11 @@ pageEncoding="ISO-8859-1"%> } div.displayDevice{ - overflow: visible; padding-right: 30px; margin-bottom: 30px; + overflow: hidden; height: auto; + width: auto; } From 8c76ed6c208d3025de3f5b8c773b564877431695 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 23 Apr 2017 20:27:35 -0400 Subject: [PATCH 4/6] Loading GIF added into a form. Experimental! Gonna see how I feel about this. --- WebContent/html/imgs/loader.gif | Bin 0 -> 1849 bytes WebContent/html/webpages/shoppingCart.jsp | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 WebContent/html/imgs/loader.gif diff --git a/WebContent/html/imgs/loader.gif b/WebContent/html/imgs/loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..9bfca92b9ae82a3b7c31ac9a259cc1e34ea0db06 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`ZP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>|Ir1RyPr=t6=o)G)nn^|Cu5#S)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAE}xSi~s-t literal 0 HcmV?d00001 diff --git a/WebContent/html/webpages/shoppingCart.jsp b/WebContent/html/webpages/shoppingCart.jsp index bc0d203..1c3e84a 100644 --- a/WebContent/html/webpages/shoppingCart.jsp +++ b/WebContent/html/webpages/shoppingCart.jsp @@ -174,7 +174,7 @@ pageEncoding="ISO-8859-1"%> - + @@ -453,6 +453,8 @@ function forceUpdateLocationMetadata() { // This is called just before order form is submitted. In order for any database activity to occur, // we must first append the employees ID as well as the ids of whatever devices are selected. + document.getElementById("load").style.visibility = 'visible'; + // First, employee id userID=getUserID(); document.orderForm.userID.value=userID; From bad76543f34cbea8c558b59932d98a612d2379ec Mon Sep 17 00:00:00 2001 From: Adam R Claxton Date: Sun, 23 Apr 2017 23:03:16 -0400 Subject: [PATCH 5/6] Admin add/removal update from meagan --- .../webpages/administration/adminThings.jsp | 75 ++++++ .../webpages/administration/approveAdmin.jsp | 240 ++++++++++++++++++ src/database/AdminQuery.java | 152 +++++++++++ 3 files changed, 467 insertions(+) create mode 100644 WebContent/html/webpages/administration/adminThings.jsp create mode 100644 WebContent/html/webpages/administration/approveAdmin.jsp create mode 100644 src/database/AdminQuery.java diff --git a/WebContent/html/webpages/administration/adminThings.jsp b/WebContent/html/webpages/administration/adminThings.jsp new file mode 100644 index 0000000..587e09a --- /dev/null +++ b/WebContent/html/webpages/administration/adminThings.jsp @@ -0,0 +1,75 @@ + + +<%@ page import = "database.*,entities.*" %> +<%@ page import = "java.util.Random" %> +<%@ page import = "database.*" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> +<%@ page import = "java.sql.*" %> +<%@ page import = "java.security.MessageDigest" %> +<%@ page import = "java.security.NoSuchAlgorithmException" %> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/administration/approveAdmin.jsp b/WebContent/html/webpages/administration/approveAdmin.jsp new file mode 100644 index 0000000..8c67fd7 --- /dev/null +++ b/WebContent/html/webpages/administration/approveAdmin.jsp @@ -0,0 +1,240 @@ +<%@ page import="database.*,entities.*"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + + + + + + + + +Synchrony Financial + + + + + + + + + + + + + + +
+ + + + + + + + +
NameSSOFinger Print
+ + +
+ + + +