]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceBean.java
Cleanup (no longer used methods? maybe it will come back, who knows ...)
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / controller / PizzaServiceBean.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.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;
38
39 /**
40  * Main application class
41  *
42  * @author Roland Haeder
43  */
44 @Named("controller")
45 @SessionScoped
46 public class PizzaServiceBean extends BaseFrameworkBean implements PizzaBean {
47         /**
48          * Serial id
49          */
50         private static final long serialVersionUID = 58137539530279L;
51
52         /**
53          * Pizza application
54          */
55         private final PizzaApplication app;
56
57         /**
58          * Initializer block
59          */
60         {
61                 // Get new application instance
62                 this.getLogger().debug("INITIALIZER!"); //NOI18N
63                 this.app = new PizzaServiceApplication();
64         }
65
66         /**
67          * Default constructor
68          */
69         public PizzaServiceBean () {
70                 this.getLogger().trace("CALLED!"); //NOI18N
71         }
72
73         @Override
74         @PostConstruct
75         public void init () throws FacesException {
76                 // Trace message
77                 this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", this.getApplication())); //NOI18N
78
79                 // Must not be null
80                 if (this.getApplication() == null) {
81                         // Abort here
82                         throw new NullPointerException("application is null"); //NOI18N
83                 }
84
85                 try {
86                         // Call init method
87                         this.app.init();
88                 } catch (final SQLException | IOException ex) {
89                         // Continue to throw
90                         throw new FacesException(ex);
91                 }
92         }
93
94         @Override
95         @Deprecated
96         public String getPrintableProduktAvailability (final Product product) {
97                 return this.app.getPrintableProduktAvailability(product);
98         }
99
100         @Override
101         public Iterator<Product> getAvailableProductsIterator () throws RemoteException {
102                 try {
103                         return this.app.getAvailableProductsIterator();
104                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
105                         // Continue to throw
106                         throw new RemoteException("getAvailableProductsIterator() failed", ex);
107                 }
108         }
109
110         @Override
111         public Iterator<Product> getAllProductsIterator () throws RemoteException {
112                 try {
113                         return this.app.getAllProductsIterator();
114                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
115                         // Continue to throw
116                         throw new RemoteException("getAllProductsIterator() failed.", ex);
117                 }
118         }
119
120         @Override
121         public Deque<Product> getAvailableProducts () throws RemoteException {
122                 try {
123                         return this.app.getAvailableProducts();
124                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
125                         // Continue to throw
126                         throw new RemoteException("getAvailableProducts() failed.", ex);
127                 }
128         }
129
130         @Override
131         public Deque<Product> getAllProducts () throws RemoteException {
132                 try {
133                         return this.app.getAllProducts();
134                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
135                         // Continue to throw
136                         throw new RemoteException("getAllProducts() failed", ex);
137                 }
138         }
139
140         @Override
141         public Iterator<Category> getAllCategoriesIterator () throws RemoteException {
142                 try {
143                         return this.app.getAllCategoriesIterator();
144                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
145                         // Continue to throw
146                         throw new RemoteException("getAllCategoriesIterator() failed.", ex);
147                 }
148         }
149
150         @Override
151         public Deque<Category> getAllCategories () throws RemoteException {
152                 try {
153                         return this.app.getAllCategories();
154                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
155                         // Continue to throw
156                         throw new RemoteException("getAllCategories() failed.", ex);
157                 }
158         }
159
160         @Override
161         public void doAdminAddCategory (final Category category) throws RemoteException, CategoryTitleAlreadyUsedException {
162                 try {
163                         this.app.doAdminAddCategory(category);
164                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
165                         // Continue to throw
166                         throw new RemoteException("doAdminAddCategory() failed.", ex);
167                 }
168         }
169
170         @Override
171         public void doAdminAddProduct (final Product product) throws RemoteException, ProductTitleAlreadyUsedException {
172                 try {
173                         this.app.doAdminAddProduct(product);
174                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
175                         // Continue to throw
176                         throw new RemoteException("doAdminAddProduct() failed.", ex);
177                 }
178         }
179
180         @Override
181         @Deprecated
182         public String getPrintableProduktCategory (final Product product) throws RemoteException {
183                 try {
184                         return this.app.getPrintableProductCategory(product);
185                 } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
186                         // Continue to throw
187                         throw new RemoteException("getPrintableProduktCategory() failed.", ex);
188                 }
189         }
190
191         @Override
192         @Deprecated
193         public void doAdminHandleProductForms () throws RemoteException {
194                 // Deprecated method called
195                 throw new UnsupportedOperationException("Deprecated method called");
196         }
197
198         @Override
199         @Deprecated
200         public void doAdminHandleCategoryForms () throws RemoteException {
201                 // Deprecated method called
202                 throw new UnsupportedOperationException("Deprecated method called");
203         }
204
205         @Override
206         @Deprecated
207         public String generateLinkForParent (final Category category) {
208                 // Deligate to app
209                 return this.app.generateLinkForParent(category);
210         }
211 }