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 pull request #399 from it-at-m/145-implementierung-von-wahlbezi…
…rke-laden 145 implementierung von wahlbezirke laden
- Loading branch information
Showing
40 changed files
with
1,743 additions
and
29 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
stack/keycloak/migration/add-authorities-basisdaten-wahlbezirke.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,55 @@ | ||
id: add authorities basisdaten wahlbezirke | ||
author: Nic12345678 | ||
realm: ${SSO_REALM} | ||
changes: | ||
- addRole: | ||
name: Basisdaten_BUSINESSACTION_GetWahlbezirke | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_BUSINESSACTION_GetWahlbezirke | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Basisdaten_READ_Wahltag | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_READ_Wahltag | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Basisdaten_READ_Wahl | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_READ_Wahl | ||
clientId: ${SSO_CLIENT_ID} | ||
|
||
- addRole: | ||
name: Basisdaten_READ_Wahlbezirk | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_READ_Wahlbezirk | ||
clientId: ${SSO_CLIENT_ID} | ||
- addRole: | ||
name: Basisdaten_WRITE_Wahlbezirk | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_WRITE_Wahlbezirk | ||
clientId: ${SSO_CLIENT_ID} | ||
- addRole: | ||
name: Basisdaten_DELETE_Wahlbezirk | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_DELETE_Wahlbezirk | ||
clientId: ${SSO_CLIENT_ID} |
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
42 changes: 42 additions & 0 deletions
42
...java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlbezirkeClientImpl.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,42 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahldatenControllerApi; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlbezirkDTO; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlbezirke.WahlbezirkModel; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlbezirke.WahlbezirkeClient; | ||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; | ||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; | ||
import java.time.LocalDate; | ||
import java.util.Set; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Profile(Profiles.NOT + Profiles.DUMMY_CLIENTS) | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WahlbezirkeClientImpl implements WahlbezirkeClient { | ||
|
||
private final ExceptionFactory exceptionFactory; | ||
private final WahldatenControllerApi wahldatenControllerApi; | ||
private final WahlbezirkeClientMapper wahlbezirkeClientMapper; | ||
|
||
@Override | ||
public Set<WahlbezirkModel> loadWahlbezirke(LocalDate forDate, String wahltagNummer) throws WlsException { | ||
final Set<WahlbezirkDTO> wahlbezirkDTOS; | ||
try { | ||
wahlbezirkDTOS = wahldatenControllerApi.loadWahlbezirke(forDate, wahltagNummer); | ||
} catch (final Exception exception) { | ||
log.info("exception on loadWahlbezirke from external", exception); | ||
throw exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI); | ||
} | ||
if (wahlbezirkDTOS == null) { | ||
throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT); | ||
} | ||
return wahlbezirkeClientMapper.fromRemoteSetOfDTOsToSetOfModels(wahlbezirkDTOS); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...va/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlbezirkeClientMapper.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.basisdatenservice.clients; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlbezirkDTO; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlbezirke.WahlbezirkModel; | ||
import java.util.Set; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper | ||
public interface WahlbezirkeClientMapper { | ||
|
||
@Mapping(source = "identifikator", target = "wahlbezirkID") | ||
@Mapping(source = "wahlbezirkArt", target = "wahlbezirkart") | ||
WahlbezirkModel fromClientDTOToModel(WahlbezirkDTO clientDTO); | ||
|
||
Set<WahlbezirkModel> fromRemoteSetOfDTOsToSetOfModels(Set<WahlbezirkDTO> wahlbezirkDTOs); | ||
|
||
} |
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
49 changes: 49 additions & 0 deletions
49
...ce/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahlbezirk.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,49 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
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 | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Wahlbezirk { | ||
|
||
@Id | ||
@NotNull | ||
@Size(max = 1024) | ||
private String wahlbezirkID; | ||
|
||
@NotNull | ||
private LocalDate wahltag; | ||
|
||
@NotNull | ||
@Size(max = 255) | ||
private String nummer; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@NotNull | ||
private WahlbezirkArt wahlbezirkart; | ||
|
||
@NotNull | ||
@Size(max = 255) | ||
private String wahlnummer; | ||
|
||
@NotNull | ||
@Size(max = 255) | ||
private String wahlID; | ||
} |
61 changes: 61 additions & 0 deletions
61
...n/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahlbezirkRepository.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,61 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
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; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@PreAuthorize("hasAuthority('Basisdaten_READ_Wahlbezirk')") | ||
@Transactional | ||
public interface WahlbezirkRepository extends CrudRepository<Wahlbezirk, String> { | ||
|
||
String CACHE = "WAHLBEZIRK_CACHE"; | ||
|
||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahlbezirk')") | ||
void deleteByWahltag(LocalDate wahltag); | ||
|
||
int countByWahltag(LocalDate wahltag); | ||
|
||
List<Wahlbezirk> findByWahltag(LocalDate wahltag); | ||
|
||
@Override | ||
List<Wahlbezirk> findAll(); | ||
|
||
@Override | ||
@Cacheable(value = CACHE, key = "#p0") | ||
Optional<Wahlbezirk> findById(String wahlbezirkID); | ||
|
||
@Override | ||
@CachePut(value = CACHE, key = "#p0.wahlbezirkID") | ||
@PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahlbezirk')") | ||
<S extends Wahlbezirk> S save(S entity); | ||
|
||
@Override | ||
@PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahlbezirk')") | ||
<S extends Wahlbezirk> Iterable<S> saveAll(Iterable<S> entities); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0") | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahlbezirk')") | ||
void deleteById(String wahlbezirkID); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0.wahlbezirkID") | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahlbezirk')") | ||
void delete(Wahlbezirk entity); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahlbezirk')") | ||
void deleteAll(Iterable<? extends Wahlbezirk> entities); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahlbezirk')") | ||
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
14 changes: 14 additions & 0 deletions
14
...ava/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahlbezirke/WahlbezirkDTO.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,14 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahlbezirke; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record WahlbezirkDTO(@NotNull String wahlbezirkID, | ||
@NotNull LocalDate wahltag, | ||
@NotNull String nummer, | ||
@NotNull WahlbezirkartDTO wahlbezirkart, | ||
@NotNull String wahlnummer, | ||
@NotNull String wahlID) { | ||
} |
10 changes: 10 additions & 0 deletions
10
.../muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahlbezirke/WahlbezirkDTOMapper.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,10 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahlbezirke; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlbezirke.WahlbezirkModel; | ||
import java.util.List; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper | ||
public interface WahlbezirkDTOMapper { | ||
List<WahlbezirkDTO> fromListOfWahlbezirkModelToListOfWahlbezirkDTO(List<WahlbezirkModel> wahlbezirkModelList); | ||
} |
5 changes: 5 additions & 0 deletions
5
.../de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahlbezirke/WahlbezirkartDTO.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,5 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahlbezirke; | ||
|
||
public enum WahlbezirkartDTO { | ||
UWB, BWB | ||
} |
27 changes: 27 additions & 0 deletions
27
...uenchen/oss/wahllokalsystem/basisdatenservice/rest/wahlbezirke/WahlbezirkeController.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,27 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahlbezirke; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlbezirke.WahlbezirkeService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
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/wahlbezirke") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WahlbezirkeController { | ||
|
||
private final WahlbezirkeService wahlbezirkeService; | ||
private final WahlbezirkDTOMapper wahlbezirkDTOMapper; | ||
|
||
@Operation(description = "Laden der Liste der Wahlbezirke, die einem vorgegebenen Wahltag (Parameter wahltagID) entsprechen.") | ||
@GetMapping("/{wahltagID}") | ||
public List<WahlbezirkDTO> getWahlbezirke(@PathVariable("wahltagID") final String wahltagID) { | ||
return wahlbezirkDTOMapper.fromListOfWahlbezirkModelToListOfWahlbezirkDTO(wahlbezirkeService.getWahlbezirke(wahltagID)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...de/muenchen/oss/wahllokalsystem/basisdatenservice/services/kopfdaten/BasisdatenModel.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
Oops, something went wrong.