diff --git a/nbactions.xml b/nbactions.xml index 921ab9ca91e096cfca383820a1770330732b1e62..86d7b89b28a64f420183051a9c85fe901b4369b1 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -11,4 +11,26 @@ <goal>jetty:run</goal> </goals> </action> + <action> + <actionName>debug</actionName> + <packagings> + <packaging>war</packaging> + <packaging>ear</packaging> + <packaging>ejb</packaging> + </packagings> + <goals> + <goal>jetty:run</goal> + </goals> + <properties> + <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode> + <jpda.listen>maven</jpda.listen> + </properties> + </action> + <action> + <actionName>CUSTOM-Sonarqube</actionName> + <displayName>Sonarqube</displayName> + <goals> + <goal>sonar:sonar</goal> + </goals> + </action> </actions> diff --git a/pom.xml b/pom.xml index 50a896db84d4ff46d7b197824ade182793aa4afc..b36bf668f977903b00a839dcd3221453cddf1a32 100644 --- a/pom.xml +++ b/pom.xml @@ -113,11 +113,11 @@ <version>1.3</version> <scope>test</scope> </dependency> - <dependency> + <!-- <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>LATEST</version> - </dependency> + </dependency>--> diff --git a/src/main/java/org/s4s/dao/KundenDAO.java b/src/main/java/org/s4s/dao/KundenDAO.java index 7470823a8a09601581eeb4a0c36ca80857782a50..1e9085f0fe41e63e0e689801ebbd1116921afc89 100644 --- a/src/main/java/org/s4s/dao/KundenDAO.java +++ b/src/main/java/org/s4s/dao/KundenDAO.java @@ -1,12 +1,7 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.dao; -import org.s4s.exceptions.NoSuchUserOrPassword; import org.s4s.exceptions.DAOException; +import org.s4s.exceptions.NoSuchUserOrPassword; import org.s4s.modell.dto.User; /** diff --git a/src/main/java/org/s4s/dao/ProductDAO.java b/src/main/java/org/s4s/dao/ProductDAO.java index b98d26fdff2c5beeda20baac2de9b159ba833c23..1c95fa3109cb15378771214175d718f438754355 100644 --- a/src/main/java/org/s4s/dao/ProductDAO.java +++ b/src/main/java/org/s4s/dao/ProductDAO.java @@ -1,12 +1,7 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.dao; -import org.s4s.exceptions.DAOException; import java.util.List; +import org.s4s.exceptions.DAOException; import org.s4s.modell.dto.Product; /** @@ -15,7 +10,9 @@ import org.s4s.modell.dto.Product; */ public interface ProductDAO { - List<Product> getProductByTyp(String typ) throws DAOException; + List<Product> getProductByName(String typ) throws DAOException; List<Product> getProductByDescription(String typ) throws DAOException; + + Product getProductById(int id) throws DAOException; } diff --git a/src/main/java/org/s4s/dao/ShopDAO.java b/src/main/java/org/s4s/dao/ShopDAO.java index 252742ee951eaa595da644830e7e637935c425a0..ea5d10b659dabdf95c5dc1c934d16cf2e2ed5905 100644 --- a/src/main/java/org/s4s/dao/ShopDAO.java +++ b/src/main/java/org/s4s/dao/ShopDAO.java @@ -1,66 +1,14 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.dao; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.logging.Level; -import java.util.logging.Logger; import org.s4s.modell.dto.User; -import org.s4s.services.db.JDBCConnection; /** * * @author Benjamin */ -public class ShopDAO { - public static ShopDAO dao = null; - private final Statement statement = JDBCConnection.getInstance().getStatement(); - private ShopDAO() { - - } +public interface ShopDAO { - public static ShopDAO getInstance() { - if (dao == null) { - dao = new ShopDAO(); - } - return dao; - } - - //Shop anhand von User/Besitzer auslesen - public boolean viewShop (User user) { - boolean result = true; - try { - ResultSet set = statement.executeQuery("SELECT *" - + "FROM ERR.shop" - + "WHERE besitzer = \'" + user.getBenutzername() + "\'"); + boolean viewShop(User user); - if (set != null) { - result = false; - } - } catch (SQLException ex) { - Logger.getLogger(ShopDAO.class.getName()).log(Level.SEVERE, null, ex); - } - return result; - } - - public boolean addShop (User user, String shopName, String shopDescription) { - //Shop via Benutzername anlegen da dieser idR eindeutig ist - try { - // vorausgesetzt ID wird automatisch gesetzt von der DB - statement.execute("INSERT INTO ERR.shop (name, besitzer, beschreibung) VALUES (" - + shopName + "," - + user.getBenutzername() + "," - + shopDescription + ");"); - return true; - } catch (SQLException ex) { - Logger.getLogger(ShopDAO.class.getName()).log(Level.SEVERE, null, ex); - return false; - } - - } + boolean addShop(User user, String shopName); } diff --git a/src/main/java/org/s4s/dao/ShopSearchDAO.java b/src/main/java/org/s4s/dao/ShopSearchDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..d9d5b7972772e1c2cd878f37fe326a4ec203cc12 --- /dev/null +++ b/src/main/java/org/s4s/dao/ShopSearchDAO.java @@ -0,0 +1,16 @@ +package org.s4s.dao; + +import java.util.List; +import org.s4s.exceptions.DAOException; +import org.s4s.modell.dto.Shop; + +/** + * + * @author Holger + */ +public interface ShopSearchDAO { + + List<Shop> getShopByName(String typ) throws DAOException; + + List<Shop> getShopByOwner(String typ) throws DAOException; +} diff --git a/src/main/java/org/s4s/dao/impl/AbstractDatabaseClass.java b/src/main/java/org/s4s/dao/impl/AbstractDatabaseClass.java index 8f2a8bfa88ec00086b2cef2bf11e4ac288d66adc..6b80843ae3d25d13beab6f24e4660ea1f358c746 100644 --- a/src/main/java/org/s4s/dao/impl/AbstractDatabaseClass.java +++ b/src/main/java/org/s4s/dao/impl/AbstractDatabaseClass.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.dao.impl; import java.sql.ResultSet; @@ -28,12 +23,11 @@ public abstract class AbstractDatabaseClass { stat.closeOnCompletion(); return set; } - + /*protected int executeUpdate(String sql) throws SQLException { Statement stat = conn.getStatement(); int set = stat.executeUpdate(sql); stat.closeOnCompletion(); return set; }*/ - } diff --git a/src/main/java/org/s4s/dao/impl/LogoutControl.java b/src/main/java/org/s4s/dao/impl/LogoutControl.java deleted file mode 100644 index d19e710fa2553d676dc537fff089b1cfa35debad..0000000000000000000000000000000000000000 --- a/src/main/java/org/s4s/dao/impl/LogoutControl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.dao.impl; - -import com.vaadin.server.VaadinSession; -import com.vaadin.ui.UI; - -/** - * - * @author Sebastian - */ -public class LogoutControl { - private void logout() { - VaadinSession session = UI.getCurrent().getSession(); - session.close(); - } - -} diff --git a/src/main/java/org/s4s/dao/impl/ShopControl.java b/src/main/java/org/s4s/dao/impl/ShopControl.java deleted file mode 100644 index 86bac45639bd0eda2908da6f80af098631ebc4c3..0000000000000000000000000000000000000000 --- a/src/main/java/org/s4s/dao/impl/ShopControl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.dao.impl; - -import com.vaadin.server.VaadinSession; -import com.vaadin.ui.UI; -import java.sql.SQLException; -import org.s4s.dao.ShopDAO; -import org.s4s.services.util.Roles; -import org.s4s.exceptions.OwnsAlreadyShop; -import org.s4s.modell.dto.User; -import org.s4s.services.util.Views; - -/** - * - * @author Benjamin - */ -public class ShopControl { - private static final User user = (User) VaadinSession.getCurrent().getAttribute(Roles.CURRENTUSER); - - //bekommt User aus der View übergeben und prüft ob dieser schon in der Shopdb vorhanden ist (= hat schon einen Shop). - public static void checkUserShop( String shopName, String shopBeschreibung) throws OwnsAlreadyShop, SQLException { - boolean test = ShopDAO.getInstance().viewShop(user); - //Shop mit dem Nutzer schon vorhanden - if (test == false) { - throw new OwnsAlreadyShop("Sie besitzen bereits einen Shop!"); - } //noch kein Shop vorhanden - else { - addUserShop(shopName, shopBeschreibung); - } - } - - private static void addUserShop(String shopName, String shopBeschreibung) throws SQLException { - boolean erstellung = ShopDAO.getInstance().addShop(user, shopName, shopBeschreibung); - - if (erstellung == true){ - //Weiterleitung zur Shopseite, wenn Shop erfolgreich erstellt - UI.getCurrent().getNavigator().navigateTo(Views.SHOP); - } else { - //Fehlerhandling - throw new SQLException("Fehler beim Anlegen des Shops bitte noch einmal versuchen oder Programmierer kontaktieren!"); - } - } -} diff --git a/src/main/java/org/s4s/exceptions/DAOException.java b/src/main/java/org/s4s/exceptions/DAOException.java index c5665929a2b02d0ae2d4747eda1eabf256fa4f37..32721078faaa1db0341550472cfa6b561c496dfc 100644 --- a/src/main/java/org/s4s/exceptions/DAOException.java +++ b/src/main/java/org/s4s/exceptions/DAOException.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.exceptions; /** diff --git a/src/main/java/org/s4s/exceptions/NoSuchProduct.java b/src/main/java/org/s4s/exceptions/NoSuchProduct.java index dbb9a78c298809923de08977a23fe189d0924d95..3abdd896a5e945984e9188695bf31930f68b7b4d 100644 --- a/src/main/java/org/s4s/exceptions/NoSuchProduct.java +++ b/src/main/java/org/s4s/exceptions/NoSuchProduct.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.exceptions; /** diff --git a/src/main/java/org/s4s/exceptions/NoSuchUserOrPassword.java b/src/main/java/org/s4s/exceptions/NoSuchUserOrPassword.java index b0a77e638b2663bf037f1c174f40a4068ff0312a..631dae37700e6f473368d5d2d32118e048129a39 100644 --- a/src/main/java/org/s4s/exceptions/NoSuchUserOrPassword.java +++ b/src/main/java/org/s4s/exceptions/NoSuchUserOrPassword.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.exceptions; /** diff --git a/src/main/java/org/s4s/exceptions/OwnsAlreadyShop.java b/src/main/java/org/s4s/exceptions/OwnsAlreadyShop.java index e7ea93de0b5d8f0ecb611f6f3457ac5272946b91..be7f3daadbfdf36d16e9537d4577e7635893fef0 100644 --- a/src/main/java/org/s4s/exceptions/OwnsAlreadyShop.java +++ b/src/main/java/org/s4s/exceptions/OwnsAlreadyShop.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.exceptions; /** @@ -20,9 +15,9 @@ public class OwnsAlreadyShop extends Exception { public void setReason(String reason) { this.reason = reason; } - - public OwnsAlreadyShop (String reason) { + + public OwnsAlreadyShop(String reason) { this.reason = reason; } - + } diff --git a/src/main/java/org/s4s/exceptions/WrongInputException.java b/src/main/java/org/s4s/exceptions/WrongInputException.java index 21646e16139436662a52f472d9b6e4750ce0c226..fe5857e1c52231f3068016c5c49e76d3bc7f4720 100644 --- a/src/main/java/org/s4s/exceptions/WrongInputException.java +++ b/src/main/java/org/s4s/exceptions/WrongInputException.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.exceptions; /** @@ -10,8 +5,9 @@ package org.s4s.exceptions; * @author Simon */ public class WrongInputException extends Exception { + String reason = null; - + public String getReason() { return reason; } @@ -19,6 +15,7 @@ public class WrongInputException extends Exception { public void setReason(String reason) { this.reason = reason; } + public WrongInputException(String reason) { this.reason = reason; } diff --git a/src/main/java/org/s4s/gui/InitView.java b/src/main/java/org/s4s/gui/InitView.java index 71f695a96c42ba598df5464e8c202280697b77a0..ca28a8b136b822410a4ef27c909df3e8cfa07f65 100644 --- a/src/main/java/org/s4s/gui/InitView.java +++ b/src/main/java/org/s4s/gui/InitView.java @@ -27,7 +27,7 @@ public class InitView extends UI { @Override protected void init(VaadinRequest vaadinRequest) { Navigator navi = new Navigator(this, this); - navi.addView(Views.SHOP, ShopView.class); + navi.addView(Views.SUCHE, SucheView.class); navi.addView(Views.WELCOME, WelcomeView.class); navi.addView(Views.LOGIN, LoginView.class); navi.addView(Views.WARENKORB, WarenkorbView.class); @@ -47,8 +47,8 @@ public class InitView extends UI { navi.addView(Views.KONTAKTBESTAETIGUNG, Kontaktbestaetigung.class); //Test der RegistrierungsView UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); - setHeight(100f,Unit.PERCENTAGE); - setWidth(100f,Unit.PERCENTAGE); + setHeight(100f, Unit.PERCENTAGE); + setWidth(100f, Unit.PERCENTAGE); //UI.getCurrent().getNavigator().navigateTo(Views.REGISTRIERUNG); //this.setWidth(64f, Unit.PERCENTAGE); diff --git a/src/main/java/org/s4s/gui/views/ArtikeldetailsView.java b/src/main/java/org/s4s/gui/views/ArtikeldetailsView.java index 6ec1e3caf79b8057d540b75ebcdf9e56acde352c..99d0064ec28c972ce34746d7a63c5d312b314cbb 100644 --- a/src/main/java/org/s4s/gui/views/ArtikeldetailsView.java +++ b/src/main/java/org/s4s/gui/views/ArtikeldetailsView.java @@ -1,24 +1,60 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Panel; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.s4s.dao.ProductDAO; +import org.s4s.exceptions.DAOException; +import org.s4s.modell.dto.Product; +import org.s4s.process.control.ProductSearch; +import org.s4s.services.util.Views; /** * * @author Holger */ -public class ArtikeldetailsView extends TemplateView{ +public class ArtikeldetailsView extends TemplateView { + + private Product product = new Product(); + private final ProductDAO products = ProductSearch.getInstance(); + private VerticalLayout verticalLayout = new VerticalLayout(); @Override public void enter(ViewChangeListener.ViewChangeEvent event) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (event.getParameters() != null) { + // split at "/", add each part as a label + String str = event.getParameters(); + int id = Integer.parseInt(str); + + this.setUp(id); + } else { + Notification.show(null, "Kein Artikel ausgewählt!", Notification.Type.HUMANIZED_MESSAGE); + UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); + } } - + public void setUp(int id) { + getInformation(id); + super.setUpFooterAndHeader(verticalLayout); + } + + private void getInformation(int id) { + try { + product = products.getProductById(id); + HorizontalLayout horizontalLayout = new HorizontalLayout(); + Panel p = new Panel("Name: " + product.getName()); + horizontalLayout.addComponent(p); + horizontalLayout.setComponentAlignment(p, Alignment.MIDDLE_LEFT); + verticalLayout.addComponent(horizontalLayout); + this.addComponent(verticalLayout); + } catch (DAOException ex) { + Logger.getLogger(ArtikeldetailsView.class.getName()).log(Level.SEVERE, null, ex); + } + } } diff --git a/src/main/java/org/s4s/gui/views/BenutzerkontoView.java b/src/main/java/org/s4s/gui/views/BenutzerkontoView.java index b1883a79ad3e013262c85570bfc02465c2d39384..a79010eeb7d48c03c9f4a6d2fbe6f25f200c5fe8 100644 --- a/src/main/java/org/s4s/gui/views/BenutzerkontoView.java +++ b/src/main/java/org/s4s/gui/views/BenutzerkontoView.java @@ -1,23 +1,16 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.VerticalLayout; /** * * @author Holger */ -public class BenutzerkontoView extends TemplateView{ +public class BenutzerkontoView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - + } diff --git a/src/main/java/org/s4s/gui/views/CheckoutView.java b/src/main/java/org/s4s/gui/views/CheckoutView.java index fed2aa2dd585b70a95195825b0aa5af1bdf70cef..46e4b14438a65d8bc708f8e8ed9a437173d61f11 100644 --- a/src/main/java/org/s4s/gui/views/CheckoutView.java +++ b/src/main/java/org/s4s/gui/views/CheckoutView.java @@ -1,23 +1,16 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.VerticalLayout; /** * * @author Holger */ -public class CheckoutView extends TemplateView{ +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. } - + } diff --git a/src/main/java/org/s4s/gui/views/ContactView.java b/src/main/java/org/s4s/gui/views/ContactView.java index 486e59fab3f05c320fd83d8f35ffebd63c26fcf3..1edc4aad38889c3e6cd887dd7860c865622b1fa5 100644 --- a/src/main/java/org/s4s/gui/views/ContactView.java +++ b/src/main/java/org/s4s/gui/views/ContactView.java @@ -3,7 +3,6 @@ package org.s4s.gui.views; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; @@ -16,36 +15,35 @@ import org.s4s.services.util.Views; /** * Created by Max-Desktop on 16.05.2017. */ -public class ContactView extends TemplateView{ - +public class ContactView extends TemplateView { + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } - + public void setUp() { setMargin(true); - + final TextField tfEMail = new TextField("E-Mail"); final TextField tfBetreff = new TextField("Betreff"); final TextArea taNachricht = new TextArea("Ihr Anliegen"); final Button bSenden = new Button("Senden", FontAwesome.SEND); final Label lSpace = new Label(" ", ContentMode.HTML); - + VerticalLayout vLayout = new VerticalLayout(); vLayout.addComponents(tfEMail, tfBetreff, taNachricht, lSpace, bSenden); - + Panel pKontakt = new Panel("Kontakt Anfrage"); // pKontakt.addStyleName("kontakt"); //this.addComponent(pKontakt); //this.setComponentAlignment(pKontakt, Alignment.MIDDLE_CENTER); - - bSenden.addClickListener(e -> - UI.getCurrent().getNavigator().navigateTo(Views.KONTAKTBESTAETIGUNG)); - + bSenden.addClickListener(e + -> UI.getCurrent().getNavigator().navigateTo(Views.KONTAKTBESTAETIGUNG)); + pKontakt.setContent(vLayout); - + super.setUpFooterAndHeader(pKontakt); } } diff --git a/src/main/java/org/s4s/gui/views/FaqView.java b/src/main/java/org/s4s/gui/views/FaqView.java index 0089e9366a3660db8a7e9b08737cc2a662052fec..4607cbe1d1d1523698e18a9c082785a3fd61bdec 100644 --- a/src/main/java/org/s4s/gui/views/FaqView.java +++ b/src/main/java/org/s4s/gui/views/FaqView.java @@ -1,23 +1,16 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.VerticalLayout; /** * * @author Holger */ -public class FaqView extends TemplateView{ +public class FaqView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - + } diff --git a/src/main/java/org/s4s/gui/views/ImpressumView.java b/src/main/java/org/s4s/gui/views/ImpressumView.java index 16992134209629980d18c43f6284b5a799d5a65d..e39dc2ab9402bd2227f6a8db5cab63bc4ebc76d7 100644 --- a/src/main/java/org/s4s/gui/views/ImpressumView.java +++ b/src/main/java/org/s4s/gui/views/ImpressumView.java @@ -1,11 +1,5 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.ui.Alignment; import com.vaadin.ui.Label; @@ -15,14 +9,14 @@ import com.vaadin.ui.VerticalLayout; * * @author Holger */ -public class ImpressumView extends TemplateView{ +public class ImpressumView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } - - private void setUp(){ + + private void setUp() { VerticalLayout vertLayout = new VerticalLayout(); vertLayout.setSizeFull(); Label label = new Label("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " @@ -34,8 +28,7 @@ public class ImpressumView extends TemplateView{ + " At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, " + "no sea takimata sanctus est Lorem ipsum dolor sit amet."); vertLayout.addComponent(label); - vertLayout.setComponentAlignment(label,Alignment.MIDDLE_CENTER); - + vertLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); super.setUpFooterAndHeader(vertLayout); diff --git a/src/main/java/org/s4s/gui/views/KaufbestaetigungView.java b/src/main/java/org/s4s/gui/views/KaufbestaetigungView.java index d23c8ff45c639730e4ca753739dd72b7fdd0d4e9..5687bec6ced3c03ef190637635974003d9b66c7e 100644 --- a/src/main/java/org/s4s/gui/views/KaufbestaetigungView.java +++ b/src/main/java/org/s4s/gui/views/KaufbestaetigungView.java @@ -1,11 +1,5 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.server.FontAwesome; import com.vaadin.ui.Button; @@ -19,7 +13,7 @@ import org.s4s.services.util.Views; * * @author JanPhilipp */ -public class KaufbestaetigungView extends TemplateView{ +public class KaufbestaetigungView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { @@ -27,26 +21,27 @@ public class KaufbestaetigungView extends TemplateView{ } private void setUp() { - Panel panel = new Panel(); + Panel panel = new Panel(); panel.setSizeUndefined(); - + VerticalLayout content = new VerticalLayout(); - + Button button = new Button("Weiter shoppen"); button.setIcon(FontAwesome.BOOK); - button.addClickListener(e -> - UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); - + button.addClickListener(e + -> UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); + Label label = new Label("Vielen Dank für ihren Einkauf! Wenn sie weitershoppen wollen... :)"); - - content.addComponent(label); - content.addComponent(button); - - content.setMargin(true); - - panel.setContent(content); - //this.addComponent(panel); - //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - - super.setUpFooterAndHeader(panel); -}} + + content.addComponent(label); + content.addComponent(button); + + content.setMargin(true); + + panel.setContent(content); + //this.addComponent(panel); + //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); + + super.setUpFooterAndHeader(panel); + } +} diff --git a/src/main/java/org/s4s/gui/views/Kontaktbestaetigung.java b/src/main/java/org/s4s/gui/views/Kontaktbestaetigung.java index 2656c044d091c88225ac27d53ff33afc62182285..d313af7980321825347d8b9bacae10a8072b468b 100644 --- a/src/main/java/org/s4s/gui/views/Kontaktbestaetigung.java +++ b/src/main/java/org/s4s/gui/views/Kontaktbestaetigung.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; import com.vaadin.navigator.ViewChangeListener; @@ -18,8 +13,8 @@ import org.s4s.services.util.Views; * @author JanPhilipp */ public class Kontaktbestaetigung extends TemplateView { - - @Override + + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } @@ -27,27 +22,24 @@ public class Kontaktbestaetigung extends TemplateView { private void setUp() { Panel panel = new Panel(); panel.setSizeUndefined(); - + VerticalLayout content = new VerticalLayout(); - + Button button = new Button("Zurück zur Startseite"); - button.addClickListener(e -> - UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); - + button.addClickListener(e + -> UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); + Label label = new Label("Vielen Dank für ihre Kontaktanfrage, Wir werden diese in Kürze beantworten und so schnell wie möglich beantworten"); - - content.addComponent(label); - content.addComponent(button); - - content.setMargin(true); - - panel.setContent(content); - //this.addComponent(panel); - //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - - super.setUpFooterAndHeader(panel); -}} - - - + content.addComponent(label); + content.addComponent(button); + + content.setMargin(true); + + panel.setContent(content); + //this.addComponent(panel); + //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); + + super.setUpFooterAndHeader(panel); + } +} diff --git a/src/main/java/org/s4s/gui/views/LoginView.java b/src/main/java/org/s4s/gui/views/LoginView.java index bfa8d4a14805a53969ef253a5a2b8933d8168154..e138fd31f405deb36d71c6c53532e740b7fa4b97 100644 --- a/src/main/java/org/s4s/gui/views/LoginView.java +++ b/src/main/java/org/s4s/gui/views/LoginView.java @@ -1,22 +1,16 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.*; - +import com.vaadin.ui.themes.ValoTheme; import java.util.logging.Level; import java.util.logging.Logger; -import org.s4s.exceptions.DAOException; import org.s4s.dao.KundenDAO; +import org.s4s.exceptions.DAOException; import org.s4s.exceptions.NoSuchUserOrPassword; -import org.s4s.dao.impl.LoginControl; +import org.s4s.process.control.LoginControl; import org.s4s.services.util.Views; /** @@ -38,8 +32,7 @@ public class LoginView extends TemplateView { final Label lblTitel = new Label("Anmelden"); titleLayout.addComponent(lblTitel); - titleLayout.setComponentAlignment(lblTitel,Alignment.MIDDLE_CENTER); - + titleLayout.setComponentAlignment(lblTitel, Alignment.MIDDLE_CENTER); final TextField userLogin = new TextField(); userLogin.setCaption("Login-Name: "); @@ -48,7 +41,7 @@ public class LoginView extends TemplateView { VerticalLayout layout = new VerticalLayout(); layout.addComponent(titleLayout); - layout.setComponentAlignment(titleLayout,Alignment.TOP_CENTER); + layout.setComponentAlignment(titleLayout, Alignment.TOP_CENTER); lblTitel.setStyleName("LoginViewContainerTitle"); titleLayout.setStyleName("LoginViewContainerTitelLayout"); layout.addComponent(userLogin); @@ -56,55 +49,66 @@ public class LoginView extends TemplateView { Label label = new Label(" ", ContentMode.HTML); layout.addComponent(label); - + HorizontalLayout hLay = new HorizontalLayout(); - + Button button = new Button("Login", FontAwesome.BEER); Button buttonReg = new Button("Registrieren", FontAwesome.BEER); + Button abbruch = new Button("Abbruch"); + abbruch.setIcon(FontAwesome.STOP_CIRCLE); + abbruch.addStyleName(ValoTheme.BUTTON_LINK); hLay.addComponent(button); Label lbl = new Label(" ", ContentMode.HTML); hLay.addComponent(lbl); hLay.addComponent(buttonReg); layout.addComponent(label); layout.addComponent(hLay); - + + VerticalLayout box = new VerticalLayout(); HorizontalLayout horSpacer = new HorizontalLayout(); horSpacer.addComponent(layout); - this.addComponent(horSpacer); - horSpacer.setComponentAlignment(layout,Alignment.MIDDLE_CENTER); - - this.setComponentAlignment(horSpacer,Alignment.MIDDLE_CENTER); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - String login = userLogin.getValue(); - String password = passwordField.getValue(); - - try { - kundenDAO.getUserByCredentials(login, password); - - } catch (NoSuchUserOrPassword ex) { - Notification.show("Fehler", "Login oder Passwort falsch", Notification.Type.ERROR_MESSAGE); - userLogin.setValue(""); - passwordField.setValue(""); - } catch (DAOException ex) { - Notification.show("Fehler", "interner Fehler", Notification.Type.ERROR_MESSAGE); - Logger.getLogger(LoginView.class.getName()).log(Level.SEVERE, null, ex); - } - // bei Erfolg wird der Navigator angesprochen und man wird in wieder zur Landingpage geführt - UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); + box.addComponent(horSpacer); + horSpacer.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); + box.setComponentAlignment(horSpacer, Alignment.MIDDLE_CENTER); + + HorizontalLayout abbruchSpacer = new HorizontalLayout(); + abbruchSpacer.addComponent(abbruch); + Label lb = new Label(" ", ContentMode.HTML); + box.addComponent(lb); + box.addComponent(abbruchSpacer); + + box.setComponentAlignment(abbruchSpacer, Alignment.MIDDLE_CENTER); + + this.addComponent(box); + this.setComponentAlignment(box, Alignment.MIDDLE_CENTER); + button.addClickListener((Button.ClickEvent event) -> { + String login = userLogin.getValue(); + String password = passwordField.getValue(); + + try { + kundenDAO.getUserByCredentials(login, password); + + } catch (NoSuchUserOrPassword ex) { + Notification.show("Fehler", "Login oder Passwort falsch", Notification.Type.ERROR_MESSAGE); + userLogin.setValue(""); + passwordField.setValue(""); + Logger.getLogger(LoginView.class.getName()).log(Level.SEVERE, null, ex); + } catch (DAOException ex) { + Notification.show("Fehler", "interner Fehler", Notification.Type.ERROR_MESSAGE); + Logger.getLogger(LoginView.class.getName()).log(Level.SEVERE, null, ex); } + // bei Erfolg wird der Navigator angesprochen und man wird in wieder zur Landingpage geführt + UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); }); horSpacer.setStyleName("LoginViewContainer"); // layout.addComponent(buttonReg); - - buttonReg.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - UI.getCurrent().getNavigator().navigateTo(Views.REGISTRIERUNG); - } + buttonReg.addClickListener((Button.ClickEvent event) -> { + UI.getCurrent().getNavigator().navigateTo(Views.REGISTRIERUNG); + }); + abbruch.addClickListener(e -> { + UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); }); } diff --git a/src/main/java/org/s4s/gui/views/PasswortView.java b/src/main/java/org/s4s/gui/views/PasswortView.java index 527083d921cba6677bd189b2d5b24564471266ab..c9e0727d5357a59fd244f19fcdf086399c7ab3d0 100644 --- a/src/main/java/org/s4s/gui/views/PasswortView.java +++ b/src/main/java/org/s4s/gui/views/PasswortView.java @@ -1,23 +1,16 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.VerticalLayout; /** * * @author Holger */ -public class PasswortView extends TemplateView{ +public class PasswortView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - + } diff --git a/src/main/java/org/s4s/gui/views/RegistrierungsBestaetigung.java b/src/main/java/org/s4s/gui/views/RegistrierungsBestaetigung.java index e1603ad43c770aecb458384e84cc2542a978ac56..aed1d7068947b6b9d61bb7fbf2f8c7e8e42444c5 100644 --- a/src/main/java/org/s4s/gui/views/RegistrierungsBestaetigung.java +++ b/src/main/java/org/s4s/gui/views/RegistrierungsBestaetigung.java @@ -1,19 +1,12 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -import org.s4s.gui.views.TemplateView; import org.s4s.services.util.Views; /** @@ -21,8 +14,8 @@ import org.s4s.services.util.Views; * @author JanPhilipp */ public class RegistrierungsBestaetigung extends TemplateView implements View { - - @Override + + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } @@ -30,23 +23,24 @@ public class RegistrierungsBestaetigung extends TemplateView implements View { private void setUp() { Panel panel = new Panel(); panel.setSizeUndefined(); - + VerticalLayout content = new VerticalLayout(); - + Button button = new Button("Zurück zur Startseite"); - button.addClickListener(e -> - UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); - + button.addClickListener(e + -> UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); + Label label = new Label("Vielen Dank für ihre Registrierung"); - - content.addComponent(label); - content.addComponent(button); - - content.setMargin(true); - - panel.setContent(content); - //this.addComponent(panel); - //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - - super.setUpFooterAndHeader(panel); -}} + + content.addComponent(label); + content.addComponent(button); + + content.setMargin(true); + + panel.setContent(content); + //this.addComponent(panel); + //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); + + super.setUpFooterAndHeader(panel); + } +} diff --git a/src/main/java/org/s4s/gui/views/ShopErstellung.java b/src/main/java/org/s4s/gui/views/ShopErstellung.java index d8a0816b3f8c608503d3efc4b56e3670cf6268b9..eb7996615523dab9db911cf457d25789cc8c5a6b 100644 --- a/src/main/java/org/s4s/gui/views/ShopErstellung.java +++ b/src/main/java/org/s4s/gui/views/ShopErstellung.java @@ -1,29 +1,21 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.NativeSelect; import com.vaadin.ui.Panel; -import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.UI; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; -import org.s4s.dao.impl.ShopControl; import org.s4s.exceptions.OwnsAlreadyShop; +import org.s4s.process.control.ShopControl; import org.s4s.services.util.Views; /** @@ -31,84 +23,77 @@ import org.s4s.services.util.Views; * @author JanPhilipp */ public class ShopErstellung extends TemplateView implements View { - - private String s = null; - @Override + + private String s = null; + + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } private void setUp() { - Panel panel = new Panel("ShopErstellung"); - panel.setSizeUndefined(); - - FormLayout content = new FormLayout(); + Panel panel = new Panel("ShopErstellung"); + panel.setSizeUndefined(); + + FormLayout content = new FormLayout(); // TextField shopowner = new TextField("Name des Shoperstellers"); // content.addComponent(shopowner); - - TextField shopname = new TextField("Name des Shops"); - content.addComponent(shopname); - + TextField shopname = new TextField("Name des Shops"); + content.addComponent(shopname); + // NativeSelect select = new NativeSelect("Position an der Hochschule"); // select.addItems("Student", "Hivi", "Prof"); // select.setNullSelectionAllowed(false); // content.addComponent(select); - - TextArea area = new TextArea("Shopbeschreibung"); - content.addComponent(area); - +// TextArea area = new TextArea("Shopbeschreibung"); +// content.addComponent(area); // TextField emailTxt = new TextField("E-Mail:"); // emailTxt.setIcon(FontAwesome.MAIL_FORWARD); // content.addComponent(emailTxt); + HorizontalLayout buttons = new HorizontalLayout(); + Button abbruch = new Button("Abbruch"); + abbruch.setIcon(FontAwesome.STOP_CIRCLE); + buttons.addComponent(abbruch); + buttons.addComponent(new Label(" ", ContentMode.HTML)); + Button bestätigen = new Button("Bestätigen"); + bestätigen.setIcon(FontAwesome.CHECK); + buttons.addComponent(bestätigen); - HorizontalLayout buttons = new HorizontalLayout(); - Button abbruch = new Button("Abbruch"); - abbruch.setIcon(FontAwesome.STOP_CIRCLE); - buttons.addComponent(abbruch); - buttons.addComponent(new Label(" ", ContentMode.HTML)); - Button bestätigen = new Button("Bestätigen"); - bestätigen.setIcon(FontAwesome.CHECK); - buttons.addComponent(bestätigen); - - content.addComponent(buttons); - content.setMargin(true); + content.addComponent(buttons); + content.setMargin(true); - panel.setContent(content); - //this.addComponent(panel); - //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - - + panel.setContent(content); + //this.addComponent(panel); + //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - bestätigen.addClickListener( e -> { + bestätigen.addClickListener(e -> { // String shopOwner = shopowner.getValue(); // String email = emailTxt.getValue(); - String shopName = shopname.getValue(); - String beschreibung = area.getValue(); - try { - ShopControl.checkUserShop(shopName, beschreibung); - } catch (OwnsAlreadyShop ex) { - Logger.getLogger(ShopErstellung.class.getName()).log(Level.SEVERE, null, ex); - } catch (SQLException ex) { - Logger.getLogger(ShopErstellung.class.getName()).log(Level.SEVERE, null, ex); - } - UI.getCurrent().getNavigator().navigateTo(Views.SHOPERSTELLUNGSBESTAETIGUNG); - // select.addValueChangeListener(event ->); + String shopName = shopname.getValue(); + // String beschreibung = area.getValue(); + try { + ShopControl.checkUserShop(shopName); + } catch (OwnsAlreadyShop ex) { + Logger.getLogger(ShopErstellung.class.getName()).log(Level.SEVERE, null, ex); + } catch (SQLException ex) { + Logger.getLogger(ShopErstellung.class.getName()).log(Level.SEVERE, null, ex); + } + UI.getCurrent().getNavigator().navigateTo(Views.SHOPERSTELLUNGSBESTAETIGUNG); + // select.addValueChangeListener(event ->); // System.out.println(shopOwner); - System.out.println(shopname); + System.out.println(shopname); // System.out.println(email); - System.out.println(beschreibung); - System.out.println(s); +// System.out.println(beschreibung); + System.out.println(s); - - // Weiterleitung auf Bestätigunsseite - + // Weiterleitung auf Bestätigunsseite }); abbruch.addClickListener(e -> { UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); }); - super.setUpFooterAndHeader(panel); + super.setUpFooterAndHeader(panel); } } diff --git a/src/main/java/org/s4s/gui/views/ShopView.java b/src/main/java/org/s4s/gui/views/ShopView.java deleted file mode 100644 index 89dfc82b4ae46a82f9e9fbde3ef2f0c54c9ac1ab..0000000000000000000000000000000000000000 --- a/src/main/java/org/s4s/gui/views/ShopView.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.gui.views; - -import com.vaadin.data.util.BeanContainer; -import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.server.FontAwesome; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Notification; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import java.util.HashSet; -import java.util.Set; -import org.s4s.exceptions.DAOException; -import org.s4s.exceptions.NoSuchProduct; -import org.s4s.dao.ProductDAO; -import org.s4s.dao.impl.ProductSearch; -import org.s4s.modell.dto.Product; - -/** - * - * @author Holger - */ -public class ShopView extends TemplateView { - - private final ProductDAO products = ProductSearch.getInstance(); - - @Override - public void enter(ViewChangeListener.ViewChangeEvent event) { - this.setUp(); - } - - public void setUp() { - // setSizeFull(); - setMargin(true); - - final HorizontalLayout searchLayout = new HorizontalLayout(); - final HorizontalLayout buttonLayout = new HorizontalLayout(); - - TextField textfield = new TextField(); - Button button = new Button("Suche", FontAwesome.SEARCH); - Label label = new Label("Das erste Label unseres Shop in Shop System"); - - buttonLayout.addComponent(label); - buttonLayout.setComponentAlignment(label, Alignment.TOP_LEFT); - - searchLayout.addComponent(textfield); - searchLayout.addComponent(button); - buttonLayout.addComponent(searchLayout); - buttonLayout.setComponentAlignment(searchLayout, Alignment.TOP_RIGHT); - buttonLayout.setSizeFull(); - addComponent(buttonLayout); - //setComponentAlignment(buttonLayout, Alignment.TOP_CENTER); - - final BeanContainer<Integer, Product> data = new BeanContainer<>(Product.class); - data.setBeanIdProperty("id"); - final Table table = new Table("Products", data); - table.setSizeFull(); - table.setSelectable(true); - - button.addClickListener((Button.ClickEvent event) -> { - String str = textfield.getValue().trim(); - - if (str.equals("")) { - Notification.show(null, "Bitte gesuchtes Produkt eingeben!", Notification.Type.WARNING_MESSAGE); - } else { - addComponent(table); - - Set<Product> liste = new HashSet<>(); - try { - liste.addAll(products.getProductByTyp(str)); - liste.addAll(products.getProductByDescription(str)); - } catch (DAOException ex) { - - } - - - data.removeAllItems(); - data.addAll(liste); - table.setPageLength(table.size()); - } - }); - } -} diff --git "a/src/main/java/org/s4s/gui/views/ShoperstellungsBest\303\244tigung.java" "b/src/main/java/org/s4s/gui/views/ShoperstellungsBest\303\244tigung.java" index e401933486c3703c39fe3c689f1e7a8e0064a78d..a6a531e5bf80e9137242304acfdc479c42ae64fa 100644 --- "a/src/main/java/org/s4s/gui/views/ShoperstellungsBest\303\244tigung.java" +++ "b/src/main/java/org/s4s/gui/views/ShoperstellungsBest\303\244tigung.java" @@ -1,13 +1,7 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; @@ -20,8 +14,8 @@ import org.s4s.services.util.Views; * @author JanPhilipp */ public class ShoperstellungsBestätigung extends TemplateView implements View { - - @Override + + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } @@ -29,24 +23,24 @@ public class ShoperstellungsBestätigung extends TemplateView implements View { private void setUp() { Panel panel = new Panel(); panel.setSizeUndefined(); - + VerticalLayout content = new VerticalLayout(); - + Button button = new Button("Zurück zur Startseite"); - button.addClickListener(e -> - UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); - + button.addClickListener(e + -> UI.getCurrent().getNavigator().navigateTo(Views.WELCOME)); + Label label = new Label("Vielen Dank für ihre Shoperstellung"); - - content.addComponent(label); - content.addComponent(button); - - content.setMargin(true); - - panel.setContent(content); - //this.addComponent(panel); - //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); - - super.setUpFooterAndHeader(panel); + + content.addComponent(label); + content.addComponent(button); + + content.setMargin(true); + + panel.setContent(content); + //this.addComponent(panel); + //this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); + + super.setUpFooterAndHeader(panel); } } diff --git a/src/main/java/org/s4s/gui/views/SucheView.java b/src/main/java/org/s4s/gui/views/SucheView.java new file mode 100644 index 0000000000000000000000000000000000000000..d750d272ae44b28c53f006071026ac5e65518ad0 --- /dev/null +++ b/src/main/java/org/s4s/gui/views/SucheView.java @@ -0,0 +1,128 @@ +package org.s4s.gui.views; + +import com.vaadin.data.util.BeanContainer; +import com.vaadin.data.util.BeanItem; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.navigator.ViewChangeListener; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Table; +import com.vaadin.ui.UI; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.s4s.dao.ProductDAO; +import org.s4s.dao.ShopSearchDAO; +import org.s4s.exceptions.DAOException; +import org.s4s.modell.dto.Product; +import org.s4s.modell.dto.Shop; +import org.s4s.modell.dto.Warenkorb; +import org.s4s.process.control.ProductSearch; +import org.s4s.process.control.ShopSearch; +import org.s4s.services.util.Roles; +import org.s4s.services.util.Views; + +/** + * + * @author Holger + */ +public class SucheView extends TemplateView { + + private final ProductDAO products = ProductSearch.getInstance(); + private final ShopSearchDAO shops = ShopSearch.getInstance(); + private Product product = null; + private final Warenkorb warenkorb = Warenkorb.getInstance(); + private final BeanContainer<Integer, Product> data = new BeanContainer<>(Product.class); + private final Table table = new Table("Products", data); + + @Override + public void enter(ViewChangeListener.ViewChangeEvent event) { + this.setUp(); + if (event.getParameters() != null) { + // split at "/", add each part as a label + String str = event.getParameters(); + str = str.trim(); + search(str); + } + } + + public void setUp() { + setSizeFull(); + setMargin(true); + + final HorizontalLayout searchLayout = new HorizontalLayout(); + final HorizontalLayout buttonLayout = new HorizontalLayout(); + buttonLayout.addComponent(searchLayout); + buttonLayout.setComponentAlignment(searchLayout, Alignment.TOP_RIGHT); + buttonLayout.setSizeFull(); + addComponent(buttonLayout); + data.setBeanIdProperty("id"); + table.setSizeFull(); + table.setSelectable(true); + + final BeanContainer<Integer, Shop> dataShops = new BeanContainer<>(Shop.class); + dataShops.setBeanIdProperty("id"); + final Table tableShops = new Table("Shops", dataShops); + tableShops.setSizeFull(); + Set<Shop> listeShops = new HashSet<>(); + + Button detailButton = new Button("Artikeldetails"); + detailButton.addClickListener((event) -> { + UI.getCurrent().getNavigator().navigateTo(Views.ARTIKELDETAILS + "/" + product.getId()); + }); + searchLayout.addComponent(detailButton); + searchLayout.setComponentAlignment(detailButton, Alignment.MIDDLE_CENTER); + + if (session.getAttribute(Roles.CURRENTUSER) != null) { + System.out.println(session.getAttribute(Roles.CURRENTUSER)); + Button addButton = new Button("Hinzufügen"); + + addButton.addClickListener((event) -> { + if (this.product == null) { + Notification.show(null, "Bitte Produkt(e) auswählen!", Notification.Type.HUMANIZED_MESSAGE); + } else { + warenkorb.add(product); + Notification.show(null, product.getName() + " wurde in den Warenkorb hinzugefügt!", + Notification.Type.WARNING_MESSAGE); + System.out.println(warenkorb.getAnzahl()); + } + }); + addComponent(addButton); + setComponentAlignment(addButton, Alignment.MIDDLE_CENTER); + } + table.addItemClickListener((ItemClickEvent event) -> { + BeanItem<Product> productBean = data.getItem(event.getItemId()); + product = productBean.getBean(); + }); + super.setUpFooterAndHeader(searchLayout); + } + + private void search(String str) { + data.setBeanIdProperty("id"); + table.setSizeFull(); + table.setSelectable(true); + Set<Product> liste = new HashSet<>(); + if ("".equals(str)) { + Notification.show(null, "Bitte gesuchtes Produkt eingeben!", Notification.Type.WARNING_MESSAGE); + } else { + addComponent(table); + try { + liste.addAll(products.getProductByName(str)); + liste.addAll(products.getProductByDescription(str)); + } catch (DAOException ex) { + Logger.getLogger(SucheView.class.getName()).log(Level.SEVERE, null, ex); + } + data.removeAllItems(); + data.addAll(liste); + table.setPageLength(table.size()); + table.setVisibleColumns(new Object[]{"name", "description", "price"}); + table.addItemClickListener((ItemClickEvent event) -> { + BeanItem<Product> productBean = data.getItem(event.getItemId()); + product = productBean.getBean(); + }); + } + } +} diff --git a/src/main/java/org/s4s/gui/views/TemplateView.java b/src/main/java/org/s4s/gui/views/TemplateView.java index 06c91bcd47a4123aba98bbb57051f90b604812b9..4614b96d6238b37b10c5a50f85941f3ad38bfa15 100644 --- a/src/main/java/org/s4s/gui/views/TemplateView.java +++ b/src/main/java/org/s4s/gui/views/TemplateView.java @@ -6,47 +6,47 @@ import com.vaadin.server.*; import com.vaadin.ui.*; import com.vaadin.ui.themes.BaseTheme; import java.io.File; - +import org.s4s.process.control.LogoutControl; +import org.s4s.process.control.ProductSearch; import org.s4s.services.util.Roles; import org.s4s.services.util.Views; - /** * Created by Max-Desktop on 14.05.2017. */ public class TemplateView extends VerticalLayout implements View { + VaadinSession session = UI.getCurrent().getSession(); + ProductSearch search = ProductSearch.getInstance(); private Image createLogo() { HorizontalLayout logoLayout = new HorizontalLayout(); logoLayout.addStyleName("logoLayout"); - + String rootpath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); - + FileResource srcLogo = new FileResource(new File(rootpath + "/WEB-INF/images/logo4.jpeg")); - + Image logo = new Image(); - + logo.setSource(srcLogo); logo.setStyleName("logo"); return logo; } - @Override public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) { - - } - public void setLoginButton () { } + public void setLoginButton() { + + } public void setUpFooterAndHeader(AbstractComponent content) { //HEADER - - final GridLayout headerLayout = new GridLayout(3,1); + final GridLayout headerLayout = new GridLayout(3, 1); //@Max: Logo eingefügt, brauchen wir meiner Meinung nach nicht mehr. #svolle2s headerLayout.setSpacing(true); // refactored Code --> header and Footer are outsourced by there own methodes #mkomp2s @@ -56,18 +56,17 @@ public class TemplateView extends VerticalLayout implements View { content.addStyleName("MainContenLocation"); //Final Content warpping Header and Footer around Content #mkomp2s - final VerticalLayout mainLayout = new VerticalLayout(headerLayout,navigationPanelGrid, content, footerLayout); + final VerticalLayout mainLayout = new VerticalLayout(headerLayout, navigationPanelGrid, content, footerLayout); mainLayout.setSizeFull(); ///mainLayout.setExpandRatio(content, 1); mainLayout.setSpacing(true);; mainLayout.setComponentAlignment(footerLayout, Alignment.BOTTOM_CENTER); addComponent(mainLayout); - mainLayout.setWidthUndefined(); //setComponentAlignment(navigationPanelGrid,Alignment.MIDDLE_CENTER); - setComponentAlignment(mainLayout,Alignment.MIDDLE_CENTER); + setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); this.setSpacing(true); this.setHeightUndefined(); @@ -75,13 +74,14 @@ public class TemplateView extends VerticalLayout implements View { this.setMargin(true); } - HorizontalLayout buildNavigationHeader () { + HorizontalLayout buildNavigationHeader() { HorizontalLayout navigationPanelGrid = new HorizontalLayout(); MenuBar.Command mycommand = new MenuBar.Command() { + @Override public void menuSelected(MenuBar.MenuItem selectedItem) { System.out.println(selectedItem); - switch (selectedItem.getText()){ + switch (selectedItem.getText()) { case "Home": UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); break; @@ -103,27 +103,38 @@ public class TemplateView extends VerticalLayout implements View { UI.getCurrent().getNavigator().navigateTo(Views.BENUTZERKONTO); break; case "Logout": - session.setAttribute(Roles.CURRENTUSER, null); + LogoutControl.logout(); UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); break; case "Kontakt": UI.getCurrent().getNavigator().navigateTo(Views.CONTACT); break; + // Edit Holger Anfang + case "Literatur": + UI.getCurrent().getNavigator().navigateTo(Views.SUCHE + "/literatur"); + break; - } + case "Mitschriften": + UI.getCurrent().getNavigator().navigateTo(Views.SUCHE + "/mitschriften"); + break; + case "Nachhilfe": + UI.getCurrent().getNavigator().navigateTo(Views.SUCHE + "/nachhilfe"); + break; + // Edit Ende + } } + ; }; MenuBar barmenu = new MenuBar(); MenuBar.MenuItem homeItem = barmenu.addItem("Home", null, mycommand); - // Another top-level item MenuBar.MenuItem categoryItem = barmenu.addItem("Kategorien", null, null); categoryItem.addItem("Literatur", null, mycommand); - categoryItem.addItem("Mitschriften", null, mycommand); + categoryItem.addItem("Mitschriften", null, mycommand); categoryItem.addItem("Nachhilfe", null, mycommand); // Yet another top-level item @@ -137,32 +148,41 @@ public class TemplateView extends VerticalLayout implements View { userItem.addItem("Einstellungen", null, mycommand); userItem.addItem("Logout", null, mycommand); + TextField tfSearch = new TextField(); + Button btnSearch = new Button("Suche", FontAwesome.SEARCH); - TextField tfSeach = new TextField(); - Button btnSearch = new Button("Suche" , FontAwesome.SEARCH); - + //Edit Holger + btnSearch.addClickListener((Button.ClickEvent event) -> { + String begriff = tfSearch.getValue(); + View view = UI.getCurrent().getNavigator().getCurrentView(); + //if (view instanceof SucheView) { + //} else { + UI.getCurrent().getNavigator().navigateTo(Views.SUCHE + "/" + begriff); + //} + }); + //Edit Ende navigationPanelGrid.addComponent(createLogo()); navigationPanelGrid.addComponent(barmenu); - navigationPanelGrid.addComponent(tfSeach); + navigationPanelGrid.addComponent(tfSearch); navigationPanelGrid.addComponent(btnSearch); navigationPanelGrid.setSpacing(true); navigationPanelGrid.setSizeUndefined(); - if (session.getAttribute(Roles.CURRENTUSER) == null){ + if (session.getAttribute(Roles.CURRENTUSER) == null) { userItem.setVisible(false); } else { registerItem.setVisible(false); loginItem.setVisible(false); } navigationPanelGrid.setStyleName("navbarGardient"); - navigationPanelGrid.setComponentAlignment(barmenu,Alignment.MIDDLE_CENTER); - navigationPanelGrid.setComponentAlignment(tfSeach,Alignment.MIDDLE_RIGHT); - navigationPanelGrid.setComponentAlignment(btnSearch,Alignment.MIDDLE_RIGHT); + navigationPanelGrid.setComponentAlignment(barmenu, Alignment.MIDDLE_CENTER); + navigationPanelGrid.setComponentAlignment(tfSearch, Alignment.MIDDLE_RIGHT); + navigationPanelGrid.setComponentAlignment(btnSearch, Alignment.MIDDLE_RIGHT); return navigationPanelGrid; } - HorizontalLayout buildFooter () { + HorizontalLayout buildFooter() { //FOOTER HorizontalLayout footerLayout = new HorizontalLayout(); @@ -181,8 +201,8 @@ public class TemplateView extends VerticalLayout implements View { btnContact.addClickListener((Button.ClickEvent event) -> { UI.getCurrent().getNavigator().navigateTo(Views.CONTACT); }); - footerLayout.setComponentAlignment(btnContact,Alignment.MIDDLE_CENTER); - footerLayout.setComponentAlignment(btnImpressum,Alignment.MIDDLE_CENTER); + footerLayout.setComponentAlignment(btnContact, Alignment.MIDDLE_CENTER); + footerLayout.setComponentAlignment(btnImpressum, Alignment.MIDDLE_CENTER); footerLayout.setStyleName("customfooter"); return footerLayout; diff --git a/src/main/java/org/s4s/gui/views/VerkaeuferbewertungView.java b/src/main/java/org/s4s/gui/views/VerkaeuferbewertungView.java index 0cbf405316c0719ce7a059325e2cdbb5d84f3faa..531a43ef9afacf514ced340bb0111f88c88c1742 100644 --- a/src/main/java/org/s4s/gui/views/VerkaeuferbewertungView.java +++ b/src/main/java/org/s4s/gui/views/VerkaeuferbewertungView.java @@ -1,27 +1,20 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.ui.VerticalLayout; /** * * @author Holger */ -public class VerkaeuferbewertungView extends TemplateView{ +public class VerkaeuferbewertungView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } - - public void setUp(){ - + + public void setUp() { + } - + } diff --git a/src/main/java/org/s4s/gui/views/WarenkorbView.java b/src/main/java/org/s4s/gui/views/WarenkorbView.java index 8a7a1dc3a290f9c8336ed7b6da9dcb8ad086ace2..419e2dd38620000fe897bf398c9f9eaad591d977 100644 --- a/src/main/java/org/s4s/gui/views/WarenkorbView.java +++ b/src/main/java/org/s4s/gui/views/WarenkorbView.java @@ -1,14 +1,20 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; +import com.vaadin.data.util.BeanContainer; +import com.vaadin.data.util.BeanItem; +import com.vaadin.event.ItemClickEvent; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.server.VaadinSession; +import com.vaadin.server.FontAwesome; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Notification; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Table; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import java.util.List; +import org.s4s.modell.dto.Product; import org.s4s.modell.dto.Warenkorb; import org.s4s.services.util.Roles; import org.s4s.services.util.Views; @@ -17,21 +23,85 @@ import org.s4s.services.util.Views; * * @author Holger */ -public class WarenkorbView extends TemplateView{ - +public class WarenkorbView extends TemplateView { + + private final Warenkorb warenkorb = Warenkorb.getInstance(); + private Product product = null; + @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } - - public void setUp(){ - VaadinSession session = UI.getCurrent().getSession(); - - if(session.getAttribute(Roles.CURRENTUSER) == null){ + + public void setUp() { + if (session.getAttribute(Roles.CURRENTUSER) == null) { UI.getCurrent().getNavigator().navigateTo(Views.LOGIN); Notification.show(null, "Einloggen, um auf den Warenkorb zuzugreifen!", Notification.Type.WARNING_MESSAGE); } - - + + final VerticalLayout contentLayout = new VerticalLayout(); + super.setUpFooterAndHeader(contentLayout); + + if (warenkorb.getAnzahl() == 0) { + Panel panel = new Panel("Der Warenkorb ist leer!"); + this.addComponent(panel); + this.setComponentAlignment(panel, Alignment.TOP_LEFT); + } else { + HorizontalLayout horizontalLayout = new HorizontalLayout(); + HorizontalLayout buttonLayout = new HorizontalLayout(); + Panel pAnzahl = new Panel("In Ihrem Warenkorb sind momentan: " + warenkorb.getAnzahl() + " Artikel!"); + horizontalLayout.addComponent(pAnzahl); + horizontalLayout.setComponentAlignment(pAnzahl, Alignment.TOP_LEFT); + + Panel pSum = new Panel("Gesamtwert im Warenkorb beträgt: " + warenkorb.sum()); + horizontalLayout.addComponent(pSum); + horizontalLayout.setComponentAlignment(pSum, Alignment.TOP_RIGHT); + + this.addComponent(horizontalLayout); + + List<Product> list = warenkorb.inhalt(); + final BeanContainer<Integer, Product> data = new BeanContainer<>(Product.class); + data.setBeanIdProperty("id"); + Table table = new Table("Ihr Warenkorb", data); + table.setSizeFull(); + table.setSelectable(true); + data.addAll(list); + this.addComponent(table); + table.setPageLength(table.size()); + table.setVisibleColumns(new Object[]{"name", "description", "price"}); + + table.addItemClickListener(new ItemClickEvent.ItemClickListener() { + @Override + public void itemClick(ItemClickEvent event) { + BeanItem<Product> productBean = data.getItem(event.getItemId()); + product = productBean.getBean(); + } + }); + + Button removeButton = new Button("Aus Warenkorb entfernen!"); + removeButton.addClickListener((Button.ClickEvent event) -> { + if (this.product == null) { + Notification.show(null, "Bitte, das zu entferndende Produkt auswählen", + Notification.Type.HUMANIZED_MESSAGE); + } else { + warenkorb.remove(product); + UI.getCurrent().getNavigator().navigateTo(Views.WARENKORB); + } + }); + + Button buyButton = new Button("Kaufen!"); + buyButton.addClickListener((event) -> { + + }); + + buttonLayout.addComponent(buyButton); + buttonLayout.setComponentAlignment(buyButton, Alignment.BOTTOM_LEFT); + buttonLayout.addComponent(removeButton); + buttonLayout.setComponentAlignment(removeButton, Alignment.BOTTOM_RIGHT); + this.addComponent(buttonLayout); + this.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER); + removeButton.setIcon(FontAwesome.UNDO); + } + } } diff --git a/src/main/java/org/s4s/gui/views/WelcomeView.java b/src/main/java/org/s4s/gui/views/WelcomeView.java index 62a76137a9e639a3477772cfe06d50675aad2a9b..b2717df1bd4555ccb1d3a4d1049cfb759757c6b9 100644 --- a/src/main/java/org/s4s/gui/views/WelcomeView.java +++ b/src/main/java/org/s4s/gui/views/WelcomeView.java @@ -1,68 +1,60 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.gui.views; -import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.ui.*; -import org.s4s.services.util.Views; /** * * @author Holger */ -public class WelcomeView extends TemplateView{ +public class WelcomeView extends TemplateView { @Override public void enter(ViewChangeListener.ViewChangeEvent event) { this.setUp(); } - - public void setUp(){ + + public void setUp() { //CONTENT goes here final VerticalLayout contentLayout = new VerticalLayout(); - super.setUpFooterAndHeader(contentLayout); -/* setSizeFull(); + /* setSizeFull(); setMargin(true); final HorizontalLayout horizontalLayout = new HorizontalLayout(); final HorizontalLayout buttonLayout = new HorizontalLayout(); - - + + Button sucheButton = new Button("Besuche Shop"); buttonLayout.addComponent(sucheButton); buttonLayout.setComponentAlignment(sucheButton, Alignment.TOP_LEFT); - - + + Button loginButton = new Button("Login"); buttonLayout.addComponent(loginButton); buttonLayout.setComponentAlignment(loginButton, Alignment.TOP_RIGHT); - - + + Button impressumButton = new Button("Impressum"); horizontalLayout.addComponent(impressumButton); horizontalLayout.setComponentAlignment(impressumButton, Alignment.MIDDLE_LEFT); - - + + addComponent(buttonLayout); buttonLayout.setSizeFull(); sucheButton.addClickListener((Button.ClickEvent event) ->{ - UI.getCurrent().getNavigator().navigateTo(Views.SHOP); + UI.getCurrent().getNavigator().navigateTo(Views.SHOP); }); - + loginButton.addClickListener((Button.ClickEvent event) ->{ UI.getCurrent().getNavigator().navigateTo(Views.LOGIN); }); - + impressumButton.addClickListener((Button.ClickEvent event) -> { UI.getCurrent().getNavigator().navigateTo(Views.IMPRESSUM); }); - + Label label = new Label("Willkommen in unserem Shop in Shop System!"); horizontalLayout.addComponent(label); horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); @@ -71,5 +63,5 @@ public class WelcomeView extends TemplateView{ addComponent(horizontalLayout); setComponentAlignment(horizontalLayout, Alignment.TOP_CENTER);*/ } - + } diff --git a/src/main/java/org/s4s/modell/dto/Product.java b/src/main/java/org/s4s/modell/dto/Product.java index 5ae338a71335f2c7fac0ea340cb5662a65829c89..3bc792e652e4331d9ecbb021a196009deb6369a6 100644 --- a/src/main/java/org/s4s/modell/dto/Product.java +++ b/src/main/java/org/s4s/modell/dto/Product.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.modell.dto; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -14,13 +9,11 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; */ public class Product { - private Warenkorb warenkorb; - private String name; + private String description; + private double price; private Integer id; private String typ; - private double price; - private String description; public Product(String name, Integer id, String typ, double price, String description) { this.name = name; @@ -34,14 +27,6 @@ public class Product { } - public void setWarenkorb(Warenkorb warenkorb) { - this.warenkorb = warenkorb; - } - - public Warenkorb getWarenkorb() { - return warenkorb; - } - @Override public boolean equals(Object other) { if (other == null) { diff --git a/src/main/java/org/s4s/modell/dto/Shop.java b/src/main/java/org/s4s/modell/dto/Shop.java index cd03c3246624ffa74829bdb4165bd9596b6f10a8..aca3f8017dde7810513dee3968ae1091a5da4b68 100644 --- a/src/main/java/org/s4s/modell/dto/Shop.java +++ b/src/main/java/org/s4s/modell/dto/Shop.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.modell.dto; /** @@ -11,4 +6,62 @@ package org.s4s.modell.dto; */ public class Shop { + private int shopId; + private String name; + private int besitzer; + private double bewertung; + private int bewertunganzahl; + + public Shop() { + + } + + public Shop(int shopId, String name, int besitzer, double bewertung, int bewertunganzahl) { + this.shopId = shopId; + this.name = name; + this.besitzer = besitzer; + this.bewertung = bewertung; + this.bewertunganzahl = bewertunganzahl; + } + + public int getShopId() { + return shopId; + } + + public void setShopId(int shopId) { + this.shopId = shopId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getBesitzer() { + return besitzer; + } + + public void setBesitzer(int besitzer) { + this.besitzer = besitzer; + } + + public double getBewertung() { + return bewertung; + } + + public void setBewertung(double bewertung) { + this.bewertung = bewertung; + } + + public int getBewertungsanzahl() { + return bewertunganzahl; + } + + public void setBewertungsanzahl(int bewertunganzahl) { + this.bewertunganzahl = bewertunganzahl; + } + } diff --git a/src/main/java/org/s4s/modell/dto/Transaction.java b/src/main/java/org/s4s/modell/dto/Transaction.java new file mode 100644 index 0000000000000000000000000000000000000000..3233cc0adfdd2c4d47a81e6bd50c506980f2dd51 --- /dev/null +++ b/src/main/java/org/s4s/modell/dto/Transaction.java @@ -0,0 +1,47 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.s4s.modell.dto; + +/** + * + * @author Holger + */ +public class Transaction { + + private String verkaeufer; + private User kaeufer; + private Product produkt; + + public Transaction(String verkaeufer, User kaeufer, Product produkt) { + this.verkaeufer = verkaeufer; + this.kaeufer = kaeufer; + this.produkt = produkt; + } + + public String getVerkaeufer() { + return verkaeufer; + } + + public void setVerkaeufer(String verkaeufer) { + this.verkaeufer = verkaeufer; + } + + public User getKaeufer() { + return kaeufer; + } + + public void setKaeufer(User kaeufer) { + this.kaeufer = kaeufer; + } + + public Product getProdukt() { + return produkt; + } + + public void setProdukt(Product produkt) { + this.produkt = produkt; + } +} diff --git a/src/main/java/org/s4s/modell/dto/User.java b/src/main/java/org/s4s/modell/dto/User.java index b7ad3eafdefe5be7d1364e4158063060cd24ef27..271e9cc912b6c25b3aeba8bff0a0c691cb39f806 100644 --- a/src/main/java/org/s4s/modell/dto/User.java +++ b/src/main/java/org/s4s/modell/dto/User.java @@ -1,12 +1,5 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.modell.dto; -import java.util.Date; - /** * * @author Holger @@ -14,63 +7,73 @@ import java.util.Date; public class User { private int userId; + private String email; + private String geburtsdatum; + private int fachbereichId; private String vorname; private String nachname; - private Date geburtsdatum; - private int fachbereichId; - private String email; - - private final String benutzername; - public User(String benutzername){ + public User(String benutzername, int userId) { this.benutzername = benutzername; + this.userId = userId; + } + + public int getUserId() { + return userId; + } + + public String getEmail() { + return email; + } + + public String getGeburtsdatum() { + return geburtsdatum; + } + + public int getFachbereichId() { + return fachbereichId; } public String getBenutzername() { return benutzername; } - + public String getVorname() { return vorname; } - public void setVorname(String vorname) { - this.vorname = vorname; - } - public String getNachname() { return nachname; } - public void setNachname(String nachname) { - this.nachname = nachname; + public String getUsername() { + return benutzername; } - public Date getGeburtsdatum() { - return geburtsdatum; + public void setUserId(int userId) { + this.userId = userId; } - public void setGeburtsdatum(Date geburtsdatum) { - this.geburtsdatum = geburtsdatum; + public void setEmail(String email) { + this.email = email; } - public int getFachbereichId() { - return fachbereichId; + public void setGeburtsdatum(String geburtsdatum) { + this.geburtsdatum = geburtsdatum; } public void setFachbereichId(int fachbereichId) { this.fachbereichId = fachbereichId; } - public String getEmail() { - return email; + public void setVorname(String vorname) { + this.vorname = vorname; } - public void setEmail(String email) { - this.email = email; + public void setNachname(String nachname) { + this.nachname = nachname; } - - + } diff --git a/src/main/java/org/s4s/modell/dto/Warenkorb.java b/src/main/java/org/s4s/modell/dto/Warenkorb.java index 97da541b3d3478180be8e75c5b250bf4f8f95955..5af4bce6abcfc765a5fc978fa766e4834cbe4707 100644 --- a/src/main/java/org/s4s/modell/dto/Warenkorb.java +++ b/src/main/java/org/s4s/modell/dto/Warenkorb.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.modell.dto; import java.util.ArrayList; @@ -15,11 +10,23 @@ import java.util.List; public class Warenkorb { private final List<Product> products; + private static Warenkorb warenkorb; public Warenkorb() { products = new ArrayList<>(); } + public static Warenkorb getInstance() { + if (warenkorb == null) { + warenkorb = new Warenkorb(); + } + return warenkorb; + } + + public List<Product> inhalt() { + return products; + } + public void add(Product p) { if (p == null) { throw new NullPointerException("Produkt darf nicht null sein!"); @@ -27,6 +34,10 @@ public class Warenkorb { products.add(p); } + public Product getProduct(int i) { + return products.get(i); + } + public void remove(Product p) { if (p == null) { throw new NullPointerException("Produkt darf nicht null sein!"); @@ -37,6 +48,10 @@ public class Warenkorb { products.remove(p); } + public void clear() { + products.clear(); + } + public double sum() { return products.stream().mapToDouble(p -> p.getPrice()).sum(); } @@ -51,4 +66,23 @@ public class Warenkorb { public int getAnzahl() { return products.size(); } + + public void auflisten() { + products.forEach((p) -> { + System.out.println(p.getName() + ", " + p.getPrice()); + //System.out.println(p.getName()); + }); + } + + /* public BeanContainer<Integer, Product> ausgabe() { + final BeanContainer<Integer, Product> data = new BeanContainer<>(Product.class); + data.setBeanIdProperty("id"); + products.forEach((product) -> { + data.addBean(product); + }); + final Table table = new Table("Products", data); + table.setSizeFull(); + table.setSelectable(true); + return data; + }*/ } diff --git a/src/main/java/org/s4s/process/control/ContactControl.java b/src/main/java/org/s4s/process/control/ContactControl.java index b53a22b08a9310215d6d30980abdc72ad7b09330..a00198f01822a7c09c73644abe867bea3a185b88 100644 --- a/src/main/java/org/s4s/process/control/ContactControl.java +++ b/src/main/java/org/s4s/process/control/ContactControl.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.process.control; /** @@ -10,5 +5,5 @@ package org.s4s.process.control; * @author synot */ public class ContactControl { - + } diff --git a/src/main/java/org/s4s/dao/impl/LoginControl.java b/src/main/java/org/s4s/process/control/LoginControl.java similarity index 54% rename from src/main/java/org/s4s/dao/impl/LoginControl.java rename to src/main/java/org/s4s/process/control/LoginControl.java index 189a124e829828d4f597fc2a85da9c7e7a1d8000..8f483effaff6fbacee1fa10d4492f89e427c88fd 100644 --- a/src/main/java/org/s4s/dao/impl/LoginControl.java +++ b/src/main/java/org/s4s/process/control/LoginControl.java @@ -1,16 +1,11 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.dao.impl; +package org.s4s.process.control; import com.vaadin.server.VaadinSession; import com.vaadin.ui.UI; import java.sql.*; -import javax.swing.JOptionPane; -import org.s4s.exceptions.DAOException; import org.s4s.dao.KundenDAO; +import org.s4s.dao.impl.AbstractDatabaseClass; +import org.s4s.exceptions.DAOException; import org.s4s.exceptions.NoSuchUserOrPassword; import org.s4s.modell.dto.User; import org.s4s.services.util.Roles; @@ -22,25 +17,23 @@ import org.s4s.services.util.Views; */ public class LoginControl extends AbstractDatabaseClass implements KundenDAO { - public static void infoBox(String infoMessage, String titleBar) { - JOptionPane.showMessageDialog(null, infoMessage, "InfoBox: " + titleBar, JOptionPane.INFORMATION_MESSAGE); - } - @Override public void getUserByCredentials(String username, String password) throws NoSuchUserOrPassword, DAOException { //Von Max und Knobie //Von Holger vervollständigt - - try(ResultSet set = executeQuery("SELECT u.\"benutzername\"" - + " FROM \"ERR\".\"user\" u " - + " WHERE u.benutzername = '" + username + "' " - + " AND u.passwort = '" + password + "';")) {if (!set.next()) { + + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"user\" u " + + " WHERE u.benutzername = '" + username + "' " + + " AND u.passwort = '" + password + "';")) { + if (!set.next()) { throw new NoSuchUserOrPassword(); } String bname = set.getString("benutzername"); - - User user = new User(bname); - + int userId = set.getInt("userID"); + + User user = new User(bname, userId); + createSession(user); } catch (SQLException ex) { @@ -50,9 +43,8 @@ public class LoginControl extends AbstractDatabaseClass implements KundenDAO { @Override public void createSession(User user) throws NoSuchUserOrPassword, DAOException { - VaadinSession session = UI.getCurrent().getSession(); + VaadinSession session = UI.getCurrent().getSession(); session.setAttribute(Roles.CURRENTUSER, user); UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); - //System.out.println(user.getBenutzername()); } } diff --git a/src/main/java/org/s4s/process/control/LogoutControl.java b/src/main/java/org/s4s/process/control/LogoutControl.java new file mode 100644 index 0000000000000000000000000000000000000000..3fc36c3dceacdceb6d232e7051658227e516b172 --- /dev/null +++ b/src/main/java/org/s4s/process/control/LogoutControl.java @@ -0,0 +1,19 @@ +package org.s4s.process.control; + +import com.vaadin.server.VaadinSession; +import com.vaadin.ui.UI; +import org.s4s.services.util.Roles; + +/** + * + * @author Sebastian + */ +public class LogoutControl { + + public static void logout() { + VaadinSession session = UI.getCurrent().getSession(); + session.setAttribute(Roles.CURRENTUSER, null); + // session.close(); + } + +} diff --git a/src/main/java/org/s4s/dao/impl/ProductSearch.java b/src/main/java/org/s4s/process/control/ProductSearch.java similarity index 54% rename from src/main/java/org/s4s/dao/impl/ProductSearch.java rename to src/main/java/org/s4s/process/control/ProductSearch.java index 985255584611f6290482d794018675506fc34001..e1d347846c7f5c81dbb6c2ca8bba4d23fb91a372 100644 --- a/src/main/java/org/s4s/dao/impl/ProductSearch.java +++ b/src/main/java/org/s4s/process/control/ProductSearch.java @@ -1,19 +1,13 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.dao.impl; +package org.s4s.process.control; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.s4s.exceptions.DAOException; -import org.s4s.exceptions.NoSuchProduct; import org.s4s.dao.ProductDAO; +import org.s4s.dao.impl.AbstractDatabaseClass; +import org.s4s.exceptions.DAOException; import org.s4s.modell.dto.Product; -import org.s4s.services.db.JDBCConnection; /** * @@ -21,10 +15,6 @@ import org.s4s.services.db.JDBCConnection; */ public class ProductSearch extends AbstractDatabaseClass implements ProductDAO { -// Product p1 = new Product("Nachhilfe Algebra", 1, "Nachhilfe", 2.00, "Biete Nachhilfe in Algebra an!"); -// Product p2 = new Product("F&I", 2, "Mitschriften", 5.00, "Mitschriften aus dem WS16/17 in F&I!"); -// Product p3 = new Product("Ãœbungen Eidip", 3, "Lösungen", 10.50, "Lösungen zu alten Eidip Aufgaben!"); - private ProductSearch() { } @@ -39,18 +29,18 @@ public class ProductSearch extends AbstractDatabaseClass implements ProductDAO { } @Override - public List<Product> getProductByTyp(String kateg) throws DAOException { + public List<Product> getProductByName(String kate) throws DAOException { List<Product> liste = new ArrayList<>(); - try( ResultSet set = executeQuery("SELECT *" - + " FROM \"ERR\".\"artikel\" a" - + " WHERE LOWER(a.kategorie) = LOWER('" + kateg + "');")) { - while(set.next()) { + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"artikel\" a" + + " WHERE LOWER(a.name) ILIKE LOWER('%" + kate + "%');")) { + while (set.next()) { String name = set.getString("name"); int id = set.getInt("artikelID"); String kategorie = set.getString("kategorie"); double price = set.getDouble("preis"); String description = set.getString("beschreibung"); - + Product p = new Product(name, id, kategorie, price, description); liste.add(p); } @@ -63,16 +53,16 @@ public class ProductSearch extends AbstractDatabaseClass implements ProductDAO { @Override public List<Product> getProductByDescription(String descrip) throws DAOException { List<Product> liste = new ArrayList<>(); - try(ResultSet set = executeQuery("SELECT *" - + " FROM \"ERR\".\"artikel\" a" - + " WHERE LOWER(a.beschreibung) ILIKE LOWER('%" + descrip + "%');")) { - while(set.next()) { + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"artikel\" a" + + " WHERE LOWER(a.beschreibung) ILIKE LOWER('%" + descrip + "%');")) { + while (set.next()) { String name = set.getString("name"); - int id = set.getInt("artikelID"); + int id = set.getInt("artikelid"); String kategorie = set.getString("kategorie"); double price = set.getDouble("preis"); String description = set.getString("beschreibung"); - + Product p = new Product(name, id, kategorie, price, description); liste.add(p); } @@ -81,4 +71,30 @@ public class ProductSearch extends AbstractDatabaseClass implements ProductDAO { } return liste; } + + @Override + public Product getProductById(int id) throws DAOException { + Product p = new Product(); + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"artikel\" a" + + " WHERE a.artikelid = ('" + id + "');")) { + if (set.next()) { + String name = set.getString("name"); + int pId = set.getInt("artikelid"); + String kategorie = set.getString("kategorie"); + double price = set.getDouble("preis"); + String description = set.getString("beschreibung"); + + p.setName(name); + p.setId(pId); + p.setTyp(kategorie); + p.setPrice(price); + p.setDescription(description); + } + } catch (SQLException ex) { + throw new DAOException(ex); + } + return p; + } + } diff --git a/src/main/java/org/s4s/dao/impl/RegistrationControl.java b/src/main/java/org/s4s/process/control/RegistrationControl.java similarity index 100% rename from src/main/java/org/s4s/dao/impl/RegistrationControl.java rename to src/main/java/org/s4s/process/control/RegistrationControl.java diff --git a/src/main/java/org/s4s/process/control/ShopControl.java b/src/main/java/org/s4s/process/control/ShopControl.java new file mode 100644 index 0000000000000000000000000000000000000000..b59eab3e0114127e89628037a19d065f03937400 --- /dev/null +++ b/src/main/java/org/s4s/process/control/ShopControl.java @@ -0,0 +1,93 @@ +package org.s4s.process.control; + +import com.vaadin.server.VaadinSession; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.s4s.dao.ShopDAO; +import org.s4s.dao.impl.AbstractDatabaseClass; +import org.s4s.exceptions.OwnsAlreadyShop; +import org.s4s.modell.dto.User; +import org.s4s.services.db.JDBCConnection; +import org.s4s.services.util.Roles; + +/** + * + * @author Benjamin + */ +public class ShopControl extends AbstractDatabaseClass implements ShopDAO { + + private static final User user = (User) VaadinSession.getCurrent().getAttribute(Roles.CURRENTUSER); + private final Statement statement = JDBCConnection.getInstance().getStatement(); + + //bekommt User aus der View übergeben und prüft ob dieser schon in der Shopdb vorhanden ist (= hat schon einen Shop). + public static void checkUserShop(String shopName) throws OwnsAlreadyShop, SQLException { + ShopControl sc = new ShopControl(); + boolean test = sc.viewShop(user); + //Shop mit dem Nutzer schon vorhanden + if (test == true) { + throw new OwnsAlreadyShop("Sie besitzen bereits einen Shop!"); + } //noch kein Shop vorhanden + else { + addUserShop(shopName); + } + } + + private static void addUserShop(String shopName) throws SQLException { + ShopControl sc = new ShopControl(); + boolean erstellung = sc.addShop(user, shopName); + + if (erstellung == false) { + //Fehlerhandling + throw new SQLException("Fehler beim Anlegen des Shops bitte noch einmal versuchen oder Programmierer kontaktieren!"); + } + } + + //Shop anhand von User/Besitzer auslesen + /** + * + * @param user + * @return + */ + @Override + public boolean viewShop(User user) { + boolean result = false; + try { + ResultSet set = executeQuery("SELECT \"besitzer\"" + + "FROM \"ERR\".\"shop\" " + + "WHERE besitzer = " + user.getUserId() + ";"); + + if (set.next()) { + result = true; + } + } catch (SQLException ex) { + Logger.getLogger(ShopDAO.class.getName()).log(Level.SEVERE, null, ex); + } + return result; + } + + /** + * + * @param user + * @param shopName + * @return + */ + @Override + public boolean addShop(User user, String shopName) { + //Shop via Benutzername anlegen da dieser idR eindeutig ist + try { + // vorausgesetzt ID wird automatisch gesetzt von der DB + statement.execute("INSERT INTO \"ERR\".\"shop\" (name, besitzer) VALUES (" + + "'" + shopName + "'" + "," + + user.getUserId() + ");"); // + "," + //+ shopDescription + ");"); + return true; + } catch (SQLException ex) { + Logger.getLogger(ShopDAO.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + + } +} diff --git a/src/main/java/org/s4s/process/control/ShopSearch.java b/src/main/java/org/s4s/process/control/ShopSearch.java new file mode 100644 index 0000000000000000000000000000000000000000..79a8afbb74088c760d33358a11f3c11fbed915b6 --- /dev/null +++ b/src/main/java/org/s4s/process/control/ShopSearch.java @@ -0,0 +1,77 @@ +package org.s4s.process.control; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.s4s.dao.ShopSearchDAO; +import org.s4s.dao.impl.AbstractDatabaseClass; +import org.s4s.exceptions.DAOException; +import org.s4s.modell.dto.Shop; + +/** + * + * @author Holger + */ +public class ShopSearch extends AbstractDatabaseClass implements ShopSearchDAO { + + private ShopSearch() { + + } + + public static ShopSearch search = null; + + public static ShopSearch getInstance() { + if (search == null) { + search = new ShopSearch(); + } + return search; + } + + @Override + public List<Shop> getShopByName(String typ) throws DAOException { + List<Shop> liste = new ArrayList<>(); + + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"shop\" s" + + " WHERE LOWER(s.name) = LOWER('" + typ + "');")) { + while (set.next()) { + int shopId = set.getInt("shopid"); + String name = set.getString("name"); + int besitzer = set.getInt("besitzer"); + double bewertung = set.getDouble("bewertung"); + int bewertunganzahl = set.getInt("bewertungsanzahl"); + + Shop s = new Shop(shopId, name, besitzer, bewertung, bewertunganzahl); + liste.add(s); + } + } catch (SQLException ex) { + throw new DAOException(ex); + } + return liste; + } + + @Override + public List<Shop> getShopByOwner(String typ) throws DAOException { + List<Shop> liste = new ArrayList<>(); + + try (ResultSet set = executeQuery("SELECT *" + + " FROM \"ERR\".\"shop\" s" + + " WHERE LOWER(s.besitzer) = LOWER('" + typ + "');")) { + while (set.next()) { + int shopId = set.getInt("shopid"); + String name = set.getString("name"); + int besitzer = set.getInt("besitzer"); + double bewertung = set.getDouble("bewertung"); + int bewertunganzahl = set.getInt("bewertungsanzahl"); + + Shop s = new Shop(shopId, name, besitzer, bewertung, bewertunganzahl); + liste.add(s); + } + } catch (SQLException ex) { + throw new DAOException(ex); + } + return liste; + } + +} diff --git a/src/main/java/org/s4s/dao/impl/TransactionControl.java b/src/main/java/org/s4s/process/control/TransactionControl.java similarity index 82% rename from src/main/java/org/s4s/dao/impl/TransactionControl.java rename to src/main/java/org/s4s/process/control/TransactionControl.java index cf77e7e12ae6adc098f951d8573a90537a13460f..f708ad1168da90bd561f8da838e47fbcc36816a5 100644 --- a/src/main/java/org/s4s/dao/impl/TransactionControl.java +++ b/src/main/java/org/s4s/process/control/TransactionControl.java @@ -1,13 +1,9 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.s4s.dao.impl; +package org.s4s.process.control; import com.vaadin.ui.UI; import java.sql.ResultSet; import java.sql.SQLException; +import org.s4s.dao.impl.AbstractDatabaseClass; import org.s4s.exceptions.DAOException; import org.s4s.modell.dto.Product; import org.s4s.modell.dto.User; diff --git a/src/main/java/org/s4s/services/db/JDBCConnection.java b/src/main/java/org/s4s/services/db/JDBCConnection.java index 4adca2ef05011ee89bed6128f7787eed02ed295b..a457a8ae8f9ddf23d8b6e01bf8e9304c749011e1 100644 --- a/src/main/java/org/s4s/services/db/JDBCConnection.java +++ b/src/main/java/org/s4s/services/db/JDBCConnection.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.services.db; import java.sql.*; @@ -38,7 +33,7 @@ public class JDBCConnection { this.openConnection(); } catch (SQLException ex) { Logger.getLogger(JDBCConnection.class.getName()).log(Level.SEVERE, null, ex); - } + } } private void openConnection() { @@ -54,7 +49,7 @@ public class JDBCConnection { Logger.getLogger(JDBCConnection.class.getName()).log(Level.SEVERE, null, ex); } } - + public Statement getStatement() { try { if (this.conn.isClosed()) { diff --git a/src/main/java/org/s4s/services/util/EmailValidator.java b/src/main/java/org/s4s/services/util/EmailValidator.java deleted file mode 100644 index f7a051e89ec8bfacebcde9121c9f8054f6686648..0000000000000000000000000000000000000000 --- a/src/main/java/org/s4s/services/util/EmailValidator.java +++ /dev/null @@ -1,41 +0,0 @@ -///* -// * To change this license header, choose License Headers in Project Properties. -// * To change this template file, choose Tools | Templates -// * and open the template in the editor. -// */ -//package org.s4s.services.util; -// -//import com.vaadin.data.Validator; -// -///** -// * -// * @author synot -// */ -//public class EmailValidator implements Validator { -// /** -// * Tests if the given value is valid -// * @param value the value to test -// */ -// public boolean isValid(Object value) { -// try { -// validate(value); -// } catch (Validator.InvalidValueException ive) { -// return false; -// } -// return true; -// } -// -// /** -// * Validates -// * @param value the value to test -// */ -// public void validate(Object value) throws Validator.InvalidValueException { -// // Here value is a String containing what *should* be an e-mail address -// if (value instanceof String) { -// String email = (String)value; -// // Match the email string against a (simplistic) regular expression matching e-mail addresses -// if (!email.matches("^[_\\w\\.\\-]+@[\\w\\.-]+\\.[a-z]{2,6}$")) -// throw new Validator.InvalidValueException("The e-mail address provided is not valid!"); -// } -// } -//} diff --git a/src/main/java/org/s4s/services/util/Roles.java b/src/main/java/org/s4s/services/util/Roles.java index a314e79396c7a740d5ff71610496ffb69a6a6caf..52fcb790f685fbaf54936e0316330d715310af66 100644 --- a/src/main/java/org/s4s/services/util/Roles.java +++ b/src/main/java/org/s4s/services/util/Roles.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.services.util; /** @@ -10,6 +5,7 @@ package org.s4s.services.util; * @author Holger */ public class Roles { + public static final String CURRENTUSER = "currentUser"; public static final String HIWI = "hiWi"; public static final String STUDENT = "student"; diff --git a/src/main/java/org/s4s/services/util/Views.java b/src/main/java/org/s4s/services/util/Views.java index 16120194681eadc0b147938af4ef491563a5c73a..7a7a35e3a7520a0cce258bcf88841144b8ef13f2 100644 --- a/src/main/java/org/s4s/services/util/Views.java +++ b/src/main/java/org/s4s/services/util/Views.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.s4s.services.util; /** @@ -10,9 +5,10 @@ package org.s4s.services.util; * @author Holger */ public final class Views { + public final static String REGISTRIERUNG = "registrierung"; public final static String WELCOME = "welcome"; - public final static String SHOP = "shop"; + public final static String SUCHE = "suche"; public final static String LOGIN = "login"; public final static String WARENKORB = "warenkorb"; public final static String BENUTZERKONTO = "benutzerkonto"; @@ -28,8 +24,8 @@ public final class Views { public final static String SHOPERSTELLUNGSBESTAETIGUNG = "shoperstellungsbestaetigung"; public final static String REGISTRIERUNGSBESTAETIGUNG = "registrierungsbestaetigung"; public final static String KONTAKTBESTAETIGUNG = "kontaktbestaetigung"; - - private Views(){ - + + private Views() { + } } diff --git a/src/test/java/org/s4s/dao/impl/LoginControl_Test.java b/src/test/java/org/s4s/dao/impl/LoginControl_Test.java index 5d25a2039b0fe431fb6a1d001623aa389a9994cb..d1b5c78e898bc1725e9dd53ac6dc86a3a645b4e4 100644 --- a/src/test/java/org/s4s/dao/impl/LoginControl_Test.java +++ b/src/test/java/org/s4s/dao/impl/LoginControl_Test.java @@ -4,9 +4,7 @@ import org.junit.Test; import org.s4s.dao.KundenDAO; import org.s4s.exceptions.DAOException; import org.s4s.exceptions.NoSuchUserOrPassword; -import org.s4s.modell.dto.User; - -import static org.junit.Assert.*; +import org.s4s.process.control.LoginControl; /** * Created by uerdingen on 03.06.17. @@ -20,4 +18,4 @@ public class LoginControl_Test { kundenDAO.getUserByCredentials("testuser", "54321"); } -} \ No newline at end of file +} diff --git a/src/test/java/org/s4s/dao/impl/RegistrationControl_Test.java b/src/test/java/org/s4s/dao/impl/RegistrationControl_Test.java index d3a6ffe807274e2175b66b8ead0cddc6a0ca97aa..9efe9a6125a514e8e16c31573b6d4018978ecbfd 100644 --- a/src/test/java/org/s4s/dao/impl/RegistrationControl_Test.java +++ b/src/test/java/org/s4s/dao/impl/RegistrationControl_Test.java @@ -1,33 +1,31 @@ package org.s4s.dao.impl; -import org.junit.Before; -import org.junit.Test; - import static org.junit.Assert.*; +import org.junit.Test; +import org.s4s.process.control.RegistrationControl; /** * Created by uerdingen on 03.06.17. */ public class RegistrationControl_Test { - private String[] data1 = new String[7]; - - @Test - public void nameValidator_Test(){ - assertTrue(RegistrationControl.nameValidator("Uerdingen")); - assertFalse(RegistrationControl.nameValidator("fs2df3")); - } + private String[] data1 = new String[7]; + @Test + public void nameValidator_Test() { + assertTrue(RegistrationControl.nameValidator("Uerdingen")); + assertFalse(RegistrationControl.nameValidator("fs2df3")); + } //unfinished @Test - public void Registration_Test(){ + public void Registration_Test() { data1[0] = "Uerdingen"; data1[1] = "Simon"; data1[2] = "simon.uerdingen@inf.h-brs.de"; data1[4] = "12345"; - //assertTrue(RegistrationControl.init(data1)); - //@TM: der Test muss neu geschrieben werden, wegen Änderungen in View, DAO & Control; svolle2s + //assertTrue(RegistrationControl.init(data1)); + //@TM: der Test muss neu geschrieben werden, wegen Änderungen in View, DAO & Control; svolle2s } -} \ No newline at end of file +}