Skip to content

Commit

Permalink
Merge pull request #315 from it-at-m/152-implementierung-wahlvorstand…
Browse files Browse the repository at this point in the history
…sdaten

152 implementierung wahlvorstandsdaten
  • Loading branch information
MrSebastian authored Jun 21, 2024
2 parents 3c739b2 + e535dd6 commit 6dfb8da
Show file tree
Hide file tree
Showing 40 changed files with 1,603 additions and 36 deletions.
21 changes: 21 additions & 0 deletions stack/keycloak/migration/add-authorities-eai-wahlvorstand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
id: add authorities eai wahlvorstand
author: MrSebastian
realm: ${SSO_REALM}
changes:
- addRole:
name: aoueai_BUSINESSACTION_LoadWahlvorstand
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_LoadWahlvorstand
clientId: ${SSO_CLIENT_ID}

- addRole:
name: aoueai_BUSINESSACTION_SaveAnwesenheit
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allEaiAuthorities
role: aoueai_BUSINESSACTION_SaveAnwesenheit
clientId: ${SSO_CLIENT_ID}
15 changes: 15 additions & 0 deletions stack/keycloak/migration/create-group-all-eai-authorities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
id: create group allEaiAuthorities and link wls_all*
author: MrSebastian
realm: ${SSO_REALM}
changes:
- addGroup:
name: allEaiAuthorities
- assignGroup:
user: wls_all
group: allEaiAuthorities
- assignGroup:
user: wls_all_uwb
group: allEaiAuthorities
- assignGroup:
user: wls_all_bwb
group: allEaiAuthorities
2 changes: 2 additions & 0 deletions stack/keycloak/migration/keycloak-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ includes:
- path: add-authorities-wahlvorbereitung-fortsetzungsuhrzeit.yml
- path: add-authorities-wahlvorbereitung-eroeffnungsuhrzeit.yml
- path: add-authorities-wahlvorbereitung-urnenwahlschliessungsuhrzeit.yml
- path: create-group-all-eai-authorities.yml
- path: add-authorities-eai-wahlvorstand.yml
5 changes: 5 additions & 0 deletions wls-eai-service/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
</module>

<module name="TreeWalker">
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="OuterTypeFilename"/>
<module name="NoLineWrap">
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@ComponentScan(
basePackages = {
"org.springframework.data.jpa.convert.threeten",
"de.muenchen.oss.wahllokalsystem.eaiservice"
"de.muenchen.oss.wahllokalsystem.eaiservice",
"de.muenchen.oss.wahllokalsystem.wls.common.exception"
}
)
@EntityScan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static java.sql.Types.VARCHAR;

import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
Expand All @@ -17,24 +16,24 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.UuidGenerator;

@MappedSuperclass
@NoArgsConstructor
@Getter
@Setter
@ToString
@ToString(onlyExplicitlyIncluded = true)
@EqualsAndHashCode
public abstract class BaseEntity implements Cloneable, Serializable {

private static final long serialVersionUID = 1L;

@Column(name = "id", length = 36)
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@UuidGenerator
@JdbcTypeCode(VARCHAR)
@ToString.Include
private UUID id;

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

import static java.sql.Types.VARCHAR;

import de.muenchen.oss.wahllokalsystem.eaiservice.domain.BaseEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.validation.constraints.NotNull;
import java.util.Collection;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.JdbcTypeCode;

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

@NotNull
@ToString.Include
@JdbcTypeCode(VARCHAR)
private UUID wahlbezirkID;

@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "wahlvorstandid")
private Collection<Wahlvorstandsmitglied> mitglieder;

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

import java.util.Optional;
import java.util.UUID;
import org.springframework.data.repository.CrudRepository;

public interface WahlvorstandRepository extends CrudRepository<Wahlvorstand, UUID> {

Optional<Wahlvorstand> findFirstByWahlbezirkID(UUID wahlbezirkID);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahlvorstand;

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

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

@NotNull
@ToString.Include
private String vorname;

@NotNull
@ToString.Include
private String nachname;

@NotNull
@ToString.Include
@Enumerated(EnumType.STRING)
private WahlvorstandsmitgliedsFunktion funktion;

@ToString.Include
private boolean anwesend;

@ToString.Include
private LocalDateTime anwesenheitUpdatedOn;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.domain.wahlvorstand;

public enum WahlvorstandsmitgliedsFunktion {
W, //Wahlvorsteher*in
SB, //Schriftführer*in
SWB, //Stellvertretung Wahlvorsteher*in
SSB, //Stellvertretung Schriftführer*in
B //Beisitzer*in
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.exception;

import de.muenchen.oss.wahllokalsystem.wls.common.exception.errorhandler.AbstractExceptionHandler;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.rest.model.DTOMapper;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.rest.model.WlsExceptionDTO;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ServiceIDFormatter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler extends AbstractExceptionHandler {
private final ServiceIDFormatter serviceIDFormatter;

public GlobalExceptionHandler(final ServiceIDFormatter serviceIDFormatter, final DTOMapper dtoMapper) {
super(dtoMapper);
this.serviceIDFormatter = serviceIDFormatter;
}

@ExceptionHandler
public ResponseEntity<WlsExceptionDTO> handleThrowables(final Throwable throwable) {
log.info("handling throwable", throwable);
return createResponse(getWahlExceptionDTO(throwable));
}

@ExceptionHandler
public ResponseEntity<Void> handleNotFoundException(final NotFoundException notFoundException) {
log.debug("not found entity {} with id {}", notFoundException.getEntityClass(), notFoundException.getRequestedID());
return ResponseEntity.notFound().build();
}

@Override
protected String getService() {
return serviceIDFormatter.getId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.exception;

import java.util.UUID;
import lombok.Getter;

@Getter
public class NotFoundException extends RuntimeException {

private final UUID requestedID;

private final Class<?> entityClass;

public NotFoundException(UUID requestID, Class<?> entityClass) {
this.requestedID = requestID;
this.entityClass = entityClass;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.rest.common.exception;

public class ExceptionConstants {
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionDataWrapper;

public static final String CODE_DATENALLGEMEIN_ID_NICHT_KONVERTIERBAR = "103";
public class ExceptionConstants {

public static final String CODE_FEHLER_BEI_KOMMUNIKATIONS_MIT_FREMDSYSTEM = "901";
public static final String MESSAGE_FEHLER_BEI_KOMMUNIKATIONS_MIT_FREMDSYSTEM = "Fremdsystem hat Fehler geworfen";
public static final String MESSAGE_FEHLER_BEI_KOMMUNIKATIONS_MIT_FREMDSYSTEM_MIT_MESSAGE = "Fremdsystem hat Fehler geworfen: %s";

public static final String CODE_DATENALLGEMEIN_PARAMETER_FEHLEN = "102";
public static final String MESSAGE_DATENALLGEMEIN_PARAMETER_FEHLEN = "Anfrage ist ungueltig da notwendige Anfragedaten fehlen";
private static final String CODE_DATENALLGEMEIN_PARAMETER_FEHLEN = "102";
private static final String MESSAGE_DATENALLGEMEIN_PARAMETER_FEHLEN = "Anfrage ist ungueltig da notwendige Anfragedaten fehlen";
public static final ExceptionDataWrapper DATENALLGEMEIN_PARAMETER_FEHLEN = new ExceptionDataWrapper(CODE_DATENALLGEMEIN_PARAMETER_FEHLEN,
MESSAGE_DATENALLGEMEIN_PARAMETER_FEHLEN);

private static final String CODE_DATENALLGEMEIN_ID_NICHT_KONVERTIERBAR = "103";
public static final ExceptionDataWrapper ID_NICHT_KONVERTIERBAR = new ExceptionDataWrapper(
CODE_DATENALLGEMEIN_ID_NICHT_KONVERTIERBAR, "");

/**
* @throws IllegalAccessException when constructor is used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@

import de.muenchen.oss.wahllokalsystem.eaiservice.rest.wahlvorstand.dto.WahlvorstandDTO;
import de.muenchen.oss.wahllokalsystem.eaiservice.rest.wahlvorstand.dto.WahlvorstandsaktualisierungDTO;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import de.muenchen.oss.wahllokalsystem.eaiservice.service.wahlvorstand.WahlvorstandService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wahlvorstaende")
@RequiredArgsConstructor
public class WahlvorstandController {

private final WahlvorstandService wahlvorstandService;

@GetMapping
@ResponseStatus(HttpStatus.OK)
public WahlvorstandDTO loadWahlvorstand(@RequestParam("wahlbezirkID") String wahlbezirkID) {
throw new UnsupportedOperationException("Not supported yet.");
@Operation(description = "Abrufen des Wahlvorstandes für einen bestimmten Wahlbezirk")
public WahlvorstandDTO loadWahlvorstand(final @RequestParam("wahlbezirkID")
String wahlbezirkID) {
return wahlvorstandService.getWahlvorstandForWahlbezirk(wahlbezirkID);
}

@PostMapping
@ResponseStatus(HttpStatus.OK)
public void saveAnwesenheit(@Valid @RequestBody WahlvorstandsaktualisierungDTO wahlvorstand) {
throw new UnsupportedOperationException("Not supported yet.");
@PutMapping("anwesenheit")
@Operation(description = "Aktualisieren der Anwesenheit der Wahlvorstandsmitglieder eines bestimmten Wahlbezirkes")
public void saveAnwesenheit(@RequestBody WahlvorstandsaktualisierungDTO wahlvorstand) {
wahlvorstandService.setAnwesenheit(wahlvorstand);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Set;

public record WahlvorstandDTO(@NotNull LocalDateTime anwesenheitBeginn,
@NotNull String wahlbezirkID,
public record WahlvorstandDTO(@NotNull String wahlbezirkID,
@NotNull @Size(min = 1) Set<WahlvorstandsmitgliedDTO> mitglieder) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Set;
import lombok.Builder;

@Builder
public record WahlvorstandsaktualisierungDTO(@NotNull String wahlbezirkID,
@NotNull @Size(min = 1) Set<WahlvorstandsmitgliedAktualisierungDTO> mitglieder,
@NotNull LocalDateTime anwesenheitBeginn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;

@Builder
public record WahlvorstandsmitgliedAktualisierungDTO(@NotNull String identifikator,
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) boolean anwesend) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;

@Builder
public record WahlvorstandsmitgliedDTO(@NotNull String identifikator,
@NotNull String vorname,
@NotNull String nachname,
@NotNull String funktion,
@NotNull WahlvorstandsmitgliedsFunktionDTO funktion,
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) boolean anwesend) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.muenchen.oss.wahllokalsystem.eaiservice.rest.wahlvorstand.dto;

public enum WahlvorstandsmitgliedsFunktionDTO {
W, //Wahlvorsteher*in
SB, //Schriftführer*in
SWB, //Stellvertretung Wahlvorsteher*in
SSB, //Stellvertretung Schriftführer*in
B //Beisitzer*in
}
Loading

0 comments on commit 6dfb8da

Please sign in to comment.