]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java
Renaming season is not yet over ... ;-)
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / controller / PizzaServiceWebBean.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.pizzaapplication.beans.controller;
18
19 import java.io.IOException;
20 import java.lang.reflect.InvocationTargetException;
21 import java.rmi.RemoteException;
22 import java.sql.SQLException;
23 import java.util.Deque;
24 import java.util.Iterator;
25 import javax.annotation.PostConstruct;
26 import javax.enterprise.context.SessionScoped;
27 import javax.faces.FacesException;
28 import javax.inject.Named;
29 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
30 import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
31 import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
32 import org.mxchange.jshopcore.model.category.Category;
33 import org.mxchange.jshopcore.model.product.Product;
34
35 /**
36  * Main application class
37  *
38  * @author Roland Haeder
39  */
40 @Named("controller")
41 @SessionScoped
42 public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBean {
43         /**
44          * Serial id
45          */
46         private static final long serialVersionUID = 58137539530279L;
47
48         /**
49          * Initializer block
50          */
51         {
52                 // Get new application instance
53                 this.getLogger().debug("INITIALIZER!"); //NOI18N
54         }
55
56         /**
57          * Default constructor
58          */
59         public PizzaServiceWebBean () {
60                 this.getLogger().trace("CALLED!"); //NOI18N
61         }
62
63         @Override
64         @PostConstruct
65         public void init () throws FacesException {
66                 // Trace message
67                 this.getLogger().trace("CALLED!"); //NOI18N
68
69                 // Super call
70                 super.init();
71
72                 try {
73                         // Call init method
74                         this.app.init();
75                 } catch (final SQLException | IOException ex) {
76                         // Continue to throw
77                         throw new FacesException(ex);
78                 }
79         }
80
81         @Override
82         public Iterator<Product> getAvailableProductsIterator () throws RemoteException {
83                 try {
84                         return this.app.getAvailableProductsIterator();
85                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
86                         // Continue to throw
87                         throw new RemoteException("getAvailableProductsIterator() failed", ex);
88                 }
89         }
90
91         @Override
92         public Iterator<Product> getAllProductsIterator () throws RemoteException {
93                 try {
94                         return this.app.getAllProductsIterator();
95                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
96                         // Continue to throw
97                         throw new RemoteException("getAllProductsIterator() failed.", ex);
98                 }
99         }
100
101         @Override
102         public Deque<Product> getAvailableProducts () throws RemoteException {
103                 try {
104                         return this.app.getAvailableProducts();
105                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
106                         // Continue to throw
107                         throw new RemoteException("getAvailableProducts() failed.", ex);
108                 }
109         }
110
111         @Override
112         public Deque<Product> getAllProducts () throws RemoteException {
113                 try {
114                         return this.app.getAllProducts();
115                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
116                         // Continue to throw
117                         throw new RemoteException("getAllProducts() failed", ex);
118                 }
119         }
120
121         @Override
122         public Iterator<Category> getAllCategoriesIterator () throws RemoteException {
123                 try {
124                         return this.app.getAllCategoriesIterator();
125                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
126                         // Continue to throw
127                         throw new RemoteException("getAllCategoriesIterator() failed.", ex);
128                 }
129         }
130
131         @Override
132         public Deque<Category> getAllCategories () throws RemoteException {
133                 try {
134                         return this.app.getAllCategories();
135                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
136                         // Continue to throw
137                         throw new RemoteException("getAllCategories() failed.", ex);
138                 }
139         }
140
141         @Override
142         public void doAdminAddCategory (final Category category) throws RemoteException, CategoryTitleAlreadyUsedException {
143                 try {
144                         this.app.doAdminAddCategory(category);
145                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
146                         // Continue to throw
147                         throw new RemoteException("doAdminAddCategory() failed.", ex);
148                 }
149         }
150
151         @Override
152         public void doAdminAddProduct (final Product product) throws RemoteException, ProductTitleAlreadyUsedException {
153                 try {
154                         this.app.doAdminAddProduct(product);
155                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
156                         // Continue to throw
157                         throw new RemoteException("doAdminAddProduct() failed.", ex);
158                 }
159         }
160 }