diff --git a/VotersBallot.png b/VotersBallot.png new file mode 100644 index 0000000..00ef817 Binary files /dev/null and b/VotersBallot.png differ diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/configuration/VotingBoothConfigurationCreator.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/configuration/VotingBoothConfigurationCreator.java index 405065f..44733f5 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/configuration/VotingBoothConfigurationCreator.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/configuration/VotingBoothConfigurationCreator.java @@ -5,6 +5,8 @@ import meerkat.protobuf.BallotQuestionUIElementOuterClass; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -23,6 +25,9 @@ import java.util.Scanner; * This class creates QuestionBallotUIElement from given configuration file */ public class VotingBoothConfigurationCreator { + + private final Logger logger = LoggerFactory.getLogger(VotingBoothConfigurationCreator.class); + private int CURRENT_NUMBER_OF_QUESTIONS_REPRESENTED_TO_VOTER = 2 ; public static String WRONG_QUESTIONS_AMOUNT_ERROR_MESSAGE = "The configuration file had too many ballot question objects."; public static String UNSUPPORTED_VALUE_TYPE_ERROR_MESSAGE = "The given question type doesnt supported in current version"; @@ -52,6 +57,7 @@ public class VotingBoothConfigurationCreator { } } + this.logger.debug("Created VotingBoothConfiguration object from given path: " + configPath); return config; } @@ -65,6 +71,7 @@ public class VotingBoothConfigurationCreator { private JSONArray getJsonFromPath(String path) throws FileNotFoundException, JSONException { String content = new Scanner(new File(path)).useDelimiter("\\Z").next(); JSONObject jsonObject = new JSONObject(content); + this.logger.debug("Created json object from from configuration path."); return (JSONArray)jsonObject.get("questions"); } @@ -106,6 +113,7 @@ public class VotingBoothConfigurationCreator { } uiAnswersBuilder.setAnswers(listOfAnswers); + this.logger.debug("Converted the json object into ballot question object.\n" + object); return BallotQuestionUIElementOuterClass.BallotQuestionUIElement.newBuilder() .setQuestion(uiQuestion) .setAnswers(uiAnswersBuilder.build()) diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java index 2a0f922..9911cee 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java @@ -1,6 +1,7 @@ package meerkat.voting.gui.managment; import javafx.stage.Stage; +import meerkat.voting.gui.configuration.VotingBoothConfiguration; import meerkat.voting.gui.panels.ballot_summary.BallotSummaryLoader; import meerkat.voting.gui.panels.cast_or_audit.CastOrAuditLoader; import meerkat.voting.gui.panels.select_candidate_by_picture.SelectCandidateByPictureLoader; @@ -9,7 +10,8 @@ import meerkat.voting.gui.panels.straight_channel_section.StraightChannelSection import meerkat.voting.gui.panels.thank_for_audditing.ThankForAuditingLoader; import meerkat.voting.gui.panels.vote_have_been_cast.VoteHaveBeenCastLoader; import meerkat.voting.gui.panels.welcome_splash.WelcomeSplashLoader; -import meerkat.voting.gui.configuration.VotingBoothConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.HashMap; @@ -107,6 +109,10 @@ class ChainBuilder { nameToTwoWayNodeMap.put("voteHaveBeenCastController", voteHaveBeenCastController); nameToTwoWayNodeMap.put("thankForAuditing", thankForAuditingController); + final Logger logger = LoggerFactory.getLogger(ChainBuilder.class); + logger.debug("Created all of the two nodes and conntected between them. (for more explanation please" + + " check ChainBuilder.java file."); + return nameToTwoWayNodeMap; } } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/Main.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/Main.java index e0e0daa..df7e9fe 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/Main.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/Main.java @@ -5,6 +5,8 @@ import javafx.stage.Stage; import meerkat.voting.gui.configuration.VotingBoothConfiguration; import meerkat.voting.gui.configuration.VotingBoothConfigurationCreator; import org.json.JSONException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -16,6 +18,8 @@ import java.io.IOException; */ public class Main extends Application { + private final Logger logger = LoggerFactory.getLogger(Main.class); + /** * Creates the VotingBoothConfigurationCreator and creates configuration based on given path * @return VotingBoothVonfiguration parsed from json file @@ -30,6 +34,7 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { + this.logger.debug("Running the app."); ChainBuilder.Build(primaryStage, GetConfig()); primaryStage.setTitle("Meerkat Polling Station"); primaryStage.show(); diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotingBoothGUIManager.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotingBoothGUIManager.java index b3764e4..3f870c9 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotingBoothGUIManager.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotingBoothGUIManager.java @@ -4,8 +4,8 @@ import com.google.common.util.concurrent.FutureCallback; import javafx.application.Application; import javafx.stage.Stage; import meerkat.protobuf.Voting; -import meerkat.voting.gui.configuration.VotingBoothConfiguration; import meerkat.voting.gui.ui.VotingBoothUI; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; @@ -20,7 +20,7 @@ import java.util.Map; * This class managers the gui of the voting booth thruogth external commands */ public class VotingBoothGUIManager extends Application implements VotingBoothUI { - private static final org.slf4j.Logger logger = LoggerFactory.getLogger(VotingBoothGUIManager.class); + private static final Logger logger = LoggerFactory.getLogger(VotingBoothGUIManager.class); private Map visualPanelsMap; private Stage currentStage; @@ -35,10 +35,7 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI * @throws IOException */ private void doStartNewSession(Stage primaryStage) throws IOException { - this.visualPanelsMap = ChainBuilder.Build(primaryStage, new VotingBoothConfiguration()); - this.currentStage = primaryStage; - this.currentStage.setTitle("Voting Booth"); - this.currentStage.show(); + } /** @@ -52,8 +49,6 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI } - - /** * Method that activates the application and passes to start the primary stage (can be called outside this class) * @param args array of strings to pass to the start method as argument