]> git.mxchange.org Git - jaddressbook-share-lib.git/commitdiff
Final (hopeful) fixes for new jcore. Still some new method(s) need(s) implementation.
authorRoland Haeder <roland@mxchange.org>
Mon, 24 Aug 2015 12:29:18 +0000 (14:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 24 Aug 2015 12:29:18 +0000 (14:29 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java

index 25f84964d533664467cedb2ec25bd4644e31def0..3577e17b433a2888e201f95ae214c0dcf225ad9f 100644 (file)
@@ -83,12 +83,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                this.initBackend();
        }
 
-       /**
-        * Adds given contact instance to database
-        *
-        * @param contact Contact instance
-        * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact instance is already found
-        */
        @Override
        public void addContact (final Contact contact) throws ContactAlreadyAddedException {
                // Trace message
@@ -127,7 +121,7 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
 
                        // Debug message
                        this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
-               } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+               } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | CorruptedDatabaseFileException ex) {
                        // Abort here
                        this.abortProgramWithException(ex);
                }
@@ -136,11 +130,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                this.getLogger().trace("CALLED!"); //NOI18N
        }
 
-       /**
-        * 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 {
                // Trace message
@@ -226,14 +215,8 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                throw new UnsupportedOperationException("Not supported yet: rowIndex=" + rowIndex);
        }
 
-       /**
-        * Checks if given Contact is found
-        * 
-        * @param contact Contact instance to check
-        * @return Whether the given Contact instance is found
-        */
        @Override
-       public boolean isContactFound (final Contact contact) throws BadTokenException {
+       public boolean isContactFound (final Contact contact) throws BadTokenException, IOException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
@@ -246,8 +229,16 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                // Default is not found
                boolean isFound = false;
 
+               // Init search instance (but empty)
+               SearchableCriteria criteria = new SearchCriteria();
+
+               // Look for all entries and compare here. Else all entries needs to be compared with many AND statements
+               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("result({0})={1}", result.size(), result));
                // Start iteration
-               Iterator<? extends Storeable> iterator = this.getBackend().iterator();
+               Iterator<? extends Storeable> iterator = result.iterator();
 
                // Check all entries
                while (iterator.hasNext()) {
@@ -272,16 +263,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                return isFound;
        }
 
-       /**
-        * Checks whether own contact is found in database
-        *
-        * @return Whether own contact is found
-        * @throws org.mxchange.jcore.exceptions.BadTokenException Continued throw
-        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If the database file is damaged
-        * @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?
-        */
        @Override
        public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Get search criteria instance