2 * Copyright (C) 2017 - 2022 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (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 Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jfinancials.beans.business.opening_time;
19 import java.util.Date;
21 import javax.enterprise.context.RequestScoped;
22 import javax.enterprise.event.Event;
23 import javax.enterprise.inject.Any;
24 import javax.inject.Inject;
25 import javax.inject.Named;
26 import org.mxchange.jcontactsbusiness.events.opening_time.added.ObservableOpeningTimeAddedEvent;
27 import org.mxchange.jcontactsbusiness.events.opening_time.added.OpeningTimeAddedEvent;
28 import org.mxchange.jcontactsbusiness.model.opening_time.AdminOpeningTimeSessionBeanRemote;
29 import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
30 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
31 import org.mxchange.jcoreee.dates.DayOfTheWeek;
32 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
35 * An administrative bean for openingTimes
37 * @author Roland Häder<roland@mxchange.org>
39 @Named ("adminOpeningTimeController")
41 public class FinancialsAdminOpeningTimeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminOpeningTimeWebRequestController {
46 private static final long serialVersionUID = 5_028_697_360_463L;
49 * EJB for administrative purposes
51 @EJB (lookup = "java:global/jfinancials-ejb/adminOpeningTimes!org.mxchange.jcontactsbusiness.model.opening_time.AdminOpeningTimeSessionBeanRemote")
52 private AdminOpeningTimeSessionBeanRemote adminOpeningTimeBean;
57 private DayOfTheWeek openingEndDay;
62 private Date openingEndTime;
67 private DayOfTheWeek openingStartDay;
72 private Date openingStartTime;
75 * An event being fired when a openingTime has been successfully added
79 private Event<ObservableOpeningTimeAddedEvent> openingTimeAddedEvent;
84 public FinancialsAdminOpeningTimeWebRequestBean () {
85 // Call super constructor
90 * Adds openingTime with all data from this backing bean. First this action
91 * method will validate if the openingTime's address is already registered
92 * and if found, it will output a proper faces message.
94 public void addOpeningTime () {
96 final OpeningTime openingTime = this.createOpeningTimes();
98 // Call EJB and return updated instance
99 final OpeningTime updatedOpeningTimes = this.adminOpeningTimeBean.addOpeningTime(openingTime);
102 this.openingTimeAddedEvent.fire(new OpeningTimeAddedEvent(updatedOpeningTimes));
106 * Getter for ending week day
108 * @return Ending week day
110 public DayOfTheWeek getOpeningEndDay () {
111 return this.openingEndDay;
115 * Setter for ending week day
117 * @param openingEndDay Ending week day
119 public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
120 this.openingEndDay = openingEndDay;
124 * Getter for ending time
126 * @return Ending time
128 @SuppressWarnings ("ReturnOfDateField")
129 public Date getOpeningEndTime () {
130 return this.openingEndTime;
134 * Getter for ending time
136 * @param openingEndTime Ending time
138 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
139 public void setOpeningEndTime (final Date openingEndTime) {
140 this.openingEndTime = openingEndTime;
144 * Getter for starting week day
146 * @return Starting week day
148 public DayOfTheWeek getOpeningStartDay () {
149 return this.openingStartDay;
153 * Getter for starting week day
155 * @param openingStartDay Starting week day
157 public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
158 this.openingStartDay = openingStartDay;
162 * Getter for starting time
164 * @return Starting time
166 @SuppressWarnings ("ReturnOfDateField")
167 public Date getOpeningStartTime () {
168 return this.openingStartTime;
172 * Getter for starting time
174 * @param openingStartTime Starting time
176 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
177 public void setOpeningStartTime (final Date openingStartTime) {
178 this.openingStartTime = openingStartTime;
182 * Prepares an instance of a OpeningTimes object (entity) with all data from
183 * this bean. If a complete fax number or land-line number was provided, it
184 * will be set in the instance as well.
186 * @return An instance of a OpeningTimes class (entity)
188 private OpeningTime createOpeningTimes () {
189 // Create new openingTime instance
190 final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime());
192 // Return fully prepared instance