]> git.mxchange.org Git - jbonuscard-core.git/commitdiff
In addressbook, there is no customer ...
authorRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 20:43:15 +0000 (22:43 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 20:51:26 +0000 (22:51 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
lib/jcustomer-core.jar [deleted file]
nbproject/project.properties
src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java [new file with mode: 0644]
src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java [deleted file]
src/org/mxchange/pizzaaplication/model/customer/PizzaCustomer.java [deleted file]

diff --git a/lib/jcustomer-core.jar b/lib/jcustomer-core.jar
deleted file mode 100644 (file)
index be24381..0000000
Binary files a/lib/jcustomer-core.jar and /dev/null differ
index 3b1ebaffc61843bd229cbe17df4397b259410983..83833dec2b24a384a5def67c526e24ecca5e7908 100644 (file)
@@ -4,7 +4,7 @@ annotation.processing.processors.list=
 annotation.processing.run.all.processors=true
 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
 application.title=addressbook-core
-application.vendor=Cho-Time GmbH
+application.vendor=rhaeder
 auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
 build.classes.dir=${build.dir}/classes
 build.classes.excludes=**/*.java,**/*.form
@@ -36,7 +36,6 @@ file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar
 file.reference.jcore.jar=lib/jcore.jar
 file.reference.jcoreee.jar=lib/jcoreee.jar
 file.reference.jcountry-core.jar=lib/jcountry-core.jar
-file.reference.jcustomer-core.jar=lib/jcustomer-core.jar
 file.reference.jphone-core.jar=lib/jphone-core.jar
 file.reference.juser-core.jar=lib/juser-core.jar
 includes=**
@@ -52,7 +51,6 @@ javac.classpath=\
     ${file.reference.juser-core.jar}:\
     ${file.reference.jcontacts-core.jar}:\
     ${file.reference.jcontacts-business-core.jar}:\
-    ${file.reference.jcustomer-core.jar}:\
     ${libs.jpa20-persistence.classpath}
 # Space-separated list of extra javac options
 javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
@@ -116,7 +114,6 @@ source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/
 source.reference.jcore.jar=../jcore/src/
 source.reference.jcoreee.jar=../jcoreee/src/
 source.reference.jcountry-core.jar=../jcountry-core/src/
-source.reference.jcustomer-core.jar=../jcustomer-core/src/
 source.reference.jphone-core.jar=../jphone-core/src/
 source.reference.juser-core.jar=../juser-core/src/
 src.dir=src
diff --git a/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java b/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java
new file mode 100644 (file)
index 0000000..bbd21e4
--- /dev/null
@@ -0,0 +1,549 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.addressbook.database;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.Objects;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.utils.PhoneUtils;
+
+/**
+ * A helper class for beans that access the database.
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 12_895_410_275_811_963L;
+
+       /**
+        * Protected constructor
+        */
+       protected BaseAddressbookDatabaseBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Updates all contacts's phone entry's created timestamps
+        * <p>
+        * @param contact Contact instance to update
+        */
+       protected void setAllContactPhoneEntriesCreated (final Contact contact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Get all phone instances
+               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+               DialableCellphoneNumber cellphoneNumber = contact.getContactCellphoneNumber();
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntriesCreated: landLineNumber={0},faxNumber={1},cellphoneNumber={2}", landLineNumber, faxNumber, cellphoneNumber)); //NOI18N
+
+               // Is a phone number instance set?
+               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
+               }
+
+               // Is a fax number instance set?
+               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       faxNumber.setPhoneEntryCreated(new GregorianCalendar());
+               }
+
+               // Is a mobile number instance set?
+               if ((cellphoneNumber instanceof DialableCellphoneNumber) && (cellphoneNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for cellphone number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       cellphoneNumber.setPhoneEntryCreated(new GregorianCalendar());
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesCreated: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Returnes a detached instance from given cellphone instance
+        * <p>
+        * @param cellphoneNumber Cellphone instance
+        * @param fetchedNumber Found cellphone number in database
+        * <p>
+        * @return Detached instance
+        */
+       protected DialableCellphoneNumber getDetached (final DialableCellphoneNumber cellphoneNumber, final DialableCellphoneNumber fetchedNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: cellphoneNumber={0},fetchedNumber={1} - CALLED!", cellphoneNumber, fetchedNumber));
+
+               // Should be valid
+               if (null == cellphoneNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("cellphoneNumber is null");
+               } else if (fetchedNumber.getPhoneId() == null) {
+                       // ..and again
+                       throw new NullPointerException("fetchedNumber.phoneId is null");
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
+
+               // Init query instance
+               DialableCellphoneNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
+
+               // Default is null
+               DialableCellphoneNumber detachedNumber = null;
+
+               // Is there a difference?
+               if (!PhoneUtils.isSameCellphoneNumber(cellphoneNumber, fetchedNumber)) {
+                       // Merge this entry
+                       detachedNumber = this.getEntityManager().merge(foundNumber);
+
+                       // Copy all
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
+
+               // Return it
+               return detachedNumber;
+       }
+
+       /**
+        * Returnes a detached instance from given land-line instance
+        * <p>
+        * @param landLineNumber Land-line instance
+        * @param fetchedNumber Found land-line number in database
+        * <p>
+        * @return Detached instance
+        */
+       protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber));
+
+               // Should be valid
+               if (null == landLineNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber is null");
+               } else if (fetchedNumber.getPhoneId() == null) {
+                       // ..and again
+                       throw new NullPointerException("landLineNumber.phoneId is null");
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
+
+               // Init query instance
+               DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
+
+               // Default is null
+               DialableLandLineNumber detachedNumber = null;
+
+               // Is there a difference?
+               if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
+                       // Merge this entry
+                       detachedNumber = this.getEntityManager().merge(foundNumber);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
+
+               // Return it
+               return detachedNumber;
+       }
+
+       /**
+        * Returnes a detached instance from given fax instance
+        * <p>
+        * @param faxNumber Fax instance
+        * @param fetchedNumber Found fax number in database
+        * <p>
+        * @return Detached instance
+        */
+       protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber));
+
+               // Should be valid
+               if (null == faxNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber is null");
+               } else if (fetchedNumber.getPhoneId() == null) {
+                       // ..and again
+                       throw new NullPointerException("fetchedNumber.phoneId is null");
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
+
+               // Init query instance
+               DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
+
+               // Default is null
+               DialableFaxNumber detachedNumber = null;
+
+               // Is there a difference?
+               if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
+                       // Merge this entry
+                       detachedNumber = this.getEntityManager().merge(foundNumber);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
+
+               // Return it
+               return detachedNumber;
+       }
+
+       /**
+        * Merges given contact's data
+        * <p>
+        * @param contact Contact instance to merge
+        * <p>
+        * @return Detached contact instance
+        */
+       protected Contact mergeContactData (final Contact contact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: contact={0} - CALLED!", contact)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
+               // Set updated timestamp
+               contact.setContactUpdated(new GregorianCalendar());
+
+               // Get contact from it and find it
+               Contact foundContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
+
+               // Should be found
+               assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
+
+               // Merge contact instance
+               Contact detachedContact = this.getEntityManager().merge(foundContact);
+
+               // Copy all
+               detachedContact.copyAll(contact);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N
+
+               // Return detached contact
+               return detachedContact;
+       }
+
+       /**
+        * Merges given (detached) contact's cellphone, land-line and fax numbers
+        * <p>
+        * @param detachedContact Detached contact instance
+        */
+       protected void mergeContactsCellphoneLandLineFaxNumbers (final Contact detachedContact) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactsCellphoneLandLineFaxNumbers: detachedContact={0} - CALLED!", detachedContact)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == detachedContact) {
+                       // Throw NPE again
+                       throw new NullPointerException("detachedContact is null"); //NOI18N
+               } else if (detachedContact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+               } else if (detachedContact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
+               }
+
+               // Get all instances
+               DialableCellphoneNumber cellphone = detachedContact.getContactCellphoneNumber();
+               DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
+               DialableFaxNumber fax = detachedContact.getContactFaxNumber();
+
+               // Is there a  cellphone instance set?
+               if (cellphone instanceof DialableCellphoneNumber) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId())); //NOI18N
+
+                       // Then find it, too
+                       DialableCellphoneNumber foundCellphone = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
+
+                       // Should be there
+                       assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableCellphoneNumber detachedCellphone = this.getEntityManager().merge(foundCellphone);
+
+                       // Should be there
+                       assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       detachedCellphone.copyAll(detachedContact.getContactCellphoneNumber());
+
+                       // Set it back
+                       detachedContact.setContactCellphoneNumber(detachedCellphone);
+               }
+
+               // Is there a  fax instance set?
+               if (fax instanceof DialableFaxNumber) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
+
+                       // Then find it, too
+                       DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
+
+                       // Should be there
+                       assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
+
+                       // Should be there
+                       assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       detachedFax.copyAll(detachedContact.getContactFaxNumber());
+
+                       // Set it back
+                       detachedContact.setContactFaxNumber(detachedFax);
+               }
+
+               // Is there a  fax instance set?
+               if (landLine instanceof DialableLandLineNumber) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
+
+                       // Then find it, too
+                       DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
+
+                       // Should be there
+                       assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
+
+                       // Should be there
+                       assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       detachedLandLine.copyAll(detachedContact.getContactLandLineNumber());
+
+                       // Set it back
+                       detachedContact.setContactLandLineNumber(detachedLandLine);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("mergeContactsCellphoneLandLineFaxNumbers: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Updates all contact's phone instances from other contact, both contacts
+        * should be the same.
+        * <p>
+        * @param contact Contact to set instances
+        * @param other Other contact to get instances from
+        */
+       protected void setAllContactPhoneEntries (final Contact contact, final Contact other) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntries: contact={0},other={1} - CALLED!", contact, other)); //NOI18N
+
+               // Both must be the same and not null
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (null == other) {
+                       // Throw NPE
+                       throw new NullPointerException("other is null"); //NOI18N
+               } else if (!Objects.equals(contact, other)) {
+                       // Not same instances
+                       throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactCellphoneNumber={0}", other.getContactCellphoneNumber())); //NOI18N
+
+               // Is other cellphone not set?
+               if ((other.getContactCellphoneNumber() == null) || (PhoneUtils.isSameCellphoneNumber(contact.getContactCellphoneNumber(), other.getContactCellphoneNumber()))) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying cellphone entry ..."); //NOI18N
+
+                       // Is the fax number set?
+                       if (other.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+                               // Copy cellphone number
+                               contact.setContactCellphoneNumber(this.getDetached(other.getContactCellphoneNumber(), contact.getContactCellphoneNumber()));
+                       } else {
+                               // Null it
+                               contact.setContactCellphoneNumber(null);
+                       }
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
+
+               // Is other cellphone not set?
+               if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying land-line entry ..."); //NOI18N
+
+                       // Is the land-line number set?
+                       if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                               // Copy land-line number
+                               contact.setContactLandLineNumber(this.getDetached(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+                       } else {
+                               // Null it
+                               contact.setContactLandLineNumber(null);
+                       }
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactFaxNumber={0}", other.getContactFaxNumber())); //NOI18N
+
+               // Is other cellphone not set?
+               if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying fax entry ..."); //NOI18N
+
+                       // Is the fax number set?
+                       if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
+                               // Copy fax number
+                               contact.setContactFaxNumber(this.getDetached(other.getContactFaxNumber(), contact.getContactFaxNumber()));
+                       } else {
+                               // Null it
+                               contact.setContactFaxNumber(null);
+                       }
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntries: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Updates all contacts's phone entry's updated timestamps
+        * <p>
+        * @param contact Contact instance to update
+        * @param isCellphoneUnlinked Whether a cellphone entry has been unlinked in
+        * contact instance
+        * @param isLandlineUnlinked Whether a land-line entry has been unlinked in
+        * contact instance
+        * @param isFaxUnlinked Whether a fax entry has been unlinked in contact
+        * instance
+        */
+       protected void setAllContactPhoneEntriesUpdated (final Contact contact, final boolean isCellphoneUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesUpdated: contact={0},isCellphoneUnlinked={1},isLandlineUnlinked={2},isFaxUnlinked={3} - CALLED", contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
+               // Get all phone instances
+               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
+               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
+               DialableCellphoneNumber cellphoneNumber = contact.getContactCellphoneNumber();
+
+               // Flags and instances must be constistent
+               if (isCellphoneUnlinked && cellphoneNumber instanceof DialableCellphoneNumber) {
+                       // Bad state
+                       throw new IllegalStateException("isCellPhoneUnlinked is TRUE, but cellphoneNumber is set."); //NOI18N
+               } else if (isLandlineUnlinked && landLineNumber instanceof DialableLandLineNumber) {
+                       // Bad state
+                       throw new IllegalStateException("isLandlineUnlinked is TRUE, but landLineNumber is set."); //NOI18N
+               } else if (isFaxUnlinked && faxNumber instanceof DialableFaxNumber) {
+                       // Bad state
+                       throw new IllegalStateException("isFaxUnlinked is TRUE, but faxNumber is set."); //NOI18N
+               }
+
+               // Is a phone number instance set?
+               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() instanceof Long) && (landLineNumber.getPhoneId() > 0)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for land-line number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       landLineNumber.setPhoneEntryUpdated(new GregorianCalendar());
+               }
+
+               // Is a fax number instance set?
+               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() instanceof Long) && (faxNumber.getPhoneId() > 0)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for fax number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       faxNumber.setPhoneEntryUpdated(new GregorianCalendar());
+               }
+
+               // Is a mobile number instance set?
+               if ((cellphoneNumber instanceof DialableCellphoneNumber) && (cellphoneNumber.getPhoneId() instanceof Long) && (cellphoneNumber.getPhoneId() > 0)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for cellphone number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       cellphoneNumber.setPhoneEntryUpdated(new GregorianCalendar());
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesUpdated: EXIT!"); //NOI18N
+       }
+
+}
diff --git a/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java b/src/org/mxchange/pizzaaplication/database/BasePizzaDatabaseBean.java
deleted file mode 100644 (file)
index 821020a..0000000
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * Copyright (C) 2016 Cho-Time GmbH
- *
- * 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.pizzaaplication.database;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import java.util.Objects;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.utils.PhoneUtils;
-
-/**
- * A helper class for beans that access the database.
- * <p>
- * @author Roland Haeder<rhaeder@cho-time.de>
- */
-public abstract class BasePizzaDatabaseBean extends BaseDatabaseBean {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 12_895_410_275_811_963L;
-
-       /**
-        * Protected constructor
-        */
-       protected BasePizzaDatabaseBean () {
-               // Call super constructor
-               super();
-       }
-
-       /**
-        * Updates all contacts's phone entry's created timestamps
-        * <p>
-        * @param contact Contact instance to update
-        */
-       protected void setAllContactPhoneEntriesCreated (final Contact contact) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == contact) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Get all phone instances
-               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
-               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
-               DialableCellphoneNumber cellphoneNumber = contact.getContactCellphoneNumber();
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntriesCreated: landLineNumber={0},faxNumber={1},cellphoneNumber={2}", landLineNumber, faxNumber, cellphoneNumber)); //NOI18N
-
-               // Is a phone number instance set?
-               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
-
-               // Is a fax number instance set?
-               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       faxNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
-
-               // Is a mobile number instance set?
-               if ((cellphoneNumber instanceof DialableCellphoneNumber) && (cellphoneNumber.getPhoneId() == null)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for cellphone number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       cellphoneNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesCreated: EXIT!"); //NOI18N
-       }
-
-       /**
-        * Returnes a detached instance from given cellphone instance
-        * <p>
-        * @param cellphoneNumber Cellphone instance
-        * @param fetchedNumber Found cellphone number in database
-        * <p>
-        * @return Detached instance
-        */
-       protected DialableCellphoneNumber getDetached (final DialableCellphoneNumber cellphoneNumber, final DialableCellphoneNumber fetchedNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: cellphoneNumber={0},fetchedNumber={1} - CALLED!", cellphoneNumber, fetchedNumber));
-
-               // Should be valid
-               if (null == cellphoneNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("cellphoneNumber is null");
-               } else if (fetchedNumber.getPhoneId() == null) {
-                       // ..and again
-                       throw new NullPointerException("fetchedNumber.phoneId is null");
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
-
-               // Init query instance
-               DialableCellphoneNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
-
-               // Default is null
-               DialableCellphoneNumber detachedNumber = null;
-
-               // Is there a difference?
-               if (!PhoneUtils.isSameCellphoneNumber(cellphoneNumber, fetchedNumber)) {
-                       // Merge this entry
-                       detachedNumber = this.getEntityManager().merge(foundNumber);
-
-                       // Copy all
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
-
-               // Return it
-               return detachedNumber;
-       }
-
-       /**
-        * Returnes a detached instance from given land-line instance
-        * <p>
-        * @param landLineNumber Land-line instance
-        * @param fetchedNumber Found land-line number in database
-        * <p>
-        * @return Detached instance
-        */
-       protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber));
-
-               // Should be valid
-               if (null == landLineNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber is null");
-               } else if (fetchedNumber.getPhoneId() == null) {
-                       // ..and again
-                       throw new NullPointerException("landLineNumber.phoneId is null");
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
-
-               // Init query instance
-               DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
-
-               // Default is null
-               DialableLandLineNumber detachedNumber = null;
-
-               // Is there a difference?
-               if (!PhoneUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
-                       // Merge this entry
-                       detachedNumber = this.getEntityManager().merge(foundNumber);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
-
-               // Return it
-               return detachedNumber;
-       }
-
-       /**
-        * Returnes a detached instance from given fax instance
-        * <p>
-        * @param faxNumber Fax instance
-        * @param fetchedNumber Found fax number in database
-        * <p>
-        * @return Detached instance
-        */
-       protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber));
-
-               // Should be valid
-               if (null == faxNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumber is null");
-               } else if (fetchedNumber.getPhoneId() == null) {
-                       // ..and again
-                       throw new NullPointerException("fetchedNumber.phoneId is null");
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId()));
-
-               // Init query instance
-               DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber));
-
-               // Default is null
-               DialableFaxNumber detachedNumber = null;
-
-               // Is there a difference?
-               if (!PhoneUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
-                       // Merge this entry
-                       detachedNumber = this.getEntityManager().merge(foundNumber);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber));
-
-               // Return it
-               return detachedNumber;
-       }
-
-       /**
-        * Merges given contact's data
-        * <p>
-        * @param contact Contact instance to merge
-        * <p>
-        * @return Detached contact instance
-        */
-       protected Contact mergeContactData (final Contact contact) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: contact={0} - CALLED!", contact)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == contact) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               }
-
-               // Set updated timestamp
-               contact.setContactUpdated(new GregorianCalendar());
-
-               // Get contact from it and find it
-               Contact foundContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
-
-               // Should be found
-               assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
-
-               // Merge contact instance
-               Contact detachedContact = this.getEntityManager().merge(foundContact);
-
-               // Copy all
-               detachedContact.copyAll(contact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N
-
-               // Return detached contact
-               return detachedContact;
-       }
-
-       /**
-        * Merges given (detached) contact's cellphone, land-line and fax numbers
-        * <p>
-        * @param detachedContact Detached contact instance
-        */
-       protected void mergeContactsCellphoneLandLineFaxNumbers (final Contact detachedContact) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactsCellphoneLandLineFaxNumbers: detachedContact={0} - CALLED!", detachedContact)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == detachedContact) {
-                       // Throw NPE again
-                       throw new NullPointerException("detachedContact is null"); //NOI18N
-               } else if (detachedContact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
-               } else if (detachedContact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
-               }
-
-               // Get all instances
-               DialableCellphoneNumber cellphone = detachedContact.getContactCellphoneNumber();
-               DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
-               DialableFaxNumber fax = detachedContact.getContactFaxNumber();
-
-               // Is there a  cellphone instance set?
-               if (cellphone instanceof DialableCellphoneNumber) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId())); //NOI18N
-
-                       // Then find it, too
-                       DialableCellphoneNumber foundCellphone = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
-
-                       // Should be there
-                       assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId()); //NOI18N
-
-                       // Then merge it, too
-                       DialableCellphoneNumber detachedCellphone = this.getEntityManager().merge(foundCellphone);
-
-                       // Should be there
-                       assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId()); //NOI18N
-
-                       // Copy all
-                       detachedCellphone.copyAll(detachedContact.getContactCellphoneNumber());
-
-                       // Set it back
-                       detachedContact.setContactCellphoneNumber(detachedCellphone);
-               }
-
-               // Is there a  fax instance set?
-               if (fax instanceof DialableFaxNumber) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
-
-                       // Then find it, too
-                       DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
-
-                       // Should be there
-                       assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
-
-                       // Then merge it, too
-                       DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
-
-                       // Should be there
-                       assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId()); //NOI18N
-
-                       // Copy all
-                       detachedFax.copyAll(detachedContact.getContactFaxNumber());
-
-                       // Set it back
-                       detachedContact.setContactFaxNumber(detachedFax);
-               }
-
-               // Is there a  fax instance set?
-               if (landLine instanceof DialableLandLineNumber) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
-
-                       // Then find it, too
-                       DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
-
-                       // Should be there
-                       assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
-
-                       // Then merge it, too
-                       DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
-
-                       // Should be there
-                       assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId()); //NOI18N
-
-                       // Copy all
-                       detachedLandLine.copyAll(detachedContact.getContactLandLineNumber());
-
-                       // Set it back
-                       detachedContact.setContactLandLineNumber(detachedLandLine);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("mergeContactsCellphoneLandLineFaxNumbers: EXIT!"); //NOI18N
-       }
-
-       /**
-        * Updates all contact's phone instances from other contact, both contacts
-        * should be the same.
-        * <p>
-        * @param contact Contact to set instances
-        * @param other Other contact to get instances from
-        */
-       protected void setAllContactPhoneEntries (final Contact contact, final Contact other) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntries: contact={0},other={1} - CALLED!", contact, other)); //NOI18N
-
-               // Both must be the same and not null
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (null == other) {
-                       // Throw NPE
-                       throw new NullPointerException("other is null"); //NOI18N
-               } else if (!Objects.equals(contact, other)) {
-                       // Not same instances
-                       throw new IllegalArgumentException(MessageFormat.format("contact={0} and other={1} are not equal!", contact, other)); //NOI18N
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactCellphoneNumber={0}", other.getContactCellphoneNumber())); //NOI18N
-
-               // Is other cellphone not set?
-               if ((other.getContactCellphoneNumber() == null) || (PhoneUtils.isSameCellphoneNumber(contact.getContactCellphoneNumber(), other.getContactCellphoneNumber()))) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying cellphone entry ..."); //NOI18N
-
-                       // Is the fax number set?
-                       if (other.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
-                               // Copy cellphone number
-                               contact.setContactCellphoneNumber(this.getDetached(other.getContactCellphoneNumber(), contact.getContactCellphoneNumber()));
-                       } else {
-                               // Null it
-                               contact.setContactCellphoneNumber(null);
-                       }
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
-
-               // Is other cellphone not set?
-               if ((other.getContactLandLineNumber() == null) || (PhoneUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying land-line entry ..."); //NOI18N
-
-                       // Is the land-line number set?
-                       if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                               // Copy land-line number
-                               contact.setContactLandLineNumber(this.getDetached(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
-                       } else {
-                               // Null it
-                               contact.setContactLandLineNumber(null);
-                       }
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactFaxNumber={0}", other.getContactFaxNumber())); //NOI18N
-
-               // Is other cellphone not set?
-               if ((other.getContactFaxNumber() == null) || (PhoneUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying fax entry ..."); //NOI18N
-
-                       // Is the fax number set?
-                       if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
-                               // Copy fax number
-                               contact.setContactFaxNumber(this.getDetached(other.getContactFaxNumber(), contact.getContactFaxNumber()));
-                       } else {
-                               // Null it
-                               contact.setContactFaxNumber(null);
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntries: EXIT!"); //NOI18N
-       }
-
-       /**
-        * Updates all contacts's phone entry's updated timestamps
-        * <p>
-        * @param contact Contact instance to update
-        * @param isCellphoneUnlinked Whether a cellphone entry has been unlinked in
-        * contact instance
-        * @param isLandlineUnlinked Whether a land-line entry has been unlinked in
-        * contact instance
-        * @param isFaxUnlinked Whether a fax entry has been unlinked in contact
-        * instance
-        */
-       protected void setAllContactPhoneEntriesUpdated (final Contact contact, final boolean isCellphoneUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesUpdated: contact={0},isCellphoneUnlinked={1},isLandlineUnlinked={2},isFaxUnlinked={3} - CALLED", contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
-
-               // The contact instance must be valid
-               if (null == contact) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
-               }
-
-               // Get all phone instances
-               DialableLandLineNumber landLineNumber = contact.getContactLandLineNumber();
-               DialableFaxNumber faxNumber = contact.getContactFaxNumber();
-               DialableCellphoneNumber cellphoneNumber = contact.getContactCellphoneNumber();
-
-               // Flags and instances must be constistent
-               if (isCellphoneUnlinked && cellphoneNumber instanceof DialableCellphoneNumber) {
-                       // Bad state
-                       throw new IllegalStateException("isCellPhoneUnlinked is TRUE, but cellphoneNumber is set."); //NOI18N
-               } else if (isLandlineUnlinked && landLineNumber instanceof DialableLandLineNumber) {
-                       // Bad state
-                       throw new IllegalStateException("isLandlineUnlinked is TRUE, but landLineNumber is set."); //NOI18N
-               } else if (isFaxUnlinked && faxNumber instanceof DialableFaxNumber) {
-                       // Bad state
-                       throw new IllegalStateException("isFaxUnlinked is TRUE, but faxNumber is set."); //NOI18N
-               }
-
-               // Is a phone number instance set?
-               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() instanceof Long) && (landLineNumber.getPhoneId() > 0)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for land-line number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       landLineNumber.setPhoneEntryUpdated(new GregorianCalendar());
-               }
-
-               // Is a fax number instance set?
-               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() instanceof Long) && (faxNumber.getPhoneId() > 0)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for fax number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       faxNumber.setPhoneEntryUpdated(new GregorianCalendar());
-               }
-
-               // Is a mobile number instance set?
-               if ((cellphoneNumber instanceof DialableCellphoneNumber) && (cellphoneNumber.getPhoneId() instanceof Long) && (cellphoneNumber.getPhoneId() > 0)) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesUpdated: Setting updated timestamp for cellphone number ..."); //NOI18N
-
-                       // Set updated timestamp
-                       cellphoneNumber.setPhoneEntryUpdated(new GregorianCalendar());
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesUpdated: EXIT!"); //NOI18N
-       }
-
-}
diff --git a/src/org/mxchange/pizzaaplication/model/customer/PizzaCustomer.java b/src/org/mxchange/pizzaaplication/model/customer/PizzaCustomer.java
deleted file mode 100644 (file)
index 1969920..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.pizzaapplication.model.customer;
-
-import java.util.Calendar;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-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.Index;
-import javax.persistence.JoinColumn;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.jcustomercore.model.customer.status.CustomerAccountStatus;
-
-/**
- * A customer entity
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Entity (name = "customer")
-@Table (
-               name = "customer",
-               indexes = {
-                       @Index (columnList = "customer_number", unique = true)
-               }
-)
-@NamedQueries (
-               {
-                       @NamedQuery (name = "AllCustomers", query = "SELECT c FROM customer AS c ORDER BY c.customerId ASC")
-               }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class PizzaCustomer implements Customer {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 14_857_923_178_504_617L;
-
-       /**
-        * Account status for this customer
-        */
-       @Basic (optional = false)
-       @Enumerated (EnumType.STRING)
-       @Column (name = "customer_status", nullable = false)
-       private CustomerAccountStatus customerAccountStatus;
-
-       /**
-        * Contact instance (personal data)
-        */
-       @JoinColumn (name = "customer_contact_id", nullable = false, updatable = false, unique = true)
-       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
-       private Contact customerContact;
-
-       /**
-        * When this customer has been created
-        */
-       @Basic (optional = false)
-       @Column (name = "customer_created", nullable = false, updatable = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       private Calendar customerCreated;
-
-       /**
-        * Id number for this entry
-        */
-       @Id
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "customer_id", nullable = false, updatable = false)
-       private Long customerId;
-
-       /**
-        * When this customer has been locked (last timestamp)
-        */
-       @Column (name = "customer_last_locked")
-       @Temporal (TemporalType.TIMESTAMP)
-       private Calendar customerLocked;
-
-       /**
-        * Customer number
-        */
-       @Basic (optional = false)
-       @Column (name = "customer_number", nullable = false, updatable = false)
-       private String customerNumber;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCustomer () {
-       }
-
-       /**
-        * Constructor with account status, contact instance and customer number
-        * <p>
-        * @param customerAccountStatus Account status (Call-agents may only call
-        * unlocked accounts)
-        * @param customerContact Contact instance
-        * @param customerNumber Customer number
-        */
-       public PizzaCustomer (final CustomerAccountStatus customerAccountStatus, final Contact customerContact, final String customerNumber) {
-               // Call other constructor
-               this();
-
-               // Set all parameter
-               this.customerAccountStatus = customerAccountStatus;
-               this.customerContact = customerContact;
-               this.customerNumber = customerNumber;
-       }
-
-       @Override
-       public void copyAll (final Customer customer) {
-               // Copy all supported fields
-               this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
-               this.setCustomerContact(customer.getCustomerContact());
-               this.setCustomerCreated(customer.getCustomerCreated());
-               this.setCustomerId(customer.getCustomerId());
-               this.setCustomerLocked(customer.getCustomerLocked());
-               this.setCustomerNumber(customer.getCustomerNumber());
-       }
-
-       @Override
-       public boolean equals (final Object object) {
-               if (this == object) {
-                       return true;
-               } else if (null == object) {
-                       return false;
-               } else if (this.getClass() != object.getClass()) {
-                       return false;
-               }
-
-               final Customer other = (Customer) object;
-
-               if (!Objects.equals(this.getCustomerNumber(), other.getCustomerNumber())) {
-                       return false;
-               } else if (!Objects.equals(this.getCustomerContact(), other.getCustomerContact())) {
-                       return false;
-               } else if (!Objects.equals(this.getCustomerId(), other.getCustomerId())) {
-                       return false;
-               }
-
-               return true;
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 7;
-
-               hash = 53 * hash + Objects.hashCode(this.getCustomerContact());
-               hash = 53 * hash + Objects.hashCode(this.getCustomerId());
-               hash = 53 * hash + Objects.hashCode(this.getCustomerNumber());
-
-               return hash;
-       }
-
-       @Override
-       public CustomerAccountStatus getCustomerAccountStatus () {
-               return this.customerAccountStatus;
-       }
-
-       @Override
-       public void setCustomerAccountStatus (final CustomerAccountStatus customerStatus) {
-               this.customerAccountStatus = customerStatus;
-       }
-
-       @Override
-       public String getCustomerConfirmKey () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void setCustomerConfirmKey (final String customerConfirmKey) {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public Contact getCustomerContact () {
-               return this.customerContact;
-       }
-
-       @Override
-       public void setCustomerContact (final Contact customerContact) {
-               this.customerContact = customerContact;
-       }
-
-       @Override
-       public Calendar getCustomerCreated () {
-               return this.customerCreated;
-       }
-
-       @Override
-       public void setCustomerCreated (final Calendar customerCreated) {
-               this.customerCreated = customerCreated;
-       }
-
-       @Override
-       public Long getCustomerId () {
-               return this.customerId;
-       }
-
-       @Override
-       public void setCustomerId (final Long customerId) {
-               this.customerId = customerId;
-       }
-
-       @Override
-       public Calendar getCustomerLocked () {
-               return this.customerLocked;
-       }
-
-       @Override
-       public void setCustomerLocked (final Calendar customerLocked) {
-               this.customerLocked = customerLocked;
-       }
-
-       @Override
-       public String getCustomerNumber () {
-               return this.customerNumber;
-       }
-
-       @Override
-       public void setCustomerNumber (final String customerNumber) {
-               this.customerNumber = customerNumber;
-       }
-
-       @Override
-       public String getCustomerPasswordHash () {
-               throw new UnsupportedOperationException("Unfinished"); //NOI18N
-       }
-
-       @Override
-       public void setCustomerPasswordHash (final String customerPasswordHash) {
-               throw new UnsupportedOperationException("Unfinished"); //NOI18N
-       }
-
-}