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
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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<roland@mxchange.org>
- */
-@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<Product> availableProducts;
-
- /**
- * All categories
- */
- private List<Category> 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<Category> getAllCategories () throws FacesException {
- // Return it
- // TODO Find something better here to prevent warning
- return Collections.unmodifiableList(this.categories);
- }
-
- @Override
- public List<Category> getAllCategoriesParent () throws FaceletException {
- // Get regular list
- List<Category> 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<Product> getAvailableProducts () throws FacesException {
- // Return it
- // TODO Find something better here to prevent warning
- return Collections.unmodifiableList(this.availableProducts);
- }
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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<roland@mxchange.org>
- */
-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<Product> 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<Category> 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<Category> getAllCategoriesParent () throws FaceletException;
-}
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
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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<roland@mxchange.org>
+ */
+@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<Product> availableProducts;
+
+ /**
+ * All categories
+ */
+ private List<Category> 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<Category> getAllCategories () throws FacesException {
+ // Return it
+ // TODO Find something better here to prevent warning
+ return Collections.unmodifiableList(this.categories);
+ }
+
+ @Override
+ public List<Category> getAllCategoriesParent () throws FaceletException {
+ // Get regular list
+ List<Category> 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<Product> getAvailableProducts () throws FacesException {
+ // Return it
+ // TODO Find something better here to prevent warning
+ return Collections.unmodifiableList(this.availableProducts);
+ }
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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<roland@mxchange.org>
+ */
+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<Product> 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<Category> 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<Category> getAllCategoriesParent () throws FaceletException;
+}