added support of controling the behavoir of the program from the cli

Start application with:
-Dmotto for mottoVoting
-Dadding for addingPhase
-Dvoting for votingPhase
This commit is contained in:
2020-12-11 10:57:58 +01:00
parent 512331d3ab
commit efc2bd7501

View File

@@ -6,6 +6,7 @@ import com.github.cato447.AbizeitungVotingSystem.helper.RandomNumber;
import com.github.cato447.AbizeitungVotingSystem.repositories.*; import com.github.cato447.AbizeitungVotingSystem.repositories.*;
import com.github.cato447.AbizeitungVotingSystem.table.TableAction; import com.github.cato447.AbizeitungVotingSystem.table.TableAction;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@@ -23,9 +24,17 @@ import java.util.*;
@Controller @Controller
public class VotingController { public class VotingController {
private boolean votingPhase;
private boolean mottoPhase; @Value("motto")
private boolean addingPhase; 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();
@@ -54,24 +63,14 @@ public class VotingController {
@PostConstruct @PostConstruct
public void init() { public void init() {
try { if (motto != null){
String votingPhaseConfig = System.getProperty("votingPhase"); mottoPhase = true;
if (votingPhaseConfig.equalsIgnoreCase("true")) { } else if (adding != null){
addingPhase = true;
} else if (voting != null){
votingPhase = true; votingPhase = true;
} }
String mottoPhaseConfig = System.getProperty("mottoPhase");
if (mottoPhaseConfig.equalsIgnoreCase("true")) {
mottoPhase = true;
}
String addingPhaseConfig = System.getProperty("addingPhase");
if (addingPhaseConfig.equalsIgnoreCase("true")){
addingPhase = true;
}
} catch (Exception e){
}
// //TODO: TESTING REMOVE ON SHIPPING // //TODO: TESTING REMOVE ON SHIPPING
// votingPhase = false; // votingPhase = false;