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