dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
-file.reference.jcontacts.jar=lib/jcontacts.jar
+file.reference.jcontacts-business-core.jar=lib\\jcontacts-business-core.jar
+file.reference.jcontacts-core.jar=lib\\jcontacts-core.jar
file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar
file.reference.jcore-swing.jar=lib/jcore-swing.jar
file.reference.jcore.jar=lib/jcore.jar
${file.reference.jcore.jar}:\
${file.reference.jcore-swing.jar}:\
${file.reference.jcore-logger-lib.jar}:\
- ${file.reference.jcontacts.jar}
+ ${file.reference.jcontacts-core.jar}:\
+ ${file.reference.jcontacts-business-core.jar}:\
+ ${libs.jpa20-persistence.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:deprecation -Xlint:unchecked
javac.deprecation=true
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
-source.reference.jcontacts.jar=../jcontacts/src/
+source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
+source.reference.jcontacts-core.jar=../jcontacts-core/src/
source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/
source.reference.jcore-swing.jar=../jcore-swing/src
source.reference.jcore.jar=../jcore/src
+++ /dev/null
-/*
- * Copyright (C) 2015 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.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jcontacts.contact.Contact;
-
-/**
- * Thrown if the given Contact instance is already added
- * <p>
- * @author Roland Haeder
- */
-public class ContactAlreadyAddedException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 75844851467L;
-
- /**
- * Constructor with a Contact instance
- * <p>
- * @param contact Contact that is already added
- */
- public ContactAlreadyAddedException (final Contact contact) {
- super(MessageFormat.format("Contact with gender={0}, firstName={1} and familyName={2} already added.", contact.getGender(), contact.getFirstName(), contact.getFamilyName()));
- }
-
- /**
- * Default constructor, may be used if no contact instance is available
- */
- public ContactAlreadyAddedException () {
- super("Contact already added");
- }
-
-}
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.addressbook.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcontacts.contact.Contact;
*/
private final List<String> columnNames;
+ /**
+ * Entity manager
+ */
+ @PersistenceContext
+ private EntityManager entityManager;
+
/**
* Logger instance
*/
// Set client instance
this.setClient(client);
- // Init database connection
- DatabaseFrontend frontend = new AddressbookContactDatabaseFrontend(this);
- this.setFrontend(frontend);
-
// Initialize list
this.columnNames = new ArrayList<>(15);
this.translatedColumnNames = new ArrayList<>(15);
}
// Add it
- ((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
+ this.entityManager.persist(contact);
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
this.getLogger().logTrace("CALLED!"); //NOI18N
// Shut down the database layer
- ((AddressbookContactFrontend) this.getFrontend()).doShutdown();
+ this.entityManager.close();
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
// Get and cast client instance
AddressbookClient client = (AddressbookClient) this.getClient();
- return client.enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
+ return client.enterString(3, 50, "Bitte geben Sie Ihren Wohnort ein: ", false);
}
@Override
}
try {
// Check if contact is found
- if (((AddressbookContactFrontend) this.getFrontend()).isContactFound(contact)) {
+ if (this.entityManager.contains(contact)) {
// Contact already added
// TODO Do something here
} else if ((contact.isOwnContact()) && (this.isOwnContactAdded())) {
// Add contact to internal list
this.addContact(contact);
- } catch (final ContactAlreadyAddedException | SQLException | IOException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+ } catch (final ContactAlreadyAddedException | IOException ex) {
// Abort here
this.abortProgramWithException(ex);
}
/**
* Logs given exception and exits program
- *
+ * <p>
* @param throwable Throwable
*/
private void abortProgramWithException (Throwable throwable) {
/**
* Getter for logger instance
- *
+ * <p>
* @return Logger instance
*/
private LoggerBeanLocal getLogger () {
* "Getter" for own contact instance or null if not found
* <p>
* @return Contact instance or null
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
- * @throws java.lang.NoSuchMethodException If a method cannot be found
- * @throws java.lang.IllegalAccessException If a method is not accessible
- * @throws java.lang.reflect.InvocationTargetException Any other problems?
*/
- private Contact getOwnContact () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ private Contact getOwnContact () {
// Trace message
this.getLogger().logTrace("CALLED!"); //NOI18N
// Deligate this call to database frontend
- Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
+ Contact contact = null;
+ //Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
// Trace message
this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
-import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcore.facade.Facade;
/**
* Adds given Contact instance to list
* <p>
* @param contact Contact instance to add
- * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
+ * @throws org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException If the contact is already added
*/
public void addContact (final Contact contact) throws ContactAlreadyAddedException;
/**
* Asks user for own data
* <p>
- * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
- * If own contact is already added
+ * @throws org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException If own contact is already added
* @throws java.io.IOException If an IO error was found
*/
public void doEnterOwnData () throws ContactAlreadyAddedException, IOException;