]> git.mxchange.org Git - addressbook-swing.git/blobdiff - src/org/mxchange/addressbook/client/console/ConsoleClient.java
Continued:
[addressbook-swing.git] / src / org / mxchange / addressbook / client / console / ConsoleClient.java
index 6bccf45ccf5ef27358c7554791a03c6d82d605a1..baf7955cdebfab6ad213f8770baafa46ba4ec0d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Häder
+ * Copyright (C) 2016 - 2022 Free Software Foundation
  *
  * 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
@@ -30,18 +30,14 @@ import org.mxchange.addressbook.menu.MenuTools;
 import org.mxchange.addressbook.menu.console.ConsoleMenu;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 import org.mxchange.addressbook.menu.item.console.ConsoleMenuItem;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.contact.gender.GenderUtils;
-import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jcontacts.model.utils.PersonalTitleUtils;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException;
 import org.mxchange.jcore.application.Application;
 import org.mxchange.jcore.exceptions.MenuInitializationException;
 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * A client for the console
@@ -103,11 +99,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                        throw new NullPointerException("contact is null"); //NOI18N
                }
 
-               // Get translated gender as the user may want to see "Mr.", "Mrs."
-               String gender = GenderUtils.getTranslatedGender(contact);
+               // Get translated title as the user may want to see "Mr.", "Mrs."
+               String title = PersonalTitleUtils.getTranslatedPersonalTitle(contact);
 
-               // Now put all together: gender, surname, family name
-               this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getContactFirstName(), contact.getContactFamilyName()));
+               // Now put all together: title, surname, family name
+               this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", title, contact.getContactFirstName(), contact.getContactFamilyName()));
 
                // Trace message
                this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
@@ -193,8 +189,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                // Get manager and cast it
                ContactFacade manager = (ContactFacade) this.getFacade();
 
-               // Gender:
-               Gender gender = manager.enterOwnGender();
+               // PersonalTitle:
+               PersonalTitle title = manager.enterOwnPersonalTitle();
 
                // Surname
                String firstName = manager.enterOwnFirstName();
@@ -203,7 +199,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String familyName = manager.enterOwnFamilyName();
 
                // Update contact instance
-               contact.setContactGender(gender);
+               contact.setContactPersonalTitle(title);
                contact.setContactFirstName(firstName);
                contact.setContactFamilyName(familyName);
 
@@ -265,8 +261,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                // Get manager and cast it
                ContactFacade manager = (ContactFacade) this.getFacade();
 
-               // First ask for gender
-               Gender gender = manager.enterOwnGender();
+               // First ask for title
+               PersonalTitle title = manager.enterOwnPersonalTitle();
 
                // 2nd for first name
                String firstName = manager.enterOwnFirstName();
@@ -275,7 +271,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String familyName = manager.enterOwnFamilyName();
 
                // Construct UserContact instance
-               Contact contact = new UserContact(gender, firstName, familyName);
+               Contact contact = new UserContact(title, firstName, familyName);
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
@@ -315,13 +311,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                switch (choice) {
                        case '1':
                                try {
-                                       // Enter/add own data
-                                       manager.doEnterOwnData();
-                               } catch (final ContactAlreadyAddedException ex) {
-                                       // Already added
-                                       this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
-                               }
-                               break;
+                               // Enter/add own data
+                               manager.doEnterOwnData();
+                       } catch (final BasicDataAlreadyAddedException ex) {
+                               // Already added
+                               this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
+                       }
+                       break;
 
                        case '2': // Change own data
                                manager.doChangeOwnData();
@@ -349,12 +345,12 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
 
                        case '0':
                                try {
-                                       // Program exit
-                                       this.getApplication().doShutdown();
-                               } catch (final SQLException | IOException ex) {
-                                       this.abortProgramWithException(ex);
-                               }
-                               break;
+                               // Program exit
+                               this.getApplication().doShutdown();
+                       } catch (final SQLException | IOException ex) {
+                               this.abortProgramWithException(ex);
+                       }
+                       break;
 
                        default:
                                // TODO throw own exception
@@ -402,23 +398,23 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        }
 
        @Override
-       public Gender enterGender (final String message) {
+       public PersonalTitle enterPersonalTitle (final String message) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
 
                // Get valid chars
-               char[] validChars = Gender.validChars();
+               char[] validChars = PersonalTitle.validChars();
 
                // Debug message
                //* NOISY-DEBUG: */ System.out.println(validChars);
                // Call inner method
-               char gender = this.enterChar(validChars, message);
+               char title = this.enterChar(validChars, message);
 
-               // Now get a Gender instance back
-               Gender g = Gender.fromChar(gender);
+               // Now get a PersonalTitle instance back
+               PersonalTitle g = PersonalTitle.fromChar(title);
 
                // g must not be null
-               assert (g instanceof Gender) : "g is not set."; //NOI18N
+               assert (g instanceof PersonalTitle) : "g is not set."; //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
@@ -660,4 +656,5 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                // Trace message
                this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
+
 }