Package de.willuhn.util

Examples of de.willuhn.util.ApplicationException


   */
  public void doExport(Object[] objects, IOFormat format, OutputStream os, ProgressMonitor monitor) throws RemoteException, ApplicationException
  {
   
    if (objects == null || objects.length == 0)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie die zu exportierenden Ums�tze aus"));

    Umsatz u = (Umsatz) objects[0];

    Date startDate     = u.getDatum();
    Date endDate       = u.getDatum();
    Hashtable umsaetze = new Hashtable();
   
    if (monitor != null)
    {
      monitor.setStatusText(i18n.tr("Ermittle zu exportierende Ums�tze und Konten"));
      monitor.addPercentComplete(1);
    }

    for (int i=0;i<objects.length;++i)
    {
      u = (Umsatz) objects[i];
      Konto k  = u.getKonto();

      // Wir ermitteln bei der Gelegenheit das Maximal- und Minimal-Datum
      Date date = u.getDatum();
      if (date != null)
      {
        if (endDate != null && date.after(endDate))    endDate = date;
        if (startDate != null && date.before(startDate)) startDate = date;
      }

      // Wir gruppieren die Umsaetze nach Konto.
      ArrayList list = (ArrayList) umsaetze.get(k.getID());
      if (list == null)
      {
        list = new ArrayList();
        umsaetze.put(k.getID(),list);
      }
      list.add(u);
    }

    // Falls wir die Datumsfelder als optionale Parameter erhalten haben,
    // nehmen wir die.
    Date d = (Date) Exporter.SESSION.get("pdf.start");
    if (d != null) startDate = d;
    d = (Date) Exporter.SESSION.get("pdf.end");
    if (d != null) endDate = d;
    Boolean filter    = (Boolean) Exporter.SESSION.get("filtered");
    Boolean b         = (Boolean) Exporter.SESSION.get(ExportSaldoExtension.KEY_SALDO_HIDE);
    boolean showSaldo = (b == null || !b.booleanValue());
   
    Reporter reporter = null;
   
    try
    {
      // Der Export
      String subTitle = i18n.tr("{0} - {1}", new String[]{startDate == null ? "" : HBCI.DATEFORMAT.format(startDate),endDate == null ? "" : HBCI.DATEFORMAT.format(endDate)});
      reporter = new Reporter(os,monitor,i18n.tr("Ums�tze") + (filter != null && filter.booleanValue() ? (" (" + i18n.tr("gefiltert") + ")") : ""), subTitle, objects.length  );

      reporter.addHeaderColumn(i18n.tr("Valuta / Buchungsdatum"), Element.ALIGN_CENTER, 30, BaseColor.LIGHT_GRAY);
      reporter.addHeaderColumn(i18n.tr("Empf�nger/Einzahler"),    Element.ALIGN_CENTER,100, BaseColor.LIGHT_GRAY);
      reporter.addHeaderColumn(i18n.tr("Zahlungsgrund"),          Element.ALIGN_CENTER,120, BaseColor.LIGHT_GRAY);
      reporter.addHeaderColumn(i18n.tr("Betrag"),                 Element.ALIGN_CENTER, 30, BaseColor.LIGHT_GRAY);
      if (showSaldo)
        reporter.addHeaderColumn(i18n.tr("Saldo"),                  Element.ALIGN_CENTER, 30, BaseColor.LIGHT_GRAY);
      reporter.createHeader();

     
      // Iteration ueber Umsaetze
      Enumeration konten = umsaetze.keys();
      while (konten.hasMoreElements())
      {
        String id = (String) konten.nextElement();
        Konto konto = (Konto) Settings.getDBService().createObject(Konto.class,id);
       
        PdfPCell cell = reporter.getDetailCell(konto.getLongName(), Element.ALIGN_CENTER,BaseColor.LIGHT_GRAY);
        cell.setColspan(showSaldo ? 5 : 4);
        reporter.addColumn(cell);

        ArrayList list = (ArrayList) umsaetze.get(id);

        if (list.size() == 0)
        {
          PdfPCell empty = reporter.getDetailCell(i18n.tr("Keine Ums�tze"), Element.ALIGN_CENTER,BaseColor.LIGHT_GRAY);
          empty.setColspan(5);
          reporter.addColumn(empty);
          continue;
        }
       
        for (int i=0;i<list.size();++i)
        {

          u = (Umsatz)list.get(i);
          String valuta = (u.getValuta() != null ? HBCI.DATEFORMAT.format(u.getValuta()) : "" );
          String datum  = (u.getDatum() != null ? HBCI.DATEFORMAT.format(u.getDatum()) : "");
         
          BaseColor color = null;
          int style = Font.NORMAL;
          if (u.hasFlag(Umsatz.FLAG_NOTBOOKED))
          {
            color = BaseColor.GRAY;
            style = Font.ITALIC;
          }
         
          reporter.addColumn(reporter.getDetailCell(valuta + "\n" + datum, Element.ALIGN_LEFT,null,color,style));
          reporter.addColumn(reporter.getDetailCell(reporter.notNull(u.getGegenkontoName()) + "\n" + reporter.notNull(u.getArt()), Element.ALIGN_LEFT,null,color,style));
          reporter.addColumn(reporter.getDetailCell(VerwendungszweckUtil.toString(u,"\n"), Element.ALIGN_LEFT,null,color,style));
          reporter.addColumn(reporter.getDetailCell(u.getBetrag()));
          if (showSaldo)
            reporter.addColumn(reporter.getDetailCell(u.getSaldo()));
          reporter.setNextRecord();
        }
      }
      if (monitor != null) monitor.setStatus(ProgressMonitor.STATUS_DONE);
    }
    catch (Exception e)
    {
      if (monitor != null) monitor.setStatus(ProgressMonitor.STATUS_ERROR);
      Logger.error("error while creating report",e);
      throw new ApplicationException(i18n.tr("Fehler beim Erzeugen der Auswertung"),e);
    }
    finally
    {
      if (reporter != null)
      {
View Full Code Here


  Print printContent() throws ApplicationException
  {
    Object data = this.ctx;
   
    if (data == null)
        throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen Auftrag aus"));
   
    if (data instanceof TablePart)
      data = ((TablePart)data).getSelection();
   
    if (!(data instanceof Dauerauftrag))
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen Auftrag aus"));
   
    try
    {
      Dauerauftrag a = (Dauerauftrag) data;
      Konto k        = a.getKonto();
     
      // Die eigentlich Tabelle mit den Werten
      DefaultGridLook look = new DefaultGridLook(5,5);
      GridPrint table = new GridPrint("l:p:n, l:d:g",look);

      // Konto
      table.add(new TextPrint(i18n.tr("Konto"),fontNormal));
      table.add(new TextPrint(notNull(k != null ? k.getLongName() : null),fontNormal));
     
      // Leerzeile
      table.add(new LineBreakPrint(fontNormal));
      table.add(new LineBreakPrint(fontNormal));
     
      // Empfaenger
      {
        String blz = a.getGegenkontoBLZ();
       
        table.add(new TextPrint(i18n.tr("Gegenkonto"),fontNormal));
        table.add(new TextPrint(notNull(a.getGegenkontoName()),fontBold));
        table.add(new EmptyPrint());
        if (blz != null && blz.length() > 0)
          table.add(new TextPrint(i18n.tr("{0} [BLZ: {1}]\nKonto: {2}",notNull(HBCIProperties.getNameForBank(blz)),blz,notNull(a.getGegenkontoNummer())),fontNormal));
        else
          table.add(new EmptyPrint());
      }

      // Leerzeile
      table.add(new LineBreakPrint(fontNormal));
      table.add(new LineBreakPrint(fontNormal));
     
      // Verwendungszweck
      {
        String usage = VerwendungszweckUtil.toString(a,"\n");
        table.add(new TextPrint(i18n.tr("Verwendungszweck"),fontNormal));
        table.add(new TextPrint(notNull(usage),fontNormal));
      }

      // Leerzeile
      table.add(new LineBreakPrint(fontNormal));
      table.add(new LineBreakPrint(fontNormal));
     
      // Betrag
      {
        double betrag = a.getBetrag();
        String curr = k != null ? k.getWaehrung() : HBCIProperties.CURRENCY_DEFAULT_DE;
       
        table.add(new TextPrint(i18n.tr("Betrag"),fontNormal));
        table.add(new TextPrint(betrag == 0.0d || Double.isNaN(betrag) ? "-" : (HBCI.DECIMALFORMAT.format(betrag) + " " + curr),fontBold));
      }

      // Leerzeile
      table.add(new LineBreakPrint(fontNormal));
      table.add(new LineBreakPrint(fontNormal));
     
      // Der Rest
      {
        table.add(new TextPrint(i18n.tr("Textschl�ssel"),fontNormal));
        table.add(new TextPrint(notNull(TextSchluessel.get(a.getTextSchluessel())),fontNormal));
       
        Date first = a.getErsteZahlung();
        table.add(new TextPrint(i18n.tr("Erste Zahlung"),fontNormal));
        table.add(new TextPrint(first == null ? "-" : HBCI.DATEFORMAT.format(first),fontNormal));

        Date last = a.getLetzteZahlung();
        table.add(new TextPrint(i18n.tr("Letzte Zahlung"),fontNormal));
        table.add(new TextPrint(last == null ? "-" : HBCI.DATEFORMAT.format(last),fontNormal));

        Date next = a.getNaechsteZahlung();
        table.add(new TextPrint(i18n.tr("N�chste Zahlung"),fontNormal));
        table.add(new TextPrint(next == null ? "-" : HBCI.DATEFORMAT.format(next),fontNormal));

        Turnus turnus = a.getTurnus();
        table.add(new TextPrint(i18n.tr("Turnus"),fontNormal));
        table.add(new TextPrint(turnus == null ? "-" : turnus.getBezeichnung(),fontBold));

        // Leerzeile
        table.add(new LineBreakPrint(fontNormal));
        table.add(new LineBreakPrint(fontNormal));

        table.add(new TextPrint(i18n.tr("Aktiv"),fontNormal));
        table.add(new TextPrint(a.isActive() ? "Ja" : "Nein",fontBold));
      }
     
      return table;
    }
    catch (RemoteException re)
    {
      Logger.error("unable to print data",re);
      throw new ApplicationException(i18n.tr("Druck fehlgeschlagen: {0}",re.getMessage()));
    }
  }
View Full Code Here

  public void handleAction(Object context) throws ApplicationException
  {
    final I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

    if (context == null || !(context instanceof SammelTransfer))
      throw new ApplicationException(i18n.tr("Kein Sammel-Auftrag angegeben"));

    try
    {
      final SammelTransfer u = (SammelTransfer) context;
     
      if (u.ausgefuehrt())
        throw new ApplicationException(i18n.tr("Sammel-Auftrag wurde bereits ausgef�hrt"));

      if (u.getBuchungen().size() == 0)
        throw new ApplicationException(i18n.tr("Sammel-Auftrag enth�lt keine Buchungen"));
      if (u.isNewObject())
        u.store(); // wir speichern bei Bedarf selbst.

      SammelTransferDialog d = new SammelTransferDialog(u,SammelTransferDialog.POSITION_CENTER);
      try
View Full Code Here

   */
  public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
  {

    if (is == null)
      throw new ApplicationException(i18n.tr("Keine zu importierende Datei ausgew�hlt"));
   
    if (format == null)
      throw new ApplicationException(i18n.tr("Kein Datei-Format ausgew�hlt"));
   
    try
    {
     
      de.willuhn.jameica.hbci.rmi.Konto konto = null;
     
      if (context != null && context instanceof de.willuhn.jameica.hbci.rmi.Konto)
        konto = (de.willuhn.jameica.hbci.rmi.Konto) context;
     
      if (konto == null)
      {
        KontoAuswahlDialog d = new KontoAuswahlDialog(KontoAuswahlDialog.POSITION_CENTER);
        d.setText(i18n.tr("Bitte w�hlen Sie das zu verwendende Konto aus."));
        konto = (de.willuhn.jameica.hbci.rmi.Konto) d.open();
      }
      // Wir erzeugen das HBCI4Java-Umsatz-Objekt selbst. Dann muessen wir
      // an der eigentlichen Parser-Routine nichts mehr aendern.
      GVRKUms umsaetze = new MyGVRKUms();

      if (monitor != null)
        monitor.setStatusText(i18n.tr("Lese Datei ein"));

      InputStreamReader encodedIs = new InputStreamReader(is,MT940UmsatzExporter.CHARSET);
      StringBuffer sb = new StringBuffer();
      int read = 0;
      char[] buf = new char[8192];

      while ((read = encodedIs.read(buf)) != -1)
      {
        if (read > 0)
          sb.append(buf,0,read);
      }
      umsaetze.appendMT940Data(Swift.decodeUmlauts(sb.toString()));

      if (monitor != null)
        monitor.setStatusText(i18n.tr("Speichere Ums�tze"));
     
      List lines = umsaetze.getFlatData();
     
      if (lines.size() == 0)
      {
        konto.addToProtokoll(i18n.tr("Keine Ums�tze importiert"),Protokoll.TYP_ERROR);
        return;
      }
     
      double factor = 100d / (double) lines.size();

      int created = 0;
      int error   = 0;

      for (int i=0;i<lines.size();++i)
      {
        if (monitor != null)
        {
          monitor.log(i18n.tr("Umsatz {0}", "" + (i+1)));
          // Mit diesem Factor sollte sich der Fortschrittsbalken
          // bis zum Ende der Swift-MT940-Datei genau auf 100% bewegen
          monitor.setPercentComplete((int)((i+1) * factor));
        }

        try
        {
          final Umsatz umsatz = Converter.HBCIUmsatz2HibiscusUmsatz((GVRKUms.UmsLine)lines.get(i));
          umsatz.setKonto(konto); // muessen wir noch machen, weil der Converter das Konto nicht kennt
          umsatz.store();
          created++;
          try
          {
            Application.getMessagingFactory().sendMessage(new ImportMessage(umsatz));
          }
          catch (Exception ex)
          {
            Logger.error("error while sending import message",ex);
          }
        }
        catch (ApplicationException ae)
        {
          monitor.log("  " + ae.getMessage());
          error++;
        }
        catch (Exception e)
        {
          Logger.error("unable to import line",e);
          monitor.log("  " + i18n.tr("Fehler beim Import des Datensatzes: {0}",e.getMessage()));
          error++;
        }
      }
      monitor.setStatusText(i18n.tr("{0} Ums�tze erfolgreich importiert, {1} fehlerhafte �bersprungen", new String[]{""+created,""+error}));
      monitor.addPercentComplete(1);
    }
    catch (OperationCanceledException oce)
    {
      Logger.warn("operation cancelled");
      throw new ApplicationException(i18n.tr("Import abgebrochen"));
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (Exception e)
    {
      Logger.error("error while reading file",e);
      throw new ApplicationException(i18n.tr("Fehler beim Import der Datei"));
    }
    finally
    {
      IOUtil.close(is);
    }
View Full Code Here

      return;
    }
    catch (Exception e)
    {
      Logger.error("error while opening about dialog",e);
      throw new ApplicationException(i18n.tr("Fehler beim Anzeigen des About-Dialogs"),e);
    }
  }
View Full Code Here

      exp = (Exp) getExporterList().getValue();
    }
    catch (Exception e)
    {
      Logger.error("error while saving export file",e);
      throw new ApplicationException(i18n.tr("Fehler beim Starten des Exports"),e);
    }

    if (exp == null || exp.exporter == null)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie ein Export-Format aus"));

    SETTINGS.setAttribute("lastformat",exp.format.getName());

    FileDialog fd = new FileDialog(GUI.getShell(),SWT.SAVE);
    fd.setText(i18n.tr("Bitte geben Sie eine Datei ein, in die die Daten exportiert werden sollen."));
    fd.setOverwrite(true);
    String[] se = exp.format.getFileExtensions();
    String ext = se == null ? "" : se[0];
    ext = ext.replaceAll("\\*.",""); // "*." entfernen
    fd.setFileName(i18n.tr("hibiscus-export-{0}." + ext,DATEFORMAT.format(new Date())));

    String path = SETTINGS.getString("lastdir",System.getProperty("user.home"));
    if (path != null && path.length() > 0)
      fd.setFilterPath(path);

    final String s = fd.open();
   
    if (s == null || s.length() == 0)
    {
      close();
      return;
    }

    final File file = new File(s);
   
    // Wir merken uns noch das Verzeichnis vom letzten mal
    SETTINGS.setAttribute("lastdir",file.getParent());

    // Dialog schliessen
    final boolean open = ((Boolean)getOpenFile().getValue()).booleanValue();
    SETTINGS.setAttribute("open",open);
    close();

    final Exporter exporter = exp.exporter;
    final IOFormat format = exp.format;

    BackgroundTask t = new BackgroundTask() {
      public void run(ProgressMonitor monitor) throws ApplicationException
      {
        try
        {
          // Der Exporter schliesst den OutputStream selbst
          OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
          exporter.doExport(objects,format,os,monitor);
          monitor.setPercentComplete(100);
          monitor.setStatus(ProgressMonitor.STATUS_DONE);
          GUI.getStatusBar().setSuccessText(i18n.tr("Daten exportiert nach {0}",s));
          monitor.setStatusText(i18n.tr("Daten exportiert nach {0}",s));
         
          if (open)
          {
            GUI.getDisplay().asyncExec(new Runnable() {
              public void run()
              {
                try
                {
                  new Program().handleAction(file);
                }
                catch (ApplicationException ae)
                {
                  Application.getMessagingFactory().sendMessage(new StatusBarMessage(ae.getLocalizedMessage(),StatusBarMessage.TYPE_ERROR));
                }
              }
            });
          }
        }
        catch (ApplicationException ae)
        {
          monitor.setStatus(ProgressMonitor.STATUS_ERROR);
          monitor.setStatusText(ae.getMessage());
          GUI.getStatusBar().setErrorText(ae.getMessage());
          throw ae;
        }
        catch (OperationCanceledException oce)
        {
          Logger.info("operation cancelled: " + oce.getMessage());
          monitor.setStatus(ProgressMonitor.STATUS_CANCEL);
          monitor.setStatusText(i18n.tr("Export abgebrochen"));
        }
        catch (Exception e)
        {
          monitor.setStatus(ProgressMonitor.STATUS_ERROR);
          Logger.error("error while writing objects to " + s,e);
          ApplicationException ae = new ApplicationException(i18n.tr("Fehler beim Exportieren der Daten in {0}",s),e);
          monitor.setStatusText(ae.getMessage());
          GUI.getStatusBar().setErrorText(ae.getMessage());
          throw ae;
        }
      }

      public void interrupt() {}
View Full Code Here

  {
    if (this.passport != null)
      return this.passport;
    RDHKey key = getKey();
    if (key == null)
      throw new ApplicationException(i18n.tr("Kein Schl�ssel ausgew�hlt"));
    this.passport = key.load();
    return this.passport;
  }
View Full Code Here

      QueryMessage msg = new QueryMessage(passport);
      Application.getMessagingFactory().getMessagingQueue("hibiscus.passport.rdh.hbciversion").sendSyncMessage(msg);
      Object data = msg.getData();
      if (data == null || !(data instanceof String))
        throw new ApplicationException(i18n.tr("HBCI-Version nicht ermittelbar"));
     
      String version = (String)msg.getData();
      Logger.info("using hbci version: " + version);
     
      handler = new HBCIHandler(version,passport);
View Full Code Here

  public void doImport(Object context, IOFormat format, InputStream is, ProgressMonitor monitor) throws RemoteException, ApplicationException
  {
    try
    {
      if (is == null)
        throw new ApplicationException(i18n.tr("Keine zu importierende Datei ausgew�hlt"));
     
      if (format == null)
        throw new ApplicationException(i18n.tr("Kein Datei-Format ausgew�hlt"));

      if (!(format instanceof MyIOFormat))
        throw new ApplicationException(i18n.tr("Das Datei-Format ist unbekannt"));
     
      Format f = ((MyIOFormat)format).format;


      monitor.setStatusText(i18n.tr("�ffne Datei"));
      monitor.addPercentComplete(1);
     
     
      // Wir lesen die Datei einmal komplett in einen Buffer.
      // Grund: Sie soll als Preview im Spalten-Zuordnungsdialog
      // angezeigt werden. Falls der User das Encoding der
      // Datei im Dialog aendert, muss sie anschliessend neu
      // mit dem geaenderten Encoding gelesen werden koennen.
      byte[] data = copy(is);
      if (data == null || data.length == 0)
        throw new ApplicationException(i18n.tr("CSV-Datei enth�lt keine Daten"));

      CSVImportDialog d = new CSVImportDialog(data,f,CSVImportDialog.POSITION_CENTER);
      Profile p = (Profile) d.open();

      CsvPreference prefs = CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE;
      String sep = p.getSeparatorChar();
      String quo = p.getQuotingChar();
      if (sep != null && sep.length() == 1) prefs.setDelimiterChar(sep.charAt(0));
      if (quo != null && quo.length() == 1) prefs.setQuoteChar(quo.charAt(0));
      ICsvListReader csv = new CsvListReader(new InputStreamReader(new ByteArrayInputStream(data),p.getFileEncoding()),prefs);

      List<String> line = csv.read();
     
      // Ggf. erste Zeilen ueberspringen
      for (int i=0;i<p.getSkipLines();++i)
      {
        line = csv.read();
      }

      // Nochmal checken, ob wir nach dem Ueberspringen ueberhaupt noch Zeilen uebrig haben
      if (line == null || line.size() == 0)
        throw new ApplicationException(i18n.tr("CSV-Datei enth�lt keine weiteren Daten"));

      int created       = 0;
      int error         = 0;
      int skipped       = 0;
      DBObject object   = null;
      String value      = null;
      List<Column> cols = p.getColumns();
      ImportListener l  = f.getImportListener();

      DBService service = (DBService) Application.getServiceFactory().lookup(HBCI.class,"database");
      do
      {
        monitor.log(i18n.tr("Importiere Zeile {0}",Integer.toString(csv.getLineNumber())));
        monitor.addPercentComplete(1);

        try
        {
          object = service.createObject(f.getType(),null);
         
          // Spalten zuordnen
          Map<String, Object> values = new HashMap<String,Object>();
          for (int i=0;i<line.size();++i)
          {
            Column column = null;
            for (Column c:cols)
            {
              if (c.getColumn() == i)
              {
                column = c;
                break;
              }
            }
           
            if (column == null)
              continue; // Spalte nicht zugeordnet
           
            // Checken, ob in der Spalte was steht
            value = line.get(i);
            if (value == null)
              continue;
            value = value.trim();
            if (value.length() == 0)
              continue;
           
            try
            {
              // Werte zwischenspeichern
              Object prev = values.get(column.getProperty());
              values.put(column.getProperty(),column.getSerializer().unserialize(prev,value));
            }
            catch (Exception e)
            {
              Logger.error("unable to unserialize " + column.getProperty() + " for line " + csv.getLineNumber() + ", value: " + value,e);
              monitor.log("  " + i18n.tr("Ung�ltiger Wert \"{0}\" in Spalte \"{1}\": {2}",value,column.getName(),e.getMessage()));
            }
          }
         
          // beforeSet-Listener ausloesen
          if (l != null)
          {
            ImportEvent e = new ImportEvent();
            e.context = context;
            e.data = values;
            try
            {
              l.beforeSet(e);
            }
            catch (OperationCanceledException oce)
            {
              skipped++;
              String msg = oce.getMessage();
              if (msg != null && msg.length() > 0)
                monitor.log("  " + msg);
              continue;
            }
          }
         

          // Werte in die Bean uebernehmen
          Iterator<String> it = values.keySet().iterator();
          while (it.hasNext())
          {
            String name = it.next();
            Object o = values.get(name);
            try
            {
              BeanUtil.set(object,name,o);
            }
            catch (Exception e)
            {
              Logger.error("unable to apply property " + name + " for line " + csv.getLineNumber() + ", value: " + o,e);
              String[] s = new String[]{value,
                                        name,
                                        e.getMessage()};
              monitor.log("  " + i18n.tr("Ung�ltiger Wert \"{0}\" in Spalte \"{1}\": {2}",s));
            }
          }
         
         
         
         
          if (l != null)
          {
            ImportEvent e = new ImportEvent();
            e.context = context;
            e.data = object;
            try
            {
              l.beforeStore(e);
            }
            catch (OperationCanceledException oce)
            {
              skipped++;
              String msg = oce.getMessage();
              if (msg != null && msg.length() > 0)
                monitor.log("  " + msg);
              continue;
            }
          }
         
          object.store();
          Application.getMessagingFactory().sendMessage(new ImportMessage(object));
          created++;
        }
        catch (Exception e)
        {
          if (!(e instanceof ApplicationException))
            Logger.error("unable to import line",e);

          monitor.log("  " + i18n.tr("Fehler in Zeile {0}: {1}",new String[]{Integer.toString(csv.getLineNumber()),e.getMessage()}));
          error++;
        }
      }
      while ((line = csv.read()) != null);

      // Fertig.
      monitor.setStatusText(i18n.tr("{0} importiert, {1} fehlerhaft, {2} �bersprungen", new String[]{Integer.toString(created),Integer.toString(error),Integer.toString(skipped)}));
    }
    catch (OperationCanceledException oce)
    {
      Logger.info("operation cancelled");
      monitor.setStatus(ProgressMonitor.STATUS_CANCEL);
      monitor.setStatusText(i18n.tr("Import abgebrochen"));
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (Exception e)
    {
      // Ich bin mir nicht sicher, ob das hier ueberhaupt noch noetig ist
      if (e instanceof SWTException)
      {
        if (e.getCause() instanceof OperationCanceledException)
        {
          Logger.info("operation cancelled");
          monitor.setStatus(ProgressMonitor.STATUS_CANCEL);
          monitor.setStatusText(i18n.tr("Import abgebrochen"));
          return;
        }
      }
      Logger.error("error while reading file",e);
      throw new ApplicationException(i18n.tr("Fehler beim Lesen der CSV-Datei"));
    }
  }
View Full Code Here

        d = (SepaDauerauftrag) Settings.getDBService().createObject(SepaDauerauftrag.class,null);
        d.setGegenkonto(e);
      }
      catch (RemoteException e)
      {
        throw new ApplicationException(i18n.tr("Fehler beim Anlegen des Dauerauftrages"));
      }
    }

    GUI.startView(de.willuhn.jameica.hbci.gui.views.SepaDauerauftragNew.class,d);
  }
View Full Code Here

TOP

Related Classes of de.willuhn.util.ApplicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.