Skip to content

Commit

Permalink
Fix internen Fehler und Auswertung Bug (#202)
Browse files Browse the repository at this point in the history
* Fix internen  Fehler

* is..active() implementiert

* geschlecht in settings aufgenommen

* Fix fehlende Parameter bei NichtMitglied Auswertung

* Fix Ausgabe der Zusatzfelder in den Parametern

* weitere fixes

* zwei attribute set statt get

* fix sort

* Für Suche eigenes SuchGeschlecht

Wird sonst doppelt verwendet

* kleine Korrektur
  • Loading branch information
JohannMaierhofer committed Apr 27, 2024
1 parent 78b2db7 commit 058d26a
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 271 deletions.
231 changes: 119 additions & 112 deletions src/de/jost_net/JVerein/Queries/MitgliedQuery.java
Expand Up @@ -78,27 +78,32 @@ public ArrayList<Mitglied> get(int adresstyp) throws RemoteException
ArrayList<Object> bedingungen = new ArrayList<>();

sql = "select distinct mitglied.*, ucase(name), ucase(vorname) ";
String sort = (String) control.getSortierung().getValue();
if (sort.equals("Geburtstagsliste"))
if (control.isSortierungAktiv())
{
sql += ", month(geburtsdatum), day(geburtsdatum) ";
String sort = (String) control.getSortierung().getValue();
if (sort.equals("Geburtstagsliste"))
{
sql += ", month(geburtsdatum), day(geburtsdatum) ";
}
}
sql += "from mitglied ";
Settings settings = control.getSettings();
char synonym = 'a';
DBIterator<Felddefinition> fdit = Einstellungen.getDBService()
.createList(Felddefinition.class);
if (settings.getInt(zusatzfelder + "selected", 0) > fdit.size())
if (control.isZusatzfelderAuswahlAktiv())
{
settings.setAttribute(zusatzfelder + "selected", 0);
}
if (settings.getInt(zusatzfelder + "selected", 0) > 0)
{
for (int i = 1; i <= settings.getInt(zusatzfelder + "counter", 0); i++)
if (settings.getInt(zusatzfelder + "selected", 0) > fdit.size())
{
int definition = settings.getInt(zusatzfeld + i + ".definition", -1);
switch (settings.getInt(zusatzfeld + i + ".datentyp", -1))
settings.setAttribute(zusatzfelder + "selected", 0);
}
if (settings.getInt(zusatzfelder + "selected", 0) > 0)
{
for (int i = 1; i <= settings.getInt(zusatzfelder + "counter", 0); i++)
{
int definition = settings.getInt(zusatzfeld + i + ".definition", -1);
switch (settings.getInt(zusatzfeld + i + ".datentyp", -1))
{
case Datentyp.ZEICHENFOLGE:
{
String value = settings
Expand Down Expand Up @@ -197,6 +202,7 @@ public ArrayList<Mitglied> get(int adresstyp) throws RemoteException
}
break;
}
}
}
}
}
Expand All @@ -208,7 +214,7 @@ public ArrayList<Mitglied> get(int adresstyp) throws RemoteException
{
addCondition("adresstyp != " + 1);
}
if (control.isMitgliedStatusAktiv() && adresstyp == 1)
if (control.isMitgliedStatusAktiv())
{
if (control.getMitgliedStatus().getValue().equals("Angemeldet"))
{
Expand Down Expand Up @@ -237,29 +243,54 @@ else if (control.getMitgliedStatus().getValue().equals("Abgemeldet"))
}
}
}
int mailauswahl = (Integer) control.getMailauswahl().getValue();
if (batch && mailauswahl == MailAuswertungInput.OHNE)
if (control.isMailauswahlAktiv())
{
addCondition("(email is null or length(email) = 0)");
}
if (batch && mailauswahl == MailAuswertungInput.MIT)
{
addCondition("(email is not null and length(email) > 0)");
int mailauswahl = (Integer) control.getMailauswahl().getValue();
if (batch && mailauswahl == MailAuswertungInput.OHNE)
{
addCondition("(email is null or length(email) = 0)");
}
if (batch && mailauswahl == MailAuswertungInput.MIT)
{
addCondition("(email is not null and length(email) > 0)");
}
}
String eigenschaften = "";
eigenschaften = control.getEigenschaftenString();
if (eigenschaften.length() > 0)
if (control.isEigenschaftenAuswahlAktiv())
{
EigenschaftenUtil eiu = new EigenschaftenUtil(eigenschaften);
if (control.getEigenschaftenVerknuepfung().equals("und"))
String eigenschaften = "";
eigenschaften = control.getEigenschaftenString();
if (eigenschaften.length() > 0)
{
for (EigenschaftGruppe eg : eiu.getGruppen())
EigenschaftenUtil eiu = new EigenschaftenUtil(eigenschaften);
if (control.getEigenschaftenVerknuepfung().equals("und"))
{
for (EigenschaftGruppe eg : eiu.getGruppen())
{
StringBuilder condEigenschaft = new StringBuilder(
"(select count(*) from eigenschaften where ");
boolean first = true;
condEigenschaft.append("eigenschaften.mitglied = mitglied.id AND (");
for (Eigenschaft ei : eiu.get(eg))
{
if (!first)
{
condEigenschaft.append("OR ");
}
first = false;
condEigenschaft.append("eigenschaft = ? ");
bedingungen.add(ei.getID());
}
condEigenschaft.append(")) > 0 ");
addCondition(condEigenschaft.toString());
}
}
else
{
StringBuilder condEigenschaft = new StringBuilder(
"(select count(*) from eigenschaften where ");
boolean first = true;
condEigenschaft.append("eigenschaften.mitglied = mitglied.id AND (");
for (Eigenschaft ei : eiu.get(eg))
for (Eigenschaft ei : eiu.getEigenschaften())
{
if (!first)
{
Expand All @@ -273,91 +304,77 @@ else if (control.getMitgliedStatus().getValue().equals("Abgemeldet"))
addCondition(condEigenschaft.toString());
}
}
else
{
StringBuilder condEigenschaft = new StringBuilder(
"(select count(*) from eigenschaften where ");
boolean first = true;
condEigenschaft.append("eigenschaften.mitglied = mitglied.id AND (");
for (Eigenschaft ei : eiu.getEigenschaften())
{
if (!first)
{
condEigenschaft.append("OR ");
}
first = false;
condEigenschaft.append("eigenschaft = ? ");
bedingungen.add(ei.getID());
}
condEigenschaft.append(")) > 0 ");
addCondition(condEigenschaft.toString());
}
}
String tmpSuchname = (String) control.getSuchname().getValue();
if (!batch && tmpSuchname.length() > 0)
if (control.isSuchnameAktiv())
{
addCondition("(lower(name) like ?)");
bedingungen.add(tmpSuchname.toLowerCase() + "%");
String tmpSuchname = (String) control.getSuchname().getValue();
if (!batch && tmpSuchname.length() > 0)
{
addCondition("(lower(name) like ?)");
bedingungen.add(tmpSuchname.toLowerCase() + "%");
}
}

if (control.getGeburtsdatumvon().getValue() != null)
if (control.isGeburtsdatumvonAktiv() && control.getGeburtsdatumvon().getValue() != null)
{
addCondition("geburtsdatum >= ?");
Date d = (Date) control.getGeburtsdatumvon().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.getGeburtsdatumbis().getValue() != null)
if (control.isGeburtsdatumbisAktiv() && control.getGeburtsdatumbis().getValue() != null)
{
addCondition("geburtsdatum <= ?");
Date d = (Date) control.getGeburtsdatumbis().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}

if (batch && control.getSterbedatumvon().getValue() != null && adresstyp == 1)
if (batch && control.isSterbedatumvonAktiv() && control.getSterbedatumvon().getValue() != null)
{
addCondition("sterbetag >= ?");
Date d = (Date) control.getSterbedatumvon().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (batch && control.getSterbedatumbis().getValue() != null && adresstyp == 1)
if (batch && control.isSterbedatumbisAktiv() && control.getSterbedatumbis().getValue() != null)
{
addCondition("sterbetag <= ?");
Date d = (Date) control.getSterbedatumbis().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.getGeschlecht().getText() != null
&& !control.getGeschlecht().getText().equals("Bitte auswählen"))
if (control.isSuchGeschlechtAktiv() && control.getSuchGeschlecht().getText() != null
&& !control.getSuchGeschlecht().getText().equals("Bitte auswählen"))
{
addCondition("geschlecht = ?");
String g = (String) control.getGeschlecht().getValue();
String g = (String) control.getSuchGeschlecht().getValue();
bedingungen.add(g);
}
if (control.getEintrittvon().getValue() != null && adresstyp == 1)
if (control.isEintrittvonAktiv() && control.getEintrittvon().getValue() != null)
{
addCondition("eintritt >= ?");
Date d = (Date) control.getEintrittvon().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.getEintrittbis().getValue() != null && adresstyp == 1)
if (control.isEintrittbisAktiv() && control.getEintrittbis().getValue() != null)
{
addCondition("eintritt <= ?");
Date d = (Date) control.getEintrittbis().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.isAustrittbisAktiv() && adresstyp == 1)
if (control.isAustrittvonAktiv() && control.getAustrittvon().getValue() != null)
{
if (control.getAustrittvon().getValue() != null)
{
addCondition("austritt >= ?");
Date d = (Date) control.getAustrittvon().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.getAustrittbis().getValue() != null)
{
addCondition("austritt <= ?");
Date d = (Date) control.getAustrittbis().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
addCondition("austritt >= ?");
Date d = (Date) control.getAustrittvon().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}
if (control.isAustrittbisAktiv() && control.getAustrittbis().getValue() != null)
{
addCondition("austritt <= ?");
Date d = (Date) control.getAustrittbis().getValue();
bedingungen.add(new java.sql.Date(d.getTime()));
}

if (control.isAustrittbisAktiv())
{
// Was soll das? Das wird nie durchlaufen!
if (control.getSterbedatumvon() == null
&& control.getSterbedatumbis() == null
&& control.getAustrittvon().getValue() == null
Expand All @@ -366,17 +383,19 @@ else if (control.getMitgliedStatus().getValue().equals("Abgemeldet"))
addCondition("(austritt is null or austritt > current_date())");
}
}
if (Einstellungen.getEinstellung().getExterneMitgliedsnummer())

if (control.isSuchExterneMitgliedsnummerActive())
{
try
{
if (control.getSuchExterneMitgliedsnummer().getValue() != null && adresstyp == 1)
if (control.getSuchExterneMitgliedsnummer().getValue() != null)
{
String ext = (String) control.getSuchExterneMitgliedsnummer()
.getValue();
if (ext.length() > 0)
{
addCondition("externemitgliedsnummer = ?");
bedingungen.add(ext);
}
}
}
Expand All @@ -385,32 +404,41 @@ else if (control.getMitgliedStatus().getValue().equals("Abgemeldet"))
// Workaround für einen Bug in IntegerInput
}
}
Beitragsgruppe bg = (Beitragsgruppe) control.getBeitragsgruppeAusw()
.getValue();
if (bg != null && adresstyp == 1)
{
addCondition("beitragsgruppe = ? ");
}
if (sort.equals("Name, Vorname"))
if (control.isBeitragsgruppeAuswAktiv())
{
sql += " ORDER BY ucase(name), ucase(vorname)";
}
else if (sort.equals("Eintrittsdatum"))
{
sql += " ORDER BY eintritt";
}
else if (sort.equals("Geburtsdatum"))
{
sql += " ORDER BY geburtsdatum";
Beitragsgruppe bg = (Beitragsgruppe) control.getBeitragsgruppeAusw()
.getValue();
if (bg != null)
{
addCondition("beitragsgruppe = ? ");
bedingungen.add(Integer.valueOf(bg.getID()));
}
}
else if (sort.equals("Geburtstagsliste"))
if (control.isSortierungAktiv())
{
sql += " ORDER BY month(geburtsdatum), day(geburtsdatum)";
String sort = (String) control.getSortierung().getValue();
if (sort.equals("Name, Vorname"))
{
sql += " ORDER BY ucase(name), ucase(vorname)";
}
else if (sort.equals("Eintrittsdatum"))
{
sql += " ORDER BY eintritt";
}
else if (sort.equals("Geburtsdatum"))
{
sql += " ORDER BY geburtsdatum";
}
else if (sort.equals("Geburtstagsliste"))
{
sql += " ORDER BY month(geburtsdatum), day(geburtsdatum)";
}
}
else
{
sql += " ORDER BY name, vorname";
}

Logger.debug(sql);

ResultSetExtractor rs = new ResultSetExtractor()
Expand All @@ -428,27 +456,6 @@ public Object extract(ResultSet rs) throws RemoteException, SQLException
}
};

try
{
if (Einstellungen.getEinstellung().getExterneMitgliedsnummer()
&& control.getSuchExterneMitgliedsnummer().getValue() != null && adresstyp == 1)
{
String ext = (String) control.getSuchExterneMitgliedsnummer()
.getValue();
if (ext.length() > 0)
{
bedingungen.add(control.getSuchExterneMitgliedsnummer().getValue());
}
}
}
catch (NullPointerException e)
{
// Workaround f. Bug in IntegerInput
}
if (bg != null && adresstyp == 1)
{
bedingungen.add(Integer.valueOf(bg.getID()));
}
return (ArrayList<Mitglied>) service.execute(sql, bedingungen.toArray(),
rs);
}
Expand Down
Expand Up @@ -19,7 +19,7 @@
import java.rmi.RemoteException;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.gui.view.AuswertungAdresseView;
import de.jost_net.JVerein.gui.view.AuswertungNichtMitgliedView;
import de.jost_net.JVerein.rmi.Mitglied;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void handleAction(Object context) throws ApplicationException
}
}

GUI.startView(AuswertungAdresseView.class.getName(), m);
GUI.startView(AuswertungNichtMitgliedView.class.getName(), m);
}

}

0 comments on commit 058d26a

Please sign in to comment.