]> git.mxchange.org Git - jfinancials-ejb.git/blob
eb2c95430840dcccfa37c747795b345580f1d153
[jfinancials-ejb.git] /
1 /*
2  * Copyright (C) 2017, 2020 Free Software Foundation
3  *
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.
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 Affero General Public License for more details.
13  *
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/>.
16  */
17 package org.mxchange.jcontactsbusiness.model.opening_time;
18
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import javax.ejb.Stateless;
22 import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
23
24 /**
25  * A stateless session bean for administrative opening times purposes
26  * <p>
27  * @author Roland Häder<roland@mxchange.org>
28  */
29 @Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times")
30 public class FinancialsAdminOpeningTimesSessionBean extends BaseFinancialsEnterpriseBean implements AdminOpeningTimeSessionBeanRemote {
31
32         /**
33          * Serial number
34          */
35         private static final long serialVersionUID = 58_467_386_571_701L;
36
37         /**
38          * Default constructor
39          */
40         public FinancialsAdminOpeningTimesSessionBean () {
41                 // Call super constructor
42                 super();
43         }
44
45         @Override
46         public OpeningTime addOpeningTime (final OpeningTime openingTime) {
47                 // Trace message
48                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime={1} - CALLED!", this.getClass().getSimpleName(), openingTime)); //NOI18N
49
50                 // Validate parameter
51                 if (null == openingTime) {
52                         // Throw NPE
53                         throw new NullPointerException("openingTime is null"); //NOI18N
54                 } else if (openingTime.getOpeningId() instanceof Long) {
55                         // Should not happen
56                         throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
57                 } else if (openingTime.getOpeningStartDay()== null) {
58                         // Throw NPE
59                         throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
60                 } else if (openingTime.getOpeningStartTime()== null) {
61                         // Throw NPE
62                         throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
63                 } else if (openingTime.getOpeningEndDay()== null) {
64                         // Throw NPE
65                         throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
66                 } else if (openingTime.getOpeningEndTime()== null) {
67                         // Throw NPE
68                         throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
69                 }
70
71                 // Set created timestamp
72                 openingTime.setOpeningCreated(new Date());
73
74                 // Persist it
75                 this.getEntityManager().persist(openingTime);
76
77                 // Trace message
78                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime.openingId={1} - EXIT!", this.getClass().getSimpleName(), openingTime.getOpeningId())); //NOI18N
79
80                 // Return updated instance
81                 return openingTime;
82         }
83
84 }