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
- 3196 discussions
Author: tchemit
Date: 2012-06-03 17:40:54 +0200 (Sun, 03 Jun 2012)
New Revision: 3416
Url: http://chorem.org/repositories/revision/pollen/3416
Log:
- les services sont tous disponibles au niveau de chaque action
- checkup que tous les commits sont bien fait au niveau services et pas dans les actions
- suppression dans le mod?\195?\168le de certaines bi-directions (il en reste encore un peu... mais j'ai plus le courage :()
- fixes #579: Poll creator acts as a admin for his poll
- fixes #575: Impossible de supprimer un vote pour le cr?\195?\169ateur du sondage
- fixes #135: [Vote] D?\195?\169pouillement effectu?\195?\169 ?\195?\160 chaque chargement de la page des votes
Added:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/pom.xml 2012-06-03 15:40:54 UTC (rev 3416)
@@ -95,8 +95,7 @@
<defaultPackage>org.chorem.pollen.entities</defaultPackage>
<templates>
org.nuiton.topia.generator.TopiaMetaTransformer,
- org.nuiton.topia.generator.BinderHelperTransformer,
- org.nuiton.topia.generator.QueryHelperTransformer
+ org.nuiton.topia.generator.BinderHelperTransformer
</templates>
</configuration>
<goals>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,8 +39,9 @@
Preconditions.checkNotNull(pollId);
TopiaQuery countQuery = createQuery("e").
- addWhere("e." + Comment.PROPERTY_POLL + ".pollId",
- TopiaQuery.Op.EQ, pollId);
+ addFrom(Poll.class, "p").
+ addWhere("p." + Poll.PROPERTY_POLL_ID, TopiaQuery.Op.EQ, pollId).
+ addWhere("e in elements(p." + Poll.PROPERTY_COMMENT + ")");
long records = countByQuery(countQuery);
pager.setRecords((int) records);
@@ -56,8 +57,9 @@
Preconditions.checkNotNull(pollId);
TopiaQuery query = createQuery("e").
- addWhere("e." + Comment.PROPERTY_POLL + ".pollId",
- TopiaQuery.Op.EQ, pollId);
+ addFrom(Poll.class, "p").
+ addWhere("p." + Poll.PROPERTY_POLL_ID, TopiaQuery.Op.EQ, pollId).
+ addWhere("e in elements(p." + Poll.PROPERTY_COMMENT + ")");
query.addOrderDesc(Comment.PROPERTY_POST_DATE);
List<E> result = findAllByQuery(query);
return result;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -106,7 +106,9 @@
VoteDAO voteDao = PollenDAOHelper.getVoteDAO(context);
TopiaQuery query = voteDao.createQuery("e").
- setSelect("e." + Vote.PROPERTY_POLL, "e." + Vote.PROPERTY_POLL_ACCOUNT).
+ addFrom(Poll.class, "p").
+ addWhere("e in elements(p." + Poll.PROPERTY_VOTE + ")").
+ setSelect("p", "e." + Vote.PROPERTY_POLL_ACCOUNT).
addWhere("e." + Vote.PROPERTY_POLL_ACCOUNT + "." +
PollAccount.PROPERTY_USER_ACCOUNT,
TopiaQuery.Op.EQ, userToUse);
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -66,62 +66,38 @@
// Order the results by creation date (the last vote done will be
// at the end of the list)
TopiaQuery query = createQuery("e").
- addWhere("e.poll", TopiaQuery.Op.EQ, poll).
+ addFrom(Poll.class, "p").
+ addWhere("p", TopiaQuery.Op.EQ, poll).
+ addWhere("e in elements (p." + Poll.PROPERTY_VOTE + ")").
addOrder("topiaCreateDate");
TopiaFilterPagerUtil.addPagerToQuery(query, pager);
results = findAllByQuery(query);
-
-//
-// List<E> votes = 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);
}
return results;
}
- public boolean hasAlreadyVoted(String votingId, Poll poll) throws TopiaException {
+ public boolean hasAlreadyVoted(Poll poll, String votingId) throws TopiaException {
// Test using a count(*) on votes
TopiaQuery query = createQuery("e").
- addWhere("e.poll", TopiaQuery.Op.EQ, poll).
+ addFrom(Poll.class, "p").
+ addWhere("p", TopiaQuery.Op.EQ, poll).
+ addWhere("e in elements(p." + Poll.PROPERTY_VOTE + ")").
addWhere("e.pollAccount.votingId", TopiaQuery.Op.EQ, votingId).
addOrder("topiaCreateDate");
boolean result = existByQuery(query);
return result;
-// 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;
-
}
-
+
public Vote findByAccountId(String accountId) throws TopiaException {
-
- String accountIdProperty =
+
+ String accountIdProperty =
TopiaQuery.getProperty("e", Vote.PROPERTY_POLL_ACCOUNT, PollAccount.PROPERTY_ACCOUNT_ID);
TopiaQuery query = createQuery("e").addEquals(accountIdProperty, accountId);
Vote result = findByQuery(query);
return result;
}
-
-
+
+
} //VoteDAOImpl<E extends Vote>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.entities.migration;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceImpl;
import org.nuiton.topia.TopiaException;
@@ -61,8 +62,17 @@
// see http://chorem.org/issues/574
// see http://chorem.org/issues/576
removeAllCondorcetNullVotes(tx, queries);
+
+ // add a flag to not generate results each time (http://chorem.org/issues/135)
+ addResultUptodateToPoll(queries);
}
+ private void addResultUptodateToPoll(List<String> queries) {
+ queries.add("ALTER TABLE poll ADD COLUMN " +
+ Poll.PROPERTY_RESULT_UPTODATE + " boolean default false;");
+
+ }
+
private void removeAllCondorcetNullVotes(TopiaContextImplementor tx,
List<String> queries) throws TopiaException {
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,6 +29,7 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.services.impl.PollUrlService;
import org.chorem.pollen.services.impl.PreventRuleService;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -80,6 +81,8 @@
try {
serviceContext.setTransaction(transaction);
+ PollUrlService pollUrlService =
+ serviceContext.newService(PollUrlService.class);
PollService pollService =
serviceContext.newService(PollService.class);
PreventRuleService preventRuleService =
@@ -90,7 +93,8 @@
for (Poll poll : polls) {
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+ PollUrl pollVoteUrl =
+ pollUrlService.getPollVoteUrl(poll, false);
preventRuleService.onPollToRemind(poll, pollVoteUrl);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,15 +27,19 @@
import com.google.common.collect.Lists;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
+import org.chorem.pollen.bean.PollResult;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceImpl;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.PersonToListImpl;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountImpl;
+import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListImpl;
import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.votecounting.business.NumberMethod;
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
@@ -223,4 +227,26 @@
return result;
}
}
+
+ public static Function<Result, PollResult> newResultToBeanFunction(final Poll poll) {
+ return new Function<Result, PollResult>() {
+
+ @Override
+ public PollResult apply(Result res) {
+ 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.isByGroup());
+ dto.setChoiceType(poll.getChoiceType());
+ dto.setVoteCountingType(poll.getVoteCountingType());
+ return dto;
+ }
+ };
+ }
+
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,8 +25,6 @@
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.PollenTechnicalException;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PersonListDAO;
@@ -49,9 +47,6 @@
public class FavoriteService extends PollenServiceSupport {
- /** Logger. */
- private static final Log log = LogFactory.getLog(FavoriteService.class);
-
public List<PersonList> getFavoriteLists(UserAccount user,
TopiaFilterPagerUtil.FilterPagerBean pager) {
@@ -198,6 +193,8 @@
}
dao.delete(favoriteListToDelete);
+
+ commitTransaction("Could not delete favorite list");
return favoriteListToDelete;
} catch (TopiaException e) {
@@ -245,6 +242,7 @@
pollAccountCreated.setEmail(pollAccount.getEmail());
personListToUpdate.addPollAccount(pollAccountCreated);
+ commitTransaction("Could not add poll account to favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
@@ -291,6 +289,7 @@
pollAccountToUpdate.setVotingId(pollAccount.getVotingId());
pollAccountToUpdate.setEmail(pollAccount.getEmail());
+ commitTransaction("Could not edit poll account favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
@@ -333,6 +332,7 @@
personListToUpdate.removePollAccount(pollAccountToRemove);
+ commitTransaction("Could not remove pollaccount to favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.CommentDAO;
import org.chorem.pollen.business.persistence.Poll;
@@ -47,6 +46,14 @@
*/
public class PollCommentService extends PollenServiceSupport {
+ public Comment getExistingPollComment(String commentId) throws PollCommentNotFound {
+ Comment result = getEntityById(Comment.class, commentId);
+ if (result == null) {
+ throw new PollCommentNotFound();
+ }
+ return result;
+ }
+
public Comment createComment(Poll poll, Comment comment) {
Preconditions.checkNotNull(poll);
@@ -61,7 +68,7 @@
// creates the poll comment
Comment commentCreated = dao.create(
- Comment.PROPERTY_POLL, pollToUpdate,
+// Comment.PROPERTY_POLL, pollToUpdate,
Comment.PROPERTY_POST_DATE, comment.getPostDate(),
Comment.PROPERTY_AUTHOR, comment.getAuthor(),
Comment.PROPERTY_TEXT, comment.getText()
@@ -90,11 +97,8 @@
// feed notification
- PollService pollService = newService(PollService.class);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
-
PollFeedService pollFeedService = newService(PollFeedService.class);
- pollFeedService.onAddComment(commentCreated, pollVoteUrl);
+ pollFeedService.onAddComment(poll, commentCreated);
return commentCreated;
} catch (TopiaException e) {
@@ -109,27 +113,20 @@
Preconditions.checkNotNull(poll);
Preconditions.checkNotNull(commentId);
+ Comment comment = getExistingPollComment(commentId);
+
CommentDAO dao = getDAO(Comment.class);
try {
- Comment comment = dao.findByTopiaId(commentId);
-
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
dao.delete(comment);
commitTransaction("Could not delete comment " + comment.getText());
// feed notification
- PollService pollService = newService(PollService.class);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
-
PollFeedService pollFeedService = newService(PollFeedService.class);
- pollFeedService.onDeleteComment(comment, pollVoteUrl, reason);
+ pollFeedService.onDeleteComment(poll, comment, reason);
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
@@ -152,26 +149,31 @@
public boolean isCanDeleteComment(Comment comment,
PollAccount pollAccount,
- UserAccount userAccount) {
+ UserAccount userAccount,
+ boolean isPollCreator) {
- boolean result;
+ boolean result = false;
PollAccount commentAccount = comment.getPollAccount();
- // loggued
- if (userAccount != null) {
+ if (isPollCreator) {
+ // poll creator has admin rights on his poll
+ result = true;
+ } else if (userAccount != null) {
+
+ // loggued
boolean isAdmin = userAccount.isAdministrator();
- boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
- result = isAdmin || isCommentAccount;
+ // pollen admin or comment owner (linked by user account)
+ result = isAdmin ||
+ userAccount.equals(commentAccount.getUserAccount());
} else if (pollAccount != null) {
+ // comment owner (linked by poll account)
result = pollAccount.equals(commentAccount);
-
- } else {
- result = false;
}
return result;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -40,6 +40,7 @@
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.Vote;
import org.chorem.pollen.services.PollenServiceSupport;
@@ -116,37 +117,50 @@
}
}
- public void onAddComment(Comment comment, PollUrl pollVoteUrl) {
+ public void onAddComment(Poll poll, Comment comment) {
+ PollUrlService pollService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
+
String title = _("pollen.feed.addCommentTitle",
comment.getAuthor());
String content = _("pollen.feed.addCommentContent",
comment.getText());
- addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
- public void onDeleteComment(Comment comment,
- PollUrl pollVoteUrl,
- String reason) {
+ public void onDeleteComment(Poll poll, Comment comment, String reason) {
+ PollUrlService pollService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
String title = _("pollen.feed.deleteCommentTitle",
- comment.getAuthor());
+ comment.getAuthor(), reason);
- String content = _("pollen.feed.deleteCommentContent",
- comment.getText(), reason);
+ String content =
+ _("pollen.feed.deleteCommentContent", comment.getText());
- addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
- public void onAddVote(Vote vote,
- boolean anonymousVote,
- String pollResult,
- PollUrl pollVoteUrl) {
+ public void onAddVote(Poll poll, Vote vote) {
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
String userId;
- if (anonymousVote) {
+
+ if (vote.isAnonymous()) {
+
userId = _("pollen.common.anonymous");
} else {
userId = vote.getPollAccount().getVotingId();
@@ -156,9 +170,62 @@
String content = _("pollen.feed.addVoteContent", pollResult);
- addFeedEntry(vote.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
+ public void onUpdateVote(Poll poll,
+ Vote vote) {
+
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
+ String userId;
+
+ if (vote.isAnonymous()) {
+
+ userId = _("pollen.common.anonymous");
+ } else {
+ userId = vote.getPollAccount().getVotingId();
+
+ }
+ String title = _("pollen.feed.updateVoteTitle", userId);
+
+ String content = _("pollen.feed.updateVoteContent", pollResult);
+
+ addFeedEntry(poll, title, content, pollVoteUrl);
+ }
+
+ public void onDeleteVote(Poll poll, Vote vote, PollAccount voteAccount, String reason) {
+
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
+ String userId;
+ if (vote.isAnonymous()) {
+ userId = _("pollen.common.anonymous");
+ } else {
+ userId = voteAccount.getVotingId();
+
+ }
+ String title = _("pollen.feed.deleteVoteTitle", userId, reason);
+
+ String content = _("pollen.feed.deleteVoteContent", pollResult);
+
+ addFeedEntry(poll, title, content, pollVoteUrl);
+ }
+
public void onAddChoice(Poll poll, Choice choice, PollUrl pollVoteUrl) {
String title = _("pollen.feed.addChoiceTitle", choice.getName());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,6 +39,7 @@
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.votecounting.business.NumberMethod;
@@ -72,91 +73,53 @@
/** log. */
private static final Log log = LogFactory.getLog(PollResultsService.class);
- public PollResultList getResults(String pollId) throws PollNotFoundException {
-
- PollService pollService = newService(PollService.class);
- Poll poll = pollService.getPollByPollId(pollId);
-
- if (poll == null) {
- throw new PollNotFoundException();
- }
- PollResultList result;
- if (poll.getPollType() == PollType.GROUP) {
- result = generateResults(poll, null, true, true);
- } else {
- result = generateResults(poll, null, true, false);
- }
- return result;
- }
-
/**
- * Génère les résultats d'un sondage (= un dépouillement).
+ * Récurpération des résultats d'un sondage sous forme de
+ * {@link PollResultList}.
+ * <p/>
+ * Si les résultats ne sont pas à jour ({@link Poll#isResultUptodate()},
+ * alors ils seront regénérés.
*
- * @param poll 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
+ * @param poll le sondage à traiter
+ * @return les résultats du sondage.
*/
- private PollResultList generateResults(Poll poll,
- VoteCountingType voteCounting,
- boolean byGroup,
- boolean groupOnly) {
+ public PollResultList getResults(Poll poll) {
+ Preconditions.checkNotNull(poll);
- 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 = PollenFunctions.POLL_TO_BEAN.apply(poll);
+ VoteCountingResultDTO result;
+ if (!poll.isResultUptodate()) {
- if (voteCounting != null) {
- dto.setVoteCounting(voteCounting);
- }
+ //must regenerate results
- // clear result (they will be regenerated ! (a big shame))
- poll.clearResult();
+ result = generateResult(poll);
- VoteCountingService service = new VoteCountingService();
+ commitTransaction("Could not generate poll result");
+ } else {
- VoteCountingResultDTO result = service.execute(dto);
+ result = getResultDTO(poll);
- ResultDAO daoResult = getDAO(Result.class);
+ }
- for (ChoiceDTO choice : result.getChoices()) {
+ boolean byGroup = poll.getPollType() == PollType.GROUP;
- Result eResult = create(daoResult);
+ VoteCountingType voteCountingType = poll.getVoteCountingType();
- Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+ // Conversion des résultats
+ List<PollResult> list = Lists.transform(
+ poll.getResult(),
+ PollenServiceFunctions.newResultToBeanFunction(poll));
- poll.addResult(eResult);
+ // Filtrage des résultats que l'on veut retourner
- eResult.setName(eChoice.getName());
- eResult.setByGroup(result.isByGroup());
- eResult.setPoll(poll);
- eResult.setResultValue(String.valueOf(choice.getValue()));
- eResult.setVoteCountingType(result.getTypeVoteCounting());
- }
-
- commitTransaction("Could not generate poll result");
-
- // 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) {
+ if (currentResult.getVoteCountingType() != voteCountingType) {
it.remove();
}
@@ -164,15 +127,10 @@
if (byGroup) {
// Filtre group : Suppression resultats non group
- if (groupOnly && !currentResult.isByGroup()) {
+ if (!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();
@@ -186,18 +144,60 @@
return resultList;
}
+ /**
+ * Génère les résultats d'un sondage (= un dépouillement) et les stoque en
+ * base.
+ * <p/>
+ * <strong>Note importante :</strong> Le commite n'est pas effectuée dans
+ * cette méthode car d'autres services vont appeller cette méthode au sein
+ * d'une transaction et on ne veut pas faire deux commits.
+ *
+ * @param poll le sondage à dépouiller
+ * @since 1.4
+ */
+ public VoteCountingResultDTO generateResult(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will regenerate results for poll " + poll.getPollId());
+ }
+
+ VoteCountingResultDTO result = getResultDTO(poll);
+
+ // clear result
+ poll.clearResult();
+
+ ResultDAO daoResult = getDAO(Result.class);
+
+ for (ChoiceDTO choice : result.getChoices()) {
+
+ Result eResult = create(daoResult);
+
+ Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+
+ eResult.setName(eChoice.getName());
+ eResult.setByGroup(result.isByGroup());
+// eResult.setPoll(poll);
+ eResult.setResultValue(String.valueOf(choice.getValue()));
+ eResult.setVoteCountingType(result.getTypeVoteCounting());
+
+ poll.addResult(eResult);
+ }
+
+ poll.setResultUptodate(true);
+
+ return result;
+ }
+
public String exportPolltoXml(String pollId) throws PollNotFoundException {
// Recherche du sondage
PollService pollService = newService(PollService.class);
- Poll poll = pollService.getPollByPollId(pollId);
+ Poll poll = pollService.getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
VoteCountingService service = new VoteCountingService();
@@ -216,7 +216,7 @@
// Transformation du sondage
PollExportDTO pollExport = new PollExportDTO();
- pollExport.setPollId(dto.getPollId());
+ pollExport.setPollId(pollId);
pollExport.setPoll(dto);
pollExport.setVoteCountingResults(results);
@@ -227,31 +227,6 @@
return content;
}
- /**
- * 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
- */
- protected 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.isByGroup());
- dto.setChoiceType(poll.getChoiceType());
- dto.setVoteCountingType(poll.getVoteCountingType());
- results.add(dto);
- }
- return results;
- }
-
public String getResultValue(Choice choice,
Collection<PollResult> results) {
@@ -398,7 +373,33 @@
return val;
}
+
// /**
+// * 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
+// */
+// protected 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.isByGroup());
+// dto.setChoiceType(poll.getChoiceType());
+// dto.setVoteCountingType(poll.getVoteCountingType());
+// results.add(dto);
+// }
+// return results;
+// }
+
+// /**
// * Création des résultats de sondage à partir d'un dto de résultats de
// * sondage.
// *
@@ -424,32 +425,32 @@
// }
// }
- /**
- * 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
- */
- protected boolean hasResults(Poll poll, VoteCountingType type) {
- boolean hasresult = false;
+// /**
+// * 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
+// */
+// protected 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;
+// }
- 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 importPoll(String filePath) {
// return importPoll(filePath, null);
// }
@@ -483,15 +484,14 @@
/**
* Retourne une chaîne contenant les résultats du sondage.
*
- * @param poll le sondage
- * @param results les résultats du sondage
+ * @param poll le sondage
* @return les résultats sous forme de chaine de caractères
*/
- public String getResultsAsString(Poll poll, Collection<Result> results) {
+ public String getResultsAsString(Poll poll) {
- DateFormat dateFormat = new SimpleDateFormat();
+ DateFormat dateFormat = new SimpleDateFormat(getDateTimePattern());
StringBuilder res = new StringBuilder("");
- Iterator<Result> it = results.iterator();
+ Iterator<Result> it = poll.getResult().iterator();
while (it.hasNext()) {
Result result = it.next();
if (poll.getChoiceType() == ChoiceType.DATE) {
@@ -507,4 +507,16 @@
}
return res.toString();
}
+
+ protected VoteCountingResultDTO getResultDTO(Poll poll) {
+
+ PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
+
+ dto.setVoteCounting(poll.getVoteCountingType());
+
+ VoteCountingService service = new VoteCountingService();
+
+ VoteCountingResultDTO result = service.execute(dto);
+ return result;
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -50,7 +50,6 @@
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.business.persistence.PreventRuleDAO;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
@@ -74,7 +73,6 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -371,10 +369,12 @@
commitTransaction("Could not create poll " + poll.getTitle());
- PollUrl pollVoteUrl = getPollVoteUrl(poll, false);
- PollUrl pollModerateUrl = getPollVoteUrl(poll, true);
- PollUrl pollEditUrl = getPollEditUrl(poll);
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+ PollUrl pollModerateUrl = pollUrlService.getPollVoteUrl(poll, true);
+ PollUrl pollEditUrl = pollUrlService.getPollEditUrl(poll);
+
// email notification
EmailService emailService = newService(EmailService.class);
emailService.onPollCreated(result, pollVoteUrl, pollModerateUrl, pollEditUrl);
@@ -448,45 +448,59 @@
commitTransaction("Could not update poll [" + poll.getTopiaId() + "]");
}
- public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/votefor/";
- PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+// public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/votefor/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// if (moderate) {
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+// }
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- if (moderate) {
- String creatorId = poll.getCreator().getAccountId();
- pollUri.setAccountId(creatorId);
- }
+// public PollUrl getPollUpdateVoteUrl(Poll poll) {
+// Preconditions.checkNotNull(poll);
+//
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/votefor/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
+// public PollUrl getPollEditUrl(Poll poll) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/modification/";
+//
+// String creatorId = poll.getCreator().getAccountId();
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- public PollUrl getPollEditUrl(Poll poll) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/modification/";
+// public PollUrl getPollResultUrl(Poll poll) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/results/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// if (!poll.isPublicResults()) {
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+// }
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- String creatorId = poll.getCreator().getAccountId();
- PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
-
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
-
- public PollUrl getPollResultUrl(Poll poll) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/results/";
- PollUri pollUri = PollUri.newPollUri(poll.getPollId());
-
- if (!poll.isPublicResults()) {
- String creatorId = poll.getCreator().getAccountId();
- pollUri.setAccountId(creatorId);
- }
-
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
-
public List<Poll> getPolls(TopiaFilterPagerUtil.FilterPagerBean pager) {
Preconditions.checkNotNull(pager);
@@ -581,6 +595,22 @@
}
}
+ public Poll getExistingPollByPollId(String pollId) throws PollNotFoundException {
+
+ Preconditions.checkNotNull(pollId);
+ try {
+ PollDAO dao = getDAO(Poll.class);
+ Poll result = dao.findByPollId(pollId);
+
+ if (result == null) {
+ throw new PollNotFoundException();
+ }
+ return result;
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not find poll with pollId '" + pollId + "'", e);
+ }
+ }
+
/**
* Retrieve a pollAccount with {@code accountId}. This pollAccount will be
* attached to the given {@code userAccount} (only if not already attached).
@@ -691,12 +721,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(accountId);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (userAccount == null || userAccount.isAdministrator()) {
// must check that accountId matches the poll creator id
@@ -721,12 +747,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(accountId);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (userAccount == null || userAccount.isAdministrator()) {
// must check that accountId matches the poll creator id
@@ -777,12 +799,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choice);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
saveChoice(poll, choice);
commitTransaction("Can't create new choice [" +
@@ -839,11 +857,8 @@
public void deleteChoice(String pollId, String choiceId)
throws PollNotFoundException, PollChoiceNotFoundException {
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
Choice choice = poll.getChoiceByTopiaId(choiceId);
if (choice == null) {
@@ -862,23 +877,15 @@
String pollId = uri.getPollId();
- Poll poll = getPollByPollId(pollId);
-
- if (poll == null) {
- throw new PollNotFoundException();
- }
+ getExistingPollByPollId(pollId);
}
public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
String pollId = uri.getPollId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (!poll.isPublicResults()) {
throw new UnauthorizedPollAccessException();
}
@@ -889,12 +896,8 @@
String pollId = uri.getPollId();
String accountId = uri.getAccountId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
PollAccountDAO dao = getDAO(PollAccount.class);
if (poll.getPollType() != PollType.FREE) {
@@ -936,12 +939,8 @@
String pollId = uri.getPollId();
String accountId = uri.getAccountId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
String creatorId = poll.getCreator().getAccountId();
if (!creatorId.equals(accountId)) {
@@ -987,32 +986,32 @@
createThumbnail(pollChoiceImage, pollChoiceImageThumb, 100);
}
- public void addVoteToPoll(Poll poll, Vote vote) {
+// public void addVoteToPoll(Poll poll, Vote vote) {
+//
+// String pollId = poll.getTopiaId();
+// String voteId = vote.getTopiaId();
+//
+// Poll pollToUpdate = getEntityById(Poll.class, pollId);
+// Vote voteToAdd = getEntityById(Vote.class, voteId);
+//
+// pollToUpdate.addVote(voteToAdd);
+//
+// // Update hasVoted flag for RESTRICTED/GROUP poll
+// if (PollType.FREE != poll.getPollType()) {
+//
+// PersonToList personToList = pollToUpdate.getPersonToListByVote(voteToAdd);
+// personToList.setHasVoted(true);
+// }
+//
+// commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
+//
+// // Send notification if necessary
+// PreventRuleService preventRuleService = newService(PreventRuleService.class);
+// PollUrl pollVoteUrl = getPollVoteUrl(pollToUpdate, false);
+// PollUrl modifUrl = getPollEditUrl(pollToUpdate);
+// preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
+// }
- String pollId = poll.getTopiaId();
- String voteId = vote.getTopiaId();
-
- Poll pollToUpdate = getEntityById(Poll.class, pollId);
- Vote voteToAdd = getEntityById(Vote.class, voteId);
-
- pollToUpdate.addVote(voteToAdd);
-
- // Update hasVoted flag for RESTRICTED/GROUP poll
- if (PollType.FREE != poll.getPollType()) {
-
- PersonToList personToList = pollToUpdate.getPersonToListByVote(voteToAdd);
- personToList.setHasVoted(true);
- }
-
- commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
-
- // Send notification if necessary
- PreventRuleService preventRuleService = newService(PreventRuleService.class);
- PollUrl pollVoteUrl = getPollVoteUrl(pollToUpdate, false);
- PollUrl modifUrl = getPollEditUrl(pollToUpdate);
- preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
- }
-
public PersonToList getNewPersonToList(PollAccount pollAccount) {
PersonToList result = newInstance(getDAO(PersonToList.class));
result.setWeight(1);
@@ -1051,8 +1050,10 @@
result.setName(votingList.getName());
result.setWeight(votingList.getWeight());
- PollUrl voteURL = getPollVoteUrl(poll, false);
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+ PollUrl voteURL = pollUrlService.getPollVoteUrl(poll, false);
+
// Merge PersonToList
List<PersonToList> personToListsUpdated = Lists.newArrayList();
for (PersonToList personToList : votingList.getPollAccountPersonToList()) {
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -0,0 +1,66 @@
+package org.chorem.pollen.services.impl;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.services.PollenServiceSupport;
+
+import java.net.URL;
+
+/**
+ * Service to deal with url used by application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class PollUrlService extends PollenServiceSupport {
+
+ public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/votefor/";
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+
+ if (moderate) {
+ String creatorId = poll.getCreator().getAccountId();
+ pollUri.setAccountId(creatorId);
+ }
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+
+ public PollUrl getPollEditUrl(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/modification/";
+
+ String creatorId = poll.getCreator().getAccountId();
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+
+ public PollUrl getPollResultUrl(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/results/";
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+
+ if (!poll.isPublicResults()) {
+ String creatorId = poll.getCreator().getAccountId();
+ pollUri.setAccountId(creatorId);
+ }
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -183,6 +183,8 @@
}
copyUserAccount(user, userToUpdate);
+
+ commitTransaction("Could not update user");
return userToUpdate;
} catch (TopiaException e) {
@@ -250,6 +252,8 @@
throw new UserNotFoundException();
}
dao.delete(user);
+
+ commitTransaction("Could not delete user "+id);
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.PersonToListDAO;
@@ -51,7 +51,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
-import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -140,21 +139,21 @@
return result;
}
- /**
- * Retrieve the URL to update a vote based on {@link PollUri}.
- *
- * @param pollUri Uri with pollId and accountId
- * @return the URL that allow the voting person to update his vote
- */
- public String getUpdateVoteUrl(PollUri pollUri) {
- Preconditions.checkNotNull(pollUri.getAccountId());
- URL baseUrl = serviceContext.getApplicationURL();
- String result =
- String.format("%s/poll/votefor/%s", baseUrl, pollUri.getUri());
- return result;
- }
+// /**
+// * Retrieve the URL to update a vote based on {@link PollUri}.
+// *
+// * @param pollUri Uri with pollId and accountId
+// * @return the URL that allow the voting person to update his vote
+// */
+// public String getUpdateVoteUrl(PollUri pollUri) {
+// Preconditions.checkNotNull(pollUri.getAccountId());
+// URL baseUrl = serviceContext.getApplicationURL();
+// String result =
+// String.format("%s/poll/votefor/%s", baseUrl, pollUri.getUri());
+// return result;
+// }
- public Vote createVote(Vote vote) throws PollAccountNotFound {
+ public Vote createVote(Poll poll, Vote vote) throws PollAccountNotFound {
VoteDAO voteDAO = getDAO(Vote.class);
@@ -206,12 +205,41 @@
log.debug("Entity created: " + result.getTopiaId());
}
+ Poll pollToUpdate = getEntityById(Poll.class, poll.getTopiaId());
+
+ pollToUpdate.addVote(result);
+
+ // Update hasVoted flag for RESTRICTED/GROUP poll
+ if (PollType.FREE != poll.getPollType()) {
+
+ PersonToList personToList = pollToUpdate.getPersonToListByVote(result);
+ personToList.setHasVoted(true);
+ }
+
+ // regnenerate poll results
+
+ generatePollResult(pollToUpdate);
+
commitTransaction("Could not create vote");
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ // Send notification if necessary
+ PreventRuleService preventRuleService = newService(PreventRuleService.class);
+ PollUrl modifUrl = pollUrlService.getPollEditUrl(poll);
+ preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
+
+ // feed notification
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onAddVote(pollToUpdate, result);
+
return result;
}
- public Vote updateVote(Vote vote) throws VoteNotFoundException {
+ public Vote updateVote(Poll poll, Vote vote) throws VoteNotFoundException {
Vote result = getEntityById(Vote.class, vote.getTopiaId());
@@ -234,6 +262,8 @@
}
result.setAnonymous(vote.isAnonymous());
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+
// -- List of VoteToChoice -- //
for (VoteToChoice input : vote.getChoiceVoteToChoice()) {
@@ -250,7 +280,8 @@
}
} else if (voteToChoiceEntity != null) {
- deleteVoteToChoice(result, voteToChoiceEntity);
+ result.removeChoiceVoteToChoice(voteToChoiceEntity);
+ delete(voteToChoiceDao, voteToChoiceEntity);
}
}
@@ -258,35 +289,17 @@
log.debug("Entity updated: " + result.getTopiaId());
}
+ generatePollResult(poll);
+
commitTransaction("Could not update vote");
- return result;
- }
+ // feed notification
- protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
-
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
- VoteToChoice result = create(voteToChoiceDao);
-
- String choiceId = source.getChoice().getTopiaId();
- Choice choiceLoaded = getEntityById(Choice.class, choiceId);
- result.setChoice(choiceLoaded);
-
- result.setVote(vote);
- result.setVoteValue(source.getVoteValue());
-
- vote.addChoiceVoteToChoice(result);
-
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onUpdateVote(poll, result);
return result;
}
- protected void deleteVoteToChoice(Vote vote, VoteToChoice entity) {
-
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
- vote.removeChoiceVoteToChoice(entity);
- delete(voteToChoiceDao, entity);
- }
-
/**
* Delete vote referenced by {@code voteId}. This will also delete all
* associated {@link VoteToChoice}. The {@link PollAccount} could also be
@@ -295,10 +308,16 @@
* is activated.
*
* @param voteId TopiaId of the vote
+ * @param reason reason to delete this vote
* @throws VoteNotFoundException if vote doesn't exist
*/
- public void deleteVote(String voteId) throws VoteNotFoundException {
+ public void deleteVote(Poll poll,
+ String voteId,
+ String reason) throws VoteNotFoundException {
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(voteId);
+
Vote entityToDelete = getEntityById(Vote.class, voteId);
if (entityToDelete == null) {
@@ -315,12 +334,12 @@
delete(voteToChoiceDao, voteToChoice);
}
- Poll poll = entityToDelete.getPoll();
+// Poll poll = entityToDelete.getPoll();
+ PollAccount voteAccount = entityToDelete.getPollAccount();
if (PollType.FREE == poll.getPollType()) {
// Delete vote PollAccount if the Poll is free and account is not the creator
- PollAccount voteAccount = entityToDelete.getPollAccount();
if (!voteAccount.equals(poll.getCreator())) {
PollAccountDAO accountDAO = getDAO(PollAccount.class);
delete(accountDAO, voteAccount);
@@ -335,13 +354,18 @@
poll.removeVote(entityToDelete);
delete(dao, entityToDelete);
- // TODO calculate results if continuous
-
if (log.isDebugEnabled()) {
log.debug("Entity deleted: " + voteId);
}
+ generatePollResult(poll);
+
commitTransaction("Could not delete vote");
+
+ // feed notification
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onDeleteVote(poll, entityToDelete, voteAccount, reason);
}
public List<Vote> getVotesByPoll(Poll poll,
@@ -423,10 +447,10 @@
return result;
}
- public boolean hasAlreadyVoted(String votingId, Poll poll) {
+ public boolean hasAlreadyVoted(Poll poll, String votingId) {
try {
VoteDAO dao = getDAO(Vote.class);
- boolean result = dao.hasAlreadyVoted(votingId, poll);
+ boolean result = dao.hasAlreadyVoted(poll, votingId);
return result;
} catch (Exception e) {
throw new PollenTechnicalException(
@@ -464,4 +488,26 @@
}
}
+ protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
+
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ VoteToChoice result = create(voteToChoiceDao);
+
+ String choiceId = source.getChoice().getTopiaId();
+ Choice choiceLoaded = getEntityById(Choice.class, choiceId);
+ result.setChoice(choiceLoaded);
+
+ result.setVote(vote);
+ result.setVoteValue(source.getVoteValue());
+
+ vote.addChoiceVoteToChoice(result);
+
+ return result;
+ }
+
+ protected void generatePollResult(Poll poll) {
+ PollResultsService pollResultsService = newService(PollResultsService.class);
+ pollResultsService.generateResult(poll);
+ }
+
} //voteservice
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -2,7 +2,7 @@
pollen.common.addingChoicesContent=From %s to %s
pollen.common.addingChoicesFrom=From %s
pollen.common.addingChoicesTo=Until %s
-pollen.common.anonymous=Anonymous vote
+pollen.common.anonymous=Anonymous voter
pollen.common.datePattern=MM/dd/yyyy
pollen.common.dateTimePattern=MM/dd/yyyy HH\:mm
pollen.common.numberVote-average=Average of numbers
@@ -31,12 +31,16 @@
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
pollen.feed.addCommentTitle=New comment of %s
-pollen.feed.addVoteContent=
-pollen.feed.addVoteTitle=
+pollen.feed.addVoteContent=Poll result\: %s
+pollen.feed.addVoteTitle=New vote from '%s'
pollen.feed.createPollContent=
pollen.feed.deleteCommentContent=%s
-pollen.feed.deleteCommentTitle=Delete comment of %s for reason '%s'
+pollen.feed.deleteCommentTitle=Delete comment of '%s' for reason '%s'
+pollen.feed.deleteVoteContent=Poll result\: %s
+pollen.feed.deleteVoteTitle=Delete vote of '%s' for reason '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
+pollen.feed.updateVoteContent=Poll result\: %s
+pollen.feed.updateVoteTitle=Vote modified for '%s'
pollen.info.admin.created=Super admin was created with login %1$s
pollen.info.admin.exists=Super admin already exists
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -2,7 +2,7 @@
pollen.common.addingChoicesContent=Du %s au %s
pollen.common.addingChoicesFrom=Depuis le %s
pollen.common.addingChoicesTo=Jusqu'au %s
-pollen.common.anonymous=Vote anonyme
+pollen.common.anonymous=votant anonyme
pollen.common.datePattern=dd/MM/yyyy
pollen.common.dateTimePattern=dd/MM/yyyy HH\:mm
pollen.common.numberVote-average=Moyenne des nombres
@@ -31,12 +31,16 @@
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
pollen.feed.addCommentTitle=Nouveau commentaire de %s
-pollen.feed.addVoteContent=
-pollen.feed.addVoteTitle=
+pollen.feed.addVoteContent=Résultat du sondage \: %s
+pollen.feed.addVoteTitle=Nouveau vote de '%s'
pollen.feed.createPollContent=
pollen.feed.deleteCommentContent=%s
-pollen.feed.deleteCommentTitle=Suppression du commentaire de %s pour la raison '%s'
+pollen.feed.deleteCommentTitle=Suppression du commentaire de '%s' pour la raison '%s'
+pollen.feed.deleteVoteContent=Résultat du sondage \: %s
+pollen.feed.deleteVoteTitle=Suppression du vote de '%s' pour la raison '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
+pollen.feed.updateVoteContent=Résultat du sondage \: %s
+pollen.feed.updateVoteTitle=Vote modifié de '%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: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -35,6 +35,15 @@
import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.PollenServiceFactory;
+import org.chorem.pollen.services.impl.FavoriteService;
+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.PollUrlService;
+import org.chorem.pollen.services.impl.PreventRuleService;
+import org.chorem.pollen.services.impl.UserService;
+import org.chorem.pollen.services.impl.VoteService;
import org.chorem.pollen.ui.PollenApplicationContext;
import org.chorem.pollen.ui.PollenSession;
import org.nuiton.topia.TopiaContext;
@@ -88,6 +97,24 @@
protected transient TopiaContext transaction;
+ private transient PollService pollService;
+
+ private transient PollUrlService pollUrlService;
+
+ private transient PollResultsService pollResultsService;
+
+ private transient VoteService voteService;
+
+ private transient PollCommentService pollCommentService;
+
+ private transient PollFeedService pollFeedService;
+
+ private transient UserService userService;
+
+ private transient FavoriteService favoriteService;
+
+ private transient PreventRuleService preventRuleService;
+
public PageSkin getSkin() {
return PageSkin.INDEX;
}
@@ -246,31 +273,16 @@
public Collection<String> getFlashMessages() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
-// }
return result;
}
public Collection<String> getFlashErrors() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// }
return result;
}
public Collection<String> getFlashWarnings() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_WARNINGS);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// }
return result;
}
@@ -307,4 +319,67 @@
boolean result = super.hasErrors();
return result || hasFlashErrors();
}
+
+ protected final PollService getPollService() {
+ if (pollService == null) {
+ pollService = newService(PollService.class);
+ }
+ return pollService;
+ }
+
+ protected final PollUrlService getPollUrlService() {
+ if (pollUrlService == null) {
+ pollUrlService = newService(PollUrlService.class);
+ }
+ return pollUrlService;
+ }
+
+ protected final PollResultsService getPollResultsService() {
+ if (pollResultsService == null) {
+ pollResultsService = newService(PollResultsService.class);
+ }
+ return pollResultsService;
+ }
+
+ protected final VoteService getVoteService() {
+ if (voteService == null) {
+ voteService = newService(VoteService.class);
+ }
+ return voteService;
+ }
+
+ protected final PollCommentService getPollCommentService() {
+ if (pollCommentService == null) {
+ pollCommentService = newService(PollCommentService.class);
+ }
+ return pollCommentService;
+ }
+
+ protected final PollFeedService getPollFeedService() {
+ if (pollFeedService == null) {
+ pollFeedService = newService(PollFeedService.class);
+ }
+ return pollFeedService;
+ }
+
+ protected final UserService getUserService() {
+ if (userService == null) {
+ userService = newService(UserService.class);
+ }
+ return userService;
+ }
+
+ protected final FavoriteService getFavoriteService() {
+ if (favoriteService == null) {
+ favoriteService = newService(FavoriteService.class);
+ }
+ return favoriteService;
+ }
+
+ protected final PreventRuleService getPreventRuleService() {
+ if (preventRuleService == null) {
+ preventRuleService = newService(PreventRuleService.class);
+ }
+ return preventRuleService;
+ }
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,8 +26,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.services.impl.PollService;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -80,17 +78,13 @@
if (StringUtils.isNotEmpty(userId)) {
// load user
- UserService service = newService(UserService.class);
-
- user = service.getEntityById(UserAccount.class, userId);
+ user = getUserService().getEntityById(UserAccount.class, userId);
}
if (StringUtils.isNotEmpty(pollId)) {
// load poll
- PollService servcie = newService(PollService.class);
-
- poll = servcie.getPollByPollId(pollId);
+ poll = getPollService().getExistingPollByPollId(pollId);
}
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -59,7 +59,7 @@
Preconditions.checkNotNull(userId);
- UserService service = newService(UserService.class);
+ UserService service = getUserService();
String result = INPUT;
@@ -68,7 +68,6 @@
service.getEntityById(UserAccount.class, userId);
service.deleteUser(userId);
- getTransaction().commitTransaction();
addFlashMessage(
_("pollen.information.user.deleted", user.getDisplayName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,7 +28,6 @@
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -45,8 +44,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -77,7 +75,7 @@
String result = INPUT;
try {
- newService(UserService.class).createUser(user, true);
+ getUserService().createUser(user, true);
addFlashMessage(
_("pollen.information.user.created",
@@ -102,13 +100,10 @@
Preconditions.checkNotNull(user);
- UserService service = newService(UserService.class);
-
String result = INPUT;
try {
- service.updateUser(user, null, true);
- getTransaction().commitTransaction();
+ getUserService().updateUser(user, null, true);
addFlashMessage(
_("pollen.information.user.updated",
user.getDisplayName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -78,10 +78,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ File file = getPollService().getPollChoiceImageFile(pollId, choiceId, thumb);
- File file = service.getPollChoiceImageFile(pollId, choiceId, thumb);
-
MimetypesFileTypeMap mimes = new MimetypesFileTypeMap();
contentType = mimes.getContentType(file);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -73,7 +73,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Poll> pollList = pollService.getCreatedPolls(pager,
getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.collect.Maps;
import org.chorem.pollen.business.persistence.PersonList;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.util.Map;
@@ -59,10 +58,8 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
PersonList personList =
- service.getEntityById(PersonList.class, favoriteListId);
+ getFavoriteService().getEntityById(PersonList.class, favoriteListId);
favoriteList = Maps.newHashMap();
favoriteList.put("id", personList.getTopiaId());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
@@ -60,10 +59,8 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
-
PollAccount userAccount =
- userService.getEntityById(PollAccount.class, pollAccountId);
+ getUserService().getEntityById(PollAccount.class, pollAccountId);
Binder<PollAccount, PollAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -81,7 +81,7 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList =
service.getEntityById(PersonList.class, favoriteListId);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.collect.Maps;
import org.chorem.pollen.business.persistence.PersonList;
-import org.chorem.pollen.services.impl.FavoriteService;
import java.util.List;
import java.util.Map;
@@ -69,9 +68,7 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
- List<PersonList> allFavoriteLists = service.getFavoriteLists(
+ List<PersonList> allFavoriteLists = getFavoriteService().getFavoriteLists(
getPollenUserAccount(),
pager);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -75,7 +75,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Pair<Poll, PollAccount>> invitedPolls = pollService.getInvitedPolls(pager,
getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -76,7 +76,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Pair<Poll, PollAccount>> participatedPolls =
pollService.getParticipatedPolls(pager, getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,7 +28,6 @@
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.PollCommentService;
import org.nuiton.util.beans.Binder;
import java.util.List;
@@ -82,10 +81,9 @@
Preconditions.checkNotNull(pollId);
- PollCommentService pollService = newService(PollCommentService.class);
+ List<Comment> commentList = getPollCommentService().getComments(
+ pager, pollId);
- List<Comment> commentList = pollService.getComments(pager, pollId);
-
UserAccount userAccount = getPollenUserAccount();
comments = new Map[commentList.size()];
@@ -101,22 +99,21 @@
Comment.PROPERTY_AUTHOR
);
map.put("id", comment.getTopiaId());
- Set<String> functions = getCommentFunctions(pollService,
- comment,
- userAccount);
+ Set<String> functions = getCommentFunctions(
+ comment,
+ userAccount);
map.put("functions", functions);
comments[index++] = map;
}
return SUCCESS;
}
- private Set<String> getCommentFunctions(PollCommentService pollService,
- Comment comment,
+ private Set<String> getCommentFunctions(Comment comment,
UserAccount userAccount) {
Set<String> result = Sets.newHashSet();
- boolean canDelete = pollService.isCanDeleteComment(comment,
- null,
- userAccount);
+ //TODO-tchemit-2012-06-03 Should use also pollAccountId (if specified in url)...
+ boolean canDelete = getPollCommentService().isCanDeleteComment(
+ comment, null, userAccount, false);
if (canDelete) {
result.add("delete");
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -72,7 +72,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Poll> pollList = pollService.getPolls(pager);
@@ -84,15 +84,6 @@
Map<String, Object> map = pollService.pollToMap(poll, binder);
-// Map<String, Object> map = binder.obtainProperties(
-// poll,
-// Poll.PROPERTY_TITLE,
-// Poll.PROPERTY_POLL_ID,
-// Poll.PROPERTY_DESCRIPTION,
-// Poll.PROPERTY_BEGIN_DATE,
-// Poll.PROPERTY_END_DATE
-// );
-// map.put("id", poll.getTopiaId());
map.put("moderateId", poll.getAdminId());
map.put("resultId", poll.getAdminId());
map.put("adminId", poll.getAdminId());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
@@ -60,10 +59,9 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
+ UserAccount userAccount = getUserService().getEntityById(
+ UserAccount.class, userId);
- UserAccount userAccount = userService.getEntityById(UserAccount.class, userId);
-
Binder<UserAccount, UserAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class);
user = binder.obtainProperties(
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.nuiton.util.beans.Binder;
import java.util.List;
@@ -72,10 +71,8 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
+ List<UserAccount> allUsers = getUserService().getUsers(pager);
- List<UserAccount> allUsers = userService.getUsers(pager);
-
UserAccount userAccount = getPollenUserAccount();
users = new Map[allUsers.size()];
Binder<UserAccount, UserAccount> binder =
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,7 +39,6 @@
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.PollenServiceFunctions;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -88,8 +87,6 @@
private int reminderHourCountdown = 2;
- private transient PollService pollService;
-
/** To create a new personToList. */
private transient Function<PersonToList, PersonToList> persontoListCreator;
@@ -110,13 +107,6 @@
return PageSkin.EDITION;
}
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
public Poll getPoll() {
return poll;
}
@@ -204,15 +194,15 @@
}
public String getPollVoteUrl() {
- return getPollService().getPollVoteUrl(poll, false).getUrl();
+ return getPollUrlService().getPollVoteUrl(poll, false).getUrl();
}
public String getPollModerateUrl() {
- return getPollService().getPollVoteUrl(poll, true).getUrl();
+ return getPollUrlService().getPollVoteUrl(poll, true).getUrl();
}
public String getPollEditUrl() {
- return getPollService().getPollEditUrl(poll).getUrl();
+ return getPollUrlService().getPollEditUrl(poll).getUrl();
}
public int getSelectedTab() {
@@ -234,18 +224,6 @@
return isEdit() && poll.sizeVote() > 0;
}
-// public boolean isPersonEditable(PersonToList personToList) {
-// boolean result;
-// // If vote is started, the person is editable if he hasn't vote yet
-// if (isVoteStarted()) {
-// result = !personToList.isHasVoted();
-//
-// } else {
-// result = true;
-// }
-// return result;
-// }
-
public boolean isCreatorUserAccountDefined() {
PollAccount creator = poll.getCreator();
return creator.getUserAccount() != null;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -59,8 +59,8 @@
}
public final void setUriId(PollUri pollUri) {
- if (log.isInfoEnabled()) {
- log.info("PollUri : " + pollUri.getUri());
+ if (log.isDebugEnabled()) {
+ log.debug("PollUri : " + pollUri.getUri());
}
this.pollUri = pollUri;
}
@@ -70,8 +70,8 @@
}
public final void setPage(int page) {
- if (log.isInfoEnabled()) {
- log.info("Page number : " + page);
+ if (log.isDebugEnabled()) {
+ log.debug("Page number : " + page);
}
this.page = page;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -42,11 +42,6 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
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 org.chorem.pollen.ui.actions.PageSkin;
import java.util.Date;
@@ -67,14 +62,6 @@
/** Logger. */
private static final Log log = LogFactory.getLog(AbstractVoteAction.class);
- private transient PollResultsService pollResultsService;
-
- private transient PollService pollService;
-
- private transient VoteService voteService;
-
- private transient PollCommentService pollCommentService;
-
private Poll poll;
private boolean feedFileExisting;
@@ -106,34 +93,6 @@
return PageSkin.VOTE;
}
- protected PollResultsService getPollResultsService() {
- if (pollResultsService == null) {
- pollResultsService = newService(PollResultsService.class);
- }
- return pollResultsService;
- }
-
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
- protected VoteService getVoteService() {
- if (voteService == null) {
- voteService = newService(VoteService.class);
- }
- return voteService;
- }
-
- protected PollCommentService getPollCommentService() {
- if (pollCommentService == null) {
- pollCommentService = newService(PollCommentService.class);
- }
- return pollCommentService;
- }
-
@Override
public void setParameters(Map<String, String[]> parameters) {
this.parameters = parameters;
@@ -298,8 +257,7 @@
loadPollResults();
loadPollComments();
- PollFeedService pollFeedService = newService(PollFeedService.class);
- feedFileExisting = pollFeedService.isFeedExists(poll);
+ feedFileExisting = getPollFeedService().isFeedExists(poll);
PollAccount pollCreator = poll.getCreator();
if (getPollenUserAccount() == null) {
@@ -372,7 +330,11 @@
}
public boolean isModifAllowed(Vote vote) {
- return getVoteService().isUpdateAllowed(getPoll(), vote.getTopiaId(), getAccountId(), getPollenUserAccount());
+ return getVoteService().isUpdateAllowed(
+ getPoll(),
+ vote.getTopiaId(),
+ getAccountId(),
+ getPollenUserAccount());
}
public boolean isVoteAllowed() {
@@ -380,11 +342,16 @@
}
public boolean isDeleteCommentAllowed(Comment comment) {
- return getPollCommentService().isCanDeleteComment(comment, getPollAccount(), getPollenUserAccount());
+ return getPollCommentService().isCanDeleteComment(
+ comment,
+ getPollAccount(),
+ getPollenUserAccount(),
+ isCreatorUser());
}
public boolean isDeleteVoteAllowed(Vote vote) {
- return isUserAdmin();
+ // can delete a vote if admin or poll creator
+ return isUserAdmin() || isCreatorUser();
}
public String escapeLineBreak(String text) {
@@ -398,7 +365,8 @@
protected void loadPollAccount() throws PollAccountNotFound {
// Current poll account
- pollAccount = getPollService().getPollAccountEditable(getAccountId(), getPollenUserAccount(), poll);
+ pollAccount = getPollService().getPollAccountEditable(
+ getAccountId(), getPollenUserAccount(), poll);
}
protected void loadPoll() throws PollNotFoundException {
@@ -408,9 +376,10 @@
String pollId = getPollId();
if (StringUtils.isNotEmpty(pollId)) {
- poll = getPollService().getPollByPollId(pollId);
+ poll = getPollService().getExistingPollByPollId(pollId);
}
- Preconditions.checkNotNull(poll, "Can't load poll with id = [" + pollId + "]");
+ Preconditions.checkNotNull(poll,
+ "Can't load poll with id = [" + pollId + "]");
if (log.isDebugEnabled()) {
log.debug("Poll TopiaId: " + poll.getTopiaId());
@@ -419,17 +388,14 @@
protected void loadPollComments() {
- PollCommentService service = newService(PollCommentService.class);
-
- comments = service.getAllComments(poll.getPollId());
+ comments = getPollCommentService().getAllComments(poll.getPollId());
}
protected void loadPollResults() throws PollNotFoundException {
- PollResultsService service = getPollResultsService();
+ PollResultList pollResultList =
+ getPollResultsService().getResults(poll);
- PollResultList pollResultList = service.getResults(poll.getPollId());
-
results = pollResultList.getPollResults();
if (log.isDebugEnabled()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -101,14 +101,16 @@
Object value = ChoiceHelper.toValue(choice, choiceType);
// -- Validate value notEmpty
- if (value == null || (value instanceof String && StringUtils.isBlank((String) value))) {
+ if (value == null ||
+ (value instanceof String && StringUtils.isBlank((String) value))) {
String typeLabel = getText(choiceType.getI18nKey());
addFieldError("choice." + propName,
_("pollen.error.choice.empty", typeLabel));
} else {
// Retrieve existing values to check if the new choice not already exists
- Iterable<Object> pollChoiceValues = ChoiceHelper.toValues(getPoll().getChoice(), choiceType);
+ Iterable<Object> pollChoiceValues = ChoiceHelper.toValues(
+ getPoll().getChoice(), choiceType);
// -- Validate value notExists
if (Iterables.contains(pollChoiceValues, value)) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -38,6 +38,11 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Text of the comment to add.
+ *
+ * @since 1.3
+ */
private String commentText;
public void setCommentText(String commentText) {
@@ -78,6 +83,7 @@
// create the comment
getPollCommentService().createComment(getPoll(), comment);
+ addFlashMessage(_("pollen.info.comment.added"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.services.impl.PollService;
-
/**
* Closes an existing poll.
*
@@ -48,10 +46,10 @@
@Override
public String execute() throws Exception {
- PollService service = newService(PollService.class);
+ getPollService().closePoll(getPollId(),
+ getPollenUserAccount(),
+ getAccountId());
- service.closePoll(getPollId(), getPollenUserAccount(), getAccountId());
-
addFlashMessage(_("pollen.information.poll.closed"));
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm delete of a poll choice.
@@ -57,10 +56,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
-
choice = poll.getChoiceByTopiaId(choiceId);
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,11 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Comment;
-import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.exceptions.PollCommentNotFound;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollCommentService;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a comment delete.
@@ -41,10 +36,18 @@
private static final long serialVersionUID = 1L;
- /** Id of the comment. */
+ /**
+ * Id of the comment.
+ *
+ * @since 1.3
+ */
protected String commentId;
- /** Comment to delete. */
+ /**
+ * Loaded comment to delete.
+ *
+ * @since 1.3
+ */
protected Comment comment;
public void setCommentId(String commentId) {
@@ -62,22 +65,10 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
- PollService pollService = newService(PollService.class);
+ getPollService().getExistingPollByPollId(pollId);
- Poll poll = pollService.getPollByPollId(getPollId());
+ comment = getPollCommentService().getExistingPollComment(commentId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
- PollCommentService service = newService(PollCommentService.class);
-
- comment = service.getEntityById(Comment.class, commentId);
-
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
return SUCCESS;
}
}
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm delete of a poll vote
@@ -38,8 +37,18 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Id of the vote to delete.
+ *
+ * @since 1.3
+ */
protected String voteId;
+ /**
+ * Loaded vote to delete.
+ *
+ * @since 1.3
+ */
protected Vote vote;
public void setVoteId(String voteId) {
@@ -57,10 +66,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
-
vote = poll.getVoteByTopiaId(voteId);
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a poll action (such as delete or close).
@@ -57,7 +56,8 @@
public String execute() throws Exception {
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- poll = newService(PollService.class).getPollByPollId(pollId);
+
+ poll = getPollService().getExistingPollByPollId(pollId);
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,6 @@
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
@@ -49,10 +48,9 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ getPollService().deleteChoice(pollId, choiceId);
- service.deleteChoice(pollId, choiceId);
-
+ addFlashMessage(_("pollen.info.choice.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,12 +25,7 @@
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
-import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.exceptions.PollCommentNotFound;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollCommentService;
-import org.chorem.pollen.services.impl.PollService;
/**
* To delete a poll comment.
@@ -42,7 +37,11 @@
private static final long serialVersionUID = 1L;
- /** Id of the comment to delete. */
+ /**
+ * Id of the comment to delete.
+ *
+ * @since 1.3
+ */
protected String commentId;
/**
@@ -64,26 +63,14 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
-
- Poll poll = pollService.getPollByPollId(getPollId());
-
- if (poll==null) {
- throw new PollNotFoundException();
- }
-
+ Preconditions.checkNotNull(getPollId());
Preconditions.checkNotNull(commentId);
- PollCommentService service = newService(PollCommentService.class);
+ Poll poll = getPollService().getExistingPollByPollId(getPollId());
- Comment comment = service.getEntityById(Comment.class, commentId);
+ getPollCommentService().deleteComment(poll, commentId, reason);
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
- service.deleteComment(poll, commentId, reason);
-
+ addFlashMessage(_("pollen.info.comment.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.services.impl.PollService;
-
/**
* Deletes an existing poll.
*
@@ -48,9 +46,10 @@
@Override
public String execute() throws Exception {
- PollService service = newService(PollService.class);
- service.deletePoll(getPollId(), getPollenUserAccount(), getAccountId());
+ getPollService().deletePoll(getPollId(),
+ getPollenUserAccount(),
+ getAccountId());
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,7 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.base.Preconditions;
-import org.chorem.pollen.services.impl.VoteService;
+import org.chorem.pollen.business.persistence.Poll;
/**
* To delete a poll vote.
@@ -36,21 +36,39 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Id of the vote to delete.
+ *
+ * @since 1.3
+ */
protected String voteId;
+ /**
+ * Reason for deleting this vote (if any).
+ *
+ * @since 1.4
+ */
+ protected String reason;
+
public void setVoteId(String voteId) {
this.voteId = voteId;
}
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
@Override
public String execute() throws Exception {
+ Preconditions.checkNotNull(getPollId());
Preconditions.checkNotNull(voteId);
- VoteService service = newService(VoteService.class);
+ Poll poll = getPollService().getExistingPollByPollId(getPollId());
- service.deleteVote(voteId);
+ getVoteService().deleteVote(poll, voteId, reason);
+ addFlashMessage(_("pollen.info.vote.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.persistence.PersonToList;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -103,24 +102,8 @@
public String execute() throws Exception {
if (personToList == null) {
- personToList = newService(PollService.class).getNewPersonToList(null);
+ personToList = getPollService().getNewPersonToList(null);
}
-
-// // consume personToList errors
-// String token = getPersonToListErrorTokenId(tokenId, personToListNumber);
-// Map<String, String> errors = getPollenSession().getDynamicData(token);
-// if (MapUtils.isNotEmpty(errors)) {
-// // transmit them as field errors
-// for (Map.Entry<String, String> e : errors.entrySet()) {
-// String fieldName = e.getKey();
-// String errorMessage = e.getValue();
-// if (log.isInfoEnabled()) {
-// log.info("Transmit error on " + fieldName + " [" + errorMessage + "]");
-// }
-// addFieldError(fieldName, errorMessage);
-// }
-// }
-// getPollenSession().removeDynamicData(token);
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.apache.commons.io.IOUtils;
-import org.chorem.pollen.services.impl.PollResultsService;
import java.io.InputStream;
@@ -63,10 +62,8 @@
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- PollResultsService service = newService(PollResultsService.class);
+ String exportContent = getPollResultsService().exportPolltoXml(pollId);
- String exportContent = service.exportPolltoXml(pollId);
-
filename = "exportPoll-" + pollId + ".xml";
contentLength = exportContent.length() * 2;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,9 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-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.io.File;
@@ -67,18 +64,10 @@
Preconditions.checkNotNull(pollId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
+ File feedLocation = getPollFeedService().getFeedLocation(poll);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
- PollFeedService pollFeedService = newService(PollFeedService.class);
-
- File feedLocation = pollFeedService.getFeedLocation(poll);
-
contentLength = feedLocation.length();
inputStream = new FileInputStream(feedLocation);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,7 +29,6 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.services.PollenServiceFunctions;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -91,9 +90,8 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
PersonList favoriteList =
- service.getFavoriteList(getPollenUserAccount(), personListId);
+ getFavoriteService().getFavoriteList(getPollenUserAccount(), personListId);
Function<PersonToList, PersonToList> persontoListCreator =
PollenServiceFunctions.newPersonToListCreator();
@@ -103,7 +101,7 @@
votingList = votingListCreator.apply(null);
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
for (PollAccount pollAccount : favoriteList.getPollAccount()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -44,7 +44,6 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollResultsService;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.converters.DateConverter;
import org.nuiton.util.StringUtil;
@@ -158,10 +157,8 @@
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- PollService service = newService(PollService.class);
+ poll = getPollService().getExistingPollByPollId(pollId);
- poll = service.getPollByPollId(pollId);
-
if (poll == null) {
addFlashError(_("pollen.error.pollNotFound"));
} else {
@@ -252,10 +249,9 @@
protected void loadResults() throws PollNotFoundException {
- PollResultsService service = newService(PollResultsService.class);
+ PollResultsService service = getPollResultsService();
- PollResultList resultListDTO =
- service.getResults(poll.getPollId());
+ PollResultList resultListDTO = service.getResults(poll);
results = resultListDTO.getPollResults();
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,8 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
/**
@@ -37,19 +37,10 @@
private static final long serialVersionUID = 1L;
- protected PollService pollService;
-
protected Poll poll;
protected String pollResultUrl;
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
@Override
public PageSkin getSkin() {
return PageSkin.EDITION;
@@ -67,10 +58,11 @@
public String execute() throws Exception {
String pollUid = getPollId();
+ Preconditions.checkNotNull(pollUid);
- poll = getPollService().getPollByPollId(pollUid);
+ poll = getPollService().getExistingPollByPollId(pollUid);
- pollResultUrl = getPollService().getPollResultUrl(poll).getUrl();
+ pollResultUrl = getPollUrlService().getPollResultUrl(poll).getUrl();
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -243,8 +243,7 @@
poll.clearPreventRule();
- PreventRuleService preventRuleService =
- newService(PreventRuleService.class);
+ PreventRuleService preventRuleService = getPreventRuleService();
if (isNotification()) {
// add a notification rule
@@ -752,7 +751,7 @@
// add personToList maps to session (but just now, since votingList
// could have been reindex)
for (Map.Entry<Integer, VotingList> entry : result.entrySet()) {
- Integer votingListNumber = entry.getKey();
+// Integer votingListNumber = entry.getKey();
VotingList votingList = entry.getValue();
if (!votingList.isPollAccountPersonToListEmpty()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,7 +27,6 @@
import org.chorem.pollen.PollenFunctions;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.util.List;
@@ -82,9 +81,9 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
UserAccount userAccount = getPollenUserAccount();
- List<PersonList> personLists = service.getFavoriteLists(userAccount);
+ List<PersonList> personLists =
+ getFavoriteService().getFavoriteLists(userAccount);
personList = Maps.uniqueIndex(personLists, PollenFunctions.ENTITY_BY_ID);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,12 +28,13 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.services.impl.VoteService;
/**
* Votes to a poll.
@@ -75,7 +76,7 @@
// check if the new pollAccount (topiaId = null) has already voted
if (pollAccount.getTopiaId() == null &&
- getVoteService().hasAlreadyVoted(name, poll)) {
+ getVoteService().hasAlreadyVoted(poll, name)) {
addFieldError("pollAccount.votingId",
_("pollen.error.user.alreadyVoted"));
}
@@ -131,25 +132,33 @@
// - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
// - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
- if (getVote().getTopiaId() != null) {
- getVoteService().updateVote(getVote());
+ Poll poll = getPoll();
+ Vote vote = getVote();
+
+ VoteService voteService = getVoteService();
+
+ if (vote.getTopiaId() == null) {
+
+ // create a new vote
+ voteService.createVote(poll, vote);
} else {
- Vote voteCreated = getVoteService().createVote(getVote());
- getPollService().addVoteToPoll(getPoll(), voteCreated);
+
+ // update existing vote
+ voteService.updateVote(poll, vote);
}
//TODO tchemit-2012-05-18 Why clean messages and just messages here ?
clearFlashMessages();
// For free Poll, display the update Url (useless if user is logged)
- if (PollType.FREE == getPoll().getPollType() && !isUserLoggued()) {
+ if (PollType.FREE == poll.getPollType() && !isUserLoggued()) {
- String pollId = getPoll().getPollId();
+ String pollId = poll.getPollId();
String accountId = getPollAccount().getAccountId();
- PollUri pollUri = PollUri.newPollUri(pollId, accountId);
+// PollUri pollUri = PollUri.newPollUri(pollId, accountId);
- String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
+ PollUrl updateUrl = getPollUrlService().getPollVoteUrl(poll, true);
if (log.isDebugEnabled()) {
log.debug(String.format(
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -76,20 +75,18 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
if (StringUtils.isNotEmpty(favoriteListId)) {
// load favorite list
- favoriteList = service.getEntityById(PersonList.class,
- favoriteListId);
+ favoriteList = getFavoriteService().getEntityById(PersonList.class,
+ favoriteListId);
}
if (StringUtils.isNotEmpty(pollAccountId)) {
// load poll account
- pollAccount = service.getEntityById(PollAccount.class,
- pollAccountId);
+ pollAccount = getFavoriteService().getEntityById(PollAccount.class,
+ pollAccountId);
}
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -62,7 +62,7 @@
String result = INPUT;
try {
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList = service.getEntityById(
PersonList.class, favoriteListId);
@@ -70,8 +70,6 @@
PersonList deletedFavoritedList = service.deleteFavoriteList(
getPollenUserAccount(), favoriteList);
- getTransaction().commitTransaction();
-
addFlashMessage(_("pollen.information.favoriteList.deleted",
deletedFavoritedList.getName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -65,7 +65,7 @@
Preconditions.checkNotNull(pollAccountId);
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList = service.getEntityById(PersonList.class,
favoriteListId);
@@ -75,8 +75,6 @@
service.removePollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
-
addFlashMessage(
_("pollen.information.pollAccount.removedFromFavoriteList",
pollAccount.getVotingId()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -53,8 +52,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -77,8 +75,8 @@
public String input() throws Exception {
UserAccount userAccount = getPollenUserAccount();
- UserService userService = newService(UserService.class);
- user = userService.getEntityById(UserAccount.class, userAccount.getTopiaId());
+ user = getUserService().getEntityById(UserAccount.class,
+ userAccount.getTopiaId());
return INPUT;
}
@@ -89,13 +87,10 @@
user.setAdministrator(
getPollenUserAccount().isAdministrator());
- UserService service = newService(UserService.class);
-
String result = INPUT;
try {
UserAccount updatedUser =
- service.updateUser(user, newPassword, false);
- getTransaction().commitTransaction();
+ getUserService().updateUser(user, newPassword, false);
// push back user to session
getPollenSession().setUserAccount(updatedUser);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,7 +27,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
import org.chorem.pollen.services.exceptions.UserNotFoundException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -75,14 +74,13 @@
@Override
public String execute() throws Exception {
- UserService service = newService(UserService.class);
-
if (StringUtils.isBlank(login) || StringUtils.isBlank(password)) {
addFlashError(_("pollen.error.user.bad.login.or.password"));
} else {
try {
- UserAccount userAccount = service.connect(login, password);
+ UserAccount userAccount =
+ getUserService().connect(login, password);
getPollenSession().setUserAccount(userAccount);
addFlashMessage(_("pollen.information.your.are.loggued"));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.services.exceptions.UserNotFoundException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.StringUtil;
@@ -57,9 +56,8 @@
} else {
- UserService service = newService(UserService.class);
try {
- service.lostPassword(email);
+ getUserService().lostPassword(email);
addFlashMessage(_("pollen.information.lostPassword.success"));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -99,10 +99,8 @@
action = actions[0];
}
- FavoriteService service = newService(FavoriteService.class);
-
try {
- favoriteList = service.getFavoriteList(
+ favoriteList = getFavoriteService().getFavoriteList(
getPollenUserAccount(), favoriteListId);
} catch (FavoriteListNotFoundException e) {
addFlashError(_("pollen.error.favoriteList.not.found"));
@@ -118,12 +116,10 @@
String result = INPUT;
- FavoriteService service = newService(FavoriteService.class);
-
try {
- service.addPollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
+ getFavoriteService().addPollAccountToFavoriteList(
+ favoriteList, pollAccount);
addFlashMessage(
_("pollen.information.pollAccount.addedTofavoriteList",
@@ -146,12 +142,10 @@
String result = INPUT;
- FavoriteService service = newService(FavoriteService.class);
-
try {
- service.editPollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
+ getFavoriteService().editPollAccountToFavoriteList(
+ favoriteList, pollAccount);
addFlashMessage(
_("pollen.information.pollAccount.updatedTofavoriteList",
@@ -173,11 +167,9 @@
Preconditions.checkNotNull(pollAccount);
Preconditions.checkNotNull(pollAccount.getTopiaId());
- FavoriteService service = newService(FavoriteService.class);
+ getFavoriteService().removePollAccountToFavoriteList(
+ favoriteList, pollAccount);
- service.removePollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
-
addFlashMessage(
_("pollen.information.pollAccount.removedFromFavoriteList",
pollAccount.getVotingId()));
@@ -190,8 +182,7 @@
protected PollAccount getPollAccount() {
if (pollAccount == null) {
- FavoriteService service = newService(FavoriteService.class);
- pollAccount = service.newPollAccountForFavoriteList();
+ pollAccount = getFavoriteService().newPollAccountForFavoriteList();
}
return pollAccount;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -34,7 +34,6 @@
import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException;
import org.chorem.pollen.services.impl.FavoriteListImportCSV;
import org.chorem.pollen.services.impl.FavoriteListImportLDAP;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -63,15 +62,6 @@
protected String action;
- private FavoriteService favoriteService;
-
- public FavoriteService getFavoriteService() {
- if (favoriteService == null) {
- favoriteService = newService(FavoriteService.class);
- }
- return favoriteService;
- }
-
public void setCsvImport(File csvImport) {
this.csvImport = csvImport;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -46,8 +45,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -70,8 +68,7 @@
String result = INPUT;
try {
- UserAccount createdUser =
- newService(UserService.class).createUser(user, false);
+ UserAccount createdUser = getUserService().createUser(user, false);
getPollenSession().setUserAccount(createdUser);
addFlashMessage(_("pollen.information.your.are.loggued"));
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
-pollen.common.deleteReason=Reason for delete
pollen.action.importPersonListToExistingVotingList=Add selected voting list
pollen.action.importPersonListToNewVotingList=Create a new group from the selected voting list
pollen.action.login=Log me In
@@ -70,6 +69,7 @@
pollen.common.datePattern=
pollen.common.datePickerPattern=mm/dd/yy
pollen.common.dateTimePattern=
+pollen.common.deleteReason=Reason for delete
pollen.common.description=Description
pollen.common.displayType-group=Results by groups
pollen.common.displayType-normal=Results
@@ -210,6 +210,10 @@
pollen.fieldset.userInformation.toDelete=User informations to delete
pollen.fieldset.userInformation.toUpdate=User informations to update
pollen.image.not.loaded=Image not loaded
+pollen.info.choice.deleted=Choice deleted
+pollen.info.comment.added=Comment added
+pollen.info.comment.deleted=Comment deleted
+pollen.info.vote.deleted=Vote deleted
pollen.information.confirmClonePoll=Confirm clone of poll\:
pollen.information.confirmClosePoll=Confirm close of poll\:
pollen.information.confirmDeleteFavoriteList=Confirm delete of favorite list\:
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,6 @@
pollen.action.editPoll=Modifier le sondage
pollen.action.editPollAccount=Editer le membre sélectionné
pollen.action.editUser=Editer un utilisateur sélectionné
-pollen.common.deleteReason=Raison de suppression
pollen.action.editVote=Modifier le vote
pollen.action.importPersonListToExistingVotingList=Ajouter la liste sélectionnée de votants
pollen.action.importPersonListToNewVotingList=Créer un groupe à partir de la liste sélectionnée
@@ -70,6 +69,7 @@
pollen.common.datePattern=
pollen.common.datePickerPattern=dd/mm/yy
pollen.common.dateTimePattern=
+pollen.common.deleteReason=Raison de suppression
pollen.common.description=Description
pollen.common.displayType-group=Résultats par groupes
pollen.common.displayType-normal=Résultats
@@ -210,6 +210,10 @@
pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer
pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour
pollen.image.not.loaded=Image non chargée
+pollen.info.choice.deleted=Choix supprimé
+pollen.info.comment.added=Commentaire ajouté
+pollen.info.comment.deleted=Commentaire supprimé
+pollen.info.vote.deleted=Vote supprimé
pollen.information.confirmClonePoll=Confirmer le clonage du sondage \:
pollen.information.confirmClosePoll=Confirmer la fermeture du sondage \:
pollen.information.confirmDeleteFavoriteList=Confirmer la suppression de la liste de votants \:
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-03 15:40:54 UTC (rev 3416)
@@ -35,6 +35,9 @@
</s:param>
</s:text>.
+ <s:textarea key='reason' rows="3" required="true"
+ label="%{getText('pollen.common.deleteReason')}"/>
+
<hr/>
<div align="right">
1
0
r3415 - trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 13:15:13 +0200 (Sun, 03 Jun 2012)
New Revision: 3415
Url: http://chorem.org/repositories/revision/pollen/3415
Log:
fix format code + usage of for-each
Modified:
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-06-03 09:40:52 UTC (rev 3414)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
@@ -23,12 +23,6 @@
*/
package org.chorem.pollen.votecounting.services;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.common.ChoiceType;
@@ -50,6 +44,11 @@
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Implémentation du service d'export.
*
@@ -57,7 +56,6 @@
* @author rannou
* @version $Id$
*/
-@SuppressWarnings("unchecked")
public class ServiceExportImpl implements ServiceExport {
private PollDTO poll;
@@ -71,9 +69,7 @@
/** log. */
private static final Log log = LogFactory.getLog(ServiceExportImpl.class);
- /**
- * Constructor
- */
+ /** Constructor */
public ServiceExportImpl() {
}
@@ -121,8 +117,7 @@
/**
* Construction du document XML à partir du sondage.
*
- * @param le chemin du fichier à créer
- * @return le fichier créé
+ * @param filePath le chemin du fichier à créer
*/
private void savePoll(String filePath) {
@@ -138,16 +133,16 @@
pollElm.setAttribute("voteCounting", poll.getVoteCounting().name());
pollElm.setAttribute("closed", poll.isClosed() ? "true" : "false");
pollElm.setAttribute("choiceAddAllowed",
- poll.isChoiceAddAllowed() ? "true" : "false");
+ poll.isChoiceAddAllowed() ? "true" : "false");
pollElm.setAttribute("anonymousVoteAllowed", poll
- .isAnonymousVoteAllowed() ? "true" : "false");
+ .isAnonymousVoteAllowed() ? "true" : "false");
pollElm
.setAttribute("anonymous", poll.isAnonymous() ? "true"
- : "false");
+ : "false");
pollElm.setAttribute("publicResults", poll.isPublicResults() ? "true"
- : "false");
+ : "false");
pollElm.setAttribute("continuousResults",
- poll.isContinuousResults() ? "true" : "false");
+ poll.isContinuousResults() ? "true" : "false");
Element titleElm = new Element("title");
titleElm.setText(poll.getTitle());
@@ -172,9 +167,8 @@
// Création des commentaires
Element commentsElm = new Element("comments");
- Iterator iteratorComment = poll.getComments().listIterator();
- while (iteratorComment.hasNext()) {
- Element commentElm = save((CommentDTO) iteratorComment.next());
+ for (CommentDTO commentDTO : poll.getComments()) {
+ Element commentElm = save(commentDTO);
commentsElm.addContent(commentElm);
}
@@ -183,9 +177,8 @@
// Création des groupes de votants
Element groupsElm = new Element("groups");
- Iterator iteratorGroup = poll.getVotingGroups().listIterator();
- while (iteratorGroup.hasNext()) {
- Element groupElm = save((VotingGroupDTO) iteratorGroup.next());
+ for (VotingGroupDTO votingGroupDTO : poll.getVotingGroups()) {
+ Element groupElm = save(votingGroupDTO);
groupsElm.addContent(groupElm);
}
@@ -194,9 +187,8 @@
// Création des choix
Element pollChoicesElm = new Element("pollChoices");
- Iterator itPollChoices = poll.getChoices().listIterator();
- while (itPollChoices.hasNext()) {
- Element pollChoiceElm = save((PollChoiceDTO) itPollChoices.next());
+ for (PollChoiceDTO pollChoiceDTO : poll.getChoices()) {
+ Element pollChoiceElm = save(pollChoiceDTO);
pollChoicesElm.addContent(pollChoiceElm);
}
pollElm.addContent(pollChoicesElm);
@@ -204,11 +196,8 @@
// Création des résultats
Element voteCountingResultsElm = new Element("voteCountingResults");
- Iterator iteratorvoteCountingResults = voteCountingResults
- .listIterator();
- while (iteratorvoteCountingResults.hasNext()) {
- Element voteCountingResult = save((VoteCountingResultDTO) iteratorvoteCountingResults
- .next());
+ for (VoteCountingResultDTO voteCountingResult1 : voteCountingResults) {
+ Element voteCountingResult = save(voteCountingResult1);
voteCountingResultsElm.addContent(voteCountingResult);
}
@@ -242,11 +231,8 @@
Element votingPersonsElm = new Element("votingPersons");
- Iterator iteratorVotingPersons = group.getVotingPersons()
- .listIterator();
- while (iteratorVotingPersons.hasNext()) {
- Element votingPersonElm = save((VotingPersonDTO) iteratorVotingPersons
- .next());
+ for (VotingPersonDTO votingPersonDTO : group.getVotingPersons()) {
+ Element votingPersonElm = save(votingPersonDTO);
votingPersonsElm.addContent(votingPersonElm);
}
groupElm.addContent(votingPersonsElm);
@@ -259,7 +245,7 @@
votingPersonElm.setAttribute("votingId", votingPerson.getVotingId());
votingPersonElm.setAttribute("weight", Double.toString(votingPerson
- .getWeight()));
+ .getWeight()));
Element emailElm = new Element("email");
emailElm.setText(votingPerson.getEmail());
@@ -271,14 +257,11 @@
Element choicesElm = new Element("choices");
- Iterator iteratorChoices = votingPerson.getChoices().listIterator();
- while (iteratorChoices.hasNext()) {
- VoteToChoiceDTO voteToChoice = (VoteToChoiceDTO) iteratorChoices
- .next();
+ for (VoteToChoiceDTO voteToChoice : votingPerson.getChoices()) {
Element choiceElm = new Element("choice");
choiceElm.setAttribute("idChoice", voteToChoice.getIdChoice());
choiceElm.setAttribute("value", Double.toString(voteToChoice
- .getValue()));
+ .getValue()));
choicesElm.addContent(choiceElm);
}
@@ -323,10 +306,8 @@
Element choicesElm = new Element("choices");
- Iterator iteratorChoices = voteCountingResults.getChoices()
- .listIterator();
- while (iteratorChoices.hasNext()) {
- Element choiceElm = save((ChoiceDTO) iteratorChoices.next());
+ for (ChoiceDTO choiceDTO : voteCountingResults.getChoices()) {
+ Element choiceElm = save(choiceDTO);
choicesElm.addContent(choiceElm);
}
@@ -371,7 +352,7 @@
sortie.output(document, new FileOutputStream(file));
} catch (java.io.IOException e) {
log.error("Erreur lors de l'enregistrement du document : "
- + filePath, e);
+ + filePath, e);
}
}
@@ -391,25 +372,25 @@
poll.setCreatorId(pollElm.getChild("creatorId").getText());
poll.setCreatorEmail(pollElm.getChild("creatorEmail").getText());
poll.setMaxChoiceNb(Integer.parseInt(pollElm.getChild("maxChoiceNb")
- .getText()));
+ .getText()));
poll.setPollType(PollType
- .valueOf(pollElm.getAttributeValue("pollType")));
+ .valueOf(pollElm.getAttributeValue("pollType")));
poll.setChoiceType(ChoiceType.valueOf(pollElm
- .getAttributeValue("choiceType")));
+ .getAttributeValue("choiceType")));
poll.setVoteCounting(VoteCountingType.valueOf(pollElm
- .getAttributeValue("voteCounting")));
+ .getAttributeValue("voteCounting")));
poll.setClosed(Boolean.valueOf(pollElm.getAttributeValue("closed")));
poll.setChoiceAddAllowed(Boolean.valueOf(pollElm
- .getAttributeValue("choiceAddAllowed")));
+ .getAttributeValue("choiceAddAllowed")));
poll.setAnonymousVoteAllowed(Boolean.valueOf(pollElm
- .getAttributeValue("anonymousVoteAllowed")));
+ .getAttributeValue("anonymousVoteAllowed")));
poll.setAnonymous(Boolean.valueOf(pollElm
- .getAttributeValue("anonymous")));
+ .getAttributeValue("anonymous")));
poll.setPublicResults(Boolean.valueOf(pollElm
- .getAttributeValue("publicResults")));
+ .getAttributeValue("publicResults")));
poll.setContinuousResults(Boolean.valueOf(pollElm
- .getAttributeValue("continuousResults")));
+ .getAttributeValue("continuousResults")));
// Ajout des commentaires
Element commentsElm = pollElm.getChild("comments");
@@ -451,11 +432,10 @@
private List loadComments(List<Element> listComments) {
List vectorComments = new ArrayList<CommentDTO>();
- Iterator i = listComments.listIterator();
- while (i.hasNext()) {
- Element commentElm = (Element) i.next();
- CommentDTO comment = new CommentDTO(commentElm
- .getAttributeValue("votingId"), commentElm.getText());
+ for (Element commentElm : listComments) {
+ CommentDTO comment = new CommentDTO(
+ commentElm.getAttributeValue("votingId"),
+ commentElm.getText());
vectorComments.add(comment);
}
@@ -465,12 +445,10 @@
private List loadGroups(List<Element> listGroups) {
List vectorGroups = new ArrayList<VotingGroupDTO>();
- Iterator i = listGroups.listIterator();
- while (i.hasNext()) {
- Element groupElm = (Element) i.next();
- VotingGroupDTO group = new VotingGroupDTO(groupElm
- .getAttributeValue("idGroup"), Double.parseDouble((groupElm
- .getAttributeValue("weight"))));
+ for (Element groupElm : listGroups) {
+ VotingGroupDTO group = new VotingGroupDTO(
+ groupElm.getAttributeValue("idGroup"),
+ Double.parseDouble((groupElm.getAttributeValue("weight"))));
group.setName(groupElm.getAttributeValue("name"));
@@ -490,16 +468,14 @@
private List loadVotingPersons(List<Element> listVotingPersons) {
List vectorVotingPersons = new ArrayList<VotingPersonDTO>();
- Iterator i = listVotingPersons.listIterator();
- while (i.hasNext()) {
- Element votingPersonElm = (Element) i.next();
- VotingPersonDTO votingPerson = new VotingPersonDTO(votingPersonElm
- .getAttributeValue("votingId"), Double
+ for (Element votingPersonElm : listVotingPersons) {
+ VotingPersonDTO votingPerson = new VotingPersonDTO(
+ votingPersonElm.getAttributeValue("votingId"), Double
.parseDouble((votingPersonElm.getAttributeValue("weight"))));
votingPerson.setEmail(votingPersonElm.getChild("email").getValue());
- votingPerson.setComment(votingPersonElm.getChild("comment")
- .getValue());
+ votingPerson.setComment(
+ votingPersonElm.getChild("comment").getValue());
Element choicesElm = votingPersonElm.getChild("choices");
@@ -516,12 +492,9 @@
private List loadVoteToChoices(List<Element> listVoteToChoices) {
List vectorVoteToChoices = new ArrayList<VotingPersonDTO>();
- Iterator i = listVoteToChoices.listIterator();
- while (i.hasNext()) {
- Element voteToChoiceElm = (Element) i.next();
-
- VoteToChoiceDTO voteToChoice = new VoteToChoiceDTO(voteToChoiceElm
- .getAttributeValue("idChoice"), Double
+ for (Element voteToChoiceElm : listVoteToChoices) {
+ VoteToChoiceDTO voteToChoice = new VoteToChoiceDTO(
+ voteToChoiceElm.getAttributeValue("idChoice"), Double
.parseDouble(voteToChoiceElm.getAttributeValue("value")));
vectorVoteToChoices.add(voteToChoice);
}
@@ -532,19 +505,17 @@
private List loadPollChoices(List<Element> listPollChoices) {
List vectorPollChoices = new ArrayList<PollChoiceDTO>();
- Iterator i = listPollChoices.listIterator();
- while (i.hasNext()) {
- Element pollChoiceElm = (Element) i.next();
- PollChoiceDTO pollChoice = new PollChoiceDTO(pollChoiceElm
- .getAttributeValue("idChoice"));
+ for (Element pollChoiceElm : listPollChoices) {
+ PollChoiceDTO pollChoice = new PollChoiceDTO(
+ pollChoiceElm.getAttributeValue("idChoice"));
String pollChoiceName = pollChoiceElm.getChild("name").getValue();
pollChoice.setName(pollChoiceName);
pollChoice.setHidden(pollChoiceName != null
- && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
- pollChoice.setDescription(pollChoiceElm.getChild("description")
- .getValue());
+ pollChoice.setDescription(
+ pollChoiceElm.getChild("description").getValue());
vectorPollChoices.add(pollChoice);
}
@@ -555,20 +526,18 @@
private List loadVoteCountingResults(List<Element> listVoteCountingResults) {
List vectorVoteCountingResults = new ArrayList<VoteCountingResultDTO>();
- Iterator i = listVoteCountingResults.listIterator();
- while (i.hasNext()) {
- Element voteCountingResultElm = (Element) i.next();
+ for (Element voteCountingResultElm : listVoteCountingResults) {
VoteCountingResultDTO voteCountingResult = new VoteCountingResultDTO();
- voteCountingResult.setIdPoll(voteCountingResultElm
- .getAttributeValue("idPoll"));
- voteCountingResult.setNbVotes(Integer
- .parseInt(voteCountingResultElm.getChild("nbVotes")
- .getValue()));
+ voteCountingResult.setIdPoll(
+ voteCountingResultElm.getAttributeValue("idPoll"));
+ voteCountingResult.setNbVotes(
+ Integer.parseInt(voteCountingResultElm.getChild("nbVotes")
+ .getValue()));
voteCountingResult.setChoiceResult(voteCountingResultElm.getChild(
"choiceResult").getValue());
- voteCountingResult.setByGroup(Boolean
- .parseBoolean((voteCountingResultElm.getChild("isByGroup")
- .getValue())));
+ voteCountingResult.setByGroup(
+ Boolean.parseBoolean(
+ voteCountingResultElm.getChild("isByGroup").getValue()));
Element choicesElm = voteCountingResultElm.getChild("choices");
List<Element> listChoices = choicesElm.getChildren("choice");
@@ -583,14 +552,12 @@
private List loadChoices(List<Element> listChoices) {
List vectorChoices = new ArrayList<ChoiceDTO>();
- Iterator i = listChoices.listIterator();
- while (i.hasNext()) {
- Element choiceElm = (Element) i.next();
- ChoiceDTO choice = new ChoiceDTO(choiceElm.getAttribute("idChoice")
- .getName(), Double.parseDouble(choiceElm.getAttribute(
- "value").getValue()), Double.parseDouble(choiceElm
- .getChild("percentage").getValue()), Integer
- .parseInt((choiceElm.getChild("nbVotes").getValue())));
+ for (Element choiceElm : listChoices) {
+ ChoiceDTO choice = new ChoiceDTO(
+ choiceElm.getAttribute("idChoice").getName(),
+ Double.parseDouble(choiceElm.getAttribute("value").getValue()),
+ Double.parseDouble(choiceElm.getChild("percentage").getValue()),
+ Integer.parseInt((choiceElm.getChild("nbVotes").getValue())));
vectorChoices.add(choice);
}
1
0
r3414 - in trunk: 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 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:40:52 +0200 (Sun, 03 Jun 2012)
New Revision: 3414
Url: http://chorem.org/repositories/revision/pollen/3414
Log:
fixes #578: Add a feed entry when a comment is removed + ask user a reason for this deletion
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -91,8 +91,8 @@
// feed notification
PollService pollService = newService(PollService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
PollFeedService pollFeedService = newService(PollFeedService.class);
pollFeedService.onAddComment(commentCreated, pollVoteUrl);
@@ -102,8 +102,11 @@
}
}
- public void deleteComment(String commentId) throws PollCommentNotFound {
+ public void deleteComment(Poll poll,
+ String commentId,
+ String reason) throws PollCommentNotFound {
+ Preconditions.checkNotNull(poll);
Preconditions.checkNotNull(commentId);
CommentDAO dao = getDAO(Comment.class);
@@ -120,6 +123,14 @@
commitTransaction("Could not delete comment " + comment.getText());
+ // feed notification
+
+ PollService pollService = newService(PollService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onDeleteComment(comment, pollVoteUrl, reason);
+
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -127,6 +127,19 @@
addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
}
+ public void onDeleteComment(Comment comment,
+ PollUrl pollVoteUrl,
+ String reason) {
+
+ String title = _("pollen.feed.deleteCommentTitle",
+ comment.getAuthor());
+
+ String content = _("pollen.feed.deleteCommentContent",
+ comment.getText(), reason);
+
+ addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ }
+
public void onAddVote(Vote vote,
boolean anonymousVote,
String pollResult,
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -34,6 +34,8 @@
pollen.feed.addVoteContent=
pollen.feed.addVoteTitle=
pollen.feed.createPollContent=
+pollen.feed.deleteCommentContent=%s
+pollen.feed.deleteCommentTitle=Delete comment of %s for reason '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Super admin was created with login %1$s
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -34,6 +34,8 @@
pollen.feed.addVoteContent=
pollen.feed.addVoteTitle=
pollen.feed.createPollContent=
+pollen.feed.deleteCommentContent=%s
+pollen.feed.deleteCommentTitle=Suppression du commentaire de %s pour la raison '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -25,8 +25,11 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Comment;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.exceptions.PollCommentNotFound;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollCommentService;
+import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a comment delete.
@@ -59,6 +62,14 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
+ PollService pollService = newService(PollService.class);
+
+ Poll poll = pollService.getPollByPollId(getPollId());
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+
PollCommentService service = newService(PollCommentService.class);
comment = service.getEntityById(Comment.class, commentId);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -26,8 +26,11 @@
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.chorem.pollen.business.persistence.Comment;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.exceptions.PollCommentNotFound;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollCommentService;
+import org.chorem.pollen.services.impl.PollService;
/**
* To delete a poll comment.
@@ -42,14 +45,33 @@
/** Id of the comment to delete. */
protected String commentId;
+ /**
+ * Reason for deleting this comment (if any).
+ *
+ * @since 1.4
+ */
+ protected String reason;
+
public void setCommentId(String commentId) {
this.commentId = commentId;
}
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
@InputConfig(methodName = "prepareVotePage")
@Override
public String execute() throws Exception {
+ PollService pollService = newService(PollService.class);
+
+ Poll poll = pollService.getPollByPollId(getPollId());
+
+ if (poll==null) {
+ throw new PollNotFoundException();
+ }
+
Preconditions.checkNotNull(commentId);
PollCommentService service = newService(PollCommentService.class);
@@ -60,10 +82,8 @@
throw new PollCommentNotFound();
}
- setUriId(getUriId());
+ service.deleteComment(poll, commentId, reason);
- service.deleteComment(commentId);
-
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -25,6 +25,7 @@
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
+pollen.common.deleteReason=Reason for delete
pollen.action.importPersonListToExistingVotingList=Add selected voting list
pollen.action.importPersonListToNewVotingList=Create a new group from the selected voting list
pollen.action.login=Log me In
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -24,6 +24,7 @@
pollen.action.editPoll=Modifier le sondage
pollen.action.editPollAccount=Editer le membre sélectionné
pollen.action.editUser=Editer un utilisateur sélectionné
+pollen.common.deleteReason=Raison de suppression
pollen.action.editVote=Modifier le vote
pollen.action.importPersonListToExistingVotingList=Ajouter la liste sélectionnée de votants
pollen.action.importPersonListToNewVotingList=Créer un groupe à partir de la liste sélectionnée
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-03 09:40:52 UTC (rev 3414)
@@ -38,6 +38,9 @@
<s:textarea key='comment.text' readonly="true" rows="3"
label="%{getText('pollen.common.commentText')}"/>
+ <s:textarea key='reason' rows="3" required="true"
+ label="%{getText('pollen.common.deleteReason')}"/>
+
<hr/>
<div align="right">
1
0
r3413 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:15:13 +0200 (Sun, 03 Jun 2012)
New Revision: 3413
Url: http://chorem.org/repositories/revision/pollen/3413
Log:
refs #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 null (migration failed)
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:06:20 UTC (rev 3412)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:15:13 UTC (rev 3413)
@@ -86,14 +86,18 @@
for (String voteId : voteIds) {
// get voteToChoice for this vote
- VoteToChoice voteToChoice =
- new GetVoteToChoiceSQLQuery(voteId).findSingleResult(tx);
+ List<VoteToChoice> voteToChoices =
+ new GetVoteToChoiceSQLQuery(voteId).findMultipleResult(tx);
- if (voteToChoice!=null && voteToChoice.getVoteValue() <= 0) {
+ for (VoteToChoice voteToChoice : voteToChoices) {
- // delete this vote
+ if (voteToChoice != null && voteToChoice.getVoteValue() <= 0) {
- queries.add("DELETE FROM votetochoice where topiaid ='" + voteToChoice.getTopiaId() + "';");
+ // delete this vote
+
+ queries.add("DELETE FROM votetochoice where topiaid ='" +
+ voteToChoice.getTopiaId() + "';");
+ }
}
}
}
1
0
r3412 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:06:20 +0200 (Sun, 03 Jun 2012)
New Revision: 3412
Url: http://chorem.org/repositories/revision/pollen/3412
Log:
refs #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 null (migration failed)
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 08:42:32 UTC (rev 3411)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:06:20 UTC (rev 3412)
@@ -89,7 +89,7 @@
VoteToChoice voteToChoice =
new GetVoteToChoiceSQLQuery(voteId).findSingleResult(tx);
- if (voteToChoice.getVoteValue() <= 0) {
+ if (voteToChoice!=null && voteToChoice.getVoteValue() <= 0) {
// delete this vote
1
0
Author: tchemit
Date: 2012-06-03 10:42:32 +0200 (Sun, 03 Jun 2012)
New Revision: 3411
Url: http://chorem.org/repositories/revision/pollen/3411
Log:
fixes #574: Mauvais d?\195?\169pouillement Vote Condorcet
fixes #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 "null"
Added:
trunk/pollen-ui-struts2/src/test/
trunk/pollen-ui-struts2/src/test/java/
trunk/pollen-ui-struts2/src/test/java/org/
trunk/pollen-ui-struts2/src/test/java/org/chorem/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
trunk/pollen-ui-struts2/pom.xml
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -1,9 +1,9 @@
/*
* #%L
* Pollen :: Persistence
- *
- * $Id: PollenMigrationCallbackV1_3_1.java 3407 2012-05-28 17:06:39Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * *
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
@@ -11,12 +11,12 @@
* 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%
@@ -72,7 +72,7 @@
@Override
protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- PreparedStatement ps = connection.prepareStatement("select topiaid from vote where topiaid in (select topiaid from poll where votecountingtype=2);");
+ PreparedStatement ps = connection.prepareStatement("select topiaid from vote where poll in (select topiaid from poll where votecountingtype=2);");
return ps;
}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/pom.xml 2012-06-03 08:42:32 UTC (rev 3411)
@@ -179,6 +179,11 @@
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -34,7 +34,6 @@
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.common.VoteCountingType;
/**
* Votes to a poll.
@@ -100,6 +99,10 @@
// see http://chorem.org/issues/576
nbVotes++;
totalValues += value;
+ } else {
+
+ // otherwise does not take account of this choice
+ voteToChoice.setVoteValue(null);
}
// for other vote type, value must be > 0
} else if (value != 0) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.ui.converters;
+import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.util.StrutsTypeConverter;
import java.util.Map;
@@ -48,7 +49,9 @@
protected Integer parseValue(String value) {
Integer result;
- if ("true".equals(value)) {
+ if (StringUtils.isEmpty(value)) {
+ result = null;
+ } else if ("true".equals(value)) {
result = 1;
} else if ("false".equals(value)) {
Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java (rev 0)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -0,0 +1,57 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $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.converters;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+/**
+ * Tests the {@link BooleanIntegerConverter}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class BooleanIntegerConverterTest {
+
+ @Test
+ public void testConvertFromString() throws Exception {
+
+ BooleanIntegerConverter converter = new BooleanIntegerConverter();
+
+ convertFromString(null, null, converter);
+ convertFromString("", null, converter);
+ convertFromString("0", 0, converter);
+ convertFromString("1", 1, converter);
+ convertFromString("-1", -1, converter);
+ convertFromString("false", 0, converter);
+ convertFromString("true", 1, converter);
+ }
+
+ protected void convertFromString(String valueToConvert,
+ Integer expected,
+ BooleanIntegerConverter converter) {
+ Integer actual = converter.convertFromString(
+ null, new String[]{valueToConvert}, Integer.class);
+ Assert.assertEquals(expected, actual);
+ }
+}
Property changes on: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
01 Jun '12
Author: tchemit
Date: 2012-06-01 12:04:08 +0200 (Fri, 01 Jun 2012)
New Revision: 3410
Url: http://chorem.org/repositories/revision/pollen/3410
Log:
updates to nuiton-utils 2.4.9 + use aggregate application config report
Modified:
trunk/pollen-ui-struts2/pom.xml
trunk/pom.xml
trunk/src/site/rst/configure.rst
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-06-01 10:03:18 UTC (rev 3409)
+++ trunk/pollen-ui-struts2/pom.xml 2012-06-01 10:04:08 UTC (rev 3410)
@@ -197,7 +197,7 @@
<properties>
<i18n.silent>true</i18n.silent>
- <i18n.bundleOutputName>pollen-i18n</i18n.bundleOutputName>
+ <i18n.bundleOutputName>${pollenI18nBundle}</i18n.bundleOutputName>
<redmine.releaseFiles>
target/${project.build.finalName}.war,
@@ -440,36 +440,6 @@
</build>
</profile>
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils-maven-report-plugin</artifactId>
- <version>${nuitonUtilsVersion}</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>application-config-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <i18nBundleName>${i18n.bundleOutputName}</i18nBundleName>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- </profile>
-
</profiles>
</project>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-01 10:03:18 UTC (rev 3409)
+++ trunk/pom.xml 2012-06-01 10:04:08 UTC (rev 3410)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -181,7 +183,7 @@
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<nuitonWebVersion>1.11</nuitonWebVersion>
- <nuitonUtilsVersion>2.4.8</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.4.9-SNAPSHOT</nuitonUtilsVersion>
<h2Version>1.3.167</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
<struts2Version>2.3.4</struts2Version>
@@ -190,6 +192,7 @@
<slf4jVersion>1.6.4</slf4jVersion>
<jettyVersion>${jettyPluginVersion}</jettyVersion>
+ <pollenI18nBundle>pollen-i18n</pollenI18nBundle>
<!-- license to use -->
<license.licenseName>agpl_v3</license.licenseName>
@@ -601,14 +604,18 @@
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>l10n-maven-plugin</artifactId>
- <version>${l10nPluginVersion}</version>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils-maven-report-plugin</artifactId>
+ <version>${nuitonUtilsVersion}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>aggregate-application-config-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
<configuration>
- <locales>
- <locale>fr_FR</locale>
- <locale>en_GB</locale>
- </locales>
+ <i18nBundleName>${pollenI18nBundle}</i18nBundleName>
</configuration>
</plugin>
Modified: trunk/src/site/rst/configure.rst
===================================================================
--- trunk/src/site/rst/configure.rst 2012-06-01 10:03:18 UTC (rev 3409)
+++ trunk/src/site/rst/configure.rst 2012-06-01 10:04:08 UTC (rev 3410)
@@ -96,4 +96,4 @@
| MySql | org.hibernate.dialect.MySQLDialect | com.mysql.jdbc.Driver | jdbc:mysql:pollen |
+-------------------------+------------------------------------------+-----------------------------------+------------------------------------------+
-.. _options page: ./pollen-ui-struts2/application-config-report.html
\ No newline at end of file
+.. _options page: ./application-config-report.html
\ No newline at end of file
1
0
r3409 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 01 Jun '12
by tchemit@users.chorem.org 01 Jun '12
01 Jun '12
Author: tchemit
Date: 2012-06-01 12:03:18 +0200 (Fri, 01 Jun 2012)
New Revision: 3409
Url: http://chorem.org/repositories/revision/pollen/3409
Log:
fixes #574: Mauvais d?\195?\169pouillement Vote Condorcet
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 09:42:49 UTC (rev 3408)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 10:03:18 UTC (rev 3409)
@@ -72,7 +72,7 @@
@Override
protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- PreparedStatement ps = connection.prepareStatement("select topiaid from vote where vote in (select topiaid from poll where votecountingtype=2);");
+ PreparedStatement ps = connection.prepareStatement("select topiaid from vote where topiaid in (select topiaid from poll where votecountingtype=2);");
return ps;
}
1
0
r3408 - in trunk: . pollen-persistence/src/main/java/org/chorem/pollen/entities/migration pollen-persistence/src/main/resources/META-INF/services pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 01 Jun '12
by tchemit@users.chorem.org 01 Jun '12
01 Jun '12
Author: tchemit
Date: 2012-06-01 11:42:49 +0200 (Fri, 01 Jun 2012)
New Revision: 3408
Url: http://chorem.org/repositories/revision/pollen/3408
Log:
using topia 2.6.11 (use new migration mode)
fixes #574: Mauvais d?\195?\169pouillement Vote Condorcet
fixes #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 "null"
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_1.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_2.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pom.xml
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -24,7 +24,7 @@
package org.chorem.pollen.entities.migration;
import org.chorem.pollen.entities.PollenDAOHelper;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
@@ -36,29 +36,31 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class PollenMigrationCallback extends TopiaMigrationCallbackByClass {
+public class PollenMigrationCallback extends TopiaMigrationCallbackByClassNG {
- public static final Version V_1_1 = VersionUtil.valueOf("1.1");
+// public static final Version V_1_1 = VersionUtil.valueOf("1.1");
+//
+// public static final Version V_1_2 = VersionUtil.valueOf("1.2");
+//
+// public static final Version V_1_3 = VersionUtil.valueOf("1.3");
+//
+// public static final Version V_1_3_1 = VersionUtil.valueOf("1.3.1");
+//
+// public static final Version V_1_4 = VersionUtil.valueOf("1.4");
- public static final Version V_1_2 = VersionUtil.valueOf("1.2");
+// /** Les versions de mise à jour disponibles. */
+// public static final Version[] AVAILABLE_VERSIONS = new Version[]{
+// V_1_1, V_1_2, V_1_3, V_1_3_1, V_1_4
+// };
- public static final Version V_1_3 = VersionUtil.valueOf("1.3");
-
- public static final Version V_1_3_1 = VersionUtil.valueOf("1.3.1");
-
- /** Les versions de mise à jour disponibles. */
- public static final Version[] AVAILABLE_VERSIONS = new Version[]{
- V_1_1, V_1_2, V_1_3, V_1_3_1
- };
-
public PollenMigrationCallback() {
- super(new PollenMigrationCallBackForVersionResolver());
+ super(new MigrationCallBackForVersionResolverByServiceLoader());
}
- @Override
- public Version[] getAvailableVersions() {
- return AVAILABLE_VERSIONS;
- }
+// @Override
+// public Version[] getAvailableVersions() {
+// return AVAILABLE_VERSIONS;
+// }
@Override
public Version getApplicationVersion() {
@@ -70,26 +72,26 @@
return true;
}
- /**
- * Migration resolver for each version.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.1
- */
- public static class PollenMigrationCallBackForVersionResolver implements MigrationCallBackForVersionResolver {
-
- @Override
- public Class<? extends MigrationCallBackForVersion> getCallBack(Version version) {
-
- String fqn = PollenMigrationCallback.class.getName() + "V" + version.getValidName();
- Class<?> klass;
- try {
- klass = Class.forName(fqn);
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(
- "Could not find migration class " + fqn, e);
- }
- return (Class<? extends MigrationCallBackForVersion>) klass;
- }
- }
+// /**
+// * Migration resolver for each version.
+// *
+// * @author tchemit <chemit(a)codelutin.com>
+// * @since 1.0.1
+// */
+// public static class PollenMigrationCallBackForVersionResolver implements MigrationCallBackForVersionResolver {
+//
+// @Override
+// public Class<? extends MigrationCallBackForVersion> getCallBack(Version version) {
+//
+// String fqn = PollenMigrationCallback.class.getName() + "V" + version.getValidName();
+// Class<?> klass;
+// try {
+// klass = Class.forName(fqn);
+// } catch (ClassNotFoundException e) {
+// throw new IllegalStateException(
+// "Could not find migration class " + fqn, e);
+// }
+// return (Class<? extends MigrationCallBackForVersion>) klass;
+// }
+// }
}
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_1.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_1.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_1.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -28,7 +28,9 @@
import org.hibernate.dialect.PostgreSQLDialect;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
import java.util.Arrays;
import java.util.List;
@@ -39,10 +41,11 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class PollenMigrationCallbackV1_1 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
+public class PollenMigrationCallbackV1_1 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- public PollenMigrationCallbackV1_1(TopiaMigrationCallbackByClass callBack) {
- super(PollenMigrationCallback.V_1_1, callBack);
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.1");
}
@Override
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_2.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_2.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_2.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -28,7 +28,9 @@
import org.hibernate.dialect.PostgreSQLDialect;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
import java.util.Arrays;
import java.util.List;
@@ -39,10 +41,11 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class PollenMigrationCallbackV1_2 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
+public class PollenMigrationCallbackV1_2 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- public PollenMigrationCallbackV1_2(TopiaMigrationCallbackByClass callBack) {
- super(PollenMigrationCallback.V_1_2, callBack);
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.2");
}
@Override
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -33,7 +33,9 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaSQLQuery;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -48,10 +50,11 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class PollenMigrationCallbackV1_3 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
+public class PollenMigrationCallbackV1_3 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- public PollenMigrationCallbackV1_3(TopiaMigrationCallbackByClass callBack) {
- super(PollenMigrationCallback.V_1_3, callBack);
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.3");
}
@Override
@@ -60,14 +63,6 @@
boolean showSql,
boolean showProgression) throws TopiaException {
-// Dialect dialect =
-// Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
-//
-// if (dialect instanceof PostgreSQLDialect) {
-//
-// } else if (dialect instanceof H2Dialect) {
-// }
-
// change choice type to use enumeration
migrateChoiceTypes(tx, queries);
@@ -86,11 +81,11 @@
// add author column for Comment
addCommentAuthorColumn(queries);
}
-
+
private void addCommentAuthorColumn(List<String> queries) {
queries.add("ALTER TABLE comment ADD COLUMN author VARCHAR(255);");
-
+
queries.add("UPDATE comment AS c SET author = (SELECT p.votingId FROM pollAccount p WHERE c.pollAccount = p.topiaId);");
queries.add("ALTER TABLE comment ALTER COLUMN author TYPE VARCHAR(255);");
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -26,7 +26,9 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaSQLQuery;
-import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -40,10 +42,11 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3.1
*/
-public class PollenMigrationCallbackV1_3_1 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
+public class PollenMigrationCallbackV1_3_1 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- public PollenMigrationCallbackV1_3_1(TopiaMigrationCallbackByClass callBack) {
- super(PollenMigrationCallback.V_1_3_1, callBack);
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.3.1");
}
@Override
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -0,0 +1,125 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id: PollenMigrationCallbackV1_3_1.java 3407 2012-05-28 17:06:39Z tchemit $
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * %%
+ * 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.entities.migration;
+
+import org.chorem.pollen.business.persistence.VoteToChoice;
+import org.chorem.pollen.business.persistence.VoteToChoiceImpl;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * Migration for version {@code 1.4}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class PollenMigrationCallbackV1_4 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
+
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.4");
+ }
+
+ @Override
+ protected void prepareMigrationScript(TopiaContextImplementor tx,
+ List<String> queries,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ // remove all votes of condorcet type with a null value (<=0)
+ // see http://chorem.org/issues/574
+ // see http://chorem.org/issues/576
+ removeAllCondorcetNullVotes(tx, queries);
+ }
+
+ private void removeAllCondorcetNullVotes(TopiaContextImplementor tx,
+ List<String> queries) throws TopiaException {
+
+ // get all votes from all polls with votecountingtype = 2 (condorcet)
+
+ TopiaSQLQuery<String> getAllVotesQuery = new TopiaSQLQuery<String>() {
+
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement("select topiaid from vote where vote in (select topiaid from poll where votecountingtype=2);");
+ return ps;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ };
+ List<String> voteIds = getAllVotesQuery.findMultipleResult(tx);
+
+ for (String voteId : voteIds) {
+
+ // get voteToChoice for this vote
+ VoteToChoice voteToChoice =
+ new GetVoteToChoiceSQLQuery(voteId).findSingleResult(tx);
+
+ if (voteToChoice.getVoteValue() <= 0) {
+
+ // delete this vote
+
+ queries.add("DELETE FROM votetochoice where topiaid ='" + voteToChoice.getTopiaId() + "';");
+ }
+ }
+ }
+
+ private static class GetVoteToChoiceSQLQuery extends TopiaSQLQuery<VoteToChoice> {
+
+ private final String voteId;
+
+ public GetVoteToChoiceSQLQuery(String voteId) {
+ this.voteId = voteId;
+ }
+
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement(
+ "SELECT topiaid, votevalue FROM votetochoice WHERE vote = ?;");
+ ps.setString(1, voteId);
+ return ps;
+ }
+
+ @Override
+ protected VoteToChoice prepareResult(ResultSet set) throws SQLException {
+ VoteToChoice result = new VoteToChoiceImpl();
+ result.setTopiaId(set.getString(1));
+ result.setVoteValue(set.getInt(2));
+ return result;
+ }
+ }
+}
Added: trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
===================================================================
--- trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion (rev 0)
+++ trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion 2012-06-01 09:42:49 UTC (rev 3408)
@@ -0,0 +1,5 @@
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_1
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_2
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_3
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_3_1
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_4
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-01 09:42:49 UTC (rev 3408)
@@ -34,6 +34,7 @@
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
/**
* Votes to a poll.
@@ -81,14 +82,27 @@
}
}
-
int nbVotes = 0;
int totalValues = 0;
for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) {
Integer value = voteToChoice.getVoteValue();
+ if (value == null) {
+ // not vote
+ continue;
+ }
// XXX-fdesbois-2012-04-11 : for a VoteCountingType#NUMBER the difference between 0 and null value could be important
- if (value != null && value != 0) {
+ if (isCondorcetVoteCounting()) {
+ if (value > 0) {
+
+ // for condorcet vote, must be strictly greater than 0
+ // see http://chorem.org/issues/574
+ // see http://chorem.org/issues/576
+ nbVotes++;
+ totalValues += value;
+ }
+ // for other vote type, value must be > 0
+ } else if (value != 0) {
nbVotes++;
totalValues += value;
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-28 17:06:39 UTC (rev 3407)
+++ trunk/pom.xml 2012-06-01 09:42:49 UTC (rev 3408)
@@ -176,7 +176,7 @@
<projectId>pollen</projectId>
<!-- customized versions -->
- <topiaVersion>2.6.10</topiaVersion>
+ <topiaVersion>2.6.11-SNAPSHOT</topiaVersion>
<eugenePluginVersion>2.4.2</eugenePluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
1
0
r3407 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 28 May '12
by tchemit@users.chorem.org 28 May '12
28 May '12
Author: tchemit
Date: 2012-05-28 19:06:39 +0200 (Mon, 28 May 2012)
New Revision: 3407
Url: http://chorem.org/repositories/revision/pollen/3407
Log:
fix misc errors
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java 2012-05-28 16:53:09 UTC (rev 3406)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3_1.java 2012-05-28 17:06:39 UTC (rev 3407)
@@ -35,10 +35,10 @@
import java.util.List;
/**
- * Migration for version {@code 1.4}.
+ * Migration for version {@code 1.3.1}.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.4
+ * @since 1.3.1
*/
public class PollenMigrationCallbackV1_3_1 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
@@ -54,7 +54,6 @@
// add indexed choices (says there is an order kept in db) : http://chorem.org/issues/154
addIndexedChoices(tx, queries);
-
}
private void addIndexedChoices(TopiaContextImplementor tx,
1
0