[pollen] branch feature/validVoteCounting created (now 9d6c3a2)
This is an automated email from the git hooks/post-receive script. New change to branch feature/validVoteCounting in repository pollen. See http://git.chorem.org/pollen.git at 9d6c3a2 check vote value This branch includes the following new commits: new 3ddc1e3 check if name is already used new 9d6c3a2 check vote value The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 9d6c3a2033967f0ab265da82ab40c6b7923fc20a Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 25 13:29:39 2014 +0200 check vote value commit 3ddc1e3c3304709923fda893069ca88974523bb5 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 25 11:37:06 2014 +0200 check if name is already used -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/validVoteCounting in repository pollen. See http://git.chorem.org/pollen.git commit 3ddc1e3c3304709923fda893069ca88974523bb5 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 25 11:37:06 2014 +0200 check if name is already used --- .../pollen/services/service/VoteService.java | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java index 2acc2ad..2317c41 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java @@ -24,6 +24,7 @@ package org.chorem.pollen.services.service; */ import com.google.common.base.Function; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.chorem.pollen.persistence.entity.Choice; import org.chorem.pollen.persistence.entity.Poll; @@ -168,6 +169,9 @@ public class VoteService extends PollenServiceSupport { ErrorMap errors = new ErrorMap(); + boolean voteExists = vote.isPersisted(); + Set<String> voterNames = new HashSet<>(); + // poll can't be closed checkNot(errors, "poll", poll.isClosed(), "poll can not be closed"); @@ -176,7 +180,30 @@ public class VoteService extends PollenServiceSupport { // poll must be started check(errors, "poll", Polls.isStarted(poll, now), "poll is not started"); - checkNotBlank(errors, "voter.name", vote.getVoterName(), "voter name can not be empty"); + boolean voteNameNotBlank = checkNotBlank(errors, "voter.name", vote.getVoterName(), "voter name can not be empty"); + + if (voteNameNotBlank) { + List<Vote> existingVote = getVoteDao().findAll(poll); + + if (CollectionUtils.isNotEmpty(existingVote)) { + + // get all voter name + + for ( Vote oneVote : existingVote ) { + if ( voteExists && + oneVote.getTopiaId().equals(vote.getEntityId()) ) { + + continue; + } + + voterNames.add(oneVote.getVoter().getName()); + } + } + + boolean voterNameAdded = voterNames.add(vote.getVoterName()); + check(errors, "voter.name", voterNameAdded, "voter name is already used"); + + } //TODO Finish validation -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/validVoteCounting in repository pollen. See http://git.chorem.org/pollen.git commit 9d6c3a2033967f0ab265da82ab40c6b7923fc20a Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 25 13:29:39 2014 +0200 check vote value --- .../services/service/VoteCountingService.java | 25 +++++++++++ .../pollen/services/service/VoteService.java | 51 +++++++++++----------- .../src/main/webapp/js/controllers/pollCtrl.js | 25 ++++++++++- pollen-ui-angular/src/main/webapp/less/style.less | 4 +- .../src/main/webapp/partials/inline-poll.html | 13 ++++-- .../chorem/pollen/votecounting/VoteCounting.java | 10 ++--- .../pollen/votecounting/BordaVoteCounting.java | 10 ++--- .../pollen/votecounting/CondorcetVoteCounting.java | 12 ++--- .../pollen/votecounting/CoombsVoteCounting.java | 10 ++--- .../votecounting/InstantRunoffVoteCounting.java | 10 ++--- .../pollen/votecounting/NormalVoteCounting.java | 10 ++--- .../pollen/votecounting/NumberVoteCounting.java | 10 ++--- .../votecounting/PercentageVoteCounting.java | 12 ++--- 13 files changed, 128 insertions(+), 74 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java index e5ca3cb..40ad59e 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java @@ -33,7 +33,9 @@ import org.chorem.pollen.persistence.entity.VoteToChoice; import org.chorem.pollen.persistence.entity.VoterList; import org.chorem.pollen.persistence.entity.VoterListMember; import org.chorem.pollen.services.bean.GroupVoteCountingResultBean; +import org.chorem.pollen.services.bean.VoteBean; import org.chorem.pollen.services.bean.VoteCountingResultBean; +import org.chorem.pollen.services.bean.VoteToChoiceBean; import org.chorem.pollen.votecounting.VoteCounting; import org.chorem.pollen.votecounting.VoteCountingFactory; import org.chorem.pollen.votecounting.VoteCountingStrategy; @@ -250,4 +252,27 @@ public class VoteCountingService extends PollenServiceSupport { } + protected ErrorMap voteIsValid(VoteBean vote, VoteCounting voteCounting) { + ErrorMap errors = new ErrorMap(); + + double total = 0; + for(VoteToChoiceBean choice: vote.getChoice()) { + if (choice.getVoteValue() != null) { + total += choice.getVoteValue(); + + check(errors, + "voteValue[" + choice.getChoiceId().getReducedId() + "]", + voteCounting.isVoteValueValid(choice.getVoteValue()), + "Value is invalid"); + } + } + + check(errors, + "totalVoteValue", + voteCounting.isTotalVoteValueValid(total), + "Total vote value is invalid"); + + return errors; + } + } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java index 2317c41..fb663ed 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java @@ -173,40 +173,44 @@ public class VoteService extends PollenServiceSupport { Set<String> voterNames = new HashSet<>(); // poll can't be closed - checkNot(errors, "poll", poll.isClosed(), "poll can not be closed"); + boolean notClosed = checkNot(errors, "poll", poll.isClosed(), "poll can not be closed"); - Date now = serviceContext.getNow(); + if (notClosed) { + Date now = serviceContext.getNow(); - // poll must be started - check(errors, "poll", Polls.isStarted(poll, now), "poll is not started"); + // poll must be started + check(errors, "poll", Polls.isStarted(poll, now), "poll is not started"); - boolean voteNameNotBlank = checkNotBlank(errors, "voter.name", vote.getVoterName(), "voter name can not be empty"); + boolean voteNameNotBlank = checkNotBlank(errors, "voter.name", vote.getVoterName(), "voter name can not be empty"); - if (voteNameNotBlank) { - List<Vote> existingVote = getVoteDao().findAll(poll); + if ( voteNameNotBlank ) { + List<Vote> existingVote = getVoteDao().findAll(poll); - if (CollectionUtils.isNotEmpty(existingVote)) { + if ( CollectionUtils.isNotEmpty(existingVote) ) { - // get all voter name + // get all voter name - for ( Vote oneVote : existingVote ) { - if ( voteExists && - oneVote.getTopiaId().equals(vote.getEntityId()) ) { + for ( Vote oneVote : existingVote ) { + if ( voteExists && + oneVote.getTopiaId().equals(vote.getEntityId()) ) { - continue; - } + continue; + } - voterNames.add(oneVote.getVoter().getName()); + voterNames.add(oneVote.getVoter().getName()); + } } - } - boolean voterNameAdded = voterNames.add(vote.getVoterName()); - check(errors, "voter.name", voterNameAdded, "voter name is already used"); + boolean voterNameAdded = voterNames.add(vote.getVoterName()); + check(errors, "voter.name", voterNameAdded, "voter name is already used"); - } + } - //TODO Finish validation + ErrorMap valueErrors = getVoteCountingService().voteIsValid(vote, getVoteCountingService().getVoteCounting(poll)); + valueErrors.copyTo(errors, "vote."); + //TODO Finish validation + } return errors; } @@ -282,11 +286,8 @@ public class VoteService extends PollenServiceSupport { Set<VoteToChoice> choicesToSave = new HashSet<>(); for (VoteToChoiceBean input : vote.getChoice()) { - Double value = input.getVoteValue(); - if (value != null) { - VoteToChoice voteToChoice = createVoteToChoice(toSave, input); - choicesToSave.add(voteToChoice); - } + VoteToChoice voteToChoice = createVoteToChoice(toSave, input); + choicesToSave.add(voteToChoice); } diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index bd7ef2b..95eab88 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -1056,7 +1056,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $scope.data.vote.anonymous = false; $scope.data.vote.choice = []; - var defaultValue = ($scope.voteCountingIsBoolean()) ? false : 0.0; + var defaultValue = ($scope.voteCountingIsBoolean()) ? false : null; for (var i = 0; i < $scope.data.choices.length; ++i) { @@ -1070,6 +1070,12 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr angular.forEach(sendVote.choice, function (choice) { choice.voteValue = (choice.voteValue)?1.0:0.0; }); + } else { + angular.forEach(sendVote.choice, function (choice) { + if (choice.voteValue == "") { + choice.voteValue = null; + } + }); } if (angular.isDefined($scope.data.vote.id)) { @@ -1094,7 +1100,22 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $rootScope.$on('newInfo', $scope.globalVariables.baseUrl+'#/poll/vote/'+$routeParams.pollId+'/'+ returnRequest.permission, -1); $location.url('/poll/vote/'+$routeParams.pollId+'/'+ returnRequest.permission); }, function (error) { - $scope.data.vote.restError = { voterName : error.data["voter.name"]}; + if (angular.isDefined(error.data["voter.name"])) { + $scope.data.vote.restError = { voterName : error.data["voter.name"]}; + } + + if (angular.isDefined(error.data["vote.totalVoteValue"])) { + $rootScope.$broadcast('newError', error.data["vote.totalVoteValue"][0]); + } + + angular.forEach($scope.data.vote.choice, function (choice, key) { + if (angular.isDefined(error.data["vote.voteValue["+choice.choiceId+"]"])) { + choice.restError = error.data["vote.voteValue["+choice.choiceId+"]"]; + } + else { + delete choice.restError; + } + }); }); } } diff --git a/pollen-ui-angular/src/main/webapp/less/style.less b/pollen-ui-angular/src/main/webapp/less/style.less index 8728234..d32bbe5 100644 --- a/pollen-ui-angular/src/main/webapp/less/style.less +++ b/pollen-ui-angular/src/main/webapp/less/style.less @@ -274,11 +274,11 @@ } &.voteTrue { - background-color:@brand-success; + background-color: lighten(@brand-success, 30%); } &.voteFalse { - background-color:@brand-danger; + background-color: lighten(@brand-danger, 30%); } } diff --git a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html index deec251..15b850e 100644 --- a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html @@ -72,8 +72,10 @@ <input type="text" class="form-control" placeholder="{{ 'user.name' | translate }}" ng-model="data.vote.voterName" input-error="data.vote.restError.voterName[0]" focus-me="true" /> </input-error> </td> - <td ng-repeat="choice in data.vote.choice" class="pollChoice" ng-class="{voteTrue:choice.voteValue, voteFalse:!choice.voteValue}" ng-click="toggleValue(choice, $event);"> - <input type="{{data.voteCountingType.renderType}}" name="{{choice.choiceId}}" ng-model="choice.voteValue" ng-click="toggleValue(choice, $event);" /> + <td ng-repeat="choice in data.vote.choice" class="pollChoice" ng-click="toggleValue(choice, $event);"> + <input-error error="choice.restError[0]" data="choice.voteValue"> + <input type="{{data.voteCountingType.renderType}}" class="form-control" name="{{choice.choiceId}}" ng-model="choice.voteValue" ng-click="toggleValue(choice, $event);" /> + </input-error> </td> <td> <input class="btn btn-primary btn-large" type="button" value="{{ 'action.vote' | translate }}" ng-click="voter()" /> @@ -85,7 +87,12 @@ <tr ng-repeat="vote in data.votants track by $index" class="pollAnim"> <td class="pollChoice"> {{vote.voterName}}</td> <td ng-repeat="choice in vote.choice" class="pollChoice" ng-class="{voteTrue:choice.voteValue, voteFalse:!choice.voteValue}"> - <input type="{{data.voteCountingType.renderType}}" ng-model="choice.voteValue" disabled /> + <div ng-show="data.voteCountingType.renderType == checkbox"> + <input type="checkbox" ng-model="choice.voteValue" disabled /> + </div> + <div ng-show="data.voteCountingType.renderType != checkbox"> + {{choice.voteValue}} + </div> </td> <td> <button class="btn btn-info" ng-if="vote.permission && !globalVariables.editMode" ng-click="editVote(vote)"><span class="glyphicon glyphicon-pencil"></span></button> diff --git a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/VoteCounting.java b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/VoteCounting.java index 97b2423..6723ae3 100644 --- a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/VoteCounting.java +++ b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/VoteCounting.java @@ -56,7 +56,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @param voteValue the vote value to display * @return the string representation of a vote value */ - String getDisplayVoteValue(Integer voteValue); + String getDisplayVoteValue(Double voteValue); /** * Test if the given value is a vote value (says users has filled it). @@ -64,7 +64,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @param voteValue the vote value to test * @return {@code true} if the given value is persisted. */ - boolean isChoiceInVote(Integer voteValue); + boolean isChoiceInVote(Double voteValue); /** * Get the vote counting strategy name to display in UI. @@ -97,7 +97,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @return {@code true} if the given vote value is valid, {@code false} * otherwise. */ - boolean isVoteValueValid(Integer voteValue); + boolean isVoteValueValid(Double voteValue); /** * If a vote value is not valid, gets the localized message of the error. @@ -118,7 +118,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @return {@code true} if the total values of a vote is valid, * {@code false} otherwhise. */ - boolean isTotalVoteValueValid(int totalValues); + boolean isTotalVoteValueValid(double totalValues); /** * If the total values of a vote is not valid, gets the localized error @@ -136,7 +136,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @return {@code true} if the given vote value is null (or considered as * null), {@code false} otherwise. */ - boolean isVoteValueNull(Integer value); + boolean isVoteValueNull(Double value); /** * Gets the type of editor used to render a vote value. diff --git a/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java b/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java index 205a112..3659edb 100644 --- a/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java +++ b/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java @@ -64,7 +64,7 @@ public class BordaVoteCounting extends AbstractVoteCounting<BordaVoteCountingStr } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @@ -74,22 +74,22 @@ public class BordaVoteCounting extends AbstractVoteCounting<BordaVoteCountingStr } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null; } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { return voteValue != null && voteValue > 0; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java b/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java index 5e4f8a4..3f8cc81 100644 --- a/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java +++ b/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java @@ -64,7 +64,7 @@ public class CondorcetVoteCounting extends AbstractVoteCounting<CondorcetVoteCou } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @@ -74,22 +74,22 @@ public class CondorcetVoteCounting extends AbstractVoteCounting<CondorcetVoteCou } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null; } @Override - public boolean isVoteValueValid(Integer voteValue) { - return voteValue != null && voteValue > 0; + public boolean isVoteValueValid(Double voteValue) { + return voteValue == null || voteValue > 0; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java b/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java index 98dbe92..9ebb2d3 100644 --- a/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java +++ b/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java @@ -65,7 +65,7 @@ public class CoombsVoteCounting extends AbstractVoteCounting<CoombsVoteCountingS } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @@ -75,22 +75,22 @@ public class CoombsVoteCounting extends AbstractVoteCounting<CoombsVoteCountingS } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null; } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { return voteValue != null && voteValue > 0; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java b/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java index 5d16ec9..366d76f 100644 --- a/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java +++ b/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java @@ -65,7 +65,7 @@ public class InstantRunoffVoteCounting extends AbstractVoteCounting<InstantRunof } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @@ -75,22 +75,22 @@ public class InstantRunoffVoteCounting extends AbstractVoteCounting<InstantRunof } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null; } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { return voteValue != null && voteValue > 0; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java b/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java index b5a93f5..60e81c6 100644 --- a/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java +++ b/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java @@ -49,17 +49,17 @@ public class NormalVoteCounting extends AbstractVoteCounting<NormalVoteCountingS } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue != null ? "OK" : ""; } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null || voteValue == 0; } @@ -69,13 +69,13 @@ public class NormalVoteCounting extends AbstractVoteCounting<NormalVoteCountingS } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { // no validation on not null vote value return true; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java b/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java index deccd9a..0fc8bca 100644 --- a/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java +++ b/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java @@ -49,17 +49,17 @@ public class NumberVoteCounting extends AbstractVoteCounting<NumberVoteCountingS } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue >= 0; } @Override - public boolean isVoteValueNull(Integer voteValue) { + public boolean isVoteValueNull(Double voteValue) { return voteValue == null || voteValue == 0; } @@ -69,13 +69,13 @@ public class NumberVoteCounting extends AbstractVoteCounting<NumberVoteCountingS } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { // no validation on not null vote value return true; } @Override - public boolean isTotalVoteValueValid(int totalValues) { + public boolean isTotalVoteValueValid(double totalValues) { // no validation on total value return true; } diff --git a/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java b/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java index a6a464d..ef3d8d2 100644 --- a/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java +++ b/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java @@ -50,18 +50,18 @@ public class PercentageVoteCounting extends AbstractVoteCounting<PercentageVoteC } @Override - public String getDisplayVoteValue(Integer voteValue) { + public String getDisplayVoteValue(Double voteValue) { return voteValue == null ? "" : String.valueOf(voteValue); } @Override - public boolean isChoiceInVote(Integer voteValue) { + public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue >= 0 && voteValue <= 100; } @Override - public boolean isVoteValueNull(Integer value) { + public boolean isVoteValueNull(Double value) { return value == null || value == 0; } @@ -71,14 +71,14 @@ public class PercentageVoteCounting extends AbstractVoteCounting<PercentageVoteC } @Override - public boolean isVoteValueValid(Integer voteValue) { + public boolean isVoteValueValid(Double voteValue) { // no validation on not null vote value return true; } @Override - public boolean isTotalVoteValueValid(int totalValues) { - return totalValues == 100; + public boolean isTotalVoteValueValid(double totalValues) { + return totalValues == 100 || totalValues == 0; } @Override -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm