diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/CandidateMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/CandidateMapper.java new file mode 100644 index 0000000..8479f4f --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/CandidateMapper.java @@ -0,0 +1,26 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.db.Candidate; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface CandidateMapper { + + de.twomartens.wahlrecht.model.dto.v1.Candidate mapToExternal(Candidate candidate); + + de.twomartens.wahlrecht.model.internal.Candidate mapToInternal( + de.twomartens.wahlrecht.model.dto.v1.Candidate candidate); + + de.twomartens.wahlrecht.model.internal.Candidate mapToInternal(Candidate candidate); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "created", ignore = true) + @Mapping(target = "lastModified", ignore = true) + Candidate mapToDB(de.twomartens.wahlrecht.model.dto.v1.Candidate candidate); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ConstituencyMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ConstituencyMapper.java new file mode 100644 index 0000000..e1b6c52 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ConstituencyMapper.java @@ -0,0 +1,26 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.db.Constituency; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ConstituencyMapper { + + de.twomartens.wahlrecht.model.dto.v1.Constituency mapToExternal(Constituency constituency); + + de.twomartens.wahlrecht.model.internal.Constituency mapToInternal( + de.twomartens.wahlrecht.model.dto.v1.Constituency constituency); + + de.twomartens.wahlrecht.model.internal.Constituency mapToInternal(Constituency constituency); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "created", ignore = true) + @Mapping(target = "lastModified", ignore = true) + Constituency mapToDB(de.twomartens.wahlrecht.model.dto.v1.Constituency constituency); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedCandidateMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedCandidateMapper.java new file mode 100644 index 0000000..e46b18a --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedCandidateMapper.java @@ -0,0 +1,17 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.internal.ElectedCandidate; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ElectedCandidateMapper { + + de.twomartens.wahlrecht.model.dto.v1.ElectedCandidate mapToExternal(ElectedCandidate candidate); + + ElectedCandidate mapToInternal(de.twomartens.wahlrecht.model.dto.v1.ElectedCandidate candidate); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedMapper.java new file mode 100644 index 0000000..3e7fc75 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedMapper.java @@ -0,0 +1,17 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.internal.Elected; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ElectedMapper { + + de.twomartens.wahlrecht.model.dto.v1.Elected mapToExternal(Elected elected); + + Elected mapToInternal(de.twomartens.wahlrecht.model.dto.v1.Elected elected); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedResultMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedResultMapper.java new file mode 100644 index 0000000..91ae57a --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectedResultMapper.java @@ -0,0 +1,35 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.dto.v1.ElectedCandidate; +import de.twomartens.wahlrecht.model.dto.v1.VotingResult; +import de.twomartens.wahlrecht.model.internal.ElectedResult; +import java.util.Collection; +import java.util.Map; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ElectedResultMapper { + + de.twomartens.wahlrecht.model.dto.v1.ElectedResult mapToExternal(ElectedResult result); + + Map> mapToExternal( + Map> value); + + Collection mapToExternal( + Collection value); + + ElectedResult mapToInternal(de.twomartens.wahlrecht.model.dto.v1.ElectedResult result); + + Map> mapToInternal( + Map> value); + + Collection mapToInternal( + Collection value); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectionMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectionMapper.java new file mode 100644 index 0000000..d7d4299 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/ElectionMapper.java @@ -0,0 +1,26 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.db.Election; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ElectionMapper { + + de.twomartens.wahlrecht.model.dto.v1.Election mapToExternal(Election election); + + de.twomartens.wahlrecht.model.internal.Election mapToInternal( + de.twomartens.wahlrecht.model.dto.v1.Election election); + + de.twomartens.wahlrecht.model.internal.Election mapToInternal(Election election); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "created", ignore = true) + @Mapping(target = "lastModified", ignore = true) + Election mapToDB(de.twomartens.wahlrecht.model.dto.v1.Election election); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/NominationMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/NominationMapper.java new file mode 100644 index 0000000..f8a168a --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/NominationMapper.java @@ -0,0 +1,30 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.db.Nomination; +import de.twomartens.wahlrecht.model.internal.Candidate; +import java.util.Collection; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface NominationMapper { + + de.twomartens.wahlrecht.model.dto.v1.Nomination mapToExternal(Nomination nomination); + + de.twomartens.wahlrecht.model.internal.Nomination mapToInternal( + de.twomartens.wahlrecht.model.dto.v1.Nomination nomination); + + de.twomartens.wahlrecht.model.internal.Nomination mapToInternal(Nomination nomination); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "created", ignore = true) + @Mapping(target = "lastModified", ignore = true) + Nomination mapToDB(de.twomartens.wahlrecht.model.dto.v1.Nomination nomination); + + Collection map(Collection candidates); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/PartyInElectionMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/PartyInElectionMapper.java new file mode 100644 index 0000000..33245b1 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/PartyInElectionMapper.java @@ -0,0 +1,21 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.db.PartyInElection; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface PartyInElectionMapper { + + de.twomartens.wahlrecht.model.dto.v1.PartyInElection mapToExternal(PartyInElection election); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "created", ignore = true) + @Mapping(target = "lastModified", ignore = true) + PartyInElection mapToDB(de.twomartens.wahlrecht.model.dto.v1.PartyInElection election); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/SeatResultMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/SeatResultMapper.java new file mode 100644 index 0000000..4cc6c7b --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/SeatResultMapper.java @@ -0,0 +1,19 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.internal.SeatResult; +import java.util.Deque; +import java.util.LinkedList; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface SeatResultMapper { + + de.twomartens.wahlrecht.model.dto.v1.SeatResult mapToExternal(SeatResult result); + + SeatResult mapToInternal(de.twomartens.wahlrecht.model.dto.v1.SeatResult result); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingResultMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingResultMapper.java new file mode 100644 index 0000000..e6c70a4 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingResultMapper.java @@ -0,0 +1,17 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.internal.VotingResult; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface VotingResultMapper { + + de.twomartens.wahlrecht.model.dto.v1.VotingResult mapToExternal(VotingResult result); + + VotingResult mapToInternal(de.twomartens.wahlrecht.model.dto.v1.VotingResult result); +} diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingThresholdMapper.java b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingThresholdMapper.java new file mode 100644 index 0000000..8975098 --- /dev/null +++ b/module-server/src/main/java/de/twomartens/wahlrecht/mapper/v1/VotingThresholdMapper.java @@ -0,0 +1,17 @@ +package de.twomartens.wahlrecht.mapper.v1; + +import de.twomartens.wahlrecht.model.internal.VotingThreshold; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, + unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface VotingThresholdMapper { + + de.twomartens.wahlrecht.model.dto.v1.VotingThreshold mapToExternal(VotingThreshold threshold); + + VotingThreshold mapToInternal(de.twomartens.wahlrecht.model.dto.v1.VotingThreshold threshold); +}