Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
February 2012
- 1 participants
- 27 discussions
r3153 - in branches/pollen-1.2.6-struts2: . pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-services/src/main/resources/i18n pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 29 Feb '12
by tchemit@users.chorem.org 29 Feb '12
29 Feb '12
Author: tchemit
Date: 2012-02-29 12:08:39 +0100 (Wed, 29 Feb 2012)
New Revision: 3153
Url: http://chorem.org/repositories/revision/pollen/3153
Log:
updates to mavenpom 3.1.1
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pom.xml
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-28 21:34:08 UTC (rev 3152)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-29 11:08:39 UTC (rev 3153)
@@ -117,9 +117,10 @@
} else {
result = service.executeVoteCounting(dto);
}
+ ResultDAO daoResult = getDAO(Result.class);
+
for (ChoiceDTO choice : result.getChoices()) {
- ResultDAO daoResult = getDAO(Result.class);
Result eResult = create(daoResult);
Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
@@ -133,6 +134,8 @@
eResult.setVoteCountingType(result.getTypeVoteCounting());
}
+ commitTransaction("Could not generate poll result");
+
// Conversion et trie des résultats
List<PollResult> list = createPollResults(poll);
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-28 21:34:08 UTC (rev 3152)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-29 11:08:39 UTC (rev 3153)
@@ -3,11 +3,11 @@
lastName-label=Nom
login-label=Identifiant
name-label=Nom
+pollen.common.anonymous=Vote anonyme
pollen.common.numberVote-average=Moyenne des nombres
pollen.common.numberVote-blank-votes=Nombre de votes blancs
pollen.common.numberVote-total=Somme des nombres
pollen.common.numberVote-total-votes=Nombre total de votes
-pollen.common.anonymous=Vote anonyme
pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%2$s\nModération des votes \: \n%3$s\nPage de modification \: \n%4$s
pollen.email.createPoll.subject=[Pollen] Création d'un sondage (%1$s)
pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de créer un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant \: %2$s\nMot de passe \: %3$s\n\nVous pouvez dès maintenant gérer vos sondages en vous identifiant sur le site \: \n%4$s
@@ -23,4 +23,3 @@
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
pollen.info.admin.exists=Le super admin existe déjà
-
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-28 21:34:08 UTC (rev 3152)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-29 11:08:39 UTC (rev 3153)
@@ -103,18 +103,6 @@
return "Vote";
}
-// public final void setPollId(String pollId) {
-// this.pollId = pollId;
-// }
-//
-// public void setAccountId(String accountId) {
-// this.accountId = accountId;
-// }
-
-// public String getPollAccountId() {
-// return pollAccountId;
-// }
-
public final Poll getPoll() {
return poll;
}
@@ -175,11 +163,9 @@
if (poll != null) {
loadPollAccount();
-
loadPollResults();
loadPollComments();
-
PollFeedService pollFeedService = newService(PollFeedService.class);
feedFileExisting = pollFeedService.isFeedExists(poll);
Modified: branches/pollen-1.2.6-struts2/pom.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pom.xml 2012-02-28 21:34:08 UTC (rev 3152)
+++ branches/pollen-1.2.6-struts2/pom.xml 2012-02-29 11:08:39 UTC (rev 3153)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.1.1-SNAPSHOT</version>
+ <version>3.1.1</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r3152 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-services/src/main/resources/i18n pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/i18n pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 28 Feb '12
by tchemit@users.chorem.org 28 Feb '12
28 Feb '12
Author: tchemit
Date: 2012-02-28 22:34:08 +0100 (Tue, 28 Feb 2012)
New Revision: 3152
Url: http://chorem.org/repositories/revision/pollen/3152
Log:
continue results page (do number charts) + move some code to service
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-28 21:34:08 UTC (rev 3152)
@@ -23,7 +23,10 @@
*/
package org.chorem.pollen.services.impl;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.bean.PollResult;
@@ -32,7 +35,6 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.ResultDAO;
-import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.PollenServiceSupport;
@@ -43,13 +45,15 @@
import org.chorem.pollen.votecounting.services.ServiceVoteCounting;
import org.chorem.pollen.votecounting.services.ServiceVoteCountingImpl;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.Collection;
-import java.util.Date;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
+import static org.nuiton.i18n.I18n.l_;
+
/**
* Deals with poll results.
*
@@ -61,29 +65,11 @@
/** log. */
private static final Log log = LogFactory.getLog(PollResultsService.class);
- public PollResultList getAllResults(String pollId) {
- return getResults(pollId, null, false, false);
- }
-
- public PollResultList getResultsByVoteCounting(String pollId,
- VoteCountingType voteCounting) {
- return getResults(pollId, voteCounting, false, false);
- }
-
public PollResultList getGroupResults(String pollId) {
- return getResults(pollId, null, true, true);
+ return generateResults(pollId, null, true, true);
}
public PollResultList getNormalResults(String pollId) {
- return getResults(pollId, null, true, false);
- }
-
- public List<PollResult> getNormalPollResults(String pollId) {
- PollResultList results = getResults(pollId, null, true, false);
- return results.getPollResults();
- }
-
- public PollResultList generateNormalResults(String pollId) {
return generateResults(pollId, null, true, false);
}
@@ -183,123 +169,19 @@
}
}
- PollResultList resultListDTO = new PollResultList();
- resultListDTO.setPollResults(list);
- resultListDTO.setVoteCountingResult(result);
-
- return resultListDTO;
+ PollResultList resultList = new PollResultList();
+ resultList.setPollResults(list);
+ resultList.setVoteCountingResult(result);
+ return resultList;
}
/**
- * Récupère les résultats d'un sondage (sans rien dépouiller).
- *
- * @param pollId le sondage
- * @param voteCounting type de dépouillement
- * @param byGroup résultats par groupe
- * @param groupOnly résultats uniquement par groupe
- * @return les résultats du sondage
- */
- private PollResultList getResults(String pollId,
- VoteCountingType voteCounting,
- boolean byGroup,
- boolean groupOnly) {
-
- PollService pollService = newService(PollService.class);
- Poll poll = pollService.getPollByPollId(pollId);
-
-// DataResultConverter converter = new DataResultConverter(transaction);
- if (log.isDebugEnabled()) {
- log.debug(poll.getPollId() + " (" + voteCounting
- + ") has results: " + hasResults(poll, voteCounting));
- }
-
- // Dépouillement du sondage.
- // S'il n'existe pas de résultats ou si le sondage est encore ouvert.
- //if (!hasResults(ePoll, voteCounting) || !ePoll.getIsClosed()) {
- PollDTO dto = pollService.createPollDTOForVoteCounting(poll);
-
- if (voteCounting != null) {
- dto.setVoteCounting(voteCounting);
- }
-
-// // clear result (they will be regenerated ! (a big shame))
-// poll.clearResult();
-
-// ServiceVoteCounting service = new ServiceVoteCountingImpl();
-//
-// VoteCountingResultDTO result;
-//
-// if (PollType.GROUP == poll.getPollType()) {
-// result = service.executeGroupCounting(dto);
-// } else {
-// result = service.executeVoteCounting(dto);
-// }
-// for (ChoiceDTO choice : result.getChoices()) {
-//
-// ResultDAO daoResult = getDAO(Result.class);
-// Result eResult = create(daoResult);
-//
-// Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
-//
-// poll.addResult(eResult);
-//
-// eResult.setName(eChoice.getName());
-// eResult.setByGroup(result.isByGroup());
-// eResult.setPoll(poll);
-// eResult.setResultValue(String.valueOf(choice.getValue()));
-// eResult.setVoteCountingType(result.getTypeVoteCounting());
-// }
-
- // Conversion et trie des résultats
- List<PollResult> list = createPollResults(poll);
-
- VoteCountingType voteCountingType = poll.getVoteCountingType();
-
- Iterator<PollResult> it = list.iterator();
- while (it.hasNext()) {
- PollResult currentResult = it.next();
-
- // Cas d'un dépouillement particulier
- // Suppression des resultats qui ne sont pas de se dépouillement
- if (voteCounting != null
- && currentResult.getVoteCountingType() != voteCounting) {
- it.remove();
- }
-
- // Cas d'un sondage de type GROUP avec filtre
- if (byGroup) {
-
- // Filtre group : Suppression resultats non group
- if (groupOnly && !currentResult.isByGroup()) {
- it.remove();
- }
-
- // Filtre non group : Suppression resultats group
- else if (!groupOnly && currentResult.isByGroup()) {
- it.remove();
- }
-
- // Suppression des autres resultats de depouillements differents
- if (currentResult.getVoteCountingType() != voteCountingType) {
- it.remove();
- }
- }
- }
-
- PollResultList resultListDTO = new PollResultList();
- resultListDTO.setPollResults(list);
- resultListDTO.setVoteCountingResult(null);
-
- return resultListDTO;
- }
-
- /**
* Retourne la liste des résultats d'un sondage sous forme de DTOs.
*
* @param poll le sondage (entitée Poll)
* @return la liste des DTO Result
*/
- public List<PollResult> createPollResults(Poll poll) {
+ protected List<PollResult> createPollResults(Poll poll) {
List<PollResult> results = Lists.newArrayList();
for (Result res : poll.getResult()) {
PollResult dto = new PollResult();
@@ -318,34 +200,6 @@
return results;
}
- /**
- * Retourne une chaîne contenant les résultats du sondage.
- *
- * @param poll le sondage
- * @param results les résultats du sondage
- * @return les résultats sous forme de chaine de caractères
- */
- public String getResultsAsString(Poll poll, Collection<Result> results) {
-
- DateFormat dateFormat = new SimpleDateFormat();
- StringBuilder res = new StringBuilder("");
- Iterator<Result> it = results.iterator();
- while (it.hasNext()) {
- Result result = it.next();
- if (poll.getChoiceType() == ChoiceType.DATE) {
- Date date = new Date(Long.parseLong(result.getName()));
- res.append(dateFormat.format(date));
- } else {
- res.append(result.getName());
- }
- res.append("=").append(removeTrailing0(result.getResultValue()));
- if (it.hasNext()) {
- res.append(", ");
- }
- }
- return res.toString();
- }
-
public String getResultValue(Choice choice, Collection<PollResult> results) {
String val = "";
@@ -358,7 +212,124 @@
return val;
}
+ public List<PollResult> createNumberVoteCountingResult(PollResultList resultListDTO,
+ Multimap<String, String> choicesResults,
+ Multimap<String, String> subtitles) {
+ Preconditions.checkNotNull(resultListDTO);
+ Preconditions.checkNotNull(choicesResults);
+ Preconditions.checkNotNull(subtitles);
+ List<PollResult> results = resultListDTO.getPollResults();
+
+ /*
+ * liste des vrais choix (les choix pas cachés).
+ * cette variable sera affectée à la variable results
+ */
+ List<PollResult> results2 = Lists.newArrayList();
+
+ // Ajout des résultats des choix cachés
+ for (PollResult result : results) {
+ if (result.isHidden()) {
+ String name = result.getName();
+ int indexOf = name.indexOf('#');
+ String choice = name.substring(
+ NumberMethod.HIDDEN_PREFIX.length(), indexOf);
+
+ String votingId = name.substring(indexOf + 1);
+ String value = result.getValue();
+
+ choicesResults.put(choice, votingId);
+ choicesResults.put(choice, value);
+
+ } else {
+ results2.add(result);
+ }
+ }
+
+ Locale locale = getLocale();
+
+ // Récupération du choix correspondant au résultat
+ VoteCountingResultDTO voteCountingResult = resultListDTO
+ .getVoteCountingResult();
+
+ for (String choiceName : choicesResults.keySet()) {
+ Collection<String> values = choicesResults.get(choiceName);
+
+ for (ChoiceDTO choice : voteCountingResult.getChoices()) {
+ if (choiceName.equals(choice.getName())) {
+ subtitles.put(
+ choiceName,
+ l_(locale, "pollen.common.numberVote-total"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getValue()));
+
+ subtitles.put(
+ choiceName,
+ l_(locale, "pollen.common.numberVote-average"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getAverage()));
+
+ subtitles.put(
+ choiceName,
+ l_(locale, "pollen.common.numberVote-blank-votes"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getNbBlankVotes()));
+
+ subtitles.put(
+ choiceName,
+ l_(locale, "pollen.common.numberVote-total-votes"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(values.size() / 2));
+ break;
+ }
+ }
+ }
+
+ if (results2.size() == 1) {
+ results2.remove(0);
+ }
+ return results2;
+ }
+
+ public List<PollResult> getTopRanking(List<PollResult> results) {
+ List<PollResult> ranking = Lists.newArrayList(results);
+
+ Collections.sort(ranking, new Comparator<PollResult>() {
+ @Override
+ public int compare(PollResult o1, PollResult o2) {
+ Double result1 = Double.parseDouble(o1.getValue());
+ Double result2 = Double.parseDouble(o2.getValue());
+ int comp = 0; // résultat de la comparaison
+
+ if (result1 > result2) {
+ comp = -1;
+ } else if (result1 < result2) {
+ comp = 1;
+ }
+ if (comp == 0) {
+ comp = o1.getName().compareTo(o2.getName());
+ }
+ return comp;
+ }
+ });
+
+ List<PollResult> topRanking = Lists.newArrayList();
+
+ if (CollectionUtils.isNotEmpty(ranking)) {
+ String winValue = ranking.get(0).getValue();
+ for (PollResult r : ranking) {
+ if (winValue.equals(r.getValue())) {
+ topRanking.add(r);
+ }
+ }
+ }
+ return topRanking;
+ }
+
/**
* Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un
* double : 1,0 -> 1 et 1,2 -> 1,2.
@@ -366,14 +337,13 @@
* @param val le nombre
* @return le nombre sans 0 final
*/
- private String removeTrailing0(String val) {
+ protected String removeTrailing0(String val) {
if (val.endsWith(".0")) {
val = val.substring(0, val.indexOf('.'));
}
return val;
}
-
/**
* Création des résultats de sondage à partir d'un dto de résultats de
* sondage.
@@ -406,7 +376,7 @@
* @param type type de dépouillement
* @return vrai si le sondage a des résultats
*/
- private boolean hasResults(Poll poll, VoteCountingType type) {
+ protected boolean hasResults(Poll poll, VoteCountingType type) {
boolean hasresult = false;
if (!poll.isResultEmpty()) {
@@ -422,10 +392,121 @@
}
}
}
-
return hasresult;
}
+// public PollResultList getAllResults(String pollId) {
+// return getResults(pollId, null, false, false);
+// }
+//
+// public PollResultList getResultsByVoteCounting(String pollId,
+// VoteCountingType voteCounting) {
+// return getResults(pollId, voteCounting, false, false);
+// }
+//
+// /**
+// * Récupère les résultats d'un sondage (sans rien dépouiller).
+// *
+// * @param pollId le sondage
+// * @param voteCounting type de dépouillement
+// * @param byGroup résultats par groupe
+// * @param groupOnly résultats uniquement par groupe
+// * @return les résultats du sondage
+// */
+// private PollResultList getResults(String pollId,
+// VoteCountingType voteCounting,
+// boolean byGroup,
+// boolean groupOnly) {
+//
+// PollService pollService = newService(PollService.class);
+// Poll poll = pollService.getPollByPollId(pollId);
+//
+//// DataResultConverter converter = new DataResultConverter(transaction);
+// if (log.isDebugEnabled()) {
+// log.debug(poll.getPollId() + " (" + voteCounting
+// + ") has results: " + hasResults(poll, voteCounting));
+// }
+//
+// // Dépouillement du sondage.
+// // S'il n'existe pas de résultats ou si le sondage est encore ouvert.
+// //if (!hasResults(ePoll, voteCounting) || !ePoll.getIsClosed()) {
+// PollDTO dto = pollService.createPollDTOForVoteCounting(poll);
+//
+// if (voteCounting != null) {
+// dto.setVoteCounting(voteCounting);
+// }
+//
+//// // clear result (they will be regenerated ! (a big shame))
+//// poll.clearResult();
+//
+//// ServiceVoteCounting service = new ServiceVoteCountingImpl();
+////
+//// VoteCountingResultDTO result;
+////
+//// if (PollType.GROUP == poll.getPollType()) {
+//// result = service.executeGroupCounting(dto);
+//// } else {
+//// result = service.executeVoteCounting(dto);
+//// }
+//// for (ChoiceDTO choice : result.getChoices()) {
+////
+//// ResultDAO daoResult = getDAO(Result.class);
+//// Result eResult = create(daoResult);
+////
+//// Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+////
+//// poll.addResult(eResult);
+////
+//// eResult.setName(eChoice.getName());
+//// eResult.setByGroup(result.isByGroup());
+//// eResult.setPoll(poll);
+//// eResult.setResultValue(String.valueOf(choice.getValue()));
+//// eResult.setVoteCountingType(result.getTypeVoteCounting());
+//// }
+//
+// // Conversion et trie des résultats
+// List<PollResult> list = createPollResults(poll);
+//
+// VoteCountingType voteCountingType = poll.getVoteCountingType();
+//
+// Iterator<PollResult> it = list.iterator();
+// while (it.hasNext()) {
+// PollResult currentResult = it.next();
+//
+// // Cas d'un dépouillement particulier
+// // Suppression des resultats qui ne sont pas de se dépouillement
+// if (voteCounting != null
+// && currentResult.getVoteCountingType() != voteCounting) {
+// it.remove();
+// }
+//
+// // Cas d'un sondage de type GROUP avec filtre
+// if (byGroup) {
+//
+// // Filtre group : Suppression resultats non group
+// if (groupOnly && !currentResult.isByGroup()) {
+// it.remove();
+// }
+//
+// // Filtre non group : Suppression resultats group
+// else if (!groupOnly && currentResult.isByGroup()) {
+// it.remove();
+// }
+//
+// // Suppression des autres resultats de depouillements differents
+// if (currentResult.getVoteCountingType() != voteCountingType) {
+// it.remove();
+// }
+// }
+// }
+//
+// PollResultList resultListDTO = new PollResultList();
+// resultListDTO.setPollResults(list);
+// resultListDTO.setVoteCountingResult(null);
+//
+// return resultListDTO;
+// }
+//
// public String exportPoll(String pollId) {
// TopiaContext transaction = getTransaction();
// try {
@@ -503,4 +584,32 @@
//
// return topiaId;
// }
+
+// /**
+// * Retourne une chaîne contenant les résultats du sondage.
+// *
+// * @param poll le sondage
+// * @param results les résultats du sondage
+// * @return les résultats sous forme de chaine de caractères
+// */
+// public String getResultsAsString(Poll poll, Collection<Result> results) {
+//
+// DateFormat dateFormat = new SimpleDateFormat();
+// StringBuilder res = new StringBuilder("");
+// Iterator<Result> it = results.iterator();
+// while (it.hasNext()) {
+// Result result = it.next();
+// if (poll.getChoiceType() == ChoiceType.DATE) {
+// Date date = new Date(Long.parseLong(result.getName()));
+// res.append(dateFormat.format(date));
+// } else {
+// res.append(result.getName());
+// }
+// res.append("=").append(removeTrailing0(result.getResultValue()));
+// if (it.hasNext()) {
+// res.append(", ");
+// }
+// }
+// return res.toString();
+// }
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-02-28 21:34:08 UTC (rev 3152)
@@ -1,154 +1,15 @@
add=Add
-addChoice-choiceDate-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})?
-addChoice-choiceDate-regexp-message=Date does not match pattern 12/31/2000 12\:59 AM.
-addChoice-choiceDate-required-message=You must provide a choice.
-addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-addChoice-choiceImage-regexp-message=The image must be a JPG, GIF or PNG file.
-addChoice-choiceImage-required-message=You must provide a choice.
-addChoice-choiceText-required-message=You must provide a choice.
-cancel=Cancel
-choiceDate-label=Date and time
-choiceDescription-label=Description
-choiceImage-label=Image
-choiceText-label=Choice
create=Create
-creatorEmail_msg=You had just created the new poll\: "%s".\nYou can access to this poll by following the links below.\n\nVote page\: \n%s\nEdit page\: \n%s
-creatorEmail_subject=[Pollen] Poll creation (%s)
delete=Delete
edit=Edit
-email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
-email-regexp-message=Invalid email
help=Help
-load=Load
-login-required-message=You must provide a username
-ok=Ok
-pollFeed_choiceContent=%s
-pollFeed_choiceTitle=New choice \: %s
-pollFeed_commentContent=%s
-pollFeed_commentTitle=New comment from %s
-pollFeed_createContent=
-pollFeed_createTitle=Poll created by %s
-pollFeed_desc=%s
-pollFeed_title=Pollen \: %s
-pollFeed_voteContent=Poll state \: %s
-pollFeed_voteTitle=New vote from %s
-pollen.common.anonymous=
+pollen.common.anonymous=Anonymous vote
+pollen.common.numberVote-average=Average of numbers
+pollen.common.numberVote-blank-votes=Number of blank votes
+pollen.common.numberVote-total=Sum of numbers
+pollen.common.numberVote-total-votes=Total votes
pollen.email.userRegister.content=Welcome %1$s. You had just created an account on the web application Pollen.\n\nLogin\: %2$s\nPassword\: %3$s\n\nYou can now manage your polls by logging on the website \: \n%4$s
pollen.email.userRegister.subject=[Pollen] Confirmation of account creation %s
-pollen.error.context.close=
-pollen.error.context.getRootContext=
-pollen.error.context.parse=
-pollen.error.context.rollback=
-pollen.error.context.start=
-pollen.error.context.stop=
-pollen.error.encodePassword=
-pollen.error.serviceEmail.createEmail=
-pollen.error.serviceEmail.getNewEmail=
-pollen.error.serviceEmail.sendEmail=
-pollen.error.serviceFavorite.createFavoriteList=
-pollen.error.serviceFavorite.createFavoriteParticipant=
-pollen.error.serviceFavorite.deleteFavoriteList=
-pollen.error.serviceFavorite.deleteFavoriteParticipant=
-pollen.error.serviceFavorite.getFavoriteLists=
-pollen.error.serviceFavorite.getFavoriteParticipant=
-pollen.error.serviceFavorite.getFavoriteParticipants=
-pollen.error.serviceFavorite.getNbFavoriteParticipants=
-pollen.error.serviceFavorite.getNewFavoriteList=
-pollen.error.serviceFavorite.getNewFavoriteParticipant=
-pollen.error.serviceFavorite.updateFavoriteParticipant=
-pollen.error.serviceList.createAccountForPersonList=
-pollen.error.serviceList.deleteAccountFromPersonList=
-pollen.error.serviceMail.sendEmail=
-pollen.error.servicePoll.addComment=
-pollen.error.servicePoll.canAdminPoll=
-pollen.error.servicePoll.createChoice=
-pollen.error.servicePoll.createComment=
-pollen.error.servicePoll.createPoll=
-pollen.error.servicePoll.createUpdateVote=
-pollen.error.servicePoll.delete=
-pollen.error.servicePoll.deleteChoice=
-pollen.error.servicePoll.deleteComment=
-pollen.error.servicePoll.deletePoll=
-pollen.error.servicePoll.deleteVote=
-pollen.error.servicePoll.getAllPolls=
-pollen.error.servicePoll.getComments=
-pollen.error.servicePoll.getNbComments=
-pollen.error.servicePoll.getNbPollsByUser=
-pollen.error.servicePoll.getNbTotalPolls=
-pollen.error.servicePoll.getNewChoice=
-pollen.error.servicePoll.getNewComment=
-pollen.error.servicePoll.getNewPoll=
-pollen.error.servicePoll.getNewPollList=
-pollen.error.servicePoll.getNewPollParticipant=
-pollen.error.servicePoll.getPoll=
-pollen.error.servicePoll.getPollForResults=
-pollen.error.servicePoll.getPollForUpdate=
-pollen.error.servicePoll.getPollForVote=
-pollen.error.servicePoll.getPolls=
-pollen.error.servicePoll.getPollsByUser=
-pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUid \= %1$s and poll with uid \= %2$s
-pollen.error.servicePoll.getRunningPolls=
-pollen.error.servicePoll.getVotes=
-pollen.error.servicePoll.savePoll=
-pollen.error.servicePoll.setPollClosed=
-pollen.error.servicePoll.updatePoll=
-pollen.error.serviceResults.importPoll=
-pollen.error.serviceUser.connect=
-pollen.error.serviceUser.createDefaultAdmin=
-pollen.error.serviceUser.createFavoriteList=
-pollen.error.serviceUser.createFavoriteParticipant=
-pollen.error.serviceUser.createList=
-pollen.error.serviceUser.createUpdateList=
-pollen.error.serviceUser.createUpdateUser=
-pollen.error.serviceUser.createUser=
-pollen.error.serviceUser.deleteFavoriteList=
-pollen.error.serviceUser.deleteFavoriteParticipant=
-pollen.error.serviceUser.deleteList=
-pollen.error.serviceUser.deleteUser=
-pollen.error.serviceUser.getAccounts=
-pollen.error.serviceUser.getFavoriteLists=
-pollen.error.serviceUser.getFavoriteParticipants=
-pollen.error.serviceUser.getNbAccounts=
-pollen.error.serviceUser.getNbFavoriteParticipants=
-pollen.error.serviceUser.getNbUsers=
-pollen.error.serviceUser.getNewAccount=
-pollen.error.serviceUser.getNewFavoriteList=
-pollen.error.serviceUser.getNewFavoriteParticipant=
-pollen.error.serviceUser.getNewList=
-pollen.error.serviceUser.getNewPerson=
-pollen.error.serviceUser.getNewUser=
-pollen.error.serviceUser.getPerson=
-pollen.error.serviceUser.getUsers=
-pollen.error.serviceUser.updateFavoriteParticipant=
-pollen.error.serviceUser.updateUser=
-pollen.error.serviceVote.canVote=
-pollen.error.serviceVote.deleteVote=
-pollen.error.serviceVote.findPollAccount=
-pollen.error.serviceVote.getNbVotes=
-pollen.error.serviceVote.getNewPollAccount=
-pollen.error.serviceVote.getNewVote=
-pollen.error.serviceVote.getPollAccount=
-pollen.error.serviceVote.getVote=
-pollen.error.serviceVote.getVotes=
-pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
-pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
-pollen.error.serviceVote.saveVote=
-pollen.exception.favorite_list_name_exist=
-pollen.exception.favorite_participant_exist=
-pollen.exception.favorite_participant_exist_without_email=
-pollen.exception.load_configuration=
-pollen.exception.participant_doubloons=
-pollen.exception.participant_exist=
-pollen.exception.participant_exist_without_email=
-pollen.exception.poll_exist=
-pollen.exception.poll_not_exist=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
-pollen.exception.smtp_not_available=
-pollen.exception.user_email_exist=
-pollen.exception.user_login_exist=
-pollen.exception.user_not_exist=
-pollen.exception.user_wrong_password=
-pollen.exception.vote_doubloon=
-pollen.exception.vote_not_allowed=
pollen.feed.addChoiceContent=
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
@@ -160,23 +21,8 @@
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Super admin was created with login %1$s
pollen.info.admin.exists=Super admin already exists
-pollen.info.start=Start Pollen
-pollen.info.started=Pollen is started \!
-pollen.info.stop=Stop Pollen
-pollen.text.empty=
-pollen.ui.choice.add.submit=Add
-pollen.ui.choice.add.title=Adding a choice
-pollen.ui.choice.datePattern=MM/dd/yyyy h\:mm a
-pollen.ui.choice.delete.confirm=Are you sure you want to delete this choice ?
-pollen.ui.choice.delete.title=Delete this choice
-pollen.ui.error.upload=An error occurred while uploading files. Maximum size allowed is %$1s per file, and %$2s total.
-pollen.ui.user.cancelEdit=Cancel changes
pollen.ui.user.delete=Delete this user account
-pollen.ui.user.delete.confirmMessage=Are you sure you want to definitively delete this user ?
pollen.ui.user.edit=Edit this user account
-pollen.ui.user.save=Save this user account
-pollen.ui.vote.noPager=%$1d existing votes
-pollen.ui.vote.noVote=Aucune personne n'a encore participé au sondage
reminderEmail_msg=You have not yet voted for the poll "%s".\nYou can still participate with the identifier %s by following this link\: \n%s
reminderEmail_subject=[Pollen] Reminder (%s)
return=Return
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-28 21:34:08 UTC (rev 3152)
@@ -1,158 +1,17 @@
-addChoice-choiceDate-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})?
-addChoice-choiceDate-regexp-message=La date de début doit-être au format 31/12/2000 23\:59.
-addChoice-choiceDate-required-message=Vous devez saisir un choix.
-addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-addChoice-choiceImage-regexp-message=L'image doit-être au format JPG, GIF ou PNG.
-addChoice-choiceImage-required-message=Vous devez saisir un choix.
-addChoice-choiceText-required-message=Vous devez saisir un choix.
-choiceDate-label=Date et heure
-choiceDateField-label=Date et heure
-choiceDateField-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})?
-choiceDateField-regexp-message=La date doit-être au format 31/12/2000 23\:59.
-choiceDescription-label=Description
-choiceImage-label=Image
-choiceImageField-label=Image
-choiceImageField-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-choiceImageField-regexp-message=L'image doit-être au format JPG, GIF ou PNG.
-choiceText-label=Choix
-connectionLegend=Connexion
-date-pattern=dd/MM/yyyy HH\:mm
-editEmail-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
-editEmail-regexp-message=Adresse email invalide.
email-label=Email
-email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
-email-regexp-message=Adresse email invalide.
firstName-label=Prénom
-groupName-label=Nom du groupe
lastName-label=Nom
-listName-label=Nom
-listSelect-label=Liste
login-label=Identifiant
-loginComp-label=Identifiant
-loginComp-required-message=Vous devez entrer votre identifiant.
-loginFailed=Mauvais identifiant ou mot de passe.
-loginSubmit=Me connecter
name-label=Nom
-participantEmail-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
-participantEmail-regexp-message=Adresse email invalide.
-passwordComp-label=Mot de passe
-passwordComp-required-message=Vous devez entrer votre mot de passe.
-pollen.common.anonymous=
+pollen.common.numberVote-average=Moyenne des nombres
+pollen.common.numberVote-blank-votes=Nombre de votes blancs
+pollen.common.numberVote-total=Somme des nombres
+pollen.common.numberVote-total-votes=Nombre total de votes
+pollen.common.anonymous=Vote anonyme
pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%2$s\nModération des votes \: \n%3$s\nPage de modification \: \n%4$s
pollen.email.createPoll.subject=[Pollen] Création d'un sondage (%1$s)
pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de créer un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant \: %2$s\nMot de passe \: %3$s\n\nVous pouvez dès maintenant gérer vos sondages en vous identifiant sur le site \: \n%4$s
pollen.email.userRegister.subject=[Pollen] Confirmation de création du compte %s
-pollen.error.context.close=Erreur lors de la fermeture de la transaction
-pollen.error.context.getRootContext=Erreur lors de la récupération du contexte principale
-pollen.error.context.parse=Erreur lors du parse du fichier de configuration %1$s
-pollen.error.context.rollback=Erreur lors de l'annulation de la transaction
-pollen.error.context.start=Erreur lors du démarrage de l'application
-pollen.error.context.stop=Erreur lors de l'arrêt de l'application
-pollen.error.encodePassword=
-pollen.error.serviceEmail.createEmail=
-pollen.error.serviceEmail.getNewEmail=
-pollen.error.serviceEmail.sendEmail=
-pollen.error.serviceFavorite.createFavoriteList=
-pollen.error.serviceFavorite.createFavoriteParticipant=
-pollen.error.serviceFavorite.deleteFavoriteList=
-pollen.error.serviceFavorite.deleteFavoriteParticipant=
-pollen.error.serviceFavorite.getFavoriteLists=
-pollen.error.serviceFavorite.getFavoriteParticipant=
-pollen.error.serviceFavorite.getFavoriteParticipants=
-pollen.error.serviceFavorite.getNbFavoriteParticipants=
-pollen.error.serviceFavorite.getNewFavoriteList=
-pollen.error.serviceFavorite.getNewFavoriteParticipant=
-pollen.error.serviceFavorite.updateFavoriteParticipant=
-pollen.error.serviceList.createAccountForPersonList=
-pollen.error.serviceList.deleteAccountFromPersonList=
-pollen.error.serviceMail.sendEmail=Erreur lors de l'envoi de l'email sur le serveur %1$s\:%2$d pour %3$s de la part de %4$s
-pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire créé par %1$s pour le sondage %2$s (%3$s)
-pollen.error.servicePoll.canAdminPoll=
-pollen.error.servicePoll.createChoice=
-pollen.error.servicePoll.createComment=
-pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s créé par %2$s
-pollen.error.servicePoll.createUpdateVote=
-pollen.error.servicePoll.deleteChoice=
-pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s)
-pollen.error.servicePoll.deletePoll=Impossible de supprimer le sondage ayant pou identifiant "%1$s"
-pollen.error.servicePoll.deleteVote=
-pollen.error.servicePoll.getAllPolls=
-pollen.error.servicePoll.getComments=
-pollen.error.servicePoll.getNbComments=
-pollen.error.servicePoll.getNbPollsByUser=
-pollen.error.servicePoll.getNbTotalPolls=
-pollen.error.servicePoll.getNewChoice=
-pollen.error.servicePoll.getNewComment=
-pollen.error.servicePoll.getNewPoll=
-pollen.error.servicePoll.getNewPollList=
-pollen.error.servicePoll.getNewPollParticipant=
-pollen.error.servicePoll.getPoll=
-pollen.error.servicePoll.getPollForResults=
-pollen.error.servicePoll.getPollForUpdate=
-pollen.error.servicePoll.getPollForVote=
-pollen.error.servicePoll.getPolls=
-pollen.error.servicePoll.getPollsByUser=
-pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUid \= %1$s and poll with uid \= %2$s
-pollen.error.servicePoll.getRunningPolls=
-pollen.error.servicePoll.getVotes=
-pollen.error.servicePoll.savePoll=
-pollen.error.servicePoll.setPollClosed=
-pollen.error.servicePoll.updatePoll=Impossible de mettre à jour le sondage %1$s (%2$s)
-pollen.error.serviceResults.importPoll=
-pollen.error.serviceUser.connect=Impossible d'établir la connexion pour l'identifiant %1$s et le mot de passe encodé %2$s
-pollen.error.serviceUser.createDefaultAdmin=Impossible de créer l'administrateur par défaut \: %1$s (%2$s)
-pollen.error.serviceUser.createFavoriteList=
-pollen.error.serviceUser.createFavoriteParticipant=
-pollen.error.serviceUser.createList=
-pollen.error.serviceUser.createUpdateList=
-pollen.error.serviceUser.createUpdateUser=Impossible de créer l'utilisateur '%1$s' <%2$s> (admin \= %$3b)
-pollen.error.serviceUser.createUser=
-pollen.error.serviceUser.deleteFavoriteList=
-pollen.error.serviceUser.deleteFavoriteParticipant=
-pollen.error.serviceUser.deleteList=
-pollen.error.serviceUser.deleteUser=
-pollen.error.serviceUser.getAccounts=
-pollen.error.serviceUser.getFavoriteLists=
-pollen.error.serviceUser.getFavoriteParticipants=
-pollen.error.serviceUser.getNbAccounts=
-pollen.error.serviceUser.getNbFavoriteParticipants=
-pollen.error.serviceUser.getNbUsers=
-pollen.error.serviceUser.getNewAccount=
-pollen.error.serviceUser.getNewFavoriteList=
-pollen.error.serviceUser.getNewFavoriteParticipant=
-pollen.error.serviceUser.getNewList=
-pollen.error.serviceUser.getNewPerson=
-pollen.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur.
-pollen.error.serviceUser.getPerson=
-pollen.error.serviceUser.getUsers=
-pollen.error.serviceUser.updateFavoriteParticipant=
-pollen.error.serviceUser.updateUser=
-pollen.error.serviceVote.canVote=
-pollen.error.serviceVote.deleteVote=
-pollen.error.serviceVote.findPollAccount=
-pollen.error.serviceVote.getNbVotes=
-pollen.error.serviceVote.getNewPollAccount=
-pollen.error.serviceVote.getNewVote=
-pollen.error.serviceVote.getPollAccount=
-pollen.error.serviceVote.getVote=
-pollen.error.serviceVote.getVotes=
-pollen.error.serviceVote.getVotesByPoll=
-pollen.error.serviceVote.hasAlreadyVoted=
-pollen.error.serviceVote.saveVote=
-pollen.exception.favorite_list_name_exist=La liste %1$s existe déjà pour l'utilisateur %2$s
-pollen.exception.load_configuration=La configuration n'a pas été chargée correctement \! Veuillez vérifier le démarrage de l'application.
-pollen.exception.participant_doubloons=Les doublons de la liste %1$s ont été ignorés \: %2$s
-pollen.exception.participant_exist=La liste %1$s contient déjà un votant nommé %2$s avec un email %3$s
-pollen.exception.participant_exist_without_email=La liste %1$s contient déjà un votant nommé %2$s avec aucun email
-pollen.exception.poll_exist=
-pollen.exception.poll_not_exist=Il n'y a pas de sondage à cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le complètement dans le champ d'adresse de votre navigateur.
-pollen.exception.smtp_not_available=Impossible d'envoyer un email à %1$s. Serveur smtp indisponible pour l'envoi d'email, veuillez contacter un administrateur.
-pollen.exception.user_email_exist=Un utilisateur est déjà enregistré avec cet email.
-pollen.exception.user_login_exist=Un utilisateur est déjà enregistré avec cet identifiant.
-pollen.exception.user_not_exist=L'identifiant '%1$s' ne correspond à aucun utilisateur connu.
-pollen.exception.user_wrong_password=Le mot de passe renseigné est incorrect pour l'utilisateur '%1$s'.
-pollen.exception.vote_doubloon=
-pollen.exception.vote_not_allowed=
pollen.feed.addChoiceContent=
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
@@ -164,75 +23,4 @@
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
pollen.info.admin.exists=Le super admin existe déjà
-pollen.info.start=Démarrage de Pollen...
-pollen.info.started=Pollen a été démarré avec succès \!
-pollen.info.stop=Arrêt de Pollen
-pollen.page.AdminUsers.title=Gestion des utilisateurs
-pollen.page.PollLinks.title=Liens d'accès au sondage
-pollen.page.UserLists.title=Vos listes de votants
-pollen.ui.button.add=Ajouter
-pollen.ui.button.create=Créer
-pollen.ui.button.ok=Ok
-pollen.ui.choice.add.submit=Ajouter
-pollen.ui.choice.add.title=Ajout d'un choix
-pollen.ui.choice.datePattern=dd/MM/yyyy HH\:mm
-pollen.ui.choice.delete.confirm=Etes-vous sûr de vouloir définitivement supprimer ce choix ?
-pollen.ui.choice.delete.title=Supprimer ce choix
-pollen.ui.error.upload=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autorisée est de %1$s par fichier et %2$s au total.
-pollen.ui.list.create.success=La liste %1$s a été créée avec succès.
-pollen.ui.list.create.title=Créer une nouvelle liste
-pollen.ui.list.create.weightHelp=Ce chiffre correspond au poids du vote de la personne, c'est à dire le nombre de voix que possède la personne dans le sondage.
-pollen.ui.list.delete=Supprimer la liste %1$s
-pollen.ui.list.delete.confirmMessage=Etes-vous sûr de vouloir définitivement supprimer cette liste et l'intégralité de ses votants ?
-pollen.ui.list.delete.success=La liste et son contenu ont été supprimé avec succès.
-pollen.ui.list.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
-pollen.ui.list.nbParticipants=%1$d votants contenus dans cette liste
-pollen.ui.list.notSelected=Aucune liste sélectionnée
-pollen.ui.list.update.addParticipant=Ajouter un nouveau votant à la liste
-pollen.ui.list.update.addParticipant.success=Le votant %1$s a été ajouté à la liste.
-pollen.ui.list.update.cancelEdition=Annuler les changements
-pollen.ui.list.update.removeParticipant=Supprimer ce votant
-pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous sûr de vouloir supprimer %1$s de la liste ?
-pollen.ui.list.update.removeParticipant.success=Le votant a été supprimé avec succès.
-pollen.ui.list.update.saveParticipant=Enregistrer les modifications
-pollen.ui.list.update.saveParticipant.success=Modification enregistrée avec succès.
-pollen.ui.list.update.updateParticipant=Modifier ce votant
-pollen.ui.participant.add=Nouveau participant
-pollen.ui.participant.email-label=Email
-pollen.ui.participant.name-label=Nom
-pollen.ui.participant.weight-label=Poids
-pollen.ui.poll.form.confirmlistChange=Des changements ont été effectués sur la/les liste(s), un changement de restriction supprimera les modifications. Voulez-vous continuer ?
-pollen.ui.poll.links.adminVotePage=Lien d'accès modérateur à la page des votes \:
-pollen.ui.poll.links.creatorEmail.notDefined=Aucun email n'a été défini à la création du sondage, vous devriez enregistrer cette page dans vos favoris pour ne pas perdre les liens.
-pollen.ui.poll.links.creatorEmail.success=Un email vous a été envoyé avec les liens ci-dessous.
-pollen.ui.poll.links.editPage=Lien d'accès à la modification du sondage \:
-pollen.ui.poll.links.myPolls=Mes sondages
-pollen.ui.poll.links.notAllowed=L'url est incorrect, vous n'êtes pas autorisé à accéder aux liens du sondage.
-pollen.ui.poll.links.pollName=%1$s par %2$s
-pollen.ui.poll.links.register=Si vous êtes un utilisateur identifié, vous pouvez retrouver ces liens dans la page
-pollen.ui.poll.links.uriNotDefined=Page inaccessible sans identifiant du sondage dans l'url \!
-pollen.ui.poll.links.votePage=Lien d'accès publique à la page des votes \:
-pollen.ui.tooltip.help=Aide
-pollen.ui.user.create.emailFailedShowPassword=Le mot de passe généré est le suivant \: %1$s
-pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a été généré.
-pollen.ui.user.create.passwordHelp=Si vous précisez un email, un mot de passe sera généré et envoyé à l'utilisateur. Sinon le mot de passe sera identique au login.
-pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le même que son identifiant.
-pollen.ui.user.create.sendEmail=Un email a été envoyé au nouvel utilisateur %1$s à l'adresse %2$s.
-pollen.ui.user.create.success=L'utilisateur %1$s a été créé avec succès.
-pollen.ui.user.create.title=Créer un nouvel utilisateur
-pollen.ui.user.delete=Supprimer cet utilisateur
-pollen.ui.user.delete.confirmMessage=Etes-vous sûr de vouloir définitivement supprimer cet utilisateur ?
-pollen.ui.user.display.notAllowed=Vous n'avez pas les droits nécessaires pour accéder à la page %1$s.
-pollen.ui.user.display.notConnected=Vous devez vous connecter pour accéder à la page %1$s.
-pollen.ui.user.nbUsers=%1$d utilisateurs existants
-pollen.ui.user.register.autoConnection=Vous êtes maintenant connecté avec l'identifiant %1$s.
-pollen.ui.user.register.sendEmail=Un email vous a été envoyé à l'adresse %1$s.
-pollen.ui.user.update.cancel=Annuler les changements
-pollen.ui.user.update.edit=Modifier cet utilisateur
-pollen.ui.user.update.save=Enregistrer les modifications
-pollen.ui.user.update.success=Modification enregistrée avec succès.
-pollen.ui.user.validate.passwords=Les deux mots de passe ne correspondent pas.
-pollen.ui.vote.delete.confirmMessage=Etes-vous sûr de vouloir supprimer ce vote ?
-pollen.ui.vote.noPager=%1$d votes existants
-pollen.ui.vote.noVote=Aucune personne n'a encore participé au sondage
-weight-label=Poids
+
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-02-28 21:34:08 UTC (rev 3152)
@@ -24,6 +24,7 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -37,25 +38,19 @@
import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.impl.PollResultsService;
import org.chorem.pollen.services.impl.PollService;
-import org.chorem.pollen.votecounting.business.NumberMethod;
-import org.chorem.pollen.votecounting.dto.ChoiceDTO;
-import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
import org.nuiton.util.StringUtil;
import java.net.URL;
import java.text.DateFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* Display results of a poll.
@@ -70,12 +65,10 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ResultForPoll.class);
+ private Boolean byGroup;
+
protected boolean userAllowed;
-// protected String victoryMessage;
-
- protected Result result;
-
/**
* Résultats du sondage.
* <p/>
@@ -83,9 +76,6 @@
*/
private transient Multimap<String, String> choicesResults;
-// /** Résultat courant */
-// private Map.Entry<String, List<String>> choicesResult;
-
/** Résultats du sondage. */
private transient Multimap<String, String> subtitles;
@@ -93,7 +83,7 @@
private List<PollResult> results;
- private List<PollResult> ranking;
+// private List<PollResult> ranking;
private List<PollResult> topRanking;
@@ -110,16 +100,12 @@
return userAllowed;
}
- public Result getResult() {
- return result;
- }
-
public List<PollResult> getResults() {
return results;
}
- public Date getResultNameAsDate(Result result) {
- return new Date(Long.valueOf(result.getName()));
+ public String formatResultNameAsDate(PollResult result) {
+ return getDateTimeFormat().format(new Date(Long.valueOf(result.getName())));
}
public Multimap<String, String> getChoicesResults() {
@@ -174,6 +160,12 @@
addActionError(_("pollen.error.pollNotFound"));
} else {
+ if (byGroup == null) {
+
+ // default byGroup value
+ byGroup = isGroupPoll();
+ }
+
setDateFormat(DateFormat.getDateTimeInstance(
DateFormat.SHORT,
DateFormat.SHORT, getLocale()));
@@ -191,7 +183,7 @@
if (!userAllowed) {
addActionError(_("pollen.error.userNotAllowed"));
} else if (!poll.getClosed()) {
- addActionError(_("pollen.error.pollNotClosed"));
+ addActionMessage(_("pollen.error.pollNotClosed"));
loadResults();
} else {
@@ -206,9 +198,9 @@
return topRanking;
}
- public List<PollResult> getRanking() {
- return ranking;
- }
+// public List<PollResult> getRanking() {
+// return ranking;
+// }
public boolean isFreePoll() {
return poll.getPollType() == PollType.FREE;
@@ -250,13 +242,21 @@
return poll.getVoteCountingType() == VoteCountingType.NUMBER;
}
+ public boolean isByGroup() {
+ return byGroup;
+ }
+
+ public void setByGroup(boolean byGroup) {
+ this.byGroup = byGroup;
+ }
+
protected void loadResults() {
PollResultsService pollResultService =
newService(PollResultsService.class);
PollResultList resultListDTO;
- if (isGroupPoll()) {
+ if (byGroup) {
resultListDTO = pollResultService.getGroupResults(poll.getPollId());
} else {
resultListDTO = pollResultService.getNormalResults(poll.getPollId());
@@ -275,118 +275,20 @@
if (isNumberVoteCounting()) {
// resultats des choix cachés
-
choicesResults = LinkedHashMultimap.create();
// sous-titres des vrais choix (les choix pas cachés)
- subtitles = LinkedHashMultimap.create();
+ subtitles = ArrayListMultimap.create();
- /*
- * liste des vrais choix (les choix pas cachés).
- * cette variable sera affectée à la variable results
- */
- List<PollResult> results2 = Lists.newArrayList();
-
- // Ajout des résultats des choix cachés
- for (PollResult result : getResults()) {
- if (result.isHidden()) {
- String name = result.getName();
- int indexOf = name.indexOf('#');
- String choice = name.substring(
- NumberMethod.HIDDEN_PREFIX.length(), indexOf);
-
- String votingId = name.substring(indexOf + 1);
- String value = result.getValue();
-
- choicesResults.put(choice, votingId);
- choicesResults.put(choice, value);
-
- } else {
- results2.add(result);
- }
- }
-
- for (String choiceName : choicesResults.keySet()) {
- Collection<String> values = choicesResults.get(choiceName);
-
- // Récupération du choix correspondant au résultat
- VoteCountingResultDTO voteCountingResult = resultListDTO
- .getVoteCountingResult();
-
- for (ChoiceDTO choice : voteCountingResult.getChoices()) {
- if (choiceName.equals(choice.getName())) {
- subtitles.put(
- choiceName,
- _("pollen.common.numberVote-total"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getValue()));
-
- subtitles.put(
- choiceName,
- _("pollen.common.numberVote-average"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getAverage()));
-
- subtitles.put(
- choiceName,
- _("pollen.common.numberVote-blank-votes"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getNbBlankVotes()));
-
- subtitles.put(
- choiceName,
- _("pollen.common.numberVote-total-votes"));
- subtitles.put(
- choiceName,
- String.valueOf(values.size() / 2));
- break;
- }
- }
- }
-
- results = results2;
- if (results.size() == 1) {
- results.remove(0);
- }
+ results = pollResultService.createNumberVoteCountingResult(
+ resultListDTO,
+ choicesResults,
+ subtitles);
}
- ranking = Lists.newArrayList(results);
+ topRanking = pollResultService.getTopRanking(results);
- Collections.sort(ranking, new Comparator<PollResult>() {
- @Override
- public int compare(PollResult o1, PollResult o2) {
- Double result1 = Double.parseDouble(o1.getValue());
- Double result2 = Double.parseDouble(o2.getValue());
- int comp = 0; // résultat de la comparaison
-
- if (result1 > result2) {
- comp = -1;
- } else if (result1 < result2) {
- comp = 1;
- }
- if (comp == 0) {
- comp = o1.getName().compareTo(o2.getName());
- }
- return comp;
- }
- });
-
- topRanking = Lists.newArrayList();
-
- if (CollectionUtils.isNotEmpty(ranking)) {
- String winValue = ranking.get(0).getValue();
- for (PollResult r : ranking) {
- if (winValue.equals(r.getValue())) {
- topRanking.add(r);
- }
- }
- }
-
if (log.isInfoEnabled()) {
- log.info("rankings = " + ranking);
log.info("topRanking = " + topRanking);
}
}
@@ -431,6 +333,33 @@
return chartUrl;
}
+ public Set<String> getChoicesResultNames() {
+ return choicesResults.keySet();
+ }
+
+ public String getChoicesResultCharUrl(int width,
+ int height,
+ String choiceName) {
+
+ URL applicationUrl = getApplicationUrl();
+ StringBuilder url = new StringBuilder(applicationUrl.toString());
+
+ url.append("/io/generateChart");
+
+ Map<String, Object> params = Maps.newHashMap();
+ params.put("width", width);
+ params.put("height", height);
+ params.put("title", "");
+ params.put("values", choicesResults.get(choiceName));
+ params.put("subtitles", subtitles.get(choiceName));
+
+ UrlHelper.buildParametersString(params, url, "&");
+
+ String chartUrl = url.toString();
+ return chartUrl;
+
+ }
+
public String getChoicesAsString() {
List<String> choices = getChoices();
return StringUtil.join(choices, ",", true);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-28 21:34:08 UTC (rev 3152)
@@ -64,10 +64,6 @@
pollen.common.newPassword=New password
pollen.common.newPassword2=Reenter new passworsd
pollen.common.normal=normal
-pollen.common.numberVote-average=Average of numbers
-pollen.common.numberVote-blank-votes=Number of blank votes
-pollen.common.numberVote-total=Sum of numbers
-pollen.common.numberVote-total-votes=Total votes
pollen.common.or=or
pollen.common.password=Password
pollen.common.password2=Renter your password
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-28 21:34:08 UTC (rev 3152)
@@ -65,10 +65,6 @@
pollen.common.newPassword=Nouveau mot de passe
pollen.common.newPassword2=Répétez votre nouveau mot de passe
pollen.common.normal=normal
-pollen.common.numberVote-average=Moyenne des nombres
-pollen.common.numberVote-blank-votes=Nombre de votes blancs
-pollen.common.numberVote-total=Somme des nombres
-pollen.common.numberVote-total-votes=Nombre total de votes
pollen.common.or=ou
pollen.common.password=Mot de passe
pollen.common.password2=Répétez votre mot de passe
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-02-28 15:32:26 UTC (rev 3151)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-02-28 21:34:08 UTC (rev 3152)
@@ -29,14 +29,34 @@
<script type="text/javascript">
- function displayNormalChartUrl(type) {
- var url = "<s:url value='%{getNormalPollResultChartUrl(400,300)}' escapeAmp='false'/>&type=" + type;
- $('#normalChartImg').attr('src', url);
+ <%--function displayNormalChartUrl(type) {--%>
+ <%--var url = "<s:url value='%{getNormalPollResultChartUrl(400, 300)}' escapeAmp='false'/>&type=" + type;--%>
+ <%--$('#normalChartImg').attr('src', url);--%>
+ <%--return false;--%>
+ <%--}--%>
+
+ function displayCharts(type) {
+ $.each(chartUrls, function (key, value) {
+ console.info("display url [" + key + "] : " + value);
+ var url = value + "&type=" + type;
+ $('#' + key).attr("src", url);
+ });
return false;
}
+ var chartUrls = {};
+
+ chartUrls['chart_normal'] = "<s:url value='%{getNormalPollResultChartUrl(400, 300)}' escapeAmp='false'/>";
+ <s:if test="numberVoteCounting">
+ <s:iterator value="choicesResultNames" var="choicesResultName" status="status">
+ chartUrls['chart_<s:property value="#status.index"/>'] = "<s:url value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}' escapeAmp='false'/>";
+ </s:iterator>
+ </s:if>
+
jQuery(document).ready(function () {
- $('#displayChart1').click();
+
+ // register all chart url (without the type in it)
+ displayCharts(1);
});
@@ -74,26 +94,24 @@
<h4><s:property value="victoryMessage"/>
<br/>
<s:iterator value="topRanking" var="result">
-
<s:if test="textType">
- <s:property value="%{#result.name}"/>
+ <s:property value="name"/>
</s:if>
- <s:if test="dateType">
- <s:property value="%{getResultNameAsDate(#result.name)}"/>
- </s:if>
- <s:if test="imageType">
+ <s:elseif test="dateType">
+ <s:property value="%{formatResultNameAsDate(#result)}"/>
+ </s:elseif>
+ <s:elseif test="imageType">
<s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
escapeAmp="false">
<s:param name="choiceId" value="name"/>
<s:param name="pollId" value="poll.pollId"/>
<s:param name="thumb" value="true"/>
</s:url>
-
<img alt="<s:property value='name'/>"
title="<s:property value='name'/>"
src="<s:property value='imageUrl'/>">
- </s:if>
+ </s:elseif>
<br/>
</s:iterator>
</h4>
@@ -102,18 +120,15 @@
<!-- Diagramme -->
<div id="resultChart">
<div class="chartTypeDiv">
- <sj:a id='displayChart1' href="#"
- onclick="return displayNormalChartUrl(1);">
+ <sj:a id='displayChart1' href="#" onclick="return displayCharts(1);">
<img src="<s:url value='/img/rep1.png'/>"
title='<s:text name="pollen.common.chartType-pie"/>' alt="1"/>
</sj:a>
- <sj:a id='displayChart2' href="#"
- onclick="return displayNormalChartUrl(2);">
+ <sj:a id='displayChart2' href="#" onclick="return displayCharts(2);">
<img src="<s:url value='/img/rep2.png'/>"
title='<s:text name="pollen.common.chartType-pie3d"/>' alt="2"/>
</sj:a>
- <sj:a id='displayChart3' href="#"
- onclick="return displayNormalChartUrl(3);">
+ <sj:a id='displayChart3' href="#" onclick="return displayCharts(3);">
<img src="<s:url value='/img/rep3.png'/>"
title='<s:text name="pollen.common.chartType-ring"/>' alt="3"/>
</sj:a>
@@ -123,14 +138,15 @@
<s:if test="groupPoll">
<s:text name="pollen.common.results"/>
<s:if test="byGroup">
- <s:a href="#" onclick="return false;">
+ <s:a namespace="/poll" action="results/%{poll.pollId}">
+ <s:param name="byGroup" value="false"/>
<s:text name="pollen.common.normal"/>
</s:a>
- <s:text name="pollen.common.group"/>
</s:if>
<s:else>
<s:text name="pollen.common.normal"/> -
- <s:a href="#" onclick="return false;">
+ <s:a namespace="/poll" action="results/%{poll.pollId}">
<s:text name="pollen.common.group"/>
</s:a>
</s:else>
@@ -138,19 +154,17 @@
</div>
<sj:div id='chartContainer'>
- <img id='normalChartImg'/>
+ <img id='chart_normal'/>
</sj:div>
<!-- Diagramme par choix -->
<s:if test="choicesResults != null">
<div id="resultChart">
<div>
- <s:iterator value="choicesResults.entrySet()" var="choicesResult">
- <s:property value="%{#choicesResult.key}"/>
- <s:property value="%{#choicesResult.value}"/>
- <%--<t:chart title="${choicesResult.key}" width="400" height="300"--%>
- <%--values="choicesResult.value" type="${type}"--%>
- <%--t:subtitles="subtitles.get(choicesResult.key)" />--%>
+ <s:iterator value="choicesResultNames" var="choicesResultName" status="status">
+ <img id='chart_<s:property value="#status.index"/>' alt="<s:property/>"
+ title="<s:property/>"
+ src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>">
</s:iterator>
</div>
</div>
1
0
Author: tchemit
Date: 2012-02-28 16:32:26 +0100 (Tue, 28 Feb 2012)
New Revision: 3151
Url: http://chorem.org/repositories/revision/pollen/3151
Log:
continue vote and result page
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GenerateChart.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-io.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/results.css
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/vote.css
Removed:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/pom.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp
branches/pollen-1.2.6-struts2/pom.xml
Copied: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java (from rev 3149, branches/pollen-1.2.6-struts2/pollen-business/src/main/java/org/chorem/pollen/business/dto/ResultDTO.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,147 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.bean;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.VoteCountingType;
+
+import java.io.Serializable;
+
+/**
+ * Classe DTO représentant un résultat de sondage.
+ *
+ * @since 1.2.6
+ */
+public class PollResult implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id;
+
+ private String name;
+
+ private String value;
+
+ private String pollId;
+
+ private ChoiceType choiceType;
+
+ private VoteCountingType voteCountingType;
+
+ private boolean byGroup;
+
+ private boolean hidden;
+
+ public PollResult() {
+
+ }
+
+ public PollResult(String id) {
+ this.id = id;
+ }
+
+ public PollResult(String name,
+ String pollId,
+ ChoiceType choiceType,
+ VoteCountingType voteCountingType) {
+ super();
+ this.name = name;
+ this.pollId = pollId;
+ this.choiceType = choiceType;
+ this.voteCountingType = voteCountingType;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getPollId() {
+ return pollId;
+ }
+
+ public void setPollId(String pollId) {
+ this.pollId = pollId;
+ }
+
+ public ChoiceType getChoiceType() {
+ return choiceType;
+ }
+
+ public void setChoiceType(ChoiceType choiceType) {
+ this.choiceType = choiceType;
+ }
+
+ public VoteCountingType getVoteCountingType() {
+ return voteCountingType;
+ }
+
+ public void setVoteCountingType(VoteCountingType voteCountingType) {
+ this.voteCountingType = voteCountingType;
+ }
+
+ public boolean isByGroup() {
+ return byGroup;
+ }
+
+ public void setByGroup(boolean byGroup) {
+ this.byGroup = byGroup;
+ }
+
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).
+ append("name", name).
+ append("value", value).
+ toString();
+ }
+}
\ No newline at end of file
Copied: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java (from rev 3149, branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.bean;
+
+import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class PollResultList {
+
+ /** Liste des résultats */
+ private List<PollResult> pollResults;
+
+ /** Résultat issu du dépouillement du vote */
+ private VoteCountingResultDTO voteCountingResult;
+
+ public List<PollResult> getPollResults() {
+ return pollResults;
+ }
+
+ public void setPollResults(List<PollResult> pollResults) {
+ this.pollResults = pollResults;
+ }
+
+ public VoteCountingResultDTO getVoteCountingResult() {
+ return voteCountingResult;
+ }
+
+ public void setVoteCountingResult(VoteCountingResultDTO voteCountingResult) {
+ this.voteCountingResult = voteCountingResult;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -1,38 +0,0 @@
-package org.chorem.pollen.bean;
-
-import org.chorem.pollen.business.persistence.Result;
-import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since TODO
- */
-public class PollResultListBean {
-
- /** Liste des résultats */
- private List<Result> resultDTOs = null;
-
- /** Résultat issu du dépouillement du vote */
- private VoteCountingResultDTO voteCountingResultDTO = null;
-
- public List<Result> getResultDTOs() {
- return resultDTOs;
- }
-
- public void setResultDTOs(List<Result> resultDTOs) {
- this.resultDTOs = resultDTOs;
- }
-
- public VoteCountingResultDTO getVoteCountingResultDTO() {
- return voteCountingResultDTO;
- }
-
- public void setVoteCountingResultDTO(VoteCountingResultDTO voteCountingResultDTO) {
- this.voteCountingResultDTO = voteCountingResultDTO;
- }
-
-}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -186,4 +186,23 @@
}
}
+ public List<Comment> getAllComments(String pollId) {
+
+ Preconditions.checkNotNull(pollId);
+
+ CommentDAO dao = getDAO(Comment.class);
+
+ try {
+
+ TopiaQuery query = dao.createQuery("e").
+ addWhere("e." + Comment.PROPERTY_POLL + ".pollId",
+ TopiaQuery.Op.EQ, pollId);
+ query.addOrderDesc(Comment.PROPERTY_POST_DATE);
+ List<Comment> result = dao.findAllByQuery(query);
+ return result;
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(e);
+ }
+ }
+
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package org.chorem.pollen.services.impl;
import com.google.common.collect.Lists;
@@ -3,5 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.bean.PollResultListBean;
+import org.chorem.pollen.bean.PollResult;
+import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
@@ -12,6 +36,7 @@
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.votecounting.business.NumberMethod;
import org.chorem.pollen.votecounting.dto.ChoiceDTO;
import org.chorem.pollen.votecounting.dto.PollDTO;
import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
@@ -36,25 +61,34 @@
/** log. */
private static final Log log = LogFactory.getLog(PollResultsService.class);
- public PollResultListBean getAllResults(String pollId) {
+ public PollResultList getAllResults(String pollId) {
return getResults(pollId, null, false, false);
}
- public PollResultListBean getResultsByVoteCounting(String pollId,
- VoteCountingType voteCounting) {
+ public PollResultList getResultsByVoteCounting(String pollId,
+ VoteCountingType voteCounting) {
return getResults(pollId, voteCounting, false, false);
}
- public PollResultListBean getGroupResults(String pollId) {
+ public PollResultList getGroupResults(String pollId) {
return getResults(pollId, null, true, true);
}
- public PollResultListBean getNormalResults(String pollId) {
+ public PollResultList getNormalResults(String pollId) {
return getResults(pollId, null, true, false);
}
+ public List<PollResult> getNormalPollResults(String pollId) {
+ PollResultList results = getResults(pollId, null, true, false);
+ return results.getPollResults();
+ }
+
+ public PollResultList generateNormalResults(String pollId) {
+ return generateResults(pollId, null, true, false);
+ }
+
/**
- * Récupère les résultats d'un sondage.
+ * Génère les résultats d'un sondage (= un dépouillement).
*
* @param pollId le sondage
* @param voteCounting type de dépouillement
@@ -62,10 +96,10 @@
* @param groupOnly résultats uniquement par groupe
* @return les résultats du sondage
*/
- private PollResultListBean getResults(String pollId,
- VoteCountingType voteCounting,
- boolean byGroup,
- boolean groupOnly) {
+ private PollResultList generateResults(String pollId,
+ VoteCountingType voteCounting,
+ boolean byGroup,
+ boolean groupOnly) {
PollService pollService = newService(PollService.class);
Poll poll = pollService.getPollByPollId(pollId);
@@ -114,13 +148,13 @@
}
// Conversion et trie des résultats
- List<Result> list = Lists.newArrayList(poll.getResult());
+ List<PollResult> list = createPollResults(poll);
VoteCountingType voteCountingType = poll.getVoteCountingType();
- Iterator<Result> it = list.iterator();
+ Iterator<PollResult> it = list.iterator();
while (it.hasNext()) {
- Result currentResult = it.next();
+ PollResult currentResult = it.next();
// Cas d'un dépouillement particulier
// Suppression des resultats qui ne sont pas de se dépouillement
@@ -133,12 +167,12 @@
if (byGroup) {
// Filtre group : Suppression resultats non group
- if (groupOnly && !currentResult.getByGroup()) {
+ if (groupOnly && !currentResult.isByGroup()) {
it.remove();
}
// Filtre non group : Suppression resultats group
- else if (!groupOnly && currentResult.getByGroup()) {
+ else if (!groupOnly && currentResult.isByGroup()) {
it.remove();
}
@@ -149,14 +183,142 @@
}
}
- PollResultListBean resultListDTO = new PollResultListBean();
- resultListDTO.setResultDTOs(list);
- resultListDTO.setVoteCountingResultDTO(result);
+ PollResultList resultListDTO = new PollResultList();
+ resultListDTO.setPollResults(list);
+ resultListDTO.setVoteCountingResult(result);
return resultListDTO;
}
/**
+ * Récupère les résultats d'un sondage (sans rien dépouiller).
+ *
+ * @param pollId le sondage
+ * @param voteCounting type de dépouillement
+ * @param byGroup résultats par groupe
+ * @param groupOnly résultats uniquement par groupe
+ * @return les résultats du sondage
+ */
+ private PollResultList getResults(String pollId,
+ VoteCountingType voteCounting,
+ boolean byGroup,
+ boolean groupOnly) {
+
+ PollService pollService = newService(PollService.class);
+ Poll poll = pollService.getPollByPollId(pollId);
+
+// DataResultConverter converter = new DataResultConverter(transaction);
+ if (log.isDebugEnabled()) {
+ log.debug(poll.getPollId() + " (" + voteCounting
+ + ") has results: " + hasResults(poll, voteCounting));
+ }
+
+ // Dépouillement du sondage.
+ // S'il n'existe pas de résultats ou si le sondage est encore ouvert.
+ //if (!hasResults(ePoll, voteCounting) || !ePoll.getIsClosed()) {
+ PollDTO dto = pollService.createPollDTOForVoteCounting(poll);
+
+ if (voteCounting != null) {
+ dto.setVoteCounting(voteCounting);
+ }
+
+// // clear result (they will be regenerated ! (a big shame))
+// poll.clearResult();
+
+// ServiceVoteCounting service = new ServiceVoteCountingImpl();
+//
+// VoteCountingResultDTO result;
+//
+// if (PollType.GROUP == poll.getPollType()) {
+// result = service.executeGroupCounting(dto);
+// } else {
+// result = service.executeVoteCounting(dto);
+// }
+// for (ChoiceDTO choice : result.getChoices()) {
+//
+// ResultDAO daoResult = getDAO(Result.class);
+// Result eResult = create(daoResult);
+//
+// Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+//
+// poll.addResult(eResult);
+//
+// eResult.setName(eChoice.getName());
+// eResult.setByGroup(result.isByGroup());
+// eResult.setPoll(poll);
+// eResult.setResultValue(String.valueOf(choice.getValue()));
+// eResult.setVoteCountingType(result.getTypeVoteCounting());
+// }
+
+ // Conversion et trie des résultats
+ List<PollResult> list = createPollResults(poll);
+
+ VoteCountingType voteCountingType = poll.getVoteCountingType();
+
+ Iterator<PollResult> it = list.iterator();
+ while (it.hasNext()) {
+ PollResult currentResult = it.next();
+
+ // Cas d'un dépouillement particulier
+ // Suppression des resultats qui ne sont pas de se dépouillement
+ if (voteCounting != null
+ && currentResult.getVoteCountingType() != voteCounting) {
+ it.remove();
+ }
+
+ // Cas d'un sondage de type GROUP avec filtre
+ if (byGroup) {
+
+ // Filtre group : Suppression resultats non group
+ if (groupOnly && !currentResult.isByGroup()) {
+ it.remove();
+ }
+
+ // Filtre non group : Suppression resultats group
+ else if (!groupOnly && currentResult.isByGroup()) {
+ it.remove();
+ }
+
+ // Suppression des autres resultats de depouillements differents
+ if (currentResult.getVoteCountingType() != voteCountingType) {
+ it.remove();
+ }
+ }
+ }
+
+ PollResultList resultListDTO = new PollResultList();
+ resultListDTO.setPollResults(list);
+ resultListDTO.setVoteCountingResult(null);
+
+ return resultListDTO;
+ }
+
+ /**
+ * Retourne la liste des résultats d'un sondage sous forme de DTOs.
+ *
+ * @param poll le sondage (entitée Poll)
+ * @return la liste des DTO Result
+ */
+ public List<PollResult> createPollResults(Poll poll) {
+ List<PollResult> results = Lists.newArrayList();
+ for (Result res : poll.getResult()) {
+ PollResult dto = new PollResult();
+ dto.setId(res.getTopiaId());
+ dto.setPollId(poll.getPollId());
+ String resName = res.getName();
+ dto.setName(resName);
+ dto.setHidden(resName != null &&
+ resName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ dto.setValue(res.getResultValue());
+ dto.setByGroup(res.getByGroup());
+ dto.setChoiceType(poll.getChoiceType());
+ dto.setVoteCountingType(poll.getVoteCountingType());
+ results.add(dto);
+ }
+ return results;
+ }
+
+ /**
* Retourne une chaîne contenant les résultats du sondage.
*
* @param poll le sondage
@@ -184,12 +346,12 @@
return res.toString();
}
- public String getResultValue(Choice choice, Collection<Result> results) {
+ public String getResultValue(Choice choice, Collection<PollResult> results) {
String val = "";
- for (Result result : results) {
+ for (PollResult result : results) {
if (result.getName().equals(choice.getName())) {
- val = removeTrailing0(result.getResultValue());
+ val = removeTrailing0(result.getValue());
break;
}
}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -57,6 +57,7 @@
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.web.struts2.FilterPagerUtil;
+import java.io.File;
import java.util.List;
public class PollService extends PollenServiceSupport {
@@ -942,6 +943,8 @@
if (userAccount != null) {
String displayName = userAccount.getDisplayName();
result.setVotingId(displayName);
+ } else {
+ result.setVotingId("");
}
return result;
}
@@ -1018,51 +1021,51 @@
}
}
- public PollDTO createPollDTOForVoteCounting(Poll ePoll) {
- PollDTO pollDTO = new PollDTO(ePoll.getPollId());
- pollDTO.setTitle(ePoll.getTitle());
- pollDTO.setDescription(ePoll.getDescription());
- pollDTO.setBeginChoiceDate(ePoll.getBeginChoiceDate());
- pollDTO.setBeginDate(ePoll.getBeginDate());
- pollDTO.setEndDate(ePoll.getEndDate());
- pollDTO.setAnonymous(ePoll.getAnonymous());
- pollDTO.setAnonymousVoteAllowed(ePoll.getAnonymousVoteAllowed());
- pollDTO.setPublicResults(ePoll.getPublicResults());
- pollDTO.setContinuousResults(ePoll.getContinuousResults());
- pollDTO.setChoiceAddAllowed(ePoll.getChoiceAddAllowed());
- pollDTO.setClosed(ePoll.getClosed());
- pollDTO.setCreatorId(ePoll.getCreator().getVotingId());
- pollDTO.setCreatorEmail(ePoll.getCreator().getEmail());
- pollDTO.setMaxChoiceNb(ePoll.getMaxChoiceNb());
- pollDTO.setPollType(ePoll.getPollType());
- pollDTO.setChoiceType(ePoll.getChoiceType());
- pollDTO.setVoteCounting(ePoll.getVoteCountingType());
+ public PollDTO createPollDTOForVoteCounting(Poll poll) {
+ PollDTO result = new PollDTO(poll.getPollId());
+ result.setTitle(poll.getTitle());
+ result.setDescription(poll.getDescription());
+ result.setBeginChoiceDate(poll.getBeginChoiceDate());
+ result.setBeginDate(poll.getBeginDate());
+ result.setEndDate(poll.getEndDate());
+ result.setAnonymous(poll.getAnonymous());
+ result.setAnonymousVoteAllowed(poll.getAnonymousVoteAllowed());
+ result.setPublicResults(poll.getPublicResults());
+ result.setContinuousResults(poll.getContinuousResults());
+ result.setChoiceAddAllowed(poll.getChoiceAddAllowed());
+ result.setClosed(poll.getClosed());
+ result.setCreatorId(poll.getCreator().getVotingId());
+ result.setCreatorEmail(poll.getCreator().getEmail());
+ result.setMaxChoiceNb(poll.getMaxChoiceNb());
+ result.setPollType(poll.getPollType());
+ result.setChoiceType(poll.getChoiceType());
+ result.setVoteCounting(poll.getVoteCountingType());
- for (Comment comment : ePoll.getComment()) {
- pollDTO.getComments().add(createPollCommentDTO(comment));
+ for (Comment comment : poll.getComment()) {
+ result.getComments().add(createPollCommentDTO(comment));
}
- for (Choice choice : ePoll.getChoice()) {
- pollDTO.getChoices().add(createPollChoiceDTO(choice));
+ for (Choice choice : poll.getChoice()) {
+ result.getChoices().add(createPollChoiceDTO(choice));
}
- if (ePoll.getVotingList() != null && !ePoll.getVotingList().isEmpty()) {
- for (VotingList list : ePoll.getVotingList()) {
- pollDTO.getVotingGroups().add(createVotingGroupDTO(list));
+ if (poll.getVotingList() != null && !poll.getVotingList().isEmpty()) {
+ for (VotingList list : poll.getVotingList()) {
+ result.getVotingGroups().add(createVotingGroupDTO(list));
}
} else {
// un groupe par défaut si il y en a pas
VotingGroupDTO group = new VotingGroupDTO("unique", 1);
group.setName("unique");
- for (Vote vote : ePoll.getVote()) {
+ for (Vote vote : poll.getVote()) {
group.getVotingPersons().add(createVotingPersonDTO(vote));
}
- pollDTO.getVotingGroups().add(group);
+ result.getVotingGroups().add(group);
}
- return pollDTO;
+ return result;
}
private CommentDTO createPollCommentDTO(Comment comment) {
- CommentDTO commentDTO = new CommentDTO(comment.getPollAccount()
- .getVotingId(), comment.getText());
+ CommentDTO commentDTO = new CommentDTO(
+ comment.getPollAccount().getVotingId(), comment.getText());
return commentDTO;
}
@@ -1084,7 +1087,8 @@
for (PersonToList pToList : list.getPollAccountPersonToList()) {
Vote vote = getPollVoteByPollAccount(list.getPoll(), pToList
.getPollAccount());
- if (vote != null) { // Pas de vote pour cette personne : doit engendrer erreur ?!?
+ if (vote != null) {
+ // Pas de vote pour cette personne : doit engendrer erreur ?!?
group.getVotingPersons().add(createVotingPersonDTO(vote));
}
}
@@ -1121,4 +1125,19 @@
}
return null;
}
+
+ public File getPollChoiceImageFile(String pollId,
+ String choiceId,
+ boolean thumb) {
+ File imageDirectory = getConfiguration().getImageDirectory();
+ File pollDirectory = new File(imageDirectory, pollId);
+
+
+ if (thumb) {
+ choiceId = "thumb_" + choiceId;
+ }
+ File result = new File(pollDirectory, choiceId);
+
+ return result;
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/pom.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/pom.xml 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/pom.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -114,6 +114,16 @@
</dependency>
<dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-jfreechart-plugin</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jfree</groupId>
+ <artifactId>jfreechart</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-runner</artifactId>
</dependency>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -44,6 +44,7 @@
import javax.servlet.http.HttpServletRequest;
import java.net.URL;
+import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -74,9 +75,9 @@
private static final Log log =
LogFactory.getLog(PollenActionSupport.class);
- private SimpleDateFormat dateFormat;
+ private static DateFormat dateTimeFormat;
- private SimpleDateFormat monthFormat;
+ private DateFormat dateFormat;
public static PollenApplicationContext getPollenApplicationContext() {
Map<String, Object> application = getActionContext().getApplication();
@@ -201,16 +202,16 @@
this.transaction = transaction;
}
- public String formatDate(Date date) {
- String result = getDateFormat().format(date);
- return result;
- }
+// public String formatDate(Date date) {
+// String result = getDateFormat().format(date);
+// return result;
+// }
+//
+// public String formatMonth(Date date) {
+// String result = getMonthFormat().format(date);
+// return result;
+// }
- public String formatMonth(Date date) {
- String result = getMonthFormat().format(date);
- return result;
- }
-
public static final List<String> SAFE_LANGUAGES =
Lists.newArrayList("en", "fr");
@@ -222,22 +223,40 @@
return language;
}
- protected SimpleDateFormat getDateFormat() {
+ protected static DateFormat getDateTimeFormat() {
+ if (dateTimeFormat == null) {
+ dateTimeFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm");
+ }
+ return dateTimeFormat;
+ }
+
+ protected DateFormat getDateFormat() {
if (dateFormat == null) {
dateFormat = new SimpleDateFormat("dd/MM/yyyy");
}
return dateFormat;
}
- protected SimpleDateFormat getMonthFormat() {
- if (monthFormat == null) {
- monthFormat = new SimpleDateFormat("mm-yyyy");
- }
- return monthFormat;
+ protected void setDateFormat(DateFormat dateFormat) {
+ this.dateFormat = dateFormat;
}
protected static ActionContext getActionContext() {
return ActionContext.getContext();
}
+ public static String getCurrentDateTime() {
+ String result = getDateTimeFormat().format(new Date());
+ return result;
+ }
+
+ public String formatDate(Date date) {
+ String result = getDateFormat().format(date);
+ return result;
+ }
+
+ public String formatDateTime(Date date) {
+ String result = getDateTimeFormat().format(date);
+ return result;
+ }
}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GenerateChart.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GenerateChart.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GenerateChart.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,176 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.io;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.plot.PiePlot3D;
+import org.jfree.chart.plot.RingPlot;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.DefaultKeyedValues;
+import org.jfree.data.general.DefaultPieDataset;
+import org.jfree.data.general.PieDataset;
+import org.jfree.util.SortOrder;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.util.List;
+
+/**
+ * Action to generate a chart given the values (and optional subtitles).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class GenerateChart extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(GenerateChart.class);
+
+ /** diagramme de type PIE. */
+ public static final int PIE = 1;
+
+ /** diagramme de type PIE3D. */
+ public static final int PIE3D = 2;
+
+ /** diagramme de type RING. */
+ public static final int RING = 3;
+
+ protected int type;
+
+ protected List<String> values;
+
+ protected List<String> subtitles;
+
+ protected int width;
+
+ protected int height;
+
+ protected String title;
+
+ protected JFreeChart chart;
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public void setValues(List<String> values) {
+ this.values = values;
+ }
+
+ public void setSubtitles(List<String> subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public JFreeChart getChart() {
+ return chart;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ DefaultKeyedValues vals = new DefaultKeyedValues();
+
+ if (log.isInfoEnabled()) {
+ log.info("Title = " + title);
+ log.info("Values = " + values);
+ log.info("Subtitles = " + subtitles);
+ }
+
+ for (int i = 0, nbValues = values.size() / 2; i < nbValues; i += 1) {
+ String key = values.get(2 * i);
+ Double value = Double.valueOf(values.get(2 * i + 1));
+ vals.addValue(key, value);
+ }
+
+ vals.sortByValues(SortOrder.DESCENDING);
+ PieDataset data = new DefaultPieDataset(vals);
+
+ // create the chart look according to the type
+ PiePlot plot;
+ switch (type) {
+ case PIE:
+ plot = new PiePlot(data);
+ break;
+ case PIE3D:
+ plot = new PiePlot3D(data);
+ break;
+ case RING:
+ plot = new RingPlot(data);
+ break;
+ default:
+ plot = new PiePlot(data);
+ break;
+ }
+
+ //plot.setForegroundAlpha(0.7f);
+ plot.setCircular(true);
+ plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}"));
+ plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
+ "{0} = {1}"));
+ plot.setNoDataMessage("No Data");
+
+ chart = new JFreeChart(plot);
+ chart.setTitle(new TextTitle(title, new Font(Font.SANS_SERIF,
+ Font.BOLD, 12)));
+ chart.setBackgroundPaint(new Color(255, 255, 255));
+
+ if (CollectionUtils.isNotEmpty(subtitles)) {
+ Font subtitlesFont = new Font(Font.SANS_SERIF, Font.ITALIC, 11);
+ for (int i = 0; i < subtitles.size(); i += 2) {
+ String subtitle = subtitles.get(i) + "=" + subtitles.get(i + 1);
+ TextTitle textTitle = new TextTitle(subtitle, subtitlesFont);
+ chart.addSubtitle(textTitle);
+ }
+ }
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GenerateChart.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,92 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.io;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+import javax.activation.MimetypesFileTypeMap;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+/**
+ * Obtain the image choice of a given choice of an image-like poll.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class GetPollImageChoice extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String pollId;
+
+ protected String choiceId;
+
+ protected boolean thumb;
+
+ protected transient InputStream inputStream;
+
+ protected String contentType;
+
+ public void setPollId(String pollId) {
+ this.pollId = pollId;
+ }
+
+ public void setChoiceId(String choiceId) {
+ this.choiceId = choiceId;
+ }
+
+ public void setThumb(boolean thumb) {
+ this.thumb = thumb;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(choiceId);
+
+ PollService service = newService(PollService.class);
+
+ File file = service.getPollChoiceImageFile(pollId, choiceId, thumb);
+
+ MimetypesFileTypeMap mimes = new MimetypesFileTypeMap();
+ contentType = mimes.getContentType(file);
+
+ inputStream = new FileInputStream(file);
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -26,11 +26,12 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.bean.PollResultListBean;
+import org.chorem.pollen.bean.PollResult;
+import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
@@ -38,11 +39,13 @@
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.impl.PollCommentService;
import org.chorem.pollen.services.impl.PollFeedService;
import org.chorem.pollen.services.impl.PollResultsService;
import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.VoteService;
+import java.text.DateFormat;
import java.util.Date;
import java.util.List;
@@ -89,10 +92,12 @@
private PollAccount pollAccount;
- private String pollAccountId;
+// private String pollAccountId;
- private List<Result> results;
+ private List<PollResult> results;
+ private List<Comment> comments;
+
@Override
public final String getPageLogo() {
return "Vote";
@@ -106,9 +111,9 @@
// this.accountId = accountId;
// }
- public String getPollAccountId() {
- return pollAccountId;
- }
+// public String getPollAccountId() {
+// return pollAccountId;
+// }
public final Poll getPoll() {
return poll;
@@ -151,19 +156,28 @@
return commentName;
}
- public List<Result> getResults() {
+ public List<PollResult> getResults() {
return results;
}
+ public List<Comment> getComments() {
+ return comments;
+ }
+
public void prepareVotePage() throws Exception {
loadPoll();
+ setDateFormat(DateFormat.getDateTimeInstance(
+ DateFormat.SHORT,
+ DateFormat.SHORT, getLocale()));
+
if (poll != null) {
loadPollAccount();
loadPollResults();
+ loadPollComments();
PollFeedService pollFeedService = newService(PollFeedService.class);
@@ -247,24 +261,31 @@
return val;
}
+ protected void loadPollComments() {
+
+ PollCommentService service = newService(PollCommentService.class);
+
+ comments = service.getAllComments(poll.getPollId());
+ }
+
protected void loadPollResults() {
PollResultsService service = getPollResultsService();
- PollResultListBean resultListDTO;
+ PollResultList resultListDTO;
if (isGroupPoll()) {
resultListDTO = service.getGroupResults(poll.getPollId());
} else {
resultListDTO = service.getNormalResults(poll.getPollId());
}
- results = resultListDTO.getResultDTOs();
+ results = resultListDTO.getPollResults();
if (log.isDebugEnabled()) {
- for (Result res : results) {
- log.debug(res.getName() + ": " + res.getResultValue()
+ for (PollResult res : results) {
+ log.debug(res.getName() + ": " + res.getValue()
+ ", (voteCounting=" + res.getVoteCountingType()
- + ", byGroup=" + res.getByGroup() + ")");
+ + ", byGroup=" + res.isByGroup() + ")");
}
}
}
@@ -377,8 +398,8 @@
PollAccount votePollAccount = vote.getPollAccount();
// si le votant du vote correspond au votant actuel (pollAccountId)
- if (pollAccountId != null
- && pollAccountId.equals(votePollAccount.getAccountId())) {
+ if (accountId != null
+ && accountId.equals(votePollAccount.getAccountId())) {
result = true;
}
@@ -497,4 +518,7 @@
return poll.getEndDate() != null && poll.getEndDate().before(now);
}
+ public String formatChoiceNameAsDate(Choice choice) {
+ return formatDate(new Date(Long.valueOf(choice.getName())));
+ }
}
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-02-28 15:32:26 UTC (rev 3151)
@@ -23,15 +23,416 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.views.util.UrlHelper;
+import org.chorem.pollen.bean.PollResult;
+import org.chorem.pollen.bean.PollResultList;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.Result;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.services.impl.PollResultsService;
+import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.votecounting.business.NumberMethod;
+import org.chorem.pollen.votecounting.dto.ChoiceDTO;
+import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
+import org.nuiton.util.StringUtil;
+import java.net.URL;
+import java.text.DateFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
/**
* Display results of a poll.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2.6
*/
-public class ResultForPoll extends PollenActionSupport {
+public class ResultForPoll extends AbstractPollUriIdAction {
private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ResultForPoll.class);
+
+ protected boolean userAllowed;
+
+// protected String victoryMessage;
+
+ protected Result result;
+
+ /**
+ * Résultats du sondage.
+ * <p/>
+ * La map est indexée par les noms de choix.
+ */
+ private transient Multimap<String, String> choicesResults;
+
+// /** Résultat courant */
+// private Map.Entry<String, List<String>> choicesResult;
+
+ /** Résultats du sondage. */
+ private transient Multimap<String, String> subtitles;
+
+ private Poll poll;
+
+ private List<PollResult> results;
+
+ private List<PollResult> ranking;
+
+ private List<PollResult> topRanking;
+
+ @Override
+ public final String getPageLogo() {
+ return "VoteCounting";
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public boolean isUserAllowed() {
+ return userAllowed;
+ }
+
+ public Result getResult() {
+ return result;
+ }
+
+ public List<PollResult> getResults() {
+ return results;
+ }
+
+ public Date getResultNameAsDate(Result result) {
+ return new Date(Long.valueOf(result.getName()));
+ }
+
+ public Multimap<String, String> getChoicesResults() {
+ return choicesResults;
+ }
+
+ public Multimap<String, String> getSubtitles() {
+ return subtitles;
+ }
+
+ public String getVictoryMessage() {
+
+ String victoryMessage;
+
+ if (poll.getVoteCountingType() == VoteCountingType.NUMBER) {
+ victoryMessage = null;
+ } else if (CollectionUtils.isEmpty(topRanking)) {
+ victoryMessage = "";
+ } else if (topRanking.size() == 1) {
+ victoryMessage = _("pollen.common.victory");
+ } else {
+ victoryMessage = _("pollen.common.victories");
+ }
+ return victoryMessage;
+ }
+
+ /**
+ * @param result la résultat à utiliser.
+ * @return la valeur du résultat courant sans le .0 final
+ */
+ public String getTrimValue(PollResult result) {
+
+ String value = result.getValue();
+
+ // le résultat peut-être un double : 1,0 -> 1 et 1,2 -> 1,2
+ if (value.endsWith(".0")) {
+ value = value.substring(0, value.indexOf('.'));
+ }
+ return value;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+
+ PollService service = newService(PollService.class);
+
+ poll = service.getPollByPollId(pollId);
+
+ if (poll == null) {
+ addActionError(_("pollen.error.pollNotFound"));
+ } else {
+
+ setDateFormat(DateFormat.getDateTimeInstance(
+ DateFormat.SHORT,
+ DateFormat.SHORT, getLocale()));
+
+ if (poll.getPublicResults()) {
+ userAllowed = true;
+ } else if (StringUtils.isNotEmpty(accountId)) {
+
+ PollAccount creator = poll.getCreator();
+ if (accountId.equals(creator.getAccountId())) {
+ userAllowed = true;
+ }
+ }
+
+ if (!userAllowed) {
+ addActionError(_("pollen.error.userNotAllowed"));
+ } else if (!poll.getClosed()) {
+ addActionError(_("pollen.error.pollNotClosed"));
+ loadResults();
+ } else {
+
+ loadResults();
+ }
+ }
+
+ return SUCCESS;
+ }
+
+ public List<PollResult> getTopRanking() {
+ return topRanking;
+ }
+
+ public List<PollResult> getRanking() {
+ return ranking;
+ }
+
+ public boolean isFreePoll() {
+ return poll.getPollType() == PollType.FREE;
+ }
+
+ public boolean isRestrictedPoll() {
+ return poll.getPollType() == PollType.RESTRICTED;
+ }
+
+ public boolean isGroupPoll() {
+ return poll.getPollType() == PollType.GROUP;
+ }
+
+ public boolean isTextType() {
+ return poll.getChoiceType() == ChoiceType.TEXT;
+ }
+
+ public boolean isDateType() {
+ return poll.getChoiceType() == ChoiceType.DATE;
+ }
+
+ public boolean isImageType() {
+ return poll.getChoiceType() == ChoiceType.IMAGE;
+ }
+
+ public boolean isNormalVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.NORMAL;
+ }
+
+ public boolean isPercentageVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.PERCENTAGE;
+ }
+
+ public boolean isCondorcetVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.CONDORCET;
+ }
+
+ public boolean isNumberVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.NUMBER;
+ }
+
+ protected void loadResults() {
+
+ PollResultsService pollResultService =
+ newService(PollResultsService.class);
+
+ PollResultList resultListDTO;
+ if (isGroupPoll()) {
+ resultListDTO = pollResultService.getGroupResults(poll.getPollId());
+ } else {
+ resultListDTO = pollResultService.getNormalResults(poll.getPollId());
+ }
+
+ results = resultListDTO.getPollResults();
+
+ if (log.isDebugEnabled()) {
+ for (PollResult res : results) {
+ log.debug(res
+ + ", (voteCounting=" + res.getVoteCountingType()
+ + ", byGroup=" + res.isByGroup() + ")");
+ }
+ }
+
+ if (isNumberVoteCounting()) {
+
+ // resultats des choix cachés
+
+ choicesResults = LinkedHashMultimap.create();
+
+ // sous-titres des vrais choix (les choix pas cachés)
+ subtitles = LinkedHashMultimap.create();
+
+ /*
+ * liste des vrais choix (les choix pas cachés).
+ * cette variable sera affectée à la variable results
+ */
+ List<PollResult> results2 = Lists.newArrayList();
+
+ // Ajout des résultats des choix cachés
+ for (PollResult result : getResults()) {
+ if (result.isHidden()) {
+ String name = result.getName();
+ int indexOf = name.indexOf('#');
+ String choice = name.substring(
+ NumberMethod.HIDDEN_PREFIX.length(), indexOf);
+
+ String votingId = name.substring(indexOf + 1);
+ String value = result.getValue();
+
+ choicesResults.put(choice, votingId);
+ choicesResults.put(choice, value);
+
+ } else {
+ results2.add(result);
+ }
+ }
+
+ for (String choiceName : choicesResults.keySet()) {
+ Collection<String> values = choicesResults.get(choiceName);
+
+ // Récupération du choix correspondant au résultat
+ VoteCountingResultDTO voteCountingResult = resultListDTO
+ .getVoteCountingResult();
+
+ for (ChoiceDTO choice : voteCountingResult.getChoices()) {
+ if (choiceName.equals(choice.getName())) {
+ subtitles.put(
+ choiceName,
+ _("pollen.common.numberVote-total"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getValue()));
+
+ subtitles.put(
+ choiceName,
+ _("pollen.common.numberVote-average"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getAverage()));
+
+ subtitles.put(
+ choiceName,
+ _("pollen.common.numberVote-blank-votes"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(choice.getNbBlankVotes()));
+
+ subtitles.put(
+ choiceName,
+ _("pollen.common.numberVote-total-votes"));
+ subtitles.put(
+ choiceName,
+ String.valueOf(values.size() / 2));
+ break;
+ }
+ }
+ }
+
+ results = results2;
+ if (results.size() == 1) {
+ results.remove(0);
+ }
+ }
+
+ ranking = Lists.newArrayList(results);
+
+ Collections.sort(ranking, new Comparator<PollResult>() {
+ @Override
+ public int compare(PollResult o1, PollResult o2) {
+ Double result1 = Double.parseDouble(o1.getValue());
+ Double result2 = Double.parseDouble(o2.getValue());
+ int comp = 0; // résultat de la comparaison
+
+ if (result1 > result2) {
+ comp = -1;
+ } else if (result1 < result2) {
+ comp = 1;
+ }
+ if (comp == 0) {
+ comp = o1.getName().compareTo(o2.getName());
+ }
+ return comp;
+ }
+ });
+
+ topRanking = Lists.newArrayList();
+
+ if (CollectionUtils.isNotEmpty(ranking)) {
+ String winValue = ranking.get(0).getValue();
+ for (PollResult r : ranking) {
+ if (winValue.equals(r.getValue())) {
+ topRanking.add(r);
+ }
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("rankings = " + ranking);
+ log.info("topRanking = " + topRanking);
+ }
+ }
+
+ /** @return Récupération de la liste des résultats pour le diagramme. */
+ public List<String> getChoices() {
+
+ List<String> choiceValues = Lists.newArrayList();
+
+ for (PollResult result : results) {
+ String name = result.getName();
+ String value = result.getValue();
+
+ if (isDateType()) {
+ // mise en forme de la date
+ Date date = new Date(Long.parseLong(name));
+ name = getDateFormat().format(date);
+ }
+
+ choiceValues.add(name);
+ choiceValues.add(value);
+ }
+ return choiceValues;
+ }
+
+ public String getNormalPollResultChartUrl(int width, int height) {
+ URL applicationUrl = getApplicationUrl();
+ StringBuilder url = new StringBuilder(applicationUrl.toString());
+
+ url.append("/io/generateChart");
+
+ Map<String, Object> params = Maps.newHashMap();
+ params.put("width", width);
+ params.put("height", height);
+ params.put("title", "");
+ params.put("values", getChoices());
+
+
+ UrlHelper.buildParametersString(params, url, "&");
+
+ String chartUrl = url.toString();
+ return chartUrl;
+ }
+
+ public String getChoicesAsString() {
+ List<String> choices = getChoices();
+ return StringUtil.join(choices, ",", true);
+ }
}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-io.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-io.xml (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-io.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+
+
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.1.7.dtd">
+
+<struts>
+
+ <package name="io" extends="default" namespace="/io">
+
+ <result-types>
+ <result-type name="chart"
+ class="org.apache.struts2.dispatcher.ChartResult"/>
+ </result-types>
+
+ <!-- generate a chart as an image -->
+ <action name="generateChart"
+ class="org.chorem.pollen.ui.actions.io.GenerateChart">
+ <result type="chart">
+ <param name="width">${width}</param>
+ <param name="height">${height}</param>
+ </result>
+ </action>
+
+ <!-- generate a chart as an image -->
+ <action name="getPollChoiceImage"
+ class="org.chorem.pollen.ui.actions.io.GetPollImageChoice">
+ <result type="stream">
+ <param name="contentType">${contentType}</param>
+ </result>
+ </action>
+
+ </package>
+
+
+</struts>
+
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-io.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -37,8 +37,6 @@
class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
<param name="namespace">/poll</param>
<param name="actionName">votefor/${uriId}</param>
- <param name="method">input</param>
- <!--<param name="uriId">${uriId}</param>-->
</result-type>
</result-types>
@@ -57,14 +55,14 @@
</action>
<!-- vote poll -->
- <action name="vote"
+ <action name="vote" method="execute"
class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
- <result>/WEB-INF/jsp/poll/vote.jsp</result>
+ <result type="redirectToVote"/>
</action>
<!-- vote poll -->
- <action name="votefor/*"
+ <action name="votefor/*" method="input"
class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
<param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
@@ -100,10 +98,10 @@
</action>
<!-- display poll result -->
- <action name="result"
+ <action name="results/*" method="execute"
class="org.chorem.pollen.ui.actions.poll.ResultForPoll">
- <result name="input">/WEB-INF/jsp/poll/result.jsp</result>
- <result>/WEB-INF/jsp/home.jsp</result>
+ <param name="uriId">{1}</param>
+ <result>/WEB-INF/jsp/poll/result.jsp</result>
</action>
<!-- display createds polls -->
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-28 15:32:26 UTC (rev 3151)
@@ -4,8 +4,9 @@
poll.common.select.userFavoriteList=List
poll.common.vote.results=Results
poll.common.vote.results-help=Display results
-poll.legend.addNewComment=Add a comment
-pollen.action.addComment=Add
+poll.common.vote.return=Back to poll
+poll.common.vote.return-help=Back to poll
+pollen.action.addComment=Add a comment
pollen.action.backToFavoriteLists=Back to favorite lists
pollen.action.create=Create
pollen.action.createFavoriteList=Create a new list
@@ -39,15 +40,21 @@
pollen.common.beginChoiceDate=Begin choice date
pollen.common.beginDate=Begin date
pollen.common.bugReport=Bug report
+pollen.common.chartType-pie=Pie
+pollen.common.chartType-pie3d=Pie 3D
+pollen.common.chartType-ring=Ring
pollen.common.commentName=Name
pollen.common.commentText=Comment
pollen.common.csvImport=CSV import
pollen.common.description=Description
+pollen.common.displayType-group=Results by groups
+pollen.common.displayType-normal=Results
pollen.common.email=Em@il
pollen.common.endChoiceDate=end choice date
pollen.common.endDate=End date
pollen.common.firstName=First name
pollen.common.functions=Functions
+pollen.common.group=group
pollen.common.lastName=Last name
pollen.common.ldapImport=LDAP import
pollen.common.license=Licence
@@ -56,6 +63,11 @@
pollen.common.nbAccounts=Number of members
pollen.common.newPassword=New password
pollen.common.newPassword2=Reenter new passworsd
+pollen.common.normal=normal
+pollen.common.numberVote-average=Average of numbers
+pollen.common.numberVote-blank-votes=Number of blank votes
+pollen.common.numberVote-total=Sum of numbers
+pollen.common.numberVote-total-votes=Total votes
pollen.common.or=or
pollen.common.password=Password
pollen.common.password2=Renter your password
@@ -73,13 +85,18 @@
pollen.common.pollOption.reminderHourCountdown=Hours before end
pollen.common.pollType=Poll type
pollen.common.postDate=Comment date
+pollen.common.results=Results\:
pollen.common.title=Title
pollen.common.userSupport=User support
+pollen.common.victories=Winners\:
+pollen.common.victory=Winner\:
+pollen.common.voteCounting-label=Vote Counting\:
pollen.common.voteCountingType=Counting type
pollen.common.voteCountingTypeHelp.condorcet=Condorcet vote\: 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.
pollen.common.voteCountingTypeHelp.normal=Normal vote\: vote for your favorite choice.
pollen.common.voteCountingTypeHelp.number=Voting by number\: The answer is free, leave blank or enter a integer.
pollen.common.voteCountingTypeHelp.percentage=Percentage vote\: allocate choices to get a 100%% total.
+pollen.common.voteNbVotes=%d existing votes
pollen.common.voterName=Votant
pollen.error.accountNotFound=
pollen.error.comment.name.empty=Comment name mandatory
@@ -100,6 +117,8 @@
pollen.error.pollAccount.email.required=Em@il mandatory
pollen.error.pollAccount.not.found=Poll account not found
pollen.error.pollAccount.votingId.required=Name mandatory
+pollen.error.pollNotClosed=The poll is not closed. Results may change.
+pollen.error.pollNotFound=The poll you want to count does not exist.
pollen.error.user.alreadyVoted=Someone has already used the name %s to vote.
pollen.error.user.bad.login.or.password=Login or password invalid.
pollen.error.user.email.already.used=This email is already used
@@ -107,6 +126,7 @@
pollen.error.user.login.already.used=This login is already used
pollen.error.user.not.found=User not found
pollen.error.user.restrictedListsForbidden=The poll is restricted and you are not allowed to vote. Check if you have correctly used the link sent to you by email.
+pollen.error.userNotAllowed=You are not allowed to count the votes for this poll.
pollen.fieldset.connexionInformation=Connexion informations
pollen.fieldset.login=Login
pollen.fieldset.poll.choices=Choices
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-28 15:32:26 UTC (rev 3151)
@@ -4,8 +4,9 @@
poll.common.select.userFavoriteList=Liste
poll.common.vote.results=Résultats
poll.common.vote.results-help=Voir les résultats
-poll.legend.addNewComment=Ajouter un commentaire
-pollen.action.addComment=Ajouter
+poll.common.vote.return=Retour au sondage
+poll.common.vote.return-help=Retour au sondage
+pollen.action.addComment=Ajouter un commentaire
pollen.action.backToFavoriteLists=Retour à la liste des favoris
pollen.action.create=Créer
pollen.action.createFavoriteList=Créer une ouvelle liste
@@ -39,24 +40,35 @@
pollen.common.beginChoiceDate=Date de début des choix
pollen.common.beginDate=Date de début
pollen.common.bugReport=Rapport de bug
+pollen.common.chartType-pie=Camembert
+pollen.common.chartType-pie3d=Camembert 3D
+pollen.common.chartType-ring=Anneau
pollen.common.commentName=Nom
pollen.common.commentText=Commentaire
pollen.common.csvImport=Import CSV
pollen.common.description=Description
+pollen.common.displayType-group=Résultats par groupes
+pollen.common.displayType-normal=Résultats
pollen.common.email=Em@il
pollen.common.endChoiceDate=Date de fin des choix
pollen.common.endDate=Date de fin
pollen.common.firstName=Prénom
pollen.common.functions=Fonctions
+pollen.common.group=groupes
pollen.common.lastName=Nom
pollen.common.ldapImport=Import LDAP
pollen.common.license=Licence
pollen.common.login=Identifiant
pollen.common.name=Nom
pollen.common.nbAccounts=Nombre de membres
-pollen.common.nbVotes=vote-size\=%d votes ont été enregistrés
+pollen.common.nbVotes=%d votes ont été enregistrés
pollen.common.newPassword=Nouveau mot de passe
pollen.common.newPassword2=Répétez votre nouveau mot de passe
+pollen.common.normal=normal
+pollen.common.numberVote-average=Moyenne des nombres
+pollen.common.numberVote-blank-votes=Nombre de votes blancs
+pollen.common.numberVote-total=Somme des nombres
+pollen.common.numberVote-total-votes=Nombre total de votes
pollen.common.or=ou
pollen.common.password=Mot de passe
pollen.common.password2=Répétez votre mot de passe
@@ -74,13 +86,17 @@
pollen.common.pollOption.reminderHourCountdown=heures avant la fin du sondage
pollen.common.pollType=Type de sondage
pollen.common.postDate=Date du commentaire
+pollen.common.results=Résultats \:
pollen.common.title=Titre
pollen.common.userSupport=Support utilisateur
+pollen.common.victories=Gagnants \:
+pollen.common.victory=Gagnant \:
pollen.common.voteCountingType=Type de dépouillement
pollen.common.voteCountingTypeHelp.condorcet=Vote Condorcet \: 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.
pollen.common.voteCountingTypeHelp.normal=Vote normal \: voter pour le ou les choix préférés.
pollen.common.voteCountingTypeHelp.number=Vote par nombre \: La réponse est libre, laissez vide ou entrez un nombre entier
pollen.common.voteCountingTypeHelp.percentage=Vote par pourcentage \: répartir les choix de manière à obtenir 100%% au total.
+pollen.common.voteNbVotes=%d votes existants
pollen.common.voterName=Votant
pollen.common.x=Dépouillement
pollen.error.accountNotFound=
@@ -102,6 +118,8 @@
pollen.error.pollAccount.email.required=Em@il obliqatoire
pollen.error.pollAccount.not.found=Membre non trouvé
pollen.error.pollAccount.votingId.required=Nom obliqatoire
+pollen.error.pollNotClosed=Ce sondage n'est pas clos. Les résultats peuvent encore changer.
+pollen.error.pollNotFound=Le sondage que vous voulez dépouiller n'existe pas.
pollen.error.user.alreadyVoted=Une personne a déjà voté sous le nom %s.
pollen.error.user.bad.login.or.password=Mauvais identifiant ou mot de passe.
pollen.error.user.email.already.used=Le courriel saisi est déjà utilisé par un autre utilisateur
@@ -109,6 +127,7 @@
pollen.error.user.login.already.used=Le login saisie est déjà utilisé par un autre utilisateur
pollen.error.user.not.found=Utilisateur non trouvé
pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'êtes pas autorisé à voter. Vérifiez que vous avez bien utiliser le lien qui vous a été envoyé.
+pollen.error.userNotAllowed=Vous n'êtes pas autorisé à dépouiller ce sondage.
pollen.fieldset.connexionInformation=Information de connexion
pollen.fieldset.login=Connexion
pollen.fieldset.poll.choices=Les choix
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -193,6 +193,7 @@
<include file="config/struts-admin.xml"/>
<include file="config/struts-poll.xml"/>
<include file="config/struts-user.xml"/>
+ <include file="config/struts-io.xml"/>
</struts>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-02-28 15:32:26 UTC (rev 3151)
@@ -58,7 +58,7 @@
href="mailto:%{configuration.adminEmail}">
<img src="<s:url value='/img/contact.png' />" alt="Contact"/>
</s:a>
- | Date - Heure |
+ | <%=PollenActionSupport.getCurrentDateTime()%> |
<s:a action="changeLang" id="localeFr">
<s:param name="request_locale">fr_FR</s:param>
<img src="<s:url value='/img/fr.png' />" alt="Français"/>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -30,6 +30,7 @@
<pattern>/config-browser/*</pattern>
<pattern>/json/*</pattern>
<pattern>/poll/confirmDelete*</pattern>
+ <pattern>/io/*</pattern>
</excludes>
<decorator name="layout-default" page="layout-default.jsp">
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-02-28 15:32:26 UTC (rev 3151)
@@ -22,4 +22,158 @@
#L%
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<h2>result poll TODO</h2>
\ No newline at end of file
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+<link rel="stylesheet" type="text/css"
+ href="<s:url value='/css/results.css'/>"/>
+
+<script type="text/javascript">
+
+ function displayNormalChartUrl(type) {
+ var url = "<s:url value='%{getNormalPollResultChartUrl(400,300)}' escapeAmp='false'/>&type=" + type;
+ $('#normalChartImg').attr('src', url);
+ return false;
+ }
+
+ jQuery(document).ready(function () {
+ $('#displayChart1').click();
+ });
+
+
+</script>
+<s:if test="userAllowed">
+
+ <h1 class="titleVoteCounting"><s:property value="poll.title"/></h1>
+
+ <!-- Informations sur le sondage -->
+ <div id="resultTop">
+ <s:property value="poll.description"/>
+ <fieldset>
+ <legend><s:text name="poll.common.aboutPoll"/></legend>
+ <div style="float: right">
+ <s:a namespace="/poll" action="votefor/%{uriId}">
+ <img src="<s:url value='/img/vote.png'/>"
+ title="<s:text name="poll.common.vote.return-help"/>"
+ alt="<s:text name="poll.common.vote.return"/>"/>
+ </s:a>
+ </div>
+ <s:label value="%{poll.creator.votingId}"
+ key='pollen.common.pollCreator'/>
+ <s:label value="%{poll.beginDate}" key='pollen.common.beginDate'/>
+ <s:label value="%{poll.endDate}"
+ label='%{getText("pollen.common.endDate")}'/>
+ <s:label value="%{poll.voteCountingType}"
+ label='%{getText("pollen.common.voteCountingType")}'
+ tooltip="%{voteCountingTypeHelp}"
+ tooltipIconPath="/img/help.png"/>
+ </fieldset>
+ </div>
+
+ <!-- Victoire -->
+ <s:if test="victoryMessage != ''">
+ <h4><s:property value="victoryMessage"/>
+ <br/>
+ <s:iterator value="topRanking" var="result">
+
+ <s:if test="textType">
+ <s:property value="%{#result.name}"/>
+ </s:if>
+ <s:if test="dateType">
+ <s:property value="%{getResultNameAsDate(#result.name)}"/>
+ </s:if>
+ <s:if test="imageType">
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false">
+ <s:param name="choiceId" value="name"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
+
+ <img alt="<s:property value='name'/>"
+ title="<s:property value='name'/>"
+ src="<s:property value='imageUrl'/>">
+
+ </s:if>
+ <br/>
+ </s:iterator>
+ </h4>
+ </s:if>
+
+ <!-- Diagramme -->
+ <div id="resultChart">
+ <div class="chartTypeDiv">
+ <sj:a id='displayChart1' href="#"
+ onclick="return displayNormalChartUrl(1);">
+ <img src="<s:url value='/img/rep1.png'/>"
+ title='<s:text name="pollen.common.chartType-pie"/>' alt="1"/>
+ </sj:a>
+ <sj:a id='displayChart2' href="#"
+ onclick="return displayNormalChartUrl(2);">
+ <img src="<s:url value='/img/rep2.png'/>"
+ title='<s:text name="pollen.common.chartType-pie3d"/>' alt="2"/>
+ </sj:a>
+ <sj:a id='displayChart3' href="#"
+ onclick="return displayNormalChartUrl(3);">
+ <img src="<s:url value='/img/rep3.png'/>"
+ title='<s:text name="pollen.common.chartType-ring"/>' alt="3"/>
+ </sj:a>
+ </div>
+
+ <div class="displayTypeDiv">
+ <s:if test="groupPoll">
+ <s:text name="pollen.common.results"/>
+ <s:if test="byGroup">
+ <s:a href="#" onclick="return false;">
+ <s:text name="pollen.common.normal"/>
+ </s:a>
+ - <s:text name="pollen.common.group"/>
+ </s:if>
+ <s:else>
+ <s:text name="pollen.common.normal"/> -
+ <s:a href="#" onclick="return false;">
+ <s:text name="pollen.common.group"/>
+ </s:a>
+ </s:else>
+ </s:if>
+ </div>
+
+ <sj:div id='chartContainer'>
+ <img id='normalChartImg'/>
+ </sj:div>
+
+ <!-- Diagramme par choix -->
+ <s:if test="choicesResults != null">
+ <div id="resultChart">
+ <div>
+ <s:iterator value="choicesResults.entrySet()" var="choicesResult">
+ <s:property value="%{#choicesResult.key}"/>
+ <s:property value="%{#choicesResult.value}"/>
+ <%--<t:chart title="${choicesResult.key}" width="400" height="300"--%>
+ <%--values="choicesResult.value" type="${type}"--%>
+ <%--t:subtitles="subtitles.get(choicesResult.key)" />--%>
+ </s:iterator>
+ </div>
+ </div>
+ </s:if>
+ </div>
+ <!-- Classement -->
+ <%--<t:remove>--%>
+ <%--<div id="resultList">--%>
+ <%--<ol>--%>
+ <%--<s:iterator value="ranking" var="result">--%>
+ <%--<li>--%>
+ <%--<s:if test="dateType">--%>
+ <%--<s:property value="%{getResultNameAsDate(#result.name)}"/>--%>
+ <%--<%–<t:output value="resultNameAsDate" format="dateFormat"/>–%>--%>
+ <%--</s:if>--%>
+ <%--<s:else>--%>
+ <%--<s:property value="name"/>--%>
+ <%--</s:else>--%>
+ <%--(<s:property value="%{getTrimValue(#result)}"/>)--%>
+ <%--</li>--%>
+ <%--</s:iterator>--%>
+ <%--</ol>--%>
+ <%--</div>--%>
+ <%--</t:remove>--%>
+
+</s:if>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-28 15:32:26 UTC (rev 3151)
@@ -26,11 +26,12 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<link rel="stylesheet" type="text/css"
+ href="<s:url value='/css/vote.css'/>"/>
+
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
-<%--<s:url id="deleteCommentUrl" action="confirmDeleteComment" namespace="/poll"/>--%>
-
<s:url id='deleteImg' value='/img/delete.png'/>
<s:set id='deleteTitle'><s:text name="pollen.action.pollCommentDelete"/></s:set>
@@ -104,8 +105,7 @@
<div style="float: right">
<s:if test="poll.publicResults">
- <s:a namespace="/poll" action="result" method="input">
- <s:param name="pollId" value="poll.pollId"/>
+ <s:a namespace="/poll" action="results/%{uriId}">
<img src="<s:url value='/img/count.png'/>"
title="<s:text name="poll.common.vote.results-help"/>"
alt="<s:text name="poll.common.vote.results"/>"/>
@@ -119,25 +119,23 @@
</s:a>
</s:if>
</div>
- <s:label value="%{poll.creator.votingId}" key='pollen.common.pollCreator'/>
+ <s:label value="%{creatorName}" key='pollen.common.pollCreator'/>
<s:label value="%{poll.beginDate}" key='pollen.common.beginDate'/>
- <s:label value="%{poll.endDate}"
- label='%{getText("pollen.common.endDate")}'/>
+ <s:label value="%{poll.endDate}" key='pollen.common.endDate'/>
<s:label value="%{poll.voteCountingType}"
label='%{getText("pollen.common.voteCountingType")}'
tooltip="%{voteCountingTypeHelp}" tooltipIconPath="/img/help.png"/>
</fieldset>
</div>
+<div id="pollZone">
<s:if test="pollChoiceOrVoteStarted">
-<br/>
-
<!-- Sondage -->
<s:if test="poll.anonymous">
<p>
- <s:text name="pollen.common.nbVotes">
+ <s:text name="pollen.common.voteNbVotes">
<s:param><s:property value="%{poll.sizeVote()}"/></s:param>
</s:text>
</p>
@@ -145,6 +143,11 @@
</s:if>
<s:else>
<%--TODO Do me!--%>
+ <div class="p-pager">
+ <s:text name="pollen.common.voteNbVotes">
+ <s:param><s:property value="%{poll.sizeVote()}"/></s:param>
+ </s:text>
+ </div>
<%--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"--%>
<%--t:currentPage="page" t:noPagerText="prop:noPagerText"/>--%>
</s:else>
@@ -178,19 +181,17 @@
<span title="<s:text name="pollen.common.description"/>"
value="%{escapeLineBreak(#choice.description)}">
<span class="desc">
- <s:property value="%{#choice.name}"/>
+ <s:property value="name"/>
</span>
</span>
</s:if>
<s:else>
- <s:property value="%{#choice.name}"/>
+ <s:property value="name"/>
</s:else>
<s:if test="pollChoiceRunning">
<s:if test="creatorUser">
<s:a action="deleteChoice" namespace="/poll">
- <s:param name="choiceId">
- <s:property value="%{#choice.id}"/>
- </s:param>
+ <s:param name="choiceId"><s:property value="id"/></s:param>
<img src="<s:url value="/img/delete.png"/>"
title="<s:text name="pollen.action.deleteChoice"/>"
alt="<s:text name="pollen.action.deleteChoice"/>"/>
@@ -208,16 +209,15 @@
<s:if test="!isDescNull(#choice)">
<th class="desc">
- <span title="<s:text name="pollen.common.description"/>"
- value="%{escapeLineBreak(#choice.description)}">
- <s:property value="%{#choice.choiceNameAsDate}"/>
+ <span
+ title='<s:property value="escapeLineBreak(#choice.description)"/>'>
+ <s:property value="%{formatChoiceNameAsDate(#choice)}"/>
</span>
</th>
</s:if>
<s:else>
<th>
- <s:property value="%{#choice.choiceNameAsDate}"/>
- <%--<t:output value="choiceNameAsDate" format="dateFormat"/>--%>
+ <s:property value="%{formatChoiceNameAsDate(#choice)}"/>
</th>
</s:else>
</s:if>
@@ -227,25 +227,27 @@
<s:if test="imageType">
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
+ <s:url id="imageUrl" namespace="/io"
+ action="getPollChoiceImage"
+ escapeAmp="false">
+ <s:param name="choiceId" value="name"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
<s:if test="!isDescNull(#choice)">
<th class="desc">
- <span title="<s:text name="pollen.common.description"/>"
- value="%{escapeLineBreak(#choice.description)}">
- <%--Obtain image from poll.pollId/choice.name--%>
- <s:property value="%{#choice.name}"/>
- <%--<t:image--%>
- <%--t:src="#choice.name"--%>
- <%--alt="#choice.description"--%>
- <%--t:dir="poll.pollId"/>--%>
- </span>
+ <img alt="<s:property value='name'/>"
+ title='<s:property value="escapeLineBreak(#choice.description)"/>'
+ src="<s:property value='imageUrl'/>">
</th>
</s:if>
<s:else>
<th>
- <%--Obtain image from poll.pollId/choice.name--%>
- <s:property value="%{#choice.name}"/>
+ <img alt="<s:property value='name'/>"
+ title='<s:property value="escapeLineBreak(#choice.description)"/>'
+ src="<s:property value='imageUrl'/>">
</th>
</s:else>
</s:if>
@@ -269,24 +271,20 @@
<s:if test="!isChoiceHidden(#choice)">
<th>
- <s:if
- test="normalVoteCounting">
- <s:checkbox value="addChoice" theme="simple"/>
+ <s:if test="normalVoteCounting">
+ <s:checkbox name="addChoice" theme="simple"/>
</s:if>
- <s:if
- test="percentageVoteCounting">
+ <s:if test="percentageVoteCounting">
<s:textfield value="#choice.value" size="3" required="true"
theme="simple"/>
<%--t:validate="required, min=0, max=100"/>%--%>
</s:if>
- <s:if
- test="condorcetVoteCounting">
+ <s:if test="condorcetVoteCounting">
<s:textfield id="condorcetInput" value="choice.value" size="3"
theme="simple"/>
<%--t:nulls="zero" t:validate="min=0, max=99"/>--%>
</s:if>
- <s:if
- test="numberVoteCounting">
+ <s:if test="numberVoteCounting">
<s:textfield value="addNumberVote" size="3" theme="simple"/>
</s:if>
</th>
@@ -302,7 +300,7 @@
<td>
<s:if test="accountFieldDisplayed">
<s:if test="!#vote.anonymous">
- <s:property value="%{#vote.pollAccount.votingId}"/>
+ <s:property value="pollAccount.votingId"/>
</s:if>
<s:else>
?
@@ -321,8 +319,6 @@
<s:if test="creatorUser">
<s:a action="deleteVote" namespace="/poll" href="#"
onclick="return openDeleteVoteDialog('%{#vote.topiaId}');">
- <%--<s:param name="uriId" value="%{uriId}"/>--%>
- <%--<s:param name="voteId" value="%{#vote.topiaId}"/>--%>
<img src="<s:url value="/img/delete.png"/>"
title="<s:text name="pollen.action.deleteVote"/>"
alt="<s:text name="pollen.action.deleteVote"/>"/>
@@ -366,8 +362,7 @@
<td class="notVoted"></td>
</s:else>
</s:if>
- <s:if
- test="numberVoteCounting">
+ <s:if test="numberVoteCounting">
<s:if test="isChoiceInVote(#currentVoteChoice)">
<td class="voted">
<s:property value="%{#currentVoteChoice.voteValue}"/>
@@ -386,12 +381,9 @@
<s:if test="poll.continuousResults">
<tr>
<td>
- <s:a namespace="/poll" action="result" method="input">
- <s:param name="pollId" value="poll.pollId"/>
+ <s:a namespace="/poll" action="results/%{poll.pollId}">
<s:text name="poll.common.vote.results"/>
</s:a>
- <%--<t:PageLink t:page="poll/results"--%>
- <%--t:context="${poll.pollId}">${message:results}</t:PageLink>--%>
</td>
<s:iterator value="poll.choice" var="choice">
@@ -416,55 +408,83 @@
<%--<t:label for="anonymousVote"/>--%>
<br/>
</s:if>
- <s:submit action="vote" key="pollen.action.vote"/>
+ <s:submit action="vote" key="pollen.action.pollVote"/>
<%--<input id="submitVote" t:type="Submit" t:value="${message:submitVote}"/>--%>
</div>
</s:if>
</s:form>
-
+</div>
<!-- Ajout de commentaires -->
<h3><s:text name="poll.common.comments"/></h3>
-<div id="commentsDiv">
+<div id="commentZone">
+ <div id="commentsDiv">
+ <s:iterator value="comments" var="comment" status="status">
+ <div
+ <s:if test="#status.even">class="even"</s:if>
+ <s:else>class="odd"</s:else>
+ >
+ <s:if test="creatorUser">
+ <span class="cmd">
+ <s:a href="#"
+ onclick="return openDeleteCommentDialog('%{#comment.topiaId}');">
+ <img src="<s:url value='/img/delete.png'/>"
+ title="<s:text name="pollen.action.pollCommentDelete"/>"
+ alt="<s:text name="pollen.action.pollCommentDelete"/>"/>
+ </s:a>
+ </span>
+ </s:if>
+ <span class="name"><s:property value='pollAccount.votingId'/></span> :
+ <span class="date">
+ <s:property value='%{formatDateTime(postDate)}'/>
+ </span>
- <s:url id="loadPollComments" action="getPollComments" namespace="/json"
- escapeAmp="false">
- <s:param name="pollId" value="%{poll.pollId}"/>
- </s:url>
+ <p>
+ <s:property value='text'/>
+ </p>
+ </div>
+ </s:iterator>
+ </div>
+ <%--div id="commentsDiv">
- <sjg:grid id="comments" dataType="json" href="%{loadPollComments}"
- gridModel="comments" sortable="true" pager="true"
- pagerButtons="true" pagerInput="true" navigator="true"
- rownumbers="false" autowidth="true" editinline="false"
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true" sortorder="desc"
- sortname="postDate" rowList="10,15,20,50,100" rowNum="10">
+ <s:url id="loadPollComments" action="getPollComments" namespace="/json"
+ escapeAmp="false">
+ <s:param name="pollId" value="%{poll.pollId}"/>
+ </s:url>
- <sjg:gridColumn name="id" title="id" hidden="true"/>
- <sjg:gridColumn name="postDate" title='%{getText("pollen.common.postDate")}'
- sortable="true" formatter="date" width="50"
- formatoptions="{newformat : 'd.m.Y H:i', srcformat : 'Y-m-d H:i:s'}"/>
- <sjg:gridColumn name="pollAccount.votingId"
- title='%{getText("pollen.common.commentName")}'
- sortable="true"/>
- <sjg:gridColumn name="text" title='%{getText("pollen.common.commentText")}'
- sortable="true"/>
- <sjg:gridColumn name="functions" sortable="false" title='' width="10"
- formatter="commentFunctions"/>
- </sjg:grid>
-</div>
+ <sjg:grid id="comments" dataType="json" href="%{loadPollComments}"
+ gridModel="comments" sortable="true" pager="true"
+ pagerButtons="true" pagerInput="true" navigator="true"
+ rownumbers="false" autowidth="true" editinline="false"
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true" sortorder="desc"
+ sortname="postDate" rowList="10,15,20,50,100" rowNum="10">
-<br/>
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+ <sjg:gridColumn name="postDate"
+ title='%{getText("pollen.common.postDate")}'
+ sortable="true" formatter="date" width="50"
+ formatoptions="{newformat : 'd.m.Y H:i', srcformat : 'Y-m-d H:i:s'}"/>
+ <sjg:gridColumn name="pollAccount.votingId"
+ title='%{getText("pollen.common.commentName")}'
+ sortable="true"/>
+ <sjg:gridColumn name="text"
+ title='%{getText("pollen.common.commentText")}'
+ sortable="true"/>
+ <sjg:gridColumn name="functions" sortable="false" title='' width="10"
+ formatter="commentFunctions"/>
+ </sjg:grid>
+ </div--%>
-<div id="commentFormDiv">
+ <%--<br/>--%>
- <fieldset>
- <legend><s:text name="poll.legend.addNewComment"/></legend>
+ <div id="commentFormDiv">
+
<s:form id='addCommentForm' method="POST" namespace="/poll">
<s:hidden key="pollId" label=''/>
- <s:textfield key="commentName" required="true"
+ <s:textfield key="commentName" required="true" size="78"
label="%{getText('pollen.common.commentName')}"/>
<s:textarea key="commentText" required="true" value=''
label="%{getText('pollen.common.commentText')}"/>
@@ -474,11 +494,12 @@
align="left"/>
</div>
</s:form>
- </fieldset>
-</div>
-<sj:dialog id="deleteCommentDialog" resizable="false"
- title="%{getText('pollen.title.delete.pollComment')}"
- autoOpen="false" modal="true" width="800"/>
+ </div>
+ <sj:dialog id="deleteCommentDialog" resizable="false"
+ title="%{getText('pollen.title.delete.pollComment')}"
+ autoOpen="false" modal="true" width="800"/>
+
+</div>
</s:if>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp 2012-02-28 15:32:26 UTC (rev 3151)
@@ -29,11 +29,11 @@
<s:url id="loadUrl" action="getPolls" namespace="/json" method="input"/>
-<s:url id="voteUrl" action="vote" namespace="/poll" method="input"/>
+<s:url id="voteUrl" action="votefor/" namespace="/poll"/>
<s:url id='voteImg' value='/img/vote.png'/>
<s:set id='voteTitle'><s:text name="pollen.action.pollVote"/></s:set>
-<s:url id="resultUrl" action="result" namespace="/poll" method="input"/>
+<s:url id="resultUrl" action="results/" namespace="/poll"/>
<s:url id='resultImg' value='/img/count.png'/>
<s:set id='resultTitle'><s:text name="pollen.action.pollResult"/></s:set>
@@ -69,10 +69,10 @@
if (rowObject['voteId']) {
id = rowObject['voteId'];
}
- result += formatLink(id, "${voteUrl}", "${voteImg}", "Vote", "${voteTitle}")
+ result += formatLink(null, "${voteUrl}"+id, "${voteImg}", "Vote", "${voteTitle}")
}
if (cellvalue.indexOf('result') > -1) {
- result += formatLink(id, "${resultUrl}", "${resultImg}", "Result", "${resultTitle}")
+ result += formatLink(null, "${resultUrl}"+id, "${resultImg}", "Result", "${resultTitle}")
}
if (cellvalue.indexOf('edit') > -1) {
result += formatLink(id, "${editUrl}", "${editImg}", "Edit", "${editTitle}")
@@ -92,7 +92,10 @@
return result;
}
function formatLink(id, baseUrl, image, imageAlt, imageTitle) {
- var url = $.prepareUrl(baseUrl, {pollId:id});
+ var url = baseUrl;
+ if (id) {
+ url = $.prepareUrl(baseUrl, {pollId:id});
+ }
return "<a href='" + url + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>";
}
</script>
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/results.css (from rev 3149, branches/pollen-1.2.6-struts2/pollen-ui/src/main/webapp/css/results.css)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/results.css (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/results.css 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+#resultTop {
+ width: 700px;
+ margin: auto;
+ text-align: center;
+}
+
+#resultTop legend {
+ color: #727a7e;
+ font-weight: bold;
+}
+
+#resultTop fieldset {
+ width: 350px;
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ margin: auto;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ vertical-align: top;
+ text-align: left;
+}
+
+#resultChart {
+ width: 400px;
+ margin: auto;
+ text-align: left;
+}
+
+#resultChart .displayTypeDiv {
+ margin-left: 10px;
+}
+
+#resultChart .chartTypeDiv {
+ margin-right: 10px;
+ float: right;
+}
+
+#resultList {
+ width: 500px;
+ margin: auto;
+ margin-top: 20px;
+ text-align: center;
+}
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/vote.css (from rev 3149, branches/pollen-1.2.6-struts2/pollen-ui/src/main/webapp/css/vote.css)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/vote.css (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/vote.css 2012-02-28 15:32:26 UTC (rev 3151)
@@ -0,0 +1,215 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+#pollTop {
+ width: 700px;
+ margin: auto;
+ text-align: center;
+}
+
+#pollTop legend {
+ color: #727a7e;
+ font-weight: bold;
+}
+
+#pollTop fieldset {
+ width: 350px;
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ margin: auto;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ vertical-align: top;
+ text-align: left;
+}
+
+#pollZone {
+ /*padding: 10px;*/
+ text-align: center;
+ -moz-border-radius: 15px;
+}
+
+#pollZone form {
+ margin-top: 10px;
+}
+
+#poll {
+ border-collapse: collapse;
+ border-left: 1px solid #aab;
+ border-top: 1px solid #aab;
+ background-color: #fff;
+ font-size: 14px;
+ margin: auto;
+}
+
+#poll THEAD,
+#poll TFOOT {
+ border-top: 1px solid #aab; /* For Firefox */
+}
+
+#poll THEAD TR {
+ color: #fff;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR a {
+ color: #fff;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR TH {
+ text-align: left;
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR TH .desc {
+ padding: 2px 3px;
+ text-decoration: overline;
+}
+
+#poll TFOOT TR TH {
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color: #55cb00;
+}
+
+#poll TFOOT TR #voterName {
+ text-align: left;
+}
+
+#poll TBODY TR {
+ background-color: #fff;
+}
+
+#poll TBODY TR .odd {
+ background-color: #b0f580;
+}
+
+#poll TBODY TR .anonymous {
+ background-color: #ddd;
+ text-align: center;
+}
+
+#poll TBODY TR .voted {
+ background-color: #6f6;
+ color: #242;
+ text-align: center;
+}
+
+#poll TBODY TR .notVoted {
+ background-color: #f66;
+}
+
+#poll TBODY TR .result {
+ background-color: #e5e5e5;
+ color: #555;
+ text-align: center;
+}
+
+#poll TBODY TR TD {
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ padding: 2px 5px;
+}
+
+#buttons {
+ text-align: center;
+ margin: 10px;
+}
+
+#voteError {
+ width: 600px;
+ margin: auto;
+ margin-top: 10px;
+}
+
+#voteError .t-error div,
+#voteError .t-error ul {
+ padding: 3px;
+}
+
+#voteError .t-error LI
+{
+ list-style:disc;
+ margin-left: 20px;
+}
+
+#choiceFormDiv form {
+ width: 200px;
+ margin: auto;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ padding: 10px 50px 10px 50px;
+ border-top: 1px solid #aab;
+}
+
+#commentZone {
+ width: 600px;
+ margin: auto;
+}
+
+#commentZone textarea {
+ width: 500px;
+ height: 100px;
+}
+
+#commentFormDiv form {
+ margin-top: 20px;
+ padding: 10px 50px 0px 50px;
+ border-top: 1px solid #aab;
+}
+
+#commentsDiv .odd {
+ background-color: #d7fabf;
+}
+
+#commentsDiv .name {
+ color: #55cb00;
+ font-weight: bold;
+}
+
+#commentsDiv .date {
+ color: #555555;
+ font-size: 11px;
+}
+
+#commentsDiv .cmd {
+ float: right;
+}
+
+#commentsDiv p {
+ font-size: 12px;
+ margin-top: 0px;
+ margin-bottom: 0px;
+}
+
+#commentsDiv div {
+ padding: 5px 15px;
+}
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pom.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pom.xml 2012-02-28 15:31:30 UTC (rev 3150)
+++ branches/pollen-1.2.6-struts2/pom.xml 2012-02-28 15:32:26 UTC (rev 3151)
@@ -197,6 +197,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-jfreechart-plugin</artifactId>
+ <version>${struts2Version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>${struts2Version}</version>
1
0
r3150 - branches/pollen-1.2.6-struts2/pollen-ui/src/main/webapp/WEB-INF
by tchemit@users.chorem.org 28 Feb '12
by tchemit@users.chorem.org 28 Feb '12
28 Feb '12
Author: tchemit
Date: 2012-02-28 16:31:30 +0100 (Tue, 28 Feb 2012)
New Revision: 3150
Url: http://chorem.org/repositories/revision/pollen/3150
Log:
delete struts stuff from tapestry module
Removed:
branches/pollen-1.2.6-struts2/pollen-ui/src/main/webapp/WEB-INF/decorators/
1
0
r3149 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/resources/i18n pollen-ui-struts2/src/main/resources/i18n
by tchemit@users.chorem.org 26 Feb '12
by tchemit@users.chorem.org 26 Feb '12
26 Feb '12
Author: tchemit
Date: 2012-02-26 18:51:43 +0100 (Sun, 26 Feb 2012)
New Revision: 3149
Url: http://chorem.org/repositories/revision/pollen/3149
Log:
i18n
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-02-26 17:20:56 UTC (rev 3148)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-02-26 17:51:43 UTC (rev 3149)
@@ -32,6 +32,7 @@
pollFeed_title=Pollen \: %s
pollFeed_voteContent=Poll state \: %s
pollFeed_voteTitle=New vote from %s
+pollen.common.anonymous=
pollen.email.userRegister.content=Welcome %1$s. You had just created an account on the web application Pollen.\n\nLogin\: %2$s\nPassword\: %3$s\n\nYou can now manage your polls by logging on the website \: \n%4$s
pollen.email.userRegister.subject=[Pollen] Confirmation of account creation %s
pollen.error.context.close=
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-26 17:20:56 UTC (rev 3148)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-02-26 17:51:43 UTC (rev 3149)
@@ -37,6 +37,7 @@
participantEmail-regexp-message=Adresse email invalide.
passwordComp-label=Mot de passe
passwordComp-required-message=Vous devez entrer votre mot de passe.
+pollen.common.anonymous=
pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%2$s\nModération des votes \: \n%3$s\nPage de modification \: \n%4$s
pollen.email.createPoll.subject=[Pollen] Création d'un sondage (%1$s)
pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de créer un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant \: %2$s\nMot de passe \: %3$s\n\nVous pouvez dès maintenant gérer vos sondages en vous identifiant sur le site \: \n%4$s
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-26 17:20:56 UTC (rev 3148)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-26 17:51:43 UTC (rev 3149)
@@ -102,13 +102,13 @@
pollen.error.pollAccount.email.required=Em@il obliqatoire
pollen.error.pollAccount.not.found=Membre non trouvé
pollen.error.pollAccount.votingId.required=Nom obliqatoire
-pollen.error.user.alreadyVoted=Une personne a d\u00E9j\u00E0 vot\u00E9 sous le nom %s.
+pollen.error.user.alreadyVoted=Une personne a déjà voté sous le nom %s.
pollen.error.user.bad.login.or.password=Mauvais identifiant ou mot de passe.
pollen.error.user.email.already.used=Le courriel saisi est déjà utilisé par un autre utilisateur
pollen.error.user.invalid.password=Mot de passe invalide
pollen.error.user.login.already.used=Le login saisie est déjà utilisé par un autre utilisateur
pollen.error.user.not.found=Utilisateur non trouvé
-pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'\u00EAtes pas autoris\u00E9 \u00E0 voter. V\u00E9rifiez que vous avez bien utiliser le lien qui vous a \u00E9t\u00E9 envoy\u00E9.
+pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'êtes pas autorisé à voter. Vérifiez que vous avez bien utiliser le lien qui vous a été envoyé.
pollen.fieldset.connexionInformation=Information de connexion
pollen.fieldset.login=Connexion
pollen.fieldset.poll.choices=Les choix
1
0
r3148 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/config resources/i18n webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 26 Feb '12
by tchemit@users.chorem.org 26 Feb '12
26 Feb '12
Author: tchemit
Date: 2012-02-26 18:20:56 +0100 (Sun, 26 Feb 2012)
New Revision: 3148
Url: http://chorem.org/repositories/revision/pollen/3148
Log:
continue vote page
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Result.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-26 17:20:56 UTC (rev 3148)
@@ -26,9 +26,11 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollResultListBean;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
@@ -37,10 +39,12 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollFeedService;
+import org.chorem.pollen.services.impl.PollResultsService;
import org.chorem.pollen.services.impl.PollService;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
+import org.chorem.pollen.services.impl.VoteService;
import java.util.Date;
+import java.util.List;
/**
* Abstract action for actions on the vote poll page.
@@ -69,6 +73,10 @@
protected boolean pollRunning;
+ protected boolean alreadyVoted;
+
+ private boolean anonymousVote;
+
protected String voteCountingTypeHelp;
protected String defaultCommentName;
@@ -83,6 +91,8 @@
private String pollAccountId;
+ private List<Result> results;
+
@Override
public final String getPageLogo() {
return "Vote";
@@ -105,6 +115,11 @@
}
public PollAccount getPollAccount() {
+ if (pollAccount == null) {
+ PollService service = newService(PollService.class);
+ pollAccount = service.getNewPollAccount(
+ getPollenSession().getUserAccount());
+ }
return pollAccount;
}
@@ -116,6 +131,14 @@
return pollChoiceOrVoteStarted;
}
+ public boolean isAlreadyVoted() {
+ return alreadyVoted;
+ }
+
+ public boolean isAnonymousVote() {
+ return anonymousVote;
+ }
+
public final String getVoteCountingTypeHelp() {
return voteCountingTypeHelp;
}
@@ -128,6 +151,10 @@
return commentName;
}
+ public List<Result> getResults() {
+ return results;
+ }
+
public void prepareVotePage() throws Exception {
loadPoll();
@@ -135,6 +162,10 @@
if (poll != null) {
loadPollAccount();
+
+ loadPollResults();
+
+
PollFeedService pollFeedService = newService(PollFeedService.class);
feedFileExisting = pollFeedService.isFeedExists(poll);
@@ -168,7 +199,6 @@
defaultCommentName = userAccount.getDisplayName();
}
- //TODO Fill this
Date currentTime = serviceContext.getCurrentTime();
accountFieldDisplayed = !poll.getAnonymous() || isRestrictedPoll() || isGroupPoll();
@@ -198,38 +228,111 @@
}
creatorName = poll.getCreator().getVotingId();
-
// voteSizeMessage=XXX;
}
}
- protected void loadPollAccount() {
+ private transient PollResultsService pollResultsService;
+ private PollResultsService getPollResultsService() {
+ if (pollResultsService == null) {
+ pollResultsService = newService(PollResultsService.class);
+ }
+ return pollResultsService;
+ }
+
+ public String getResultValue(Choice choice) {
+
+ String val = getPollResultsService().getResultValue(choice, results);
+ return val;
+ }
+
+ protected void loadPollResults() {
+
+ PollResultsService service = getPollResultsService();
+
+ PollResultListBean resultListDTO;
+ if (isGroupPoll()) {
+ resultListDTO = service.getGroupResults(poll.getPollId());
+ } else {
+ resultListDTO = service.getNormalResults(poll.getPollId());
+ }
+
+ results = resultListDTO.getResultDTOs();
+
+ if (log.isDebugEnabled()) {
+ for (Result res : results) {
+ log.debug(res.getName() + ": " + res.getResultValue()
+ + ", (voteCounting=" + res.getVoteCountingType()
+ + ", byGroup=" + res.getByGroup() + ")");
+ }
+ }
+ }
+
+ protected void loadPollAccount() throws PollNotFoundException {
+
PollService service = newService(PollService.class);
- if (StringUtils.isNotEmpty(getAccountId())) {
+ //// Contrôle et définition du votingId
+ alreadyVoted = false;
+ boolean modifAllowed = false;
+ boolean restrictedListsForbidden = false;
- pollAccount = service.getPollAccountByAccountId(getAccountId());
+ // The calcul of alreadyVoted will be needed for no double votingId
+ // Carefull, not correct for an anonymous vote
+ VoteService voteService = newService(VoteService.class);
- if (pollAccount != null) {
+ // Suppression des espaces pouvant provoquer un double vote
+ String votingId = getPollAccount().getVotingId().trim();
+ getPollAccount().setVotingId(votingId);
- pollAccountId = pollAccount.getAccountId();
+ alreadyVoted = voteService.hasAlreadyVoted(votingId, poll);
- } else {
+ // Check for restricted poll
+ if (!alreadyVoted && !isFreePoll()) {
+ if (StringUtils.isNotEmpty(getAccountId())) {
- //TODO Do something in case of none free poll ?, not normal :(
- addActionError(_("pollen.error.accountNotFound"));
+ // The accountUId must be valid for the poll
+ PollAccount restrictedAccount =
+ service.getRestrictedAccount(getPollId(), getAccountId());
- if (!isFreePoll()) {
+ if (restrictedAccount != null) {
+ // PollAccount is replaced by the good account from db
+ pollAccount = restrictedAccount;
- //TODO Should not be able to see the page ?
+ // Refresh alreadyVoted value depends on pollAccount
+// alreadyVoted = pollAccount.isHasVoted();
+
+ } else {
+ // Existing account is null is forbidden for a restricted poll
+ restrictedListsForbidden = true;
}
+
+ } else {
+ // Not allowed to vote without an accountUId
+ restrictedListsForbidden = true;
}
- } else {
- pollAccount = service.getNewPollAccount(getPollenSession().getUserAccount());
+ if (restrictedListsForbidden) {
+ addActionError(_("pollen.error.user.restrictedListsForbidden"));
+ }
}
+
+ // Génération d'un identifiant de vote (si le sondage est libre et anonyme)
+ if (poll.getAnonymous()) {
+ anonymousVote = true;
+ if (isFreePoll()) {
+ getPollAccount().setVotingId(
+ "anonymous" + serviceContext.createPollenUrlId());
+ }
+ }
+
+ modifAllowed = isModifAllowed(getPollAccount().getVotingId());
+ if (alreadyVoted && !modifAllowed) {
+ addActionError(_("pollen.error.user.alreadyVoted",
+ getPollAccount().getVotingId()));
+ }
}
public String escapeLineBreak(String text) {
@@ -263,12 +366,14 @@
return result;
}
- public boolean isModifAllowed(Vote vote) {
+ public boolean isModifAllowed(String voteId) {
boolean result = false;
+ Vote vote = poll.getVoteByTopiaId(voteId);
+
// can only modify a vote if poll is running.
- if (pollRunning) {
+ if (vote != null && pollRunning) {
PollAccount votePollAccount = vote.getPollAccount();
// si le votant du vote correspond au votant actuel (pollAccountId)
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Result.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Result.java 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Result.java 2012-02-26 17:20:56 UTC (rev 3148)
@@ -1,37 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.ui.actions.poll;
-
-import org.chorem.pollen.ui.actions.PollenActionSupport;
-
-/**
- * Display results of a poll.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2.6
- */
-public class Result extends PollenActionSupport {
-
- private static final long serialVersionUID = 1L;
-}
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java (from rev 3144, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Result.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-02-26 17:20:56 UTC (rev 3148)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * Display results of a poll.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class ResultForPoll extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-26 17:20:56 UTC (rev 3148)
@@ -101,7 +101,7 @@
<!-- display poll result -->
<action name="result"
- class="org.chorem.pollen.ui.actions.poll.Result">
+ class="org.chorem.pollen.ui.actions.poll.ResultForPoll">
<result name="input">/WEB-INF/jsp/poll/result.jsp</result>
<result>/WEB-INF/jsp/home.jsp</result>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-26 17:20:56 UTC (rev 3148)
@@ -100,11 +100,13 @@
pollen.error.pollAccount.email.required=Em@il mandatory
pollen.error.pollAccount.not.found=Poll account not found
pollen.error.pollAccount.votingId.required=Name mandatory
+pollen.error.user.alreadyVoted=Someone has already used the name %s to vote.
pollen.error.user.bad.login.or.password=Login or password invalid.
pollen.error.user.email.already.used=This email is already used
pollen.error.user.invalid.password=Invalid password
pollen.error.user.login.already.used=This login is already used
pollen.error.user.not.found=User not found
+pollen.error.user.restrictedListsForbidden=The poll is restricted and you are not allowed to vote. Check if you have correctly used the link sent to you by email.
pollen.fieldset.connexionInformation=Connexion informations
pollen.fieldset.login=Login
pollen.fieldset.poll.choices=Choices
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-26 17:20:56 UTC (rev 3148)
@@ -102,11 +102,13 @@
pollen.error.pollAccount.email.required=Em@il obliqatoire
pollen.error.pollAccount.not.found=Membre non trouvé
pollen.error.pollAccount.votingId.required=Nom obliqatoire
+pollen.error.user.alreadyVoted=Une personne a d\u00E9j\u00E0 vot\u00E9 sous le nom %s.
pollen.error.user.bad.login.or.password=Mauvais identifiant ou mot de passe.
pollen.error.user.email.already.used=Le courriel saisi est déjà utilisé par un autre utilisateur
pollen.error.user.invalid.password=Mot de passe invalide
pollen.error.user.login.already.used=Le login saisie est déjà utilisé par un autre utilisateur
pollen.error.user.not.found=Utilisateur non trouvé
+pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'\u00EAtes pas autoris\u00E9 \u00E0 voter. V\u00E9rifiez que vous avez bien utiliser le lien qui vous a \u00E9t\u00E9 envoy\u00E9.
pollen.fieldset.connexionInformation=Information de connexion
pollen.fieldset.login=Connexion
pollen.fieldset.poll.choices=Les choix
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-26 17:19:55 UTC (rev 3147)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-26 17:20:56 UTC (rev 3148)
@@ -309,7 +309,7 @@
</s:else>
</s:if>
<s:if test="!poll.anonymous">
- <s:if test="isModifAllowed(#vote)">
+ <s:if test="isModifAllowed(#vote.topiaId)">
<s:a action="editVote" namespace="/poll">
<s:param name="uriId" value="%{uriId}"/>
<s:param name="voteId" value="%{#vote.topiaId}"/>
@@ -348,8 +348,8 @@
</s:if>
<s:if test="percentageVoteCounting">
<s:if test="isChoiceInVote(#currentVoteChoice)">
- <td class="voted"><s:property
- value="%{#currentVoteChoice.voteValue}"/> %
+ <td class="voted">
+ <s:property value="%{#currentVoteChoice.voteValue}"/> %
</td>
</s:if>
<s:else>
@@ -358,8 +358,9 @@
</s:if>
<s:if test="condorcetVoteCounting">
<s:if test="isChoiceInVote(#currentVoteChoice)">
- <td class="voted"><s:property
- value="%{#currentVoteChoice.voteValue}"/></td>
+ <td class="voted">
+ <s:property value="%{#currentVoteChoice.voteValue}"/>
+ </td>
</s:if>
<s:else>
<td class="notVoted"></td>
@@ -368,8 +369,9 @@
<s:if
test="numberVoteCounting">
<s:if test="isChoiceInVote(#currentVoteChoice)">
- <td class="voted"><s:property
- value="%{#currentVoteChoice.voteValue}"/></td>
+ <td class="voted">
+ <s:property value="%{#currentVoteChoice.voteValue}"/>
+ </td>
</s:if>
<s:else>
<td class="notVoted"></td>
@@ -394,7 +396,9 @@
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
- <td class="result">TODO ${currentChoiceResult}</td>
+ <td class="result">
+ <s:property value="%{getResultValue(#choice)}"/>
+ </td>
</s:if>
</s:iterator>
</tr>
1
0
r3147 - in branches/pollen-1.2.6-struts2/pollen-services/src: main/java/org/chorem/pollen/bean main/java/org/chorem/pollen/services main/java/org/chorem/pollen/services/exceptions main/java/org/chorem/pollen/services/impl test/java/org/chorem/pollen/services test/java/org/chorem/pollen/services/impl
by tchemit@users.chorem.org 26 Feb '12
by tchemit@users.chorem.org 26 Feb '12
26 Feb '12
Author: tchemit
Date: 2012-02-26 18:19:55 +0100 (Sun, 26 Feb 2012)
New Revision: 3147
Url: http://chorem.org/repositories/revision/pollen/3147
Log:
add PollResultsService, improve servive tests skeleton
continue stuff...
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotFoundException.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/AbstractPollenServiceTest.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/EmailServiceTest.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/PollServiceTest.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/UserServiceTest.java
branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/VoteServiceTest.java
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultListBean.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -0,0 +1,38 @@
+package org.chorem.pollen.bean;
+
+import org.chorem.pollen.business.persistence.Result;
+import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class PollResultListBean {
+
+ /** Liste des résultats */
+ private List<Result> resultDTOs = null;
+
+ /** Résultat issu du dépouillement du vote */
+ private VoteCountingResultDTO voteCountingResultDTO = null;
+
+ public List<Result> getResultDTOs() {
+ return resultDTOs;
+ }
+
+ public void setResultDTOs(List<Result> resultDTOs) {
+ this.resultDTOs = resultDTOs;
+ }
+
+ public VoteCountingResultDTO getVoteCountingResultDTO() {
+ return voteCountingResultDTO;
+ }
+
+ public void setVoteCountingResultDTO(VoteCountingResultDTO voteCountingResultDTO) {
+ this.voteCountingResultDTO = voteCountingResultDTO;
+ }
+
+}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -110,6 +110,14 @@
}
}
+ protected <T extends TopiaEntity, D extends TopiaDAO<? super T>> T create(D dao) {
+ try {
+ return (T) dao.create();
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not create entity ", e);
+ }
+ }
+
protected TopiaContext getTransaction() {
return serviceContext.getTransaction();
}
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotFoundException.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotFoundException.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotFoundException.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -0,0 +1,34 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.services.exceptions;
+
+/**
+ * When a vote is not found.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class VoteNotFoundException extends Exception {
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotFoundException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -193,7 +193,8 @@
String title = _("pollen.feed.createPollContent",
poll.getCreator().getVotingId());
- String content = _("pollen.feed.createPollContent", poll.getDescription());
+ String content = _("pollen.feed.createPollContent",
+ poll.getDescription());
feedFeed(poll, title, content);
}
@@ -211,14 +212,20 @@
feedFeed(comment.getPoll(), title, content);
}
- public void addFeedEntryWhenAddVote(Vote vote) {
+ public void addFeedEntryWhenAddVote(Vote vote,
+ boolean anonymousVote,
+ String pollResult) {
+ String userId;
+ if (anonymousVote) {
+ userId = _("pollen.common.anonymous");
+ } else {
+ userId = vote.getPollAccount().getVotingId();
- String title = _("pollen.feed.addVoteTitle",
- vote.getPollAccount().getVotingId());
+ }
+ String title = _("pollen.feed.addVoteTitle", userId);
- // TODO Add result of poll ? And if poll is not public ?
- String content = _("pollen.feed.addVoteContent", "TODO");
+ String content = _("pollen.feed.addVoteContent", pollResult);
feedFeed(vote.getPoll(), title, content);
}
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -0,0 +1,344 @@
+package org.chorem.pollen.services.impl;
+
+import com.google.common.collect.Lists;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollResultListBean;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.Result;
+import org.chorem.pollen.business.persistence.ResultDAO;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.votecounting.dto.ChoiceDTO;
+import org.chorem.pollen.votecounting.dto.PollDTO;
+import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
+import org.chorem.pollen.votecounting.services.ServiceVoteCounting;
+import org.chorem.pollen.votecounting.services.ServiceVoteCountingImpl;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Deals with poll results.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PollResultsService extends PollenServiceSupport {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(PollResultsService.class);
+
+ public PollResultListBean getAllResults(String pollId) {
+ return getResults(pollId, null, false, false);
+ }
+
+ public PollResultListBean getResultsByVoteCounting(String pollId,
+ VoteCountingType voteCounting) {
+ return getResults(pollId, voteCounting, false, false);
+ }
+
+ public PollResultListBean getGroupResults(String pollId) {
+ return getResults(pollId, null, true, true);
+ }
+
+ public PollResultListBean getNormalResults(String pollId) {
+ return getResults(pollId, null, true, false);
+ }
+
+ /**
+ * Récupère les résultats d'un sondage.
+ *
+ * @param pollId le sondage
+ * @param voteCounting type de dépouillement
+ * @param byGroup résultats par groupe
+ * @param groupOnly résultats uniquement par groupe
+ * @return les résultats du sondage
+ */
+ private PollResultListBean getResults(String pollId,
+ VoteCountingType voteCounting,
+ boolean byGroup,
+ boolean groupOnly) {
+
+ PollService pollService = newService(PollService.class);
+ Poll poll = pollService.getPollByPollId(pollId);
+
+// DataResultConverter converter = new DataResultConverter(transaction);
+ if (log.isDebugEnabled()) {
+ log.debug(poll.getPollId() + " (" + voteCounting
+ + ") has results: " + hasResults(poll, voteCounting));
+ }
+
+ // Dépouillement du sondage.
+ // S'il n'existe pas de résultats ou si le sondage est encore ouvert.
+ //if (!hasResults(ePoll, voteCounting) || !ePoll.getIsClosed()) {
+ PollDTO dto = pollService.createPollDTOForVoteCounting(poll);
+
+ if (voteCounting != null) {
+ dto.setVoteCounting(voteCounting);
+ }
+
+ // clear result (they will be regenerated ! (a big shame))
+ poll.clearResult();
+
+ ServiceVoteCounting service = new ServiceVoteCountingImpl();
+
+ VoteCountingResultDTO result;
+
+ if (PollType.GROUP == poll.getPollType()) {
+ result = service.executeGroupCounting(dto);
+ } else {
+ result = service.executeVoteCounting(dto);
+ }
+ for (ChoiceDTO choice : result.getChoices()) {
+
+ ResultDAO daoResult = getDAO(Result.class);
+ Result eResult = create(daoResult);
+
+ Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+
+ poll.addResult(eResult);
+
+ eResult.setName(eChoice.getName());
+ eResult.setByGroup(result.isByGroup());
+ eResult.setPoll(poll);
+ eResult.setResultValue(String.valueOf(choice.getValue()));
+ eResult.setVoteCountingType(result.getTypeVoteCounting());
+ }
+
+ // Conversion et trie des résultats
+ List<Result> list = Lists.newArrayList(poll.getResult());
+
+ VoteCountingType voteCountingType = poll.getVoteCountingType();
+
+ Iterator<Result> it = list.iterator();
+ while (it.hasNext()) {
+ Result currentResult = it.next();
+
+ // Cas d'un dépouillement particulier
+ // Suppression des resultats qui ne sont pas de se dépouillement
+ if (voteCounting != null
+ && currentResult.getVoteCountingType() != voteCounting) {
+ it.remove();
+ }
+
+ // Cas d'un sondage de type GROUP avec filtre
+ if (byGroup) {
+
+ // Filtre group : Suppression resultats non group
+ if (groupOnly && !currentResult.getByGroup()) {
+ it.remove();
+ }
+
+ // Filtre non group : Suppression resultats group
+ else if (!groupOnly && currentResult.getByGroup()) {
+ it.remove();
+ }
+
+ // Suppression des autres resultats de depouillements differents
+ if (currentResult.getVoteCountingType() != voteCountingType) {
+ it.remove();
+ }
+ }
+ }
+
+ PollResultListBean resultListDTO = new PollResultListBean();
+ resultListDTO.setResultDTOs(list);
+ resultListDTO.setVoteCountingResultDTO(result);
+
+ return resultListDTO;
+ }
+
+ /**
+ * Retourne une chaîne contenant les résultats du sondage.
+ *
+ * @param poll le sondage
+ * @param results les résultats du sondage
+ * @return les résultats sous forme de chaine de caractères
+ */
+ public String getResultsAsString(Poll poll, Collection<Result> results) {
+
+ DateFormat dateFormat = new SimpleDateFormat();
+ StringBuilder res = new StringBuilder("");
+ Iterator<Result> it = results.iterator();
+ while (it.hasNext()) {
+ Result result = it.next();
+ if (poll.getChoiceType() == ChoiceType.DATE) {
+ Date date = new Date(Long.parseLong(result.getName()));
+ res.append(dateFormat.format(date));
+ } else {
+ res.append(result.getName());
+ }
+ res.append("=").append(removeTrailing0(result.getResultValue()));
+ if (it.hasNext()) {
+ res.append(", ");
+ }
+ }
+ return res.toString();
+ }
+
+ public String getResultValue(Choice choice, Collection<Result> results) {
+
+ String val = "";
+ for (Result result : results) {
+ if (result.getName().equals(choice.getName())) {
+ val = removeTrailing0(result.getResultValue());
+ break;
+ }
+ }
+ return val;
+ }
+
+
+ /**
+ * Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un
+ * double : 1,0 -> 1 et 1,2 -> 1,2.
+ *
+ * @param val le nombre
+ * @return le nombre sans 0 final
+ */
+ private String removeTrailing0(String val) {
+ if (val.endsWith(".0")) {
+ val = val.substring(0, val.indexOf('.'));
+ }
+ return val;
+ }
+
+
+ /**
+ * Création des résultats de sondage à partir d'un dto de résultats de
+ * sondage.
+ *
+ * @param ePoll poll à remplir
+ * @param dto le dto des résultats de sondage.
+ */
+ protected void populateResultEntities(Poll ePoll, VoteCountingResultDTO dto) {
+ for (ChoiceDTO choice : dto.getChoices()) {
+
+ ResultDAO daoResult = getDAO(Result.class);
+ Result eResult = create(daoResult);
+
+ Choice eChoice = ePoll.getChoiceByTopiaId(choice.getIdChoice());
+
+ ePoll.addResult(eResult);
+
+ eResult.setName(eChoice.getName());
+ eResult.setByGroup(dto.isByGroup());
+ eResult.setPoll(ePoll);
+ eResult.setResultValue(String.valueOf(choice.getValue()));
+ eResult.setVoteCountingType(dto.getTypeVoteCounting());
+ }
+ }
+
+ /**
+ * Retourne vrai si le sondage a des résultats.
+ *
+ * @param poll le sondage
+ * @param type type de dépouillement
+ * @return vrai si le sondage a des résultats
+ */
+ private boolean hasResults(Poll poll, VoteCountingType type) {
+ boolean hasresult = false;
+
+ if (!poll.isResultEmpty()) {
+
+ if (type == null) {
+ hasresult = true;
+ } else {
+ for (Result result : poll.getResult()) {
+ if (type.equals(result.getVoteCountingType())) {
+ hasresult = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return hasresult;
+ }
+
+// public String exportPoll(String pollId) {
+// TopiaContext transaction = getTransaction();
+// try {
+//
+// // Recherche du sondage
+// PollDAO daoPoll = PollenDAOHelper.getPollDAO(transaction);
+// Poll ePoll = daoPoll.findByPollId(pollId);
+//
+// // Dépouillement du sondage.
+// DataResultConverter converter = new DataResultConverter(transaction);
+// PollDTO dto = DataVoteCountingConverter
+// .createPollDTOForVoteCounting(ePoll);
+//
+// ePoll.clearResult();
+//
+// ServiceVoteCounting service = new ServiceVoteCountingImpl();
+// List<VoteCountingResultDTO> results = new ArrayList<VoteCountingResultDTO>();
+// VoteCountingResultDTO result = service.executeVoteCounting(dto);
+// converter.populateResultEntities(result);
+// results.add(result);
+//
+// if (EnumController.isGroupType(ePoll)) {
+// VoteCountingResultDTO groupResult = service
+// .executeGroupCounting(dto);
+// converter.populateResultEntities(groupResult);
+// results.add(groupResult);
+// }
+//
+// // Transformation du sondage
+// PollExportDTO pollExport = new PollExportDTO();
+// pollExport.setPollId(pollId);
+// pollExport.setPoll(dto);
+// pollExport.setVoteCountingResults(results);
+//
+// // Export du sondage
+// ServiceExport serviceExport = new ServiceExportImpl();
+// String filename = serviceExport.executeExport(pollExport);
+//
+// if (log.isInfoEnabled()) {
+// log.info("Poll exported: " + pollId);
+// }
+//
+// return filename;
+// } catch (Exception e) {
+// throw new PollenTechnicalException("Could not export results", e);
+// }
+// }
+
+// public String importPoll(String filePath) {
+// return importPoll(filePath, null);
+// }
+//
+// public String importPoll(String filePath, UserAccount user) {
+// String topiaId = "";
+//
+// // Import du sondage
+// ServiceExport serviceExport = new ServiceExportImpl();
+// PollExportDTO pollExportDTO = serviceExport.executeImport(filePath);
+//
+// // Transformation du sondage
+// // FIXME do not call a Service from an other one
+// PollService servicePoll = newService(PollService.class);
+// org.chorem.pollen.business.dto.PollDTO poll = DataVoteCountingConverter
+// .createPollDTO(pollExportDTO.getPoll());
+//
+// // Enregistrement du sondage
+// if (user != null) {
+// poll.setUserId(user.getId());
+// }
+// topiaId = servicePoll.createPoll(poll);
+//
+// if (log.isInfoEnabled()) {
+// log.info("Poll imported: " + topiaId);
+// }
+//
+// return topiaId;
+// }
+}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -31,6 +31,7 @@
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceDAO;
+import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
@@ -39,11 +40,19 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteDAO;
+import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.exceptions.PollVoteNotFoundException;
+import org.chorem.pollen.votecounting.business.NumberMethod;
+import org.chorem.pollen.votecounting.dto.CommentDTO;
+import org.chorem.pollen.votecounting.dto.PollChoiceDTO;
+import org.chorem.pollen.votecounting.dto.PollDTO;
+import org.chorem.pollen.votecounting.dto.VoteToChoiceDTO;
+import org.chorem.pollen.votecounting.dto.VotingGroupDTO;
+import org.chorem.pollen.votecounting.dto.VotingPersonDTO;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.web.struts2.FilterPagerUtil;
@@ -982,4 +991,134 @@
ChoiceDAO dao = getDAO(Choice.class);
delete(dao, choice);
}
+
+ public PollAccount getRestrictedAccount(String pollId,
+ String accountId) throws PollNotFoundException {
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("getRestrictedAccount : accountId = " + accountId +
+ " _ pollId = " + poll.getPollId());
+ }
+
+ // Use PersonToList association entity to find coherence between
+ // the poll and votingId
+ PollAccountDAO dao = getDAO(PollAccount.class);
+
+ try {
+ PollAccount result = dao.getRestrictedPollAccount(pollId, accountId);
+ return result;
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not obtain restricted pollAccount", e);
+ }
+ }
+
+ public PollDTO createPollDTOForVoteCounting(Poll ePoll) {
+ PollDTO pollDTO = new PollDTO(ePoll.getPollId());
+ pollDTO.setTitle(ePoll.getTitle());
+ pollDTO.setDescription(ePoll.getDescription());
+ pollDTO.setBeginChoiceDate(ePoll.getBeginChoiceDate());
+ pollDTO.setBeginDate(ePoll.getBeginDate());
+ pollDTO.setEndDate(ePoll.getEndDate());
+ pollDTO.setAnonymous(ePoll.getAnonymous());
+ pollDTO.setAnonymousVoteAllowed(ePoll.getAnonymousVoteAllowed());
+ pollDTO.setPublicResults(ePoll.getPublicResults());
+ pollDTO.setContinuousResults(ePoll.getContinuousResults());
+ pollDTO.setChoiceAddAllowed(ePoll.getChoiceAddAllowed());
+ pollDTO.setClosed(ePoll.getClosed());
+ pollDTO.setCreatorId(ePoll.getCreator().getVotingId());
+ pollDTO.setCreatorEmail(ePoll.getCreator().getEmail());
+ pollDTO.setMaxChoiceNb(ePoll.getMaxChoiceNb());
+ pollDTO.setPollType(ePoll.getPollType());
+ pollDTO.setChoiceType(ePoll.getChoiceType());
+ pollDTO.setVoteCounting(ePoll.getVoteCountingType());
+
+ for (Comment comment : ePoll.getComment()) {
+ pollDTO.getComments().add(createPollCommentDTO(comment));
+ }
+ for (Choice choice : ePoll.getChoice()) {
+ pollDTO.getChoices().add(createPollChoiceDTO(choice));
+ }
+ if (ePoll.getVotingList() != null && !ePoll.getVotingList().isEmpty()) {
+ for (VotingList list : ePoll.getVotingList()) {
+ pollDTO.getVotingGroups().add(createVotingGroupDTO(list));
+ }
+ } else {
+ // un groupe par défaut si il y en a pas
+ VotingGroupDTO group = new VotingGroupDTO("unique", 1);
+ group.setName("unique");
+ for (Vote vote : ePoll.getVote()) {
+ group.getVotingPersons().add(createVotingPersonDTO(vote));
+ }
+ pollDTO.getVotingGroups().add(group);
+ }
+ return pollDTO;
+ }
+
+ private CommentDTO createPollCommentDTO(Comment comment) {
+ CommentDTO commentDTO = new CommentDTO(comment.getPollAccount()
+ .getVotingId(), comment.getText());
+ return commentDTO;
+ }
+
+ private PollChoiceDTO createPollChoiceDTO(Choice choice) {
+ PollChoiceDTO choiceDTO = new PollChoiceDTO(choice.getTopiaId());
+ String choiceName = choice.getName();
+ choiceDTO.setName(choiceName);
+ choiceDTO.setHidden(choiceName != null &&
+ choiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ choiceDTO.setDescription(choice.getDescription());
+ return choiceDTO;
+ }
+
+ private VotingGroupDTO createVotingGroupDTO(VotingList list) {
+ VotingGroupDTO group = new VotingGroupDTO(list.getTopiaId(), list
+ .getWeight());
+ group.setName(list.getName());
+
+ for (PersonToList pToList : list.getPollAccountPersonToList()) {
+ Vote vote = getPollVoteByPollAccount(list.getPoll(), pToList
+ .getPollAccount());
+ if (vote != null) { // Pas de vote pour cette personne : doit engendrer erreur ?!?
+ group.getVotingPersons().add(createVotingPersonDTO(vote));
+ }
+ }
+ return group;
+ }
+
+ private VotingPersonDTO createVotingPersonDTO(Vote vote) {
+ VotingPersonDTO votingPerson = new VotingPersonDTO(vote
+ .getPollAccount().getVotingId(), vote.getWeight());
+ votingPerson.setEmail(vote.getPollAccount().getEmail());
+
+ for (VoteToChoice vToChoice : vote.getChoiceVoteToChoice()) {
+ if (vToChoice != null && vToChoice.getChoice() != null) {
+ votingPerson.getChoices().add(createVoteToChoiceDTO(vToChoice));
+ }
+ }
+ return votingPerson;
+ }
+
+ private VoteToChoiceDTO createVoteToChoiceDTO(VoteToChoice vToChoice) {
+ String topiaId = vToChoice.getChoice().getTopiaId();
+ VoteToChoiceDTO vote = new VoteToChoiceDTO(topiaId, vToChoice
+ .getVoteValue());
+
+ return vote;
+ }
+
+ /* A Deplacer au bon endroit (PollImpl) si c'est possible */
+ private static Vote getPollVoteByPollAccount(Poll poll, PollAccount account) {
+ for (Vote vote : poll.getVote()) {
+ if (account.getTopiaId().equals(vote.getPollAccount().getTopiaId())) {
+ return vote;
+ }
+ }
+ return null;
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -23,411 +23,237 @@
*/
package org.chorem.pollen.services.impl;
+import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.PollAccountDAO;
+import org.chorem.pollen.business.persistence.Vote;
+import org.chorem.pollen.business.persistence.VoteDAO;
+import org.chorem.pollen.entities.PollenDAOHelper;
import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.services.exceptions.VoteNotFoundException;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
public class VoteService extends PollenServiceSupport {
/** Logger. */
private static final Log log = LogFactory.getLog(VoteService.class);
- /*
- private void addFeedEntry(PollAction pollAction, String titleStr,
- String contentStr) {
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- File feedFile = getFeedContext().getFile(poll.getPollId());
- String title = null;
- String content = null;
+ public String createVote(Vote vote, PollAccount pollAccount) {
+ TopiaContext transaction = getTransaction();
- switch (pollAction) {
- case ADDVOTE:
- if (isVoteAnonymous()) {
- titleStr = messages.get("anonymous");
+ String topiaId;
+ try {
+
+ // création du compte associé au vote s'il n'existe pas
+ // sinon mise à jour du compte
+ //ServicePollAccount spa = new ServicePollAccountImpl();
+ if (pollAccount == null) {
+ vote.setPollAccount(null);
+ } else {
+// pollAccount.setHasVoted(true);
+ PollAccountDAO pollAccountDAO =
+ PollenDAOHelper.getPollAccountDAO(transaction);
+
+ PollAccount pollAccountEntity =
+ pollAccountDAO.findByTopiaId(pollAccount.getTopiaId());
+
+// PollAccountDTO account = spa.findPollAccountById(pollAccountDTO
+// .getId());
+ if (pollAccountEntity == null) {
+ log.debug("Nouveau compte associé au vote");
+ pollAccountEntity = pollAccountDAO.create();
+// voteDTO.setPollAccountId(spa
+// .createPollAccount(pollAccountDTO));
+ } else {
+ log.debug("Compte associé au vote : " + pollAccountEntity.getTopiaId());
+ //spa.updatePollAccount(pollAccountDTO);
+ //voteDTO.setPollAccountId(account.getId());
+
+ }
+ // Fill pollAccountEntity from DTO in argument
+// DataPollAccountConverter pollAccountConverter = new DataPollAccountConverter();
+// pollAccountConverter.setTransaction(transaction);
+// pollAccountConverter.populatePollAccountEntity(pollAccountDTO,
+// pollAccountEntity);
+ // Update pollAccountEntity
+ pollAccountDAO.update(pollAccountEntity);
+
+ vote.setPollAccount(pollAccountEntity);
+// vote.setVotingListId(pollAccount.getVotingListId());
+// vote.setWeight(pollAccount.getWeight());
+ log.debug("Poids du vote : " + vote.getWeight());
}
- title = messages.format("pollFeed_voteTitle", titleStr);
- content = messages.format("pollFeed_voteContent", contentStr);
- break;
- case ADDCHOICE:
- title = messages.format("pollFeed_choiceTitle", titleStr);
- content = messages.format("pollFeed_choiceContent", contentStr);
- break;
- case ADDCOMMENT:
- title = messages.format("pollFeed_commentTitle", titleStr);
- content = messages.format("pollFeed_commentContent", contentStr);
- break;
+
+ VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(transaction);
+
+ Vote voteEntity = voteDAO.create();
+// converter.setTransaction(transaction);
+// converter.populateVoteEntity(vote, voteEntity);
+
+// converter.populateChoiceVote(vote, voteEntity);
+
+ topiaId = voteEntity.getTopiaId();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
+ }
+
+ return topiaId;
+ } catch (Exception e) {
+ throw new PollenTechnicalException("Could not obtain votes", e);
}
+ }
- if (!feedFile.exists()) {
- FeedUtil.createFeed(feedFile, "atom_1.0", messages.format(
- "pollFeed_title", poll.getTitle()), siteURL, messages
- .format("pollFeed_desc", poll.getDescription()));
+ public boolean updateVote(Vote vote) {
+ TopiaContext transaction = getTransaction();
+ try {
+
+ VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(transaction);
+ Vote voteEntity = voteDAO.findByTopiaId(vote.getTopiaId());
+// converter.setTransaction(transaction);
+// converter.populateVoteEntity(voteDTO, voteEntity);
+ voteDAO.update(voteEntity);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + vote.getTopiaId());
+ }
+
+ return true;
+ } catch (Exception e) {
+ throw new PollenTechnicalException("Could not update vote", e);
}
- FeedUtil.feedFeed(feedFile, title, voteURL, content);
+
}
- */
-// public boolean canVote(Poll poll, PollAccount participant) {
-// try {
-// if (log.isDebugEnabled()) {
-// log.debug("Poll started : " + poll.isStarted());
-// log.debug("Poll finished : " + poll.isFinished());
-// log.debug("Poll closed : " + poll.isClosed());
-// }
-// boolean result = true;
-// if (!poll.isRunning()) {
-// if (log.isInfoEnabled()) {
-// log.info("Poll is no longer running... Participant can't vote");
-// }
-// result = false;
-// // Creator can't vote
-// } else if (poll.getCreator().equals(participant)) {
-// return false;
-// } else if (poll.getType().isRestrictedOrGroup()) {
-// if (log.isInfoEnabled()) {
-// log.info("Poll is restricted... Participant need to be identified");
-// }
-//
-// PollAccountDAO dao =
-// PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-// TopiaQuery query = dao.createQueryFindAllParticipantsByPoll(poll);
-//
-// String participantAlias = PollenQueryHelper.ALIAS_POLL_ACCOUNT_CHILD;
-//
-// String pollCreatorProperty =
-// TopiaQuery.getProperty(PollenQueryHelper.ALIAS_POLL,
-// Poll.PROPERTY_CREATOR);
-//
-// query.addEquals(participantAlias, participant).
-// addWhere(pollCreatorProperty, TopiaQuery.Op.NEQ, participant);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Query : " + query);
-// }
-//
-// result = dao.existByQuery(query);
-// }
-// return result;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// public PollAccount getNewPollAccount(UserAccount user) {
-// PollAccount result = new PollAccountImpl();
-// if (user != null) {
-// result.setName(user.getDisplayName());
-// result.setEmail(user.getEmail());
-// result.setUserAccount(user);
-// }
-// return result;
-// }
-//
-// public PollAccount getPollAccount(String accountUid) {
-// try {
-// PollenQueryHelper.PollAccountProperty accountProperty =
-// PollenQueryHelper.newPollAccountProperty();
-//
-// TopiaQuery query = PollenQueryHelper.createQuery(accountProperty).
-// addEquals(accountProperty.uid(), accountUid).
-// // Need fetching account votes to edit them
-// addFetch(accountProperty.choiceVote());
-//
-// PollAccount result =
-// PollenDAOHelper.getPollAccountDAO(getTransaction()).
-// findByQuery(query);
-//
-// return result;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// public List<PollAccount> getVotes(EntityFilter filter) {
-// try {
-// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-//// String participantChoiceProperty =
-//// TopiaQuery.getProperty(PollenQueryHelper.ALIAS_POLL_ACCOUNT,
-//// PollAccount.PROPERTY_CHOICE_VOTE,
-//// Vote.PROPERTY_CHOICE);
-////
-//// TopiaQuery query = dao.createQueryFindAllByPoll(filter).
-//// addDistinct().
-//// addFetch(participantChoiceProperty);
-//
-// PollenQueryHelper.PollAccountProperty accountProperty =
-// PollenQueryHelper.newPollAccountProperty();
-//
-// TopiaQuery query = dao.createQueryFindAllByPoll(filter).
-// addDistinct().
-// addFetch(accountProperty.choiceVoteProperty().choice());
-//
-// List<PollAccount> results = dao.findAllByQuery(query);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Query : " + query);
-// }
-//
-// return results;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// public void deleteVote(Poll poll, PollAccount participant) {
-// try {
-// // For free poll, delete the participant
-// // For other types, delete all votes and set voteDate to null
-//
-// PollAccountDAO dao =
-// PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-// if (poll.getType().isFree()) {
-//
-// PollAccount participantToDelete =
-// dao.findByTopiaId(participant.getTopiaId());
-//
-// dao.delete(participantToDelete);
-//
-// } else if (poll.getType().isRestrictedOrGroup()) {
-//
-// PollAccount participantToUpdate =
-// dao.findByTopiaId(participant.getTopiaId());
-//
-// // Remove all votes deleted by cascade
-// participantToUpdate.clearChoiceVote();
-// // Reset date, the participant is considered like he has not alerady
-// // voted
-// participantToUpdate.setVoteDate(null);
-//
-// dao.update(participantToUpdate);
-// }
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// public int getNbVotes(Poll poll) {
-// try {
-// PollAccountDAO dao =
-// PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-// EntityFilter filter = new TopiaFilter();
-// filter.setReference(poll);
-// TopiaQuery query = dao.createQueryFindAllByPoll(filter);
-//
-// int result = dao.countByQuery(query);
-// return result;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// public Vote getNewVote(Choice choice) {
-// Vote result = new VoteImpl();
-// result.setChoice(choice);
-// return result;
-// }
-//
-// public PollAccount saveVote(Poll poll, PollAccount participant) throws VoteNotAllowedException, VoteDoubloonException {
-// try {
-// // 1- executeCanVote(transaction, poll, participant);
-// // 2- generate uid if needed
-// // 3- update or create participant
-// // 4- add participant in the poll if needed
-// // 5- save only votes with voteValue != 0 : update/create/delete
-// // 6- execute calcul for continuousResults poll
-//
-// // NEED test :
-// // need existing poll with choices
-// // getNewPollAccount
-// // set some votes for poll choices
-// // saveVote
-//
-// PollAccount result;
-// if (canVote(poll, participant)) {
-//
-// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-// checkParticipantDoubloons(dao, poll, participant);
-//
-// PollAccount participantToSave =
-// dao.findByTopiaId(participant.getTopiaId());
-//
-// // canVote method check the existence of participant for a
-// // restricted poll, so the create case is only for FREE poll.
-// if (participantToSave == null) {
-// if (log.isInfoEnabled()) {
-// log.info("Create new participant for FREE poll");
-// }
-// participantToSave = createNewParticipant(poll);
-// }
-//
-// // Copy data (care about anonymous case)
-// copyPollAccount(participant, participantToSave);
-//
-// // Update vote date
-// participantToSave.setVoteDate(serviceContext.getCurrentTime());
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Vote " + participantToSave.getName() +
-// " updated : " + participantToSave.getVoteDate());
-// }
-//
-// // Save votes
-// saveParticipantVotes(participant, participantToSave);
-//
-// dao.update(participantToSave);
-//
-// result = participantToSave;
-//
-// // TODO-fdesbois-2010-05-27 : execute vote counting if poll.isContinuousResults()
-//
-// } else {
-// throw new VoteNotAllowedException();
-// }
-//
-// return result;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
-// }
-//
-// //FIXME tchemit-20120123 : what is the need ? :(
-// public PollAccount findPollAccount(Poll poll, UserAccount user) {
-// throw new UnsupportedOperationException("unsupported operation findPollAccount");
-// }
-//
-// protected void checkParticipantDoubloons(PollAccountDAO dao,
-// Poll poll,
-// PollAccount participant)
-// throws TopiaException, VoteDoubloonException {
-//
-// TopiaQuery query = dao.createQueryFindAllParticipantsByPoll(poll);
-//
-// String participantAlias = PollenQueryHelper.ALIAS_POLL_ACCOUNT_CHILD;
-//
-// String participantNameProperty =
-// TopiaQuery.getProperty(participantAlias,
-// PollAccount.PROPERTY_NAME);
-//
-// query.addEquals(participantNameProperty, participant.getName());
-//
-// if (StringUtils.isNotEmpty(participant.getTopiaId())) {
-// query.addWhere(participantAlias, TopiaQuery.Op.NEQ, participant);
-// }
-//
-// if (dao.existByQuery(query)) {
-// throw new VoteDoubloonException();
-// }
-// }
-//
-// /**
-// * Create a new participant for a running {@code poll}. The participant uid
-// * will be generated and the new instance of pollAccount will be added to
-// * the {@code poll}.
-// *
-// * @param poll Poll where the new participant will be added
-// * @return a new PollAccount added to the poll
-// * @throws TopiaException for Topia errors
-// */
-// protected PollAccount createNewParticipant(Poll poll)
-// throws TopiaException {
-//
-// PollAccountDAO dao =
-// PollenDAOHelper.getPollAccountDAO(getTransaction());
-//
-// // Generate new uid
-// String newUid = serviceContext.createPollenUrlId();
-// PollAccount newParticipant = dao.create(newUid);
-//
-// // Add the new participant in poll
-// PollDAO pollDAO = PollenDAOHelper.getPollDAO(getTransaction());
-//
-// Poll pollFound = pollDAO.findByTopiaId(poll.getTopiaId());
-// pollFound.addPollAccount(newParticipant);
-//
-// pollDAO.update(pollFound);
-// return newParticipant;
-// }
-//
-// /**
-// * Save all votes from a participant. Votes will be added/updated or deleted
-// * depends on voteValue and existence in database.
-// *
-// * @param source PollAccount source that contains vote to save
-// * @param destination PollAccount destination where votes will be added to
-// * be persisted
-// * @throws TopiaException for Topia errors
-// */
-// protected void saveParticipantVotes(PollAccount source,
-// PollAccount destination)
-// throws TopiaException {
-//
-// VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(getTransaction());
-// for (Vote vote : source.getChoiceVote()) {
-//
-// Vote voteToSave = voteDAO.findByTopiaId(vote.getTopiaId());
-//
-// if (vote.getVoteValue() != 0) {
-// // Create vote
-// if (voteToSave == null) {
-// if (log.isDebugEnabled()) {
-// log.debug("Create vote for " + destination.getUid());
-// }
-// voteToSave = voteDAO.create();
-// voteToSave.setChoice(vote.getChoice());
-// // Add new vote to destination participant
-// destination.addChoiceVote(voteToSave);
-// }
-//
-// // Update vote
-// voteToSave.setVoteValue(vote.getVoteValue());
-// voteDAO.update(voteToSave);
-//
-// // Delete vote if exist and new value is 0
-// } else if (voteToSave != null) {
-// if (log.isDebugEnabled()) {
-// log.debug("Delete vote for " + destination.getUid());
-// }
-// // Normally the vote will be deleted
-// destination.removeChoiceVote(voteToSave);
-// }
-// }
-// }
-//
-// /**
-// * Copy from account {@code source} to {@code destination}. The {@code
-// * destination} will be persisted. The anonymous case is manage, properties
-// * that identify the person are excluded from the copy in this case.
-// *
-// * @param source PollAccount to save
-// * @param destination PollAccount with up to date data to persist
-// * @see TopiaEntityBinder#copyExcluding(Object, Object, String...)
-// */
-// protected void copyPollAccount(PollAccount source, PollAccount destination) {
-// // Uid is the naturalId, don't copy it
-// String[] excludes = new String[]{PollAccount.PROPERTY_UID};
-//
-// // Exclude properties for anonymous account
-// if (source.isAnonymous()) {
-// if (log.isInfoEnabled()) {
-// log.info("Anonymous vote, doesn't copy participant's data : " +
-// "name, email, userAccount");
-// }
-//
-// excludes = new String[]{
-// PollAccount.PROPERTY_UID,
-// PollAccount.PROPERTY_NAME,
-// PollAccount.PROPERTY_EMAIL,
-// PollAccount.PROPERTY_USER_ACCOUNT};
-// }
-//
-// TopiaEntityBinder<PollAccount> binder =
-// PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class);
-//
-// binder.copyExcluding(source, destination, excludes);
-// }
-} //ServiceVote
+ public boolean deleteVote(String voteId) {
+ TopiaContext transaction = getTransaction();
+ try {
+
+ VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(transaction);
+ Vote voteEntity = voteDAO.findByTopiaId(voteId);
+
+ if (voteEntity == null) {
+ throw new VoteNotFoundException();
+ }
+
+ voteDAO.delete(voteEntity);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + voteId);
+ }
+
+ return true;
+ } catch (Exception e) {
+ throw new PollenTechnicalException("Could not obtain votes", e);
+ }
+ }
+
+ public List<Vote> getVotesByPoll(Poll poll,
+ int startIndex, int endIndex) {
+ TopiaContext transaction = getTransaction();
+ List<Vote> results = new ArrayList<Vote>();
+ try {
+ // No need to load votes for an anonymous poll
+ if (poll.getAnonymous()) {
+ return results;
+ }
+
+ // FIXME-FD20100309 : change model to suppress link from poll to vote
+ // It's not necessary to have votes when retrieving the poll, this
+ // method do this job only when it's needed
+
+ if (log.isDebugEnabled()) {
+ log.debug("Load votes for poll with uid = " + poll.getPollId());
+ log.debug("LIMIT : startIndex = " + startIndex + " _ " +
+ "endIndex = " + endIndex);
+ }
+
+ // FIXME : refactor this to use TopiaQuery from ToPIA 2.3
+ // Order the results by creation date (the last vote done will be
+ // at the end of the list)
+ List<Vote> votes = transaction.find(
+ "FROM " + Vote.class.getName() +
+ " WHERE poll.pollId = :pollUId" +
+ " ORDER BY topiaCreateDate",
+ startIndex, endIndex,
+ new Object[]{"pollUId", poll.getPollId()});
+
+ if (log.isDebugEnabled()) {
+ log.debug("Nb votes found : " + votes.size());
+ }
+
+ results = Lists.newArrayList(results);
+
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not obtain votes", e);
+ }
+ return results;
+ }
+
+ public boolean hasAlreadyVoted(String votingId, Poll poll) {
+ TopiaContext transaction = getTransaction();
+ boolean result = false;
+ try {
+
+ // Test using a count(*) on votes
+ List<Long> tmp = transaction.find(
+ "SELECT COUNT(*)" +
+ " FROM " + Vote.class.getName() +
+ " WHERE poll.pollId = :pollUId" +
+ " AND pollAccount.votingId = :votingId",
+ "pollUId", poll.getPollId(),
+ "votingId", votingId);
+
+ int count = tmp.get(0).intValue();
+
+ // If the count is greater than 0, there is an existing votingId
+ // who has already voted for the poll
+ result = count > 0;
+
+ } catch (Exception e) {
+ throw new PollenTechnicalException(
+ "Unable test vote existing for account with votingId = " +
+ votingId + " and poll with uid = " + poll.getPollId(), e);
+ }
+ return result;
+ }
+
+ public List<Vote> selectVotes(Map<String, Object> properties) {
+ TopiaContext transaction = getTransaction();
+ try {
+ VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(transaction);
+
+ List<Vote> voteEntities;
+
+ if (properties == null) {
+ voteEntities = voteDAO.findAll();
+ if (log.isWarnEnabled()) {
+ log.warn("Attention : tous les votes ont été sélectionnés !");
+ }
+ } else {
+ voteEntities = voteDAO.findAllByProperties(properties);
+ }
+
+ List<Vote> results = Lists.newArrayList(voteEntities);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ + ((results == null) ? "null" : results.size()));
+ }
+
+ return results;
+ } catch (Exception e) {
+ throw new PollenTechnicalException("Could not obtain votes", e);
+ }
+ }
+
+} //voteservice
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/AbstractPollenServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/AbstractPollenServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/AbstractPollenServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -38,12 +38,15 @@
public abstract class AbstractPollenServiceTest extends PollenServiceSupport {
@Rule
- public FakeServiceContext serviceContext = new FakeServiceContext();
+ public FakeServiceContext fakeContext = new FakeServiceContext();
@Before
public void setUp() throws Exception {
- serviceContext.setServiceFactory(new PollenServiceFactory());
- setServiceContext(serviceContext);
+ getServiceContext().setServiceFactory(new PollenServiceFactory());
+ setServiceContext(getServiceContext());
}
+ public FakeServiceContext getServiceContext() {
+ return fakeContext;
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -24,9 +24,9 @@
package org.chorem.pollen.services;
-import com.google.common.base.Supplier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PolleIOUtil;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.PollenTopiaRootContextFactory;
import org.junit.rules.TestWatcher;
@@ -39,7 +39,10 @@
import java.io.File;
import java.net.URL;
import java.util.Date;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
import java.util.UUID;
/**
@@ -50,12 +53,10 @@
public static final String CONFIGURATION_PATH = "pollen-fake.properties";
- protected Supplier<TopiaContext> rootContextSupplier;
-
private static final Log log = LogFactory.getLog(FakeServiceContext.class);
/** A time-stamp, allow to make multiple build and keep the tests data. */
- protected static final String TIMESTAMP = String.valueOf(System.nanoTime());
+ protected static final long TIMESTAMP = System.nanoTime();
protected PollenServiceFactory serviceFactory;
@@ -65,39 +66,21 @@
protected Date fakeCurrentTime;
- protected File getTestSpecificDirectory(Description description) {
- // Trying to look for the temporary folder to store data for the test
- String tempDirPath = System.getProperty("java.io.tmpdir");
- if (tempDirPath == null) {
- // can this really occur ?
- tempDirPath = "";
- if (log.isWarnEnabled()) {
- log.warn("'\"java.io.tmpdir\" not defined");
- }
- }
- File tempDirFile = new File(tempDirPath);
+ protected File testDir;
- // create the directory to store database data
- String dataBasePath = description.getClassName()
- + File.separator // a directory with the test class name
- + description.getMethodName()// a sub-directory with the method name
- + '_'
- + TIMESTAMP; // and a timestamp
- File databaseFile = new File(tempDirFile, dataBasePath);
- return databaseFile;
+ public TopiaContext getRootContext() {
+ return this.rootContext;
}
- public Supplier<TopiaContext> getRootContextSupplier() {
- return rootContextSupplier;
- }
-
@Override
protected void starting(Description description) {
super.starting(description);
- description.getMethodName();
PollenTopiaRootContextFactory factory =
new PollenTopiaRootContextFactory();
- File testDir = getTestSpecificDirectory(description);
+ testDir = PolleIOUtil.getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName(),
+ TIMESTAMP);
if (log.isInfoEnabled()) {
log.info("Test dir = " + testDir);
}
@@ -138,8 +121,8 @@
public Date getCurrentTime() {
if (fakeCurrentTime == null) {
throw new IllegalStateException("le service testé a besoin de " +
- "connaître la date, il faudrait en préciser une de test via les"
- + " méthodes serviceContext#setCurrentTime(...)");
+ "connaître la date, il faudrait en préciser une de test via les"
+ + " méthodes serviceContext#setCurrentTime(...)");
} else {
log.trace("injecting fake date in service : " + fakeCurrentTime);
}
@@ -181,8 +164,11 @@
@Override
public PollenConfiguration getConfiguration() {
+
+ Properties props = new Properties();
+ props.put("testDirectory", testDir);
PollenConfiguration configuration
- = new PollenConfiguration(CONFIGURATION_PATH);
+ = new PollenConfiguration(CONFIGURATION_PATH, props);
return configuration;
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/EmailServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/EmailServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/EmailServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -24,7 +24,6 @@
package org.chorem.pollen.services.impl;
import org.chorem.pollen.services.AbstractPollenServiceTest;
-import org.chorem.pollen.services.impl.EmailService;
import org.junit.Before;
import org.junit.Test;
@@ -40,7 +39,7 @@
@Before
public void setUp() throws Exception {
- serviceContext.setCurrentTime(5, 10, 2011);
+ getServiceContext().setCurrentTime(5, 10, 2011);
super.setUp();
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -46,7 +46,7 @@
@Before
public void setUp() throws Exception {
- serviceContext.setCurrentTime(5, 10, 2011);
+ getServiceContext().setCurrentTime(5, 10, 2011);
super.setUp();
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/PollServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/PollServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/PollServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -24,7 +24,6 @@
package org.chorem.pollen.services.impl;
import org.chorem.pollen.services.AbstractPollenServiceTest;
-import org.chorem.pollen.services.impl.PollService;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -43,7 +42,7 @@
@Before
public void setUp() throws Exception {
- serviceContext.setCurrentTime(5, 10, 2011);
+ getServiceContext().setCurrentTime(5, 10, 2011);
super.setUp();
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/UserServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/UserServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/UserServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -24,7 +24,6 @@
package org.chorem.pollen.services.impl;
import org.chorem.pollen.services.AbstractPollenServiceTest;
-import org.chorem.pollen.services.impl.UserService;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -42,7 +41,7 @@
@Before
public void setUp() throws Exception {
- serviceContext.setCurrentTime(5, 10, 2011);
+ getServiceContext().setCurrentTime(5, 10, 2011);
super.setUp();
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/VoteServiceTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/VoteServiceTest.java 2012-02-26 17:19:03 UTC (rev 3146)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/test/java/org/chorem/pollen/services/impl/VoteServiceTest.java 2012-02-26 17:19:55 UTC (rev 3147)
@@ -24,7 +24,6 @@
package org.chorem.pollen.services.impl;
import org.chorem.pollen.services.AbstractPollenServiceTest;
-import org.chorem.pollen.services.impl.VoteService;
import org.junit.Before;
import org.junit.Test;
@@ -40,7 +39,7 @@
@Before
public void setUp() throws Exception {
- serviceContext.setCurrentTime(5, 10, 2011);
+ getServiceContext().setCurrentTime(5, 10, 2011);
super.setUp();
}
1
0
r3146 - in branches/pollen-1.2.6-struts2/pollen-persistence/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/business/persistence test/java/org/chorem/pollen test/java/org/chorem/pollen/business test/java/org/chorem/pollen/business/persistence test/resources
by tchemit@users.chorem.org 26 Feb '12
by tchemit@users.chorem.org 26 Feb '12
26 Feb '12
Author: tchemit
Date: 2012-02-26 18:19:03 +0100 (Sun, 26 Feb 2012)
New Revision: 3146
Url: http://chorem.org/repositories/revision/pollen/3146
Log:
add poll account dao method + tests for dao
Added:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PolleIOUtil.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/
branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/
branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/AbstractDAOTest.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollAccountDAOTest.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/test/resources/pollen-fake.properties
Modified:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PolleIOUtil.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PolleIOUtil.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PolleIOUtil.java 2012-02-26 17:19:03 UTC (rev 3146)
@@ -0,0 +1,66 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+/**
+ * Some utils IO methods.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PolleIOUtil {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PolleIOUtil.class);
+
+ protected PolleIOUtil() {
+ }
+
+ public static File getTestSpecificDirectory(Class<?> klass, String methodName, long timestamp) {
+ // Trying to look for the temporary folder to store data for the test
+ String tempDirPath = System.getProperty("java.io.tmpdir");
+ if (tempDirPath == null) {
+ // can this really occur ?
+ tempDirPath = "";
+ if (log.isWarnEnabled()) {
+ log.warn("'\"java.io.tmpdir\" not defined");
+ }
+ }
+ File tempDirFile = new File(tempDirPath);
+
+ // create the directory to store database data
+ String dataBasePath = klass
+ + File.separator // a directory with the test class name
+ + methodName // a sub-directory with the method name
+ + '_'
+ + timestamp; // and a timestamp
+ File databaseFile = new File(tempDirFile, dataBasePath);
+ return databaseFile;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PolleIOUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java 2012-02-25 14:59:05 UTC (rev 3145)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java 2012-02-26 17:19:03 UTC (rev 3146)
@@ -37,6 +37,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Map;
import java.util.Properties;
/**
@@ -55,10 +56,10 @@
protected ApplicationConfig applicationConfig;
public PollenConfiguration() {
- this("pollen.properties");
+ this("pollen.properties", null);
}
- public PollenConfiguration(String file) {
+ public PollenConfiguration(String file, Properties defaultOptions) {
applicationConfig = new ApplicationConfig();
applicationConfig.setConfigFileName(file);
@@ -66,6 +67,15 @@
if (log.isInfoEnabled()) {
log.info(this + " is initializing...");
}
+ if (defaultOptions != null) {
+ for (Map.Entry<Object, Object> entry : defaultOptions.entrySet()) {
+
+ applicationConfig.setDefaultOption(
+ String.valueOf(entry.getKey()),
+ String.valueOf(entry.getValue())
+ );
+ }
+ }
try {
applicationConfig.loadDefaultOptions(PollenConfigurationOption.class);
applicationConfig.parse();
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-02-26 17:19:03 UTC (rev 3146)
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+
+public class PollAccountDAOImpl<E extends PollAccount> extends PollAccountDAOAbstract<E> {
+
+ public PollAccount getRestrictedPollAccount(String pollId,
+ String accountId) throws TopiaException {
+
+// List<PersonToList> tmp = transaction.find(
+// "FROM " + PersonToList.class.getName() +
+// " WHERE pollAccount.accountId = :accountUId" +
+// " AND votingList.poll.pollId = :pollUId",
+// "accountUId", accountId,
+// "pollUId", pollId);
+
+ TopiaQuery query = new TopiaQuery(PersonToList.class,"p").
+ setSelect("p."+PersonToList.PROPERTY_POLL_ACCOUNT).
+ addWhere("p."+PersonToList.PROPERTY_POLL_ACCOUNT + "." + PollAccount.PROPERTY_ACCOUNT_ID, TopiaQuery.Op.EQ, accountId).
+ addWhere("p."+PersonToList.PROPERTY_VOTING_LIST + "." + VotingList.PROPERTY_POLL + "." + Poll.PROPERTY_POLL_ID, TopiaQuery.Op.EQ, pollId);
+ PollAccount result = findByQuery(query);
+ return result;
+ }
+} //PollAccountDAOImpl<E extends PollAccount>
Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/AbstractDAOTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/AbstractDAOTest.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/AbstractDAOTest.java 2012-02-26 17:19:03 UTC (rev 3146)
@@ -0,0 +1,145 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PolleIOUtil;
+import org.chorem.pollen.PollenConfiguration;
+import org.chorem.pollen.PollenTopiaRootContextFactory;
+import org.junit.Rule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * Base test for daos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class AbstractDAOTest {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AbstractDAOTest.class);
+
+ public static final String CONFIGURATION_PATH = "pollen-fake.properties";
+
+ public static final long TIMESTAMP = System.nanoTime();
+
+ @Rule
+ public T3Database db = new T3Database();
+
+ public T3Database getDb() {
+ return db;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return db.beginTransaction();
+ }
+
+ public PollenConfiguration getConfiguration() {
+ return getDb().getConfiguration();
+ }
+
+ /**
+ * A new database created for each test.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+ public static class T3Database extends TestWatcher {
+
+ private File testBasedir;
+
+ private TopiaContext rootCtxt;
+
+ private PollenConfiguration configuration;
+
+ public PollenConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ protected void starting(Description description) {
+
+ testBasedir = PolleIOUtil.getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName(),
+ TIMESTAMP);
+
+ // create the database
+ rootCtxt = new PollenTopiaRootContextFactory().newEmbeddedDatabase(
+ testBasedir,
+ "/" + CONFIGURATION_PATH
+ );
+
+ Properties props = new Properties();
+ props.put("testDirectory", testBasedir);
+ configuration = new PollenConfiguration(CONFIGURATION_PATH, props);
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ TopiaContextImplementor rootContext =
+ ((TopiaContextImplementor) rootCtxt).getRootContext();
+
+ if (log.isInfoEnabled()) {
+ log.info("release database " +
+ rootContext.getConfig().get(TopiaContextFactory.CONFIG_URL));
+ }
+ try {
+ if (rootContext != null && !rootContext.isClosed()) {
+ rootContext.closeContext();
+ }
+ } catch (TopiaException e) {
+ // we don't want this to throw an exception, wants to close
+ // all possible opened contexts
+ if (log.isErrorEnabled()) {
+ log.error("Could not close context " + rootContext, e);
+ }
+ }
+ }
+
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ public TopiaContext getRootCtxt() {
+ return rootCtxt;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return rootCtxt.beginTransaction();
+ }
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/AbstractDAOTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollAccountDAOTest.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollAccountDAOTest.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollAccountDAOTest.java 2012-02-26 17:19:03 UTC (rev 3146)
@@ -0,0 +1,90 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import org.chorem.pollen.entities.PollenDAOHelper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * Test the {@link PollAccountDAO}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PollAccountDAOTest extends AbstractDAOTest {
+
+ @Test
+ public void getRestrictedPollAccount() throws Exception {
+ TopiaContext tx = beginTransaction();
+
+ PollDAO pollDAO = PollenDAOHelper.getPollDAO(tx);
+
+ String pollId = "pollId";
+ String accountId = "accountId";
+
+ PollAccountDAO pollAccountDAO = PollenDAOHelper.getPollAccountDAO(tx);
+ PollAccount pollAccount = pollAccountDAO.newInstance();
+ pollAccount.setAccountId(accountId);
+ pollAccount = pollAccountDAO.create(pollAccount);
+
+ Poll poll = pollDAO.newInstance();
+ poll.setPollId(pollId);
+ poll = pollDAO.create(poll);
+
+
+ VotingListDAO votingListDAO = PollenDAOHelper.getVotingListDAO(tx);
+
+ VotingList votingList = votingListDAO.newInstance();
+
+ votingList.setPoll(poll);
+ votingList = votingListDAO.create(votingList);
+
+
+ PersonToListDAO personToListDAO = PollenDAOHelper.getPersonToListDAO(tx);
+
+ PersonToList personToList = personToListDAO.newInstance();
+ personToList.setPollAccount(pollAccount);
+ personToList.setVotingList(votingList);
+ personToList.setPollAccount(pollAccount);
+
+ personToList = personToListDAO.create(personToList);
+
+ poll.addVotingList(votingList);
+ pollAccount.addVotingListPersonToList(personToList);
+
+ pollDAO.update(poll);
+ pollAccountDAO.update(pollAccount);
+
+
+ PollAccount restrictedPollAccount =
+ pollAccountDAO.getRestrictedPollAccount(pollId, accountId);
+
+ Assert.assertNotNull(restrictedPollAccount);
+ Assert.assertEquals(accountId, restrictedPollAccount.getAccountId());
+ Assert.assertNotNull(restrictedPollAccount.getVotingListPersonToList());
+ Assert.assertTrue(restrictedPollAccount.getVotingListPersonToList().contains(personToList));
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollAccountDAOTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/resources/pollen-fake.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/test/resources/pollen-fake.properties (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/test/resources/pollen-fake.properties 2012-02-26 17:19:03 UTC (rev 3146)
@@ -0,0 +1,38 @@
+###
+# #%L
+# Pollen :: Persistence
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2012 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
+hibernate.show_sql=false
+hibernate.hbm2ddl.auto=update
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=sa
+hibernate.connection.driver_class=org.h2.Driver
+
+# Migration configuration
+topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine
+topia.service.migration.callback=org.chorem.pollen.entities.migration.PollenMigrationCallback
+topia.service.migration.showSql=true
+
+upImgDir=${testDirectory}/.pollen/uploadedImages
+feedDir=${testDirectory}/.pollen/feeds
+pollen.emails.directory=${testDirectory}/.pollen/emails
Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/test/resources/pollen-fake.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2012-02-25 15:59:05 +0100 (Sat, 25 Feb 2012)
New Revision: 3145
Url: http://chorem.org/repositories/revision/pollen/3145
Log:
votefor page continue (show votes + delete choices + votes)
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollChoiceNotFoundException.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollVoteNotFoundException.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/main.css
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -87,7 +87,8 @@
D dao = PollenDAOHelper.getDAO(getTransaction(), entityType);
return dao;
} catch (TopiaException e) {
- throw new PollenTechnicalException("Could not obtain dao of type " + entityType.getName(), e);
+ throw new PollenTechnicalException(
+ "Could not obtain dao of type " + entityType.getName(), e);
}
}
@@ -95,10 +96,20 @@
try {
return (T) dao.newInstance();
} catch (TopiaException e) {
- throw new PollenTechnicalException("Could not obtain new instance from dao " + dao, e);
+ throw new PollenTechnicalException(
+ "Could not obtain new instance from dao " + dao, e);
}
}
+ protected <T extends TopiaEntity, D extends TopiaDAO<? super T>> void delete(D dao, T entity) {
+ try {
+ dao.delete(entity);
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not delete entity " +
+ entity.getTopiaId(), e);
+ }
+ }
+
protected TopiaContext getTransaction() {
return serviceContext.getTransaction();
}
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollChoiceNotFoundException.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollChoiceNotFoundException.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollChoiceNotFoundException.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,34 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.services.exceptions;
+
+/**
+ * When a poll choice not found.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PollChoiceNotFoundException extends Exception {
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollChoiceNotFoundException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollVoteNotFoundException.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollVoteNotFoundException.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollVoteNotFoundException.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,34 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.services.exceptions;
+
+/**
+ * When a pooll vote not found.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PollVoteNotFoundException extends Exception {
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollVoteNotFoundException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -29,6 +29,8 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceDAO;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
@@ -39,14 +41,15 @@
import org.chorem.pollen.business.persistence.VoteDAO;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.exceptions.PollVoteNotFoundException;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.web.struts2.FilterPagerUtil;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
-
public class PollService extends PollenServiceSupport {
/** Logger. */
@@ -923,4 +926,60 @@
throw new PollenTechnicalException("Could not find poll with pollId " + pollId);
}
}
+
+ public PollAccount getNewPollAccount(UserAccount userAccount) {
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ PollAccount result = newInstance(dao);
+ if (userAccount != null) {
+ String displayName = userAccount.getDisplayName();
+ result.setVotingId(displayName);
+ }
+ return result;
+ }
+
+ public PollAccount getPollAccountByAccountId(String accountId) {
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ try {
+ PollAccount result = dao.findByAccountId(accountId);
+ return result;
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not botain account with this id", e);
+ }
+ }
+
+ public void deleteVote(String pollId, String voteId)
+ throws PollNotFoundException, PollVoteNotFoundException {
+
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+ Vote vote = poll.getVoteByTopiaId(voteId);
+
+ if (vote == null) {
+ throw new PollVoteNotFoundException();
+ }
+
+ VoteDAO dao = getDAO(Vote.class);
+ delete(dao, vote);
+ }
+
+ public void deleteChoice(String pollId, String choiceId)
+ throws PollNotFoundException, PollChoiceNotFoundException {
+
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+ Choice choice = poll.getChoiceByTopiaId(choiceId);
+
+ if (choice == null) {
+ throw new PollChoiceNotFoundException();
+ }
+
+ ChoiceDAO dao = getDAO(Choice.class);
+ delete(dao, choice);
+ }
}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,70 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * Abstract action for all actions with a poll uri id.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public abstract class AbstractPollUriIdAction extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Poll id (not topiaId but uuid, perharps we should use directly topiaId transformed to something smaller ?). */
+ protected String pollId;
+
+ /** Account id (not topiaId but uuid, perharps we should use directly topiaId transformed to something smaller ?). */
+ protected String accountId;
+
+ public final String getUriId() {
+ String result = pollId;
+ if (StringUtils.isNotEmpty(accountId)) {
+ result += ":" + accountId;
+ }
+ return result;
+ }
+
+ public final void setUriId(String uriId) {
+ String[] split = uriId.split(":", 2);
+ if (split.length > 0) {
+ pollId = split[0];
+ if (split.length > 1) {
+ accountId = split[1];
+ }
+ }
+ }
+
+ public final String getPollId() {
+ return pollId;
+ }
+
+ public final String getAccountId() {
+ return accountId;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -23,31 +23,52 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.UserAccount;
+import org.chorem.pollen.business.persistence.Vote;
+import org.chorem.pollen.business.persistence.VoteToChoice;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollFeedService;
import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
+import java.util.Date;
+
/**
* Abstract action for actions on the vote poll page.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2.6
*/
-public abstract class AbstractVoteAction extends PollenActionSupport {
+public abstract class AbstractVoteAction extends AbstractPollUriIdAction {
private static final long serialVersionUID = 1L;
- protected String pollId;
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AbstractVoteAction.class);
protected Poll poll;
protected boolean feedFileExisting;
+ protected boolean creatorUser;
+
+ protected boolean pollChoiceOrVoteStarted;
+
+ protected boolean accountFieldDisplayed;
+
+ protected boolean pollChoiceRunning;
+
+ protected boolean pollRunning;
+
protected String voteCountingTypeHelp;
protected String defaultCommentName;
@@ -56,27 +77,45 @@
protected String commentName;
+ protected String voteSizeMessage;
+
+ private PollAccount pollAccount;
+
+ private String pollAccountId;
+
@Override
public final String getPageLogo() {
return "Vote";
}
- public final String getPollId() {
- return pollId;
- }
+// public final void setPollId(String pollId) {
+// this.pollId = pollId;
+// }
+//
+// public void setAccountId(String accountId) {
+// this.accountId = accountId;
+// }
- public final void setPollId(String pollId) {
- this.pollId = pollId;
+ public String getPollAccountId() {
+ return pollAccountId;
}
public final Poll getPoll() {
return poll;
}
+ public PollAccount getPollAccount() {
+ return pollAccount;
+ }
+
public final boolean isFeedFileExisting() {
return feedFileExisting;
}
+ public boolean isPollChoiceOrVoteStarted() {
+ return pollChoiceOrVoteStarted;
+ }
+
public final String getVoteCountingTypeHelp() {
return voteCountingTypeHelp;
}
@@ -93,50 +132,264 @@
loadPoll();
- PollFeedService pollFeedService = newService(PollFeedService.class);
+ if (poll != null) {
- feedFileExisting = pollFeedService.isFeedExists(poll);
+ loadPollAccount();
+ PollFeedService pollFeedService = newService(PollFeedService.class);
- VoteCountingType voteCountingType = poll.getVoteCountingType();
- switch (voteCountingType) {
+ feedFileExisting = pollFeedService.isFeedExists(poll);
- case NORMAL:
- voteCountingTypeHelp =
- _("pollen.common.voteCountingTypeHelp.normal");
- break;
- case PERCENTAGE:
- voteCountingTypeHelp =
- _("pollen.common.voteCountingTypeHelp.percentage");
- break;
- case CONDORCET:
- voteCountingTypeHelp =
- _("pollen.common.voteCountingTypeHelp.condorcet");
- break;
- case NUMBER:
- voteCountingTypeHelp =
- _("pollen.common.voteCountingTypeHelp.number");
- break;
+ VoteCountingType voteCountingType = poll.getVoteCountingType();
+ switch (voteCountingType) {
+
+ case NORMAL:
+ voteCountingTypeHelp =
+ _("pollen.common.voteCountingTypeHelp.normal");
+ break;
+ case PERCENTAGE:
+ voteCountingTypeHelp =
+ _("pollen.common.voteCountingTypeHelp.percentage");
+ break;
+ case CONDORCET:
+ voteCountingTypeHelp =
+ _("pollen.common.voteCountingTypeHelp.condorcet");
+ break;
+ case NUMBER:
+ voteCountingTypeHelp =
+ _("pollen.common.voteCountingTypeHelp.number");
+ break;
+ }
+
+ // set default comment name
+ UserAccount userAccount = getPollenSession().getUserAccount();
+ if (userAccount == null) {
+ defaultCommentName = "";
+ } else {
+ defaultCommentName = userAccount.getDisplayName();
+ }
+
+ //TODO Fill this
+ Date currentTime = serviceContext.getCurrentTime();
+
+ accountFieldDisplayed = !poll.getAnonymous() || isRestrictedPoll() || isGroupPoll();
+
+ boolean choicestarted = poll.getBeginChoiceDate() == null || poll.getBeginChoiceDate().before(currentTime);
+ boolean choiceended = poll.getEndChoiceDate() != null && poll.getEndChoiceDate().before(currentTime);
+ boolean pollChoiceStarted = choicestarted && !choiceended;
+
+ //TODO Move this is poll entity
+ pollChoiceOrVoteStarted = pollChoiceStarted || isPollStarted();
+
+ pollChoiceRunning = poll.getChoiceAddAllowed() && pollChoiceStarted;
+
+ pollRunning = !(poll.getClosed() != null && poll.getClosed()) &&
+ isPollStarted() && !isPollFinished();
+
+ //TODO Deal the case of the not loggued poll (using the pollAccountId
+ creatorUser = getPollenSession().getUserAccount() != null &&
+ getPollenSession().getUserAccount().equals(poll.getCreator().getUserAccount());
+
+ if (log.isInfoEnabled()) {
+ log.info("pollChoiceOrVoteStarted = " + pollChoiceOrVoteStarted);
+ log.info("pollChoiceRunning = " + pollChoiceRunning);
+ log.info("pollRunning = " + pollRunning);
+ log.info("accountFieldDisplayed = " + accountFieldDisplayed);
+ log.info("creatorUser = " + creatorUser);
+ }
+ creatorName = poll.getCreator().getVotingId();
+
+
+// voteSizeMessage=XXX;
}
+ }
- // set default comment name
- UserAccount userAccount = getPollenSession().getUserAccount();
- if (userAccount == null) {
- defaultCommentName = "";
+ protected void loadPollAccount() {
+
+ PollService service = newService(PollService.class);
+
+ if (StringUtils.isNotEmpty(getAccountId())) {
+
+ pollAccount = service.getPollAccountByAccountId(getAccountId());
+
+ if (pollAccount != null) {
+
+ pollAccountId = pollAccount.getAccountId();
+
+ } else {
+
+
+ //TODO Do something in case of none free poll ?, not normal :(
+ addActionError(_("pollen.error.accountNotFound"));
+
+ if (!isFreePoll()) {
+
+ //TODO Should not be able to see the page ?
+ }
+ }
+
} else {
- defaultCommentName = userAccount.getDisplayName();
+ pollAccount = service.getNewPollAccount(getPollenSession().getUserAccount());
}
}
+ public String escapeLineBreak(String text) {
+ return text;
+ }
+
+ /**
+ * Retourne si le choix fait partie du vote (s'il a été renseigné par le
+ * votant).
+ *
+ * @param choice le choix concerné
+ * @return true si le choix est dans le vote
+ */
+ public boolean isChoiceInVote(VoteToChoice choice) {
+ boolean result = false;
+ if (choice != null) {
+ switch (poll.getVoteCountingType()) {
+ case NORMAL:
+ result = choice.getVoteValue() > 0;
+ break;
+ case PERCENTAGE:
+ result = true;
+ break;
+ case CONDORCET:
+ result = choice.getVoteValue() < 100;
+ break;
+ case NUMBER:
+ result = choice.getVoteValue() >= 0;
+ }
+ }
+ return result;
+ }
+
+ public boolean isModifAllowed(Vote vote) {
+
+ boolean result = false;
+
+ // can only modify a vote if poll is running.
+ if (pollRunning) {
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ // si le votant du vote correspond au votant actuel (pollAccountId)
+ if (pollAccountId != null
+ && pollAccountId.equals(votePollAccount.getAccountId())) {
+ result = true;
+ }
+
+ UserAccount userAccount = getPollenSession().getUserAccount();
+
+ // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
+ if (userAccount != null) {
+ UserAccount voteUserAccount = votePollAccount.getUserAccount();
+ result = voteUserAccount != null && userAccount.getTopiaId().equals(voteUserAccount.getTopiaId());
+ }
+ }
+ return result;
+ }
+
+ public boolean isCreatorUser() {
+ return creatorUser;
+ }
+
+ public boolean isAccountFieldDisplayed() {
+ return accountFieldDisplayed;
+ }
+
+ public boolean isPollChoiceRunning() {
+ return pollChoiceRunning;
+ }
+
+ public boolean isPollRunning() {
+ return pollRunning;
+ }
+
+ public String getCreatorName() {
+ return creatorName;
+ }
+
+ public String getVoteSizeMessage() {
+ return voteSizeMessage;
+ }
+
protected void loadPoll() throws PollNotFoundException {
- Preconditions.checkNotNull(pollId);
+// Preconditions.checkNotNull(pollId);
PollService service = newService(PollService.class);
- poll = service.getPollByPollId(pollId);
+ if (StringUtils.isNotEmpty(pollId)) {
+ poll = service.getPollByPollId(pollId);
+ }
if (poll == null) {
- throw new PollNotFoundException();
+ addActionError(_("pollen.error.poll.notfound"));
+ } else {
+ if (poll.getClosed()) {
+ addActionMessage(_("pollen.information.pollClosed"));
+ } else if (!isPollStarted()) {
+ addActionMessage(_("pollen.information.pollNotStarted"));
+ } else if (isPollFinished()) {
+ addActionMessage(_("pollen.information.pollFinished"));
+ }
+ if (isPollChoiceRunning()) {
+ addActionMessage(_("pollen.information.pollChoiceRunning"));
+ }
}
}
+
+ public boolean isDescNull(Choice choice) {
+ return StringUtils.isEmpty(choice.getDescription());
+ }
+
+ public boolean isFreePoll() {
+ return poll.getPollType() == PollType.FREE;
+ }
+
+ public boolean isRestrictedPoll() {
+ return poll.getPollType() == PollType.RESTRICTED;
+ }
+
+ public boolean isGroupPoll() {
+ return poll.getPollType() == PollType.GROUP;
+ }
+
+ public boolean isTextType() {
+ return poll.getChoiceType() == ChoiceType.TEXT;
+ }
+
+ public boolean isDateType() {
+ return poll.getChoiceType() == ChoiceType.DATE;
+ }
+
+ public boolean isImageType() {
+ return poll.getChoiceType() == ChoiceType.IMAGE;
+ }
+
+ public boolean isNormalVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.NORMAL;
+ }
+
+ public boolean isPercentageVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.PERCENTAGE;
+ }
+
+ public boolean isCondorcetVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.CONDORCET;
+ }
+
+ public boolean isNumberVoteCounting() {
+ return poll.getVoteCountingType() == VoteCountingType.NUMBER;
+ }
+
+ public boolean isPollStarted() {
+ Date now = serviceContext.getCurrentTime();
+ return poll.getBeginDate() == null || poll.getBeginDate().before(now);
+ }
+
+ public boolean isPollFinished() {
+ Date now = serviceContext.getCurrentTime();
+ return poll.getEndDate() != null && poll.getEndDate().before(now);
+ }
+
}
\ No newline at end of file
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * To confirm delete of a poll choice.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class ConfirmDeleteChoice extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String choiceId;
+
+ protected Choice choice;
+
+ public void setChoiceId(String choiceId) {
+ this.choiceId = choiceId;
+ }
+
+ public Choice getChoice() {
+ return choice;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(choiceId);
+
+ PollService service = newService(PollService.class);
+
+ Poll poll = service.getPollByPollId(pollId);
+
+ choice = poll.getChoiceByTopiaId(choiceId);
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -35,7 +35,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2.6
*/
-public class ConfirmDeleteComment extends PollenActionSupport {
+public class ConfirmDeleteComment extends AbstractPollUriIdAction {
private static final long serialVersionUID = 1L;
@@ -56,6 +56,7 @@
@Override
public String execute() throws Exception {
+ Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
PollCommentService service = newService(PollCommentService.class);
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.Vote;
+import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * To confirm delete of a poll vote
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class ConfirmDeleteVote extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String voteId;
+
+ protected Vote vote;
+
+ public void setVoteId(String voteId) {
+ this.voteId = voteId;
+ }
+
+ public Vote getVote() {
+ return vote;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(voteId);
+
+ PollService service = newService(PollService.class);
+
+ Poll poll = service.getPollByPollId(pollId);
+
+ vote = poll.getVoteByTopiaId(voteId);
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,58 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.services.impl.PollService;
+
+/**
+ * To delete a poll choice
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class DeleteChoice extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String choiceId;
+
+ public void setChoiceId(String choiceId) {
+ this.choiceId = choiceId;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(choiceId);
+
+ PollService service = newService(PollService.class);
+
+ service.deleteChoice(pollId, choiceId);
+ getTransaction().commitTransaction();
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -60,7 +60,7 @@
throw new PollCommentNotFound();
}
- setPollId(comment.getPoll().getPollId());
+ setUriId(getUriId());
service.deleteComment(commentId);
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,58 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.services.impl.PollService;
+
+/**
+ * To delete a poll vote.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class DeleteVote extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String voteId;
+
+ public void setVoteId(String voteId) {
+ this.voteId = voteId;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(voteId);
+
+ PollService service = newService(PollService.class);
+
+ service.deleteVote(pollId, voteId);
+ getTransaction().commitTransaction();
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,50 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class ModifyVote extends AbstractVoteAction {
+
+ private static final long serialVersionUID = 1L;
+
+
+ @Override
+ public String execute() throws Exception {
+
+
+ loadPoll();
+
+
+ if (poll==null) {
+
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.ui.actions.poll;
-
-import com.opensymphony.xwork2.Preparable;
-
-/**
- * Votes to a poll.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2.6
- */
-public class Vote extends AbstractVoteAction implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public String input() throws Exception {
-
- //TODO DO me!
- return INPUT;
- }
-
- @Override
- public String execute() throws Exception {
-
- //TODO Do me!
-
- return SUCCESS;
- }
-
- @Override
- public void prepare() throws Exception {
-
- prepareVotePage();
- commentName = getDefaultCommentName();
- }
-}
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java (from rev 3144, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.opensymphony.xwork2.Preparable;
+
+/**
+ * Votes to a poll.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class VoteForPoll extends AbstractVoteAction implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String input() throws Exception {
+
+ //TODO DO me!
+ return INPUT;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ //TODO Do me!
+
+ return SUCCESS;
+ }
+
+ @Override
+ public void prepare() throws Exception {
+
+ prepareVotePage();
+ commentName = getDefaultCommentName();
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-25 14:59:05 UTC (rev 3145)
@@ -36,9 +36,9 @@
<result-type name="redirectToVote"
class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
<param name="namespace">/poll</param>
- <param name="actionName">vote</param>
+ <param name="actionName">votefor/${uriId}</param>
<param name="method">input</param>
- <param name="pollId">${pollId}</param>
+ <!--<param name="uriId">${uriId}</param>-->
</result-type>
</result-types>
@@ -58,11 +58,19 @@
<!-- vote poll -->
<action name="vote"
- class="org.chorem.pollen.ui.actions.poll.Vote">
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
<result>/WEB-INF/jsp/poll/vote.jsp</result>
</action>
+ <!-- vote poll -->
+ <action name="votefor/*"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ <result>/WEB-INF/jsp/poll/vote.jsp</result>
+ </action>
+
<!-- clone poll -->
<action name="clone"
class="org.chorem.pollen.ui.actions.poll.Clone">
@@ -117,7 +125,7 @@
<!-- confirm delete comment -->
<action name="confirmDeleteComment"
class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteComment">
- <result>/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp</result>
+ <result>/WEB-INF/jsp/poll/confirmDeletePollComment.jsp</result>
</action>
<!-- add a poll comment -->
@@ -143,6 +151,36 @@
</result>
</action>
+ <!-- confirm delete poll vote -->
+ <action name="confirmDeleteVote"
+ class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteVote">
+ <result>/WEB-INF/jsp/poll/confirmDeletePollVote.jsp</result>
+ </action>
+
+ <!-- delete poll vote -->
+ <action name="deleteVote"
+ class="org.chorem.pollen.ui.actions.poll.DeleteVote">
+ <result type="redirectToVote"/>
+ </action>
+
+ <!-- modify poll vote -->
+ <action name="modifyVote"
+ class="org.chorem.pollen.ui.actions.poll.ModifyVote">
+ <result type="redirectToVote"/>
+ </action>
+
+ <!-- confirm delete poll choice -->
+ <action name="confirmDeleteChoice"
+ class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteChoice">
+ <result>/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp</result>
+ </action>
+
+ <!-- delete poll choice -->
+ <action name="deleteChoice"
+ class="org.chorem.pollen.ui.actions.poll.DeleteChoice">
+ <result type="redirectToVote"/>
+ </action>
+
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-25 14:59:05 UTC (rev 3145)
@@ -13,12 +13,15 @@
pollen.action.createPollAccount=Add a new member
pollen.action.createUser=Create a new user
pollen.action.delete=Delete
+pollen.action.deleteChoice=Delete the choice
pollen.action.deleteFavoriteList=Delete a list
pollen.action.deletePollAccount=Delete selected member
pollen.action.deleteUser=Delete selected user
+pollen.action.deleteVote=Supprimer ce vote
pollen.action.editFavoriteList=Edit a list
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
+pollen.action.editVote=Modifier le vote
pollen.action.login=Log me In
pollen.action.modify=Modify
pollen.action.pollClone=Copy the poll to create a new one
@@ -77,6 +80,8 @@
pollen.common.voteCountingTypeHelp.normal=Normal vote\: vote for your favorite choice.
pollen.common.voteCountingTypeHelp.number=Voting by number\: The answer is free, leave blank or enter a integer.
pollen.common.voteCountingTypeHelp.percentage=Percentage vote\: allocate choices to get a 100%% total.
+pollen.common.voterName=Votant
+pollen.error.accountNotFound=
pollen.error.comment.name.empty=Comment name mandatory
pollen.error.comment.text.empty=Comment text mandatory
pollen.error.email.required=You must provide an email
@@ -91,6 +96,7 @@
pollen.error.password.required=Your must provide a password
pollen.error.password2.required=You must repeat your password for confirmation
pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques
+pollen.error.poll.notfound=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
pollen.error.pollAccount.email.required=Em@il mandatory
pollen.error.pollAccount.not.found=Poll account not found
pollen.error.pollAccount.votingId.required=Name mandatory
@@ -114,12 +120,18 @@
pollen.fieldset.userInformation.toCreate=User informations to create
pollen.fieldset.userInformation.toDelete=User informations to delete
pollen.fieldset.userInformation.toUpdate=User informations to update
+pollen.information.confirmDeleteChoice=Confirm delete of choice %s
+pollen.information.confirmDeleteVote=Confirm delete of vote for %s
pollen.information.favoriteList.created=Favorite list %s created.
pollen.information.favoriteList.deleted=Favorite list %s deleted.
pollen.information.need.login=You must be logged to access this page. Please fill the form below.
pollen.information.pollAccount.addedTofavoriteList=Member '%s was added to favorite list.
pollen.information.pollAccount.removedFromFavoriteList=Member %s was removed from favorite list.
pollen.information.pollAccount.updatedTofavoriteList=Member %s was updated in favorite list.
+pollen.information.pollChoiceRunning=Adding choices is allowed.
+pollen.information.pollClosed=This poll is closed. You can not vote anymore.
+pollen.information.pollFinished=This poll is finished. You can not vote anymore.
+pollen.information.pollNotStarted=This poll has not started yet.
pollen.information.user.created=User %s created.
pollen.information.user.deleted=User %s deleted.
pollen.information.user.updated=User %s updated.
@@ -140,7 +152,9 @@
pollen.menu.register=Register
pollen.menu.userFavoriteLists=Voting lists
pollen.title.createPoll=New poll
-pollen.title.delete.comment=Confirm to delete a poll comment
+pollen.title.delete.pollChoice=Confirm to delete a poll choice
+pollen.title.delete.pollComment=Confirm to delete a poll comment
+pollen.title.delete.pollVote=Confirm to delete a poll vote
pollen.title.editFavoriteList=Edition de la liste des favoris
pollen.title.favoriteLists=Vos listes de votants
pollen.title.myAccount=My account
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-25 14:59:05 UTC (rev 3145)
@@ -13,12 +13,15 @@
pollen.action.createPollAccount=Ajouter une membre à la liste
pollen.action.createUser=Créer un nouvel utilisateur
pollen.action.delete=Supprimer
+pollen.action.deleteChoice=Supprimer le choix
pollen.action.deleteFavoriteList=Supprimer une liste sélectionnée
pollen.action.deletePollAccount=Supprimer une membre de la liste
pollen.action.deleteUser=Supprimer un utilisateur sélectionné
+pollen.action.deleteVote=Supprimer ce vote
pollen.action.editFavoriteList=Editer une liste sélectionnée
pollen.action.editPollAccount=Editer le membre sélectionné
pollen.action.editUser=Editer un utilisateur sélectionné
+pollen.action.editVote=Modifier le vote
pollen.action.login=M'identifier
pollen.action.modify=Modifier
pollen.action.pollClone=Créer un nouveau sondage à partir de celui-ci
@@ -51,6 +54,7 @@
pollen.common.login=Identifiant
pollen.common.name=Nom
pollen.common.nbAccounts=Nombre de membres
+pollen.common.nbVotes=vote-size\=%d votes ont été enregistrés
pollen.common.newPassword=Nouveau mot de passe
pollen.common.newPassword2=Répétez votre nouveau mot de passe
pollen.common.or=ou
@@ -77,7 +81,9 @@
pollen.common.voteCountingTypeHelp.normal=Vote normal \: voter pour le ou les choix préférés.
pollen.common.voteCountingTypeHelp.number=Vote par nombre \: La réponse est libre, laissez vide ou entrez un nombre entier
pollen.common.voteCountingTypeHelp.percentage=Vote par pourcentage \: répartir les choix de manière à obtenir 100%% au total.
+pollen.common.voterName=Votant
pollen.common.x=Dépouillement
+pollen.error.accountNotFound=
pollen.error.comment.name.empty=Nom du commentaire obligatoire
pollen.error.comment.text.empty=Texte du commentaire obligatoire
pollen.error.email.required=Courriel obligatoire
@@ -92,6 +98,7 @@
pollen.error.password.required=Mot de passe obligatoire
pollen.error.password2.required=Mot de passe répété obligatoire
pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques
+pollen.error.poll.notfound=Il n'y a pas de sondage à cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le complètement dans le champ d'adresse de votre navigateur.
pollen.error.pollAccount.email.required=Em@il obliqatoire
pollen.error.pollAccount.not.found=Membre non trouvé
pollen.error.pollAccount.votingId.required=Nom obliqatoire
@@ -115,12 +122,18 @@
pollen.fieldset.userInformation.toCreate=Informations de l'utilisateur à créer
pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer
pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour
+pollen.information.confirmDeletePollChoice=Confirmer la suppression du chois %s
+pollen.information.confirmDeletePollVote=Confirmer la suppression du vote de %s
pollen.information.favoriteList.created=La liste %s a été créée.
pollen.information.favoriteList.deleted=La liste %s a été supprimée.
pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous.
pollen.information.pollAccount.addedTofavoriteList=Le membre %s a été ajoutée à la liste des favoris.
pollen.information.pollAccount.removedFromFavoriteList=Le membre %s a été supprimé de la liste des favoris.
pollen.information.pollAccount.updatedTofavoriteList=Le membre %s a été mise à jour dans la liste des favoris.
+pollen.information.pollChoiceRunning=L'ajout de choix est possible.
+pollen.information.pollClosed=Ce sondage est clos. Vous ne pouvez plus voter.
+pollen.information.pollFinished=Ce sondage est terminé. Vous ne pouvez plus voter.
+pollen.information.pollNotStarted=Ce sondage n'a pas encore commencé.
pollen.information.user.created=L'utilisateur %s a été créé.
pollen.information.user.deleted=L'utilisateur %s a été supprimé.
pollen.information.user.updated=L'utilisateur %s a été mis à jour.
@@ -141,7 +154,9 @@
pollen.menu.register=Inscrivez-vous
pollen.menu.userFavoriteLists=Listes de votants
pollen.title.createPoll=Nouveau sondage
-pollen.title.delete.comment=Confirmer la suppresion d'un commentaire
+pollen.title.delete.pollChoice=Confirmer la suppresion d'un choix
+pollen.title.delete.pollComment=Confirmer la suppresion d'un commentaire
+pollen.title.delete.pollVote=Confirmer la suppresion d'un vote
pollen.title.editFavoriteList=Edition de la liste des favoris
pollen.title.favoriteLists=Vos listes de votants
pollen.title.myAccount=Mon compte
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-02-25 14:59:05 UTC (rev 3145)
@@ -42,6 +42,7 @@
<constant name="struts.configuration.xml.reload" value="false"/>
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.multipart.maxSize" value="209715200"/>
+ <constant name="struts.enable.SlashesInActionNames" value="true"/>
<!--Performance tuning-->
<!--see http://struts.apache.org/2.2.3/docs/performance-tuning.html-->
@@ -97,7 +98,33 @@
<!-- params stack with params-->
<interceptor-stack name="pollenParamsPrepareParamsStack">
<interceptor-ref name="i18n"/>
- <interceptor-ref name="paramsPrepareParamsStack"/>
+ <!--<interceptor-ref name="paramsPrepareParamsStack"/>-->
+ <interceptor-ref name="exception"/>
+ <interceptor-ref name="alias"/>
+ <interceptor-ref name="i18n"/>
+ <interceptor-ref name="checkbox"/>
+ <interceptor-ref name="multiselect"/>
+ <interceptor-ref name="params">
+ <param name="excludeParams">dojo\..*,^struts\..*</param>
+ </interceptor-ref>
+ <interceptor-ref name="servletConfig"/>
+ <interceptor-ref name="staticParams"/>
+ <interceptor-ref name="prepare"/>
+ <interceptor-ref name="chain"/>
+ <interceptor-ref name="modelDriven"/>
+ <interceptor-ref name="fileUpload"/>
+ <!--<interceptor-ref name="staticParams"/>-->
+ <interceptor-ref name="actionMappingParams"/>
+ <interceptor-ref name="params">
+ <param name="excludeParams">dojo\..*,^struts\..*</param>
+ </interceptor-ref>
+ <interceptor-ref name="conversionError"/>
+ <interceptor-ref name="validation">
+ <param name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
+ <interceptor-ref name="workflow">
+ <param name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
<interceptor-ref name="store">
<param name="operationMode">STORE</param>
</interceptor-ref>
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,44 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<br/>
+<s:form method="POST" namespace="/poll" action="deleteChoice">
+
+ <s:hidden key="uriId" label=''/>
+ <s:hidden key="choiceId" label=''/>
+
+ <s:text name="pollen.information.confirmDeletePollChoice">
+ <s:param>
+ <s:property value="%{choice.name}"/>
+ </s:param>
+ </s:text>.
+
+ <hr/>
+
+ <div class="cleanBoth">
+ <s:submit key="pollen.action.delete" align="right"/>
+ </div>
+</s:form>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp (from rev 3144, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,47 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<br/>
+<s:form method="POST" namespace="/poll" action="deleteComment">
+
+ <s:hidden name="uriId" value='%{uriId}'/>
+
+ <s:hidden name="commentId" value='%{comment.topiaId}'/>
+
+ <s:textfield key='comment.postDate' readonly="true" size="50"
+ label="%{getText('pollen.common.postDate')}"/>
+
+ <s:textfield key='comment.pollAccount.votingId' readonly="true" size="50"
+ label="%{getText('pollen.common.commentName')}"/>
+
+ <s:textarea key='comment.text' readonly="true" rows="3"
+ label="%{getText('pollen.common.commentText')}"/>
+
+ <hr/>
+
+ <div class="cleanBoth">
+ <s:submit key="pollen.action.delete" align="right"/>
+ </div>
+</s:form>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-02-25 14:59:05 UTC (rev 3145)
@@ -0,0 +1,43 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<br/>
+<s:form method="POST" namespace="/poll" action="deleteVote">
+
+ <s:hidden key="uriId" label=''/>
+ <s:hidden key="voteId" label=''/>
+
+ <s:text name="pollen.information.confirmDeletePollVote">
+ <s:param>
+ <strong><s:property value="%{vote.pollAccount.votingId}"/></strong>
+ </s:param>
+ </s:text>.
+
+ <hr/>
+
+ <div class="cleanBoth">
+ <s:submit key="pollen.action.delete" align="right"/>
+ </div>
+</s:form>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp 2012-02-25 14:59:05 UTC (rev 3145)
@@ -1,45 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:form method="POST" namespace="/poll" action="deleteComment">
-
- <s:hidden name="pollId" value='%{comment.poll.pollId}'/>
-
- <s:hidden name="commentId" value='%{comment.topiaId}'/>
-
- <s:textfield key='comment.postDate' readonly="true" size="50"
- label="%{getText('pollen.common.postDate')}"/>
-
- <s:textfield key='comment.pollAccount.votingId' readonly="true" size="50"
- label="%{getText('pollen.common.commentName')}"/>
-
- <s:textarea key='comment.text' readonly="true" rows="3"
- label="%{getText('pollen.common.commentText')}"/>
-
- <div class="cleanBoth">
- <s:submit key="pollen.action.delete" align="center"/>
- </div>
-</s:form>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-25 14:59:05 UTC (rev 3145)
@@ -29,7 +29,7 @@
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
-<s:url id="deleteUrl" action="confirmDeleteComment" namespace="/poll"/>
+<%--<s:url id="deleteCommentUrl" action="confirmDeleteComment" namespace="/poll"/>--%>
<s:url id='deleteImg' value='/img/delete.png'/>
<s:set id='deleteTitle'><s:text name="pollen.action.pollCommentDelete"/></s:set>
@@ -43,7 +43,7 @@
var result = "";
if (cellvalue.indexOf('delete') > -1) {
- var url = "openDialog(\""+ id + "\"); return false;";
+ var url = "return openDeleteCommentDialog(\"" + id + "\");";
result += formatLink(id, url, "${deleteImg}", "Delete", "${deleteTitle}")
}
return result;
@@ -54,12 +54,41 @@
// return "<a href='" + url + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>";
}
- function openDialog(commentId) {
+ function openDeleteCommentDialog(commentId) {
var dialog = $("#deleteCommentDialog");
- var url = $.prepareUrl("${deleteUrl}", {commentId:commentId});
+ var uriId = "<s:property value='%{uriId}'/>";
+ var url = $.prepareUrl("<s:url action='confirmDeleteComment' namespace='/poll'/>",
+ {uriId:uriId, commentId:commentId});
dialog.load(url);
dialog.dialog('open');
+ return false;
}
+
+ function openDeleteVoteDialog(voteId) {
+ var dialog = $("#deleteVoteDialog");
+ var uriId = "<s:property value='%{uriId}'/>";
+ var url = $.prepareUrl("<s:url action='confirmDeleteVote' namespace='/poll'/>",
+ {uriId:uriId, voteId:voteId});
+ dialog.load(url);
+ dialog.dialog('open');
+ return false;
+ }
+
+ function openDeleteChoiceDialog(choiceId) {
+ var dialog = $("#deleteChoiceDialog");
+ var uriId = "<s:property value='%{uriId}'/>";
+ var url = $.prepareUrl("<s:url action='confirmDeleteChoice' namespace='/poll'/>",
+ {uriId:uriId, choiceId:choiceId});
+ dialog.load(url);
+ dialog.dialog('open');
+ return false;
+ }
+
+ jQuery(document).ready(function () {
+ $('#poll tr:even').addClass('even');
+ });
+
+
</script>
<h1 class="titleVote"><s:property value="poll.title"/></h1>
@@ -82,7 +111,7 @@
alt="<s:text name="poll.common.vote.results"/>"/>
</s:a>
</s:if>
- <t:FeedContextLink t:id="feedContext"/>
+ <%--<t:FeedContextLink t:id="feedContext"/>--%>
<s:if test="feedFileExisting">
<s:a namespace="/poll" action="getFeed">
<s:param name="pollId" value="poll.pollId"/>
@@ -100,7 +129,295 @@
</fieldset>
</div>
+<s:if test="pollChoiceOrVoteStarted">
+<br/>
+
+<!-- Sondage -->
+
+<s:if test="poll.anonymous">
+ <p>
+ <s:text name="pollen.common.nbVotes">
+ <s:param><s:property value="%{poll.sizeVote()}"/></s:param>
+ </s:text>
+ </p>
+ <%--<t:feedback t:id="voteFeedback"/>--%>
+</s:if>
+<s:else>
+ <%--TODO Do me!--%>
+ <%--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"--%>
+ <%--t:currentPage="page" t:noPagerText="prop:noPagerText"/>--%>
+</s:else>
+
+<sj:dialog id="deleteVoteDialog" height="120" resizable="false"
+ title="%{getText('pollen.title.delete.pollVote')}"
+ autoOpen="false" modal="true" width="800"/>
+
+<sj:dialog id="deleteChoiceDialog" height="100" resizable="false"
+ title="%{getText('pollen.title.delete.pollChoice')}"
+ autoOpen="false" modal="true" width="800"/>
+
+<s:form id="voteForm">
+<table id="poll">
+<thead>
+<tr>
+ <s:if test="accountFieldDisplayed">
+ <th style="width:200px;">
+ <s:text name="pollen.common.voterName"/>
+ </th>
+ </s:if>
+ <s:else>
+ <th></th>
+ </s:else>
+ <s:if test="textType">
+ <s:iterator value="poll.choice" var="choice">
+ <s:if test="!isChoiceHidden(#choice)">
+ <th>
+ <s:if test="!isDescNull(#choice)">
+
+ <span title="<s:text name="pollen.common.description"/>"
+ value="%{escapeLineBreak(#choice.description)}">
+ <span class="desc">
+ <s:property value="%{#choice.name}"/>
+ </span>
+ </span>
+ </s:if>
+ <s:else>
+ <s:property value="%{#choice.name}"/>
+ </s:else>
+ <s:if test="pollChoiceRunning">
+ <s:if test="creatorUser">
+ <s:a action="deleteChoice" namespace="/poll">
+ <s:param name="choiceId">
+ <s:property value="%{#choice.id}"/>
+ </s:param>
+ <img src="<s:url value="/img/delete.png"/>"
+ title="<s:text name="pollen.action.deleteChoice"/>"
+ alt="<s:text name="pollen.action.deleteChoice"/>"/>
+ </s:a>
+ </s:if>
+ </s:if>
+ </th>
+ </s:if>
+ </s:iterator>
+ </s:if>
+
+ <s:if test="dateType">
+ <s:iterator value="poll.choice" var="choice">
+ <s:if test="!isChoiceHidden(#choice)">
+ <s:if test="!isDescNull(#choice)">
+
+ <th class="desc">
+ <span title="<s:text name="pollen.common.description"/>"
+ value="%{escapeLineBreak(#choice.description)}">
+ <s:property value="%{#choice.choiceNameAsDate}"/>
+ </span>
+ </th>
+ </s:if>
+ <s:else>
+ <th>
+ <s:property value="%{#choice.choiceNameAsDate}"/>
+ <%--<t:output value="choiceNameAsDate" format="dateFormat"/>--%>
+ </th>
+ </s:else>
+ </s:if>
+ </s:iterator>
+ </s:if>
+
+ <s:if test="imageType">
+ <s:iterator value="poll.choice" var="choice">
+ <s:if test="!isChoiceHidden(#choice)">
+ <s:if test="!isDescNull(#choice)">
+
+ <th class="desc">
+ <span title="<s:text name="pollen.common.description"/>"
+ value="%{escapeLineBreak(#choice.description)}">
+
+ <%--Obtain image from poll.pollId/choice.name--%>
+ <s:property value="%{#choice.name}"/>
+ <%--<t:image--%>
+ <%--t:src="#choice.name"--%>
+ <%--alt="#choice.description"--%>
+ <%--t:dir="poll.pollId"/>--%>
+ </span>
+ </th>
+ </s:if>
+ <s:else>
+ <th>
+ <%--Obtain image from poll.pollId/choice.name--%>
+ <s:property value="%{#choice.name}"/>
+ </th>
+ </s:else>
+ </s:if>
+ </s:iterator>
+ </s:if>
+</tr>
+</thead>
+<s:if test="pollRunning">
+ <tfoot>
+ <tr>
+ <s:if test="accountFieldDisplayed">
+ <th id="voterName">
+ <s:textfield id='pollAccountName' required="true"
+ value="%{pollAccount.votingId}" theme="simple"/>
+ </th>
+ </s:if>
+ <s:else>
+ <th></th>
+ </s:else>
+ <s:iterator value="poll.choice" var="choice">
+
+ <s:if test="!isChoiceHidden(#choice)">
+ <th>
+ <s:if
+ test="normalVoteCounting">
+ <s:checkbox value="addChoice" theme="simple"/>
+ </s:if>
+ <s:if
+ test="percentageVoteCounting">
+ <s:textfield value="#choice.value" size="3" required="true"
+ theme="simple"/>
+ <%--t:validate="required, min=0, max=100"/>%--%>
+ </s:if>
+ <s:if
+ test="condorcetVoteCounting">
+ <s:textfield id="condorcetInput" value="choice.value" size="3"
+ theme="simple"/>
+ <%--t:nulls="zero" t:validate="min=0, max=99"/>--%>
+ </s:if>
+ <s:if
+ test="numberVoteCounting">
+ <s:textfield value="addNumberVote" size="3" theme="simple"/>
+ </s:if>
+ </th>
+ </s:if>
+ </s:iterator>
+ </tr>
+ </tfoot>
+</s:if>
+<tbody>
+<s:if test="!poll.anonymous">
+ <s:iterator value="poll.vote" var="vote">
+ <tr>
+ <td>
+ <s:if test="accountFieldDisplayed">
+ <s:if test="!#vote.anonymous">
+ <s:property value="%{#vote.pollAccount.votingId}"/>
+ </s:if>
+ <s:else>
+ ?
+ </s:else>
+ </s:if>
+ <s:if test="!poll.anonymous">
+ <s:if test="isModifAllowed(#vote)">
+ <s:a action="editVote" namespace="/poll">
+ <s:param name="uriId" value="%{uriId}"/>
+ <s:param name="voteId" value="%{#vote.topiaId}"/>
+ <img src="<s:url value="/img/editSmall.png"/>"
+ title="<s:text name="pollen.action.editVote"/>"
+ alt="<s:text name="pollen.action.editVote"/>"/>
+ </s:a>
+ </s:if>
+ <s:if test="creatorUser">
+ <s:a action="deleteVote" namespace="/poll" href="#"
+ onclick="return openDeleteVoteDialog('%{#vote.topiaId}');">
+ <%--<s:param name="uriId" value="%{uriId}"/>--%>
+ <%--<s:param name="voteId" value="%{#vote.topiaId}"/>--%>
+ <img src="<s:url value="/img/delete.png"/>"
+ title="<s:text name="pollen.action.deleteVote"/>"
+ alt="<s:text name="pollen.action.deleteVote"/>"/>
+ </s:a>
+ </s:if>
+ </s:if>
+ </td>
+ <s:iterator value="poll.choice" var="choice">
+ <s:if test="!isChoiceHidden(#choice)">
+ <s:set name="currentVoteChoice"
+ value="%{#vote.getChoiceVoteToChoice(#choice)}"/>
+ <s:if test="poll.anonymous">
+ <td class="anonymous">?</td>
+ </s:if>
+ <s:else>
+ <s:if test="normalVoteCounting">
+ <s:if test="isChoiceInVote(#currentVoteChoice)">
+ <td class="voted">OK</td>
+ </s:if>
+ <s:else>
+ <td class="notVoted"></td>
+ </s:else>
+ </s:if>
+ <s:if test="percentageVoteCounting">
+ <s:if test="isChoiceInVote(#currentVoteChoice)">
+ <td class="voted"><s:property
+ value="%{#currentVoteChoice.voteValue}"/> %
+ </td>
+ </s:if>
+ <s:else>
+ <td class="notVoted"></td>
+ </s:else>
+ </s:if>
+ <s:if test="condorcetVoteCounting">
+ <s:if test="isChoiceInVote(#currentVoteChoice)">
+ <td class="voted"><s:property
+ value="%{#currentVoteChoice.voteValue}"/></td>
+ </s:if>
+ <s:else>
+ <td class="notVoted"></td>
+ </s:else>
+ </s:if>
+ <s:if
+ test="numberVoteCounting">
+ <s:if test="isChoiceInVote(#currentVoteChoice)">
+ <td class="voted"><s:property
+ value="%{#currentVoteChoice.voteValue}"/></td>
+ </s:if>
+ <s:else>
+ <td class="notVoted"></td>
+ </s:else>
+ </s:if>
+ </s:else>
+ </s:if>
+ </s:iterator>
+ </tr>
+ </s:iterator>
+</s:if>
+<s:if test="poll.continuousResults">
+ <tr>
+ <td>
+ <s:a namespace="/poll" action="result" method="input">
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:text name="poll.common.vote.results"/>
+ </s:a>
+ <%--<t:PageLink t:page="poll/results"--%>
+ <%--t:context="${poll.pollId}">${message:results}</t:PageLink>--%>
+ </td>
+
+ <s:iterator value="poll.choice" var="choice">
+ <s:if test="!isChoiceHidden(#choice)">
+ <td class="result">TODO ${currentChoiceResult}</td>
+ </s:if>
+ </s:iterator>
+ </tr>
+</s:if>
+</tbody>
+</table>
+<div id="voteError">
+ <%--<t:errors/>--%>
+</div>
+
+<s:if test="pollRunning">
+ <div id="buttons">
+ <s:if test="anonymousVoteDisplayed">
+ <s:checkbox id="anonymousVote" value="anonymousVote"/>
+ <%--<t:label for="anonymousVote"/>--%>
+ <br/>
+ </s:if>
+ <s:submit action="vote" key="pollen.action.vote"/>
+ <%--<input id="submitVote" t:type="Submit" t:value="${message:submitVote}"/>--%>
+ </div>
+</s:if>
+</s:form>
+
<!-- Ajout de commentaires -->
<h3><s:text name="poll.common.comments"/></h3>
@@ -137,26 +454,27 @@
<br/>
-<%--<div id="commentFormDiv">--%>
+<div id="commentFormDiv">
-<fieldset>
- <legend><s:text name="poll.legend.addNewComment"/></legend>
- <s:form id='addCommentForm' method="POST" namespace="/poll">
- <s:hidden key="pollId" label=''/>
- <s:textfield key="commentName" required="true"
- label="%{getText('pollen.common.commentName')}"/>
- <s:textarea key="commentText" required="true" value=''
- label="%{getText('pollen.common.commentText')}"/>
+ <fieldset>
+ <legend><s:text name="poll.legend.addNewComment"/></legend>
+ <s:form id='addCommentForm' method="POST" namespace="/poll">
+ <s:hidden key="pollId" label=''/>
+ <s:textfield key="commentName" required="true"
+ label="%{getText('pollen.common.commentName')}"/>
+ <s:textarea key="commentText" required="true" value=''
+ label="%{getText('pollen.common.commentText')}"/>
- <div class="cleanBoth">
- <s:submit action="addComment" key="pollen.action.addComment"
- align="left"/>
- </div>
- </s:form>
-</fieldset>
-<%--</div>--%>
+ <div class="cleanBoth">
+ <s:submit action="addComment" key="pollen.action.addComment"
+ align="left"/>
+ </div>
+ </s:form>
+ </fieldset>
+</div>
-<sj:dialog id="deleteCommentDialog"
- title="%{getText('pollen.title.delete.comment')}"
+<sj:dialog id="deleteCommentDialog" resizable="false"
+ title="%{getText('pollen.title.delete.pollComment')}"
autoOpen="false" modal="true" width="800"/>
+</s:if>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/main.css
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/main.css 2012-02-23 12:31:32 UTC (rev 3144)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/main.css 2012-02-25 14:59:05 UTC (rev 3145)
@@ -492,4 +492,98 @@
text-align: center;
text-decoration: none;
text-shadow: 1px 1px 10px #000000;
+}
+
+#poll {
+ border-collapse: collapse;
+ border-left: 1px solid #aab;
+ border-top: 1px solid #aab;
+ background-color: #fff;
+ font-size: 14px;
+ margin: auto;
+}
+
+#poll THEAD,
+#poll TFOOT {
+ border-top: 1px solid #aab; /* For Firefox */
+}
+
+#poll THEAD TR {
+ color: #fff;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR a {
+ color: #fff;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR TH {
+ text-align: left;
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color: #55cb00;
+}
+
+#poll THEAD TR TH .desc {
+ padding: 2px 3px;
+ text-decoration: overline;
+}
+
+#poll TFOOT TR TH {
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color: #55cb00;
+}
+
+#poll TFOOT TR #voterName {
+ text-align: left;
+}
+
+/*#poll TBODY TR {*/
+ /*background-color: #fff;*/
+/*}*/
+
+#poll TBODY TR .even {
+ background-color: #b0f580;
+}
+
+#poll TBODY TR .anonymous {
+ background-color: #ddd;
+ text-align: center;
+}
+
+#poll TBODY TR .voted {
+ background-color: #6f6;
+ color: #242;
+ text-align: center;
+}
+
+#poll TBODY TR .notVoted {
+ background-color: #f66;
+}
+
+#poll TBODY TR .result {
+ background-color: #e5e5e5;
+ color: #555;
+ text-align: center;
+}
+
+#poll TBODY TR TD {
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ padding: 2px 5px;
+}
+
+#choiceFormDiv form {
+ width: 200px;
+ margin: auto;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ padding: 10px 50px 10px 50px;
+ border-top: 1px solid #aab;
}
\ No newline at end of file
1
0
r3144 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 23 Feb '12
by tchemit@users.chorem.org 23 Feb '12
23 Feb '12
Author: tchemit
Date: 2012-02-23 13:31:32 +0100 (Thu, 23 Feb 2012)
New Revision: 3144
Url: http://chorem.org/repositories/revision/pollen/3144
Log:
make poll feeds works
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java 2012-02-22 22:54:14 UTC (rev 3143)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java 2012-02-23 12:31:32 UTC (rev 3144)
@@ -48,18 +48,18 @@
protected long contentLength;
- protected transient InputStream stream;
+ protected transient InputStream inputStream;
- public String getPollId() {
- return pollId;
+ public void setPollId(String pollId) {
+ this.pollId = pollId;
}
public long getContentLength() {
return contentLength;
}
- public InputStream getStream() {
- return stream;
+ public InputStream getInputStream() {
+ return inputStream;
}
@Override
@@ -81,7 +81,7 @@
contentLength = feedLocation.length();
- stream = new FileInputStream(feedLocation);
+ inputStream = new FileInputStream(feedLocation);
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-22 22:54:14 UTC (rev 3143)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-23 12:31:32 UTC (rev 3144)
@@ -84,7 +84,7 @@
</s:if>
<t:FeedContextLink t:id="feedContext"/>
<s:if test="feedFileExisting">
- <s:a namespace="/poll" action="getFeed" method="input">
+ <s:a namespace="/poll" action="getFeed">
<s:param name="pollId" value="poll.pollId"/>
<img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/>
</s:a>
1
0