Skip to content

Commit

Permalink
Merge pull request #326 from it-at-m/144-implementierung-von-wahlvors…
Browse files Browse the repository at this point in the history
…chläge-laden

144 implementierung von wahlvorschläge laden
  • Loading branch information
MrSebastian authored Jul 4, 2024
2 parents f402011 + b9c071d commit d3d8ee0
Show file tree
Hide file tree
Showing 47 changed files with 2,029 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
id: add authorities basisdaten wahlvorschlaege
author: MrSebastian
realm: ${SSO_REALM}
changes:
- addRole:
name: Basisdaten_BUSINESSACTION_GetWahlvorschlaege
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_BUSINESSACTION_GetWahlvorschlaege
clientId: ${SSO_CLIENT_ID}

- addRole:
name: Basisdaten_READ_WLSWahlvorschlaege
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_READ_WLSWahlvorschlaege
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_WRITE_WLSWahlvorschlaege
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_WRITE_WLSWahlvorschlaege
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_DELETE_WLSWahlvorschlaege
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_DELETE_WLSWahlvorschlaege
clientId: ${SSO_CLIENT_ID}

- addRole:
name: Basisdaten_READ_Wahlvorschlag
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_READ_Wahlvorschlag
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_WRITE_Wahlvorschlag
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_WRITE_Wahlvorschlag
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_DELETE_Wahlvorschlag
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_DELETE_Wahlvorschlag
clientId: ${SSO_CLIENT_ID}

- addRole:
name: Basisdaten_READ_Kandidat
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_READ_Kandidat
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_WRITE_Kandidat
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_WRITE_Kandidat
clientId: ${SSO_CLIENT_ID}
- addRole:
name: Basisdaten_DELETE_Kandidat
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allBasisdatenAuthorities
role: Basisdaten_DELETE_Kandidat
clientId: ${SSO_CLIENT_ID}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
id: create group allBasisdatenAuthorities and link wls_all*
author: MrSebastian
realm: ${SSO_REALM}
changes:
- addGroup:
name: allBasisdatenAuthorities
- assignGroup:
user: wls_all
group: allBasisdatenAuthorities
- assignGroup:
user: wls_all_uwb
group: allBasisdatenAuthorities
- assignGroup:
user: wls_all_bwb
group: allBasisdatenAuthorities
4 changes: 3 additions & 1 deletion stack/keycloak/migration/keycloak-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ includes:
- path: add-authorities-wahlvorbereitung-urnenwahlschliessungsuhrzeit.yml
- path: create-group-all-eai-authorities.yml
- path: add-authorities-eai-wahlvorstand.yml
- path: add-authorities-wahlvorbereitung-briefwahlvorbereitung.yml
- path: add-authorities-wahlvorbereitung-briefwahlvorbereitung.yml
- path: create-group-all-basisdaten-authorities.yml
- path: add-authorities-basisdaten-wahlvorschlaege.yml
33 changes: 33 additions & 0 deletions wls-basisdaten-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<!-- Version muss mit der in den spring-boot-dependencies bereitgestellten Lombok-Version übereinstimmen -->
<org.projectlombok.lombok.version>1.18.30</org.projectlombok.lombok.version>
<org.projectlombok.mapstructbinding.version>0.2.0</org.projectlombok.mapstructbinding.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<org.springdoc.version>2.6.0</org.springdoc.version>
<wls.common.version>1.1.0</wls.common.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -178,6 +180,13 @@
<version>0.2.6</version>
</dependency>

<!-- wls-common -->
<dependency>
<groupId>de.muenchen.oss.wahllokalsystem.wls-common</groupId>
<artifactId>security</artifactId>
<version>${wls.common.version}</version>
</dependency>

<!-- Validation -->
<dependency>
<groupId>jakarta.validation</groupId>
Expand All @@ -199,6 +208,11 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -209,6 +223,12 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.muenchen.oss.wahllokalsystem.wls-common</groupId>
<artifactId>testing</artifactId>
<version>${wls.common.version}</version>
<scope>test</scope>
</dependency>

<!-- Logging -->
<dependency>
Expand Down Expand Up @@ -328,12 +348,25 @@
<artifactId>lombok</artifactId>
<version>${org.projectlombok.lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${org.projectlombok.mapstructbinding.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=spring
</compilerArg>
<compilerArg>
-Amapstruct.unmappedTargetPolicy=ERROR
</compilerArg>
</compilerArgs>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
@ComponentScan(
basePackages = {
"org.springframework.data.jpa.convert.threeten",
"de.muenchen.oss.wahllokalsystem.basisdatenservice"
"de.muenchen.oss.wahllokalsystem.basisdatenservice",
"de.muenchen.oss.wahllokalsystem.wls.common.exception",
"de.muenchen.oss.wahllokalsystem.wls.common.security"
}
)
@EntityScan(
Expand Down
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.WahlvorschlagControllerApi;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlaegeDTO;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeClient;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeModel;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory;
import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID;
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 ClientImpl implements WahlvorschlaegeClient {

private final ExceptionFactory exceptionFactory;

private final WahlvorschlagControllerApi wahlvorschlagControllerApi;
private final WahlvorschlaegeClientMapper wahlvorschlaegeClientMapper;

@Override
public WahlvorschlaegeModel getWahlvorschlaege(final BezirkUndWahlID bezirkUndWahlID) {
final WahlvorschlaegeDTO wahlvorschlaege;
try {
wahlvorschlaege = wahlvorschlagControllerApi.loadWahlvorschlaege(bezirkUndWahlID.getWahlID(), bezirkUndWahlID.getWahlbezirkID());
} catch (final Exception exception) {
log.info("exception on loadwahlvorschlaege from external", exception);
throw exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI);
}
if (wahlvorschlaege == null) {
throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT);
}

return wahlvorschlaegeClientMapper.toModel(wahlvorschlaege);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients;

import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.KandidatModel;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeClient;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeModel;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlagModel;
import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID;
import java.util.Set;
import java.util.UUID;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

@Component
@Profile(Profiles.DUMMY_CLIENTS)
public class DummyClientImpl implements WahlvorschlaegeClient {

@Override
public WahlvorschlaegeModel getWahlvorschlaege(BezirkUndWahlID bezirkUndWahlID) {
return new WahlvorschlaegeModel(bezirkUndWahlID, "stimmzettelgebiedID",
Set.of(new WahlvorschlagModel(UUID.randomUUID().toString(), 1L, "kurzname1", true,
Set.of(new KandidatModel(UUID.randomUUID().toString(), "kandidat11", 1L, true, 1L, true),
new KandidatModel(UUID.randomUUID().toString(), "kandidat21", 2L, false, 1L, false))),
new WahlvorschlagModel(UUID.randomUUID().toString(), 2L, "kurzname2", true,
Set.of(new KandidatModel(UUID.randomUUID().toString(), "kandidat21", 1L, true, 1L, true),
new KandidatModel(UUID.randomUUID().toString(), "kandidat22", 2L, false, 1L, false)))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients;

import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlaegeDTO;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeModel;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper
public interface WahlvorschlaegeClientMapper {

@Mapping(target = "bezirkUndWahlID.wahlID", source = "wahlID")
@Mapping(target = "bezirkUndWahlID.wahlbezirkID", source = "wahlbezirkID")
WahlvorschlaegeModel toModel(WahlvorschlaegeDTO wahlvorschlaegeDTO);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Profiles {

public static final String NOT = "!";

public static final String DUMMY_CLIENTS = "dummy.clients";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain;

import static java.sql.Types.VARCHAR;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
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;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.UuidGenerator;

@Entity
@Getter
@Setter
@ToString(onlyExplicitlyIncluded = true)
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class Kandidat {

@Id
@GeneratedValue(generator = "uuid")
@UuidGenerator
@JdbcTypeCode(VARCHAR)
private UUID id;

@NaturalId
@NotNull
@ToString.Include
private String identifikator;

@ManyToOne
@NotNull
@JoinColumn(name = "wahlvorschlagID")
@EqualsAndHashCode.Exclude
private Wahlvorschlag wahlvorschlag;

@NotNull
@ToString.Include
private String name;

@NotNull
@ToString.Include
private long listenposition;

@NotNull
@ToString.Include
private boolean direktkandidat;

@NotNull
@ToString.Include
private long tabellenSpalteInNiederschrift;

@NotNull
@ToString.Include
private boolean einzelbewerber;
}
Loading

0 comments on commit d3d8ee0

Please sign in to comment.