Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
2020-12-11 21:21:35 +01:00

View File

@@ -24,15 +24,17 @@ import java.util.*;
@Controller @Controller
public class VotingController { public class VotingController {
@Value("$(voting)")
private String voting;
@Value("$(motto)")
private String motto;
@Value("$(adding)")
private String adding;
private Boolean votingPhase = false, mottoPhase = false, addingPhase = false; @Value("motto")
String motto;
@Value("adding")
String adding;
@Value("voting")
String voting;
private boolean votingPhase = false;
private boolean mottoPhase = false;
private boolean addingPhase = false;
private static final Logger LOGGER = LogManager.getLogger(VotingController.class); private static final Logger LOGGER = LogManager.getLogger(VotingController.class);
private TableAction tableAction = new TableAction(); private TableAction tableAction = new TableAction();
@@ -61,40 +63,42 @@ public class VotingController {
@PostConstruct @PostConstruct
public void init() { public void init() {
if (voting != null) { if (motto != null){
votingPhase = true; mottoPhase = true;
} else if (adding != null) { } else if (adding != null){
addingPhase = true; addingPhase = true;
} else if (motto != null) { } else if (voting != null){
mottoPhase = true; votingPhase = true;
} }
// //TODO: TESTING REMOVE ON SHIPPING // //TODO: TESTING REMOVE ON SHIPPING
// votingPhase = false; // votingPhase = false;
// mottoPhase = true; // mottoPhase = true;
// addingPhase = false; // addingPhase = false;
LOGGER.info("Program started with arguments: votingPhase=" + votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase); LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase);
if (voterRepository.findAll().size() == 0) { if (voterRepository.findAll().size() == 0) {
tableAction.setUpVoters(voterRepository); tableAction.setUpVoters(voterRepository);
LOGGER.info("Voters successfully set up"); LOGGER.info("Voters successfully set up");
} }
if (categoryRepository.findAll().size() == 0) { if (categoryRepository.findAll().size() == 0) {
tableAction.setUpCategories(categoryRepository); tableAction.setUpCategories(categoryRepository);
LOGGER.info("Categories successfully set up"); LOGGER.info("Categories successfully set up");
} }
if (mottoRepository.findAll().size() == 0) { if (mottoRepository.findAll().size() == 0){
tableAction.setUpMottos(mottoRepository); tableAction.setUpMottos(mottoRepository);
LOGGER.info("Mottos successfully set up"); LOGGER.info("Mottos successfully set up");
} }
if (candidateRepository.findAll().size() == 0 && votingPhase == true && possibleCandidateRepository.findAll().size() != 0) { if (candidateRepository.findAll().size() == 0 && votingPhase == true && possibleCandidateRepository.findAll().size() != 0) {
tableAction.setUpCandidates(possibleCandidateRepository, candidateRepository); tableAction.setUpCandidates(possibleCandidateRepository, candidateRepository);
LOGGER.info("Candidates successfully set up"); LOGGER.info("Candidates successfully set up");
}
} }
}
@RequestMapping("/") @RequestMapping("/")
public String WelcomeSite() { public String WelcomeSite() {