Author: schorlet Date: 2010-01-11 17:17:56 +0100 (Mon, 11 Jan 2010) New Revision: 2837 Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java trunk/pollen-ui/src/main/webapp/poll/Results.tml trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/NumberMethod.java trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java Log: correction de bugs ajout du calcul du r?\195?\169sultats pour les groupes lors d'un sondage par nombre Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-01-11 12:46:59 UTC (rev 2836) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-01-11 16:17:56 UTC (rev 2837) @@ -119,7 +119,6 @@ * * La map est indexée par les noms de choix. */ - @Persist @Property(write = false) private Map<String, List<String>> choicesResults; @@ -299,7 +298,7 @@ public boolean isGroupPoll() { return poll.getPollType() == PollType.GROUP; } - + /** Retourne le message d'aide correspondant au type de sondage. */ public String getHelpMessage() { switch (poll.getVoteCounting()) { Modified: trunk/pollen-ui/src/main/webapp/poll/Results.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/Results.tml 2010-01-11 12:46:59 UTC (rev 2836) +++ trunk/pollen-ui/src/main/webapp/poll/Results.tml 2010-01-11 16:17:56 UTC (rev 2837) @@ -106,15 +106,17 @@ </div> <!-- Diagramme par choix --> - <div id="resultChart"> - <div> - <t:loop source="choicesResults.entrySet()" value="choicesResult"> - <t:chart title="${choicesResult.key}" width="400" height="300" - values="choicesResult.value" type="${type}" - t:subtitles="subtitles.get(choicesResult.key)" /> - </t:loop> + <t:if test="choicesResults"> + <div id="resultChart"> + <div> + <t:loop source="choicesResults.entrySet()" value="choicesResult"> + <t:chart title="${choicesResult.key}" width="400" height="300" + values="choicesResult.value" type="${type}" + t:subtitles="subtitles.get(choicesResult.key)" /> + </t:loop> + </div> </div> - </div> + </t:if> <!-- Classement --> <t:remove> Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/NumberMethod.java =================================================================== --- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/NumberMethod.java 2010-01-11 12:46:59 UTC (rev 2836) +++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/NumberMethod.java 2010-01-11 16:17:56 UTC (rev 2837) @@ -14,9 +14,9 @@ @Override public void executeCounting(List<Choice> choices, boolean byGroup) { calculateGroups(choices); -// if (byGroup) { -// calculateChoicesByGroup(choices); -// } + if (byGroup) { + calculateChoicesByGroup(choices); + } } public void calculateGroups(List<Choice> choices) { Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java =================================================================== --- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java 2010-01-11 12:46:59 UTC (rev 2836) +++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/StandardMethod.java 2010-01-11 16:17:56 UTC (rev 2837) @@ -79,21 +79,27 @@ public Map<String, List<String>> getChoosenChoicesByGroup( List<Choice> choices) { Map<String, List<String>> mapGroupsChoosenChoices = new HashMap<String, List<String>>(); - for (Group group : choices.get(0).getGroups()) { - double maxValue = 0.; - List<String> choosenChoicesId = new ArrayList<String>(); - for (Choice choice : choices) { - Group curr = choice.getGroup(group.getIdGroup()); - if (curr.getValue() > maxValue) { - maxValue = curr.getValue(); - choosenChoicesId.clear(); + + if (choices != null && choices.size() > 0) { + for (Group group : choices.get(0).getGroups()) { + double maxValue = 0.; + List<String> choosenChoicesId = new ArrayList<String>(); + + for (Choice choice : choices) { + Group curr = choice.getGroup(group.getIdGroup()); + if (curr.getValue() > maxValue) { + maxValue = curr.getValue(); + choosenChoicesId.clear(); + } + if (curr.getValue() != 0 && maxValue == curr.getValue()) { + choosenChoicesId.add(choice.getIdChoice()); + } } - if (curr.getValue() != 0 && maxValue == curr.getValue()) { - choosenChoicesId.add(choice.getIdChoice()); - } + + mapGroupsChoosenChoices.put(group.getIdGroup(), choosenChoicesId); } - mapGroupsChoosenChoices.put(group.getIdGroup(), choosenChoicesId); } + return mapGroupsChoosenChoices; }