This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit aef052cea55ef15be98f2f24ff619c0769a82ec8 Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 13 17:46:01 2017 +0200 refs #15 ajout de la possibilité ou non de limiter le nombre de choix par vote en fonction du type (+ ajout des bornes min max des valeurs possibles et correction des messages d'erreur) --- .../chorem/pollen/votecounting/VoteCounting.java | 26 +++++++++++++++++++++- .../pollen/votecounting/BordaVoteCounting.java | 15 +++++++++++++ .../pollen-votecounting-borda_en_GB.properties | 2 +- .../pollen-votecounting-borda_fr_FR.properties | 2 +- .../pollen/votecounting/CondorcetVoteCounting.java | 15 +++++++++++++ .../pollen-votecounting-condorcet_en_GB.properties | 2 +- .../pollen-votecounting-condorcet_fr_FR.properties | 2 +- .../pollen/votecounting/CoombsVoteCounting.java | 15 +++++++++++++ .../pollen-votecounting-coombs_en_GB.properties | 2 +- .../pollen-votecounting-coombs_fr_FR.properties | 2 +- .../votecounting/InstantRunoffVoteCounting.java | 17 +++++++++++++- ...en-votecounting-instant-runoff_en_GB.properties | 2 +- ...en-votecounting-instant-runoff_fr_FR.properties | 2 +- .../pollen/votecounting/NormalVoteCounting.java | 15 +++++++++++++ .../pollen/votecounting/NumberVoteCounting.java | 15 +++++++++++++ .../votecounting/PercentageVoteCounting.java | 15 +++++++++++++ 16 files changed, 139 insertions(+), 10 deletions(-) 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 5e91029..b3ec2f2 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 @@ -101,7 +101,7 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * If a vote value is not valid, gets the localized message of the error. * * @param locale the locale used to render the error message - * @param choiceName name of thechoice + * @param choiceName name of the choice * @param voteValue value fo the vote * @return the localized validation message */ @@ -143,4 +143,28 @@ public interface VoteCounting<S extends VoteCountingStrategy> { * @see ChoiceToVoteRenderType */ ChoiceToVoteRenderType getVoteValueEditorType(); + + /** + * Can the creator limit the number of selected choices for a vote? + * It makes sense to limit the number of choice for the normal vote, but not for Condorcet + * + * @return {@code true} if the type of vote counting accept a limited number of choice, {@code false} otherwise. + */ + boolean canLimitNumberOfChoices(); + + /** + * Gets the minimum value for the vote value to be valid. + * If null, then it means no minimum value. + * + * @return the minimum value for the vote to be valid. + */ + Double getMinimumValue(); + + /** + * Gets the maximum value for the vote value to be valid. + * If null, then it means no maximum value. + * + * @return the maximum value for the vote to be valid. + */ + Double getMaximumValue(); } 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 994f7b5..c9168a4 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 @@ -72,6 +72,21 @@ public class BordaVoteCounting extends AbstractVoteCounting<BordaVoteCountingStr } @Override + public boolean canLimitNumberOfChoices() { + return false; + } + + @Override + public Double getMinimumValue() { + return 1d; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } diff --git a/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_en_GB.properties b/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_en_GB.properties index 58d7ad9..1a606a8 100644 --- a/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_en_GB.properties +++ b/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_en_GB.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidBordaVoteValue=The value '%s' of vote for choice %s is not valid, only integer values are authorized. +pollen.error.vote.invalidBordaVoteValue=The value '%2$s' of vote for choice %1$s is not valid, only integer values are authorized. pollen.voteCountingType.borda=Borda pollen.voteCountingType.borda.help=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_Borda' target\='\#doc'>More about this method</a> pollen.voteCountingType.borda.shortHelp=Rank choices by preference order from 1 to N (1\=favorite). Only the rank is taken into account, not the values. Two choices can have the same value. diff --git a/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_fr_FR.properties b/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_fr_FR.properties index 1b42bab..2257e7c 100644 --- a/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_fr_FR.properties +++ b/pollen-votecounting-borda/src/main/resources/i18n/pollen-votecounting-borda_fr_FR.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidBordaVoteValue=La valeur du vote '%s' pour le choix %s n'est pas correcte, seul des valeurs entières sont autorisées. +pollen.error.vote.invalidBordaVoteValue=La valeur du vote '%2$s' pour le choix %1$s n'est pas correcte, seul des valeurs entières sont autorisées. pollen.voteCountingType.borda=Borda pollen.voteCountingType.borda.help=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/> Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_Borda' target\='\#doc'>Pour en savoir plus</a> pollen.voteCountingType.borda.shortHelp=Classer les choix par ordre de préférence de 1 à N (1\=préféré). Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. 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 7056eb4..4949d52 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 @@ -72,6 +72,21 @@ public class CondorcetVoteCounting extends AbstractVoteCounting<CondorcetVoteCou } @Override + public boolean canLimitNumberOfChoices() { + return false; + } + + @Override + public Double getMinimumValue() { + return 1d; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0; } diff --git a/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_en_GB.properties b/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_en_GB.properties index f7be8ce..4c6493f 100644 --- a/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_en_GB.properties +++ b/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_en_GB.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidCondorcetVoteValue=The value '%s' of vote for choice %s is not valid, only integer values are authorized. +pollen.error.vote.invalidCondorcetVoteValue=The value '%2$s' of vote for choice %1$s is not valid, only integer values are authorized. pollen.voteCountingType.condorcet=Condorcet pollen.voteCountingType.condorcet.help=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_Condorcet' target\='\#doc'>More about this method</a> pollen.voteCountingType.condorcet.shortHelp=Rank choices by preference order from 1 to N (1\=favorite). Only the rank is taken into account, not the values. Two choices can have the same value. diff --git a/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_fr_FR.properties b/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_fr_FR.properties index a354014..0482f9d 100644 --- a/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_fr_FR.properties +++ b/pollen-votecounting-condorcet/src/main/resources/i18n/pollen-votecounting-condorcet_fr_FR.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidCondorcetVoteValue=La valeur du vote '%s' pour le choix %s n'est pas correcte, seul des valeurs entières sont autorisées. +pollen.error.vote.invalidCondorcetVoteValue=La valeur du vote '%2$s' pour le choix %1$s n'est pas correcte, seul des valeurs entières sont autorisées. pollen.voteCountingType.condorcet=Condorcet pollen.voteCountingType.condorcet.help=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/>Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_Condorcet' target\='\#doc'>Pour en savoir plus</a> pollen.voteCountingType.condorcet.shortHelp=Classer les choix par ordre de préférence de 1 à N (1\=préféré). Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. 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 4a20120..955c546 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 @@ -73,6 +73,21 @@ public class CoombsVoteCounting extends AbstractVoteCounting<CoombsVoteCountingS } @Override + public boolean canLimitNumberOfChoices() { + return false; + } + + @Override + public Double getMinimumValue() { + return 1d; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isChoiceInVote(Double voteValue) { return voteValue != null && voteValue > 0 && voteValue < 100; } diff --git a/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_en_GB.properties b/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_en_GB.properties index 7f96c8e..2f1686e 100644 --- a/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_en_GB.properties +++ b/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_en_GB.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidCoombsVoteValue=The value '%s' of vote for choice %s is not valid, only integer values are authorized. +pollen.error.vote.invalidCoombsVoteValue=The value '%2$s' of vote for choice %1$s is not valid, only integer values are authorized. pollen.voteCountingType.coombs=Coombs pollen.voteCountingType.coombs.help=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_de_Coombs' target\='\#doc'>More about this method</a> pollen.voteCountingType.coombs.shortHelp=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value. diff --git a/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_fr_FR.properties b/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_fr_FR.properties index 9566ccb..d3d9d2a 100644 --- a/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_fr_FR.properties +++ b/pollen-votecounting-coombs/src/main/resources/i18n/pollen-votecounting-coombs_fr_FR.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidCoombsVoteValue=La valeur du vote '%s' pour le choix %s n'est pas correcte, seul des valeurs entières sont autorisées. +pollen.error.vote.invalidCoombsVoteValue=La valeur du vote '%2$s' pour le choix %1$s n'est pas correcte, seul des valeurs entières sont autorisées. pollen.voteCountingType.coombs=Coombs pollen.voteCountingType.coombs.help=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/>Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur.<br/><a href\='http\://fr.wikipedia.org/wiki/M%C3%A9thode_de_Coombs' target\='\#doc'>Pour en savoir plus</a> pollen.voteCountingType.coombs.shortHelp=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/>Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. 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 3aa8b6b..1fafc24 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 @@ -73,8 +73,23 @@ public class InstantRunoffVoteCounting extends AbstractVoteCounting<InstantRunof } @Override + public boolean canLimitNumberOfChoices() { + return false; + } + + @Override + public Double getMinimumValue() { + return 1d; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isChoiceInVote(Double voteValue) { - return voteValue != null && voteValue > 0 && voteValue < 100; + return voteValue != null && voteValue > 0; } @Override diff --git a/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_en_GB.properties b/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_en_GB.properties index ce6028c..e363e5f 100644 --- a/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_en_GB.properties +++ b/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_en_GB.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidInstantRunoffVoteValue=The value '%s' of vote for choice %s is not valid, only integer values are authorized. +pollen.error.vote.invalidInstantRunoffVoteValue=The value '%2$s' of vote for choice %1$s is not valid, only integer values are authorized. pollen.voteCountingType.instantRunoff=Instant Runoff pollen.voteCountingType.instantRunoff.help=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value.<br/><a href\='http\://fr.wikipedia.org/wiki/Vote_alternatif' target\='\#doc'>More about this method</a> pollen.voteCountingType.instantRunoff.shortHelp=Rank choices by preference order from 1 to N (1\=favorite).<br/>Only the rank is taken into account, not the values. Two choices can have the same value. diff --git a/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_fr_FR.properties b/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_fr_FR.properties index 5ab27c6..3e9cac1 100644 --- a/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_fr_FR.properties +++ b/pollen-votecounting-instant-runoff/src/main/resources/i18n/pollen-votecounting-instant-runoff_fr_FR.properties @@ -1,4 +1,4 @@ -pollen.error.vote.invalidInstantRunoffVoteValue=La valeur du vote '%s' pour le choix %s n'est pas correcte, seul des valeurs entières sont autorisées. +pollen.error.vote.invalidInstantRunoffVoteValue=La valeur du vote '%2$s' pour le choix %1$s n'est pas correcte, seul des valeurs entières sont autorisées. pollen.voteCountingType.instantRunoff=Vote alternatif pollen.voteCountingType.instantRunoff.help=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/>Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur.<br/><a href\='http\://fr.wikipedia.org/wiki/Vote_alternatif' target\='\#doc'>Pour en savoir plus</a> pollen.voteCountingType.instantRunoff.shortHelp=Classer les choix par ordre de préférence de 1 à N (1\=préféré).<br/>Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. 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 c7a4ffa..c190b7a 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 @@ -67,6 +67,21 @@ public class NormalVoteCounting extends AbstractVoteCounting<NormalVoteCountingS } @Override + public boolean canLimitNumberOfChoices() { + return true; + } + + @Override + public Double getMinimumValue() { + return null; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isVoteValueValid(Double voteValue) { // no validation on not null vote 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 9fbb4d8..1c9f5c8 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 @@ -67,6 +67,21 @@ public class NumberVoteCounting extends AbstractVoteCounting<NumberVoteCountingS } @Override + public boolean canLimitNumberOfChoices() { + return true; + } + + @Override + public Double getMinimumValue() { + return null; + } + + @Override + public Double getMaximumValue() { + return null; + } + + @Override public boolean isVoteValueValid(Double voteValue) { // no validation on not null vote 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 955c6cd..4672d48 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 @@ -69,6 +69,21 @@ public class PercentageVoteCounting extends AbstractVoteCounting<PercentageVoteC } @Override + public boolean canLimitNumberOfChoices() { + return false; + } + + @Override + public Double getMinimumValue() { + return 0d; + } + + @Override + public Double getMaximumValue() { + return 100d; + } + + @Override public boolean isVoteValueValid(Double voteValue) { return voteValue == null || 0 <= voteValue && voteValue <= 100; } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.