generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/dev' into renovate/spring-boot
- Loading branch information
Showing
44 changed files
with
1,102 additions
and
12 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
stack/keycloak/migration/add-authorities-wahlvorbereitung-urnenwahlvorbereitung.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
id: add authorities wahlvorbereitung urnenwahlvorbereitung | ||
author: MrSebastian | ||
realm: ${SSO_REALM} | ||
changes: | ||
- addRole: | ||
name: Wahlvorbereitung_BUSINESSACTION_GetUrnenwahlVorbereitung | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allWahlvorbereitungAuthorities | ||
role: Wahlvorbereitung_BUSINESSACTION_GetUrnenwahlVorbereitung | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Wahlvorbereitung_BUSINESSACTION_PostUrnenwahlVorbereitung | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allWahlvorbereitungAuthorities | ||
role: Wahlvorbereitung_BUSINESSACTION_PostUrnenwahlVorbereitung | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Wahlvorbereitung_WRITE_UrnenwahlVorbereitung | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allWahlvorbereitungAuthorities | ||
role: Wahlvorbereitung_WRITE_UrnenwahlVorbereitung | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Wahlvorbereitung_DELETE_UrnenwahlVorbereitung | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allWahlvorbereitungAuthorities | ||
role: Wahlvorbereitung_DELETE_UrnenwahlVorbereitung | ||
clientId: ${SSO_CLIENT_ID} |
9 changes: 9 additions & 0 deletions
9
stack/keycloak/migration/create-and-assign-group-all-wahlvorbereitung.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
id: create group allWahlvorbereitungAuthorities | ||
author: MrSebastian | ||
realm: ${SSO_REALM} | ||
changes: | ||
- addGroup: | ||
name: allWahlvorbereitungAuthorities | ||
- assignGroup: | ||
user: wls_all | ||
group: allWahlvorbereitungAuthorities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/domain/UrnenwahlVorbereitung.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.domain; | ||
|
||
import jakarta.persistence.CollectionTable; | ||
import jakarta.persistence.ElementCollection; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class UrnenwahlVorbereitung { | ||
|
||
@Id | ||
@NotNull | ||
@Size(max = 255) | ||
private String wahlbezirkID; | ||
|
||
@ElementCollection(fetch = FetchType.EAGER) | ||
@CollectionTable(name = "UWVorbereitung_Urnen", joinColumns = @JoinColumn(name = "vorbereitung_wahlbezirkID")) | ||
@NotNull | ||
@Size(min = 1) | ||
@Builder.Default | ||
private java.util.List<Wahlurne> urnenAnzahl = new java.util.ArrayList<>(); | ||
|
||
private long anzahlWahlkabinen; | ||
|
||
private long anzahlWahltische; | ||
|
||
private long anzahlNebenraeume; | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...n/oss/wahllokalsystem/wahlvorbereitungservice/domain/UrnenwahlVorbereitungRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.domain; | ||
|
||
import java.util.Optional; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.cache.annotation.CachePut; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
|
||
public interface UrnenwahlVorbereitungRepository extends CrudRepository<UrnenwahlVorbereitung, String> { | ||
|
||
String CACHE = "UrnenwahlVorbereitungCACHE"; | ||
|
||
@Override | ||
Iterable<UrnenwahlVorbereitung> findAll(); | ||
|
||
@Override | ||
@Cacheable(value = CACHE, key = "#p0") | ||
Optional<UrnenwahlVorbereitung> findById(String wahlbezirkID); | ||
|
||
@Override | ||
@CachePut(value = CACHE, key = "#p0.wahlbezirkID") | ||
@PreAuthorize("hasAuthority('Wahlvorbereitung_WRITE_UrnenwahlVorbereitung')") | ||
<S extends UrnenwahlVorbereitung> S save(S urnenwahlVorbereitung); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0") | ||
@PreAuthorize("hasAuthority('Wahlvorbereitung_DELETE_UrnenwahlVorbereitung')") | ||
void deleteById(String wahlbezirkID); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0.wahlbezirkID") | ||
@PreAuthorize("hasAuthority('Wahlvorbereitung_DELETE_UrnenwahlVorbereitung')") | ||
void delete(UrnenwahlVorbereitung entity); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Wahlvorbereitung_DELETE_UrnenwahlVorbereitung')") | ||
void deleteAll(Iterable<? extends UrnenwahlVorbereitung> entities); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Wahlvorbereitung_DELETE_UrnenwahlVorbereitung')") | ||
void deleteAll(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/exception/ExceptionConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.exception; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ExceptionConstants { | ||
|
||
private static final String CODE_SUCHKRITERIEN_UNVOLLSTAENDIG = "901"; | ||
private static final String MSG_SUCHKRITERIEN_UNVOLLSTAENDIG = "Fehler beim Laden: Suchkriterien unvollständig."; | ||
|
||
public static ExceptionDataWrapper SUCHKRITERIEN_UNVOLLSTAENDIG = new ExceptionDataWrapper(CODE_SUCHKRITERIEN_UNVOLLSTAENDIG, | ||
MSG_SUCHKRITERIEN_UNVOLLSTAENDIG); | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
.../muenchen/oss/wahllokalsystem/wahlvorbereitungservice/exception/ExceptionDataWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.exception; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record ExceptionDataWrapper(@NotNull String code, @NotNull String message) { | ||
} |
18 changes: 18 additions & 0 deletions
18
...a/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/exception/ExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.exception; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException; | ||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ServiceIDFormatter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ExceptionFactory { | ||
|
||
private final ServiceIDFormatter serviceIDFormatter; | ||
|
||
public FachlicheWlsException createFachlicheWlsException(final ExceptionDataWrapper exceptionDataWrapper) { | ||
return FachlicheWlsException.withCode(exceptionDataWrapper.code()).inService(serviceIDFormatter.getId()) | ||
.buildWithMessage(exceptionDataWrapper.message()); | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
...java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/common/WahlurneDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.common; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record WahlurneDTO(String wahlID, long anzahl, Boolean urneVersiegelt) { | ||
public record WahlurneDTO(@NotNull @Size(max = 255) String wahlID, | ||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long anzahl, | ||
Boolean urneVersiegelt) { | ||
} |
34 changes: 34 additions & 0 deletions
34
...m/wahlvorbereitungservice/rest/urnenwahlvorbereitung/UrnenwahlvorbereitungController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.urnenwahlvorbereitung; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.service.urnenwahlvorbereitung.UrnenwahlvorbereitungService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import java.util.Optional; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.val; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/businessActions/urnenwahlVorbereitung") | ||
@RequiredArgsConstructor | ||
public class UrnenwahlvorbereitungController { | ||
|
||
private final UrnenwahlvorbereitungService service; | ||
|
||
private final UrnenwahlvorbereitungDTOMapper urnenwahlvorbereitungDTOMapper; | ||
|
||
@Operation(description = "Laden der Wahlvorbereitungsdaten des Urnenwahllokals {wahlbezirkID}") | ||
@GetMapping("{wahlbezirkID}") | ||
public ResponseEntity<UrnenwahlvorbereitungDTO> getUrnenwahlVorbereitung(@PathVariable("wahlbezirkID") final String wahlbezirkID) { | ||
val urnenwahlvorbereitungModel = service.getUrnenwahlvorbereitung(wahlbezirkID); | ||
|
||
return withBodyOrNoContent(urnenwahlvorbereitungModel.map(urnenwahlvorbereitungDTOMapper::toDTO)); | ||
} | ||
|
||
private <T> ResponseEntity<T> withBodyOrNoContent(final Optional<T> body) { | ||
return body.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.noContent().build()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...alsystem/wahlvorbereitungservice/rest/urnenwahlvorbereitung/UrnenwahlvorbereitungDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.urnenwahlvorbereitung; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.common.WahlurneDTO; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public record UrnenwahlvorbereitungDTO(@NotNull String wahlbezirkID, | ||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long anzahlWahlkabinen, | ||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long anzahlWahltische, | ||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long anzahlNebenraeume, | ||
@NotNull @Size(min = 1) List<WahlurneDTO> urnenAnzahl) { | ||
|
||
public UrnenwahlvorbereitungDTO(final String wahlbezirkID, final long anzahlWahlkabinen, final long anzahlWahltische, final long anzahlNebenraeume, | ||
final List<WahlurneDTO> urnenAnzahl) { | ||
this.wahlbezirkID = wahlbezirkID; | ||
this.anzahlWahlkabinen = anzahlWahlkabinen; | ||
this.anzahlWahltische = anzahlWahltische; | ||
this.anzahlNebenraeume = anzahlNebenraeume; | ||
this.urnenAnzahl = Objects.requireNonNullElseGet(urnenAnzahl, ArrayList::new); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...em/wahlvorbereitungservice/rest/urnenwahlvorbereitung/UrnenwahlvorbereitungDTOMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.urnenwahlvorbereitung; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.rest.common.WahlurneDTOMapper; | ||
import de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.service.urnenwahlvorbereitung.UrnenwahlvorbereitungModel; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper(uses = WahlurneDTOMapper.class) | ||
public interface UrnenwahlvorbereitungDTOMapper { | ||
|
||
UrnenwahlvorbereitungDTO toDTO(UrnenwahlvorbereitungModel model); | ||
} |
21 changes: 21 additions & 0 deletions
21
...tem/wahlvorbereitungservice/service/urnenwahlvorbereitung/UrnenwahlvorbereitungModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.service.urnenwahlvorbereitung; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wahlvorbereitungservice.service.common.WahlurneModel; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record UrnenwahlvorbereitungModel(String wahlbezirkID, long anzahlWahlkabinen, long anzahlWahltische, long anzahlNebenraeume, | ||
List<WahlurneModel> urnenAnzahl) { | ||
|
||
public UrnenwahlvorbereitungModel(final String wahlbezirkID, final long anzahlWahlkabinen, final long anzahlWahltische, final long anzahlNebenraeume, | ||
final List<WahlurneModel> urnenAnzahl) { | ||
this.wahlbezirkID = wahlbezirkID; | ||
this.anzahlWahlkabinen = anzahlWahlkabinen; | ||
this.anzahlWahltische = anzahlWahltische; | ||
this.anzahlNebenraeume = anzahlNebenraeume; | ||
this.urnenAnzahl = Objects.requireNonNullElseGet(urnenAnzahl, ArrayList::new); | ||
} | ||
} |
Oops, something went wrong.