2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.controller;
19 import java.io.IOException;
20 import java.lang.reflect.InvocationTargetException;
21 import java.rmi.RemoteException;
22 import java.sql.SQLException;
23 import java.text.MessageFormat;
24 import java.util.Deque;
25 import java.util.Iterator;
26 import javax.annotation.PostConstruct;
27 import javax.enterprise.context.SessionScoped;
28 import javax.faces.FacesException;
29 import javax.inject.Named;
30 import org.mxchange.jshop.beans.BaseFrameworkBean;
31 import org.mxchange.jshop.category.Category;
32 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
33 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
34 import org.mxchange.jshop.item.AddableBasketItem;
35 import org.mxchange.jshop.product.Product;
36 import org.mxchange.pizzaapplication.application.PizzaApplication;
37 import org.mxchange.pizzaapplication.application.PizzaServiceApplication;
40 * Main application class
42 * @author Roland Haeder
46 public class PizzaServiceBean extends BaseFrameworkBean implements PizzaBean {
50 private static final long serialVersionUID = 58137539530279L;
55 private final PizzaApplication app;
61 // Get new application instance
62 this.getLogger().debug("INITIALIZER!"); //NOI18N
63 this.app = new PizzaServiceApplication();
69 public PizzaServiceBean () {
70 this.getLogger().trace("CALLED!"); //NOI18N
75 public void init () throws FacesException {
77 this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", this.getApplication())); //NOI18N
80 if (this.getApplication() == null) {
82 throw new NullPointerException("application is null"); //NOI18N
88 } catch (final SQLException | IOException ex) {
90 throw new FacesException(ex);
96 public String getPrintableProductAvailability (final Product product) {
97 return this.app.getPrintableProductAvailability(product);
101 public Iterator<Product> getAvailableProductsIterator () throws RemoteException {
103 return this.app.getAvailableProductsIterator();
104 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
106 throw new RemoteException("getAvailableProductsIterator() failed", ex);
111 public Iterator<Product> getAllProductsIterator () throws RemoteException {
113 return this.app.getAllProductsIterator();
114 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
116 throw new RemoteException("getAllProductsIterator() failed.", ex);
121 public Deque<Product> getAvailableProducts () throws RemoteException {
123 return this.app.getAvailableProducts();
124 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
126 throw new RemoteException("getAvailableProducts() failed.", ex);
131 public Deque<Product> getAllProducts () throws RemoteException {
133 return this.app.getAllProducts();
134 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
136 throw new RemoteException("getAllProducts() failed", ex);
141 public Iterator<Category> getAllCategoriesIterator () throws RemoteException {
143 return this.app.getAllCategoriesIterator();
144 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
146 throw new RemoteException("getAllCategoriesIterator() failed.", ex);
151 public Deque<Category> getAllCategories () throws RemoteException {
153 return this.app.getAllCategories();
154 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
156 throw new RemoteException("getAllCategories() failed.", ex);
161 public void doAdminAddCategory (final Category category) throws RemoteException, CategoryTitleAlreadyUsedException {
163 this.app.doAdminAddCategory(category);
164 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
166 throw new RemoteException("doAdminAddCategory() failed.", ex);
171 public void doAdminAddProduct (final Product product) throws RemoteException, ProductTitleAlreadyUsedException {
173 this.app.doAdminAddProduct(product);
174 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
176 throw new RemoteException("doAdminAddProduct() failed.", ex);
182 public String getPrintableProduktCategory (final Product product) throws RemoteException {
184 return this.app.getPrintableProductCategory(product);
185 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
187 throw new RemoteException("getPrintableProduktCategory() failed.", ex);
193 public void doAdminHandleProductForms () throws RemoteException {
194 // Deprecated method called
195 throw new UnsupportedOperationException("Deprecated method called");
200 public void doAdminHandleCategoryForms () throws RemoteException {
201 // Deprecated method called
202 throw new UnsupportedOperationException("Deprecated method called");
207 public String generateLinkForParent (final Category category) {
209 return this.app.generateLinkForParent(category);