Skip to content

Commit

Permalink
SEPA: Verweigere Import mit falschem PAIN (default) aber lasse Nutzer…
Browse files Browse the repository at this point in the history
… dies überschreiben

Durch die neue Checkbox "Import erzwingen" kann die PAIN Typ Überprüfung deaktiviert werden.
  • Loading branch information
michael-dev committed Dec 17, 2015
1 parent 31e9017 commit 8ec6d0f
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 29 deletions.
15 changes: 13 additions & 2 deletions src/de/willuhn/jameica/hbci/gui/dialogs/ImportDialog.java
Expand Up @@ -32,6 +32,7 @@
import de.willuhn.jameica.gui.input.Input;
import de.willuhn.jameica.gui.input.LabelInput;
import de.willuhn.jameica.gui.input.SelectInput;
import de.willuhn.jameica.gui.input.CheckboxInput;
import de.willuhn.jameica.gui.parts.Button;
import de.willuhn.jameica.gui.parts.ButtonArea;
import de.willuhn.jameica.gui.util.Container;
Expand Down Expand Up @@ -59,6 +60,7 @@ public class ImportDialog extends AbstractDialog
private final static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

private Input importerListe = null;
private CheckboxInput forceBox = null;
private GenericObject context = null;
private Class type = null;

Expand Down Expand Up @@ -94,6 +96,13 @@ protected void paint(Composite parent) throws Exception
Input formats = getImporterList();
group.addLabelPair(i18n.tr("Verfügbare Formate:"),formats);

if (this.forceBox == null) {
String newName = i18n.tr("Import erzwingen");
this.forceBox = new CheckboxInput(false);
this.forceBox.setName(newName);
}
group.addInput(this.forceBox);

ButtonArea buttons = new ButtonArea();
Button button = new Button(i18n.tr("Import starten"),new Action()
{
Expand Down Expand Up @@ -138,6 +147,8 @@ private void doImport() throws ApplicationException

settings.setAttribute("lastformat",imp.format.getName());

final boolean useForce = ((Boolean)this.forceBox.getValue()).booleanValue();

FileDialog fd = new FileDialog(GUI.getShell(),SWT.OPEN);
fd.setText(i18n.tr("Bitte wählen Sie die Datei aus, welche für den Import verwendet werden soll."));
fd.setFilterNames(imp.format.getFileExtensions());
Expand Down Expand Up @@ -174,7 +185,7 @@ public void run(ProgressMonitor monitor) throws ApplicationException
try
{
InputStream is = new BufferedInputStream(new FileInputStream(file));
importer.doImport(context,format,is,monitor);
importer.doImport(context,format,is,monitor,useForce);
monitor.setPercentComplete(100);
monitor.setStatus(ProgressMonitor.STATUS_DONE);
GUI.getStatusBar().setSuccessText(i18n.tr("Daten importiert aus {0}",s));
Expand Down Expand Up @@ -404,4 +415,4 @@ public int compareTo(Object o)
* Revision 1.1 2006/01/18 00:51:01 willuhn
* @B bug 65
*
**********************************************************************/
**********************************************************************/
6 changes: 3 additions & 3 deletions src/de/willuhn/jameica/hbci/io/AbstractDTAUSImporter.java
Expand Up @@ -45,10 +45,10 @@ public abstract class AbstractDTAUSImporter extends AbstractDTAUSIO implements I
private Hashtable kontenCache = new Hashtable();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is,
ProgressMonitor monitor) throws RemoteException, ApplicationException
ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{
// Wir merken uns die Konten, die der User schonmal ausgewaehlt
// hat, um ihn nicht fuer jede Buchung mit immer wieder dem
Expand Down Expand Up @@ -350,4 +350,4 @@ abstract void create(DBObject skel, Object context, CSatz csatz, ASatz asatz)
* Revision 1.1 2006/06/08 17:40:59 willuhn
* @N Vorbereitungen fuer DTAUS-Import von Sammellastschriften und Umsaetzen
*
**********************************************************************/
**********************************************************************/
7 changes: 5 additions & 2 deletions src/de/willuhn/jameica/hbci/io/AbstractImporter.java
Expand Up @@ -28,13 +28,16 @@
public abstract class AbstractImporter implements Importer
{
final static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();
protected boolean useForce = false;

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
@Override
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{
this.useForce = force;

try
{
Object[] objects = this.setup(context,format,is,monitor);
Expand Down
16 changes: 11 additions & 5 deletions src/de/willuhn/jameica/hbci/io/AbstractSepaImporter.java
Expand Up @@ -27,6 +27,7 @@
import de.willuhn.jameica.hbci.rmi.Konto;
import de.willuhn.jameica.hbci.server.KontoUtil;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

Expand Down Expand Up @@ -68,9 +69,9 @@ Object[] setup(Object context, IOFormat format, InputStream is, ProgressMonitor
PainVersion version = PainVersion.autodetect(new ByteArrayInputStream(bos.toByteArray()));
if (version == null)
throw new ApplicationException(i18n.tr("SEPA-Version der XML-Datei nicht ermittelbar"));

monitor.log(i18n.tr("SEPA-Version: {0}",version.getURN()));

// Überprüfe PAIN Typ
PainVersion.Type[] types = this.getSupportedPainTypes();
PainVersion.Type type = version.getType();
Expand All @@ -80,9 +81,14 @@ Object[] setup(Object context, IOFormat format, InputStream is, ProgressMonitor
found = true;
}
}
if (!found)
throw new ApplicationException(i18n.tr("Unzulässige SEPA-Version in der XML-Datei - Überweisung und Lastschrift verwechselt?"));

if (!found) {
Logger.error("invalid file PAIN type");
monitor.log(i18n.tr("Ungültiger PAIN Typ: {0}",type.getName()));
if (!this.useForce) {
throw new ApplicationException(i18n.tr("Unzulässige SEPA-Version in der XML-Datei - Überweisung und Lastschrift verwechselt?"));
}
}

List<Properties> props = new ArrayList<Properties>();
ISEPAParser parser = SEPAParserFactory.get(version);
parser.parse(new ByteArrayInputStream(bos.toByteArray()),props);
Expand Down
5 changes: 3 additions & 2 deletions src/de/willuhn/jameica/hbci/io/Importer.java
Expand Up @@ -33,11 +33,12 @@ public interface Importer extends IO
* @param is der Stream, aus dem die Daten gelesen werden.
* @param monitor ein Monitor, an den der Importer Ausgaben ueber seinen
* Bearbeitungszustand ausgeben kann.
* @param force Ob nicht-fatale Fehler übersprungen werden.
* Der Importer muss den Import-Stream selbst schliessen!
* @throws RemoteException
* @throws ApplicationException
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException;
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException;

}

Expand Down Expand Up @@ -65,4 +66,4 @@ public interface Importer extends IO
* Revision 1.1 2005/06/08 16:48:54 web0
* @N new Import/Export-System
*
*********************************************************************/
*********************************************************************/
6 changes: 3 additions & 3 deletions src/de/willuhn/jameica/hbci/io/MT940UmsatzImporter.java
Expand Up @@ -48,9 +48,9 @@ public class MT940UmsatzImporter implements Importer
private final static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{

if (is == null)
Expand Down Expand Up @@ -346,4 +346,4 @@ public void changePassphrase(){}
* Revision 1.1 2006/01/17 00:22:36 willuhn
* @N erster Code fuer Swift MT940-Import
*
******************************************************************************/
******************************************************************************/
6 changes: 3 additions & 3 deletions src/de/willuhn/jameica/hbci/io/MoneyplexUmsatzImporter.java
Expand Up @@ -57,9 +57,9 @@ public class MoneyplexUmsatzImporter implements Importer
private Map<String,UmsatzTyp> cache = new HashMap<String,UmsatzTyp>();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{
cache.clear(); // Cache leeren

Expand Down Expand Up @@ -443,4 +443,4 @@ public String[] getFileExtensions()
* Revision 1.1 2010/06/02 17:33:33 willuhn
* @N TICKET #61 - Moneyplex-Import
*
******************************************************************************/
******************************************************************************/
4 changes: 2 additions & 2 deletions src/de/willuhn/jameica/hbci/io/XMLImporter.java
Expand Up @@ -42,9 +42,9 @@ public class XMLImporter implements Importer
protected final static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{

if (is == null)
Expand Down
Expand Up @@ -38,7 +38,7 @@
public class XMLSepaSammelTransferImporter extends XMLImporter
{
/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
{
Expand Down
2 changes: 1 addition & 1 deletion src/de/willuhn/jameica/hbci/io/XMLUmsatzImporter.java
Expand Up @@ -37,7 +37,7 @@
public class XMLUmsatzImporter extends XMLImporter
{
/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
{
Expand Down
4 changes: 2 additions & 2 deletions src/de/willuhn/jameica/hbci/io/XMLUmsatzTypImporter.java
Expand Up @@ -39,9 +39,9 @@ public class XMLUmsatzTypImporter implements Importer
protected final static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{

if (is == null)
Expand Down
6 changes: 3 additions & 3 deletions src/de/willuhn/jameica/hbci/io/csv/CsvImporter.java
Expand Up @@ -54,9 +54,9 @@ public class CsvImporter implements Importer
private static I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

/**
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor)
* @see de.willuhn.jameica.hbci.io.Importer#doImport(java.lang.Object, de.willuhn.jameica.hbci.io.IOFormat, java.io.InputStream, de.willuhn.util.ProgressMonitor, boolean)
*/
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor, boolean force) throws RemoteException, ApplicationException
{
try
{
Expand Down Expand Up @@ -416,4 +416,4 @@ public String[] getFileExtensions()
* - Import-Preset wird nun im XML-Format nach ~/.jameica/hibiscus/csv serialisiert. Damit wird es kuenftig moeglich sein,
* CSV-Import-Profile vorzukonfigurieren und anschliessend zu exportieren, um sie mit anderen Usern teilen zu koennen
*
**********************************************************************/
**********************************************************************/

0 comments on commit 8ec6d0f

Please sign in to comment.