This commit is contained in:
2020-12-10 23:57:47 +01:00

View File

@@ -6,6 +6,7 @@ import com.github.cato447.AbizeitungVotingSystem.helper.RandomNumber;
import com.github.cato447.AbizeitungVotingSystem.repositories.*;
import com.github.cato447.AbizeitungVotingSystem.table.TableAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Controller;
@@ -23,9 +24,15 @@ import java.util.*;
@Controller
public class VotingController {
private boolean votingPhase;
private boolean mottoPhase;
private boolean addingPhase;
@Value("$(voting)")
private String voting;
@Value("$(motto)")
private String motto;
@Value("$(adding)")
private String adding;
private Boolean votingPhase = false, mottoPhase = false, addingPhase = false;
private static final Logger LOGGER = LogManager.getLogger(VotingController.class);
private TableAction tableAction = new TableAction();
@@ -54,31 +61,19 @@ public class VotingController {
@PostConstruct
public void init() {
try {
String votingPhaseConfig = System.getProperty("votingPhase");
if (votingPhaseConfig.equalsIgnoreCase("true")) {
if (voting != null) {
votingPhase = true;
}
String mottoVotingConfig = System.getProperty("mottoVoting");
if (mottoVotingConfig.equalsIgnoreCase("true")) {
} else if (adding != null) {
addingPhase = true;
} else if (motto != null) {
mottoPhase = true;
}
String addingPhaseConfig = System.getProperty("addingPhase");
if (addingPhaseConfig.equalsIgnoreCase("true")){
addingPhase = true;
}
} catch (Exception e){
}
// //TODO: TESTING REMOVE ON SHIPPING
// votingPhase = false;
// mottoPhase = true;
// addingPhase = false;
LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoVoting=" + mottoPhase + " addingPhase=" + addingPhase);
LOGGER.info("Program started with arguments: votingPhase=" + votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase);
if (voterRepository.findAll().size() == 0) {
tableAction.setUpVoters(voterRepository);