diff --git a/src/main/java/de/hsel/itech/db/AddressDB.java b/src/main/java/de/hsel/itech/db/AddressDB.java index d15b22f..a8799e0 100644 --- a/src/main/java/de/hsel/itech/db/AddressDB.java +++ b/src/main/java/de/hsel/itech/db/AddressDB.java @@ -26,9 +26,9 @@ public class AddressDB { } /** - * get all addresses of specified user. + * getAll all addresses of specified user. * - * @param user user to get addresses from + * @param user user to getAll addresses from * @return list of users addresses */ @Nullable @@ -54,7 +54,7 @@ public class AddressDB { } /** - * get specific address. + * getAll specific address. * * @param id address id * @return specific address diff --git a/src/main/java/de/hsel/itech/db/OrderDB.java b/src/main/java/de/hsel/itech/db/OrderDB.java index 1ad30f6..8fa651d 100644 --- a/src/main/java/de/hsel/itech/db/OrderDB.java +++ b/src/main/java/de/hsel/itech/db/OrderDB.java @@ -18,7 +18,7 @@ public class OrderDB { } @Nullable - public Order get(long id) { + private Order get(long id, @NotNull User user) { Map.Entry entry = database.getResultSetById(database.tableOrder, id); assert entry != null; @@ -30,7 +30,6 @@ public class OrderDB { while (rs.next()) { List items = getItems(id); - User user = database.user().get(rs.getLong("user")); Payment payment = database.payment().get(rs.getLong("payment"), user); Address address = database.address().get(rs.getLong("address"), user); order = new Order(id, user, items, rs.getDate("date"), rs.getLong("price"), payment, address); @@ -53,7 +52,7 @@ public class OrderDB { ResultSet rs = entry.getKey(); rs.beforeFirst(); while (rs.next()) { - list.add(get(rs.getLong("id"))); + list.add(get(rs.getLong("id"), user)); } } catch (SQLException ex) { ex.printStackTrace(); diff --git a/src/main/java/de/hsel/itech/db/PaymentDB.java b/src/main/java/de/hsel/itech/db/PaymentDB.java index d41464f..415198f 100644 --- a/src/main/java/de/hsel/itech/db/PaymentDB.java +++ b/src/main/java/de/hsel/itech/db/PaymentDB.java @@ -47,7 +47,7 @@ public class PaymentDB { } @NotNull - public List get(@NotNull User user) { + public List getAll(@NotNull User user) { List list = new ArrayList<>(); Map.Entry entry = database.getResultSetByValue(database.tableUserPayment, "user", user.getId()); if(entry == null) return list; @@ -55,7 +55,6 @@ public class PaymentDB { try { ResultSet rs = entry.getKey(); rs.beforeFirst(); - System.out.println(user); while(rs.next()) { list.add(get(rs.getLong("id"), user)); } @@ -64,7 +63,6 @@ public class PaymentDB { } catch (SQLException e) { e.printStackTrace(); } - return list; } @@ -73,8 +71,6 @@ public class PaymentDB { Map.Entry metadata = getMetadata(id); assert metadata != null; - System.out.println(user); - switch (metadata.getValue().getName()) { case "PayPal": return getPayPal(id, user); diff --git a/src/main/java/de/hsel/itech/db/ShoppingCartDB.java b/src/main/java/de/hsel/itech/db/ShoppingCartDB.java index 78775dc..17c538d 100644 --- a/src/main/java/de/hsel/itech/db/ShoppingCartDB.java +++ b/src/main/java/de/hsel/itech/db/ShoppingCartDB.java @@ -28,9 +28,9 @@ public class ShoppingCartDB { } /** - * get all items from users shopping cart. + * getAll all items from users shopping cart. * - * @param user which users shopping cart to get. + * @param user which users shopping cart to getAll. * @return list of shopping cart items. */ @NotNull diff --git a/src/main/java/de/hsel/itech/db/pojo/Order.java b/src/main/java/de/hsel/itech/db/pojo/Order.java index 52a26c0..5fa6b3f 100644 --- a/src/main/java/de/hsel/itech/db/pojo/Order.java +++ b/src/main/java/de/hsel/itech/db/pojo/Order.java @@ -34,12 +34,12 @@ public class Order { @NonNull private Payment payment; @NonNull private Address address; - public List getItemNames() { + public String getItemNames() { List titles = new ArrayList<>(); for(OrderItem item : items) { titles.add(item.getBook().getTitle()); } - return titles; + return String.join(", ", titles); } } \ No newline at end of file diff --git a/src/main/java/de/hsel/itech/jsf/OrderBean.java b/src/main/java/de/hsel/itech/jsf/OrderBean.java index 9546222..c2dba39 100644 --- a/src/main/java/de/hsel/itech/jsf/OrderBean.java +++ b/src/main/java/de/hsel/itech/jsf/OrderBean.java @@ -25,7 +25,6 @@ public class OrderBean { } public List getOrders() { - System.out.println(getUser()); return Database.getInstance().order().getAll(getUser()); } } \ No newline at end of file diff --git a/src/main/java/de/hsel/itech/jsf/PaymentBean.java b/src/main/java/de/hsel/itech/jsf/PaymentBean.java index 9f297ab..ec731c9 100644 --- a/src/main/java/de/hsel/itech/jsf/PaymentBean.java +++ b/src/main/java/de/hsel/itech/jsf/PaymentBean.java @@ -30,7 +30,7 @@ public class PaymentBean { public List getCreditCard() { List list = new ArrayList<>(); - for(Payment payment : Database.getInstance().payment().get(getUser())) { + for(Payment payment : Database.getInstance().payment().getAll(getUser())) { if(payment instanceof CreditCardPayment) list.add((CreditCardPayment) payment); } @@ -39,7 +39,7 @@ public class PaymentBean { public List getDebitCard() { List list = new ArrayList<>(); - for(Payment payment : Database.getInstance().payment().get(getUser())) { + for(Payment payment : Database.getInstance().payment().getAll(getUser())) { if(payment instanceof DebitCardPayment) list.add((DebitCardPayment) payment); } @@ -48,7 +48,7 @@ public class PaymentBean { public List getPayPal() { List list = new ArrayList<>(); - for (Payment payment : Database.getInstance().payment().get(getUser())) { + for (Payment payment : Database.getInstance().payment().getAll(getUser())) { if(payment instanceof PayPalPayment) list.add((PayPalPayment) payment); } @@ -57,7 +57,7 @@ public class PaymentBean { public List getInvoice() { List list = new ArrayList<>(); - for(Payment payment : Database.getInstance().payment().get(getUser())) { + for(Payment payment : Database.getInstance().payment().getAll(getUser())) { if(payment instanceof InvoicePayment) list.add((InvoicePayment) payment); } diff --git a/src/main/webapp/orders.xhtml b/src/main/webapp/orders.xhtml index 9016bd6..792f6df 100644 --- a/src/main/webapp/orders.xhtml +++ b/src/main/webapp/orders.xhtml @@ -15,6 +15,7 @@
#{order.itemNames} + #{order.payment.type.name}