From: Roland Haeder Date: Thu, 24 Sep 2015 09:19:48 +0000 (+0200) Subject: renamed package to proper name X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4d60205d13f87484e11292add4491e3171685d28;p=pizzaservice-war.git renamed package to proper name Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java index 5531c0c7..687ada65 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java @@ -28,7 +28,7 @@ import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.jshopcore.model.category.AdminCategorySessionBeanRemote; import org.mxchange.jshopcore.model.category.Category; import org.mxchange.jshopcore.model.category.ProductCategory; -import org.mxchange.pizzaapplication.beans.controller.ShopWebController; +import org.mxchange.pizzaapplication.beans.shop.ShopWebController; /** * Main application class diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java deleted file mode 100644 index c151a605..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.controller; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.faces.FacesException; -import javax.faces.view.facelets.FaceletException; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcoreee.BaseEeSystem; -import org.mxchange.jshopcore.model.category.Category; -import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; -import org.mxchange.jshopcore.model.category.ProductCategory; -import org.mxchange.jshopcore.model.product.Product; -import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; - -/** - * General shop controller - * - * @author Roland Haeder - */ -@Named("controller") -@ApplicationScoped -public class ShopWebBean extends BaseEeSystem implements ShopWebController { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_137_539_530_279L; - - /** - * "Cache" for all available products - */ - private List availableProducts; - - /** - * All categories - */ - private List categories; - - @Override - public void addCategory (final Category category) { - // Add the category - this.categories.add(category); - } - - @Override - public void addProduct (final Product product) { - // Is the product available? - if (product.getAvailable()) { - // Add it - this.availableProducts.add(product); - } - } - - @PostConstruct - public void init () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N - - // Get all categories - this.categories = categoryBean.getAllCategories(); - - // Try to lookup the bean - ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N - - // Get available products list - this.availableProducts = productBean.getAvailableProducts(); - } catch (final NamingException e) { - // Continued to throw - throw new FacesException(e); - } - } - - @Override - public List getAllCategories () throws FacesException { - // Return it - // TODO Find something better here to prevent warning - return Collections.unmodifiableList(this.categories); - } - - @Override - public List getAllCategoriesParent () throws FaceletException { - // Get regular list - List deque = new LinkedList<>(); - - // Create fake entry - Category fake = new ProductCategory(0L, this.getMessageStringFromKey("ADMIN_CATEGORY_HAS_NO_PARENT"), 0L); //NOI18N - - // Add it - deque.add(fake); - - // Add all - deque.addAll(this.getAllCategories()); - - // Return it - return deque; - } - - @Override - public List getAvailableProducts () throws FacesException { - // Return it - // TODO Find something better here to prevent warning - return Collections.unmodifiableList(this.availableProducts); - } -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java deleted file mode 100644 index 61bd49b7..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.controller; - -import java.io.Serializable; -import java.util.List; -import javax.faces.view.facelets.FaceletException; -import org.mxchange.jshopcore.model.category.Category; -import org.mxchange.jshopcore.model.product.Product; - -/** - * An interface for the shop - * - * @author Roland Haeder - */ -public interface ShopWebController extends Serializable { - - /** - * Adds given category to the "cached" instance - * - * @param category Category instance - */ - public void addCategory (final Category category); - - /** - * Adds given product to the "cached" instance - * - * @param product Product instance - */ - public void addProduct (final Product product); - - /** - * Some "getter" for a linked list of only available products - * - * @return Only available products - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public List getAvailableProducts () throws FaceletException; - - /** - * Some "getter" for a linked list of all categories - * - * @return All categories - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public List getAllCategories () throws FaceletException; - - /** - * Some "getter" for a linked list of all categories including "Has no - * parent" fake category. - * - * @return All categories - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public List getAllCategoriesParent () throws FaceletException; -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java index fcd1a531..0b0645a8 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java @@ -29,7 +29,7 @@ import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException; import org.mxchange.jshopcore.model.product.AdminProductSessionBeanRemote; import org.mxchange.jshopcore.model.product.GenericProduct; import org.mxchange.jshopcore.model.product.Product; -import org.mxchange.pizzaapplication.beans.controller.ShopWebController; +import org.mxchange.pizzaapplication.beans.shop.ShopWebController; /** * Main application class diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java new file mode 100644 index 00000000..172c4bc6 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java @@ -0,0 +1,130 @@ +/* + * 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.shop; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.faces.FacesException; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.BaseEeSystem; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; +import org.mxchange.jshopcore.model.category.ProductCategory; +import org.mxchange.jshopcore.model.product.Product; +import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; + +/** + * General shop controller + * + * @author Roland Haeder + */ +@Named("controller") +@ApplicationScoped +public class ShopWebBean extends BaseEeSystem implements ShopWebController { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_137_539_530_279L; + + /** + * "Cache" for all available products + */ + private List availableProducts; + + /** + * All categories + */ + private List categories; + + @Override + public void addCategory (final Category category) { + // Add the category + this.categories.add(category); + } + + @Override + public void addProduct (final Product product) { + // Is the product available? + if (product.getAvailable()) { + // Add it + this.availableProducts.add(product); + } + } + + @PostConstruct + public void init () { + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the bean + CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N + + // Get all categories + this.categories = categoryBean.getAllCategories(); + + // Try to lookup the bean + ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + + // Get available products list + this.availableProducts = productBean.getAvailableProducts(); + } catch (final NamingException e) { + // Continued to throw + throw new FacesException(e); + } + } + + @Override + public List getAllCategories () throws FacesException { + // Return it + // TODO Find something better here to prevent warning + return Collections.unmodifiableList(this.categories); + } + + @Override + public List getAllCategoriesParent () throws FaceletException { + // Get regular list + List deque = new LinkedList<>(); + + // Create fake entry + Category fake = new ProductCategory(0L, this.getMessageStringFromKey("ADMIN_CATEGORY_HAS_NO_PARENT"), 0L); //NOI18N + + // Add it + deque.add(fake); + + // Add all + deque.addAll(this.getAllCategories()); + + // Return it + return deque; + } + + @Override + public List getAvailableProducts () throws FacesException { + // Return it + // TODO Find something better here to prevent warning + return Collections.unmodifiableList(this.availableProducts); + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.java new file mode 100644 index 00000000..efdadb28 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.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.shop; + +import java.io.Serializable; +import java.util.List; +import javax.faces.view.facelets.FaceletException; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.product.Product; + +/** + * An interface for the shop + * + * @author Roland Haeder + */ +public interface ShopWebController extends Serializable { + + /** + * Adds given category to the "cached" instance + * + * @param category Category instance + */ + public void addCategory (final Category category); + + /** + * Adds given product to the "cached" instance + * + * @param product Product instance + */ + public void addProduct (final Product product); + + /** + * Some "getter" for a linked list of only available products + * + * @return Only available products + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public List getAvailableProducts () throws FaceletException; + + /** + * Some "getter" for a linked list of all categories + * + * @return All categories + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public List getAllCategories () throws FaceletException; + + /** + * Some "getter" for a linked list of all categories including "Has no + * parent" fake category. + * + * @return All categories + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public List getAllCategoriesParent () throws FaceletException; +}