--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.opening_time;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.ejb.Stateless;
+import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+
+/**
+ * A stateless session bean for administrative opening times purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times")
+public class AddressbookAdminOpeningTimesSessionBean extends BaseAddressbookDatabaseBean implements AdminOpeningTimeSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_467_386_571_701L;
+
+ /**
+ * Default constructor
+ */
+ public AddressbookAdminOpeningTimesSessionBean () {
+ // Call super constructor
+ super();
+ }
+
+ @Override
+ public OpeningTime addOpeningTime (final OpeningTime openingTime) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime={1} - CALLED!", this.getClass().getSimpleName(), openingTime)); //NOI18N
+
+ // Validate parameter
+ if (null == openingTime) {
+ // Throw NPE
+ throw new NullPointerException("openingTime is null"); //NOI18N
+ } else if (openingTime.getOpeningId() instanceof Long) {
+ // Should not happen
+ throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
+ } else if (openingTime.getOpeningStartDay()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
+ } else if (openingTime.getOpeningStartTime()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
+ } else if (openingTime.getOpeningEndDay()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
+ } else if (openingTime.getOpeningEndTime()== null) {
+ // Throw NPE
+ throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
+ }
+
+ // Set created timestamp
+ openingTime.setOpeningCreated(new Date());
+
+ // Persist it
+ this.getEntityManager().persist(openingTime);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addOpeningTimes(): openingTime.openingId={1} - EXIT!", this.getClass().getSimpleName(), openingTime.getOpeningId())); //NOI18N
+
+ // Return updated instance
+ return openingTime;
+ }
+
+}