Added the logging to the configuration parsing and the main
parent
0af9d94a73
commit
2bf78f7c73
Binary file not shown.
After Width: | Height: | Size: 1002 B |
|
@ -5,6 +5,8 @@ import meerkat.protobuf.BallotQuestionUIElementOuterClass;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
@ -23,6 +25,9 @@ import java.util.Scanner;
|
||||||
* This class creates QuestionBallotUIElement from given configuration file
|
* This class creates QuestionBallotUIElement from given configuration file
|
||||||
*/
|
*/
|
||||||
public class VotingBoothConfigurationCreator {
|
public class VotingBoothConfigurationCreator {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(VotingBoothConfigurationCreator.class);
|
||||||
|
|
||||||
private int CURRENT_NUMBER_OF_QUESTIONS_REPRESENTED_TO_VOTER = 2 ;
|
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 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";
|
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;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +71,7 @@ public class VotingBoothConfigurationCreator {
|
||||||
private JSONArray getJsonFromPath(String path) throws FileNotFoundException, JSONException {
|
private JSONArray getJsonFromPath(String path) throws FileNotFoundException, JSONException {
|
||||||
String content = new Scanner(new File(path)).useDelimiter("\\Z").next();
|
String content = new Scanner(new File(path)).useDelimiter("\\Z").next();
|
||||||
JSONObject jsonObject = new JSONObject(content);
|
JSONObject jsonObject = new JSONObject(content);
|
||||||
|
this.logger.debug("Created json object from from configuration path.");
|
||||||
return (JSONArray)jsonObject.get("questions");
|
return (JSONArray)jsonObject.get("questions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +113,7 @@ public class VotingBoothConfigurationCreator {
|
||||||
}
|
}
|
||||||
uiAnswersBuilder.setAnswers(listOfAnswers);
|
uiAnswersBuilder.setAnswers(listOfAnswers);
|
||||||
|
|
||||||
|
this.logger.debug("Converted the json object into ballot question object.\n" + object);
|
||||||
return BallotQuestionUIElementOuterClass.BallotQuestionUIElement.newBuilder()
|
return BallotQuestionUIElementOuterClass.BallotQuestionUIElement.newBuilder()
|
||||||
.setQuestion(uiQuestion)
|
.setQuestion(uiQuestion)
|
||||||
.setAnswers(uiAnswersBuilder.build())
|
.setAnswers(uiAnswersBuilder.build())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package meerkat.voting.gui.managment;
|
package meerkat.voting.gui.managment;
|
||||||
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import meerkat.voting.gui.configuration.VotingBoothConfiguration;
|
||||||
import meerkat.voting.gui.panels.ballot_summary.BallotSummaryLoader;
|
import meerkat.voting.gui.panels.ballot_summary.BallotSummaryLoader;
|
||||||
import meerkat.voting.gui.panels.cast_or_audit.CastOrAuditLoader;
|
import meerkat.voting.gui.panels.cast_or_audit.CastOrAuditLoader;
|
||||||
import meerkat.voting.gui.panels.select_candidate_by_picture.SelectCandidateByPictureLoader;
|
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.thank_for_audditing.ThankForAuditingLoader;
|
||||||
import meerkat.voting.gui.panels.vote_have_been_cast.VoteHaveBeenCastLoader;
|
import meerkat.voting.gui.panels.vote_have_been_cast.VoteHaveBeenCastLoader;
|
||||||
import meerkat.voting.gui.panels.welcome_splash.WelcomeSplashLoader;
|
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.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -107,6 +109,10 @@ class ChainBuilder {
|
||||||
nameToTwoWayNodeMap.put("voteHaveBeenCastController", voteHaveBeenCastController);
|
nameToTwoWayNodeMap.put("voteHaveBeenCastController", voteHaveBeenCastController);
|
||||||
nameToTwoWayNodeMap.put("thankForAuditing", thankForAuditingController);
|
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;
|
return nameToTwoWayNodeMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import javafx.stage.Stage;
|
||||||
import meerkat.voting.gui.configuration.VotingBoothConfiguration;
|
import meerkat.voting.gui.configuration.VotingBoothConfiguration;
|
||||||
import meerkat.voting.gui.configuration.VotingBoothConfigurationCreator;
|
import meerkat.voting.gui.configuration.VotingBoothConfigurationCreator;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -16,6 +18,8 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the VotingBoothConfigurationCreator and creates configuration based on given path
|
* Creates the VotingBoothConfigurationCreator and creates configuration based on given path
|
||||||
* @return VotingBoothVonfiguration parsed from json file
|
* @return VotingBoothVonfiguration parsed from json file
|
||||||
|
@ -30,6 +34,7 @@ public class Main extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception
|
public void start(Stage primaryStage) throws Exception
|
||||||
{
|
{
|
||||||
|
this.logger.debug("Running the app.");
|
||||||
ChainBuilder.Build(primaryStage, GetConfig());
|
ChainBuilder.Build(primaryStage, GetConfig());
|
||||||
primaryStage.setTitle("Meerkat Polling Station");
|
primaryStage.setTitle("Meerkat Polling Station");
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.google.common.util.concurrent.FutureCallback;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import meerkat.protobuf.Voting;
|
import meerkat.protobuf.Voting;
|
||||||
import meerkat.voting.gui.configuration.VotingBoothConfiguration;
|
|
||||||
import meerkat.voting.gui.ui.VotingBoothUI;
|
import meerkat.voting.gui.ui.VotingBoothUI;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||||
* This class managers the gui of the voting booth thruogth external commands
|
* This class managers the gui of the voting booth thruogth external commands
|
||||||
*/
|
*/
|
||||||
public class VotingBoothGUIManager extends Application implements VotingBoothUI {
|
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<String, TwoWayNode> visualPanelsMap;
|
private Map<String, TwoWayNode> visualPanelsMap;
|
||||||
private Stage currentStage;
|
private Stage currentStage;
|
||||||
|
|
||||||
|
@ -35,10 +35,7 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void doStartNewSession(Stage primaryStage) 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)
|
* 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
|
* @param args array of strings to pass to the start method as argument
|
||||||
|
|
Loading…
Reference in New Issue