]> git.mxchange.org Git - jfinancials-swing.git/commitdiff
Updated jcore + some more fixes for changed database backend (Table Data Gateway...
authorRoland Haeder <roland@mxchange.org>
Mon, 24 Aug 2015 11:30:16 +0000 (13:30 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 24 Aug 2015 11:30:16 +0000 (13:30 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcore.jar
nbproject/project.properties
src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java
src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java
src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java

index 4ad2d9d51895e21f4aa9cee85a33acf155bc655c..d426e0dec31b4479bf275fbb9cc6ca3ba25ffd7c 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index d1a9fce074d383ae8d588146a2f710993f52361d..7d2fb23ffd39b6d3226be6a21be84fcbe67b68c6 100644 (file)
@@ -78,6 +78,7 @@ run.test.classpath=\
     ${javac.test.classpath}:\
     ${build.test.classes.dir}
 source.encoding=UTF-8
+source.reference.jcore.jar=../jcore/src/
 source.reference.log4j-api-2.3.jar=/home/quix0r/MyProjects/JARs/log4j-api-2.3-sources.jar
 source.reference.log4j-core-2.3.jar=/home/quix0r/MyProjects/JARs/log4j-core-2.3-sources.jar
 src.dir=src
index 89802a8b5198ea3bc1f789da99e5dd1a21cc8856..e51b94209566dae5ae8a970e23fade28283e57c1 100644 (file)
 package org.mxchange.addressbook.database.frontend.contact;
 
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.StringTokenizer;
-import org.mxchange.addressbook.contact.book.BookContact;
-import org.mxchange.addressbook.contact.user.UserContact;
 import org.mxchange.addressbook.database.contact.AddressbookContactDatabaseConstants;
 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
 import org.mxchange.addressbook.manager.contact.AddressbookContactManager;
 import org.mxchange.jcore.contact.Contact;
-import org.mxchange.jcore.contact.Gender;
 import org.mxchange.jcore.criteria.searchable.SearchCriteria;
 import org.mxchange.jcore.criteria.searchable.SearchableCriteria;
 import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend;
@@ -110,9 +107,27 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                                throw new ContactAlreadyAddedException(contact);
                        }
 
+                       // Clear dataset from previous usage
+                       this.clearDataSet();
+
+                       // Get field iterator
+                       Iterator<Map.Entry<Field, Object>> iterator = contact.iterator();
+
+                       // Iterate over all
+                       while (iterator.hasNext()) {
+                               // Get next field
+                               Map.Entry<Field, Object> field = iterator.next();
+
+                               // Add it to data set
+                               this.addToDataSet(field.getKey().getName(), field.getValue());
+                       }
+
                        // Then add it
-                       this.getBackend().store((Storeable) contact);
-               } catch (final IOException | BadTokenException ex) {
+                       Result<? extends Storeable> result = this.doInsertDataSet();
+
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
+               } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Abort here
                        this.abortProgramWithException(ex);
                }
@@ -123,6 +138,8 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
 
        /**
         * Shuts down the database layer
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
         */
        @Override
        public void doShutdown () throws SQLException, IOException {
@@ -147,9 +164,15 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
         * @return Total contact count
         */
        @Override
-       public int getContactsCount () throws SQLException {
+       public int getContactsCount () throws SQLException, IOException {
                // And deligate to backend
-               return this.getBackend().getTotalCount(); //NOI18N
+               return this.getBackend().getTotalRows(); //NOI18N
+       }
+
+       @Override
+       public String getIdName () {
+               // Return id column
+               return AddressbookContactDatabaseConstants.COLUMN_ID;
        }
 
        /**
@@ -281,10 +304,4 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
        public Storeable toStoreable (final Map<String, String> map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                throw new UnsupportedOperationException("Not supported yet: map=" + map);
        }
-
-       @Override
-       public String getIdName () {
-               // Return id column
-               return AddressbookContactDatabaseConstants.COLUMN_ID;
-       }
 }
index 213575eb3de7d6a5b3bc3972c7da47139e1c3628..d1c46b7a96d6269f4e8da4491ecb89a1629790fb 100644 (file)
@@ -44,9 +44,10 @@ public interface AddressbookContactFrontend extends DatabaseFrontend {
         * Some "getter" for total contacts count
         *
         * @return Total contacts count
-        * @throws java.sql.SQLException If any SQL error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
         */
-       public int getContactsCount () throws SQLException;
+       public int getContactsCount () throws SQLException, IOException;
 
        /**
         * Checks if given Contact is found
index 3def29dbe88ca96c29afc94f223591d81a3bf097..d928695d982cd359ed03d69f63e59f0849a98c70 100644 (file)
@@ -683,11 +683,11 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                        // Abort here
                        throw new NullPointerException("contact is null"); //NOI18N
                }
-
-               // Debug message
-               /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getFirstName(), contact.getFamilyName(), this.size())); //NOI18N
                try {
-                       // Check if contact is found
+                       // Debug message
+                       /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getFirstName(), contact.getFamilyName(), this.size())); //NOI18N
+
+               // Check if contact is found
                        if (this.getContactDatabase().isContactFound(contact)) {
                                // Contact already added
                                // @todo Do something here
@@ -707,13 +707,8 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
-       /**
-        * Getter for size
-        *
-        * @return size of contact "book"
-        */
        @Override
-       public final int size () {
+       public final int size () throws IOException {
                // Init size
                int size = -1;