]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued (renaming-season has started):
authorRoland Häder <roland@mxchange.org>
Sat, 7 Oct 2017 22:17:52 +0000 (00:17 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Oct 2017 22:17:52 +0000 (00:17 +0200)
- renamed OpeningTimes -> OpeningTime as it is a single entity anyway
- also renamed package opening_times -> opening_time
- add event for when an opening time has been added

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
src/org/mxchange/jcontactsbusiness/events/opening_time/added/ObservableOpeningTimeAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/events/opening_time/added/OpeningTimeAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/exceptions/opening_time/OpeningTimeNotFoundException.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/exceptions/opening_times/OpeningTimesNotFoundException.java [deleted file]
src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java
src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/model/opening_time/OpeningTime.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/model/opening_time/dayofweek/DayOfTheWeek.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/model/opening_times/BusinessOpeningTimes.java [deleted file]
src/org/mxchange/jcontactsbusiness/model/opening_times/OpeningTimes.java [deleted file]
src/org/mxchange/jcontactsbusiness/model/opening_times/dayofweek/DayOfTheWeek.java [deleted file]

diff --git a/src/org/mxchange/jcontactsbusiness/events/opening_time/added/ObservableOpeningTimeAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/opening_time/added/ObservableOpeningTimeAddedEvent.java
new file mode 100644 (file)
index 0000000..116ed21
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.opening_time.added;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+
+/**
+ * An interface for events being triggered when a opening time has been added.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableOpeningTimeAddedEvent extends Serializable {
+
+       /**
+        * Getter for opening time instance
+        * <p>
+        * @return OpeningTime instance
+        */
+       OpeningTime getOpeningTime ();
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/events/opening_time/added/OpeningTimeAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/opening_time/added/OpeningTimeAddedEvent.java
new file mode 100644 (file)
index 0000000..0d53faf
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.opening_time.added;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+
+/**
+ * An event being fired when a openingTime has been added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class OpeningTimeAddedEvent implements ObservableOpeningTimeAddedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 572_367_561_659_111L;
+
+       /**
+        * Branch office instance being added
+        */
+       private final OpeningTime openingTime;
+
+       /**
+        * Constructor with opening time instance
+        * <p>
+        * @param openingTime Branch office instance
+        * @throws NullPointerException If the parameter is null
+        */
+       public OpeningTimeAddedEvent (final OpeningTime openingTime) {
+               // Check parameter
+               if (null == openingTime) {
+                       // Throw NPE
+                       throw new NullPointerException("openingTime is null"); //NOI18N
+               } else if (openingTime.getOpeningId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("openingTime.openingId is null"); //NOI18N
+               } else if (openingTime.getOpeningId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("openingTime.openingId={0} is not valid", openingTime.getOpeningId())); //NOI18N
+               }
+
+               // Set it
+               this.openingTime = openingTime;
+       }
+
+       @Override
+       public OpeningTime getOpeningTime () {
+               return this.openingTime;
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/opening_time/OpeningTimeNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/opening_time/OpeningTimeNotFoundException.java
new file mode 100644 (file)
index 0000000..7fc610b
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.exceptions.opening_time;
+
+import java.text.MessageFormat;
+
+/**
+ * An exception thrown when an opening time (entity) has not found.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class OpeningTimeNotFoundException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 23_759_801_876_416_573L;
+
+       /**
+        * Constructor with opening time id
+        * <p>
+        * @param openingId Opening time id
+        */
+       public OpeningTimeNotFoundException (final Long openingId) {
+               // Call super constructor with message and cause
+               super(MessageFormat.format("Opening time with id {0} was not found.", openingId)); //NOI18N
+       }
+
+       /**
+        * Constructor with opening time id and causing exception
+        * <p>
+        * @param openingId Opening time id
+        * @param cause     Causing exception
+        */
+       public OpeningTimeNotFoundException (final Long openingId, final Throwable cause) {
+               // Call super constructor with message and cause
+               super(MessageFormat.format("Opening time with id {0} was not found.", openingId), cause); //NOI18N
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/opening_times/OpeningTimesNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/opening_times/OpeningTimesNotFoundException.java
deleted file mode 100644 (file)
index d232b27..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.exceptions.opening_times;
-
-import java.text.MessageFormat;
-
-/**
- * An exception thrown when an opening time (entity) has not found.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class OpeningTimesNotFoundException extends Exception {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 23_759_801_876_416_573L;
-
-       /**
-        * Constructor with opening time id
-        * <p>
-        * @param openingId Opening time id
-        */
-       public OpeningTimesNotFoundException (final Long openingId) {
-               // Call super constructor with message and cause
-               super(MessageFormat.format("Opening time with id {0} was not found.", openingId)); //NOI18N
-       }
-
-       /**
-        * Constructor with opening time id and causing exception
-        * <p>
-        * @param openingId Opening time id
-        * @param cause     Causing exception
-        */
-       public OpeningTimesNotFoundException (final Long openingId, final Throwable cause) {
-               // Call super constructor with message and cause
-               super(MessageFormat.format("Opening time with id {0} was not found.", openingId), cause); //NOI18N
-       }
-
-}
index 798316c54f4af23f3b0469ef4acbceb8a0d1ef7a..11eef9608cff2704dc69983c11ab472dbe324fc9 100644 (file)
@@ -21,11 +21,11 @@ import java.util.Date;
 import java.util.List;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.employee.Employee;
-import org.mxchange.jcontactsbusiness.model.opening_times.OpeningTimes;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 
 /**
  * A POJI for branch offices
@@ -165,14 +165,14 @@ public interface BranchOffice extends Serializable {
         * <p>
         * @return Opening times
         */
-       List<OpeningTimes> getBranchOpeningTimes ();
+       List<OpeningTime> getBranchOpeningTimes ();
 
        /**
         * Setter for opening times for this branch office
         * <p>
         * @param branchOpeningTimes Opening times
         */
-       void setBranchOpeningTimes (final List<OpeningTimes> branchOpeningTimes);
+       void setBranchOpeningTimes (final List<OpeningTime> branchOpeningTimes);
 
        /**
         * Getter for branch office owning employee
index e747688401082617e94597d9a86bebac0b4c2ed2..5db5c8d035501f578285f87751fe748c9857c017 100644 (file)
@@ -41,8 +41,8 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
 import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
 import org.mxchange.jcontactsbusiness.model.employee.Employee;
-import org.mxchange.jcontactsbusiness.model.opening_times.BusinessOpeningTimes;
-import org.mxchange.jcontactsbusiness.model.opening_times.OpeningTimes;
+import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
@@ -155,8 +155,8 @@ public class CompanyBranchOffice implements BranchOffice {
         * Opening times for this branch office
         */
        @JoinTable (name = "branch_opening_times", joinColumns = @JoinColumn(name = "branch_opening_id", referencedColumnName = "branch_id"), inverseJoinColumns = @JoinColumn(name = "opening_branch_id", referencedColumnName = "opening_times_id"))
-       @ManyToMany (targetEntity = BusinessOpeningTimes.class, cascade = CascadeType.REFRESH)
-       private List<OpeningTimes> branchOpeningTimes;
+       @ManyToMany (targetEntity = BusinessOpeningTime.class, cascade = CascadeType.REFRESH)
+       private List<OpeningTime> branchOpeningTimes;
 
        /**
         * Reference to branch office owner (for example some franchise supermarkets
@@ -421,12 +421,14 @@ public class CompanyBranchOffice implements BranchOffice {
        }
 
        @Override
-       public List<OpeningTimes> getBranchOpeningTimes () {
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<OpeningTime> getBranchOpeningTimes () {
                return this.branchOpeningTimes;
        }
 
        @Override
-       public void setBranchOpeningTimes (final List<OpeningTimes> branchOpeningTimes) {
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setBranchOpeningTimes (final List<OpeningTime> branchOpeningTimes) {
                this.branchOpeningTimes = branchOpeningTimes;
        }
 
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java
new file mode 100644 (file)
index 0000000..c794ea1
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.opening_time;
+
+import java.util.Date;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek;
+
+/**
+ * A POJO for business opening hours
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Entity (name = "company_opening_times")
+@Table (name = "company_opening_times")
+@NamedQueries (
+               {
+                       @NamedQuery (name = "AllOpeningTimes", query = "SELECT ot FROM company_opening_times AS ot ORDER BY ot.openingId ASC"),
+                       @NamedQuery (name = "SearchOpeningTimesById", query = "SELECT ot FROM company_opening_times AS ot WHERE ot.openingId = :openingId")
+               }
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class BusinessOpeningTime implements OpeningTime {
+
+       /**
+        * Serial number
+        */
+       @Transient
+       private static final long serialVersionUID = 19_578_871_756_871L;
+
+       /**
+        * When this opening time was created
+        */
+       @Basic(optional = false)
+       @Column(name = "opening_times_created", nullable = false, updatable = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       private Date openingCreated;
+
+       /**
+        * Ending day of opening hours (if applyable)
+        */
+       @Basic (optional = false)
+       @Column (name = "opening_times_end_day", nullable = false)
+       @Enumerated (EnumType.STRING)
+       private DayOfTheWeek openingEndDay;
+
+       /**
+        * Ending time (hh:mm)
+        */
+       @Basic (optional = false)
+       @Column (name = "opening_times_end_time", nullable = false)
+       @Temporal (TemporalType.TIME)
+       private Date openingEndTime;
+
+       /**
+        * Id number
+        */
+       @Id
+       @Column (name = "opening_times_id", nullable = false, updatable = false)
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       private Long openingId;
+
+       /**
+        * Starting day of opening times
+        */
+       @Basic (optional = false)
+       @Column (name = "opening_times_start_day", nullable = false)
+       @Enumerated (EnumType.STRING)
+       private DayOfTheWeek openingStartDay;
+
+       /**
+        * Starting time (hh:mm)
+        */
+       @Basic (optional = false)
+       @Column (name = "opening_times_start_time", nullable = false)
+       @Temporal (TemporalType.TIME)
+       private Date openingStartTime;
+
+       /**
+        * Default constructor
+        */
+       public BusinessOpeningTime () {
+       }
+
+       /**
+        * Constructor with all required fields except created timestamp
+        * <p>
+        * @param openingEndDay    End day
+        * @param openingEndTime   End time
+        * @param openingStartDay  Start day
+        * @param openingStartTime Start time
+        */
+       public BusinessOpeningTime (final DayOfTheWeek openingEndDay, final Date openingEndTime, final DayOfTheWeek openingStartDay, final Date openingStartTime) {
+               // Set all fields
+               this.openingEndDay = openingEndDay;
+               this.openingEndTime = openingEndTime;
+               this.openingStartDay = openingStartDay;
+               this.openingStartTime = openingStartTime;
+       }
+
+       @Override
+       public boolean equals (final Object obj) {
+               if (this == obj) {
+                       return true;
+               } else if (obj == null) {
+                       return false;
+               } else if (this.getClass() != obj.getClass()) {
+                       return false;
+               }
+
+               final OpeningTime openingTimes = (OpeningTime) obj;
+
+               if (!Objects.equals(this.getOpeningId(), openingTimes.getOpeningId())) {
+                       return false;
+               } else if (this.getOpeningStartDay() != openingTimes.getOpeningStartDay()) {
+                       return false;
+               } else if (this.getOpeningEndDay() != openingTimes.getOpeningEndDay()) {
+                       return false;
+               } else if (!Objects.equals(this.getOpeningStartTime(), openingTimes.getOpeningStartTime())) {
+                       return false;
+               } else if (!Objects.equals(this.getOpeningEndTime(), openingTimes.getOpeningEndTime())) {
+                       return false;
+               }
+
+               return true;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getOpeningCreated () {
+               return this.openingCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setOpeningCreated (final Date openingCreated) {
+               this.openingCreated = openingCreated;
+       }
+
+       @Override
+       public DayOfTheWeek getOpeningEndDay () {
+               return this.openingEndDay;
+       }
+
+       @Override
+       public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
+               this.openingEndDay = openingEndDay;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getOpeningEndTime () {
+               return this.openingEndTime;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setOpeningEndTime (final Date openingEndTime) {
+               this.openingEndTime = openingEndTime;
+       }
+
+       @Override
+       public Long getOpeningId () {
+               return this.openingId;
+       }
+
+       @Override
+       public void setOpeningId (final Long openingId) {
+               this.openingId = openingId;
+       }
+
+       @Override
+       public DayOfTheWeek getOpeningStartDay () {
+               return this.openingStartDay;
+       }
+
+       @Override
+       public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
+               this.openingStartDay = openingStartDay;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getOpeningStartTime () {
+               return this.openingStartTime;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setOpeningStartTime (final Date openingStartTime) {
+               this.openingStartTime = openingStartTime;
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 7;
+
+               hash = 97 * hash + Objects.hashCode(this.getOpeningId());
+               hash = 97 * hash + Objects.hashCode(this.getOpeningStartDay());
+               hash = 97 * hash + Objects.hashCode(this.getOpeningEndDay());
+               hash = 97 * hash + Objects.hashCode(this.getOpeningStartTime());
+               hash = 97 * hash + Objects.hashCode(this.getOpeningEndTime());
+
+               return hash;
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_time/OpeningTime.java b/src/org/mxchange/jcontactsbusiness/model/opening_time/OpeningTime.java
new file mode 100644 (file)
index 0000000..404c365
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.opening_time;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek;
+
+/**
+ * A POJI for opening times
+ *
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface OpeningTime extends Serializable {
+
+       /**
+        * Getter for opening time created timestamp
+        * <p>
+        * @return Opening time created timestamp
+        */
+       Date getOpeningCreated ();
+
+       /**
+        * Setter for opening time created timestamp
+        * <p>
+        * @param openingCreated Opening time created timestamp
+        */
+       void setOpeningCreated (final Date openingCreated);
+
+       /**
+        * Getter for id number
+        * <p>
+        * @return Id number
+        */
+       Long getOpeningId ();
+
+       /**
+        * Setter for id number
+        * <p>
+        * @param openingId Id number
+        */
+       void setOpeningId (final Long openingId);
+
+       /**
+        * Getter for starting day
+        * <p>
+        * @return Starting day
+        */
+       DayOfTheWeek getOpeningStartDay ();
+
+       /**
+        * Setter for starting day
+        * <p>
+        * @param openingStartDay Starting day
+        */
+       void setOpeningStartDay (final DayOfTheWeek openingStartDay);
+
+       /**
+        * Getter for ending day
+        * <p>
+        * @return Ending day
+        */
+       DayOfTheWeek getOpeningEndDay ();
+
+       /**
+        * Setter for ending day
+        * <p>
+        * @param openinhEndDay Ending day
+        */
+       void setOpeningEndDay (final DayOfTheWeek openinhEndDay);
+
+       /**
+        * Getter for starting time
+        * <p>
+        * @return Starting time
+        */
+       Date getOpeningStartTime ();
+
+       /**
+        * Setter for starting time
+        * <p>
+        * @param openingStartTime Starting time
+        */
+       void setOpeningStartTime (final Date openingStartTime);
+
+       /**
+        * Getter for ending time
+        * <p>
+        * @return Ending time
+        */
+       Date getOpeningEndTime ();
+
+       /**
+        * Setter for ending time
+        * <p>
+        * @param openingEndTime Ending time
+        */
+       void setOpeningEndTime (final Date openingEndTime);
+
+       @Override
+       boolean equals (final Object obj);
+
+       @Override
+       int hashCode ();
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_time/dayofweek/DayOfTheWeek.java b/src/org/mxchange/jcontactsbusiness/model/opening_time/dayofweek/DayOfTheWeek.java
new file mode 100644 (file)
index 0000000..d6a8f26
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.opening_time.dayofweek;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * An enumeration suitable for persisting
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public enum DayOfTheWeek {
+       SUNDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.SUNDAY;
+               }
+
+       },
+       MONDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.MONDAY;
+               }
+       },
+       TUESDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.TUESDAY;
+               }
+       },
+       WEDNESDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.WEDNESDAY;
+               }
+       },
+       THURSDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.THURSDAY;
+               }
+       },
+       FRIDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.FRIDAY;
+               }
+       },
+       SATURDAY {
+               @Override
+               public int toCalendar () {
+                       return Calendar.SATURDAY;
+               }
+       };
+
+       public abstract int toCalendar ();
+
+       public static DayOfTheWeek fromCalendarDay (final int day) {
+
+               for (DayOfTheWeek dayOfWeek : DayOfTheWeek.values()) {
+                       if (dayOfWeek.toCalendar() == day) {
+                               return dayOfWeek;
+                       }
+               }
+
+               return null; // Consider throwing IllegalArgumentException
+       }
+
+       public static DayOfTheWeek getByDate (final Date date) {
+               Calendar calendar = GregorianCalendar.getInstance();
+               calendar.setTime(date);
+               return fromCalendarDay(calendar.get(Calendar.DAY_OF_WEEK));
+       }
+
+       /*
+        * Should return the localized day of the week
+        */
+       @Override
+       public String toString () {
+               Calendar c = new GregorianCalendar();
+               c.set(Calendar.DAY_OF_WEEK, this.toCalendar());
+               SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat
+                                                .getInstance();
+               sdf.applyPattern("EEEEEEEEEE"); //NOI18N
+
+               return sdf.format(c.getTime());
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_times/BusinessOpeningTimes.java b/src/org/mxchange/jcontactsbusiness/model/opening_times/BusinessOpeningTimes.java
deleted file mode 100644 (file)
index b14dd50..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.opening_times;
-
-import java.util.Date;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import org.mxchange.jcontactsbusiness.model.opening_times.dayofweek.DayOfTheWeek;
-
-/**
- * A POJO for business opening hours
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Entity (name = "company_opening_times")
-@Table (name = "company_opening_times")
-@NamedQueries (
-               {
-                       @NamedQuery (name = "AllOpeningTimes", query = "SELECT ot FROM company_opening_times AS ot ORDER BY ot.openingId ASC"),
-                       @NamedQuery (name = "SearchOpeningTimesById", query = "SELECT ot FROM company_opening_times AS ot WHERE ot.openingId = :openingId")
-               }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class BusinessOpeningTimes implements OpeningTimes {
-
-       /**
-        * Serial number
-        */
-       @Transient
-       private static final long serialVersionUID = 19_578_871_756_871L;
-
-       /**
-        * When this opening time was created
-        */
-       @Basic(optional = false)
-       @Column(name = "opening_times_created", nullable = false, updatable = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       private Date openingCreated;
-
-       /**
-        * Ending day of opening hours (if applyable)
-        */
-       @Basic (optional = false)
-       @Column (name = "opening_times_end_day", nullable = false)
-       @Enumerated (EnumType.STRING)
-       private DayOfTheWeek openingEndDay;
-
-       /**
-        * Ending time (hh:mm)
-        */
-       @Basic (optional = false)
-       @Column (name = "opening_times_end_time", nullable = false)
-       @Temporal (TemporalType.TIME)
-       private Date openingEndTime;
-
-       /**
-        * Id number
-        */
-       @Id
-       @Column (name = "opening_times_id", nullable = false, updatable = false)
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       private Long openingId;
-
-       /**
-        * Starting day of opening times
-        */
-       @Basic (optional = false)
-       @Column (name = "opening_times_start_day", nullable = false)
-       @Enumerated (EnumType.STRING)
-       private DayOfTheWeek openingStartDay;
-
-       /**
-        * Starting time (hh:mm)
-        */
-       @Basic (optional = false)
-       @Column (name = "opening_times_start_time", nullable = false)
-       @Temporal (TemporalType.TIME)
-       private Date openingStartTime;
-
-       /**
-        * Default constructor
-        */
-       public BusinessOpeningTimes () {
-       }
-
-       /**
-        * Constructor with all required fields except created timestamp
-        * <p>
-        * @param openingEndDay    End day
-        * @param openingEndTime   End time
-        * @param openingStartDay  Start day
-        * @param openingStartTime Start time
-        */
-       public BusinessOpeningTimes (final DayOfTheWeek openingEndDay, final Date openingEndTime, final DayOfTheWeek openingStartDay, final Date openingStartTime) {
-               // Set all fields
-               this.openingEndDay = openingEndDay;
-               this.openingEndTime = openingEndTime;
-               this.openingStartDay = openingStartDay;
-               this.openingStartTime = openingStartTime;
-       }
-
-       @Override
-       public boolean equals (final Object obj) {
-               if (this == obj) {
-                       return true;
-               } else if (obj == null) {
-                       return false;
-               } else if (this.getClass() != obj.getClass()) {
-                       return false;
-               }
-
-               final OpeningTimes openingTimes = (OpeningTimes) obj;
-
-               if (!Objects.equals(this.getOpeningId(), openingTimes.getOpeningId())) {
-                       return false;
-               } else if (this.getOpeningStartDay() != openingTimes.getOpeningStartDay()) {
-                       return false;
-               } else if (this.getOpeningEndDay() != openingTimes.getOpeningEndDay()) {
-                       return false;
-               } else if (!Objects.equals(this.getOpeningStartTime(), openingTimes.getOpeningStartTime())) {
-                       return false;
-               } else if (!Objects.equals(this.getOpeningEndTime(), openingTimes.getOpeningEndTime())) {
-                       return false;
-               }
-
-               return true;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getOpeningCreated () {
-               return this.openingCreated;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setOpeningCreated (final Date openingCreated) {
-               this.openingCreated = openingCreated;
-       }
-
-       @Override
-       public DayOfTheWeek getOpeningEndDay () {
-               return this.openingEndDay;
-       }
-
-       @Override
-       public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
-               this.openingEndDay = openingEndDay;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getOpeningEndTime () {
-               return this.openingEndTime;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setOpeningEndTime (final Date openingEndTime) {
-               this.openingEndTime = openingEndTime;
-       }
-
-       @Override
-       public Long getOpeningId () {
-               return this.openingId;
-       }
-
-       @Override
-       public void setOpeningId (final Long openingId) {
-               this.openingId = openingId;
-       }
-
-       @Override
-       public DayOfTheWeek getOpeningStartDay () {
-               return this.openingStartDay;
-       }
-
-       @Override
-       public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
-               this.openingStartDay = openingStartDay;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getOpeningStartTime () {
-               return this.openingStartTime;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setOpeningStartTime (final Date openingStartTime) {
-               this.openingStartTime = openingStartTime;
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 7;
-
-               hash = 97 * hash + Objects.hashCode(this.getOpeningId());
-               hash = 97 * hash + Objects.hashCode(this.getOpeningStartDay());
-               hash = 97 * hash + Objects.hashCode(this.getOpeningEndDay());
-               hash = 97 * hash + Objects.hashCode(this.getOpeningStartTime());
-               hash = 97 * hash + Objects.hashCode(this.getOpeningEndTime());
-
-               return hash;
-       }
-
-}
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_times/OpeningTimes.java b/src/org/mxchange/jcontactsbusiness/model/opening_times/OpeningTimes.java
deleted file mode 100644 (file)
index 42c9f80..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.opening_times;
-
-import java.io.Serializable;
-import java.util.Date;
-import org.mxchange.jcontactsbusiness.model.opening_times.dayofweek.DayOfTheWeek;
-
-/**
- * A POJI for opening times
- *
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface OpeningTimes extends Serializable {
-
-       /**
-        * Getter for opening time created timestamp
-        * <p>
-        * @return Opening time created timestamp
-        */
-       Date getOpeningCreated ();
-
-       /**
-        * Setter for opening time created timestamp
-        * <p>
-        * @param openingCreated Opening time created timestamp
-        */
-       void setOpeningCreated (final Date openingCreated);
-
-       /**
-        * Getter for id number
-        * <p>
-        * @return Id number
-        */
-       Long getOpeningId ();
-
-       /**
-        * Setter for id number
-        * <p>
-        * @param openingId Id number
-        */
-       void setOpeningId (final Long openingId);
-
-       /**
-        * Getter for starting day
-        * <p>
-        * @return Starting day
-        */
-       DayOfTheWeek getOpeningStartDay ();
-
-       /**
-        * Setter for starting day
-        * <p>
-        * @param openingStartDay Starting day
-        */
-       void setOpeningStartDay (final DayOfTheWeek openingStartDay);
-
-       /**
-        * Getter for ending day
-        * <p>
-        * @return Ending day
-        */
-       DayOfTheWeek getOpeningEndDay ();
-
-       /**
-        * Setter for ending day
-        * <p>
-        * @param openinhEndDay Ending day
-        */
-       void setOpeningEndDay (final DayOfTheWeek openinhEndDay);
-
-       /**
-        * Getter for starting time
-        * <p>
-        * @return Starting time
-        */
-       Date getOpeningStartTime ();
-
-       /**
-        * Setter for starting time
-        * <p>
-        * @param openingStartTime Starting time
-        */
-       void setOpeningStartTime (final Date openingStartTime);
-
-       /**
-        * Getter for ending time
-        * <p>
-        * @return Ending time
-        */
-       Date getOpeningEndTime ();
-
-       /**
-        * Setter for ending time
-        * <p>
-        * @param openingEndTime Ending time
-        */
-       void setOpeningEndTime (final Date openingEndTime);
-
-       @Override
-       boolean equals (final Object obj);
-
-       @Override
-       int hashCode ();
-
-}
diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_times/dayofweek/DayOfTheWeek.java b/src/org/mxchange/jcontactsbusiness/model/opening_times/dayofweek/DayOfTheWeek.java
deleted file mode 100644 (file)
index 74f45b9..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.opening_times.dayofweek;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * An enumeration suitable for persisting
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public enum DayOfTheWeek {
-       SUNDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.SUNDAY;
-               }
-
-       },
-       MONDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.MONDAY;
-               }
-       },
-       TUESDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.TUESDAY;
-               }
-       },
-       WEDNESDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.WEDNESDAY;
-               }
-       },
-       THURSDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.THURSDAY;
-               }
-       },
-       FRIDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.FRIDAY;
-               }
-       },
-       SATURDAY {
-               @Override
-               public int toCalendar () {
-                       return Calendar.SATURDAY;
-               }
-       };
-
-       public abstract int toCalendar ();
-
-       public static DayOfTheWeek fromCalendarDay (final int day) {
-
-               for (DayOfTheWeek dayOfWeek : DayOfTheWeek.values()) {
-                       if (dayOfWeek.toCalendar() == day) {
-                               return dayOfWeek;
-                       }
-               }
-
-               return null; // Consider throwing IllegalArgumentException
-       }
-
-       public static DayOfTheWeek getByDate (final Date date) {
-               Calendar calendar = GregorianCalendar.getInstance();
-               calendar.setTime(date);
-               return fromCalendarDay(calendar.get(Calendar.DAY_OF_WEEK));
-       }
-
-       /*
-        * Should return the localized day of the week
-        */
-       @Override
-       public String toString () {
-               Calendar c = new GregorianCalendar();
-               c.set(Calendar.DAY_OF_WEEK, this.toCalendar());
-               SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat
-                                                .getInstance();
-               sdf.applyPattern("EEEEEEEEEE"); //NOI18N
-
-               return sdf.format(c.getTime());
-       }
-
-}