From: Roland Haeder Date: Fri, 4 Sep 2015 13:28:43 +0000 (+0200) Subject: Removed all TDGP-related classes as Persistence is coming + updated jcore X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1702a5356aeeb74e7654b96fa253fb3b2050f0a9;p=jfinancials-swing.git Removed all TDGP-related classes as Persistence is coming + updated jcore Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index a12ac5b..61bf6e6 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java b/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java deleted file mode 100644 index 4596c57..0000000 --- a/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java +++ /dev/null @@ -1,40 +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 . - */ -package org.mxchange.addressbook.database.contact; - -/** - * A class holding constants for contact table - * - * @author Roland Haeder - */ -public final class AddressbookContactDatabaseConstants { - /** - * Column own_contact - */ - public static final String COLUMN_OWN_CONTACT = "own_contact"; //NOI18N - - /** - * Column id - */ - public static final String COLUMN_ID = "id"; - - /** - * No instances are allowed as this class only holds static attributes - */ - private AddressbookContactDatabaseConstants () { - } -} diff --git a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java b/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java deleted file mode 100644 index 7a5d205..0000000 --- a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java +++ /dev/null @@ -1,286 +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 . - */ -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 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.criteria.searchable.SearchCriteria; -import org.mxchange.jcore.criteria.searchable.SearchableCriteria; -import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend; -import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storable; -import org.mxchange.jcore.exceptions.BadTokenException; -import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; -import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; - -/** - * Stores and retrieves Contact instances - * - * @author Roland Haeder - */ -public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend implements AddressbookContactFrontend { - - /** - * Constructor which accepts a contact manager - * - * @param manager Manager instance - * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the database backend is not supported - * @throws java.sql.SQLException If an SQL error occurs - */ - public AddressbookContactDatabaseFrontend (final AddressbookContactManager manager) throws UnsupportedDatabaseBackendException, SQLException { - // Call own constructor - this(); - - // Trace message - this.getLogger().trace(MessageFormat.format("manager={0} - CALLED!", manager)); //NOI18N - - // Manager instance must not be null - if (null == manager) { - // Abort here - throw new NullPointerException("manager is null"); //NOI18N - } - - // Set contact manager - this.setContactManager(manager); - } - - /** - * Default but protected constructor - * @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 () throws UnsupportedDatabaseBackendException, SQLException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Set "table" name - this.setTableName("contacts"); //NOI18N - - // Initalize backend - this.initBackend(); - } - - @Override - public void addContact (final Contact contact) throws ContactAlreadyAddedException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Make sure the contact is set - if (null == contact) { - // Abort here - throw new NullPointerException("contact is null"); //NOI18N - } - - try { - // First check if the contact is there - if (this.isContactFound(contact)) { - // Already there - throw new ContactAlreadyAddedException(contact); - } - - // Clear dataset from previous usage - this.clearDataSet(); - - // Get field iterator - Iterator> iterator = contact.iterator(); - - // Iterate over all - while (iterator.hasNext()) { - // Get next field - Map.Entry field = iterator.next(); - - // Add it to data set - this.addToDataSet(field.getKey().getName(), field.getValue()); - } - - // Then add it - // TODO Nothing is done yet! - Result result = this.doInsertDataSet(); - - // Debug message - this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N - } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | CorruptedDatabaseFileException ex) { - // Abort here - this.abortProgramWithException(ex); - } - - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - } - - @Override - public void doShutdown () throws SQLException, IOException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Shutdown backend - this.getBackend().doShutdown(); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } - - @Override - public Object emptyStringToNull (final String key, final Object value) { - throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: key={0},value={1}", key, value)); - } - - /** - * Some "getter" for total contact count - * - * @return Total contact count - */ - @Override - public int getContactsCount () throws SQLException, IOException { - // And deligate to backend - return this.getBackend().getTotalRows(); //NOI18N - } - - @Override - public String getIdName () { - // Return id column - return AddressbookContactDatabaseConstants.COLUMN_ID; - } - - @Override - public Contact getOwnContact () throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Prepare search instance - SearchableCriteria criteria = new SearchCriteria(); - - // Add criteria and limit - criteria.addCriteria(AddressbookContactDatabaseConstants.COLUMN_OWN_CONTACT, true); - criteria.setLimit(1); - - // Then search for it - Result result = this.getBackend().doSelectByCriteria(criteria); - - // Debug message - this.getLogger().debug(MessageFormat.format("result={0}", result)); - - // Init instance - Contact contact = null; - - // Is there one row at least? - if (result.hasNext()) { - // Then get it - Storable storable = result.next(); - - // Debug message - this.getLogger().debug(MessageFormat.format("storable={0}", storable)); - - // Is it same instance? - if (!(storable instanceof Contact)) { - // Not same instance - throw new IllegalArgumentException(MessageFormat.format("storable={0} is not implementing Contact", storable)); - } - - // Cast it securely - contact = (Contact) storable; - } - - // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); - - // Return it - return contact; - } - - @Override - public Storable getStorableAtRow (final int rowIndex) { - throw new UnsupportedOperationException("Not supported yet: rowIndex=" + rowIndex); - } - - @Override - 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 - - // contact should not be null - if (null == contact) { - // Abort here - throw new NullPointerException("contact is null"); //NOI18N - } - - // 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 result = this.getBackend().doSelectByCriteria(criteria); - - // Debug message - this.getLogger().debug(MessageFormat.format("result({0})={1}", result.size(), result)); - // Start iteration - Iterator iterator = result.iterator(); - - // Check all entries - while (iterator.hasNext()) { - // Get next element - Contact c = (Contact) iterator.next(); - - // Debug message - this.getLogger().debug(MessageFormat.format("c={0},contact={1}", c, contact)); //NOI18N - - // Is it added? - if (c.equals(contact)) { - // Is found - isFound = true; - break; - } - } - - // Trace message - this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound)); //NOI18N - - // Return it - return isFound; - } - - @Override - public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // Get search criteria instance - SearchableCriteria criteria = new SearchCriteria(); - - // Add condition - criteria.addCriteria(AddressbookContactDatabaseConstants.COLUMN_OWN_CONTACT, true); - - // Get result - Result result = this.getBackend().doSelectByCriteria(criteria); - - // Deligate this call to backend - return result.hasNext(); - } - - @Override - public Storable toStorable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - throw new UnsupportedOperationException("Not supported yet: map=" + map); - } -} diff --git a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java b/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java deleted file mode 100644 index b06940a..0000000 --- a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2015 Roland Häder - * - * 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 . - */ -package org.mxchange.addressbook.database.frontend.contact; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.sql.SQLException; -import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.database.frontend.DatabaseFrontend; -import org.mxchange.jcore.exceptions.BadTokenException; -import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; - -/** - * An interface for addressbook contact database frontends - * - * @author Roland Häder - */ -public interface AddressbookContactFrontend extends DatabaseFrontend { - - /** - * Adds given contact instance to database - * - * @param contact Contact instance to add - * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added - */ - public void addContact (final Contact contact) throws ContactAlreadyAddedException; - - /** - * Some "getter" for total contacts count - * - * @return Total contacts count - * @throws java.sql.SQLException If an SQL error occurs - * @throws java.io.IOException If an IO error occurs - */ - public int getContactsCount () throws SQLException, IOException; - - /** - * Checks if given Contact is found - * - * @param contact Contact instance to check - * @return Whether the given Contact instance is found - * @throws java.sql.SQLException If an SQL error occurs - * @throws java.io.IOException If an IO error occurs - * @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? - */ - public boolean isContactFound (final Contact contact) throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; - - /** - * Some "getter" for own contact instance - * - * @return Own contact instance - * @throws java.sql.SQLException If an SQL error occurs - * @throws java.io.IOException If an IO error occurs - * @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? - */ - public Contact getOwnContact () throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; - - /** - * Checks whether own contact is found - * - * @return Whether own contact is found - * @throws java.sql.SQLException If any SQL error occurs - * @throws java.io.IOException If an IO error occurs - * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found - * @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? - */ - public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; -} diff --git a/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java b/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java index 554a42d..23ca2f2 100644 --- a/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java +++ b/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java @@ -25,8 +25,6 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.mxchange.addressbook.client.AddressbookClient; -import org.mxchange.addressbook.database.frontend.contact.AddressbookContactDatabaseFrontend; -import org.mxchange.addressbook.database.frontend.contact.AddressbookContactFrontend; import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; import org.mxchange.jcore.client.Client; import org.mxchange.jcore.contact.Contact;