import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
import org.mxchange.jcontactsbusiness.model.department.Department;
+import org.mxchange.jcontactsbusiness.model.department.Departments;
import org.mxchange.jcontactsbusiness.model.employee.Employable;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
}
// Get contact from it and find it
- final BranchOffice foundBranchOffice = this.getEntityManager().find(detachedBranchOffice.getClass(), detachedBranchOffice.getBranchId());
+ final DialableMobileNumber foundBranchOffice = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getMobileId());
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: foundBranchOffice={0} - EXIT!", foundBranchOffice)); //NOI18N
// Return it
- return detachedNumber;
- }
-
- /**
- * Returns 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)); //NOI18N
-
- // Should be valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableLandLineNumber detachedNumber = null;
-
- // Is there a difference?
- if (!LandLineNumbers.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
- // @TODO Copy all to foundNumber, then merge
-
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
- }
-
- // Set updated timestamp
- managedBranchOffice.setBranchEntryUpdated(new Date());
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
+ return foundBranchOffice;
}
/**
// Is the land-line number set?
if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
// Copy land-line number
- contact.setContactLandLineNumber(this.getDetached(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+ contact.setContactLandLineNumber(this.mergeLandLineNumberData(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
} else {
// Null it
contact.setContactLandLineNumber(null);