### Eclipse Workspace Patch 1.0 #P jverein diff --git build/BUILD build/BUILD index 92ca10f..502e1b3 100644 --- build/BUILD +++ build/BUILD @@ -1,3 +1,3 @@ -#Build Number for ANT. Do not edit! -#Sun Feb 28 09:00:48 CET 2016 -build.number=514 +#Build Number for ANT. Do not edit! +#Mon Jan 09 14:49:25 CET 2017 +build.number=517 diff --git src/de/jost_net/JVerein/gui/action/BuchungProjektZuordnungAction.java src/de/jost_net/JVerein/gui/action/BuchungProjektZuordnungAction.java index 7b1089c..6da0a4e 100644 --- src/de/jost_net/JVerein/gui/action/BuchungProjektZuordnungAction.java +++ src/de/jost_net/JVerein/gui/action/BuchungProjektZuordnungAction.java @@ -68,7 +68,7 @@ try { ProjektAuswahlDialog pad = new ProjektAuswahlDialog( - AbstractDialog.POSITION_CENTER); + AbstractDialog.POSITION_CENTER, b); Projekt open = pad.open(); if (open == null) diff --git src/de/jost_net/JVerein/gui/control/BuchungsControl.java src/de/jost_net/JVerein/gui/control/BuchungsControl.java index 72c56db..b44be62 100644 --- src/de/jost_net/JVerein/gui/control/BuchungsControl.java +++ src/de/jost_net/JVerein/gui/control/BuchungsControl.java @@ -469,6 +469,8 @@ } DBIterator list = Einstellungen.getDBService() .createList(Projekt.class); + Date buchungsDatum = getBuchung().getDatum() == null ? new Date() : getBuchung().getDatum(); + list.addFilter( "((startdatum is null or startdatum <= ?) and (endedatum is null or endedatum >= ?))", new Object[] {buchungsDatum, buchungsDatum} ); list.setOrder("ORDER BY bezeichnung"); projekt = new SelectInput(list, getBuchung().getProjekt()); projekt.setValue(getBuchung().getProjekt()); 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..6b77848 100644 --- src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java +++ src/de/jost_net/JVerein/gui/dialogs/ProjektAuswahlDialog.java @@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Listener; import de.jost_net.JVerein.Einstellungen; +import de.jost_net.JVerein.rmi.Buchung; import de.jost_net.JVerein.rmi.Projekt; import de.willuhn.datasource.rmi.DBIterator; import de.willuhn.jameica.gui.Action; @@ -43,9 +44,12 @@ private SelectInput projekte = null; - public ProjektAuswahlDialog(int position) + Buchung[] buchungen = null; + + public ProjektAuswahlDialog(int position, Buchung[] buchungen) { super(position); + this.buchungen = buchungen; setTitle("Projekt ausw�hlen"); setSize(450, 150); @@ -93,6 +97,15 @@ } DBIterator pj = Einstellungen.getDBService() .createList(Projekt.class); + String select = "((startdatum is null or startdatum <= ?) and (endedatum is null or endedatum >= ?)) "; + + if ( buchungen != null ) { + /* UND-Verkn�pfung der Datumsbereiche, damit nur Projekte angezeigt werden, die f�r die Auswahl g�ltig sind */ + for ( Buchung buchung : buchungen ) { + pj.addFilter( select, new Object[] {buchung.getDatum(), buchung.getDatum()} ); + } + } + 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/BuchungImpl.java src/de/jost_net/JVerein/server/BuchungImpl.java index e867bd1..668adcc 100644 --- src/de/jost_net/JVerein/server/BuchungImpl.java +++ src/de/jost_net/JVerein/server/BuchungImpl.java @@ -117,6 +117,24 @@ throw new ApplicationException( "Buchung kann nicht gespeichert werden. Zeitraum ist bereits abgeschlossen!"); } + + /* Pr�fung des Projektes */ + Projekt projekt = getProjekt(); + if ( projekt != null ) { + Date startDatum = projekt.getStartDatum(); + Date endeDatum = projekt.getEndeDatum(); + + if ( startDatum != null && startDatum.after( getDatum() ) ) { + throw new ApplicationException( + "Buchungsdatum liegt vor dem Projektbeginn!"); + } + + if ( endeDatum != null && endeDatum.before( getDatum() ) ) { + throw new ApplicationException( + "Buchungsdatum liegt nach dem Projektende!"); + } + } + if (!getSpeicherung() && getBuchungsart() == null) { throw new ApplicationException("Buchungsart fehlt bei Splitbuchung!"); 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; + } + }