]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceBean.java
Removed even more deprecated/unused methods
[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.sql.SQLException;
21 import java.text.MessageFormat;
22 import java.util.Deque;
23 import java.util.Iterator;
24 import javax.annotation.PostConstruct;
25 import javax.enterprise.context.SessionScoped;
26 import javax.faces.FacesException;
27 import javax.inject.Named;
28 import javax.servlet.ServletException;
29 import javax.servlet.ServletRequest;
30 import javax.servlet.http.HttpSession;
31 import org.mxchange.jcore.exceptions.BadTokenException;
32 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
33 import org.mxchange.jshop.beans.BaseFrameworkBean;
34 import org.mxchange.jshop.category.Category;
35 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
36 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
37 import org.mxchange.jshop.item.AddableBasketItem;
38 import org.mxchange.jshop.product.Product;
39 import org.mxchange.pizzaapplication.application.PizzaApplication;
40 import org.mxchange.pizzaapplication.application.PizzaServiceApplication;
41
42 /**
43  * Main application class
44  *
45  * @author Roland Haeder
46  */
47 @Named("controller")
48 @SessionScoped
49 public class PizzaServiceBean extends BaseFrameworkBean implements PizzaBean {
50         /**
51          * Serial id
52          */
53         private static final long serialVersionUID = 58137539530279L;
54
55         /**
56          * Pizza application
57          */
58         private final PizzaApplication app;
59
60         /**
61          * Initializer block
62          */
63         {
64                 // Get new application instance
65                 this.getLogger().debug("INITIALIZER!"); //NOI18N
66                 this.app = new PizzaServiceApplication();
67         }
68
69         /**
70          * Default constructor
71          */
72         public PizzaServiceBean () {
73                 this.getLogger().trace("CALLED!"); //NOI18N
74         }
75
76         @Override
77         @PostConstruct
78         public void init () throws FacesException {
79                 // Trace message
80                 this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", this.getApplication())); //NOI18N
81
82                 // Must not be null
83                 if (this.getApplication() == null) {
84                         // Abort here
85                         throw new NullPointerException("application is null"); //NOI18N
86                 }
87
88                 try {
89                         // Call init method
90                         this.app.init(this.getApplication());
91                 } catch (final UnsupportedDatabaseBackendException | SQLException | IOException | BadTokenException ex) {
92                         // Continue to throw
93                         throw new FacesException(ex);
94                 }
95         }
96
97         @Override
98         public String getPrintableProduktAvailability (final Product product) {
99                 return this.app.getPrintableProduktAvailability(product);
100         }
101
102         @Override
103         public Iterator<Product> getAvailableProductsIterator () throws ServletException {
104                 return this.app.getAvailableProductsIterator();
105         }
106
107         @Override
108         public Iterator<Product> getAllProductsIterator () throws ServletException {
109                 return this.app.getAllProductsIterator();
110         }
111
112         @Override
113         public Deque<Product> getAvailableProducts () throws ServletException {
114                 return this.app.getAvailableProducts();
115         }
116
117         @Override
118         public Deque<Product> getAllProducts () throws ServletException {
119                 return this.app.getAllProducts();
120         }
121
122         @Override
123         public Iterator<Category> getAllCategoriesIterator () throws ServletException {
124                 return this.app.getAllCategoriesIterator();
125         }
126
127         @Override
128         public Deque<Category> getAllCategories () throws ServletException {
129                 return this.app.getAllCategories();
130         }
131
132         @Override
133         public void doAdminAddCategory (final ServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException {
134                 this.app.doAdminAddCategory(request);
135         }
136
137         @Override
138         public void doAdminAddProduct (final ServletRequest request) throws ServletException, ProductTitleAlreadyUsedException {
139                 this.app.doAdminAddProduct(request);
140         }
141
142         @Override
143         public String getPrintableProduktCategory (final Product product) throws ServletException {
144                 return this.app.getPrintableProduktCategory(product);
145         }
146
147         @Override
148         public void doAdminHandleProductForms () throws ServletException {
149                 this.app.doAdminHandleProductForms(this.getRequest(), this.getResponse());
150         }
151
152         @Override
153         public void doAdminHandleCategoryForms () throws ServletException {
154                 this.app.doAdminHandleCategoryForms(this.getRequest(), this.getResponse());
155         }
156
157         @Override
158         public Product getProduct (final AddableBasketItem item) throws ServletException {
159                 // Deligate to application
160                 return this.app.getProduct(item);
161         }
162 }