Final release

This commit is contained in:
2021-01-09 21:56:17 +01:00
parent 69b320b28b
commit 3528c1d0d3

View File

@@ -193,23 +193,28 @@ public class VotingController {
long index = 1; long index = 1;
for (PossibleCandidate posCandidate : posCandidates) { for (PossibleCandidate posCandidate : posCandidates) {
if (posCandidate.getName() != "") { if (posCandidate.getName() != "") {
if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null) { if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()) != null ||
possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null) {
PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get());
p.setVotes(p.getVotes() + 1); p.setVotes(p.getVotes() + 1);
possibleCandidateRepository.save(p); possibleCandidateRepository.save(p);
} else { } else {
if (index > 31 && posCandidate.getName().indexOf(" ") != -1) { if (index > 31 && posCandidate.getName().indexOf(" ") != -1) {
if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Neumann" || if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Neumann") ||
posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "neumann" || posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("neumann") ||
posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "Mecklenburg" || posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Mecklenburg") ||
posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1] == "mecklenburg" ){ posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("mecklenburg")){
posCandidate.setName(posCandidate.getName()); PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get());
possibleCandidateRepository.save(possibleCandidate);
} else { } else {
posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]);
PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get());
possibleCandidateRepository.save(possibleCandidate);
} }
} else {
PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get());
possibleCandidateRepository.save(possibleCandidate);
} }
PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get());
possibleCandidateRepository.save(possibleCandidate);
} }
} }
index++; index++;