### Eclipse Workspace Patch 1.0 #P jverein diff --git src/de/jost_net/JVerein/gui/control/BuchungsControl.java src/de/jost_net/JVerein/gui/control/BuchungsControl.java index 72c56db..f13268b 100644 --- src/de/jost_net/JVerein/gui/control/BuchungsControl.java +++ src/de/jost_net/JVerein/gui/control/BuchungsControl.java @@ -241,8 +241,9 @@ if (null != buchung) { Konto konto = buchung.getKonto(); - if (null != konto) + if (null != konto) { return konto.getID(); + } } return settings.getString("kontoid", ""); } @@ -469,6 +470,8 @@ } DBIterator list = Einstellungen.getDBService() .createList(Projekt.class); + Date currentDate = new Date(); + list.addFilter( "(startdatum is null or startdatum <= ?) and (endedatum is null or endedatum >= ?)", new Object[] {currentDate, currentDate} ); list.setOrder("ORDER BY bezeichnung"); projekt = new SelectInput(list, getBuchung().getProjekt()); projekt.setValue(getBuchung().getProjekt()); @@ -780,11 +783,15 @@ try { Object auswahl = mitgliedskonto.getValue(); - if (null == auswahl) + if (null == auswahl) + { return null; + } - if (auswahl instanceof Mitgliedskonto) + if (auswahl instanceof Mitgliedskonto) + { return (Mitgliedskonto) auswahl; + } if (auswahl instanceof Mitglied) { @@ -856,8 +863,10 @@ try { Projekt projekt = (Projekt) getProjekt().getValue(); - if (null == projekt) + if (null == projekt) + { return null; + } Long id = new Long(projekt.getID()); return id; } @@ -874,8 +883,9 @@ try { Buchungsart buchungsArt = (Buchungsart) getBuchungsart().getValue(); - if (null == buchungsArt) + if (null == buchungsArt) { return null; + } Long id = new Long(buchungsArt.getID()); return id; } @@ -943,7 +953,7 @@ @Override public String format(Object o) { - return (o != null ? "S" : " "); + return o != null ? "S" : " "; } }); buchungsList.addColumn("Konto", "konto", new Formatter() @@ -1464,8 +1474,9 @@ public String getTitleBuchungsView() throws RemoteException { - if (getBuchung().getSpeicherung()) + if (getBuchung().getSpeicherung()) { return "Buchung"; + } return "Splitbuchung"; } diff --git src/de/jost_net/JVerein/gui/control/ProjektControl.java src/de/jost_net/JVerein/gui/control/ProjektControl.java index b0d1f26..2c3b5f2 100644 --- src/de/jost_net/JVerein/gui/control/ProjektControl.java +++ src/de/jost_net/JVerein/gui/control/ProjektControl.java @@ -17,17 +17,20 @@ package de.jost_net.JVerein.gui.control; import java.rmi.RemoteException; +import java.util.Date; import de.jost_net.JVerein.Einstellungen; import de.jost_net.JVerein.gui.action.ProjektAction; import de.jost_net.JVerein.gui.menu.ProjektMenu; import de.jost_net.JVerein.rmi.Projekt; +import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; import de.willuhn.datasource.rmi.DBIterator; import de.willuhn.datasource.rmi.DBService; import de.willuhn.jameica.gui.AbstractControl; import de.willuhn.jameica.gui.AbstractView; import de.willuhn.jameica.gui.GUI; import de.willuhn.jameica.gui.Part; +import de.willuhn.jameica.gui.input.DateInput; import de.willuhn.jameica.gui.input.Input; import de.willuhn.jameica.gui.input.TextInput; import de.willuhn.jameica.gui.parts.TablePart; @@ -42,6 +45,10 @@ private TablePart projektList; private Input bezeichnung; + + private DateInput startDatum; + + private DateInput endeDatum; private Projekt projekt; @@ -72,6 +79,44 @@ return bezeichnung; } + public Input getStartDatum() throws RemoteException + { + if (startDatum != null) + { + return startDatum; + } + + Date d = getProjekt().getStartDatum(); + if (d.equals( Einstellungen.NODATE )) + { + d = null; + } + startDatum = new DateInput(d, new JVDateFormatTTMMJJJJ()); + startDatum.setName("Startdatum"); + startDatum.setTitle("Startdatum"); + startDatum.setText("Bitte Startdatum w�hlen"); + return startDatum; + } + + public Input getEndeDatum() throws RemoteException + { + if (endeDatum != null) + { + return endeDatum; + } + + Date d = getProjekt().getEndeDatum(); + if (d.equals( Einstellungen.NODATE )) + { + d = null; + } + endeDatum = new DateInput(d, new JVDateFormatTTMMJJJJ()); + endeDatum.setName("Endedatum"); + endeDatum.setTitle("Endedatum"); + endeDatum.setText("Bitte Endedatum w�hlen"); + return endeDatum; + } + /** * This method stores the project using the current values. */ @@ -81,6 +126,9 @@ { Projekt p = getProjekt(); p.setBezeichnung((String) getBezeichnung().getValue()); + p.setStartDatum( (Date) getStartDatum().getValue() ); + p.setEndeDatum( (Date) getEndeDatum().getValue() ); + try { p.store(); @@ -107,6 +155,8 @@ projektList = new TablePart(projekte, new ProjektAction()); projektList.addColumn("Bezeichnung", "bezeichnung"); + projektList.addColumn("Startdatum", "startdatum"); + projektList.addColumn("Endedatum", "endedatum"); projektList.setContextMenu(new ProjektMenu()); projektList.setRememberColWidths(true); projektList.setRememberOrder(true); diff --git src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java index b0cb0c5..356884f 100644 --- src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java +++ src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java @@ -18,6 +18,7 @@ package de.jost_net.JVerein.gui.dialogs; import java.rmi.RemoteException; +import java.util.Date; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; @@ -93,6 +94,8 @@ } DBIterator pj = Einstellungen.getDBService() .createList(Projekt.class); + Date currentDate = new Date(); + pj.addFilter( "(startdatum is null or startdatum <= ?) and (endedatum is null or endedatum >= ?)", new Object[] {currentDate, currentDate} ); pj.setOrder("ORDER BY bezeichnung"); this.projekte = new SelectInput(pj, null); this.projekte.setName("Projekt"); diff --git src/de/jost_net/JVerein/gui/view/ProjektView.java src/de/jost_net/JVerein/gui/view/ProjektView.java index 8d7c74f..2abd656 100644 --- src/de/jost_net/JVerein/gui/view/ProjektView.java +++ src/de/jost_net/JVerein/gui/view/ProjektView.java @@ -36,6 +36,8 @@ LabelGroup group = new LabelGroup(getParent(), "Projekt"); group.addLabelPair("Bezeichnung", control.getBezeichnung()); + group.addLabelPair("Startdatum", control.getStartDatum()); + group.addLabelPair("Endedatum", control.getEndeDatum()); ButtonArea buttons = new ButtonArea(); buttons.addButton("Hilfe", new DokumentationAction(), diff --git src/de/jost_net/JVerein/rmi/Projekt.java src/de/jost_net/JVerein/rmi/Projekt.java index 0f531b8..4fa0f78 100644 --- src/de/jost_net/JVerein/rmi/Projekt.java +++ src/de/jost_net/JVerein/rmi/Projekt.java @@ -17,6 +17,7 @@ package de.jost_net.JVerein.rmi; import java.rmi.RemoteException; +import java.util.Date; import de.willuhn.datasource.rmi.DBObject; @@ -26,4 +27,19 @@ public void setBezeichnung(String bezeichnung) throws RemoteException; + public Date getStartDatum() throws RemoteException; + + public void setStartDatum(Date startDatum) throws RemoteException; + + public void setStartDatum(String startDatum) throws RemoteException; + + public Date getEndeDatum() throws RemoteException; + + public void setEndeDatum(Date endeDatum) throws RemoteException; + + public void setEndeDatum(String endeDatum) throws RemoteException; + + public boolean isStartDatumGesetzt() throws RemoteException; + + public boolean isEndeDatumGesetzt() throws RemoteException; } diff --git src/de/jost_net/JVerein/server/DDLTool/Updates/Update0416.java src/de/jost_net/JVerein/server/DDLTool/Updates/Update0416.java new file mode 100644 index 0000000..976ec13 --- /dev/null +++ src/de/jost_net/JVerein/server/DDLTool/Updates/Update0416.java @@ -0,0 +1,52 @@ +/********************************************************************** + * JVerein - Mitgliederverwaltung und einfache Buchhaltung f�r Vereine + * Copyright (c) by Heiner Jostkleigrewe + * Copyright (c) 2015 by Thomas Hooge + * Main Project: heiner@jverein.dem http://www.jverein.de/ + * Module Author: thomas@hoogi.de, http://www.hoogi.de/ + * + * This file is part of JVerein. + * + * JVerein 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. + * + * JVerein 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 de.jost_net.JVerein.server.DDLTool.Updates; + +import java.sql.Connection; + +import de.jost_net.JVerein.server.DDLTool.AbstractDDLUpdate; +import de.jost_net.JVerein.server.DDLTool.Column; +import de.willuhn.util.ApplicationException; +import de.willuhn.util.ProgressMonitor; + +public class Update0416 extends AbstractDDLUpdate +{ + public Update0416(String driver, ProgressMonitor monitor, Connection conn) + { + super(driver, monitor, conn); + } + + @Override + public void run() throws ApplicationException + { + // Startdatum des Projektes + execute(addColumn("projekt", + new Column("startdatum", COLTYPE.DATE, 0, "NULL", false, false))); + + // Endedatum des Projektes + execute(addColumn("projekt", + new Column("endedatum", COLTYPE.DATE, 0, "NULL", false, false))); + + } +} \ No newline at end of file diff --git src/de/jost_net/JVerein/server/ProjektImpl.java src/de/jost_net/JVerein/server/ProjektImpl.java index 6679a16..ea18678 100644 --- src/de/jost_net/JVerein/server/ProjektImpl.java +++ src/de/jost_net/JVerein/server/ProjektImpl.java @@ -17,8 +17,11 @@ package de.jost_net.JVerein.server; import java.rmi.RemoteException; +import java.util.Date; +import de.jost_net.JVerein.Einstellungen; import de.jost_net.JVerein.rmi.Projekt; +import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; import de.willuhn.datasource.db.AbstractDBObject; import de.willuhn.logging.Logger; import de.willuhn.util.ApplicationException; @@ -27,6 +30,9 @@ { private static final long serialVersionUID = 1L; + + private static final String STARTDATUM = "startdatum"; + private static final String ENDEDATUM = "endedatum"; public ProjektImpl() throws RemoteException { @@ -72,6 +78,11 @@ { throw new ApplicationException("Bitte Bezeichnung eingeben"); } + + if ( isStartDatumGesetzt() && isEndeDatumGesetzt() && getEndeDatum().before( getStartDatum() ) ) + { + throw new ApplicationException( "Endedatum muss nach dem Startdatum liegen" ); + } } @Override @@ -99,9 +110,78 @@ } @Override + public Date getStartDatum() throws RemoteException { + Date d = (Date) getAttribute(STARTDATUM); + if ( d == null ) { + return Einstellungen.NODATE; + } + + return d; + } + + @Override + public void setStartDatum( Date startDatum ) throws RemoteException + { + setAttribute( STARTDATUM, startDatum ); + } + + @Override + public void setStartDatum( String startDatum ) throws RemoteException + { + setAttribute( STARTDATUM, toDate(startDatum) ); + } + + @Override + public Date getEndeDatum() throws RemoteException + { + Date d = (Date) getAttribute(ENDEDATUM); + if( d == null ) { + return Einstellungen.NODATE; + } + return d; + } + + @Override + public void setEndeDatum( Date endeDatum ) throws RemoteException + { + setAttribute(ENDEDATUM, endeDatum); + } + + @Override + public void setEndeDatum(String endeDatum) throws RemoteException + { + setAttribute(ENDEDATUM, toDate(endeDatum)); + } + + @Override + public boolean isStartDatumGesetzt() throws RemoteException { + return getAttribute( STARTDATUM ) != null; + } + + @Override + public boolean isEndeDatumGesetzt() throws RemoteException { + return getAttribute( ENDEDATUM ) != null; + } + + @Override public Object getAttribute(String fieldName) throws RemoteException { return super.getAttribute(fieldName); } + private Date toDate(String datum) + { + Date d = null; + + try + { + d = new JVDateFormatTTMMJJJJ().parse(datum); + } + catch (Exception e) + { + // + } + return d; + } + }