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.jcontactsbusiness.model.opening_time;
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import javax.ejb.Stateless;
22 import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
25 * A stateless session bean for administrative opening times purposes
27 * @author Roland Häder<roland@mxchange.org>
29 @Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times")
30 public class FinancialsAdminOpeningTimesSessionBean extends BaseFinancialsEnterpriseBean implements AdminOpeningTimeSessionBeanRemote {
35 private static final long serialVersionUID = 58_467_386_571_709L;
40 public FinancialsAdminOpeningTimesSessionBean () {
41 // Call super constructor
46 public OpeningTime addOpeningTime (final OpeningTime openingTime) {
48 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime={1} - CALLED!", this.getClass().getSimpleName(), openingTime)); //NOI18N
51 if (null == openingTime) {
53 throw new NullPointerException("openingTime is null"); //NOI18N
54 } else if (openingTime.getOpeningTimeId() instanceof Long) {
56 throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
57 } else if (openingTime.getOpeningStartDay() == null) {
59 throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
60 } else if (openingTime.getOpeningStartTime() == null) {
62 throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
63 } else if (openingTime.getOpeningEndDay() == null) {
65 throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
66 } else if (openingTime.getOpeningEndTime() == null) {
68 throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
71 // Set created timestamp
72 openingTime.setOpeningTimeEntryCreated(new Date());
75 this.getEntityManager().persist(openingTime);
78 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime.openingId={1} - EXIT!", this.getClass().getSimpleName(), openingTime.getOpeningTimeId())); //NOI18N
80 // Return updated instance