Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.rmi.RemoteException;
import java.util.Date;

import de.willuhn.jameica.hbci.rmi.TransferQueryBuilder;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithDBService;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithStatusbarMessage;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -44,19 +47,15 @@
import de.willuhn.jameica.hbci.messaging.ObjectChangedMessage;
import de.willuhn.jameica.hbci.messaging.ObjectMessage;
import de.willuhn.jameica.hbci.reminder.ReminderStorageProviderHibiscus;
import de.willuhn.jameica.hbci.rmi.HBCIDBService;
import de.willuhn.jameica.hbci.rmi.HibiscusDBObject;
import de.willuhn.jameica.hbci.rmi.Konto;
import de.willuhn.jameica.hbci.rmi.SammelTransfer;
import de.willuhn.jameica.hbci.rmi.SammelTransferBuchung;
import de.willuhn.jameica.messaging.Message;
import de.willuhn.jameica.messaging.MessageConsumer;
import de.willuhn.jameica.messaging.StatusBarMessage;
import de.willuhn.jameica.reminder.Reminder;
import de.willuhn.jameica.reminder.ReminderStorageProvider;
import de.willuhn.jameica.services.BeanService;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.util.DateUtil;
import de.willuhn.logging.Logger;

/**
Expand Down Expand Up @@ -170,58 +169,19 @@ protected boolean hasChanged()
*/
protected DBIterator getList(Object konto, Date from, Date to, String text) throws RemoteException
{
int filterCount = 0;

HBCIDBService service = (HBCIDBService) Settings.getDBService();

DBIterator list = service.createList(getObjectType());
if (from != null)
{
list.addFilter("termin >= ?", new java.sql.Date(DateUtil.startOfDay(from).getTime()));
filterCount++;
}
if (to != null)
{
list.addFilter("termin <= ?", new java.sql.Date(DateUtil.endOfDay(to).getTime()));
filterCount++;
}

if (text != null && text.length() > 0)
{
list.addFilter("LOWER(bezeichnung) like ?", "%" + text.toLowerCase() + "%");
filterCount++;
}

if (konto != null)
{
if (konto instanceof Konto)
list.addFilter("konto_id = " + ((Konto) konto).getID());
else if (konto instanceof String)
list.addFilter("konto_id in (select id from konto where kategorie = ?)", (String) konto);

filterCount++;
}

boolean pending = ((Boolean) this.getPending().getValue()).booleanValue();
if (pending)
{
list.addFilter("ausgefuehrt = 0");
filterCount++;
}

list.setOrder("ORDER BY " + service.getSQLTimestamp("termin") + " DESC, id DESC");

if (filterCount > 0)
{
final int all = service.createList(getObjectType()).size();
final int size = list.size();
if (all != size)
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0} - Anzeige: {1} von {2} Auftr�gen",Integer.toString(filterCount), Integer.toString(size), Integer.toString(all)),StatusBarMessage.TYPE_INFO));
else
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0}",Integer.toString(filterCount)),StatusBarMessage.TYPE_INFO));
}

return list;
TransferQueryBuilder builder = new TransferQueryBuilderWithStatusbarMessage(
new TransferQueryBuilderWithDBService(Settings.getDBService(), getObjectType()),
i18n
);
//@formatter:off
return builder.withStartDate(from)
.withEndDate(to)
.withTextLike(text)
.withAccount(konto)
.withOnlyPendingTransactions((Boolean) this.getPending().getValue())
.orderedByDateDesc()
.build();
//@formatter:on
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import java.util.Date;
import java.util.List;

import de.willuhn.jameica.hbci.rmi.TransferQueryBuilder;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithDBService;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithStatusbarMessage;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -45,19 +48,15 @@
import de.willuhn.jameica.hbci.messaging.ObjectChangedMessage;
import de.willuhn.jameica.hbci.messaging.ObjectMessage;
import de.willuhn.jameica.hbci.reminder.ReminderStorageProviderHibiscus;
import de.willuhn.jameica.hbci.rmi.HBCIDBService;
import de.willuhn.jameica.hbci.rmi.HibiscusDBObject;
import de.willuhn.jameica.hbci.rmi.Konto;
import de.willuhn.jameica.hbci.rmi.SepaSammelTransfer;
import de.willuhn.jameica.hbci.rmi.SepaSammelTransferBuchung;
import de.willuhn.jameica.messaging.Message;
import de.willuhn.jameica.messaging.MessageConsumer;
import de.willuhn.jameica.messaging.StatusBarMessage;
import de.willuhn.jameica.reminder.Reminder;
import de.willuhn.jameica.reminder.ReminderStorageProvider;
import de.willuhn.jameica.services.BeanService;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.util.DateUtil;
import de.willuhn.logging.Logger;

/**
Expand Down Expand Up @@ -210,58 +209,19 @@ protected boolean hasChanged()
*/
protected DBIterator getList(Object konto, Date from, Date to, String text) throws RemoteException
{
int filterCount = 0;

HBCIDBService service = (HBCIDBService) Settings.getDBService();

DBIterator list = service.createList(getObjectType());
if (from != null)
{
list.addFilter("termin >= ?", new java.sql.Date(DateUtil.startOfDay(from).getTime()));
filterCount++;
}
if (to != null)
{
list.addFilter("termin <= ?", new java.sql.Date(DateUtil.endOfDay(to).getTime()));
filterCount++;
}

if (text != null && text.length() > 0)
{
list.addFilter("LOWER(bezeichnung) like ?", "%" + text.toLowerCase() + "%");
filterCount++;
}

if (konto != null)
{
if (konto instanceof Konto)
list.addFilter("konto_id = " + ((Konto) konto).getID());
else if (konto instanceof String)
list.addFilter("konto_id in (select id from konto where kategorie = ?)", (String) konto);

filterCount++;
}

boolean pending = ((Boolean) this.getPending().getValue()).booleanValue();
if (pending)
{
list.addFilter("ausgefuehrt = 0");
filterCount++;
}

list.setOrder("ORDER BY " + service.getSQLTimestamp("termin") + " DESC, id DESC");

if (filterCount > 0)
{
final int all = service.createList(getObjectType()).size();
final int size = list.size();
if (all != size)
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0} - Anzeige: {1} von {2} Auftr�gen",Integer.toString(filterCount), Integer.toString(size), Integer.toString(all)),StatusBarMessage.TYPE_INFO));
else
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0}",Integer.toString(filterCount)),StatusBarMessage.TYPE_INFO));
}

return list;
TransferQueryBuilder builder = new TransferQueryBuilderWithStatusbarMessage(
new TransferQueryBuilderWithDBService(Settings.getDBService(), getObjectType()),
i18n
);
//@formatter:off
return builder.withStartDate(from)
.withEndDate(to)
.withTextLike(text)
.withAccount(konto)
.withOnlyPendingTransactions((Boolean) this.getPending().getValue())
.orderedByDateDesc()
.build();
//@formatter:on
}

/**
Expand Down
65 changes: 15 additions & 50 deletions src/de/willuhn/jameica/hbci/gui/parts/AbstractTransferList.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.rmi.RemoteException;
import java.util.Date;

import de.willuhn.jameica.hbci.rmi.TransferQueryBuilder;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithDBService;
import de.willuhn.jameica.hbci.rmi.TransferQueryBuilderWithStatusbarMessage;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -45,18 +48,14 @@
import de.willuhn.jameica.hbci.messaging.ObjectChangedMessage;
import de.willuhn.jameica.hbci.messaging.ObjectMessage;
import de.willuhn.jameica.hbci.reminder.ReminderStorageProviderHibiscus;
import de.willuhn.jameica.hbci.rmi.HBCIDBService;
import de.willuhn.jameica.hbci.rmi.HibiscusDBObject;
import de.willuhn.jameica.hbci.rmi.Konto;
import de.willuhn.jameica.hbci.rmi.Terminable;
import de.willuhn.jameica.messaging.Message;
import de.willuhn.jameica.messaging.MessageConsumer;
import de.willuhn.jameica.messaging.StatusBarMessage;
import de.willuhn.jameica.reminder.Reminder;
import de.willuhn.jameica.reminder.ReminderStorageProvider;
import de.willuhn.jameica.services.BeanService;
import de.willuhn.jameica.system.Application;
import de.willuhn.jameica.util.DateUtil;
import de.willuhn.logging.Logger;

/**
Expand Down Expand Up @@ -205,52 +204,18 @@ public void widgetDisposed(DisposeEvent e)
*/
protected DBIterator getList(Object konto, Date from, Date to, String text) throws RemoteException
{
int filterCount = 0;

HBCIDBService service = (HBCIDBService) Settings.getDBService();

DBIterator list = service.createList(getObjectType());
if (from != null)
{
list.addFilter("termin >= ?", new java.sql.Date(DateUtil.startOfDay(from).getTime()));
filterCount++;
}
if (to != null)
{
list.addFilter("termin <= ?", new java.sql.Date(DateUtil.endOfDay(to).getTime()));
filterCount++;
}

if (konto != null)
{
if (konto instanceof Konto)
list.addFilter("konto_id = " + ((Konto) konto).getID());
else if (konto instanceof String)
list.addFilter("konto_id in (select id from konto where kategorie = ?)", (String) konto);

filterCount++;
}

boolean pending = ((Boolean) this.getPending().getValue()).booleanValue();
if (pending)
{
list.addFilter("ausgefuehrt = 0");
filterCount++;
}

list.setOrder("ORDER BY " + service.getSQLTimestamp("termin") + " DESC, id DESC");

if (filterCount > 0)
{
final int all = service.createList(getObjectType()).size();
final int size = list.size();
if (all != size)
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0} - Anzeige: {1} von {2} Auftr�gen",Integer.toString(filterCount), Integer.toString(size), Integer.toString(all)),StatusBarMessage.TYPE_INFO));
else
Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Suchkriterien: {0}",Integer.toString(filterCount)),StatusBarMessage.TYPE_INFO));
}

return list;
TransferQueryBuilder builder = new TransferQueryBuilderWithStatusbarMessage(
new TransferQueryBuilderWithDBService(Settings.getDBService(), getObjectType()),
i18n
);
//@formatter:off
return builder.withStartDate(from)
.withEndDate(to)
.withAccount(konto)
.withOnlyPendingTransactions((Boolean) this.getPending().getValue())
.orderedByDateDesc()
.build();
//@formatter:on
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/de/willuhn/jameica/hbci/rmi/TransferQueryBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.willuhn.jameica.hbci.rmi;

import java.rmi.RemoteException;
import java.util.Date;

import de.willuhn.datasource.rmi.DBIterator;

public interface TransferQueryBuilder
{
DBIterator build() throws RemoteException;

int getElementCount() throws RemoteException;
int getElementCountWithoutFilter() throws RemoteException;

TransferQueryBuilder orderedByDateDesc();
TransferQueryBuilder withAccount(Object konto);
TransferQueryBuilder withEndDate(Date to);
TransferQueryBuilder withOnlyPendingTransactions(boolean yes);
TransferQueryBuilder withStartDate(Date from);
TransferQueryBuilder withTextLike(String text);
}
Loading