/*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.contact.title.PersonalTitle;
+import org.mxchange.jcontactsbusiness.exceptions.BusinessContactAlreadyAddedException;
import org.mxchange.jcore.client.Client;
import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
import org.mxchange.jcore.facade.BaseFacade;
import org.mxchange.jcoreeelogger.beans.local.logger.Log;
import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
import org.mxchange.jcountry.data.Country;
-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.phonenumbers.mobile.DialableMobileNumber;
/**
* A facade for contacts.
* <p>
- * @author Roland Haeder
+ * @author Roland Häder<roland@mxchange.org>
* @version 0.0
*/
public class AddressbookContactFacade extends BaseFacade implements ContactFacade {
*/
private final List<String> columnNames;
- /**
- * Entity manager
- */
- @PersistenceContext
- private EntityManager entityManager;
-
/**
* Logger instance
*/
@Log
- private LoggerBeanLocal logger;
+ private LoggerBeanLocal loggerBeanLocal;
/**
* Translated column name list
*/
public AddressbookContactFacade (final Client client) throws SQLException {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
// Make sure all parameters are set correctly
if (null == client) {
}
@Override
- public void addContact (final Contact contact) throws ContactAlreadyAddedException {
+ public void addContact (final Contact contact) throws BusinessContactAlreadyAddedException {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
// Contact instance must not be null
if (null == contact) {
this.entityManager.persist(contact);
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
@Override
public void doChangeAddressData (final Contact contact) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
// Contact must not be null
if (null == contact) {
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
public void doChangeNameData (final Contact contact) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
// Contact must not be null
if (null == contact) {
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
@Override
public void doChangeOtherData (final Contact contact) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
// Contact must not be null
if (null == contact) {
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
public void doChangeOwnData () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
/*
* First check if the user has registered own contact, before that
// Ask user what to change
client.userChooseChangeContactData(contact);
} catch (final UnhandledUserChoiceException ex) {
- this.getLogger().logException(ex);
+ this.getLoggerBeanLocal().logException(ex);
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
}
@Override
- public void doEnterOwnData () throws ContactAlreadyAddedException {
+ public void doEnterOwnData () throws BusinessContactAlreadyAddedException {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Is own contact already added?
if (this.isOwnContactAdded()) {
// Don't continue here
- throw new ContactAlreadyAddedException();
+ throw new BusinessContactAlreadyAddedException();
}
// Get and cast client instance
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
@Override
public void doShutdown () throws SQLException, IOException {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Shut down the database layer
this.entityManager.close();
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
@Override
- public DialableCellphoneNumber enterOwnCellNumber () {
+ public DialableMobileNumber enterOwnCellNumber () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnCity () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnComment () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnCompanyName () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public Country enterOwnCountryCode () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnEmailAddress () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnFamilyName () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public DialableFaxNumber enterOwnFaxNumber () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnFirstName () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
}
@Override
- public Gender enterOwnGender () {
+ public PersonalTitle enterOwnPersonalTitle () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
- return client.enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
+ return client.enterPersonalTitle("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
}
@Override
public DialableLandLineNumber enterOwnPhoneNumber () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public String enterOwnStreet () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public int enterOwnZipCode () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
@Override
public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
// Convert column index -> name
String columnName = this.getColumnName(columnIndex);
// Debug message
- this.getLogger().logDebug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
// Init value
Object value = null;
// Trace message
- this.getLogger().logTrace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
// Return it
return value;
@Override
public boolean isOwnContactAdded () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Init variable
boolean isAdded = false;
// Trace message
- this.getLogger().logTrace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
// Return result
return isAdded;
@Override
public void registerContact (final Contact contact) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
// Sanity check
if (null == contact) {
// Add contact to internal list
this.addContact(contact);
- } catch (final ContactAlreadyAddedException ex) {
+ } catch (final BusinessContactAlreadyAddedException ex) {
// Abort here
this.abortProgramWithException(ex);
}
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
/**
assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
// Debug message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// First get an iterator from key set to iterate over
Iterator<String> iterator = this.getBundle().keySet().iterator();
// Does the key start with AddressbookContactFacade.columnName ?
if (key.startsWith("ContactManager.columnName")) { //NOI18N
// This is the wanted entry.
- this.getLogger().logDebug(MessageFormat.format("key={0}", key)); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("key={0}", key)); //NOI18N
// Convert string to array based on delimiter '.'
String[] tokens = this.getArrayFromString(key, "."); //NOI18N
String columnName = tokens[tokens.length - 2];
// Debug message
- this.getLogger().logDebug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
// So add it
this.columnNames.add(columnName);
}
// Debug message
- this.getLogger().logTrace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
}
/**
- * Getter for logger instance
+ * Getter for loggerBeanLocal instance
* <p>
* @return Logger instance
*/
- private LoggerBeanLocal getLogger () {
- return this.logger;
+ private LoggerBeanLocal getLoggerBeanLocal () {
+ return this.loggerBeanLocal;
}
/**
*/
private Contact getOwnContact () {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Deligate this call to database frontend
Contact contact = null;
//Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
// Trace message
- this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
// Return instance or null
return contact;
* @param exception Throwable
*/
protected void logException (final Throwable exception) {
- this.getLogger().logException(exception);
+ this.getLoggerBeanLocal().logException(exception);
}
}