Skip to content
Snippets Groups Projects
Commit f4e93b8f authored by hkarwa2s's avatar hkarwa2s
Browse files

fix, damit die TransactionControl nicht schon bei einer Setter Methode eine Exception wirft ;)

parent f200d98d
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,11 @@ public class CheckoutView extends TemplateView {
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
this.setUp();
}
public void setUp() {
}
}
......@@ -99,6 +99,7 @@ public class WarenkorbView extends TemplateView {
TransactionControl t = new TransactionControl();
try {
t.createTransactions();
UI.getCurrent().getNavigator().navigateTo(Views.CHECKOUT);
} catch (DAOException ex) {
Logger.getLogger(WarenkorbView.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
......
......@@ -21,6 +21,10 @@ public class Transaction {
this.produkt = produkt;
}
public Transaction() {
}
public Integer getVerkaeufer() {
return verkaeufer;
}
......
......@@ -102,7 +102,6 @@ public class ProductSearch extends AbstractDatabaseClass implements ProductDAO {
return p;
}
// Noch fertig zu stellen!!!!!!!!!
@Override
public Shop getProductOwner(Product product) throws DAOException {
Shop s = new Shop();
......
......@@ -19,13 +19,17 @@ import org.s4s.services.util.Roles;
*/
public class TransactionControl extends AbstractDatabaseClass {
Transaction transaktion;
private final Transaction transaktion = new Transaction();
private final Statement statement = JDBCConnection.getInstance().getStatement();
//String kaeuferString = (String) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER);
public void createTransactions() throws DAOException, SQLException {
User u = (User) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER);
String name = u.getBenutzername();
int id = u.getUserId();
User user = new User(name, id);
transaktion.setKaeufer(user);
for (Product p : Warenkorb.getInstance().inhalt()) {
transaktion.setKaeufer((User) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER));
transaktion.setVerkaeufer(kaeuferinDB(p.getId()));
transaktion.setProdukt(p);
createTransactionInDB(transaktion);
......@@ -37,7 +41,7 @@ public class TransactionControl extends AbstractDatabaseClass {
Integer verkaeufer;
try (ResultSet rs = executeQuery("SELECT u.\"besitzer\"" + " FROM \"ERR\".\"shop\" u , \"ERR\".\"artikel\" s"
+ " WHERE u.shopid = s.shopid AND "
+ "s.artikelid'" + transaktion.getProdukt().getId() + "';");) {
+ "s.artikelid = '" + transaktion.getProdukt().getId() + "';");) {
verkaeufer = rs.getInt("besitzer");
} catch (SQLException ex) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment