Author: tchemit Date: 2012-01-24 15:11:32 +0100 (Tue, 24 Jan 2012) New Revision: 3115 Url: http://chorem.org/repositories/revision/pollen/3115 Log: - add i18n on enums - clean codes (remo this., public modifiers on interfaces, usage of generics, for-each,...) -This line, and those below, will be ignored-- M pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java M pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/ListBehavior.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/PercentageBehavior.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExport.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCounting.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingPersonDTO.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollChoiceDTO.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollDTO.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Method.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/CondorcetMethod.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Context.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Choice.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Group.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Vote.java M pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/PercentageMethod.java M pollen-domain/src/main/java/org/chorem/pollen/common/VoteCountingType.java M pollen-domain/src/main/java/org/chorem/pollen/common/PollType.java M pollen-domain/src/main/java/org/chorem/pollen/common/ChoiceType.java A pollen-domain/src/main/resources/i18n AM pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties AM pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties M pollen-domain/pom.xml Added: branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/ branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties Modified: branches/pollen-2.0-beta-1/pollen-domain/pom.xml branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/ChoiceType.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/PollType.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/VoteCountingType.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Choice.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/CondorcetMethod.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Context.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Group.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Method.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/PercentageMethod.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Vote.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollChoiceDTO.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollDTO.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingPersonDTO.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExport.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCounting.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/ListBehavior.java branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/PercentageBehavior.java branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java Modified: branches/pollen-2.0-beta-1/pollen-domain/pom.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/pom.xml 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/pom.xml 2012-01-24 14:11:32 UTC (rev 3115) @@ -21,6 +21,10 @@ <artifactId>commons-logging</artifactId> </dependency> <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> + <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> </dependency> @@ -34,4 +38,20 @@ <name>Pollen :: Domain</name> <description>Service de dépouillement</description> + <build> + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/ChoiceType.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/ChoiceType.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/ChoiceType.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -39,19 +39,33 @@ package org.chorem.pollen.common; +import static org.nuiton.i18n.I18n.n_; + public enum ChoiceType { - TEXT, DATE, IMAGE; + TEXT(n_("pollen.choiceType.text")), + DATE(n_("pollen.choiceType.date")), + IMAGE(n_("pollen.choiceType.image")); + private final String i18nKey; + + ChoiceType(String i18nKey) { + this.i18nKey = i18nKey; + } + + public String getI18nKey() { + return i18nKey; + } + public boolean isText() { - return this.equals(TEXT); + return equals(TEXT); } public boolean isDate() { - return this.equals(DATE); + return equals(DATE); } public boolean isImage() { - return this.equals(IMAGE); + return equals(IMAGE); } public static ChoiceType valueOf(int ordinal) { Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/PollType.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/PollType.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/PollType.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -39,19 +39,34 @@ package org.chorem.pollen.common; +import static org.nuiton.i18n.I18n.n_; + public enum PollType { - FREE, RESTRICTED, GROUP; + FREE(n_("pollen.pollType.free")), + RESTRICTED(n_("pollen.pollType.restricted")), + GROUP(n_("pollen.pollType.group")); + + private final String i18nKey; + + PollType(String i18nKey) { + this.i18nKey = i18nKey; + } + + public String getI18nKey() { + return i18nKey; + } + public boolean isFree() { - return this.equals(FREE); + return equals(FREE); } public boolean isRestricted() { - return this.equals(RESTRICTED); + return equals(RESTRICTED); } public boolean isGroup() { - return this.equals(GROUP); + return equals(GROUP); } public boolean isRestrictedOrGroup() { Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/VoteCountingType.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/VoteCountingType.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/common/VoteCountingType.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -39,23 +39,38 @@ package org.chorem.pollen.common; +import static org.nuiton.i18n.I18n.n_; + public enum VoteCountingType { - NORMAL, PERCENTAGE, CONDORCET, NUMBER; + NORMAL(n_("pollen.voteCountingType.normal")), + PERCENTAGE(n_("pollen.voteCountingType.percentage")), + CONDORCET(n_("pollen.voteCountingType.condorcet")), + NUMBER(n_("pollen.voteCountingType.number")); + private final String i18nKey; + + VoteCountingType(String i18nKey) { + this.i18nKey = i18nKey; + } + + public String getI18nKey() { + return i18nKey; + } + public boolean isNormal() { - return this.equals(NORMAL); + return equals(NORMAL); } public boolean isPercentage() { - return this.equals(PERCENTAGE); + return equals(PERCENTAGE); } public boolean isCondorcet() { - return this.equals(CONDORCET); + return equals(CONDORCET); } public boolean isNumber() { - return this.equals(NUMBER); + return equals(NUMBER); } public static VoteCountingType valueOf(int ordinal) { Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Choice.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Choice.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Choice.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -76,9 +76,9 @@ * @param id : identifiant du choix */ public Choice(String id) { - this.idChoice = id; - this.groups = new ArrayList<Group>(); - this.value = 0.; + idChoice = id; + groups = new ArrayList<Group>(); + value = 0.; } /** @@ -107,7 +107,7 @@ * @return valeur courante du choix */ public double getValue() { - return this.value; + return value; } /** @@ -116,7 +116,7 @@ * @return identifiant du choix */ public String getIdChoice() { - return this.idChoice; + return idChoice; } /** @@ -125,7 +125,7 @@ * @return nom du choix */ public String getName() { - return this.name; + return name; } /** @@ -134,7 +134,7 @@ * @return map des groupes pour ce choix */ public List<Group> getGroups() { - return this.groups; + return groups; } /** @@ -144,7 +144,7 @@ * @param idGroup : identifiant du groupe */ public void addGroup(String idGroup, double weight) { - this.groups.add(new Group(idGroup, weight)); + groups.add(new Group(idGroup, weight)); } /** @@ -154,7 +154,7 @@ * @return le groupe ayant l'identifiant idGroup */ public Group getGroup(String idGroup) { - for (Group g : this.groups) { + for (Group g : groups) { if (g.getIdGroup().equals(idGroup)) { return g; } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/CondorcetMethod.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/CondorcetMethod.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/CondorcetMethod.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -180,8 +180,7 @@ * autres votes du votant et mise à jour du nombre de victoires pour ce * vote. * - * @see getVictories(String id, Choice choice, Map<String, Map<Choice, - * Double>> votes) + * @see #getVictories(String, Choice choice, Map) * @param choices Les choix utilisés pour le dépouillement. * @param votes Les votes de chaque votant. * @param byGroup Calcul sur des groupes. Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Context.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -81,9 +81,9 @@ */ public Context(Method method, boolean groupCounting) { this.groupCounting = groupCounting; - this.choices = new ArrayList<Choice>(); - this.hiddenChoices = new ArrayList<Choice>(); - this.results = new ArrayList<Choice>(); + choices = new ArrayList<Choice>(); + hiddenChoices = new ArrayList<Choice>(); + results = new ArrayList<Choice>(); this.method = method; } @@ -94,12 +94,12 @@ * @return choix */ public Choice getChoice(String idChoice) { - for (Choice choice : this.choices) { + for (Choice choice : choices) { if (choice.getIdChoice().equals(idChoice)) { return choice; } } - for (Choice choice : this.hiddenChoices) { + for (Choice choice : hiddenChoices) { if (choice.getIdChoice().equals(idChoice)) { return choice; } @@ -113,7 +113,7 @@ * @return liste des choix */ public List<Choice> getChoices() { - return this.choices; + return choices; } /** @@ -122,7 +122,7 @@ * @return liste des choix cachés */ public List<Choice> getHiddenChoices() { - return this.hiddenChoices; + return hiddenChoices; } /** @@ -131,25 +131,25 @@ * @return liste des choix résultats */ public List<Choice> getResults() { - return this.results; + return results; } /** * Ajout d'un nouveau choix au contexte * - * @param idChoice : identifiant du choix + * @param choice : identifiant du choix */ public void addChoice(PollChoiceDTO choice) { - this.choices.add(new Choice(choice.getIdChoice(), choice.getName())); + choices.add(new Choice(choice.getIdChoice(), choice.getName())); } /** * Ajout d'un nouveau choix au contexte * - * @param idChoice : identifiant du choix + * @param choice : identifiant du choix */ public void addHiddenChoice(PollChoiceDTO choice) { - this.hiddenChoices.add(new Choice(choice.getIdChoice(), choice.getName())); + hiddenChoices.add(new Choice(choice.getIdChoice(), choice.getName())); } /** @@ -159,10 +159,10 @@ * @param weight : poids du groupe */ public void addGroup(String idGroup, double weight) { - for (Choice choice : this.choices) { + for (Choice choice : choices) { choice.addGroup(idGroup, weight); } - for (Choice choice : this.hiddenChoices) { + for (Choice choice : hiddenChoices) { choice.addGroup(idGroup, weight); } } @@ -196,20 +196,20 @@ log.error("L'exécution du dépouillement a échoué", e); return false; } - - this.results.clear(); + + results.clear(); Choice result = new Choice(""); - for (Choice curr : this.choices) { + for (Choice curr : choices) { if (curr.value() > result.value()) { result = curr; - this.results.clear(); + results.clear(); } else if (curr.value() == result.value()) { - this.results.add(curr); + results.add(curr); } } - - this.results.add(result); + + results.add(result); return true; } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Group.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Group.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Group.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -76,10 +76,10 @@ * @param weight : poids du groupe */ public Group(String id, double weight) { - this.idGroup = id; + idGroup = id; this.weight = weight; - this.value = 0.; - this.votes = new ArrayList<Vote>(); + value = 0.; + votes = new ArrayList<Vote>(); } /** @@ -88,7 +88,7 @@ * @return identifiant du groupe */ public String getIdGroup() { - return this.idGroup; + return idGroup; } /** @@ -97,7 +97,7 @@ * @return poids du groupe */ public double getWeight() { - return this.weight; + return weight; } /** @@ -115,7 +115,7 @@ * @return la valeur du groupe */ public double getValue() { - return this.value; + return value; } /** @@ -124,7 +124,7 @@ * @return liste des votes */ public List<Vote> getVotes() { - return this.votes; + return votes; } /** @@ -132,9 +132,10 @@ * * @param value : valeur du vote * @param weight : poids du vote + * @param votingID id of vote */ public void addVote(double value, double weight, String votingID) { - this.votes.add(new Vote(value, weight, votingID)); + votes.add(new Vote(value, weight, votingID)); } @Override Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Method.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Method.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Method.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -55,7 +55,7 @@ * @param choices l'ensemble des choix à dépouiller * @param groupCounting si le dépouillement doit être groupé */ - public void executeCounting(List<Choice> choices, boolean groupCounting); + void executeCounting(List<Choice> choices, boolean groupCounting); /** * Effectue des statistiques sur le <code>choice</code> specifié. @@ -68,6 +68,6 @@ * @param choice le choix sur lequel effectuer des statistiques * @param choiceDTO le choix contenant les resultats statistiques */ - public void executeStats(List<Choice> choices, boolean groupCounting, - Choice choice, ChoiceDTO choiceDTO); + void executeStats(List<Choice> choices, boolean groupCounting, + Choice choice, ChoiceDTO choiceDTO); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/PercentageMethod.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/PercentageMethod.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/PercentageMethod.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -48,7 +48,7 @@ * @author rannou * @version $Id$ */ -public class PercentageMethod extends StandardMethod implements Method { +public class PercentageMethod extends StandardMethod { @Override public double getValueForChoiceByGroup(Choice choice, String idGroup, Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -68,7 +68,7 @@ for (Choice choice : choices) { double totalChoice = 0.; for (Group group : choice.getGroups()) { - this.getValueForGroup(group); + getValueForGroup(group); totalChoice += group.getValue(); } choice.setValue(totalChoice); @@ -85,13 +85,12 @@ // Calcul avec prise en compte des groupes public void calculateChoicesByGroup(List<Choice> choices) { - Map<String, List<String>> mapGroupsChoosenChoices = this - .getChoosenChoicesByGroup(choices); + Map<String, List<String>> mapGroupsChoosenChoices = getChoosenChoicesByGroup(choices); for (Choice choice : choices) { double totalChoice = 0.; for (String idGroup : mapGroupsChoosenChoices.keySet()) { - totalChoice += this.getValueForChoiceByGroup(choice, idGroup, + totalChoice += getValueForChoiceByGroup(choice, idGroup, mapGroupsChoosenChoices.get(idGroup)); } choice.setValue(totalChoice); Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Vote.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Vote.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/business/Vote.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -75,7 +75,7 @@ * @return valeur du vote */ public double getValue() { - return this.value; + return value; } /** @@ -84,7 +84,7 @@ * @return poids du vote */ public double getWeight() { - return this.weight; + return weight; } /** @@ -93,6 +93,6 @@ * @return identifiant du votant */ public String getVotingID() { - return this.votingID; + return votingID; } } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollChoiceDTO.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollChoiceDTO.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollChoiceDTO.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -55,16 +55,16 @@ public PollChoiceDTO(String idChoice) { this.idChoice = idChoice; - this.name = ""; - this.description = ""; - this.hidden = false; + name = ""; + description = ""; + hidden = false; } public PollChoiceDTO(int idChoice) { this.idChoice = String.valueOf(idChoice); - this.name = ""; - this.description = ""; - this.hidden = false; + name = ""; + description = ""; + hidden = false; } public String getIdChoice() { Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollDTO.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollDTO.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/PollDTO.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -62,29 +62,29 @@ private Date beginDate = new Date(); - private Date endDate = null; + private Date endDate; - private Date beginChoiceDate = null; + private Date beginChoiceDate; - private int maxChoiceNb = 0; + private int maxChoiceNb; private boolean closed = true; - private boolean choiceAddAllowed = false; + private boolean choiceAddAllowed; - private boolean anonymousVoteAllowed = false; + private boolean anonymousVoteAllowed; - private boolean anonymous = false; + private boolean anonymous; - private boolean publicResults = false; + private boolean publicResults; - private boolean continuousResults = false; + private boolean continuousResults; - private PollType pollType = null; + private PollType pollType; - private VoteCountingType voteCounting = null; + private VoteCountingType voteCounting; - private ChoiceType choiceType = null; + private ChoiceType choiceType; private String creatorId = ""; Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -62,7 +62,7 @@ public VotingGroupDTO(String idGroup, double weight) { this.idGroup = idGroup; this.weight = weight; - this.votingPersons = new ArrayList<VotingPersonDTO>(); + votingPersons = new ArrayList<VotingPersonDTO>(); } @Override Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingPersonDTO.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingPersonDTO.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/dto/VotingPersonDTO.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -65,11 +65,11 @@ private List<VoteToChoiceDTO> choices; public VotingPersonDTO(String votingId, double weight) { - this.choices = new ArrayList<VoteToChoiceDTO>(); - this.comment = ""; - this.email = ""; - this.login = ""; - this.votingDate = new Date(); + choices = new ArrayList<VoteToChoiceDTO>(); + comment = ""; + email = ""; + login = ""; + votingDate = new Date(); this.votingId = votingId; this.weight = weight; } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExport.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExport.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExport.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -58,7 +58,7 @@ * @param export : DTO à exporter. * @return le chemin du fichier exporté. */ - public String executeExport(PollExportDTO export); + String executeExport(PollExportDTO export); /** * Export d'un sondage et de ses résultats au format XML. Le DTO contient le @@ -67,7 +67,7 @@ * @param export : DTO à exporter. * @return le fichier exporté. */ - public File executeFileExport(PollExportDTO export); + File executeFileExport(PollExportDTO export); /** * Import d'un sondage et de ses résultats à partir d'un fichier XML. @@ -75,5 +75,5 @@ * @param filePath chemin du fichier à importer. * @return le sondage importé */ - public PollExportDTO executeImport(String filePath); + PollExportDTO executeImport(String filePath); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -41,8 +41,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.commons.logging.Log; @@ -137,8 +137,7 @@ /** * Construction du document XML à partir du sondage. * - * @param le chemin du fichier à créer - * @return le fichier créé + * @param filePath chemin du fichier à créer */ private void savePoll(String filePath) { @@ -188,9 +187,8 @@ // Création des commentaires Element commentsElm = new Element("comments"); - Iterator iteratorComment = poll.getComments().listIterator(); - while (iteratorComment.hasNext()) { - Element commentElm = save((CommentDTO) iteratorComment.next()); + for (CommentDTO commentDTO : poll.getComments()) { + Element commentElm = save(commentDTO); commentsElm.addContent(commentElm); } @@ -199,9 +197,8 @@ // Création des groupes de votants Element groupsElm = new Element("groups"); - Iterator iteratorGroup = poll.getVotingGroups().listIterator(); - while (iteratorGroup.hasNext()) { - Element groupElm = save((VotingGroupDTO) iteratorGroup.next()); + for (VotingGroupDTO votingGroupDTO : poll.getVotingGroups()) { + Element groupElm = save(votingGroupDTO); groupsElm.addContent(groupElm); } @@ -210,9 +207,8 @@ // Création des choix Element pollChoicesElm = new Element("pollChoices"); - Iterator itPollChoices = poll.getChoices().listIterator(); - while (itPollChoices.hasNext()) { - Element pollChoiceElm = save((PollChoiceDTO) itPollChoices.next()); + for (PollChoiceDTO pollChoiceDTO : poll.getChoices()) { + Element pollChoiceElm = save(pollChoiceDTO); pollChoicesElm.addContent(pollChoiceElm); } pollElm.addContent(pollChoicesElm); @@ -220,11 +216,8 @@ // Création des résultats Element voteCountingResultsElm = new Element("voteCountingResults"); - Iterator iteratorvoteCountingResults = voteCountingResults - .listIterator(); - while (iteratorvoteCountingResults.hasNext()) { - Element voteCountingResult = save((VoteCountingResultDTO) iteratorvoteCountingResults - .next()); + for (VoteCountingResultDTO voteCountingResult1 : voteCountingResults) { + Element voteCountingResult = save(voteCountingResult1); voteCountingResultsElm.addContent(voteCountingResult); } @@ -258,11 +251,8 @@ Element votingPersonsElm = new Element("votingPersons"); - Iterator iteratorVotingPersons = group.getVotingPersons() - .listIterator(); - while (iteratorVotingPersons.hasNext()) { - Element votingPersonElm = save((VotingPersonDTO) iteratorVotingPersons - .next()); + for (VotingPersonDTO votingPersonDTO : group.getVotingPersons()) { + Element votingPersonElm = save(votingPersonDTO); votingPersonsElm.addContent(votingPersonElm); } groupElm.addContent(votingPersonsElm); @@ -287,14 +277,11 @@ Element choicesElm = new Element("choices"); - Iterator iteratorChoices = votingPerson.getChoices().listIterator(); - while (iteratorChoices.hasNext()) { - VoteToChoiceDTO voteToChoice = (VoteToChoiceDTO) iteratorChoices - .next(); + for (VoteToChoiceDTO voteToChoice : votingPerson.getChoices()) { Element choiceElm = new Element("choice"); choiceElm.setAttribute("idChoice", voteToChoice.getIdChoice()); choiceElm.setAttribute("value", Double.toString(voteToChoice - .getValue())); + .getValue())); choicesElm.addContent(choiceElm); } @@ -339,10 +326,8 @@ Element choicesElm = new Element("choices"); - Iterator iteratorChoices = voteCountingResults.getChoices() - .listIterator(); - while (iteratorChoices.hasNext()) { - Element choiceElm = save((ChoiceDTO) iteratorChoices.next()); + for (ChoiceDTO choiceDTO : voteCountingResults.getChoices()) { + Element choiceElm = save(choiceDTO); choicesElm.addContent(choiceElm); } @@ -384,8 +369,13 @@ // Mise en forme classique avec getPrettyFormat() XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); - sortie.output(document, new FileOutputStream(file)); - } catch (java.io.IOException e) { + FileOutputStream out = new FileOutputStream(file); + try { + sortie.output(document, out); + } finally { + out.close(); + } + } catch (IOException e) { log.error("Erreur lors de l'enregistrement du document : " + filePath, e); } @@ -430,14 +420,14 @@ // Ajout des commentaires Element commentsElm = pollElm.getChild("comments"); List<Element> listComments = commentsElm.getChildren("comment"); - List vectorComments = loadComments(listComments); + List<CommentDTO> vectorComments = loadComments(listComments); poll.setComments(vectorComments); // Ajout des groupes Element groupsElm = pollElm.getChild("groups"); List<Element> listGroups = groupsElm.getChildren("group"); - List vectorGroups = loadGroups(listGroups); + List<VotingGroupDTO> vectorGroups = loadGroups(listGroups); poll.setVotingGroups(vectorGroups); @@ -445,7 +435,7 @@ Element pollChoicesElm = pollElm.getChild("pollChoices"); List<Element> listPollChoices = pollChoicesElm .getChildren("pollChoice"); - List vectorPollChoices = loadPollChoices(listPollChoices); + List<PollChoiceDTO> vectorPollChoices = loadPollChoices(listPollChoices); poll.setChoices(vectorPollChoices); @@ -453,7 +443,7 @@ Element voteCountingResultsElm = racine.getChild("voteCountingResults"); List<Element> listVoteCountingResults = voteCountingResultsElm .getChildren("voteCountingResult"); - List vectorVoteCountingResults = loadVoteCountingResults(listVoteCountingResults); + List<VoteCountingResultDTO> vectorVoteCountingResults = loadVoteCountingResults(listVoteCountingResults); // Création du sondage PollExportDTO PollExportDTO pollExport = new PollExportDTO(); @@ -464,36 +454,32 @@ return pollExport; } - private List loadComments(List<Element> listComments) { - List vectorComments = new ArrayList<CommentDTO>(); + private List<CommentDTO> loadComments(List<Element> listComments) { + List<CommentDTO> vectorComments = new ArrayList<CommentDTO>(); - Iterator i = listComments.listIterator(); - while (i.hasNext()) { - Element commentElm = (Element) i.next(); + for (Element commentElm : listComments) { CommentDTO comment = new CommentDTO(commentElm - .getAttributeValue("votingId"), commentElm.getText()); + .getAttributeValue("votingId"), commentElm.getText()); vectorComments.add(comment); } return vectorComments; } - private List loadGroups(List<Element> listGroups) { - List vectorGroups = new ArrayList<VotingGroupDTO>(); + private List<VotingGroupDTO> loadGroups(List<Element> listGroups) { + List<VotingGroupDTO> vectorGroups = new ArrayList<VotingGroupDTO>(); - Iterator i = listGroups.listIterator(); - while (i.hasNext()) { - Element groupElm = (Element) i.next(); + for (Element groupElm : listGroups) { VotingGroupDTO group = new VotingGroupDTO(groupElm - .getAttributeValue("idGroup"), Double.parseDouble((groupElm - .getAttributeValue("weight")))); + .getAttributeValue("idGroup"), Double.parseDouble(groupElm + .getAttributeValue("weight"))); group.setName(groupElm.getAttributeValue("name")); Element votingPersonsElm = groupElm.getChild("votingPersons"); List<Element> listVotingPersons = votingPersonsElm .getChildren("votingPerson"); - List vectorVotingPersons = loadVotingPersons(listVotingPersons); + List<VotingPersonDTO> vectorVotingPersons = loadVotingPersons(listVotingPersons); group.setVotingPersons(vectorVotingPersons); @@ -503,24 +489,22 @@ return vectorGroups; } - private List loadVotingPersons(List<Element> listVotingPersons) { - List vectorVotingPersons = new ArrayList<VotingPersonDTO>(); + private List<VotingPersonDTO> loadVotingPersons(List<Element> listVotingPersons) { + List<VotingPersonDTO> vectorVotingPersons = new ArrayList<VotingPersonDTO>(); - Iterator i = listVotingPersons.listIterator(); - while (i.hasNext()) { - Element votingPersonElm = (Element) i.next(); + for (Element votingPersonElm : listVotingPersons) { VotingPersonDTO votingPerson = new VotingPersonDTO(votingPersonElm - .getAttributeValue("votingId"), Double - .parseDouble((votingPersonElm.getAttributeValue("weight")))); + .getAttributeValue("votingId"), Double + .parseDouble(votingPersonElm.getAttributeValue("weight"))); votingPerson.setEmail(votingPersonElm.getChild("email").getValue()); votingPerson.setComment(votingPersonElm.getChild("comment") - .getValue()); + .getValue()); Element choicesElm = votingPersonElm.getChild("choices"); List<Element> listVoteToChoices = choicesElm.getChildren("choice"); - List vectorVoteToChoices = loadVoteToChoices(listVoteToChoices); + List<VoteToChoiceDTO> vectorVoteToChoices = loadVoteToChoices(listVoteToChoices); votingPerson.setChoices(vectorVoteToChoices); vectorVotingPersons.add(votingPerson); @@ -529,15 +513,12 @@ return vectorVotingPersons; } - private List loadVoteToChoices(List<Element> listVoteToChoices) { - List vectorVoteToChoices = new ArrayList<VotingPersonDTO>(); + private List<VoteToChoiceDTO> loadVoteToChoices(List<Element> listVoteToChoices) { + List<VoteToChoiceDTO> vectorVoteToChoices = new ArrayList<VoteToChoiceDTO>(); - Iterator i = listVoteToChoices.listIterator(); - while (i.hasNext()) { - Element voteToChoiceElm = (Element) i.next(); - + for (Element voteToChoiceElm : listVoteToChoices) { VoteToChoiceDTO voteToChoice = new VoteToChoiceDTO(voteToChoiceElm - .getAttributeValue("idChoice"), Double + .getAttributeValue("idChoice"), Double .parseDouble(voteToChoiceElm.getAttributeValue("value"))); vectorVoteToChoices.add(voteToChoice); } @@ -545,22 +526,20 @@ return vectorVoteToChoices; } - private List loadPollChoices(List<Element> listPollChoices) { - List vectorPollChoices = new ArrayList<PollChoiceDTO>(); + private List<PollChoiceDTO> loadPollChoices(List<Element> listPollChoices) { + List<PollChoiceDTO> vectorPollChoices = new ArrayList<PollChoiceDTO>(); - Iterator i = listPollChoices.listIterator(); - while (i.hasNext()) { - Element pollChoiceElm = (Element) i.next(); + for (Element pollChoiceElm : listPollChoices) { PollChoiceDTO pollChoice = new PollChoiceDTO(pollChoiceElm - .getAttributeValue("idChoice")); + .getAttributeValue("idChoice")); String pollChoiceName = pollChoiceElm.getChild("name").getValue(); pollChoice.setName(pollChoiceName); pollChoice.setHidden(pollChoiceName != null - && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX)); + && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX)); pollChoice.setDescription(pollChoiceElm.getChild("description") - .getValue()); + .getValue()); vectorPollChoices.add(pollChoice); } @@ -568,27 +547,25 @@ return vectorPollChoices; } - private List loadVoteCountingResults(List<Element> listVoteCountingResults) { - List vectorVoteCountingResults = new ArrayList<VoteCountingResultDTO>(); + private List<VoteCountingResultDTO> loadVoteCountingResults(List<Element> listVoteCountingResults) { + List<VoteCountingResultDTO> vectorVoteCountingResults = new ArrayList<VoteCountingResultDTO>(); - Iterator i = listVoteCountingResults.listIterator(); - while (i.hasNext()) { - Element voteCountingResultElm = (Element) i.next(); + for (Element voteCountingResultElm : listVoteCountingResults) { VoteCountingResultDTO voteCountingResult = new VoteCountingResultDTO(); voteCountingResult.setIdPoll(voteCountingResultElm - .getAttributeValue("idPoll")); + .getAttributeValue("idPoll")); voteCountingResult.setNbVotes(Integer - .parseInt(voteCountingResultElm.getChild("nbVotes") - .getValue())); + .parseInt(voteCountingResultElm.getChild("nbVotes") + .getValue())); voteCountingResult.setChoiceResult(voteCountingResultElm.getChild( "choiceResult").getValue()); voteCountingResult.setByGroup(Boolean - .parseBoolean((voteCountingResultElm.getChild("isByGroup") - .getValue()))); + .parseBoolean(voteCountingResultElm.getChild("isByGroup") + .getValue())); Element choicesElm = voteCountingResultElm.getChild("choices"); List<Element> listChoices = choicesElm.getChildren("choice"); - List vectorChoices = loadChoices(listChoices); + List<ChoiceDTO> vectorChoices = loadChoices(listChoices); voteCountingResult.setChoices(vectorChoices); vectorVoteCountingResults.add(voteCountingResult); } @@ -596,17 +573,15 @@ return vectorVoteCountingResults; } - private List loadChoices(List<Element> listChoices) { - List vectorChoices = new ArrayList<ChoiceDTO>(); + private List<ChoiceDTO> loadChoices(List<Element> listChoices) { + List<ChoiceDTO> vectorChoices = new ArrayList<ChoiceDTO>(); - Iterator i = listChoices.listIterator(); - while (i.hasNext()) { - Element choiceElm = (Element) i.next(); + for (Element choiceElm : listChoices) { ChoiceDTO choice = new ChoiceDTO(choiceElm.getAttribute("idChoice") - .getName(), Double.parseDouble(choiceElm.getAttribute( + .getName(), Double.parseDouble(choiceElm.getAttribute( "value").getValue()), Double.parseDouble(choiceElm - .getChild("percentage").getValue()), Integer - .parseInt((choiceElm.getChild("nbVotes").getValue()))); + .getChild("percentage").getValue()), Integer + .parseInt(choiceElm.getChild("nbVotes").getValue())); vectorChoices.add(choice); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCounting.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCounting.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCounting.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -49,7 +49,7 @@ */ public interface ServiceVoteCounting { - public VoteCountingResultDTO executeVoteCounting(PollDTO poll); + VoteCountingResultDTO executeVoteCounting(PollDTO poll); - public VoteCountingResultDTO executeGroupCounting(PollDTO poll); + VoteCountingResultDTO executeGroupCounting(PollDTO poll); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -89,8 +89,8 @@ * Constructeur */ public ServiceVoteCountingImpl() { - this.currentIdGroup = ""; - this.context = null; + currentIdGroup = ""; + context = null; } /** @@ -101,8 +101,8 @@ */ @Override public VoteCountingResultDTO executeVoteCounting(PollDTO poll) { - this.isByGroup = false; - return this.execute(poll); + isByGroup = false; + return execute(poll); } /** @@ -113,8 +113,8 @@ */ @Override public VoteCountingResultDTO executeGroupCounting(PollDTO poll) { - this.isByGroup = true; - return this.execute(poll); + isByGroup = true; + return execute(poll); } /** @@ -130,8 +130,8 @@ } // Création et remplissage du contexte - this.createContext(poll.getVoteCounting()); - this.fillContext(poll); + createContext(poll.getVoteCounting()); + fillContext(poll); // Execution if (!context.executeCounting()) { @@ -141,9 +141,9 @@ VoteCountingResultDTO result = new VoteCountingResultDTO(); result.setNbVotes(Utils.calculateNbVotes(poll.getVotingGroups(), - this.isByGroup)); + isByGroup)); result.setTypeVoteCounting(poll.getVoteCounting()); - result.setByGroup(this.isByGroup); + result.setByGroup(isByGroup); result.setIdPoll(poll.getPollId()); result.setChoices(resChoices); return result; @@ -155,7 +155,7 @@ * @param type : type de dépouillement */ private void createContext(VoteCountingType type) { - Method method = null; + Method method; switch (type) { case NORMAL: method = new StandardMethod(); @@ -172,7 +172,7 @@ default: method = new StandardMethod(); } - this.context = new Context(method, this.isByGroup); + context = new Context(method, isByGroup); } /** @@ -186,14 +186,14 @@ } for (PollChoiceDTO choice : poll.getChoices()) { if (choice.isHidden()) { - this.context.addHiddenChoice(choice); + context.addHiddenChoice(choice); } else { - this.context.addChoice(choice); + context.addChoice(choice); } } for (Object o : poll.getVotingGroups()) { VotingGroupDTO group = (VotingGroupDTO) o; - this.routeGroup(group); + routeGroup(group); } } @@ -207,11 +207,11 @@ log.debug("Ajout group : " + group.getIdGroup() + " _ weight=" + group.getWeight()); } - this.context.addGroup(group.getIdGroup(), group.getWeight()); + context.addGroup(group.getIdGroup(), group.getWeight()); for (Object o : group.getVotingPersons()) { VotingPersonDTO person = (VotingPersonDTO) o; - this.currentIdGroup = group.getIdGroup(); - this.routePerson(person); + currentIdGroup = group.getIdGroup(); + routePerson(person); } } @@ -226,7 +226,7 @@ + person.getWeight()); } for (VoteToChoiceDTO vote : person.getChoices()) { - this.addVoteToContext(vote, person.getWeight(), person + addVoteToContext(vote, person.getWeight(), person .getVotingId()); } } @@ -243,8 +243,8 @@ log.debug("Ajout vote : " + vote.getValue() + " _ choice=" + vote.getIdChoice()); } - Choice choice = this.context.getChoice(vote.getIdChoice()); - Group group = choice.getGroup(this.currentIdGroup); + Choice choice = context.getChoice(vote.getIdChoice()); + Group group = choice.getGroup(currentIdGroup); group.addVote(vote.getValue(), weight, votingID); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/ListBehavior.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/ListBehavior.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/ListBehavior.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -47,5 +47,5 @@ * @version $Id$ */ public interface ListBehavior<T> { - public List<T> list(); + List<T> list(); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/PercentageBehavior.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/PercentageBehavior.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/java/org/chorem/pollen/votecounting/utils/PercentageBehavior.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -45,5 +45,5 @@ * @version $Id$ */ public interface PercentageBehavior { - public double value(); + double value(); } Added: branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties (rev 0) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties 2012-01-24 14:11:32 UTC (rev 3115) @@ -0,0 +1,10 @@ +pollen.choiceType.date=Date +pollen.choiceType.image=Image +pollen.choiceType.text=Text +pollen.pollType.free=Free +pollen.pollType.group=Group +pollen.pollType.restricted=Restricted +pollen.voteCountingType.condorcet=Condorcet +pollen.voteCountingType.normal=Normal +pollen.voteCountingType.number=Number +pollen.voteCountingType.percentage=Percentage Property changes on: branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_en_GB.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties (rev 0) +++ branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties 2012-01-24 14:11:32 UTC (rev 3115) @@ -0,0 +1,10 @@ +pollen.choiceType.date=Date +pollen.choiceType.image=Image +pollen.choiceType.text=Texte +pollen.pollType.free=Libre +pollen.pollType.group=Groupe +pollen.pollType.restricted=Restreint +pollen.voteCountingType.condorcet=Condorcet +pollen.voteCountingType.normal=Normal +pollen.voteCountingType.number=Nombre +pollen.voteCountingType.percentage=Pourcentage Property changes on: branches/pollen-2.0-beta-1/pollen-domain/src/main/resources/i18n/pollen-domain_fr_FR.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -53,12 +53,12 @@ * * @return le sondage */ - public PollDTO createPoll(); + PollDTO createPoll(); /** * Création d'un sondage de test. * * @return le sondage */ - public PollDTO createTestPoll(); + PollDTO createTestPoll(); } Modified: branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2012-01-24 10:08:09 UTC (rev 3114) +++ branches/pollen-2.0-beta-1/pollen-domain/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2012-01-24 14:11:32 UTC (rev 3115) @@ -71,25 +71,25 @@ .getLog(PollDTOCreatorVoteCounting.class); public PollDTOCreatorVoteCounting(int maxchoice, VoteCountingType typeCount) { - this.maxChoice = maxchoice; - this.maxChoiceNb = this.getAleaNb(this.maxChoice); + maxChoice = maxchoice; + maxChoiceNb = getAleaNb(maxChoice); this.typeCount = typeCount; } @Override public PollDTO createPoll() { if (log.isDebugEnabled()) { - log.debug("Création du sondage : " + "maxchoice=" + this.maxChoice - + " _ " + "maxchoiceByPerson=" + this.maxChoiceNb + " _ " - + "typeVoteCounting=" + this.typeCount); + log.debug("Création du sondage : " + "maxchoice=" + maxChoice + + " _ " + "maxchoiceByPerson=" + maxChoiceNb + " _ " + + "typeVoteCounting=" + typeCount); } PollDTO poll = new PollDTO("RandomPoll"); - poll.setMaxChoiceNb(this.maxChoiceNb); + poll.setMaxChoiceNb(maxChoiceNb); poll.setPollType(PollType.FREE); - poll.setVoteCounting(this.typeCount); - poll.setChoices(this.createChoices()); - poll.setVotingGroups(this.createGroups()); + poll.setVoteCounting(typeCount); + poll.setChoices(createChoices()); + poll.setVotingGroups(createGroups()); return poll; } @@ -98,7 +98,7 @@ log.debug("Création des choix : "); } List<PollChoiceDTO> choices = new ArrayList<PollChoiceDTO>(); - for (int i = 1; i <= this.maxChoice; i++) { + for (int i = 1; i <= maxChoice; i++) { choices.add(new PollChoiceDTO(String.valueOf(i))); if (log.isDebugEnabled()) { log.debug("Choice : id=" + i); @@ -109,19 +109,19 @@ private List<VotingGroupDTO> createGroups() { List<VotingGroupDTO> groups = new ArrayList<VotingGroupDTO>(); - int nbGroups = this.getAleaNb(3); + int nbGroups = getAleaNb(3); if (log.isDebugEnabled()) { log.debug("Création des groupes : " + nbGroups); } int oldNbPersons = 1; for (int i = 1; i <= nbGroups; i++) { - double weight = this.getAleaWeight(); + double weight = getAleaWeight(); VotingGroupDTO group = new VotingGroupDTO(Integer.toString(i), weight); if (log.isDebugEnabled()) { log.debug("_Groupe : id=" + i + " _ weight=" + weight); } - group.setVotingPersons(this.createPersons(oldNbPersons)); + group.setVotingPersons(createPersons(oldNbPersons)); oldNbPersons += group.getVotingPersons().size(); groups.add(group); } @@ -130,18 +130,18 @@ private List<VotingPersonDTO> createPersons(int next) { List<VotingPersonDTO> persons = new ArrayList<VotingPersonDTO>(); - int nbPersons = this.getAleaNb(3); + int nbPersons = getAleaNb(3); if (log.isDebugEnabled()) { log.debug("_Création des votants : " + nbPersons); } for (int i = 1; i <= nbPersons; i++) { - double weight = this.getAleaWeight(); + double weight = getAleaWeight(); VotingPersonDTO person = new VotingPersonDTO("person" + next, weight); if (log.isDebugEnabled()) { log.debug("__Votant : id=person" + next + " _ " + weight); } - person.setChoices(this.createVotes()); + person.setChoices(createVotes()); persons.add(person); next++; } @@ -150,14 +150,14 @@ private List<VoteToChoiceDTO> createVotes() { List<VoteToChoiceDTO> choices = new ArrayList<VoteToChoiceDTO>(); - int nbchoice = this.getAleaNb(this.maxChoiceNb); + int nbchoice = getAleaNb(maxChoiceNb); if (log.isDebugEnabled()) { log.debug("__Création du vote : " + nbchoice); } List<Integer> choicesId = new ArrayList<Integer>(); for (int i = 1; i <= nbchoice; i++) { - int choiceId = this.getAleaNb(this.maxChoice, choicesId); - int value = this.getAleaValue(nbchoice); + int choiceId = getAleaNb(maxChoice, choicesId); + int value = getAleaValue(nbchoice); choicesId.add(new Integer(choiceId)); choices.add(new VoteToChoiceDTO(choiceId, value)); if (log.isDebugEnabled()) { @@ -174,7 +174,7 @@ private int getAleaNb(int max, List<Integer> prevs) { int val = 0; do { - val = this.getAleaNb(max); + val = getAleaNb(max); } while (findInteger(prevs, val)); return val; } @@ -192,7 +192,7 @@ } private int getAleaValue(int nbchoice) { - switch (this.typeCount) { + switch (typeCount) { case NORMAL: return 1; case PERCENTAGE: