Skip to content

Commit

Permalink
Import und Export von Formularen (#555)
Browse files Browse the repository at this point in the history
* Import und Export von Formularen

* Dokulink

* Import von Menue zu Button verschoben. Vereinsdaten in Allgemeine Map
  • Loading branch information
lenilsas authored Jan 8, 2025
1 parent 36ab577 commit 77562e5
Show file tree
Hide file tree
Showing 10 changed files with 519 additions and 5 deletions.
26 changes: 26 additions & 0 deletions src/de/jost_net/JVerein/Variable/AllgemeineMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
**********************************************************************/
package de.jost_net.JVerein.Variable;

import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.keys.Staat;
import de.jost_net.JVerein.util.JVDateFormatJJJJ;
import de.jost_net.JVerein.util.JVDateFormatMM;
import de.jost_net.JVerein.util.JVDateFormatMMJJJJ;
Expand All @@ -46,6 +49,7 @@ public AllgemeineMap()
}

public Map<String, Object> getMap(Map<String, Object> inma)
throws RemoteException
{
Map<String, Object> map = null;
if (inma == null)
Expand Down Expand Up @@ -81,6 +85,28 @@ public Map<String, Object> getMap(Map<String, Object> inma)
calendar.add(Calendar.YEAR, -1);
map.put(AllgemeineVar.VORJAHR.getName(), jjjj.format(calendar.getTime()));

map.put(AllgemeineVar.AKTUELLERMONAT.getName(), mmjjjj.format(new Date()));

map.put(AllgemeineVar.NAME.getName(),
Einstellungen.getEinstellung().getName());
map.put(AllgemeineVar.STRASSE.getName(),
Einstellungen.getEinstellung().getStrasse());
map.put(AllgemeineVar.PLZ.getName(),
Einstellungen.getEinstellung().getPlz());
map.put(AllgemeineVar.ORT.getName(),
Einstellungen.getEinstellung().getOrt());
map.put(AllgemeineVar.STAAT.getName(),
Staat.getByKey(Einstellungen.getEinstellung().getStaat()).getText());
map.put(AllgemeineVar.IBAN.getName(),
Einstellungen.getEinstellung().getIban());
map.put(AllgemeineVar.BIC.getName(),
Einstellungen.getEinstellung().getBic());
map.put(AllgemeineVar.GLAEUBIGER_ID.getName(),
Einstellungen.getEinstellung().getGlaeubigerID());
map.put(AllgemeineVar.UST_ID.getName(),
Einstellungen.getEinstellung().getUStID());
map.put(AllgemeineVar.STEUER_NR.getName(),
Einstellungen.getEinstellung().getSteuernummer());
return map;
}
}
12 changes: 11 additions & 1 deletion src/de/jost_net/JVerein/Variable/AllgemeineVar.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ public enum AllgemeineVar
TAGESDATUMJJJJ("tagesdatumjjjj"), //
VORMONAT("vormonat"), //
VORJAHR("vorjahr"), //
ZAEHLER("zaehler"); //
ZAEHLER("zaehler"), //
NAME("verein_name"), //
STRASSE("verein_strasse"), //
PLZ("verein_name"), //
ORT("verein_ort"), //
STAAT("verein_staat"), //
IBAN("verein_iban"), //
BIC("verein_bic"), //
GLAEUBIGER_ID("verein_glaeubiger_id"), //
UST_ID("verein_ust_id"), //
STEUER_NR("verein_steuer_nr"); //

private String name;

Expand Down
59 changes: 59 additions & 0 deletions src/de/jost_net/JVerein/gui/action/FormularExportAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**********************************************************************
* Copyright (c) by Heiner Jostkleigrewe
* 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 <http://www.gnu.org/licenses/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import de.jost_net.JVerein.gui.dialogs.ExportDialog;
import de.jost_net.JVerein.gui.view.DokumentationUtil;
import de.jost_net.JVerein.rmi.Formular;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

public class FormularExportAction implements Action
{

/**
* @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
*/
@Override
public void handleAction(Object context) throws ApplicationException
{
try
{
ExportDialog d = new ExportDialog(new Object[] { context },
Formular.class, DokumentationUtil.FORMULARE);
d.open();
}
catch (OperationCanceledException oce)
{
Logger.info(oce.getMessage());
return;
}
catch (ApplicationException ae)
{
throw ae;
}
catch (Exception e)
{
Logger.error("Fehler", e);
GUI.getStatusBar()
.setErrorText("Fehler beim exportieren des Formulars");
}
}
}
59 changes: 59 additions & 0 deletions src/de/jost_net/JVerein/gui/action/FormularImportAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**********************************************************************
* Copyright (c) by Heiner Jostkleigrewe
* 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 <http://www.gnu.org/licenses/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import de.jost_net.JVerein.gui.dialogs.ImportDialog;
import de.jost_net.JVerein.gui.view.DokumentationUtil;
import de.jost_net.JVerein.rmi.Formular;
import de.willuhn.datasource.GenericObject;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

public class FormularImportAction implements Action
{

/**
* @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
*/
@Override
public void handleAction(Object context) throws ApplicationException
{
try
{
ImportDialog d = new ImportDialog((GenericObject) context,
Formular.class, true, DokumentationUtil.FORMULARE);
d.open();
}
catch (OperationCanceledException oce)
{
Logger.info(oce.getMessage());
return;
}
catch (ApplicationException ae)
{
throw ae;
}
catch (Exception e)
{
Logger.error("Fehler", e);
GUI.getStatusBar().setErrorText("Fehler beim importieren des Formulars");
}
}
}
1 change: 1 addition & 0 deletions src/de/jost_net/JVerein/gui/control/FormularControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public Part getFormularList() throws RemoteException
formularList.setContextMenu(new FormularMenu(this));
formularList.setRememberOrder(true);
formularList.removeFeature(FeatureSummary.class);
formularList.setMulti(true);
return formularList;
}

Expand Down
2 changes: 0 additions & 2 deletions src/de/jost_net/JVerein/gui/dialogs/ImportDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ public void run(ProgressMonitor monitor) throws ApplicationException
}
catch (ApplicationException ae)
{
monitor.setStatus(ProgressMonitor.STATUS_ERROR);
monitor.setStatusText(ae.getMessage());
GUI.getStatusBar().setErrorText(ae.getMessage());
throw ae;
}
Expand Down
10 changes: 8 additions & 2 deletions src/de/jost_net/JVerein/gui/menu/FormularMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import de.jost_net.JVerein.gui.action.FormularAnzeigeAction;
import de.jost_net.JVerein.gui.action.FormularDeleteAction;
import de.jost_net.JVerein.gui.action.FormularDuplizierenAction;
import de.jost_net.JVerein.gui.action.FormularExportAction;
import de.jost_net.JVerein.gui.control.FormularControl;
import de.willuhn.jameica.gui.parts.CheckedContextMenuItem;
import de.willuhn.jameica.gui.parts.CheckedSingleContextMenuItem;
Expand All @@ -38,11 +39,16 @@ public FormularMenu(FormularControl control)
{
addItem(new CheckedSingleContextMenuItem("Bearbeiten", new FormularAction(),
"text-x-generic.png"));
addItem(new CheckedContextMenuItem("Anzeigen", new FormularAnzeigeAction(),
addItem(new CheckedSingleContextMenuItem("Anzeigen",
new FormularAnzeigeAction(),
"edit-copy.png"));
addItem(new CheckedSingleContextMenuItem("Duplizieren",
new FormularDuplizierenAction(control), "edit-copy.png"));
addItem(new CheckedContextMenuItem("Löschen", new FormularDeleteAction(),
addItem(new CheckedSingleContextMenuItem("Löschen",
new FormularDeleteAction(),
"user-trash-full.png"));
addItem(
new CheckedContextMenuItem("Exportieren",
new FormularExportAction(), "document-save.png"));
}
}
3 changes: 3 additions & 0 deletions src/de/jost_net/JVerein/gui/view/FormularListeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import de.jost_net.JVerein.gui.action.DokumentationAction;
import de.jost_net.JVerein.gui.action.FormularAction;
import de.jost_net.JVerein.gui.action.FormularImportAction;
import de.jost_net.JVerein.gui.control.FormularControl;
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.GUI;
Expand All @@ -38,6 +39,8 @@ public void bind() throws Exception
ButtonArea buttons = new ButtonArea();
buttons.addButton("Hilfe", new DokumentationAction(),
DokumentationUtil.FORMULARE, false, "question-circle.png");
buttons.addButton("Importieren", new FormularImportAction(), null, false,
"file-import.png");
buttons.addButton("Neu", new FormularAction(), null, false,
"document-new.png");
buttons.paint(this.getParent());
Expand Down
112 changes: 112 additions & 0 deletions src/de/jost_net/JVerein/io/FormularExporterXML.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**********************************************************************
* Copyright (c) by Heiner Jostkleigrewe
* 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 <http://www.gnu.org/licenses/>.
*
* [email protected]
* www.jverein.de
**********************************************************************/

package de.jost_net.JVerein.io;


import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.rmi.RemoteException;

import com.itextpdf.text.DocumentException;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.rmi.Formular;
import de.jost_net.JVerein.rmi.Formularfeld;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBObject;
import de.willuhn.datasource.serialize.XmlWriter;
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

public class FormularExporterXML implements Exporter
{
@Override
public String getName()
{
return "Formular XML-Export";
}

@Override
public IOFormat[] getIOFormats(Class<?> objectType)
{
if (objectType != Formular.class)
{
return null;
}
IOFormat f = new IOFormat()
{

@Override
public String getName()
{
return FormularExporterXML.this.getName();
}

/**
* @see de.willuhn.jameica.hbci.io.IOFormat#getFileExtensions()
*/
@Override
public String[] getFileExtensions()
{
return new String[] { "*.xml" };
}
};
return new IOFormat[] { f };
}

@Override
public String getDateiname()
{
return "formular";
}

@Override
public void doExport(Object[] objects, IOFormat format, File file,
ProgressMonitor monitor) throws RemoteException, ApplicationException,
FileNotFoundException, DocumentException, IOException
{
XmlWriter writer = new XmlWriter(
new BufferedOutputStream(new FileOutputStream(file)));

int count = 1;
if (objects[0] instanceof DBObject[])
{
objects = (Object[]) objects[0];
}
for (Object o : objects)
{
DBObject dbObject = (DBObject) o;
writer.write(dbObject);

DBIterator<Formularfeld> formularfeldIt = Einstellungen.getDBService()
.createList(Formularfeld.class);
formularfeldIt.addFilter("formular = ?", dbObject.getID());
while (formularfeldIt.hasNext())
{
writer.write(formularfeldIt.next());
}
monitor.setPercentComplete(count * 100 / objects.length);
}

writer.close();
}

}
Loading

0 comments on commit 77562e5

Please sign in to comment.