r3517 - in trunk: pollen-persistence/src/main/java/org/chorem/pollen pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/i18n
Author: tchemit Date: 2012-06-18 18:59:38 +0200 (Mon, 18 Jun 2012) New Revision: 3517 Url: http://chorem.org/repositories/revision/pollen/3517 Log: refs #576 (NPE if no values) + improve validation for condorcet Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java 2012-06-18 16:19:22 UTC (rev 3516) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java 2012-06-18 16:59:38 UTC (rev 3517) @@ -164,10 +164,12 @@ new VotingPersonDTO(input.getPollAccount().getVotingId(), input.getWeight()); result.setEmail(input.getPollAccount().getEmail()); - for (VoteToChoice vToChoice : input.getChoiceVoteToChoice()) { - if (vToChoice != null && vToChoice.getChoice() != null) { - VoteToChoiceDTO bean = VOTE_TO_CHOICE_TO_BEAN.apply(vToChoice); - result.getChoices().add(bean); + if (!input.isChoiceVoteToChoiceEmpty()) { + for (VoteToChoice vToChoice : input.getChoiceVoteToChoice()) { + if (vToChoice != null && vToChoice.getChoice() != null) { + VoteToChoiceDTO bean = VOTE_TO_CHOICE_TO_BEAN.apply(vToChoice); + result.getChoices().add(bean); + } } } return result; @@ -185,7 +187,7 @@ } }; - public static final Function<Map.Entry<Poll,PollAccount>,Pair<Poll,PollAccount>> MAP_ENTRY_TO_PAIR_FUNCTION = new Function<Map.Entry<Poll, PollAccount>, Pair<Poll, PollAccount>>() { + public static final Function<Map.Entry<Poll, PollAccount>, Pair<Poll, PollAccount>> MAP_ENTRY_TO_PAIR_FUNCTION = new Function<Map.Entry<Poll, PollAccount>, Pair<Poll, PollAccount>>() { @Override public Pair<Poll, PollAccount> apply(Map.Entry<Poll, PollAccount> input) { return Pair.of(input.getKey(), input.getValue()); Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-18 16:19:22 UTC (rev 3516) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-18 16:59:38 UTC (rev 3517) @@ -65,12 +65,6 @@ addFlashMessage(_("pollen.information.pollNotStarted")); } else if (isPollFinished()) { addFlashMessage(_("pollen.information.pollFinished")); - } else if (isCreatorUser()) { -// if (getUriId().isAccountIdNotBlank()) { -// -// // account Id setted in url, so should not be abel to vote -// addFlashWarning(_("pollen.information.vote.creatorUser")); -// } } if (isPollChoiceRunning()) { addFlashMessage(_("pollen.information.pollChoiceRunning")); @@ -124,8 +118,8 @@ totalValues += value; } else { - // otherwise does not take account of this choice - voteToChoice.setVoteValue(null); + addFieldError("vote.choices", + _("pollen.error.vote.invalidCondorcetVoteValue")); } // for other vote type, value must be > 0 } else if (value != 0) { @@ -147,6 +141,7 @@ } } + // @InputConfig(methodName = PREPARE_VOTE_PAGE) @Override public String execute() throws Exception { Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-18 16:19:22 UTC (rev 3516) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-18 16:59:38 UTC (rev 3517) @@ -216,6 +216,7 @@ pollen.error.user.not.found=User not found pollen.error.user.restrictedListsForbidden=The poll is restricted and you are not allowed to vote. Check if you have correctly used the link sent to you by email. pollen.error.userNotAllowed=You are not allowed to count the votes for this poll. +pollen.error.vote.invalidCondorcetVoteValue=Invalid position\: in a condorcet vote, you can let empty values, or put values greater than zero. pollen.error.vote.maxChoiceNb=The maximal number of choices is %d. pollen.error.vote.percentage=The sum of the values must be equals to 100. pollen.fieldset.choice.options=Choices Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-18 16:19:22 UTC (rev 3516) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-18 16:59:38 UTC (rev 3517) @@ -216,6 +216,7 @@ pollen.error.user.not.found=Utilisateur non trouvé pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'êtes pas autorisé à voter. Vérifiez que vous avez bien utiliser le lien qui vous a été envoyé. pollen.error.userNotAllowed=Vous n'êtes pas autorisé à dépouiller ce sondage. +pollen.error.vote.invalidCondorcetVoteValue=Position invalide \: dans un vote condorcet, vous pouvez soit laisser laisser vide un choix, soit mettre une valeur strictement positive. pollen.error.vote.maxChoiceNb=Le nombre de choix maximal est de %d. pollen.error.vote.percentage=La somme des valeurs doit être égale à 100. pollen.fieldset.choice.options=Les choix
participants (1)
-
tchemit@users.chorem.org