From 7b24880986702465b25890e6cbf4953ac0597a6d Mon Sep 17 00:00:00 2001 From: Adam R Claxton Date: Fri, 31 Mar 2017 20:16:54 -0400 Subject: [PATCH] So much refactoring MySQLAccess is now split up into many smaller classes in the database package, and I updated all MySQLAccess references to the appropriate new class. Killed navbar.js. All .html pages are now .jsp pages so that they can <%@include file navbar.html%> --- WebContent/adminLogin.jsp | 6 +- WebContent/html/javascript/listing.jsp | 5 +- WebContent/html/javascript/navbar.js | 2 - WebContent/html/javascript/request.jsp | 5 +- .../html/webpages/{admin.html => admin.jsp} | 178 +++++----- .../{adminApprove.html => adminApprove.jsp} | 164 ++++----- WebContent/html/webpages/adminLocation.jsp | 9 +- WebContent/html/webpages/index.jsp | 2 +- WebContent/html/webpages/listingPage.jsp | 2 +- WebContent/html/webpages/locationRedirect.jsp | 11 +- .../html/webpages/{map.html => map.jsp} | 176 +++++----- WebContent/html/webpages/navbar.html | 2 +- WebContent/html/webpages/orderFormHandler.jsp | 10 +- ...ofileSettings.html => profileSettings.jsp} | 249 +++++++------- WebContent/html/webpages/requestPage.jsp | 2 +- WebContent/html/webpages/returnComplete.jsp | 8 +- WebContent/html/webpages/returnPage.jsp | 9 +- WebContent/html/webpages/shoppingCart.jsp | 8 +- WebContent/index.jsp | 2 +- WebContent/userLogin.jsp | 4 +- src/database/DeviceQueries.java | 82 +++++ src/database/EmployeeQueries.java | 51 +++ src/database/LocationQueries.java | 142 ++++++++ src/database/MySQLAccess.java | 315 +----------------- src/database/TicketQueries.java | 30 ++ 25 files changed, 736 insertions(+), 738 deletions(-) delete mode 100644 WebContent/html/javascript/navbar.js rename WebContent/html/webpages/{admin.html => admin.jsp} (93%) rename WebContent/html/webpages/{adminApprove.html => adminApprove.jsp} (93%) rename WebContent/html/webpages/{map.html => map.jsp} (95%) rename WebContent/html/webpages/{profileSettings.html => profileSettings.jsp} (97%) create mode 100644 src/database/DeviceQueries.java create mode 100644 src/database/EmployeeQueries.java create mode 100644 src/database/LocationQueries.java create mode 100644 src/database/TicketQueries.java diff --git a/WebContent/adminLogin.jsp b/WebContent/adminLogin.jsp index ffd6dc8..de40b3c 100644 --- a/WebContent/adminLogin.jsp +++ b/WebContent/adminLogin.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess" %> +<%@ page import = "database.*" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import = "java.sql.*" %> @@ -9,7 +9,7 @@ Cookie adminCookie; ssoNum = Integer.parseInt(request.getParameter("ssoNum2")); pass = request.getParameter("pass"); MySQLAccess myaccess = new MySQLAccess(); -Statement statement = myaccess.connectDB(); +Statement statement = myaccess.getStatement(); ResultSet result; result = statement.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + pass + "'"); @@ -20,7 +20,7 @@ if (result.next()){ adminCookie.setMaxAge(30*60); response.addCookie(adminCookie); statement.close(); - response.sendRedirect("html/webpages/admin.html"); + response.sendRedirect("html/webpages/admin.jsp"); } else { statement.close(); response.sendRedirect("index.jsp"); diff --git a/WebContent/html/javascript/listing.jsp b/WebContent/html/javascript/listing.jsp index 64ca8fc..cdf42d7 100644 --- a/WebContent/html/javascript/listing.jsp +++ b/WebContent/html/javascript/listing.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.ListedDevice" %> +<%@ page import = "database.*,entities.ListedDevice" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -8,8 +8,7 @@ <% -MySQLAccess myaccess = new MySQLAccess(); -ListedDevice[] mydevices = myaccess.getAllDevices(); +ListedDevice[] mydevices = DeviceQueries.getAllDevices(); //string representation of array. String deviceString = ListedDevice.arrayToString(mydevices); diff --git a/WebContent/html/javascript/navbar.js b/WebContent/html/javascript/navbar.js deleted file mode 100644 index 07b0906..0000000 --- a/WebContent/html/javascript/navbar.js +++ /dev/null @@ -1,2 +0,0 @@ -document.getElementById('navbaruniversal').innerHTML = '
' - diff --git a/WebContent/html/javascript/request.jsp b/WebContent/html/javascript/request.jsp index b1cca96..086c24f 100644 --- a/WebContent/html/javascript/request.jsp +++ b/WebContent/html/javascript/request.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.ListedDevice" %> +<%@ page import = "database.*,entities.ListedDevice" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -8,8 +8,7 @@ <% -MySQLAccess myaccess = new MySQLAccess(); -ListedDevice[] mydevices = myaccess.getAllDevices(); +ListedDevice[] mydevices = DeviceQueries.getAllDevices(); //string representation of array. String deviceString = ListedDevice.arrayToString(mydevices); diff --git a/WebContent/html/webpages/admin.html b/WebContent/html/webpages/admin.jsp similarity index 93% rename from WebContent/html/webpages/admin.html rename to WebContent/html/webpages/admin.jsp index 312348b..d3992f8 100644 --- a/WebContent/html/webpages/admin.html +++ b/WebContent/html/webpages/admin.jsp @@ -1,90 +1,90 @@ - - - - - - - - - -Synchrony Financial - - - - - - - - - - - - - -
-

Welcome to the admin page

-
-
- - - - - - + + + + + + + + + +Synchrony Financial + + + + + + + + + + + + + +
+

Welcome to the admin page

+
+
+ + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/adminApprove.html b/WebContent/html/webpages/adminApprove.jsp similarity index 93% rename from WebContent/html/webpages/adminApprove.html rename to WebContent/html/webpages/adminApprove.jsp index f73865e..3efebf8 100644 --- a/WebContent/html/webpages/adminApprove.html +++ b/WebContent/html/webpages/adminApprove.jsp @@ -1,83 +1,83 @@ - - - - - - - - - - Synchrony Financial - - - - - - - - - - - - -
-

Admin View Approvals

-
-
- -
-

Approved!

-
- - - - + + + + + + + + + + Synchrony Financial + + + + + + + + + + + + +
+

Admin View Approvals

+
+
+ +
+

Approved!

+
+ + + \ No newline at end of file diff --git a/WebContent/html/webpages/adminLocation.jsp b/WebContent/html/webpages/adminLocation.jsp index 573f6aa..b9a4a45 100644 --- a/WebContent/html/webpages/adminLocation.jsp +++ b/WebContent/html/webpages/adminLocation.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.Location" %> +<%@ page import = "database.*,entities.Location" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -92,6 +92,7 @@ @@ -308,10 +309,9 @@ <% -//database connection -MySQLAccess myaccess = new MySQLAccess(); + //database query -Location[] locations = myaccess.getAdminLocations(); +Location[] locations = LocationQueries.getAdminLocations(); //string representation of array. String locationString = Location.arrayToString(locations); locationString = locationString.replace("'","\\'"); @@ -384,6 +384,5 @@ function closeModifyModal(){ - \ No newline at end of file diff --git a/WebContent/html/webpages/index.jsp b/WebContent/html/webpages/index.jsp index e31fe6f..0f23040 100644 --- a/WebContent/html/webpages/index.jsp +++ b/WebContent/html/webpages/index.jsp @@ -67,7 +67,7 @@

Just curious to see what devices we have to offer? You've come to the right place.

- + diff --git a/WebContent/html/webpages/orderFormHandler.jsp b/WebContent/html/webpages/orderFormHandler.jsp index aee91c6..1f13065 100644 --- a/WebContent/html/webpages/orderFormHandler.jsp +++ b/WebContent/html/webpages/orderFormHandler.jsp @@ -1,5 +1,4 @@ - -<%@ page import = "database.MySQLAccess" %> +<%@ page import = "database.*" %> <%@ page import = "entities.User" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -11,7 +10,6 @@ pageEncoding="ISO-8859-1"%> - - - - - - - - - - - - - - - - - - - - - -
-
- -
- -
-
-

Change profile image:

-
-
- -
-

Profile Settings

-
- - - -
-
- - - -
-
- - -
-
- - -
- -
-
- - - - - - + + + + + + + + + + Synchrony Financial + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+
+

Change profile image:

+
+
+ +
+

Profile Settings

+
+ + + +
+
+ + + +
+
+ + +
+
+ + +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/WebContent/html/webpages/requestPage.jsp b/WebContent/html/webpages/requestPage.jsp index d9f010f..e6d30e3 100644 --- a/WebContent/html/webpages/requestPage.jsp +++ b/WebContent/html/webpages/requestPage.jsp @@ -62,6 +62,7 @@ <%@ include file="../javascript/request.jsp" %> - \ No newline at end of file diff --git a/WebContent/html/webpages/returnComplete.jsp b/WebContent/html/webpages/returnComplete.jsp index 08a267d..4ed52d5 100644 --- a/WebContent/html/webpages/returnComplete.jsp +++ b/WebContent/html/webpages/returnComplete.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.RentedDevice" %> +<%@ page import = "database.*,entities.RentedDevice" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -20,6 +20,7 @@ @@ -27,13 +28,10 @@

Thanks for returning some devices!

<% -//make instance -MySQLAccess myaccess = new MySQLAccess(); //get string from request form String devices = request.getParameter("devicesToReturn"); -myaccess.returnDevices(devices); +DeviceQueries.returnDevices(devices); %> - \ No newline at end of file diff --git a/WebContent/html/webpages/returnPage.jsp b/WebContent/html/webpages/returnPage.jsp index 7cf5b9f..15bdf43 100644 --- a/WebContent/html/webpages/returnPage.jsp +++ b/WebContent/html/webpages/returnPage.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.RentedDevice" %> +<%@ page import = "database.*,entities.RentedDevice" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -75,6 +75,7 @@ } @@ -125,11 +126,9 @@ <% -//database connection -MySQLAccess myaccess = new MySQLAccess(); //String userID = cookie implementation exists here. //19 is just for testing purposes. Replaced by userID later. -RentedDevice[] mydevices = myaccess.getUserDevices("19"); +RentedDevice[] mydevices = DeviceQueries.getUserDevices("19"); //string representation of array. String deviceString = RentedDevice.arrayToString(mydevices); %> @@ -272,7 +271,5 @@ function arrayToString(array){ return sb; } - - \ No newline at end of file diff --git a/WebContent/html/webpages/shoppingCart.jsp b/WebContent/html/webpages/shoppingCart.jsp index 7649ec2..49fa859 100644 --- a/WebContent/html/webpages/shoppingCart.jsp +++ b/WebContent/html/webpages/shoppingCart.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess" %> +<%@ page import = "database.*" %> <%@ page import = "entities.User" %> <%@ page import = "entities.Location" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" @@ -195,7 +195,6 @@ if(c.getName().equals("ssoNum")) sso = Integer.parseInt(c.getValue()); -