From 4e46abc3349babdee32d8949f311c89f25cf6919 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 9 Sep 2015 11:19:59 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20added=20controller=20for=20prod?= =?utf8?q?ucts=20and=20categories=20(both=20admin)=20-=20updated=20jcore-e?= =?utf8?q?e-logger.jar=20+=20updated=20jshop-ee-lib.jar=20Signed-off-by:Ro?= =?utf8?q?land=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore-ee-logger.jar | Bin 7793 -> 7793 bytes lib/jshop-ee-lib.jar | Bin 6975 -> 7191 bytes .../beans/category/AdminCategoryWebBean.java | 70 ++++++++++++++++ .../category/AdminCategoryWebController.java | 36 ++++++++ .../beans/product/AdminProductWebBean.java | 77 ++++++++++++++++++ .../AdminProductWebController.java | 11 +-- 6 files changed, 184 insertions(+), 10 deletions(-) create mode 100644 src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java rename src/java/org/mxchange/pizzaapplication/beans/{controller => product}/AdminProductWebController.java (79%) diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 5b54c7d62bdde3ebaa2ee7121b7a5af6f59b349a..6a5ff51e99f32a7569a071da9273c33111266a92 100644 GIT binary patch delta 211 zcmexp^U;PUz?+$ci-CcIfk7a0B9A5$f8<2-=}bWO1qBfKNfSs;mSr>tQDKa>AZjY3 zGl;sy=mn%Ut1-neg6I}zWfl;tQDKa>AZjY3 zGl;sy=mk{0S&b=%5y;)#!mP{!qF1sTGJ)tjoL@LV^d%v45PvbZC@YYf%qwLH)HT^d z$^pddk}?2Mdw_yK>bsOXh;oqj1yTLd!6531bQDN~gNz-B*C1mCqISq6gD6?qED+Tx Ln-8LX$(92Er7c3N diff --git a/lib/jshop-ee-lib.jar b/lib/jshop-ee-lib.jar index 657fb7073717301d8fdc08ac57eb98bd8307e0a2..1697bcc77c63dcbdd0b94e3b806e76bb364a1671 100644 GIT binary patch delta 697 zcmZvZ&r1|>6u{s2``w+{S!ZTv$C;hkb<6c2IfQ74s~*x!hbz-GehR^qXKUNPX&H6o+$^v8n z!p6QC$)K@6aVRPNUg7;Bq8+b@5ypZTXS@+N8DGRaBP+)kGjfXYQr;pQs8MvROxMp3 z)NO8Z_ZV4E2SfC2Jv2I!RZ-b2ewA`5JyM%_7pf5*`JWIYos zHJCeXOAS_^EKHLSuQ`&c;7%!n!|t`L-!{^r7yFz$h5-Bd>gMd)8m_y;_%*kL%Wi<@ z?ynVf=?Fv(bh4n4C$2`vj4I~;E7WZz&NjOy&JH^Z>8Z};VcDCa+r!5m-vAzYql|Bq zBxwE&qvpqqUH?Ag%zwlfE6g#r3U?Ww3w6eepo}+yYCBwHd*L~kB?>7l*! zgVKv&)0dJ%kJgI^FKy3K+EXuWZw1A(cn}f)0OyH@>cL%RelyI@v%GI-;=`Czzo!yO zB8#XMx1ExF7`MkeQm@a7n17V?%mq;fHE|QHi`(E>%z>o50jA_6Sd@1(TdKm#dF!9> zEj5D==G3%iZ$nK;cxb#9FSXO6|2`7D3$vy*9)QYN`3 z4e(><8ejMOg}1li#KIQ|K?yQQ(iI}T5@d467(sR+^-RE3_f)3vkM_*Fk4HNHNbr+% zl^K9HcE14GZjNLC diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java new file mode 100644 index 00000000..240437b7 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.category; + +import java.rmi.RemoteException; +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; + +/** + * Main application class + * + * @author Roland Haeder + */ +@Named("admin_category") +@SessionScoped +public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCategoryWebController { + /** + * Serial id + */ + private static final long serialVersionUID = 5_819_375_183_472_871L; + + /** + * Remote bean for categories + */ + private final CategorySessionBeanRemote category; + + /** + * Default constructor + * + * @throws javax.naming.NamingException Something happened here? + */ + public AdminCategoryWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup the bean + this.category = (CategorySessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + } + + @Override + public void doAdminAddCategory (final Category category) throws FaceletException { + try { + // Deligate to bean + this.category.doAdminAddCategory(category); + } catch (final RemoteException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java new file mode 100644 index 00000000..c38dcdb5 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.category; + +import javax.faces.view.facelets.FaceletException; +import org.mxchange.jshopcore.model.category.Category; + +/** + * An interface for product controllers for "ADMIN" role + * + * @author Roland Haeder + */ +public interface AdminCategoryWebController { + + /** + * Adds given category data from request to database + * + * @param category Category instance + * @throws javax.faces.view.facelets.FaceletException If something unexpected happened + */ + public void doAdminAddCategory (final Category category) throws FaceletException; +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java new file mode 100644 index 00000000..0792c6b8 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.product; + +import java.rmi.RemoteException; +import java.util.Deque; +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.product.Product; +import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; + +/** + * Main application class + * + * @author Roland Haeder + */ +@Named("admin_product") +@SessionScoped +public class AdminProductWebBean extends BaseFrameworkBean implements AdminProductWebController { + /** + * Serial id + */ + private static final long serialVersionUID = 5_819_375_183_472_871L; + + /** + * Remote bean for products + */ + private final ProductSessionBeanRemote product; + + /** + * Default constructor + * + * @throws javax.naming.NamingException Something happened here? + */ + public AdminProductWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup the bean + this.product = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + } + + @Override + public void doAdminAddProduct (final Product product) throws FaceletException { + // Call bean + this.product.doAdminAddProduct(product); + } + + @Override + public Deque getAllProducts () throws FaceletException { + try { + // Call bean + return this.product.getAllProducts(); + } catch (final RemoteException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java similarity index 79% rename from src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java rename to src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java index 6000979c..a77b18db 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/AdminProductWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java @@ -14,11 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.pizzaapplication.beans.controller; +package org.mxchange.pizzaapplication.beans.product; import java.util.Deque; import javax.faces.view.facelets.FaceletException; -import org.mxchange.jshopcore.model.category.Category; import org.mxchange.jshopcore.model.product.Product; /** @@ -28,14 +27,6 @@ import org.mxchange.jshopcore.model.product.Product; */ public interface AdminProductWebController { - /** - * Adds given category data from request to database - * - * @param category Category instance - * @throws javax.faces.view.facelets.FaceletException If something unexpected happened - */ - public void doAdminAddCategory (final Category category) throws FaceletException; - /** * Adds given product data from request to database * -- 2.39.2