ordering process done
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
88145df721
commit
6d6a1c9b2a
7
pom.xml
7
pom.xml
|
@ -180,13 +180,6 @@
|
|||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- other -->
|
||||
<dependency>
|
||||
<groupId>javaee</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,10 @@ public class AuthorDB {
|
|||
ResultSet rs = entry.getKey();
|
||||
Author author = null;
|
||||
try {
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
author = new Author(rs.getLong("id"), rs.getString("name"));
|
||||
}
|
||||
entry.getValue().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -35,6 +35,11 @@ public class BookDB {
|
|||
public Book get(long id) {
|
||||
Map.Entry<ResultSet, Connection> entry = database.getResultSetById(database.tableBook, id);
|
||||
assert entry != null;
|
||||
try {
|
||||
entry.getKey().beforeFirst();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return build(entry);
|
||||
}
|
||||
|
||||
|
@ -50,6 +55,8 @@ public class BookDB {
|
|||
Book book = null;
|
||||
ResultSet rs = entry.getKey();
|
||||
try {
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
Category category = database.category().get(rs.getLong(database.tableCategory));
|
||||
Publisher publisher = database.publisher().get(rs.getLong(database.tablePublisher));
|
||||
List<Integer> authorIds = database.author().getAll(rs.getLong("id"));
|
||||
|
@ -66,6 +73,7 @@ public class BookDB {
|
|||
book = new Book(rs.getLong("id"), rs.getLong("isbn"), authors, publisher, category, rs.getString("title"),
|
||||
Year.of(rs.getInt("year")), rs.getInt("price"), rs.getString("description"),
|
||||
rs.getString("image"));
|
||||
}
|
||||
|
||||
entry.getValue().close();
|
||||
} catch (SQLException e) {
|
||||
|
|
|
@ -37,7 +37,10 @@ public class PublisherDB {
|
|||
ResultSet rs = entry.getKey();
|
||||
Publisher publisher = null;
|
||||
try {
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
publisher = new Publisher(rs.getLong("id"), rs.getString("name"));
|
||||
}
|
||||
entry.getValue().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
* @version 1.0
|
||||
*/
|
||||
@ManagedBean
|
||||
@RequestScoped
|
||||
@SessionScoped
|
||||
public class AddressBean implements Serializable {
|
||||
|
||||
public User getUser() {
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package de.hsel.itech.jsf;
|
||||
|
||||
import de.hsel.itech.db.Database;
|
||||
import de.hsel.itech.db.pojo.Book;
|
||||
import de.hsel.itech.db.pojo.OrderItem;
|
||||
import de.hsel.itech.db.pojo.ShoppingCartItem;
|
||||
import de.hsel.itech.db.pojo.User;
|
||||
import de.hsel.itech.db.pojo.*;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.faces.annotation.ManagedProperty;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,6 +25,16 @@ public class CartBean {
|
|||
return (User) context.getApplication().evaluateExpressionGet(context, "#{userBean.user}", User.class);
|
||||
}
|
||||
|
||||
public Payment getPayment () {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
return (Payment) context.getApplication().evaluateExpressionGet(context, "#{paymentBean.selected}", Payment.class);
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
return (Address) context.getApplication().evaluateExpressionGet(context, "#{addressBean.selected}", Address.class);
|
||||
}
|
||||
|
||||
public String add(Book book) {
|
||||
if (getUser() != null) {
|
||||
for (ShoppingCartItem item : getItems()) {
|
||||
|
@ -68,11 +76,11 @@ public class CartBean {
|
|||
for (ShoppingCartItem item : getItems()) {
|
||||
orderList.add(new OrderItem(item.getArticle(), item.getCount()));
|
||||
}
|
||||
//Database.getInstance().order().insert(new Order(getUser(),orderList, new Date(234235235),sum(),null,null));
|
||||
Database.getInstance().order().insert(new Order(getUser(), orderList, new Date(System.currentTimeMillis()), sum(), getPayment(), getAddress()));
|
||||
for (ShoppingCartItem item : getItems()) {
|
||||
Database.getInstance().shoppingCart().delete(item);
|
||||
}
|
||||
return "thanks.jsp";
|
||||
return "index.jsf";
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<ui:repeat value="#{addressBean.addressList}" var="address">
|
||||
|
||||
<h:panelGroup layout="block" styleClass="m-col-t-3">
|
||||
<h:form>
|
||||
<h:commandLink action="#{addressBean.select(address)}">
|
||||
<div class="m-block m-primary">
|
||||
#{address.name}<br/>
|
||||
|
@ -23,6 +24,7 @@
|
|||
#{address.zipCode} #{address.city}
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
</h:panelGroup>
|
||||
</ui:repeat>
|
||||
</h:panelGroup>
|
||||
|
|
|
@ -45,22 +45,22 @@
|
|||
</ui:repeat>
|
||||
|
||||
|
||||
<h:panelGroup type="block" styleClass="m-row" rendered="#{cartBean.itemCount != 0}">
|
||||
<h:panelGroup layout="block" styleClass="m-row" rendered="#{cartBean.itemCount != 0}">
|
||||
<div class="m-col-t-5 m-push-t-7">
|
||||
<h1 class="m-text-right">Summe(#{cartBean.itemCount} Items): #{cartBean.sum}€</h1>
|
||||
</div>
|
||||
</h:panelGroup>
|
||||
|
||||
<h:panelGroup type="block" styleClass="m-row" rendered="#{cartBean.itemCount == 0}">
|
||||
<h:panelGroup layout="block" styleClass="m-row" rendered="#{cartBean.itemCount == 0}">
|
||||
<h1 class="m-text-center">Der Warenkorb ist Leer</h1>
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
<div class="m-row">
|
||||
<h:panelGroup layout="block" styleClass="m-row" rendered="#{cartBean.itemCount != 0}">
|
||||
<div class="m-col-t-4 m-push-t-4 m-button m-success">
|
||||
<a href="confirmation.jsf">Jetzt Kaufen</a>
|
||||
</div>
|
||||
<a href="addressSelection.xhtml">Jetzt Kaufen</a>
|
||||
</div>
|
||||
</h:panelGroup>
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
|
|
|
@ -15,14 +15,21 @@
|
|||
<div class="m-row">
|
||||
<div class="m-col-t-3 m-block">
|
||||
<h4>Addresse:</h4>
|
||||
Max Mustermann<br/>
|
||||
Musterstraße 42<br/>
|
||||
12345 Musterstadt
|
||||
#{addressBean.selected.name}<br/>
|
||||
#{addressBean.selected.street} #{addressBean.selected.number}<br/>
|
||||
#{addressBean.selected.zipCode} #{addressBean.selected.city}
|
||||
</div>
|
||||
<div class="m-col-t-4 m-block m-push-t-5">
|
||||
<h4>Konto</h4>
|
||||
IBAN: 12345••••••••••••••••••••••••111<br/>
|
||||
Inhaber: Max Mustermann<br/>
|
||||
<h4>#{paymentBean.selected.type.name}</h4>
|
||||
<h:panelGroup layout="block" rendered="#{paymentBean.selected.type.name eq 'CreditCard'}">
|
||||
Inhaber: #{paymentBean.selected.owner}<br/>
|
||||
Nummer : #{paymentBean.selected.number} / #{paymentBean.selected.checksum}
|
||||
gültig bis: #{paymentBean.selected.expiration}
|
||||
</h:panelGroup>
|
||||
|
||||
<h:panelGroup layout="block" rendered="#{paymentBean.selected.type.name eq 'PayPal'}">
|
||||
Konto: #{paymentBean.selected.email}
|
||||
</h:panelGroup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -43,7 +50,7 @@
|
|||
</ui:repeat>
|
||||
|
||||
|
||||
<h:panelGroup type="block" styleClass="m-row">
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<div class="m-col-t-5 m-push-t-7">
|
||||
<h1 class="m-text-right">Summe: #{cartBean.sum}€</h1>
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<h3 class="m-text-center m-text m-small">Kreditkarte</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.creditCard}" var="payment">
|
||||
<h:form>
|
||||
<h:commandLink action="#{paymentBean.select(payment)}">
|
||||
<div class="m-col-t-3">
|
||||
<div class="m-block m-primary">
|
||||
|
@ -29,6 +30,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
</ui:repeat>
|
||||
|
||||
</h:panelGroup>
|
||||
|
@ -37,6 +39,7 @@
|
|||
<h3 class="m-text-center m-text m-small">PayPal</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.payPal}" var="payment">
|
||||
<h:form>
|
||||
<h:commandLink action="#{paymentBean.select(payment)}">
|
||||
<div class="m-col-t-3">
|
||||
<div class="m-block m-primary">
|
||||
|
@ -44,6 +47,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</h:form>
|
||||
</ui:repeat>
|
||||
|
||||
</h:panelGroup>
|
||||
|
|
Loading…
Reference in New Issue