Skip to content

Commit

Permalink
Merge pull request #334 from it-at-m/153-implementierung-wahldaten
Browse files Browse the repository at this point in the history
153 implementierung wahldaten in eai-service
  • Loading branch information
MrSebastian committed Jul 9, 2024
2 parents 225224c + a9925c2 commit fa1b4ea
Show file tree
Hide file tree
Showing 78 changed files with 3,367 additions and 112 deletions.
14 changes: 13 additions & 1 deletion docs/src/features/eai-service/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ Wahlbeteiligungen der Wahllokale kann mitgeteilt werden.

### Wahllokalstatus

Der Zustand in dem sich die Wahllokale befinden kann mitgeteilt werden.
Der Zustand in dem sich die Wahllokale befinden kann mitgeteilt werden.

## Zugriffsbeschränkungen

Übersicht über die Endpunkte und die dafür benötigten Rechte:

| Endpunkt | erforderliche Rechte |
| --- | --- |
| GET /wahldaten/wahlbezirke/{wahlbezirkID}/wahlberechtigte | aoueai_BUSINESSACTION_LoadWahlberechtigte
| GET /wahldaten/wahltage?includingSince | aoueai_BUSINESSACTION_LoadWahltage
| GET /wahldaten/wahlbezirk?forDate&withNummer | aoueai_BUSINESSACTION_LoadWahlbezirke
| GET /wahldaten/wahlen?forDate&withNummer | aoueai_BUSINESSACTION_LoadWahlen
| GET /wahldaten/basisdaten?forDate&withNummer | aoueai_BUSINESSACTION_LoadBasisdaten
48 changes: 48 additions & 0 deletions stack/keycloak/migration/add-authorities-eai-wahldaten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
id: add authorities eai wahldaten
author: MrSebastian
realm: ${SSO_REALM}
changes:
- addRole:
name: aoueai_BUSINESSACTION_LoadWahltage
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadWahltage
clientId: ${SSO_CLIENT_ID}

- addRole:
name: aoueai_BUSINESSACTION_LoadWahlen
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadWahlen
clientId: ${SSO_CLIENT_ID}

- addRole:
name: aoueai_BUSINESSACTION_LoadWahlbezirke
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadWahlbezirke
clientId: ${SSO_CLIENT_ID}

- addRole:
name: aoueai_BUSINESSACTION_LoadWahlberechtigte
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadWahlberechtigte
clientId: ${SSO_CLIENT_ID}

- addRole:
name: aoueai_BUSINESSACTION_LoadBasisdaten
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadBasisdaten
clientId: ${SSO_CLIENT_ID}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: add authorities eai wahlvorstand
id: add authorities eai wahlvorschlag
author: dragonfly28
realm: ${SSO_REALM}
changes:
Expand Down
2 changes: 1 addition & 1 deletion stack/keycloak/migration/keycloak-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ includes:
- path: create-group-all-basisdaten-authorities.yml
- path: add-authorities-basisdaten-wahlvorschlaege.yml
- path: add-authorities-eai-wahlvorschlag.yml

- path: add-authorities-eai-wahldaten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import de.muenchen.oss.wahllokalsystem.eaiservice.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(onlyExplicitlyIncluded = true, callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Stimmzettelgebiet extends BaseEntity {

@ToString.Include
private String nummer;

@ToString.Include
private String name;

@NotNull
@Enumerated(EnumType.STRING)
@ToString.Include
private Stimmzettelgebietsart stimmzettelgebietsart;

@NotNull
@ManyToOne
@JoinColumn(name = "wahlID")
private Wahl wahl;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;
import org.springframework.data.repository.CrudRepository;

public interface StimmzettelgebietRepository extends CrudRepository<Stimmzettelgebiet, UUID> {

List<Stimmzettelgebiet> findByWahlWahltagTagAndWahlWahltagNummer(LocalDate wahltag, String nummer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

public enum Stimmzettelgebietsart {
SB, SG, SK, WK
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import de.muenchen.oss.wahllokalsystem.eaiservice.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(onlyExplicitlyIncluded = true, callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Wahl extends BaseEntity {

@NotNull
@ToString.Include
private String name;

@NotNull
@ToString.Include
@Enumerated(EnumType.STRING)
private Wahlart wahlart;

@NotNull
@ManyToOne
@JoinColumn(name = "wahltagID")
private Wahltag wahltag;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;
import org.springframework.data.repository.CrudRepository;

public interface WahlRepository extends CrudRepository<Wahl, UUID> {

List<Wahl> findByWahltagTagAndWahltagNummer(LocalDate wahltag, String nummer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

public enum Wahlart {
BAW, BEB, BTW, BZW, EUW, LTW, MBW, OBW, SRW, SVW, VE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import de.muenchen.oss.wahllokalsystem.eaiservice.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(onlyExplicitlyIncluded = true, callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Wahlbezirk extends BaseEntity {

@NotNull
@ToString.Include
@Enumerated(EnumType.STRING)
private WahlbezirkArt wahlbezirkArt;

@NotNull
@ToString.Include
private String nummer;

@NotNull
@ManyToOne
@JoinColumn(name = "stimmzettelgebietID")
private Stimmzettelgebiet stimmzettelgebiet;

@ToString.Include
private long a1;

@ToString.Include
private long a2;

@ToString.Include
private long a3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

public enum WahlbezirkArt {
UWB, BWB
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

public interface WahlbezirkRepository extends CrudRepository<Wahlbezirk, UUID> {

@Query(
"SELECT wb FROM Wahlbezirk wb JOIN FETCH wb.stimmzettelgebiet sg JOIN FETCH sg.wahl w JOIN FETCH w.wahltag t WHERE t.tag = (:wahltag) AND t.nummer = (:nummer)"
)
List<Wahlbezirk> findWahlbezirkeWithStimmzettelgebietAndWahlAndWahltagByWahltagAndNummer(@Param("wahltag") LocalDate wahltag,
@Param("nummer") String nummer);

@Query("SELECT wb FROM Wahlbezirk wb JOIN FETCH wb.stimmzettelgebiet sg JOIN FETCH sg.wahl w JOIN FETCH w.wahltag t WHERE wb.id = (:wahlbezirkID)")
List<Wahlbezirk> findWahlbezirkeWithStimmzettelgebietAndWahlAndWahltagByID(@Param("wahlbezirkID") UUID wahlbezirkID);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import de.muenchen.oss.wahllokalsystem.eaiservice.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString(onlyExplicitlyIncluded = true, callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Wahltag extends BaseEntity {

@NotNull
@ToString.Include
private LocalDate tag;

@NotNull
@ToString.Include
private String beschreibung;

@NotNull
@ToString.Include
private String nummer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahldaten;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;
import org.springframework.data.repository.CrudRepository;

public interface WahltageRepository extends CrudRepository<Wahltag, UUID> {

List<Wahltag> findByTagAfterOrTagEquals(LocalDate afterDate, LocalDate equalsDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public class ExceptionConstants {
public static final ExceptionDataWrapper LOADREFERENDUMVORLAGEN_WAHLID_FEHLT = new ExceptionDataWrapper(
CODE_WAHLID_FEHLT, MESSAGE_WAHLID_FEHLT);

//loadBasisdaten
public static final ExceptionDataWrapper LOADBASISDATEN_TAG_FEHLT = new ExceptionDataWrapper("001", "Es ist kein Tag definiert");
public static final ExceptionDataWrapper LOADBASISDATEN_NUMMER_FEHLT = new ExceptionDataWrapper("001_1", "Es ist keine Wahlnummer angegeben");

//loadWahlberechtigte
public static final ExceptionDataWrapper LOADWAHLBERECHTIGTE_SUCHKRITERIEN_UNVOLLSTAENDIG = new ExceptionDataWrapper("001",
"Wahlberechtigtenkriterien sind nicht vollständig");

//loadWahltage
public static final ExceptionDataWrapper LOADWAHLTAGE_TAG_FEHLT = new ExceptionDataWrapper("001", "Es ist kein Tag definiert");

//loadWahlbezirke
public static final ExceptionDataWrapper LOADWAHLBEZIRKE_WAHLTAG_FEHLT = new ExceptionDataWrapper("001", "Es ist kein Wahltag angegeben");
public static final ExceptionDataWrapper LOADWAHLBEZIRKE_NUMMER_FEHLT = new ExceptionDataWrapper("001_1", "Es ist keine Wahltag-Nummer angegeben");

//loadWahlen
public static final ExceptionDataWrapper LOADWAHLEN_WAHLTAG_FEHLT = new ExceptionDataWrapper("001", "Es ist kein Wahltag angegeben");
public static final ExceptionDataWrapper LOADWAHLEN_NUMMER_FEHLT = new ExceptionDataWrapper("001_1", "Es ist keine Wahlnummer angegeben");

/**
* @throws IllegalAccessException when constructor is used
*/
Expand Down
Loading

0 comments on commit fa1b4ea

Please sign in to comment.