From 4a864c437dc5534098b18848a02ebbdddc2d6238 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 12 Aug 2015 15:58:15 +0200 Subject: [PATCH] =?utf8?q?Rewrite=20to=20data-gateway=20pattern=20Signed-o?= =?utf8?q?ff-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../AddressbookContactDatabaseFrontend.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java index 6fb08169..9b574f3d 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java @@ -28,7 +28,10 @@ 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.SearchableCritera; import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend; +import org.mxchange.jcore.database.result.Result; import org.mxchange.jcore.database.storage.Storeable; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; @@ -64,21 +67,18 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp /** * Basic constrcutor + * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the database backend is not supported + * @throws java.sql.SQLException Any SQL exception from e.g. MySQL connector */ - protected AddressbookContactDatabaseFrontend () { + protected AddressbookContactDatabaseFrontend () throws UnsupportedDatabaseBackendException, SQLException { // Trace message this.getLogger().trace("CALLED!"); //NOI18N // Set "table" name this.setTableName("contacts"); //NOI18N - try { - // Initalize backend - this.initBackend(); - } catch (final UnsupportedDatabaseBackendException | SQLException ex) { - // Abort program - this.abortProgramWithException(ex); - } + // Initalize backend + this.initBackend(); } /** @@ -229,8 +229,17 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp */ @Override public boolean isOwnContactFound () throws SQLException { + // Get search criteria instance + SearchableCritera critera = new SearchCriteria(); + + // Add condition + critera.addCriteria(AddressbookContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); + + // Get result + Result result = this.getBackend().doSelectByCriteria(critera); + // Deligate this call to backend - return this.getBackend().isRowFound(AddressbookContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); + return result.hasNext(); } /** -- 2.39.5