]> git.mxchange.org Git - jjobs-ejb.git/blob - src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java
Please cherry-pick/rename:
[jjobs-ejb.git] / src / java / org / mxchange / jcontacts / model / phone / JobsAdminContactPhoneSessionBean.java
1 /*
2  * Copyright (C) 2016 - 2018 Free Software Foundation
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcontacts.model.phone;
18
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import java.util.Objects;
22 import javax.ejb.EJB;
23 import javax.ejb.Stateless;
24 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
25 import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
26 import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException;
27 import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException;
28 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
29 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
30 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
31
32 /**
33  * A session EJB for administrative contact's phone number purposes
34  * <p>
35  * @author Roland Häder<roland@mxchange.org>
36  */
37 @Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone (fax, land-line and mobile) data")
38 public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
39
40         /**
41          * Serial number
42          */
43         private static final long serialVersionUID = 189_217_561_460_237_108L;
44
45         /**
46          * Contact EJB
47          */
48         @EJB
49         private ContactSessionBeanRemote contactBean;
50
51         /**
52          * Default constructor
53          */
54         public JobsAdminContactPhoneSessionBean () {
55                 // Call super constructor
56                 super();
57         }
58
59         @Override
60         public org.mxchange.jcontacts.model.contact.Contact linkExistingFaxNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
61                 // Trace message
62                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
63
64                 // Is the contact set?
65                 if (null == contact) {
66                         // Throw NPE
67                         throw new NullPointerException("contact is null"); //NOI18N
68                 } else if (contact.getContactId() == null) {
69                         // ... and throw again
70                         throw new NullPointerException("contact.contactId is null"); //NOI18N
71                 } else if (contact.getContactId() < 1) {
72                         // Invalid id number
73                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
74                 } else if (contact.getContactFaxNumber() instanceof org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber) {
75                         // Not set cell phone instance
76                         throw new PhoneNumberAlreadyLinkedException(faxNumber);
77                 } else if (null == faxNumber) {
78                         // Throw NPE
79                         throw new NullPointerException("faxNumber is null"); //NOI18N
80                 } else if (faxNumber.getPhoneId() == null) {
81                         // Throw it again
82                         throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
83                 } else if (faxNumber.getPhoneId() < 1) {
84                         // Invalid id
85                         throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
86                 } else if (faxNumber.getPhoneCountry() == null) {
87                         // ... and again
88                         throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
89                 } else if (faxNumber.getPhoneAreaCode() == null) {
90                         // Throw it again
91                         throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
92                 } else if (faxNumber.getPhoneAreaCode() < 1) {
93                         // Invalid id
94                         throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
95                 } else if (faxNumber.getPhoneNumber() == null) {
96                         // Throw it again
97                         throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
98                 } else if (faxNumber.getPhoneNumber() < 1) {
99                         // Invalid id
100                         throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
101                 }
102
103                 // Set fax number in contact
104                 contact.setContactFaxNumber(faxNumber);
105
106                 // Update database
107                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
108
109                 // Trace message
110                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
111
112                 // Return it
113                 return updatedContact;
114         }
115
116         @Override
117         public org.mxchange.jcontacts.model.contact.Contact linkExistingLandLineNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
118                 // Trace message
119                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
120
121                 // Is the contact set?
122                 if (null == contact) {
123                         // Throw NPE
124                         throw new NullPointerException("contact is null"); //NOI18N
125                 } else if (contact.getContactId() == null) {
126                         // ... and throw again
127                         throw new NullPointerException("contact.contactId is null"); //NOI18N
128                 } else if (contact.getContactId() < 1) {
129                         // Invalid id number
130                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
131                 } else if (contact.getContactLandLineNumber() instanceof org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber) {
132                         // Not set cell phone instance
133                         throw new PhoneNumberAlreadyLinkedException(landLineNumber);
134                 } else if (null == landLineNumber) {
135                         // Throw NPE
136                         throw new NullPointerException("landLineNumber is null"); //NOI18N
137                 } else if (landLineNumber.getPhoneId() == null) {
138                         // Throw it again
139                         throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
140                 } else if (landLineNumber.getPhoneId() < 1) {
141                         // Invalid id
142                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
143                 } else if (landLineNumber.getPhoneCountry() == null) {
144                         // ... and again
145                         throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
146                 } else if (landLineNumber.getPhoneAreaCode() == null) {
147                         // Throw it again
148                         throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
149                 } else if (landLineNumber.getPhoneAreaCode() < 1) {
150                         // Invalid id
151                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
152                 } else if (landLineNumber.getPhoneNumber() == null) {
153                         // Throw it again
154                         throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
155                 } else if (landLineNumber.getPhoneNumber() < 1) {
156                         // Invalid id
157                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
158                 }
159
160                 // Set land-line number in contact
161                 contact.setContactLandLineNumber(landLineNumber);
162
163                 // Update database
164                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
165
166                 // Trace message
167                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
168
169                 // Return it
170                 return updatedContact;
171         }
172
173         @Override
174         public org.mxchange.jcontacts.model.contact.Contact linkExistingMobileNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
175                 // Trace message
176                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
177
178                 // Is the contact set?
179                 if (null == contact) {
180                         // Throw NPE
181                         throw new NullPointerException("contact is null"); //NOI18N
182                 } else if (contact.getContactId() == null) {
183                         // ... and throw again
184                         throw new NullPointerException("contact.contactId is null"); //NOI18N
185                 } else if (contact.getContactId() < 1) {
186                         // Invalid id number
187                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
188                 } else if (contact.getContactMobileNumber() instanceof org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber) {
189                         // Not set cell phone instance
190                         throw new PhoneNumberAlreadyLinkedException(mobileNumber);
191                 } else if (null == mobileNumber) {
192                         // Throw NPE
193                         throw new NullPointerException("mobileNumber is null"); //NOI18N
194                 } else if (mobileNumber.getPhoneId() == null) {
195                         // Throw it again
196                         throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
197                 } else if (mobileNumber.getPhoneId() < 1) {
198                         // Invalid id
199                         throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
200                 } else if (mobileNumber.getMobileProvider() == null) {
201                         // Throw NPE again
202                         throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
203                 } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
204                         // Throw NPE again
205                         throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
206                 } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
207                         // Throw NPE again
208                         throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
209                 }
210
211                 // Set mobile number in contact
212                 contact.setContactMobileNumber(mobileNumber);
213
214                 // Update database
215                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
216
217                 // Trace message
218                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
219
220                 // Return it
221                 return updatedContact;
222         }
223
224         @Override
225         public org.mxchange.jcontacts.model.contact.Contact linkNewFaxNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
226                 // Trace message
227                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
228
229                 // Is the contact set?
230                 if (null == contact) {
231                         // Throw NPE
232                         throw new NullPointerException("contact is null"); //NOI18N
233                 } else if (contact.getContactId() == null) {
234                         // ... and throw again
235                         throw new NullPointerException("contact.contactId is null"); //NOI18N
236                 } else if (contact.getContactId() < 1) {
237                         // Invalid id number
238                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
239                 } else if (contact.getContactFaxNumber() instanceof org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber) {
240                         // Not set cell phone instance
241                         throw new PhoneNumberAlreadyLinkedException(faxNumber);
242                 } else if (null == faxNumber) {
243                         // Throw NPE
244                         throw new NullPointerException("faxNumber is null"); //NOI18N
245                 } else if (faxNumber.getPhoneId() instanceof Long) {
246                         // Throw it again
247                         throw new IllegalStateException(MessageFormat.format("faxNumber.phoneId={0} is not null", faxNumber.getPhoneId())); //NOI18N
248                 } else if (faxNumber.getPhoneCountry() == null) {
249                         // ... and again
250                         throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
251                 } else if (faxNumber.getPhoneAreaCode() == null) {
252                         // Throw it again
253                         throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
254                 } else if (faxNumber.getPhoneAreaCode() < 1) {
255                         // Invalid id
256                         throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
257                 } else if (faxNumber.getPhoneNumber() == null) {
258                         // Throw it again
259                         throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
260                 } else if (faxNumber.getPhoneNumber() < 1) {
261                         // Invalid id
262                         throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
263                 }
264
265                 // Set created instance
266                 faxNumber.setPhoneEntryCreated(new Date());
267
268                 // Set fax number in contact
269                 contact.setContactFaxNumber(faxNumber);
270
271                 // Update database
272                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
273
274                 // Trace message
275                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
276
277                 // Return it
278                 return updatedContact;
279         }
280
281         @Override
282         public org.mxchange.jcontacts.model.contact.Contact linkNewLandLineNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
283                 // Trace message
284                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
285
286                 // Is the contact set?
287                 if (null == contact) {
288                         // Throw NPE
289                         throw new NullPointerException("contact is null"); //NOI18N
290                 } else if (contact.getContactId() == null) {
291                         // ... and throw again
292                         throw new NullPointerException("contact.contactId is null"); //NOI18N
293                 } else if (contact.getContactId() < 1) {
294                         // Invalid id number
295                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
296                 } else if (contact.getContactLandLineNumber() instanceof org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber) {
297                         // Not set cell phone instance
298                         throw new PhoneNumberAlreadyLinkedException(landLineNumber);
299                 } else if (null == landLineNumber) {
300                         // Throw NPE
301                         throw new NullPointerException("landLineNumber is null"); //NOI18N
302                 } else if (landLineNumber.getPhoneId() instanceof Long) {
303                         // Throw it again
304                         throw new IllegalStateException(MessageFormat.format("landLineNumber.phoneId={0} is not null", landLineNumber.getPhoneId())); //NOI18N
305                 } else if (landLineNumber.getPhoneCountry() == null) {
306                         // ... and again
307                         throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
308                 } else if (landLineNumber.getPhoneAreaCode() == null) {
309                         // Throw it again
310                         throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
311                 } else if (landLineNumber.getPhoneAreaCode() < 1) {
312                         // Invalid id
313                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
314                 } else if (landLineNumber.getPhoneNumber() == null) {
315                         // Throw it again
316                         throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
317                 } else if (landLineNumber.getPhoneNumber() < 1) {
318                         // Invalid id
319                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
320                 }
321
322                 // Set created instance
323                 landLineNumber.setPhoneEntryCreated(new Date());
324
325                 // Set landLine number in contact
326                 contact.setContactLandLineNumber(landLineNumber);
327
328                 // Update database
329                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
330
331                 // Trace message
332                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
333
334                 // Return it
335                 return updatedContact;
336         }
337
338         @Override
339         public org.mxchange.jcontacts.model.contact.Contact linkNewMobileNumberWithContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
340                 // Trace message
341                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
342
343                 // Is the contact set?
344                 if (null == contact) {
345                         // Throw NPE
346                         throw new NullPointerException("contact is null"); //NOI18N
347                 } else if (contact.getContactId() == null) {
348                         // ... and throw again
349                         throw new NullPointerException("contact.contactId is null"); //NOI18N
350                 } else if (contact.getContactId() < 1) {
351                         // Invalid id number
352                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
353                 } else if (contact.getContactMobileNumber() instanceof org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber) {
354                         // Not set cell phone instance
355                         throw new PhoneNumberAlreadyLinkedException(mobileNumber);
356                 } else if (null == mobileNumber) {
357                         // Throw NPE
358                         throw new NullPointerException("mobileNumber is null"); //NOI18N
359                 } else if (mobileNumber.getPhoneId() instanceof Long) {
360                         // Throw it again
361                         throw new IllegalStateException(MessageFormat.format("mobileNumber.phoneId={0} is not null", mobileNumber.getPhoneId())); //NOI18N
362                 } else if (mobileNumber.getMobileProvider() == null) {
363                         // Throw NPE again
364                         throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
365                 } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
366                         // Throw NPE again
367                         throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
368                 } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
369                         // Throw NPE again
370                         throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
371                 }
372
373                 // Set created instance
374                 mobileNumber.setPhoneEntryCreated(new Date());
375
376                 // Set mobile number in contact
377                 contact.setContactMobileNumber(mobileNumber);
378
379                 // Update database
380                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
381
382                 // Trace message
383                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
384
385                 // Return it
386                 return updatedContact;
387         }
388
389         @Override
390         public org.mxchange.jcontacts.model.contact.Contact unlinkFaxDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException {
391                 // Trace message
392                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
393
394                 // Is the contact set?
395                 if (null == contact) {
396                         // Throw NPE
397                         throw new NullPointerException("contact is null"); //NOI18N
398                 } else if (contact.getContactId() == null) {
399                         // ... and throw again
400                         throw new NullPointerException("contact.contactId is null"); //NOI18N
401                 } else if (contact.getContactId() < 1) {
402                         // Invalid id number
403                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
404                 } else if (contact.getContactFaxNumber() == null) {
405                         // Not set cell phone instance
406                         throw new PhoneNumberNotLinkedException(faxNumber);
407                 } else if (contact.getContactFaxNumber().getPhoneId() == null) {
408                         // Throw NPE again
409                         throw new NullPointerException("contact.contactFaxNumber.phoneId is null"); //NOI18N
410                 } else if (contact.getContactFaxNumber().getPhoneId() < 1) {
411                         // Invalid id number
412                         throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} is invalid.", contact.getContactFaxNumber().getPhoneId())); //NOI18N
413                 } else if (!Objects.equals(faxNumber.getPhoneId(), contact.getContactFaxNumber().getPhoneId())) {
414                         // Not same object
415                         throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} and faxNumber.phoneId={1} are not the same.", contact.getContactFaxNumber().getPhoneId(), faxNumber.getPhoneId())); //NOI18N
416                 }
417
418                 // Remove it from contact
419                 contact.setContactFaxNumber(null);
420
421                 // Update database
422                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
423
424                 // Trace message
425                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
426
427                 // Return it
428                 return updatedContact;
429         }
430
431         @Override
432         public org.mxchange.jcontacts.model.contact.Contact unlinkLandLineDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException {
433                 // Trace message
434                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
435
436                 // Is the contact set?
437                 if (null == contact) {
438                         // Throw NPE
439                         throw new NullPointerException("contact is null"); //NOI18N
440                 } else if (contact.getContactId() == null) {
441                         // ... and throw again
442                         throw new NullPointerException("contact.contactId is null"); //NOI18N
443                 } else if (contact.getContactId() < 1) {
444                         // Invalid id number
445                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
446                 } else if (contact.getContactLandLineNumber() == null) {
447                         // Not set cell phone instance
448                         throw new PhoneNumberNotLinkedException(landLineNumber);
449                 } else if (contact.getContactLandLineNumber().getPhoneId() == null) {
450                         // Throw NPE again
451                         throw new NullPointerException("contact.contactLandLineNumber.phoneId is null"); //NOI18N
452                 } else if (contact.getContactLandLineNumber().getPhoneId() < 1) {
453                         // Invalid id number
454                         throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} is invalid.", contact.getContactLandLineNumber().getPhoneId())); //NOI18N
455                 } else if (!Objects.equals(landLineNumber.getPhoneId(), contact.getContactLandLineNumber().getPhoneId())) {
456                         // Not same object
457                         throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} and landLineNumber.phoneId={1} are not the same.", contact.getContactLandLineNumber().getPhoneId(), landLineNumber.getPhoneId())); //NOI18N
458                 }
459
460                 // Remove it from contact
461                 contact.setContactLandLineNumber(null);
462
463                 // Update database
464                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
465
466                 // Trace message
467                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
468
469                 // Return it
470                 return updatedContact;
471         }
472
473         @Override
474         public org.mxchange.jcontacts.model.contact.Contact unlinkMobileDataFromContact (final org.mxchange.jcontacts.model.contact.Contact contact, final org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber mobileNumber) throws PhoneNumberNotLinkedException {
475                 // Trace message
476                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
477
478                 // Is the contact set?
479                 if (null == contact) {
480                         // Throw NPE
481                         throw new NullPointerException("contact is null"); //NOI18N
482                 } else if (contact.getContactId() == null) {
483                         // ... and throw again
484                         throw new NullPointerException("contact.contactId is null"); //NOI18N
485                 } else if (contact.getContactId() < 1) {
486                         // Invalid id number
487                         throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
488                 } else if (contact.getContactMobileNumber() == null) {
489                         // Not set cell phone instance
490                         throw new PhoneNumberNotLinkedException(mobileNumber);
491                 } else if (contact.getContactMobileNumber().getPhoneId() == null) {
492                         // Throw NPE again
493                         throw new NullPointerException("contact.contactMobileNumber.phoneId is null"); //NOI18N
494                 } else if (contact.getContactMobileNumber().getPhoneId() < 1) {
495                         // Invalid id number
496                         throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} is invalid.", contact.getContactMobileNumber().getPhoneId())); //NOI18N
497                 } else if (!Objects.equals(mobileNumber.getPhoneId(), contact.getContactMobileNumber().getPhoneId())) {
498                         // Not same object
499                         throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
500                 }
501
502                 // Remove it from contact
503                 contact.setContactMobileNumber(null);
504
505                 // Update database
506                 final org.mxchange.jcontacts.model.contact.Contact updatedContact = this.contactBean.updateContactData(contact);
507
508                 // Trace message
509                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
510
511                 // Return it
512                 return updatedContact;
513         }
514
515 }