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