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 #359 from it-at-m/140-wahltag-kann-abgerufen-werden
140 wahltag kann abgerufen werden
- Loading branch information
Showing
34 changed files
with
1,238 additions
and
8 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
stack/keycloak/migration/add-authorities-basisdaten-wahltage.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,37 @@ | ||
id: add authorities basisdaten wahltage | ||
author: Nic12345678 | ||
realm: ${SSO_REALM} | ||
changes: | ||
- addRole: | ||
name: Basisdaten_BUSINESSACTION_GetWahltage | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_BUSINESSACTION_GetWahltage | ||
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_WRITE_Wahltag | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_WRITE_Wahltag | ||
clientId: ${SSO_CLIENT_ID} | ||
- addRole: | ||
name: Basisdaten_DELETE_Wahltag | ||
clientRole: true | ||
clientId: ${SSO_CLIENT_ID} | ||
- assignRoleToGroup: | ||
group: allBasisdatenAuthorities | ||
role: Basisdaten_DELETE_Wahltag | ||
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
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
45 changes: 45 additions & 0 deletions
45
...in/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.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.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.WahltagDTO; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageClient; | ||
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.List; | ||
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 WahltageClientImpl implements WahltageClient { | ||
|
||
private final ExceptionFactory exceptionFactory; | ||
|
||
private final WahldatenControllerApi wahldatenControllerApi; | ||
private final WahltageClientMapper wahltageClientMapper; | ||
|
||
@Override | ||
public List<WahltagModel> getWahltage(LocalDate tag) throws WlsException { | ||
|
||
final Set<WahltagDTO> wahltageDTO; | ||
try { | ||
wahltageDTO = wahldatenControllerApi.loadWahltageSinceIncluding(tag); | ||
} catch (final Exception exception) { | ||
log.info("exception on loadwahltage from external", exception); | ||
throw exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI); | ||
} | ||
if (wahltageDTO == null) { | ||
throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT); | ||
} | ||
return wahltageClientMapper.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(wahltageDTO); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.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.WahltagDTO; | ||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper | ||
public interface WahltageClientMapper { | ||
|
||
@Mapping(target = "wahltagID", source = "identifikator") | ||
@Mapping(target = "wahltag", source = "tag") | ||
WahltagModel toWahltagModel(WahltagDTO wahltagDTO); | ||
|
||
List<WahltagModel> fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(Set<WahltagDTO> wahltageDTO); | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...rvice/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.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,47 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import java.time.LocalDate; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.springframework.stereotype.Indexed; | ||
|
||
@Entity | ||
@Indexed | ||
@Data | ||
@EqualsAndHashCode | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "Wahltag") | ||
public class Wahltag { | ||
|
||
@Id | ||
@NotNull | ||
@Size(max = 1024) | ||
@ToString.Include | ||
private String wahltagID; | ||
|
||
@NotNull | ||
@ToString.Include | ||
private LocalDate wahltag; | ||
|
||
@Size(max = 1024) | ||
@ToString.Include | ||
private String beschreibung; | ||
|
||
@Size(max = 1024) | ||
@ToString.Include | ||
private String nummer; | ||
} |
55 changes: 55 additions & 0 deletions
55
...main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.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,55 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; | ||
|
||
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_Wahltag')") | ||
@Transactional | ||
public interface WahltagRepository extends CrudRepository<Wahltag, String> { | ||
|
||
String CACHE = "WAHLTAG_CACHE"; | ||
|
||
@Override | ||
List<Wahltag> findAll(); | ||
|
||
@Override | ||
@Cacheable(value = CACHE, key = "#p0") | ||
Optional<Wahltag> findById(String wahltagID); | ||
|
||
@Override | ||
@CachePut(value = CACHE, key = "#p0.wahltagID") | ||
@PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") | ||
<S extends Wahltag> S save(S entity); | ||
|
||
@Override | ||
@PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") | ||
<S extends Wahltag> Iterable<S> saveAll(Iterable<S> entities); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0") | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") | ||
void deleteById(String wahltagID); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, key = "#p0.wahltagID") | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") | ||
void delete(Wahltag entity); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") | ||
void deleteAll(Iterable<? extends Wahltag> entities); | ||
|
||
@Override | ||
@CacheEvict(value = CACHE, allEntries = true) | ||
@PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") | ||
void deleteAll(); | ||
|
||
List<Wahltag> findAllByOrderByWahltagAsc(); | ||
} |
12 changes: 12 additions & 0 deletions
12
...main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.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,12 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record WahltagDTO(@NotNull String wahltagID, | ||
@NotNull LocalDate wahltag, | ||
String beschreibung, | ||
String nummer) { | ||
} |
26 changes: 26 additions & 0 deletions
26
...a/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.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,26 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/businessActions/wahltage") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WahltageController { | ||
|
||
private final WahltageService wahltageService; | ||
private final WahltageDTOMapper wahltageDTOMapper; | ||
|
||
@Operation(description = "Laden der Liste der Wahltage, aufsteigend sortiert nach Wahltag-Datum und nicht länger als 3 Monate in der Vergangenheit.") | ||
@GetMapping | ||
public List<WahltagDTO> getWahltage() { | ||
return wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...va/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapper.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.wahltage; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; | ||
import java.util.List; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper | ||
public interface WahltageDTOMapper { | ||
List<WahltagDTO> fromListOfWahltagModelToListOfWahltagDTO(List<WahltagModel> wahltage); | ||
} |
14 changes: 14 additions & 0 deletions
14
...java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.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.services.wahltag; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record WahltagModel(@NotNull String wahltagID, | ||
@NotNull LocalDate wahltag, | ||
String beschreibung, | ||
String nummer | ||
) { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...e/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.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,13 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; | ||
|
||
import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; | ||
import java.util.List; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper | ||
public interface WahltagModelMapper { | ||
|
||
List<WahltagModel> fromWahltagEntityToWahltagModelList(List<Wahltag> entities); | ||
|
||
List<Wahltag> fromWahltagModelToWahltagEntityList(List<WahltagModel> entities); | ||
} |
20 changes: 20 additions & 0 deletions
20
...va/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.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,20 @@ | ||
package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public interface WahltageClient { | ||
|
||
/** | ||
* @param tag The Request Tag - Reference for requested Wahltage | ||
* @return List<WahltagModel> | ||
* @throws WlsException | ||
* {@link de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException} if | ||
* return would be null | ||
* {@link de.muenchen.oss.wahllokalsystem.wls.common.exception.TechnischeWlsException} | ||
* if there were trouble during communication | ||
*/ | ||
List<WahltagModel> getWahltage(final LocalDate tag) throws WlsException; | ||
|
||
} |
Oops, something went wrong.