]> git.mxchange.org Git - jfinancials-lib.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 10:03:38 +0000 (12:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 13:21:04 +0000 (15:21 +0200)
- added jcontacts-business-core.jar (model/POJO/POJI for business contacts)
- renamed jcontacts -> jcontacts-core
- added persistence as the facade will do it (maybe this will be moved to EJB?)
- moved exception to jcontacts-core
- fixed imports
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcontacts-business-core.jar [new file with mode: 0644]
lib/jcontacts-core.jar [new file with mode: 0644]
lib/jcontacts.jar [deleted file]
lib/jpa20-persistence/javax.persistence-2.1.0-doc.zip [new file with mode: 0644]
lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar [new file with mode: 0644]
nbproject/project.properties
src/org/mxchange/addressbook/exceptions/ContactAlreadyAddedException.java [deleted file]
src/org/mxchange/addressbook/facade/contact/AddressbookContactFacade.java
src/org/mxchange/addressbook/facade/contact/ContactFacade.java

diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar
new file mode 100644 (file)
index 0000000..6a1d4ef
Binary files /dev/null and b/lib/jcontacts-business-core.jar differ
diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar
new file mode 100644 (file)
index 0000000..13b4e24
Binary files /dev/null and b/lib/jcontacts-core.jar differ
diff --git a/lib/jcontacts.jar b/lib/jcontacts.jar
deleted file mode 100644 (file)
index b2e362b..0000000
Binary files a/lib/jcontacts.jar and /dev/null differ
diff --git a/lib/jpa20-persistence/javax.persistence-2.1.0-doc.zip b/lib/jpa20-persistence/javax.persistence-2.1.0-doc.zip
new file mode 100644 (file)
index 0000000..fd55e6e
Binary files /dev/null and b/lib/jpa20-persistence/javax.persistence-2.1.0-doc.zip differ
diff --git a/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar b/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar
new file mode 100644 (file)
index 0000000..841d2e1
Binary files /dev/null and b/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar differ
index 8eb5de30cac5372e6efe594b8575450c488773a7..7e0ac8ea55fd5bee3461b4a8fea39de1abb1e75e 100644 (file)
@@ -30,7 +30,8 @@ dist.jar=${dist.dir}/addressbook-lib.jar
 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
@@ -42,7 +43,9 @@ javac.classpath=\
     ${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
@@ -91,7 +94,8 @@ run.test.classpath=\
     ${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
diff --git a/src/org/mxchange/addressbook/exceptions/ContactAlreadyAddedException.java b/src/org/mxchange/addressbook/exceptions/ContactAlreadyAddedException.java
deleted file mode 100644 (file)
index 53e3ac0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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");
-       }
-
-}
index ce6d43ac3fc0832a1e4c6a4a02cea0cac781836c..105bec45ffb3919b4d7b0d8e66039b39f645db8d 100644 (file)
@@ -24,6 +24,8 @@ import java.util.ArrayList;
 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;
@@ -47,6 +49,12 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
         */
        private final List<String> columnNames;
 
+       /**
+        * Entity manager
+        */
+       @PersistenceContext
+       private EntityManager entityManager;
+
        /**
         * Logger instance
         */
@@ -78,10 +86,6 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
                // 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);
@@ -105,7 +109,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
                }
 
                // Add it
-               ((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
+               this.entityManager.persist(contact);
 
                // Trace message
                this.getLogger().logTrace("EXIT!"); //NOI18N
@@ -303,7 +307,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
                this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Shut down the database layer
-               ((AddressbookContactFrontend) this.getFrontend()).doShutdown();
+               this.entityManager.close();
 
                // Trace message
                this.getLogger().logTrace("EXIT!"); //NOI18N
@@ -328,7 +332,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
                // 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
@@ -549,7 +553,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
                }
                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())) {
@@ -559,7 +563,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
 
                        // 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);
                }
@@ -570,7 +574,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
 
        /**
         * Logs given exception and exits program
-        *
+        * <p>
         * @param throwable Throwable
         */
        private void abortProgramWithException (Throwable throwable) {
@@ -628,7 +632,7 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
 
        /**
         * Getter for logger instance
-        *
+        * <p>
         * @return Logger instance
         */
        private LoggerBeanLocal getLogger () {
@@ -639,18 +643,14 @@ public class AddressbookContactFacade extends BaseFacade implements ContactFacad
         * "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
index 889ba785f9265d39837da160f6bd1a821d536de2..7b206e867df5b3568e5a044321cf2f5f07d0def5 100644 (file)
@@ -19,9 +19,9 @@ package org.mxchange.addressbook.facade.contact;
 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;
 
 /**
@@ -35,7 +35,7 @@ public interface ContactFacade extends 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;
 
@@ -91,8 +91,7 @@ public interface ContactFacade extends Facade {
        /**
         * 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;