diff --git a/WebContent/html/imgs/Tablet.png b/WebContent/html/imgs/Tablet.png new file mode 100644 index 0000000..c1011a1 Binary files /dev/null and b/WebContent/html/imgs/Tablet.png differ diff --git a/WebContent/html/imgs/ipad.png b/WebContent/html/imgs/ipad.png deleted file mode 100644 index dd56f42..0000000 Binary files a/WebContent/html/imgs/ipad.png and /dev/null differ diff --git a/WebContent/html/imgs/iphone.png b/WebContent/html/imgs/iphone.png deleted file mode 100644 index d4e9ee4..0000000 Binary files a/WebContent/html/imgs/iphone.png and /dev/null differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/license/license.pdf b/WebContent/html/imgs/my-icons-collection-devices/license/license.pdf new file mode 100644 index 0000000..bdeedb7 Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/license/license.pdf differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/Smartphone.png b/WebContent/html/imgs/my-icons-collection-devices/png/Smartphone.png new file mode 100644 index 0000000..2256dc0 Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/Smartphone.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/Tablet.png b/WebContent/html/imgs/my-icons-collection-devices/png/Tablet.png new file mode 100644 index 0000000..c1011a1 Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/Tablet.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/laptop.png b/WebContent/html/imgs/my-icons-collection-devices/png/laptop.png new file mode 100644 index 0000000..ab31afd Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/laptop.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/modem.png b/WebContent/html/imgs/my-icons-collection-devices/png/modem.png new file mode 100644 index 0000000..0c9148a Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/modem.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/music-player.png b/WebContent/html/imgs/my-icons-collection-devices/png/music-player.png new file mode 100644 index 0000000..c857d29 Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/music-player.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/photo-camera.png b/WebContent/html/imgs/my-icons-collection-devices/png/photo-camera.png new file mode 100644 index 0000000..6e2f1ee Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/photo-camera.png differ diff --git a/WebContent/html/imgs/my-icons-collection-devices/png/usb.png b/WebContent/html/imgs/my-icons-collection-devices/png/usb.png new file mode 100644 index 0000000..762071b Binary files /dev/null and b/WebContent/html/imgs/my-icons-collection-devices/png/usb.png differ diff --git a/WebContent/html/javascript/listing.jsp b/WebContent/html/javascript/listing.jsp index 456db40..5fc1d46 100644 --- a/WebContent/html/javascript/listing.jsp +++ b/WebContent/html/javascript/listing.jsp @@ -9,95 +9,81 @@ <% -/*MySQLAccess myaccess = new MySQLAccess(); +MySQLAccess myaccess = new MySQLAccess(); myaccess.connectDB(); String name = myaccess.getResult()[0][0]; String description = myaccess.getResult()[0][1]; -String hardware = myaccess.getResult()[0][2];*/ -//out.println(name); +String hardware = myaccess.getResult()[0][2]; +System.out.println(name); //out.println(description); //out.println(hardware); %> + + \ No newline at end of file diff --git a/WebContent/html/webpages/modem.png b/WebContent/html/webpages/modem.png new file mode 100644 index 0000000..0c9148a Binary files /dev/null and b/WebContent/html/webpages/modem.png differ diff --git a/WebContent/html/webpages/returnPage.html b/WebContent/html/webpages/returnPage.jsp similarity index 83% rename from WebContent/html/webpages/returnPage.html rename to WebContent/html/webpages/returnPage.jsp index 2e702d5..34db421 100644 --- a/WebContent/html/webpages/returnPage.html +++ b/WebContent/html/webpages/returnPage.jsp @@ -1,111 +1,99 @@ - - - - - - - - - Synchrony Financial - - - - - - - - - - - - -
-

Devices to Be Returned

-
- -
-
-
- - George -
-
-

Checked out: 2/15/2016

-

You've had this device for one day!

-
-
-
-

-
- -
-
-

Return Here

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

Devices to Be Returned

+
+
+ +
+
+

Return Here

+
+ <%@ include file="../javascript/return.jsp" %> + + \ No newline at end of file diff --git a/src/database/MySQLAccess.java b/src/database/MySQLAccess.java index d68d57b..147b6bf 100644 --- a/src/database/MySQLAccess.java +++ b/src/database/MySQLAccess.java @@ -29,20 +29,25 @@ public void connectDB() throws SQLException, ClassNotFoundException { } } - public RentedDevice[] getUserDevices(Connection connect, String userID) throws SQLException, ClassNotFoundException{ + public RentedDevice[] getUserDevices(String userID) throws SQLException, ClassNotFoundException{ //Not sure how to get cookie information (if that is how we choose to accomplish this...) ? But this should be a passed parameter + System.getenv("VCAP_SERVICES"); + Class.forName("com.mysql.jdbc.Driver"); + Connection connect = DriverManager.getConnection("jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317", "b372dfe7409692", "74f6e317"); Statement stmt = connect.createStatement(); - ResultSet countset = stmt.executeQuery("SELECT COUNT(*) FROM devices WHERE Renter = " + userID); - //number of devices obtained - int rows = countset.getInt(1); - ResultSet resultSet = connect.createStatement().executeQuery("SELECT Device_ID, Device_Name, Device_Description, Ticket_ID, Model_Type, Hardware_Model, Borrow_Date FROM devices WHERE Renter = " + userID); + ResultSet resultSet = stmt.executeQuery("SELECT Device_ID, Device_Name, Device_Description, Ticket_ID, Model_Type, Hardware_Model, Borrow_Date FROM devices WHERE Renter = " + userID); int counter = 0; + resultSet.last(); + int rows = resultSet.getRow(); + resultSet.beforeFirst(); + //Covers amount of rows, and 6 attributes (indices 0-5) RentedDevice[] devices = new RentedDevice[rows]; //iterate result set while(resultSet.next()){ + System.out.println(resultSet.getString("Device_Name")); devices[counter] = new RentedDevice(resultSet.getInt("Device_ID") + "",resultSet.getString("Device_Name"),resultSet.getString("Device_Description"),resultSet.getInt("Ticket_ID") + "",resultSet.getString("Model_Type"),resultSet.getString("Hardware_Model"),resultSet.getString("Borrow_Date")); counter++; } diff --git a/src/entities/RentedDevice.java b/src/entities/RentedDevice.java index 1517383..9503279 100644 --- a/src/entities/RentedDevice.java +++ b/src/entities/RentedDevice.java @@ -31,14 +31,32 @@ public RentedDevice(String id, String name, String desc, String ticketid, String public String toString(){ StringBuilder sb = new StringBuilder(); String comma = ", "; - sb.append("{id: ").append(Device_ID).append(comma); - sb.append("name: \"").append(Device_Name).append(comma); - sb.append("description: \"").append(Device_Description).append(comma); - sb.append("ticket: \"").append(Ticket_ID).append(comma); - sb.append("model: \"").append(Model_Type).append(comma); - sb.append("hardware: \"").append(Hardware_Model).append(comma); - sb.append("checkout: \"").append(Borrow_Date); - sb.append("};"); + sb.append("{\"id\": ").append(Device_ID).append(comma); + sb.append("\"name\": \"").append(Device_Name).append("\"").append(comma); + sb.append("\"description\": \"").append(Device_Description).append("\"").append(comma); + sb.append("\"ticket\": \"").append(Ticket_ID).append("\"").append(comma); + sb.append("\"model\": \"").append(Model_Type).append("\"").append(comma); + sb.append("\"hardware\": \"").append(Hardware_Model).append("\"").append(comma); + sb.append("\"checkout\": \"").append(Borrow_Date).append("\""); + sb.append("}"); + return sb.toString(); + } + + /** + * This is a static function which will turn a Rented Device array into its proper string. + * @param array + * @return + */ + public static String arrayToString(RentedDevice[] array){ + StringBuilder sb = new StringBuilder(); + sb.append("["); + for(int i = 0; i < array.length; i++){ + sb.append(array[i].toString()); + if(i+1 != array.length){ + sb.append(","); + } + } + sb.append("]"); return sb.toString(); } diff --git a/src/main/Main.java b/src/main/Main.java index 691ab9a..f6f1cfa 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -2,9 +2,6 @@ import java.util.Scanner; -import functionality_managers.ClientManager; -import functionality_managers.SystemManager; - public class Main { public static void main(String[] args) {